first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

20
node_modules/simple-plist/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Joe Wollard
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

130
node_modules/simple-plist/README.md generated vendored Normal file
View File

@@ -0,0 +1,130 @@
# `simple-plist`
[![npm](https://img.shields.io/npm/dw/simple-plist.svg?style=popout&logo=npm)](https://www.npmjs.org/package/simple-plist)
[![npm](https://img.shields.io/npm/v/simple-plist.svg?style=popout&logo=npm)](https://www.npmjs.com/package/simple-plist)
A simple API for interacting with binary and plain text
[plist](https://en.wikipedia.org/wiki/Property_list) data.
## Installation
```sh
# via npm
npm install simple-plist
# via yarn
yarn add simple-plist
```
## Synchronous API
```js
const plist = require("simple-plist");
let data;
// read
data = plist.readFileSync("/path/to/some.plist");
// write xml
plist.writeFileSync("/path/to/plaintext.plist", data);
// write binary
plist.writeBinaryFileSync("/path/to/binary.plist", data);
```
## Asynchronous API
> Note: all of the async examples can optionally be converted to promises using
> node's [`util.promisify`](https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_promisify_original).
```js
const plist = require("simple-plist");
let data;
function callback(err, contents) {
if (err) throw err;
data = contents;
}
// read
plist.readFile("/path/to/some.plist", callback);
// write xml
plist.writeFile("/path/to/plaintext.plist", data, callback);
// write binary
plist.writeBinaryFile("/path/to/binary.plist", data, callback);
```
## In Memory
### `plist.stringify()`
```js
const plist = require("simple-plist");
// Convert an object to a plist xml string
plist.stringify({ name: "Joe", answer: 42 });
/*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Joe</string>
<key>answer</key>
<integer>42</integer>
</dict>
</plist>
*/
```
### `plist.parse()`
```js
const plist = require("simple-plist");
const xml = `<plist>
<dict>
<key>name</key>
<string>Joe</string>
</dict>
</plist>`;
plist.parse(xml);
// { "name": "Joe" }
```
## TypeScript Support
All functions have typescript signatures, but there are a few handy generics
that are worth pointing out. Those generics belong to `parse`, `readFile`,
and `readFileSync`. Here's an example:
```tsx
import { parse, readFile, readFileSync } from "simple-plist";
type Profile = {
name: string;
answer: number;
};
const xml = `<plist>
<dict>
<key>name</key>
<string>Joe</string>
<key>answer</key>
<integer>42</integer>
</dict>
</plist>`;
// typed string parsing
const { answer } = parse<Profile>(xml);
// answer = 42;
// typed file loading
const { name } = readFileSync<Profile>("/path/to/profile.plist");
```

24
node_modules/simple-plist/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import bplistCreator from "bplist-creator";
import bplistParser from "bplist-parser";
import { parse } from "./parse";
import { readFile } from "./readFile";
import { readFileSync } from "./readFileSync";
import { stringify } from "./stringify";
import { writeBinaryFile } from "./writeBinaryFile";
import { writeBinaryFileSync } from "./writeBinaryFileSync";
import { writeFile } from "./writeFile";
import { writeFileSync } from "./writeFileSync";
declare const SimplePlist: {
bplistCreator: bplistCreator;
bplistParser: bplistParser;
parse: typeof parse;
readFile: typeof readFile;
readFileSync: typeof readFileSync;
stringify: typeof stringify;
writeBinaryFile: typeof writeBinaryFile;
writeBinaryFileSync: typeof writeBinaryFileSync;
writeFile: typeof writeFile;
writeFileSync: typeof writeFileSync;
};
export default SimplePlist;
export type { callbackFn, PlistJsObj, StringOrBuffer } from "./types";

41
node_modules/simple-plist/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "bplist-creator", "bplist-parser", "./parse", "./readFile", "./readFileSync", "./stringify", "./writeBinaryFile", "./writeBinaryFileSync", "./writeFile", "./writeFileSync"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bplist_creator_1 = __importDefault(require("bplist-creator"));
var bplist_parser_1 = __importDefault(require("bplist-parser"));
var parse_1 = require("./parse");
var readFile_1 = require("./readFile");
var readFileSync_1 = require("./readFileSync");
var stringify_1 = require("./stringify");
var writeBinaryFile_1 = require("./writeBinaryFile");
var writeBinaryFileSync_1 = require("./writeBinaryFileSync");
var writeFile_1 = require("./writeFile");
var writeFileSync_1 = require("./writeFileSync");
// "modern" named exports
var SimplePlist = {
bplistCreator: bplist_creator_1.default,
bplistParser: bplist_parser_1.default,
parse: parse_1.parse,
readFile: readFile_1.readFile,
readFileSync: readFileSync_1.readFileSync,
stringify: stringify_1.stringify,
writeBinaryFile: writeBinaryFile_1.writeBinaryFile,
writeBinaryFileSync: writeBinaryFileSync_1.writeBinaryFileSync,
writeFile: writeFile_1.writeFile,
writeFileSync: writeFileSync_1.writeFileSync,
};
exports.default = SimplePlist;
// preserve backwards compatibility
module.exports = SimplePlist;
});

8
node_modules/simple-plist/dist/parse.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
/// <reference types="node" />
import { PathOrFileDescriptor } from "fs";
import { PlistJsObj, StringOrBuffer } from "./types";
/**
* Detects the format of the given string or buffer, then attempts to parse the
* payload using the appropriate tooling.
*/
export declare function parse<T = PlistJsObj>(aStringOrBuffer: StringOrBuffer, aFile?: PathOrFileDescriptor): T;

45
node_modules/simple-plist/dist/parse.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "bplist-parser", "plist"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = void 0;
var bplist_parser_1 = __importDefault(require("bplist-parser"));
var plist_1 = __importDefault(require("plist"));
/**
* Detects the format of the given string or buffer, then attempts to parse the
* payload using the appropriate tooling.
*/
function parse(aStringOrBuffer, aFile) {
var firstByte = aStringOrBuffer[0];
var results;
try {
if (firstByte === 60 || firstByte === "<") {
results = plist_1.default.parse(aStringOrBuffer.toString());
}
else if (firstByte === 98) {
results = bplist_parser_1.default.parseBuffer(aStringOrBuffer)[0];
}
else if (aFile) {
throw new Error("Unable to determine format for '" + aFile + "'");
}
else {
throw new Error("Unable to determine format for plist aStringOrBuffer");
}
}
catch (error) {
throw error instanceof Error ? error : new Error("error parsing " + aFile);
}
return results;
}
exports.parse = parse;
});

4
node_modules/simple-plist/dist/readFile.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
/// <reference types="node" />
import { PathOrFileDescriptor } from "fs";
import { callbackFn } from "./types";
export declare function readFile<T = unknown>(aFile: PathOrFileDescriptor, callback: callbackFn<T>): void;

36
node_modules/simple-plist/dist/readFile.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "fs", "./parse"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readFile = void 0;
var fs_1 = __importDefault(require("fs"));
var parse_1 = require("./parse");
function readFile(aFile, callback) {
fs_1.default.readFile(aFile, function (err, contents) {
if (err) {
return callback(err);
}
var results;
try {
results = (0, parse_1.parse)(contents, aFile);
}
catch (error) {
return callback(error instanceof Error
? error
: new Error("failed to read file " + aFile));
}
callback(null, results);
});
}
exports.readFile = readFile;
});

3
node_modules/simple-plist/dist/readFileSync.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
/// <reference types="node" />
import { PathOrFileDescriptor } from "fs";
export declare function readFileSync<T = unknown>(aFile: PathOrFileDescriptor): T;

26
node_modules/simple-plist/dist/readFileSync.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "fs", "./parse"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readFileSync = void 0;
var fs_1 = __importDefault(require("fs"));
var parse_1 = require("./parse");
function readFileSync(aFile) {
var contents = fs_1.default.readFileSync(aFile);
if (contents.length === 0) {
return {};
}
return (0, parse_1.parse)(contents, aFile);
}
exports.readFileSync = readFileSync;
});

2
node_modules/simple-plist/dist/stringify.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { PlistJsObj } from "./types";
export declare function stringify(anObject: PlistJsObj): string;

21
node_modules/simple-plist/dist/stringify.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "plist"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringify = void 0;
var plist_1 = __importDefault(require("plist"));
function stringify(anObject) {
return plist_1.default.build(anObject);
}
exports.stringify = stringify;
});

4
node_modules/simple-plist/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
/// <reference types="node" />
export declare type callbackFn<T> = (error: Error | null, result?: T) => void;
export declare type StringOrBuffer = string | Buffer;
export declare type PlistJsObj = Record<any, any> | any[];

12
node_modules/simple-plist/dist/types.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
});

5
node_modules/simple-plist/dist/writeBinaryFile.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
/// <reference types="node" />
import { PathOrFileDescriptor, WriteFileOptions } from "fs";
import { callbackFn, PlistJsObj } from "./types";
export declare function writeBinaryFile(aFile: PathOrFileDescriptor, anObject: PlistJsObj, callback: callbackFn<void>): void;
export declare function writeBinaryFile(aFile: PathOrFileDescriptor, anObject: PlistJsObj, options: WriteFileOptions, callback: callbackFn<void>): void;

30
node_modules/simple-plist/dist/writeBinaryFile.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "bplist-creator", "fs"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeBinaryFile = void 0;
var bplist_creator_1 = __importDefault(require("bplist-creator"));
var fs_1 = __importDefault(require("fs"));
function writeBinaryFile(aFile, anObject, options, callback) {
if (typeof options === "function" && callback === undefined) {
fs_1.default.writeFile(aFile, (0, bplist_creator_1.default)(anObject), options);
}
else if (typeof options === "object" && typeof callback === "function") {
fs_1.default.writeFile(aFile, (0, bplist_creator_1.default)(anObject), options, callback);
}
else {
throw new Error("Invalid parameters passed to writeBinaryFile");
}
}
exports.writeBinaryFile = writeBinaryFile;
});

View File

@@ -0,0 +1,4 @@
/// <reference types="node" />
import { PathOrFileDescriptor, WriteFileOptions } from "fs";
import { PlistJsObj } from "./types";
export declare function writeBinaryFileSync(aFile: PathOrFileDescriptor, anObject: PlistJsObj, options?: WriteFileOptions): void;

22
node_modules/simple-plist/dist/writeBinaryFileSync.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "bplist-creator", "fs"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeBinaryFileSync = void 0;
var bplist_creator_1 = __importDefault(require("bplist-creator"));
var fs_1 = __importDefault(require("fs"));
function writeBinaryFileSync(aFile, anObject, options) {
return fs_1.default.writeFileSync(aFile, (0, bplist_creator_1.default)(anObject), options);
}
exports.writeBinaryFileSync = writeBinaryFileSync;
});

5
node_modules/simple-plist/dist/writeFile.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
/// <reference types="node" />
import { PathOrFileDescriptor, WriteFileOptions } from "fs";
import { callbackFn, PlistJsObj } from "./types";
export declare function writeFile(aFile: PathOrFileDescriptor, anObject: PlistJsObj, options: callbackFn<void>): void;
export declare function writeFile(aFile: PathOrFileDescriptor, anObject: PlistJsObj, options: WriteFileOptions, callback: callbackFn<void>): void;

30
node_modules/simple-plist/dist/writeFile.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "fs", "plist"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeFile = void 0;
var fs_1 = __importDefault(require("fs"));
var plist_1 = __importDefault(require("plist"));
function writeFile(aFile, anObject, options, callback) {
if (typeof options === "function" && callback === undefined) {
fs_1.default.writeFile(aFile, plist_1.default.build(anObject), options);
}
else if (typeof options === "object" && typeof callback === "function") {
fs_1.default.writeFile(aFile, plist_1.default.build(anObject), options, callback);
}
else {
throw new Error("Invalid parameters passed to writeFile");
}
}
exports.writeFile = writeFile;
});

4
node_modules/simple-plist/dist/writeFileSync.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
/// <reference types="node" />
import { PathOrFileDescriptor, WriteFileOptions } from "fs";
import { PlistJsObj } from "./types";
export declare function writeFileSync(aFile: PathOrFileDescriptor, anObject: PlistJsObj, options?: WriteFileOptions): void;

23
node_modules/simple-plist/dist/writeFileSync.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "fs", "plist"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeFileSync = void 0;
var fs_1 = __importDefault(require("fs"));
var plist_1 = __importDefault(require("plist"));
function writeFileSync(aFile, anObject, options) {
var data = plist_1.default.build(anObject);
return fs_1.default.writeFileSync(aFile, data, options);
}
exports.writeFileSync = writeFileSync;
});

View File

@@ -0,0 +1,12 @@
; EditorConfig file: https://EditorConfig.org
; Install the "EditorConfig" plugin into your editor to use
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

View File

@@ -0,0 +1 @@
node_modules

View File

@@ -0,0 +1,295 @@
module.exports = {
"env": {
"node": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "error",
"array-bracket-spacing": "off",
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": [
"error",
"1tbs"
],
"callback-return": "off",
"camelcase": "off",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "error",
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"comma-style": "error",
"complexity": "error",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "off",
"consistent-this": "error",
"curly": "off",
"default-case": "error",
"dot-location": "error",
"dot-notation": "off",
"eol-last": "error",
"eqeqeq": "off",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": "off",
"func-style": [
"error",
"declaration"
],
"function-paren-newline": "error",
"generator-star-spacing": "error",
"global-require": "error",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": "error",
"indent": "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": [
"error",
{
"after": true,
"before": true
}
],
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "error",
"lines-around-directive": "error",
"lines-between-class-members": "error",
"max-classes-per-file": "error",
"max-depth": "error",
"max-len": "off",
"max-lines": "off",
"max-lines-per-function": "off",
"max-nested-callbacks": "error",
"max-params": "error",
"max-statements": "off",
"max-statements-per-line": "error",
"multiline-comment-style": [
"error",
"separate-lines"
],
"multiline-ternary": "error",
"new-cap": "error",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "error",
"no-alert": "error",
"no-array-constructor": "error",
"no-async-promise-executor": "error",
"no-await-in-loop": "error",
"no-bitwise": "off",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-empty-function": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-misleading-character-class": "error",
"no-mixed-operators": "off",
"no-mixed-requires": "error",
"no-multi-assign": "off",
"no-multi-spaces": [
"error",
{
"ignoreEOLComments": true
}
],
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "error",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "error",
"no-underscore-dangle": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "error",
"no-void": "error",
"no-warning-comments": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "error",
"object-curly-spacing": [
"error",
"never"
],
"object-property-newline": "error",
"object-shorthand": "error",
"one-var": "off",
"one-var-declaration-per-line": "error",
"operator-assignment": [
"error",
"always"
],
"operator-linebreak": "error",
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-destructuring": "error",
"prefer-named-capture-group": "error",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": "error",
"require-atomic-updates": "error",
"require-await": "error",
"require-jsdoc": "off",
"require-unicode-regexp": "error",
"rest-spread-spacing": "error",
"semi": "error",
"semi-spacing": [
"error",
{
"after": true,
"before": false
}
],
"semi-style": [
"error",
"last"
],
"sort-imports": "error",
"sort-keys": "error",
"sort-vars": "error",
"space-before-blocks": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": "error",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "error",
"vars-on-top": "error",
"wrap-iife": "error",
"wrap-regex": "error",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
]
}
};

View File

@@ -0,0 +1,48 @@
# bplist-parser
Binary Mac OS X Plist (property list) parser.
## Installation
```bash
$ npm install bplist-parser
```
## Quick Examples
```javascript
const bplist = require('bplist-parser');
(async () => {
const obj = await bplist.parseFile('myPlist.bplist');
console.log(JSON.stringify(obj));
})();
```
## License
(The MIT License)
Copyright (c) 2012 Near Infinity Corporation
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,6 @@
declare namespace bPlistParser {
type CallbackFunction<T = any> = (error: Error|null, result: [T]) => void
export function parseFile<T = any>(fileNameOrBuffer: string|Buffer, callback?: CallbackFunction<T>): Promise<[T]>
}
export = bPlistParser

View File

@@ -0,0 +1,366 @@
/* eslint-disable no-console */
'use strict';
// adapted from https://github.com/3breadt/dd-plist
const fs = require('fs');
const bigInt = require('big-integer');
const debug = false;
exports.maxObjectSize = 100 * 1000 * 1000; // 100Meg
exports.maxObjectCount = 32768;
// EPOCH = new SimpleDateFormat("yyyy MM dd zzz").parse("2001 01 01 GMT").getTime();
// ...but that's annoying in a static initializer because it can throw exceptions, ick.
// So we just hardcode the correct value.
const EPOCH = 978307200000;
// UID object definition
const UID = exports.UID = function(id) {
this.UID = id;
};
exports.parseFile = function (fileNameOrBuffer, callback) {
return new Promise(function (resolve, reject) {
function tryParseBuffer(buffer) {
let err = null;
let result;
try {
result = parseBuffer(buffer);
resolve(result);
} catch (ex) {
err = ex;
reject(err);
} finally {
if (callback) callback(err, result);
}
}
if (Buffer.isBuffer(fileNameOrBuffer)) {
return tryParseBuffer(fileNameOrBuffer);
}
fs.readFile(fileNameOrBuffer, function (err, data) {
if (err) {
reject(err);
return callback(err);
}
tryParseBuffer(data);
});
});
};
const parseBuffer = exports.parseBuffer = function (buffer) {
// check header
const header = buffer.slice(0, 'bplist'.length).toString('utf8');
if (header !== 'bplist') {
throw new Error("Invalid binary plist. Expected 'bplist' at offset 0.");
}
// Handle trailer, last 32 bytes of the file
const trailer = buffer.slice(buffer.length - 32, buffer.length);
// 6 null bytes (index 0 to 5)
const offsetSize = trailer.readUInt8(6);
if (debug) {
console.log("offsetSize: " + offsetSize);
}
const objectRefSize = trailer.readUInt8(7);
if (debug) {
console.log("objectRefSize: " + objectRefSize);
}
const numObjects = readUInt64BE(trailer, 8);
if (debug) {
console.log("numObjects: " + numObjects);
}
const topObject = readUInt64BE(trailer, 16);
if (debug) {
console.log("topObject: " + topObject);
}
const offsetTableOffset = readUInt64BE(trailer, 24);
if (debug) {
console.log("offsetTableOffset: " + offsetTableOffset);
}
if (numObjects > exports.maxObjectCount) {
throw new Error("maxObjectCount exceeded");
}
// Handle offset table
const offsetTable = [];
for (let i = 0; i < numObjects; i++) {
const offsetBytes = buffer.slice(offsetTableOffset + i * offsetSize, offsetTableOffset + (i + 1) * offsetSize);
offsetTable[i] = readUInt(offsetBytes, 0);
if (debug) {
console.log("Offset for Object #" + i + " is " + offsetTable[i] + " [" + offsetTable[i].toString(16) + "]");
}
}
// Parses an object inside the currently parsed binary property list.
// For the format specification check
// <a href="https://www.opensource.apple.com/source/CF/CF-635/CFBinaryPList.c">
// Apple's binary property list parser implementation</a>.
function parseObject(tableOffset) {
const offset = offsetTable[tableOffset];
const type = buffer[offset];
const objType = (type & 0xF0) >> 4; //First 4 bits
const objInfo = (type & 0x0F); //Second 4 bits
switch (objType) {
case 0x0:
return parseSimple();
case 0x1:
return parseInteger();
case 0x8:
return parseUID();
case 0x2:
return parseReal();
case 0x3:
return parseDate();
case 0x4:
return parseData();
case 0x5: // ASCII
return parsePlistString();
case 0x6: // UTF-16
return parsePlistString(true);
case 0xA:
return parseArray();
case 0xD:
return parseDictionary();
default:
throw new Error("Unhandled type 0x" + objType.toString(16));
}
function parseSimple() {
//Simple
switch (objInfo) {
case 0x0: // null
return null;
case 0x8: // false
return false;
case 0x9: // true
return true;
case 0xF: // filler byte
return null;
default:
throw new Error("Unhandled simple type 0x" + objType.toString(16));
}
}
function bufferToHexString(buffer) {
let str = '';
let i;
for (i = 0; i < buffer.length; i++) {
if (buffer[i] != 0x00) {
break;
}
}
for (; i < buffer.length; i++) {
const part = '00' + buffer[i].toString(16);
str += part.substr(part.length - 2);
}
return str;
}
function parseInteger() {
const length = Math.pow(2, objInfo);
if (length < exports.maxObjectSize) {
const data = buffer.slice(offset + 1, offset + 1 + length);
if (length === 16) {
const str = bufferToHexString(data);
return bigInt(str, 16);
}
return data.reduce((acc, curr) => {
acc <<= 8;
acc |= curr & 255;
return acc;
});
} else {
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
}
}
function parseUID() {
const length = objInfo + 1;
if (length < exports.maxObjectSize) {
return new UID(readUInt(buffer.slice(offset + 1, offset + 1 + length)));
}
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
}
function parseReal() {
const length = Math.pow(2, objInfo);
if (length < exports.maxObjectSize) {
const realBuffer = buffer.slice(offset + 1, offset + 1 + length);
if (length === 4) {
return realBuffer.readFloatBE(0);
}
if (length === 8) {
return realBuffer.readDoubleBE(0);
}
} else {
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
}
}
function parseDate() {
if (objInfo != 0x3) {
console.error("Unknown date type :" + objInfo + ". Parsing anyway...");
}
const dateBuffer = buffer.slice(offset + 1, offset + 9);
return new Date(EPOCH + (1000 * dateBuffer.readDoubleBE(0)));
}
function parseData() {
let dataoffset = 1;
let length = objInfo;
if (objInfo == 0xF) {
const int_type = buffer[offset + 1];
const intType = (int_type & 0xF0) / 0x10;
if (intType != 0x1) {
console.error("0x4: UNEXPECTED LENGTH-INT TYPE! " + intType);
}
const intInfo = int_type & 0x0F;
const intLength = Math.pow(2, intInfo);
dataoffset = 2 + intLength;
if (intLength < 3) {
length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
} else {
length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
}
}
if (length < exports.maxObjectSize) {
return buffer.slice(offset + dataoffset, offset + dataoffset + length);
}
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
}
function parsePlistString (isUtf16) {
isUtf16 = isUtf16 || 0;
let enc = "utf8";
let length = objInfo;
let stroffset = 1;
if (objInfo == 0xF) {
const int_type = buffer[offset + 1];
const intType = (int_type & 0xF0) / 0x10;
if (intType != 0x1) {
console.error("UNEXPECTED LENGTH-INT TYPE! " + intType);
}
const intInfo = int_type & 0x0F;
const intLength = Math.pow(2, intInfo);
stroffset = 2 + intLength;
if (intLength < 3) {
length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
} else {
length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
}
}
// length is String length -> to get byte length multiply by 2, as 1 character takes 2 bytes in UTF-16
length *= (isUtf16 + 1);
if (length < exports.maxObjectSize) {
let plistString = Buffer.from(buffer.slice(offset + stroffset, offset + stroffset + length));
if (isUtf16) {
plistString = swapBytes(plistString);
enc = "ucs2";
}
return plistString.toString(enc);
}
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
}
function parseArray() {
let length = objInfo;
let arrayoffset = 1;
if (objInfo == 0xF) {
const int_type = buffer[offset + 1];
const intType = (int_type & 0xF0) / 0x10;
if (intType != 0x1) {
console.error("0xa: UNEXPECTED LENGTH-INT TYPE! " + intType);
}
const intInfo = int_type & 0x0F;
const intLength = Math.pow(2, intInfo);
arrayoffset = 2 + intLength;
if (intLength < 3) {
length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
} else {
length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
}
}
if (length * objectRefSize > exports.maxObjectSize) {
throw new Error("Too little heap space available!");
}
const array = [];
for (let i = 0; i < length; i++) {
const objRef = readUInt(buffer.slice(offset + arrayoffset + i * objectRefSize, offset + arrayoffset + (i + 1) * objectRefSize));
array[i] = parseObject(objRef);
}
return array;
}
function parseDictionary() {
let length = objInfo;
let dictoffset = 1;
if (objInfo == 0xF) {
const int_type = buffer[offset + 1];
const intType = (int_type & 0xF0) / 0x10;
if (intType != 0x1) {
console.error("0xD: UNEXPECTED LENGTH-INT TYPE! " + intType);
}
const intInfo = int_type & 0x0F;
const intLength = Math.pow(2, intInfo);
dictoffset = 2 + intLength;
if (intLength < 3) {
length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
} else {
length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
}
}
if (length * 2 * objectRefSize > exports.maxObjectSize) {
throw new Error("Too little heap space available!");
}
if (debug) {
console.log("Parsing dictionary #" + tableOffset);
}
const dict = {};
for (let i = 0; i < length; i++) {
const keyRef = readUInt(buffer.slice(offset + dictoffset + i * objectRefSize, offset + dictoffset + (i + 1) * objectRefSize));
const valRef = readUInt(buffer.slice(offset + dictoffset + (length * objectRefSize) + i * objectRefSize, offset + dictoffset + (length * objectRefSize) + (i + 1) * objectRefSize));
const key = parseObject(keyRef);
const val = parseObject(valRef);
if (debug) {
console.log(" DICT #" + tableOffset + ": Mapped " + key + " to " + val);
}
dict[key] = val;
}
return dict;
}
}
return [ parseObject(topObject) ];
};
function readUInt(buffer, start) {
start = start || 0;
let l = 0;
for (let i = start; i < buffer.length; i++) {
l <<= 8;
l |= buffer[i] & 0xFF;
}
return l;
}
// we're just going to toss the high order bits because javascript doesn't have 64-bit ints
function readUInt64BE(buffer, start) {
const data = buffer.slice(start, start + 8);
return data.readUInt32BE(4, 8);
}
function swapBytes(buffer) {
const len = buffer.length;
for (let i = 0; i < len; i += 2) {
const a = buffer[i];
buffer[i] = buffer[i+1];
buffer[i+1] = a;
}
return buffer;
}

View File

@@ -0,0 +1,35 @@
{
"name": "bplist-parser",
"version": "0.3.1",
"description": "Binary plist parser.",
"main": "bplistParser.js",
"scripts": {
"test": "mocha test"
},
"keywords": [
"bplist",
"plist",
"parser"
],
"author": "Joe Ferner <joe.ferner@nearinfinity.com>",
"contributors": [
"Brett Zamir"
],
"license": "MIT",
"devDependencies": {
"eslint": "6.5.x",
"mocha": "6.2.x"
},
"homepage": "https://github.com/nearinfinity/node-bplist-parser",
"bugs": "https://github.com/nearinfinity/node-bplist-parser/issues",
"engines": {
"node": ">= 5.10.0"
},
"repository": {
"type": "git",
"url": "https://github.com/nearinfinity/node-bplist-parser.git"
},
"dependencies": {
"big-integer": "1.6.x"
}
}

53
node_modules/simple-plist/package.json generated vendored Normal file
View File

@@ -0,0 +1,53 @@
{
"name": "simple-plist",
"author": "Joe Wollard",
"license": "MIT",
"homepage": "https://github.com/wollardj/simple-plist.git",
"repository": {
"type": "git",
"url": "https://github.com/wollardj/simple-plist.git"
},
"version": "1.3.1",
"description": "A wrapper utility for interacting with plist data.",
"main": "dist/index",
"files": [
"./dist"
],
"types": "./dist/index.d.ts",
"keywords": [
"plist",
"binary",
"bplist",
"xml"
],
"scripts": {
"build:tsc": "tsc --project ./tsconfig-build.json",
"build": "run-s clean:build build:tsc",
"clean:build": "rimraf dist",
"clean": "rimraf __tests__/write-test* coverage",
"prepare": "husky install",
"pretest": "clean",
"test": "jest --coverage --verbose"
},
"dependencies": {
"bplist-creator": "0.1.0",
"bplist-parser": "0.3.1",
"plist": "^3.0.5"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/node": "^16.11.26",
"@types/plist": "^3.0.2",
"husky": "^7.0.4",
"jest": "^27.5.1",
"lint-staged": "^11.2.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.7",
"typescript": "^4.4.4"
},
"lint-staged": {
"*.{ts,js,json,md}": "yarn prettier --write"
}
}