diff --git a/tools/hermes-parser/js/flow-api-translator/__tests__/flowDefToTSDef/fixtures/conditional-types/infer/translate-result.shot b/tools/hermes-parser/js/flow-api-translator/__tests__/flowDefToTSDef/fixtures/conditional-types/infer/translate-result.shot index 13f9d202ebb..f627b1513fe 100644 --- a/tools/hermes-parser/js/flow-api-translator/__tests__/flowDefToTSDef/fixtures/conditional-types/infer/translate-result.shot +++ b/tools/hermes-parser/js/flow-api-translator/__tests__/flowDefToTSDef/fixtures/conditional-types/infer/translate-result.shot @@ -12,7 +12,8 @@ exports[`flowDefToTSDef conditional-types/infer 1`] = ` type ExtractValues< T extends - string | {readonly default: string; readonly [$$Key$$: string]: string}, + | string + | {readonly default: string; readonly [$$Key$$: string]: string}, > = T[Key] extends { readonly default: infer X; readonly [$$Key$$: string]: infer Y; diff --git a/tools/hermes-parser/js/flow-api-translator/__tests__/flowDefToTSDef/fixtures/object/mapped-objects/translate-result.shot b/tools/hermes-parser/js/flow-api-translator/__tests__/flowDefToTSDef/fixtures/object/mapped-objects/translate-result.shot index d8a01418cc1..c00c64e3dc8 100644 --- a/tools/hermes-parser/js/flow-api-translator/__tests__/flowDefToTSDef/fixtures/object/mapped-objects/translate-result.shot +++ b/tools/hermes-parser/js/flow-api-translator/__tests__/flowDefToTSDef/fixtures/object/mapped-objects/translate-result.shot @@ -11,12 +11,11 @@ exports[`flowDefToTSDef object/mapped-objects 1`] = ` */ export type FlattenTokens< - T extends - { - readonly [$$Key$$: string]: - | string - | {readonly default: string; readonly [$$Key$$: string]: string}; - }, + T extends { + readonly [$$Key$$: string]: + | string + | {readonly default: string; readonly [$$Key$$: string]: string}; + }, > = { readonly [Key in keyof T]: T[Key] extends { readonly default: infer X; diff --git a/tools/hermes-parser/js/flow-api-translator/src/flowDefToTSDef.js b/tools/hermes-parser/js/flow-api-translator/src/flowDefToTSDef.js index daf6f9b84b2..1f84c18d3d5 100644 --- a/tools/hermes-parser/js/flow-api-translator/src/flowDefToTSDef.js +++ b/tools/hermes-parser/js/flow-api-translator/src/flowDefToTSDef.js @@ -1663,7 +1663,7 @@ const getTransforms = ( return { type: 'TSImportType', isTypeOf: true, - parameter: moduleName, + argument: moduleName, qualifier: null, typeParameters: null, }; diff --git a/tools/hermes-parser/js/flow-api-translator/src/utils/ts-estree-ast-types.js b/tools/hermes-parser/js/flow-api-translator/src/utils/ts-estree-ast-types.js index b22c17c7c22..7fb7c85af32 100644 --- a/tools/hermes-parser/js/flow-api-translator/src/utils/ts-estree-ast-types.js +++ b/tools/hermes-parser/js/flow-api-translator/src/utils/ts-estree-ast-types.js @@ -1589,7 +1589,7 @@ export interface TSImportEqualsDeclaration extends BaseNode { export interface TSImportType extends BaseNode { +type: 'TSImportType'; +isTypeOf: boolean; - +parameter: TypeNode; + +argument: TypeNode; +qualifier: EntityName | null; +typeParameters: TSTypeParameterInstantiation | null; } diff --git a/tools/hermes-parser/js/hermes-parser/__tests__/ComponentDeclaration-test.js b/tools/hermes-parser/js/hermes-parser/__tests__/ComponentDeclaration-test.js index 67e3419b631..0f5c65ef8b3 100644 --- a/tools/hermes-parser/js/hermes-parser/__tests__/ComponentDeclaration-test.js +++ b/tools/hermes-parser/js/hermes-parser/__tests__/ComponentDeclaration-test.js @@ -85,7 +85,7 @@ describe('ComponentDeclaration', () => { }); }); - describe('return type', () => { + describe('renders type', () => { const code = ` component Foo() renders SpecialType {} `; @@ -103,6 +103,24 @@ describe('ComponentDeclaration', () => { }); }); + describe('renders type (complex)', () => { + const code = ` + component Foo() renders (SpecialType | OtherSpecialType) {} + `; + + test('ESTree', async () => { + expect(await printForSnapshotESTree(code)).toBe(code.trim()); + expect(await parseForSnapshotESTree(code)).toMatchSnapshot(); + }); + + test('Babel', async () => { + expect(await parseForSnapshotBabel(code)).toMatchSnapshot(); + expect(await printForSnapshotBabel(code)).toMatchInlineSnapshot( + `"function Foo(): SpecialType | OtherSpecialType {}"`, + ); + }); + }); + describe('type parameters', () => { const code = ` component Foo(bar: T1) renders T2 {} diff --git a/tools/hermes-parser/js/hermes-parser/__tests__/TypeOperator-test.js b/tools/hermes-parser/js/hermes-parser/__tests__/TypeOperator-test.js index 57156ee7969..b191a6b4f78 100644 --- a/tools/hermes-parser/js/hermes-parser/__tests__/TypeOperator-test.js +++ b/tools/hermes-parser/js/hermes-parser/__tests__/TypeOperator-test.js @@ -11,9 +11,9 @@ import {parseForSnapshot, printForSnapshot} from '../__test_utils__/parse'; const parserOpts = {enableExperimentalComponentSyntax: true}; -// async function printForSnapshotESTree(code: string) { -// return printForSnapshot(code, parserOpts); -// } +async function printForSnapshotESTree(code: string) { + return printForSnapshot(code, parserOpts); +} async function parseForSnapshotESTree(code: string) { return parseForSnapshot(code, parserOpts); } @@ -33,8 +33,7 @@ describe('TypeOperator', () => { test('ESTree', async () => { expect(await parseForSnapshotESTree(code)).toMatchSnapshot(); - // TODO: Prettier support - // expect(await printForSnapshotESTree(code)).toBe(code.trim()); + expect(await printForSnapshotESTree(code)).toBe(code.trim()); }); test('Babel', async () => { @@ -51,8 +50,7 @@ describe('TypeOperator', () => { test('ESTree', async () => { expect(await parseForSnapshotESTree(code)).toMatchSnapshot(); - // TODO: Prettier support - // expect(await printForSnapshotESTree(code)).toBe(code.trim()); + expect(await printForSnapshotESTree(code)).toBe(code.trim()); }); test('Babel', async () => { @@ -62,5 +60,22 @@ describe('TypeOperator', () => { ); }); }); + describe('Nested Union', () => { + const code = ` + type T = renders (Foo | Bar) | null; + `; + + test('ESTree', async () => { + expect(await parseForSnapshotESTree(code)).toMatchSnapshot(); + expect(await printForSnapshotESTree(code)).toBe(code.trim()); + }); + + test('Babel', async () => { + expect(await parseForSnapshotBabel(code)).toMatchSnapshot(); + expect(await printForSnapshotBabel(code)).toMatchInlineSnapshot( + `"type T = any | null;"`, + ); + }); + }); }); }); diff --git a/tools/hermes-parser/js/hermes-parser/__tests__/__snapshots__/ComponentDeclaration-test.js.snap b/tools/hermes-parser/js/hermes-parser/__tests__/__snapshots__/ComponentDeclaration-test.js.snap index 1d132b158d1..466aa94a74c 100644 --- a/tools/hermes-parser/js/hermes-parser/__tests__/__snapshots__/ComponentDeclaration-test.js.snap +++ b/tools/hermes-parser/js/hermes-parser/__tests__/__snapshots__/ComponentDeclaration-test.js.snap @@ -3035,7 +3035,7 @@ exports[`ComponentDeclaration ref param ESTree 1`] = ` } `; -exports[`ComponentDeclaration rest params Babel 1`] = ` +exports[`ComponentDeclaration renders type (complex) Babel 1`] = ` { "body": [ { @@ -3051,52 +3051,29 @@ exports[`ComponentDeclaration rest params Babel 1`] = ` "name": "Foo", "type": "Identifier", }, - "params": [ - { - "name": "props", - "type": "Identifier", - "typeAnnotation": { - "type": "TypeAnnotation", - "typeAnnotation": { + "params": [], + "returnType": { + "type": "TypeAnnotation", + "typeAnnotation": { + "type": "UnionTypeAnnotation", + "types": [ + { "id": { - "name": "$ReadOnly", + "name": "SpecialType", "type": "Identifier", }, "type": "GenericTypeAnnotation", - "typeParameters": { - "params": [ - { - "callProperties": [], - "exact": false, - "indexers": [], - "inexact": true, - "internalSlots": [], - "properties": [], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "TypeParameterInstantiation", - }, - }, - }, - }, - ], - "returnType": { - "type": "TypeAnnotation", - "typeAnnotation": { - "id": { - "id": { - "name": "Node", - "type": "Identifier", + "typeParameters": null, }, - "qualification": { - "name": "React", - "type": "Identifier", + { + "id": { + "name": "OtherSpecialType", + "type": "Identifier", + }, + "type": "GenericTypeAnnotation", + "typeParameters": null, }, - "type": "QualifiedTypeIdentifier", - }, - "type": "GenericTypeAnnotation", - "typeParameters": null, + ], }, }, "type": "FunctionDeclaration", @@ -3106,7 +3083,7 @@ exports[`ComponentDeclaration rest params Babel 1`] = ` } `; -exports[`ComponentDeclaration rest params ESTree 1`] = ` +exports[`ComponentDeclaration renders type (complex) ESTree 1`] = ` { "body": [ { @@ -3120,30 +3097,35 @@ exports[`ComponentDeclaration rest params ESTree 1`] = ` "type": "Identifier", "typeAnnotation": null, }, - "params": [ - { - "argument": { - "name": "props", - "optional": false, - "type": "Identifier", - "typeAnnotation": { - "type": "TypeAnnotation", - "typeAnnotation": { - "id": { - "name": "Props", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "type": "GenericTypeAnnotation", - "typeParameters": null, + "params": [], + "rendersType": { + "type": "TypeAnnotation", + "typeAnnotation": { + "type": "UnionTypeAnnotation", + "types": [ + { + "id": { + "name": "SpecialType", + "optional": false, + "type": "Identifier", + "typeAnnotation": null, }, + "type": "GenericTypeAnnotation", + "typeParameters": null, }, - }, - "type": "RestElement", + { + "id": { + "name": "OtherSpecialType", + "optional": false, + "type": "Identifier", + "typeAnnotation": null, + }, + "type": "GenericTypeAnnotation", + "typeParameters": null, + }, + ], }, - ], - "rendersType": null, + }, "type": "ComponentDeclaration", "typeParameters": null, }, @@ -3152,7 +3134,7 @@ exports[`ComponentDeclaration rest params ESTree 1`] = ` } `; -exports[`ComponentDeclaration return type Babel 1`] = ` +exports[`ComponentDeclaration renders type Babel 1`] = ` { "body": [ { @@ -3187,7 +3169,7 @@ exports[`ComponentDeclaration return type Babel 1`] = ` } `; -exports[`ComponentDeclaration return type ESTree 1`] = ` +exports[`ComponentDeclaration renders type ESTree 1`] = ` { "body": [ { @@ -3223,6 +3205,123 @@ exports[`ComponentDeclaration return type ESTree 1`] = ` } `; +exports[`ComponentDeclaration rest params Babel 1`] = ` +{ + "body": [ + { + "__componentDeclaration": true, + "async": false, + "body": { + "body": [], + "directives": [], + "type": "BlockStatement", + }, + "generator": false, + "id": { + "name": "Foo", + "type": "Identifier", + }, + "params": [ + { + "name": "props", + "type": "Identifier", + "typeAnnotation": { + "type": "TypeAnnotation", + "typeAnnotation": { + "id": { + "name": "$ReadOnly", + "type": "Identifier", + }, + "type": "GenericTypeAnnotation", + "typeParameters": { + "params": [ + { + "callProperties": [], + "exact": false, + "indexers": [], + "inexact": true, + "internalSlots": [], + "properties": [], + "type": "ObjectTypeAnnotation", + }, + ], + "type": "TypeParameterInstantiation", + }, + }, + }, + }, + ], + "returnType": { + "type": "TypeAnnotation", + "typeAnnotation": { + "id": { + "id": { + "name": "Node", + "type": "Identifier", + }, + "qualification": { + "name": "React", + "type": "Identifier", + }, + "type": "QualifiedTypeIdentifier", + }, + "type": "GenericTypeAnnotation", + "typeParameters": null, + }, + }, + "type": "FunctionDeclaration", + }, + ], + "type": "Program", +} +`; + +exports[`ComponentDeclaration rest params ESTree 1`] = ` +{ + "body": [ + { + "body": { + "body": [], + "type": "BlockStatement", + }, + "id": { + "name": "Foo", + "optional": false, + "type": "Identifier", + "typeAnnotation": null, + }, + "params": [ + { + "argument": { + "name": "props", + "optional": false, + "type": "Identifier", + "typeAnnotation": { + "type": "TypeAnnotation", + "typeAnnotation": { + "id": { + "name": "Props", + "optional": false, + "type": "Identifier", + "typeAnnotation": null, + }, + "type": "GenericTypeAnnotation", + "typeParameters": null, + }, + }, + }, + "type": "RestElement", + }, + ], + "rendersType": null, + "type": "ComponentDeclaration", + "typeParameters": null, + }, + ], + "type": "Program", +} +`; + exports[`ComponentDeclaration type parameters Babel 1`] = ` { "body": [ diff --git a/tools/hermes-parser/js/hermes-parser/__tests__/__snapshots__/TypeOperator-test.js.snap b/tools/hermes-parser/js/hermes-parser/__tests__/__snapshots__/TypeOperator-test.js.snap index e46affa0d9b..f3b8d52e11b 100644 --- a/tools/hermes-parser/js/hermes-parser/__tests__/__snapshots__/TypeOperator-test.js.snap +++ b/tools/hermes-parser/js/hermes-parser/__tests__/__snapshots__/TypeOperator-test.js.snap @@ -51,6 +51,88 @@ exports[`TypeOperator renders Basic ESTree 1`] = ` } `; +exports[`TypeOperator renders Nested Union Babel 1`] = ` +{ + "body": [ + { + "id": { + "name": "T", + "type": "Identifier", + }, + "right": { + "type": "UnionTypeAnnotation", + "types": [ + { + "type": "AnyTypeAnnotation", + }, + { + "type": "NullLiteralTypeAnnotation", + }, + ], + }, + "type": "TypeAlias", + "typeParameters": null, + }, + ], + "type": "Program", +} +`; + +exports[`TypeOperator renders Nested Union ESTree 1`] = ` +{ + "body": [ + { + "id": { + "name": "T", + "optional": false, + "type": "Identifier", + "typeAnnotation": null, + }, + "right": { + "type": "UnionTypeAnnotation", + "types": [ + { + "operator": "renders", + "type": "TypeOperator", + "typeAnnotation": { + "type": "UnionTypeAnnotation", + "types": [ + { + "id": { + "name": "Foo", + "optional": false, + "type": "Identifier", + "typeAnnotation": null, + }, + "type": "GenericTypeAnnotation", + "typeParameters": null, + }, + { + "id": { + "name": "Bar", + "optional": false, + "type": "Identifier", + "typeAnnotation": null, + }, + "type": "GenericTypeAnnotation", + "typeParameters": null, + }, + ], + }, + }, + { + "type": "NullLiteralTypeAnnotation", + }, + ], + }, + "type": "TypeAlias", + "typeParameters": null, + }, + ], + "type": "Program", +} +`; + exports[`TypeOperator renders Union Babel 1`] = ` { "body": [ diff --git a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/README.md b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/README.md index 629ec74b15f..75105559ff7 100644 --- a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/README.md +++ b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/README.md @@ -5,5 +5,5 @@ This directory contains a modified version of prettier v3. ## Recreating prettier files 1. Check out prettier fork: `https://github.com/pieterv/prettier/tree/hermes-v2-backport`. -2. Build repo: `yarn build --minify false` +2. Build repo: `yarn build --no-minify` 3. Copy built files `dist/ast-to-doc.js` and all files in the `dist/plugins` directory to this location. diff --git a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/ast-to-doc.js b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/ast-to-doc.js index b6141770704..1fda65c31d4 100644 --- a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/ast-to-doc.js +++ b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/ast-to-doc.js @@ -68,3210 +68,31 @@ return method; }; - // node_modules/vnopts/node_modules/tslib/tslib.es6.js - var tslib_es6_exports = {}; - __export(tslib_es6_exports, { - __assign: () => __assign, - __asyncDelegator: () => __asyncDelegator, - __asyncGenerator: () => __asyncGenerator, - __asyncValues: () => __asyncValues, - __await: () => __await, - __awaiter: () => __awaiter, - __classPrivateFieldGet: () => __classPrivateFieldGet, - __classPrivateFieldSet: () => __classPrivateFieldSet, - __createBinding: () => __createBinding, - __decorate: () => __decorate, - __exportStar: () => __exportStar, - __extends: () => __extends, - __generator: () => __generator, - __importDefault: () => __importDefault, - __importStar: () => __importStar, - __makeTemplateObject: () => __makeTemplateObject, - __metadata: () => __metadata, - __param: () => __param, - __read: () => __read, - __rest: () => __rest, - __spread: () => __spread, - __spreadArrays: () => __spreadArrays, - __values: () => __values - }); - function __extends(d, b) { - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - } - function __rest(s, e) { - var t = {}; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - } - function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r = Reflect.decorate(decorators, target, key, desc); - else - for (var i = decorators.length - 1; i >= 0; i--) - if (d = decorators[i]) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - } - function __param(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; - } - function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") - return Reflect.metadata(metadataKey, metadataValue); - } - function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - } - function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { - if (t[0] & 1) - throw t[1]; - return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { - return this; - }), g; - function verb(n) { - return function(v) { - return step([n, v]); - }; - } - function step(op) { - if (f) - throw new TypeError("Generator is already executing."); - while (_) - try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) - return t; - if (y = 0, t) - op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) - _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) - throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } - } - function __createBinding(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - o[k2] = m[k]; - } - function __exportStar(m, exports) { - for (var p in m) - if (p !== "default" && !exports.hasOwnProperty(p)) - exports[p] = m[p]; - } - function __values(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) - return m.call(o); - if (o && typeof o.length === "number") - return { - next: function() { - if (o && i >= o.length) - o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); - } - function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) - return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) - ar.push(r.value); - } catch (error) { - e = { error }; - } finally { - try { - if (r && !r.done && (m = i["return"])) - m.call(i); - } finally { - if (e) - throw e.error; - } - } - return ar; - } - function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - } - function __spreadArrays() { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) - s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; - } - function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - } - function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i; - function verb(n) { - if (g[n]) - i[n] = function(v) { - return new Promise(function(a, b) { - q.push([n, v, a, b]) > 1 || resume(n, v); - }); - }; - } - function resume(n, v) { - try { - step(g[n](v)); - } catch (e) { - settle(q[0][3], e); - } - } - function step(r) { - r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f, v) { - if (f(v), q.shift(), q.length) - resume(q[0][0], q[0][1]); - } - } - function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i[Symbol.iterator] = function() { - return this; - }, i; - function verb(n, f) { - i[n] = o[n] ? function(v) { - return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; - } : f; - } - } - function __asyncValues(o) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i); - function verb(n) { - i[n] = o[n] && function(v) { - return new Promise(function(resolve, reject) { - v = o[n](v), settle(resolve, reject, v.done, v.value); - }); - }; - } - function settle(resolve, reject, d, v) { - Promise.resolve(v).then(function(v2) { - resolve({ value: v2, done: d }); - }, reject); - } - } - function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { - Object.defineProperty(cooked, "raw", { value: raw }); - } else { - cooked.raw = raw; - } - return cooked; - } - function __importStar(mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) { - for (var k in mod) - if (Object.hasOwnProperty.call(mod, k)) - result[k] = mod[k]; - } - result.default = mod; - return result; - } - function __importDefault(mod) { - return mod && mod.__esModule ? mod : { default: mod }; - } - function __classPrivateFieldGet(receiver, privateMap) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to get private field on non-instance"); - } - return privateMap.get(receiver); - } - function __classPrivateFieldSet(receiver, privateMap, value) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to set private field on non-instance"); - } - privateMap.set(receiver, value); - return value; - } - var extendStatics, __assign; - var init_tslib_es6 = __esm({ - "node_modules/vnopts/node_modules/tslib/tslib.es6.js"() { - extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { - d2.__proto__ = b2; - } || function(d2, b2) { - for (var p in b2) - if (b2.hasOwnProperty(p)) - d2[p] = b2[p]; - }; - return extendStatics(d, b); - }; - __assign = function() { - __assign = Object.assign || function __assign2(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - } - }); - - // node_modules/vnopts/lib/descriptors/api.js - var require_api = __commonJS({ - "node_modules/vnopts/lib/descriptors/api.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.apiDescriptor = { - key: (key) => /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(key) ? key : JSON.stringify(key), - value(value) { - if (value === null || typeof value !== "object") { - return JSON.stringify(value); - } - if (Array.isArray(value)) { - return `[${value.map((subValue) => exports.apiDescriptor.value(subValue)).join(", ")}]`; - } - const keys = Object.keys(value); - return keys.length === 0 ? "{}" : `{ ${keys.map((key) => `${exports.apiDescriptor.key(key)}: ${exports.apiDescriptor.value(value[key])}`).join(", ")} }`; - }, - pair: ({ key, value }) => exports.apiDescriptor.value({ [key]: value }) - }; - } - }); - - // node_modules/vnopts/lib/descriptors/index.js - var require_descriptors = __commonJS({ - "node_modules/vnopts/lib/descriptors/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - tslib_1.__exportStar(require_api(), exports); - } - }); - - // node_modules/vnopts/node_modules/escape-string-regexp/index.js - var require_escape_string_regexp = __commonJS({ - "node_modules/vnopts/node_modules/escape-string-regexp/index.js"(exports, module) { - "use strict"; - var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; - module.exports = function(str) { - if (typeof str !== "string") { - throw new TypeError("Expected a string"); - } - return str.replace(matchOperatorsRe, "\\$&"); - }; - } - }); - - // node_modules/color-name/index.js - var require_color_name = __commonJS({ - "node_modules/color-name/index.js"(exports, module) { - "use strict"; - module.exports = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] - }; - } - }); - - // node_modules/color-convert/conversions.js - var require_conversions = __commonJS({ - "node_modules/color-convert/conversions.js"(exports, module) { - var cssKeywords = require_color_name(); - var reverseKeywords = {}; - for (key in cssKeywords) { - if (cssKeywords.hasOwnProperty(key)) { - reverseKeywords[cssKeywords[key]] = key; - } - } - var key; - var convert = module.exports = { - rgb: { channels: 3, labels: "rgb" }, - hsl: { channels: 3, labels: "hsl" }, - hsv: { channels: 3, labels: "hsv" }, - hwb: { channels: 3, labels: "hwb" }, - cmyk: { channels: 4, labels: "cmyk" }, - xyz: { channels: 3, labels: "xyz" }, - lab: { channels: 3, labels: "lab" }, - lch: { channels: 3, labels: "lch" }, - hex: { channels: 1, labels: ["hex"] }, - keyword: { channels: 1, labels: ["keyword"] }, - ansi16: { channels: 1, labels: ["ansi16"] }, - ansi256: { channels: 1, labels: ["ansi256"] }, - hcg: { channels: 3, labels: ["h", "c", "g"] }, - apple: { channels: 3, labels: ["r16", "g16", "b16"] }, - gray: { channels: 1, labels: ["gray"] } - }; - for (model in convert) { - if (convert.hasOwnProperty(model)) { - if (!("channels" in convert[model])) { - throw new Error("missing channels property: " + model); - } - if (!("labels" in convert[model])) { - throw new Error("missing channel labels property: " + model); - } - if (convert[model].labels.length !== convert[model].channels) { - throw new Error("channel and label counts mismatch: " + model); - } - channels = convert[model].channels; - labels = convert[model].labels; - delete convert[model].channels; - delete convert[model].labels; - Object.defineProperty(convert[model], "channels", { value: channels }); - Object.defineProperty(convert[model], "labels", { value: labels }); - } - } - var channels; - var labels; - var model; - convert.rgb.hsl = function(rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var delta = max - min; - var h; - var s; - var l; - if (max === min) { - h = 0; - } else if (r === max) { - h = (g - b) / delta; - } else if (g === max) { - h = 2 + (b - r) / delta; - } else if (b === max) { - h = 4 + (r - g) / delta; - } - h = Math.min(h * 60, 360); - if (h < 0) { - h += 360; - } - l = (min + max) / 2; - if (max === min) { - s = 0; - } else if (l <= 0.5) { - s = delta / (max + min); - } else { - s = delta / (2 - max - min); - } - return [h, s * 100, l * 100]; - }; - convert.rgb.hsv = function(rgb) { - var rdif; - var gdif; - var bdif; - var h; - var s; - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var v = Math.max(r, g, b); - var diff = v - Math.min(r, g, b); - var diffc = function(c) { - return (v - c) / 6 / diff + 1 / 2; - }; - if (diff === 0) { - h = s = 0; - } else { - s = diff / v; - rdif = diffc(r); - gdif = diffc(g); - bdif = diffc(b); - if (r === v) { - h = bdif - gdif; - } else if (g === v) { - h = 1 / 3 + rdif - bdif; - } else if (b === v) { - h = 2 / 3 + gdif - rdif; - } - if (h < 0) { - h += 1; - } else if (h > 1) { - h -= 1; - } - } - return [ - h * 360, - s * 100, - v * 100 - ]; - }; - convert.rgb.hwb = function(rgb) { - var r = rgb[0]; - var g = rgb[1]; - var b = rgb[2]; - var h = convert.rgb.hsl(rgb)[0]; - var w = 1 / 255 * Math.min(r, Math.min(g, b)); - b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); - return [h, w * 100, b * 100]; - }; - convert.rgb.cmyk = function(rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var c; - var m; - var y; - var k; - k = Math.min(1 - r, 1 - g, 1 - b); - c = (1 - r - k) / (1 - k) || 0; - m = (1 - g - k) / (1 - k) || 0; - y = (1 - b - k) / (1 - k) || 0; - return [c * 100, m * 100, y * 100, k * 100]; - }; - function comparativeDistance(x, y) { - return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2); - } - convert.rgb.keyword = function(rgb) { - var reversed = reverseKeywords[rgb]; - if (reversed) { - return reversed; - } - var currentClosestDistance = Infinity; - var currentClosestKeyword; - for (var keyword in cssKeywords) { - if (cssKeywords.hasOwnProperty(keyword)) { - var value = cssKeywords[keyword]; - var distance = comparativeDistance(rgb, value); - if (distance < currentClosestDistance) { - currentClosestDistance = distance; - currentClosestKeyword = keyword; - } - } - } - return currentClosestKeyword; - }; - convert.keyword.rgb = function(keyword) { - return cssKeywords[keyword]; - }; - convert.rgb.xyz = function(rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92; - g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92; - b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92; - var x = r * 0.4124 + g * 0.3576 + b * 0.1805; - var y = r * 0.2126 + g * 0.7152 + b * 0.0722; - var z = r * 0.0193 + g * 0.1192 + b * 0.9505; - return [x * 100, y * 100, z * 100]; - }; - convert.rgb.lab = function(rgb) { - var xyz = convert.rgb.xyz(rgb); - var x = xyz[0]; - var y = xyz[1]; - var z = xyz[2]; - var l; - var a; - var b; - x /= 95.047; - y /= 100; - z /= 108.883; - x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116; - y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116; - z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116; - l = 116 * y - 16; - a = 500 * (x - y); - b = 200 * (y - z); - return [l, a, b]; - }; - convert.hsl.rgb = function(hsl) { - var h = hsl[0] / 360; - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var t1; - var t2; - var t3; - var rgb; - var val; - if (s === 0) { - val = l * 255; - return [val, val, val]; - } - if (l < 0.5) { - t2 = l * (1 + s); - } else { - t2 = l + s - l * s; - } - t1 = 2 * l - t2; - rgb = [0, 0, 0]; - for (var i = 0; i < 3; i++) { - t3 = h + 1 / 3 * -(i - 1); - if (t3 < 0) { - t3++; - } - if (t3 > 1) { - t3--; - } - if (6 * t3 < 1) { - val = t1 + (t2 - t1) * 6 * t3; - } else if (2 * t3 < 1) { - val = t2; - } else if (3 * t3 < 2) { - val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; - } else { - val = t1; - } - rgb[i] = val * 255; - } - return rgb; - }; - convert.hsl.hsv = function(hsl) { - var h = hsl[0]; - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var smin = s; - var lmin = Math.max(l, 0.01); - var sv; - var v; - l *= 2; - s *= l <= 1 ? l : 2 - l; - smin *= lmin <= 1 ? lmin : 2 - lmin; - v = (l + s) / 2; - sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s); - return [h, sv * 100, v * 100]; - }; - convert.hsv.rgb = function(hsv) { - var h = hsv[0] / 60; - var s = hsv[1] / 100; - var v = hsv[2] / 100; - var hi = Math.floor(h) % 6; - var f = h - Math.floor(h); - var p = 255 * v * (1 - s); - var q = 255 * v * (1 - s * f); - var t = 255 * v * (1 - s * (1 - f)); - v *= 255; - switch (hi) { - case 0: - return [v, t, p]; - case 1: - return [q, v, p]; - case 2: - return [p, v, t]; - case 3: - return [p, q, v]; - case 4: - return [t, p, v]; - case 5: - return [v, p, q]; - } - }; - convert.hsv.hsl = function(hsv) { - var h = hsv[0]; - var s = hsv[1] / 100; - var v = hsv[2] / 100; - var vmin = Math.max(v, 0.01); - var lmin; - var sl; - var l; - l = (2 - s) * v; - lmin = (2 - s) * vmin; - sl = s * vmin; - sl /= lmin <= 1 ? lmin : 2 - lmin; - sl = sl || 0; - l /= 2; - return [h, sl * 100, l * 100]; - }; - convert.hwb.rgb = function(hwb) { - var h = hwb[0] / 360; - var wh = hwb[1] / 100; - var bl = hwb[2] / 100; - var ratio = wh + bl; - var i; - var v; - var f; - var n; - if (ratio > 1) { - wh /= ratio; - bl /= ratio; - } - i = Math.floor(6 * h); - v = 1 - bl; - f = 6 * h - i; - if ((i & 1) !== 0) { - f = 1 - f; - } - n = wh + f * (v - wh); - var r; - var g; - var b; - switch (i) { - default: - case 6: - case 0: - r = v; - g = n; - b = wh; - break; - case 1: - r = n; - g = v; - b = wh; - break; - case 2: - r = wh; - g = v; - b = n; - break; - case 3: - r = wh; - g = n; - b = v; - break; - case 4: - r = n; - g = wh; - b = v; - break; - case 5: - r = v; - g = wh; - b = n; - break; - } - return [r * 255, g * 255, b * 255]; - }; - convert.cmyk.rgb = function(cmyk) { - var c = cmyk[0] / 100; - var m = cmyk[1] / 100; - var y = cmyk[2] / 100; - var k = cmyk[3] / 100; - var r; - var g; - var b; - r = 1 - Math.min(1, c * (1 - k) + k); - g = 1 - Math.min(1, m * (1 - k) + k); - b = 1 - Math.min(1, y * (1 - k) + k); - return [r * 255, g * 255, b * 255]; - }; - convert.xyz.rgb = function(xyz) { - var x = xyz[0] / 100; - var y = xyz[1] / 100; - var z = xyz[2] / 100; - var r; - var g; - var b; - r = x * 3.2406 + y * -1.5372 + z * -0.4986; - g = x * -0.9689 + y * 1.8758 + z * 0.0415; - b = x * 0.0557 + y * -0.204 + z * 1.057; - r = r > 31308e-7 ? 1.055 * Math.pow(r, 1 / 2.4) - 0.055 : r * 12.92; - g = g > 31308e-7 ? 1.055 * Math.pow(g, 1 / 2.4) - 0.055 : g * 12.92; - b = b > 31308e-7 ? 1.055 * Math.pow(b, 1 / 2.4) - 0.055 : b * 12.92; - r = Math.min(Math.max(0, r), 1); - g = Math.min(Math.max(0, g), 1); - b = Math.min(Math.max(0, b), 1); - return [r * 255, g * 255, b * 255]; - }; - convert.xyz.lab = function(xyz) { - var x = xyz[0]; - var y = xyz[1]; - var z = xyz[2]; - var l; - var a; - var b; - x /= 95.047; - y /= 100; - z /= 108.883; - x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116; - y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116; - z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116; - l = 116 * y - 16; - a = 500 * (x - y); - b = 200 * (y - z); - return [l, a, b]; - }; - convert.lab.xyz = function(lab) { - var l = lab[0]; - var a = lab[1]; - var b = lab[2]; - var x; - var y; - var z; - y = (l + 16) / 116; - x = a / 500 + y; - z = y - b / 200; - var y2 = Math.pow(y, 3); - var x2 = Math.pow(x, 3); - var z2 = Math.pow(z, 3); - y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787; - x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787; - z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787; - x *= 95.047; - y *= 100; - z *= 108.883; - return [x, y, z]; - }; - convert.lab.lch = function(lab) { - var l = lab[0]; - var a = lab[1]; - var b = lab[2]; - var hr; - var h; - var c; - hr = Math.atan2(b, a); - h = hr * 360 / 2 / Math.PI; - if (h < 0) { - h += 360; - } - c = Math.sqrt(a * a + b * b); - return [l, c, h]; - }; - convert.lch.lab = function(lch) { - var l = lch[0]; - var c = lch[1]; - var h = lch[2]; - var a; - var b; - var hr; - hr = h / 360 * 2 * Math.PI; - a = c * Math.cos(hr); - b = c * Math.sin(hr); - return [l, a, b]; - }; - convert.rgb.ansi16 = function(args) { - var r = args[0]; - var g = args[1]; - var b = args[2]; - var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; - value = Math.round(value / 50); - if (value === 0) { - return 30; - } - var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255)); - if (value === 2) { - ansi += 60; - } - return ansi; - }; - convert.hsv.ansi16 = function(args) { - return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); - }; - convert.rgb.ansi256 = function(args) { - var r = args[0]; - var g = args[1]; - var b = args[2]; - if (r === g && g === b) { - if (r < 8) { - return 16; - } - if (r > 248) { - return 231; - } - return Math.round((r - 8) / 247 * 24) + 232; - } - var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5); - return ansi; - }; - convert.ansi16.rgb = function(args) { - var color = args % 10; - if (color === 0 || color === 7) { - if (args > 50) { - color += 3.5; - } - color = color / 10.5 * 255; - return [color, color, color]; - } - var mult = (~~(args > 50) + 1) * 0.5; - var r = (color & 1) * mult * 255; - var g = (color >> 1 & 1) * mult * 255; - var b = (color >> 2 & 1) * mult * 255; - return [r, g, b]; - }; - convert.ansi256.rgb = function(args) { - if (args >= 232) { - var c = (args - 232) * 10 + 8; - return [c, c, c]; - } - args -= 16; - var rem; - var r = Math.floor(args / 36) / 5 * 255; - var g = Math.floor((rem = args % 36) / 6) / 5 * 255; - var b = rem % 6 / 5 * 255; - return [r, g, b]; - }; - convert.rgb.hex = function(args) { - var integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255); - var string = integer.toString(16).toUpperCase(); - return "000000".substring(string.length) + string; - }; - convert.hex.rgb = function(args) { - var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); - if (!match) { - return [0, 0, 0]; - } - var colorString = match[0]; - if (match[0].length === 3) { - colorString = colorString.split("").map(function(char) { - return char + char; - }).join(""); - } - var integer = parseInt(colorString, 16); - var r = integer >> 16 & 255; - var g = integer >> 8 & 255; - var b = integer & 255; - return [r, g, b]; - }; - convert.rgb.hcg = function(rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var max = Math.max(Math.max(r, g), b); - var min = Math.min(Math.min(r, g), b); - var chroma = max - min; - var grayscale; - var hue; - if (chroma < 1) { - grayscale = min / (1 - chroma); - } else { - grayscale = 0; - } - if (chroma <= 0) { - hue = 0; - } else if (max === r) { - hue = (g - b) / chroma % 6; - } else if (max === g) { - hue = 2 + (b - r) / chroma; - } else { - hue = 4 + (r - g) / chroma + 4; - } - hue /= 6; - hue %= 1; - return [hue * 360, chroma * 100, grayscale * 100]; - }; - convert.hsl.hcg = function(hsl) { - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var c = 1; - var f = 0; - if (l < 0.5) { - c = 2 * s * l; - } else { - c = 2 * s * (1 - l); - } - if (c < 1) { - f = (l - 0.5 * c) / (1 - c); - } - return [hsl[0], c * 100, f * 100]; - }; - convert.hsv.hcg = function(hsv) { - var s = hsv[1] / 100; - var v = hsv[2] / 100; - var c = s * v; - var f = 0; - if (c < 1) { - f = (v - c) / (1 - c); - } - return [hsv[0], c * 100, f * 100]; - }; - convert.hcg.rgb = function(hcg) { - var h = hcg[0] / 360; - var c = hcg[1] / 100; - var g = hcg[2] / 100; - if (c === 0) { - return [g * 255, g * 255, g * 255]; - } - var pure = [0, 0, 0]; - var hi = h % 1 * 6; - var v = hi % 1; - var w = 1 - v; - var mg = 0; - switch (Math.floor(hi)) { - case 0: - pure[0] = 1; - pure[1] = v; - pure[2] = 0; - break; - case 1: - pure[0] = w; - pure[1] = 1; - pure[2] = 0; - break; - case 2: - pure[0] = 0; - pure[1] = 1; - pure[2] = v; - break; - case 3: - pure[0] = 0; - pure[1] = w; - pure[2] = 1; - break; - case 4: - pure[0] = v; - pure[1] = 0; - pure[2] = 1; - break; - default: - pure[0] = 1; - pure[1] = 0; - pure[2] = w; - } - mg = (1 - c) * g; - return [ - (c * pure[0] + mg) * 255, - (c * pure[1] + mg) * 255, - (c * pure[2] + mg) * 255 - ]; - }; - convert.hcg.hsv = function(hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; - var v = c + g * (1 - c); - var f = 0; - if (v > 0) { - f = c / v; - } - return [hcg[0], f * 100, v * 100]; - }; - convert.hcg.hsl = function(hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; - var l = g * (1 - c) + 0.5 * c; - var s = 0; - if (l > 0 && l < 0.5) { - s = c / (2 * l); - } else if (l >= 0.5 && l < 1) { - s = c / (2 * (1 - l)); - } - return [hcg[0], s * 100, l * 100]; - }; - convert.hcg.hwb = function(hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; - var v = c + g * (1 - c); - return [hcg[0], (v - c) * 100, (1 - v) * 100]; - }; - convert.hwb.hcg = function(hwb) { - var w = hwb[1] / 100; - var b = hwb[2] / 100; - var v = 1 - b; - var c = v - w; - var g = 0; - if (c < 1) { - g = (v - c) / (1 - c); - } - return [hwb[0], c * 100, g * 100]; - }; - convert.apple.rgb = function(apple) { - return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255]; - }; - convert.rgb.apple = function(rgb) { - return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535]; - }; - convert.gray.rgb = function(args) { - return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; - }; - convert.gray.hsl = convert.gray.hsv = function(args) { - return [0, 0, args[0]]; - }; - convert.gray.hwb = function(gray) { - return [0, 100, gray[0]]; - }; - convert.gray.cmyk = function(gray) { - return [0, 0, 0, gray[0]]; - }; - convert.gray.lab = function(gray) { - return [gray[0], 0, 0]; - }; - convert.gray.hex = function(gray) { - var val = Math.round(gray[0] / 100 * 255) & 255; - var integer = (val << 16) + (val << 8) + val; - var string = integer.toString(16).toUpperCase(); - return "000000".substring(string.length) + string; - }; - convert.rgb.gray = function(rgb) { - var val = (rgb[0] + rgb[1] + rgb[2]) / 3; - return [val / 255 * 100]; - }; - } - }); - - // node_modules/color-convert/route.js - var require_route = __commonJS({ - "node_modules/color-convert/route.js"(exports, module) { - var conversions = require_conversions(); - function buildGraph() { - var graph = {}; - var models = Object.keys(conversions); - for (var len = models.length, i = 0; i < len; i++) { - graph[models[i]] = { - // http://jsperf.com/1-vs-infinity - // micro-opt, but this is simple. - distance: -1, - parent: null - }; - } - return graph; - } - function deriveBFS(fromModel) { - var graph = buildGraph(); - var queue = [fromModel]; - graph[fromModel].distance = 0; - while (queue.length) { - var current = queue.pop(); - var adjacents = Object.keys(conversions[current]); - for (var len = adjacents.length, i = 0; i < len; i++) { - var adjacent = adjacents[i]; - var node = graph[adjacent]; - if (node.distance === -1) { - node.distance = graph[current].distance + 1; - node.parent = current; - queue.unshift(adjacent); - } - } - } - return graph; - } - function link(from, to) { - return function(args) { - return to(from(args)); - }; - } - function wrapConversion(toModel, graph) { - var path = [graph[toModel].parent, toModel]; - var fn = conversions[graph[toModel].parent][toModel]; - var cur = graph[toModel].parent; - while (graph[cur].parent) { - path.unshift(graph[cur].parent); - fn = link(conversions[graph[cur].parent][cur], fn); - cur = graph[cur].parent; - } - fn.conversion = path; - return fn; - } - module.exports = function(fromModel) { - var graph = deriveBFS(fromModel); - var conversion = {}; - var models = Object.keys(graph); - for (var len = models.length, i = 0; i < len; i++) { - var toModel = models[i]; - var node = graph[toModel]; - if (node.parent === null) { - continue; - } - conversion[toModel] = wrapConversion(toModel, graph); - } - return conversion; - }; - } - }); - - // node_modules/color-convert/index.js - var require_color_convert = __commonJS({ - "node_modules/color-convert/index.js"(exports, module) { - var conversions = require_conversions(); - var route = require_route(); - var convert = {}; - var models = Object.keys(conversions); - function wrapRaw(fn) { - var wrappedFn = function(args) { - if (args === void 0 || args === null) { - return args; - } - if (arguments.length > 1) { - args = Array.prototype.slice.call(arguments); - } - return fn(args); - }; - if ("conversion" in fn) { - wrappedFn.conversion = fn.conversion; - } - return wrappedFn; - } - function wrapRounded(fn) { - var wrappedFn = function(args) { - if (args === void 0 || args === null) { - return args; - } - if (arguments.length > 1) { - args = Array.prototype.slice.call(arguments); - } - var result = fn(args); - if (typeof result === "object") { - for (var len = result.length, i = 0; i < len; i++) { - result[i] = Math.round(result[i]); - } - } - return result; - }; - if ("conversion" in fn) { - wrappedFn.conversion = fn.conversion; - } - return wrappedFn; - } - models.forEach(function(fromModel) { - convert[fromModel] = {}; - Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels }); - Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels }); - var routes = route(fromModel); - var routeModels = Object.keys(routes); - routeModels.forEach(function(toModel) { - var fn = routes[toModel]; - convert[fromModel][toModel] = wrapRounded(fn); - convert[fromModel][toModel].raw = wrapRaw(fn); - }); - }); - module.exports = convert; - } - }); - - // node_modules/ansi-styles/index.js - var require_ansi_styles = __commonJS({ - "node_modules/ansi-styles/index.js"(exports, module) { - "use strict"; - var colorConvert = require_color_convert(); - var wrapAnsi16 = (fn, offset) => function() { - const code = fn.apply(colorConvert, arguments); - return `\x1B[${code + offset}m`; - }; - var wrapAnsi256 = (fn, offset) => function() { - const code = fn.apply(colorConvert, arguments); - return `\x1B[${38 + offset};5;${code}m`; - }; - var wrapAnsi16m = (fn, offset) => function() { - const rgb = fn.apply(colorConvert, arguments); - return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; - }; - function assembleStyles() { - const codes = /* @__PURE__ */ new Map(); - const styles = { - modifier: { - reset: [0, 0], - // 21 isn't widely supported and 22 does the same thing - bold: [1, 22], - dim: [2, 22], - italic: [3, 23], - underline: [4, 24], - inverse: [7, 27], - hidden: [8, 28], - strikethrough: [9, 29] - }, - color: { - black: [30, 39], - red: [31, 39], - green: [32, 39], - yellow: [33, 39], - blue: [34, 39], - magenta: [35, 39], - cyan: [36, 39], - white: [37, 39], - gray: [90, 39], - // Bright color - redBright: [91, 39], - greenBright: [92, 39], - yellowBright: [93, 39], - blueBright: [94, 39], - magentaBright: [95, 39], - cyanBright: [96, 39], - whiteBright: [97, 39] - }, - bgColor: { - bgBlack: [40, 49], - bgRed: [41, 49], - bgGreen: [42, 49], - bgYellow: [43, 49], - bgBlue: [44, 49], - bgMagenta: [45, 49], - bgCyan: [46, 49], - bgWhite: [47, 49], - // Bright color - bgBlackBright: [100, 49], - bgRedBright: [101, 49], - bgGreenBright: [102, 49], - bgYellowBright: [103, 49], - bgBlueBright: [104, 49], - bgMagentaBright: [105, 49], - bgCyanBright: [106, 49], - bgWhiteBright: [107, 49] - } - }; - styles.color.grey = styles.color.gray; - for (const groupName of Object.keys(styles)) { - const group = styles[groupName]; - for (const styleName of Object.keys(group)) { - const style = group[styleName]; - styles[styleName] = { - open: `\x1B[${style[0]}m`, - close: `\x1B[${style[1]}m` - }; - group[styleName] = styles[styleName]; - codes.set(style[0], style[1]); - } - Object.defineProperty(styles, groupName, { - value: group, - enumerable: false - }); - Object.defineProperty(styles, "codes", { - value: codes, - enumerable: false - }); - } - const ansi2ansi = (n) => n; - const rgb2rgb = (r, g, b) => [r, g, b]; - styles.color.close = "\x1B[39m"; - styles.bgColor.close = "\x1B[49m"; - styles.color.ansi = { - ansi: wrapAnsi16(ansi2ansi, 0) - }; - styles.color.ansi256 = { - ansi256: wrapAnsi256(ansi2ansi, 0) - }; - styles.color.ansi16m = { - rgb: wrapAnsi16m(rgb2rgb, 0) - }; - styles.bgColor.ansi = { - ansi: wrapAnsi16(ansi2ansi, 10) - }; - styles.bgColor.ansi256 = { - ansi256: wrapAnsi256(ansi2ansi, 10) - }; - styles.bgColor.ansi16m = { - rgb: wrapAnsi16m(rgb2rgb, 10) - }; - for (let key of Object.keys(colorConvert)) { - if (typeof colorConvert[key] !== "object") { - continue; - } - const suite = colorConvert[key]; - if (key === "ansi16") { - key = "ansi"; - } - if ("ansi16" in suite) { - styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); - styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); - } - if ("ansi256" in suite) { - styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); - styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); - } - if ("rgb" in suite) { - styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); - styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); - } - } - return styles; - } - Object.defineProperty(module, "exports", { - enumerable: true, - get: assembleStyles - }); - } - }); - - // node_modules/vnopts/node_modules/supports-color/browser.js - var require_browser = __commonJS({ - "node_modules/vnopts/node_modules/supports-color/browser.js"(exports, module) { - "use strict"; - module.exports = { - stdout: false, - stderr: false - }; - } - }); - - // node_modules/vnopts/node_modules/chalk/templates.js - var require_templates = __commonJS({ - "node_modules/vnopts/node_modules/chalk/templates.js"(exports, module) { - "use strict"; - var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; - var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; - var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; - var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi; - var ESCAPES = /* @__PURE__ */ new Map([ - ["n", "\n"], - ["r", "\r"], - ["t", " "], - ["b", "\b"], - ["f", "\f"], - ["v", "\v"], - ["0", "\0"], - ["\\", "\\"], - ["e", "\x1B"], - ["a", "\x07"] - ]); - function unescape(c) { - if (c[0] === "u" && c.length === 5 || c[0] === "x" && c.length === 3) { - return String.fromCharCode(parseInt(c.slice(1), 16)); - } - return ESCAPES.get(c) || c; - } - function parseArguments(name, args) { - const results = []; - const chunks = args.trim().split(/\s*,\s*/g); - let matches; - for (const chunk of chunks) { - if (!isNaN(chunk)) { - results.push(Number(chunk)); - } else if (matches = chunk.match(STRING_REGEX)) { - results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr)); - } else { - throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); - } - } - return results; - } - function parseStyle(style) { - STYLE_REGEX.lastIndex = 0; - const results = []; - let matches; - while ((matches = STYLE_REGEX.exec(style)) !== null) { - const name = matches[1]; - if (matches[2]) { - const args = parseArguments(name, matches[2]); - results.push([name].concat(args)); - } else { - results.push([name]); - } - } - return results; - } - function buildStyle(chalk, styles) { - const enabled = {}; - for (const layer of styles) { - for (const style of layer.styles) { - enabled[style[0]] = layer.inverse ? null : style.slice(1); - } - } - let current = chalk; - for (const styleName of Object.keys(enabled)) { - if (Array.isArray(enabled[styleName])) { - if (!(styleName in current)) { - throw new Error(`Unknown Chalk style: ${styleName}`); - } - if (enabled[styleName].length > 0) { - current = current[styleName].apply(current, enabled[styleName]); - } else { - current = current[styleName]; - } - } - } - return current; - } - module.exports = (chalk, tmp) => { - const styles = []; - const chunks = []; - let chunk = []; - tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => { - if (escapeChar) { - chunk.push(unescape(escapeChar)); - } else if (style) { - const str = chunk.join(""); - chunk = []; - chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str)); - styles.push({ inverse, styles: parseStyle(style) }); - } else if (close) { - if (styles.length === 0) { - throw new Error("Found extraneous } in Chalk template literal"); - } - chunks.push(buildStyle(chalk, styles)(chunk.join(""))); - chunk = []; - styles.pop(); - } else { - chunk.push(chr); - } - }); - chunks.push(chunk.join("")); - if (styles.length > 0) { - const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`; - throw new Error(errMsg); - } - return chunks.join(""); - }; - } - }); - - // node_modules/vnopts/node_modules/chalk/index.js - var require_chalk = __commonJS({ - "node_modules/vnopts/node_modules/chalk/index.js"(exports, module) { - "use strict"; - var escapeStringRegexp = require_escape_string_regexp(); - var ansiStyles = require_ansi_styles(); - var stdoutColor = require_browser().stdout; - var template = require_templates(); - var isSimpleWindowsTerm = process.platform === "win32" && !(process.env.TERM || "").toLowerCase().startsWith("xterm"); - var levelMapping = ["ansi", "ansi", "ansi256", "ansi16m"]; - var skipModels = /* @__PURE__ */ new Set(["gray"]); - var styles = /* @__PURE__ */ Object.create(null); - function applyOptions(obj, options) { - options = options || {}; - const scLevel = stdoutColor ? stdoutColor.level : 0; - obj.level = options.level === void 0 ? scLevel : options.level; - obj.enabled = "enabled" in options ? options.enabled : obj.level > 0; - } - function Chalk(options) { - if (!this || !(this instanceof Chalk) || this.template) { - const chalk = {}; - applyOptions(chalk, options); - chalk.template = function() { - const args = [].slice.call(arguments); - return chalkTag.apply(null, [chalk.template].concat(args)); - }; - Object.setPrototypeOf(chalk, Chalk.prototype); - Object.setPrototypeOf(chalk.template, chalk); - chalk.template.constructor = Chalk; - return chalk.template; - } - applyOptions(this, options); - } - if (isSimpleWindowsTerm) { - ansiStyles.blue.open = "\x1B[94m"; - } - for (const key of Object.keys(ansiStyles)) { - ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), "g"); - styles[key] = { - get() { - const codes = ansiStyles[key]; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); - } - }; - } - styles.visible = { - get() { - return build.call(this, this._styles || [], true, "visible"); - } - }; - ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), "g"); - for (const model of Object.keys(ansiStyles.color.ansi)) { - if (skipModels.has(model)) { - continue; - } - styles[model] = { - get() { - const level = this.level; - return function() { - const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments); - const codes = { - open, - close: ansiStyles.color.close, - closeRe: ansiStyles.color.closeRe - }; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); - }; - } - }; - } - ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), "g"); - for (const model of Object.keys(ansiStyles.bgColor.ansi)) { - if (skipModels.has(model)) { - continue; - } - const bgModel = "bg" + model[0].toUpperCase() + model.slice(1); - styles[bgModel] = { - get() { - const level = this.level; - return function() { - const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments); - const codes = { - open, - close: ansiStyles.bgColor.close, - closeRe: ansiStyles.bgColor.closeRe - }; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); - }; - } - }; - } - var proto = Object.defineProperties(() => { - }, styles); - function build(_styles, _empty, key) { - const builder = function() { - return applyStyle.apply(builder, arguments); - }; - builder._styles = _styles; - builder._empty = _empty; - const self = this; - Object.defineProperty(builder, "level", { - enumerable: true, - get() { - return self.level; - }, - set(level) { - self.level = level; - } - }); - Object.defineProperty(builder, "enabled", { - enumerable: true, - get() { - return self.enabled; - }, - set(enabled) { - self.enabled = enabled; - } - }); - builder.hasGrey = this.hasGrey || key === "gray" || key === "grey"; - builder.__proto__ = proto; - return builder; - } - function applyStyle() { - const args = arguments; - const argsLen = args.length; - let str = String(arguments[0]); - if (argsLen === 0) { - return ""; - } - if (argsLen > 1) { - for (let a = 1; a < argsLen; a++) { - str += " " + args[a]; - } - } - if (!this.enabled || this.level <= 0 || !str) { - return this._empty ? "" : str; - } - const originalDim = ansiStyles.dim.open; - if (isSimpleWindowsTerm && this.hasGrey) { - ansiStyles.dim.open = ""; - } - for (const code of this._styles.slice().reverse()) { - str = code.open + str.replace(code.closeRe, code.open) + code.close; - str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); - } - ansiStyles.dim.open = originalDim; - return str; - } - function chalkTag(chalk, strings) { - if (!Array.isArray(strings)) { - return [].slice.call(arguments, 1).join(" "); - } - const args = [].slice.call(arguments, 2); - const parts = [strings.raw[0]]; - for (let i = 1; i < strings.length; i++) { - parts.push(String(args[i - 1]).replace(/[{}\\]/g, "\\$&")); - parts.push(String(strings.raw[i])); - } - return template(chalk, parts.join("")); - } - Object.defineProperties(Chalk.prototype, styles); - module.exports = Chalk(); - module.exports.supportsColor = stdoutColor; - module.exports.default = module.exports; - } - }); - - // node_modules/vnopts/lib/handlers/deprecated/common.js - var require_common = __commonJS({ - "node_modules/vnopts/lib/handlers/deprecated/common.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var chalk_1 = require_chalk(); - exports.commonDeprecatedHandler = (keyOrPair, redirectTo, { descriptor }) => { - const messages = [ - `${chalk_1.default.yellow(typeof keyOrPair === "string" ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair))} is deprecated` - ]; - if (redirectTo) { - messages.push(`we now treat it as ${chalk_1.default.blue(typeof redirectTo === "string" ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))}`); - } - return messages.join("; ") + "."; - }; - } - }); - - // node_modules/vnopts/lib/handlers/deprecated/index.js - var require_deprecated = __commonJS({ - "node_modules/vnopts/lib/handlers/deprecated/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - tslib_1.__exportStar(require_common(), exports); - } - }); - - // node_modules/vnopts/lib/handlers/invalid/common.js - var require_common2 = __commonJS({ - "node_modules/vnopts/lib/handlers/invalid/common.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var chalk_1 = require_chalk(); - exports.commonInvalidHandler = (key, value, utils) => [ - `Invalid ${chalk_1.default.red(utils.descriptor.key(key))} value.`, - `Expected ${chalk_1.default.blue(utils.schemas[key].expected(utils))},`, - `but received ${chalk_1.default.red(utils.descriptor.value(value))}.` - ].join(" "); - } - }); - - // node_modules/vnopts/lib/handlers/invalid/index.js - var require_invalid = __commonJS({ - "node_modules/vnopts/lib/handlers/invalid/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - tslib_1.__exportStar(require_common2(), exports); - } - }); - - // node_modules/vnopts/node_modules/leven/index.js - var require_leven = __commonJS({ - "node_modules/vnopts/node_modules/leven/index.js"(exports, module) { - "use strict"; - var arr = []; - var charCodeCache = []; - module.exports = function(a, b) { - if (a === b) { - return 0; - } - var swap = a; - if (a.length > b.length) { - a = b; - b = swap; - } - var aLen = a.length; - var bLen = b.length; - if (aLen === 0) { - return bLen; - } - if (bLen === 0) { - return aLen; - } - while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) { - aLen--; - bLen--; - } - if (aLen === 0) { - return bLen; - } - var start = 0; - while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) { - start++; - } - aLen -= start; - bLen -= start; - if (aLen === 0) { - return bLen; - } - var bCharCode; - var ret; - var tmp; - var tmp2; - var i = 0; - var j = 0; - while (i < aLen) { - charCodeCache[start + i] = a.charCodeAt(start + i); - arr[i] = ++i; - } - while (j < bLen) { - bCharCode = b.charCodeAt(start + j); - tmp = j++; - ret = j; - for (i = 0; i < aLen; i++) { - tmp2 = bCharCode === charCodeCache[start + i] ? tmp : tmp + 1; - tmp = arr[i]; - ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2; - } - } - return ret; - }; - } - }); - - // node_modules/vnopts/lib/handlers/unknown/leven.js - var require_leven2 = __commonJS({ - "node_modules/vnopts/lib/handlers/unknown/leven.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var chalk_1 = require_chalk(); - var leven = require_leven(); - exports.levenUnknownHandler = (key, value, { descriptor, logger, schemas }) => { - const messages = [ - `Ignored unknown option ${chalk_1.default.yellow(descriptor.pair({ key, value }))}.` - ]; - const suggestion = Object.keys(schemas).sort().find((knownKey) => leven(key, knownKey) < 3); - if (suggestion) { - messages.push(`Did you mean ${chalk_1.default.blue(descriptor.key(suggestion))}?`); - } - logger.warn(messages.join(" ")); - }; - } - }); - - // node_modules/vnopts/lib/handlers/unknown/index.js - var require_unknown = __commonJS({ - "node_modules/vnopts/lib/handlers/unknown/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - tslib_1.__exportStar(require_leven2(), exports); - } - }); - - // node_modules/vnopts/lib/handlers/index.js - var require_handlers = __commonJS({ - "node_modules/vnopts/lib/handlers/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - tslib_1.__exportStar(require_deprecated(), exports); - tslib_1.__exportStar(require_invalid(), exports); - tslib_1.__exportStar(require_unknown(), exports); - } - }); - - // node_modules/vnopts/lib/schema.js - var require_schema = __commonJS({ - "node_modules/vnopts/lib/schema.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var HANDLER_KEYS = [ - "default", - "expected", - "validate", - "deprecated", - "forward", - "redirect", - "overlap", - "preprocess", - "postprocess" - ]; - function createSchema(SchemaConstructor, parameters) { - const schema = new SchemaConstructor(parameters); - const subSchema = Object.create(schema); - for (const handlerKey of HANDLER_KEYS) { - if (handlerKey in parameters) { - subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length); - } - } - return subSchema; - } - exports.createSchema = createSchema; - var Schema = class { - constructor(parameters) { - this.name = parameters.name; - } - static create(parameters) { - return createSchema(this, parameters); - } - default(_utils) { - return void 0; - } - // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length` - expected(_utils) { - return "nothing"; - } - // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length` - validate(_value, _utils) { - return false; - } - deprecated(_value, _utils) { - return false; - } - forward(_value, _utils) { - return void 0; - } - redirect(_value, _utils) { - return void 0; - } - overlap(currentValue, _newValue, _utils) { - return currentValue; - } - preprocess(value, _utils) { - return value; - } - postprocess(value, _utils) { - return value; - } - }; - exports.Schema = Schema; - function normalizeHandler(handler, superSchema, handlerArgumentsLength) { - return typeof handler === "function" ? (...args) => handler(...args.slice(0, handlerArgumentsLength - 1), superSchema, ...args.slice(handlerArgumentsLength - 1)) : () => handler; - } - } - }); - - // node_modules/vnopts/lib/schemas/alias.js - var require_alias = __commonJS({ - "node_modules/vnopts/lib/schemas/alias.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var schema_1 = require_schema(); - var AliasSchema = class extends schema_1.Schema { - constructor(parameters) { - super(parameters); - this._sourceName = parameters.sourceName; - } - expected(utils) { - return utils.schemas[this._sourceName].expected(utils); - } - validate(value, utils) { - return utils.schemas[this._sourceName].validate(value, utils); - } - redirect(_value, _utils) { - return this._sourceName; - } - }; - exports.AliasSchema = AliasSchema; - } - }); - - // node_modules/vnopts/lib/schemas/any.js - var require_any = __commonJS({ - "node_modules/vnopts/lib/schemas/any.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var schema_1 = require_schema(); - var AnySchema = class extends schema_1.Schema { - expected() { - return "anything"; - } - validate() { - return true; - } - }; - exports.AnySchema = AnySchema; - } - }); - - // node_modules/vnopts/lib/schemas/array.js - var require_array = __commonJS({ - "node_modules/vnopts/lib/schemas/array.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - var schema_1 = require_schema(); - var ArraySchema = class extends schema_1.Schema { - constructor(_a) { - var { valueSchema, name = valueSchema.name } = _a, handlers = tslib_1.__rest(_a, ["valueSchema", "name"]); - super(Object.assign({}, handlers, { name })); - this._valueSchema = valueSchema; - } - expected(utils) { - return `an array of ${this._valueSchema.expected(utils)}`; - } - validate(value, utils) { - if (!Array.isArray(value)) { - return false; - } - const invalidValues = []; - for (const subValue of value) { - const subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue); - if (subValidateResult !== true) { - invalidValues.push(subValidateResult.value); - } - } - return invalidValues.length === 0 ? true : { value: invalidValues }; - } - deprecated(value, utils) { - const deprecatedResult = []; - for (const subValue of value) { - const subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue); - if (subDeprecatedResult !== false) { - deprecatedResult.push(...subDeprecatedResult.map(({ value: deprecatedValue }) => ({ - value: [deprecatedValue] - }))); - } - } - return deprecatedResult; - } - forward(value, utils) { - const forwardResult = []; - for (const subValue of value) { - const subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue); - forwardResult.push(...subForwardResult.map(wrapTransferResult)); - } - return forwardResult; - } - redirect(value, utils) { - const remain = []; - const redirect = []; - for (const subValue of value) { - const subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue); - if ("remain" in subRedirectResult) { - remain.push(subRedirectResult.remain); - } - redirect.push(...subRedirectResult.redirect.map(wrapTransferResult)); - } - return remain.length === 0 ? { redirect } : { redirect, remain }; - } - overlap(currentValue, newValue) { - return currentValue.concat(newValue); - } - }; - exports.ArraySchema = ArraySchema; - function wrapTransferResult({ from, to }) { - return { from: [from], to }; - } - } - }); - - // node_modules/vnopts/lib/schemas/boolean.js - var require_boolean = __commonJS({ - "node_modules/vnopts/lib/schemas/boolean.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var schema_1 = require_schema(); - var BooleanSchema = class extends schema_1.Schema { - expected() { - return "true or false"; - } - validate(value) { - return typeof value === "boolean"; - } - }; - exports.BooleanSchema = BooleanSchema; - } - }); - - // node_modules/vnopts/lib/utils.js - var require_utils = __commonJS({ - "node_modules/vnopts/lib/utils.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function recordFromArray(array, mainKey) { - const record = /* @__PURE__ */ Object.create(null); - for (const value of array) { - const key = value[mainKey]; - if (record[key]) { - throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`); - } - record[key] = value; - } - return record; - } - exports.recordFromArray = recordFromArray; - function mapFromArray(array, mainKey) { - const map = /* @__PURE__ */ new Map(); - for (const value of array) { - const key = value[mainKey]; - if (map.has(key)) { - throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`); - } - map.set(key, value); - } - return map; - } - exports.mapFromArray = mapFromArray; - function createAutoChecklist() { - const map = /* @__PURE__ */ Object.create(null); - return (id) => { - const idString = JSON.stringify(id); - if (map[idString]) { - return true; - } - map[idString] = true; - return false; - }; - } - exports.createAutoChecklist = createAutoChecklist; - function partition(array, predicate) { - const trueArray = []; - const falseArray = []; - for (const value of array) { - if (predicate(value)) { - trueArray.push(value); - } else { - falseArray.push(value); - } - } - return [trueArray, falseArray]; - } - exports.partition = partition; - function isInt(value) { - return value === Math.floor(value); - } - exports.isInt = isInt; - function comparePrimitive(a, b) { - if (a === b) { - return 0; - } - const typeofA = typeof a; - const typeofB = typeof b; - const orders = [ - "undefined", - "object", - "boolean", - "number", - "string" - ]; - if (typeofA !== typeofB) { - return orders.indexOf(typeofA) - orders.indexOf(typeofB); - } - if (typeofA !== "string") { - return Number(a) - Number(b); - } - return a.localeCompare(b); - } - exports.comparePrimitive = comparePrimitive; - function normalizeDefaultResult(result) { - return result === void 0 ? {} : result; - } - exports.normalizeDefaultResult = normalizeDefaultResult; - function normalizeValidateResult(result, value) { - return result === true ? true : result === false ? { value } : result; - } - exports.normalizeValidateResult = normalizeValidateResult; - function normalizeDeprecatedResult(result, value, doNotNormalizeTrue = false) { - return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{ value }] : "value" in result ? [result] : result.length === 0 ? false : result; - } - exports.normalizeDeprecatedResult = normalizeDeprecatedResult; - function normalizeTransferResult(result, value) { - return typeof result === "string" || "key" in result ? { from: value, to: result } : "from" in result ? { from: result.from, to: result.to } : { from: value, to: result.to }; - } - exports.normalizeTransferResult = normalizeTransferResult; - function normalizeForwardResult(result, value) { - return result === void 0 ? [] : Array.isArray(result) ? result.map((transferResult) => normalizeTransferResult(transferResult, value)) : [normalizeTransferResult(result, value)]; - } - exports.normalizeForwardResult = normalizeForwardResult; - function normalizeRedirectResult(result, value) { - const redirect = normalizeForwardResult(typeof result === "object" && "redirect" in result ? result.redirect : result, value); - return redirect.length === 0 ? { remain: value, redirect } : typeof result === "object" && "remain" in result ? { remain: result.remain, redirect } : { redirect }; - } - exports.normalizeRedirectResult = normalizeRedirectResult; - } - }); - - // node_modules/vnopts/lib/schemas/choice.js - var require_choice = __commonJS({ - "node_modules/vnopts/lib/schemas/choice.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var schema_1 = require_schema(); - var utils_1 = require_utils(); - var ChoiceSchema = class extends schema_1.Schema { - constructor(parameters) { - super(parameters); - this._choices = utils_1.mapFromArray(parameters.choices.map((choice) => choice && typeof choice === "object" ? choice : { value: choice }), "value"); - } - expected({ descriptor }) { - const choiceValues = Array.from(this._choices.keys()).map((value) => this._choices.get(value)).filter((choiceInfo) => !choiceInfo.deprecated).map((choiceInfo) => choiceInfo.value).sort(utils_1.comparePrimitive).map(descriptor.value); - const head = choiceValues.slice(0, -2); - const tail = choiceValues.slice(-2); - return head.concat(tail.join(" or ")).join(", "); - } - validate(value) { - return this._choices.has(value); - } - deprecated(value) { - const choiceInfo = this._choices.get(value); - return choiceInfo && choiceInfo.deprecated ? { value } : false; - } - forward(value) { - const choiceInfo = this._choices.get(value); - return choiceInfo ? choiceInfo.forward : void 0; - } - redirect(value) { - const choiceInfo = this._choices.get(value); - return choiceInfo ? choiceInfo.redirect : void 0; - } - }; - exports.ChoiceSchema = ChoiceSchema; - } - }); - - // node_modules/vnopts/lib/schemas/number.js - var require_number = __commonJS({ - "node_modules/vnopts/lib/schemas/number.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var schema_1 = require_schema(); - var NumberSchema = class extends schema_1.Schema { - expected() { - return "a number"; - } - validate(value, _utils) { - return typeof value === "number"; - } - }; - exports.NumberSchema = NumberSchema; - } - }); - - // node_modules/vnopts/lib/schemas/integer.js - var require_integer = __commonJS({ - "node_modules/vnopts/lib/schemas/integer.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var utils_1 = require_utils(); - var number_1 = require_number(); - var IntegerSchema = class extends number_1.NumberSchema { - expected() { - return "an integer"; - } - validate(value, utils) { - return utils.normalizeValidateResult(super.validate(value, utils), value) === true && utils_1.isInt(value); - } - }; - exports.IntegerSchema = IntegerSchema; - } - }); - - // node_modules/vnopts/lib/schemas/string.js - var require_string = __commonJS({ - "node_modules/vnopts/lib/schemas/string.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var schema_1 = require_schema(); - var StringSchema = class extends schema_1.Schema { - expected() { - return "a string"; - } - validate(value) { - return typeof value === "string"; - } - }; - exports.StringSchema = StringSchema; - } - }); - - // node_modules/vnopts/lib/schemas/index.js - var require_schemas = __commonJS({ - "node_modules/vnopts/lib/schemas/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - tslib_1.__exportStar(require_alias(), exports); - tslib_1.__exportStar(require_any(), exports); - tslib_1.__exportStar(require_array(), exports); - tslib_1.__exportStar(require_boolean(), exports); - tslib_1.__exportStar(require_choice(), exports); - tslib_1.__exportStar(require_integer(), exports); - tslib_1.__exportStar(require_number(), exports); - tslib_1.__exportStar(require_string(), exports); - } - }); - - // node_modules/vnopts/lib/defaults.js - var require_defaults = __commonJS({ - "node_modules/vnopts/lib/defaults.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var api_1 = require_api(); - var common_1 = require_common(); - var invalid_1 = require_invalid(); - var leven_1 = require_leven2(); - exports.defaultDescriptor = api_1.apiDescriptor; - exports.defaultUnknownHandler = leven_1.levenUnknownHandler; - exports.defaultInvalidHandler = invalid_1.commonInvalidHandler; - exports.defaultDeprecatedHandler = common_1.commonDeprecatedHandler; - } - }); - - // node_modules/vnopts/lib/normalize.js - var require_normalize = __commonJS({ - "node_modules/vnopts/lib/normalize.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var defaults_1 = require_defaults(); - var utils_1 = require_utils(); - exports.normalize = (options, schemas, opts) => new Normalizer(schemas, opts).normalize(options); - var Normalizer = class { - constructor(schemas, opts) { - const { logger = console, descriptor = defaults_1.defaultDescriptor, unknown = defaults_1.defaultUnknownHandler, invalid = defaults_1.defaultInvalidHandler, deprecated = defaults_1.defaultDeprecatedHandler } = opts || {}; - this._utils = { - descriptor, - logger: ( - /* istanbul ignore next */ - logger || { warn: () => { - } } - ), - schemas: utils_1.recordFromArray(schemas, "name"), - normalizeDefaultResult: utils_1.normalizeDefaultResult, - normalizeDeprecatedResult: utils_1.normalizeDeprecatedResult, - normalizeForwardResult: utils_1.normalizeForwardResult, - normalizeRedirectResult: utils_1.normalizeRedirectResult, - normalizeValidateResult: utils_1.normalizeValidateResult - }; - this._unknownHandler = unknown; - this._invalidHandler = invalid; - this._deprecatedHandler = deprecated; - this.cleanHistory(); - } - cleanHistory() { - this._hasDeprecationWarned = utils_1.createAutoChecklist(); - } - normalize(options) { - const normalized = {}; - const restOptionsArray = [options]; - const applyNormalization = () => { - while (restOptionsArray.length !== 0) { - const currentOptions = restOptionsArray.shift(); - const transferredOptionsArray = this._applyNormalization(currentOptions, normalized); - restOptionsArray.push(...transferredOptionsArray); - } - }; - applyNormalization(); - for (const key of Object.keys(this._utils.schemas)) { - const schema = this._utils.schemas[key]; - if (!(key in normalized)) { - const defaultResult = utils_1.normalizeDefaultResult(schema.default(this._utils)); - if ("value" in defaultResult) { - restOptionsArray.push({ [key]: defaultResult.value }); - } - } - } - applyNormalization(); - for (const key of Object.keys(this._utils.schemas)) { - const schema = this._utils.schemas[key]; - if (key in normalized) { - normalized[key] = schema.postprocess(normalized[key], this._utils); - } - } - return normalized; - } - _applyNormalization(options, normalized) { - const transferredOptionsArray = []; - const [knownOptionNames, unknownOptionNames] = utils_1.partition(Object.keys(options), (key) => key in this._utils.schemas); - for (const key of knownOptionNames) { - const schema = this._utils.schemas[key]; - const value = schema.preprocess(options[key], this._utils); - const validateResult = utils_1.normalizeValidateResult(schema.validate(value, this._utils), value); - if (validateResult !== true) { - const { value: invalidValue } = validateResult; - const errorMessageOrError = this._invalidHandler(key, invalidValue, this._utils); - throw typeof errorMessageOrError === "string" ? new Error(errorMessageOrError) : ( - /* istanbul ignore next*/ - errorMessageOrError - ); - } - const appendTransferredOptions = ({ from, to }) => { - transferredOptionsArray.push(typeof to === "string" ? { [to]: from } : { [to.key]: to.value }); - }; - const warnDeprecated = ({ value: currentValue, redirectTo }) => { - const deprecatedResult = utils_1.normalizeDeprecatedResult( - schema.deprecated(currentValue, this._utils), - value, - /* doNotNormalizeTrue */ - true - ); - if (deprecatedResult === false) { - return; - } - if (deprecatedResult === true) { - if (!this._hasDeprecationWarned(key)) { - this._utils.logger.warn(this._deprecatedHandler(key, redirectTo, this._utils)); - } - } else { - for (const { value: deprecatedValue } of deprecatedResult) { - const pair = { key, value: deprecatedValue }; - if (!this._hasDeprecationWarned(pair)) { - const redirectToPair = typeof redirectTo === "string" ? { key: redirectTo, value: deprecatedValue } : redirectTo; - this._utils.logger.warn(this._deprecatedHandler(pair, redirectToPair, this._utils)); - } - } - } - }; - const forwardResult = utils_1.normalizeForwardResult(schema.forward(value, this._utils), value); - forwardResult.forEach(appendTransferredOptions); - const redirectResult = utils_1.normalizeRedirectResult(schema.redirect(value, this._utils), value); - redirectResult.redirect.forEach(appendTransferredOptions); - if ("remain" in redirectResult) { - const remainingValue = redirectResult.remain; - normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, this._utils) : remainingValue; - warnDeprecated({ value: remainingValue }); - } - for (const { from, to } of redirectResult.redirect) { - warnDeprecated({ value: from, redirectTo: to }); - } - } - for (const key of unknownOptionNames) { - const value = options[key]; - const unknownResult = this._unknownHandler(key, value, this._utils); - if (unknownResult) { - for (const unknownKey of Object.keys(unknownResult)) { - const unknownOption = { [unknownKey]: unknownResult[unknownKey] }; - if (unknownKey in this._utils.schemas) { - transferredOptionsArray.push(unknownOption); - } else { - Object.assign(normalized, unknownOption); - } - } - } - } - return transferredOptionsArray; - } - }; - exports.Normalizer = Normalizer; - } - }); - - // node_modules/vnopts/lib/index.js - var require_lib = __commonJS({ - "node_modules/vnopts/lib/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - tslib_1.__exportStar(require_descriptors(), exports); - tslib_1.__exportStar(require_handlers(), exports); - tslib_1.__exportStar(require_schemas(), exports); - tslib_1.__exportStar(require_normalize(), exports); - tslib_1.__exportStar(require_schema(), exports); - } - }); - - // node_modules/js-tokens/index.js - var require_js_tokens = __commonJS({ - "node_modules/js-tokens/index.js"(exports) { - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g; - exports.matchToToken = function(match) { - var token = { type: "invalid", value: match[0], closed: void 0 }; - if (match[1]) - token.type = "string", token.closed = !!(match[3] || match[4]); - else if (match[5]) - token.type = "comment"; - else if (match[6]) - token.type = "comment", token.closed = !!match[7]; - else if (match[8]) - token.type = "regex"; - else if (match[9]) - token.type = "number"; - else if (match[10]) - token.type = "name"; - else if (match[11]) - token.type = "punctuator"; - else if (match[12]) - token.type = "whitespace"; - return token; - }; - } - }); - - // node_modules/@babel/helper-validator-identifier/lib/identifier.js - var require_identifier = __commonJS({ - "node_modules/@babel/helper-validator-identifier/lib/identifier.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.isIdentifierChar = isIdentifierChar; - exports.isIdentifierName = isIdentifierName; - exports.isIdentifierStart = isIdentifierStart; - var nonASCIIidentifierStartChars = "\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC"; - var nonASCIIidentifierChars = "\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F"; - var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); - var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); - nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; - var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938, 6, 4191]; - var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; - function isInAstralSet(code, set) { - let pos = 65536; - for (let i = 0, length = set.length; i < length; i += 2) { - pos += set[i]; - if (pos > code) - return false; - pos += set[i + 1]; - if (pos >= code) - return true; - } - return false; - } - function isIdentifierStart(code) { - if (code < 65) - return code === 36; - if (code <= 90) - return true; - if (code < 97) - return code === 95; - if (code <= 122) - return true; - if (code <= 65535) { - return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code)); - } - return isInAstralSet(code, astralIdentifierStartCodes); - } - function isIdentifierChar(code) { - if (code < 48) - return code === 36; - if (code < 58) - return true; - if (code < 65) - return false; - if (code <= 90) - return true; - if (code < 97) - return code === 95; - if (code <= 122) - return true; - if (code <= 65535) { - return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code)); - } - return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); - } - function isIdentifierName(name) { - let isFirst = true; - for (let i = 0; i < name.length; i++) { - let cp = name.charCodeAt(i); - if ((cp & 64512) === 55296 && i + 1 < name.length) { - const trail = name.charCodeAt(++i); - if ((trail & 64512) === 56320) { - cp = 65536 + ((cp & 1023) << 10) + (trail & 1023); - } - } - if (isFirst) { - isFirst = false; - if (!isIdentifierStart(cp)) { - return false; - } - } else if (!isIdentifierChar(cp)) { - return false; - } - } - return !isFirst; - } - } - }); - - // node_modules/@babel/helper-validator-identifier/lib/keyword.js - var require_keyword = __commonJS({ - "node_modules/@babel/helper-validator-identifier/lib/keyword.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.isKeyword = isKeyword; - exports.isReservedWord = isReservedWord; - exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord; - exports.isStrictBindReservedWord = isStrictBindReservedWord; - exports.isStrictReservedWord = isStrictReservedWord; - var reservedWords = { - keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"], - strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], - strictBind: ["eval", "arguments"] - }; - var keywords = new Set(reservedWords.keyword); - var reservedWordsStrictSet = new Set(reservedWords.strict); - var reservedWordsStrictBindSet = new Set(reservedWords.strictBind); - function isReservedWord(word, inModule) { - return inModule && word === "await" || word === "enum"; - } - function isStrictReservedWord(word, inModule) { - return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); - } - function isStrictBindOnlyReservedWord(word) { - return reservedWordsStrictBindSet.has(word); - } - function isStrictBindReservedWord(word, inModule) { - return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); - } - function isKeyword(word) { - return keywords.has(word); - } - } - }); - - // node_modules/@babel/helper-validator-identifier/lib/index.js - var require_lib2 = __commonJS({ - "node_modules/@babel/helper-validator-identifier/lib/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - Object.defineProperty(exports, "isIdentifierChar", { - enumerable: true, - get: function() { - return _identifier.isIdentifierChar; - } - }); - Object.defineProperty(exports, "isIdentifierName", { - enumerable: true, - get: function() { - return _identifier.isIdentifierName; - } - }); - Object.defineProperty(exports, "isIdentifierStart", { - enumerable: true, - get: function() { - return _identifier.isIdentifierStart; - } - }); - Object.defineProperty(exports, "isKeyword", { - enumerable: true, - get: function() { - return _keyword.isKeyword; - } - }); - Object.defineProperty(exports, "isReservedWord", { - enumerable: true, - get: function() { - return _keyword.isReservedWord; - } - }); - Object.defineProperty(exports, "isStrictBindOnlyReservedWord", { - enumerable: true, - get: function() { - return _keyword.isStrictBindOnlyReservedWord; - } - }); - Object.defineProperty(exports, "isStrictBindReservedWord", { - enumerable: true, - get: function() { - return _keyword.isStrictBindReservedWord; - } - }); - Object.defineProperty(exports, "isStrictReservedWord", { - enumerable: true, - get: function() { - return _keyword.isStrictReservedWord; - } - }); - var _identifier = require_identifier(); - var _keyword = require_keyword(); - } - }); - - // node_modules/@babel/highlight/node_modules/escape-string-regexp/index.js - var require_escape_string_regexp2 = __commonJS({ - "node_modules/@babel/highlight/node_modules/escape-string-regexp/index.js"(exports, module) { - "use strict"; - var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; - module.exports = function(str) { - if (typeof str !== "string") { - throw new TypeError("Expected a string"); - } - return str.replace(matchOperatorsRe, "\\$&"); - }; - } - }); - - // node_modules/@babel/highlight/node_modules/supports-color/browser.js - var require_browser2 = __commonJS({ - "node_modules/@babel/highlight/node_modules/supports-color/browser.js"(exports, module) { - "use strict"; - module.exports = { - stdout: false, - stderr: false - }; - } - }); - - // node_modules/@babel/highlight/node_modules/chalk/templates.js - var require_templates2 = __commonJS({ - "node_modules/@babel/highlight/node_modules/chalk/templates.js"(exports, module) { - "use strict"; - var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; - var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; - var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; - var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi; - var ESCAPES = /* @__PURE__ */ new Map([ - ["n", "\n"], - ["r", "\r"], - ["t", " "], - ["b", "\b"], - ["f", "\f"], - ["v", "\v"], - ["0", "\0"], - ["\\", "\\"], - ["e", "\x1B"], - ["a", "\x07"] - ]); - function unescape(c) { - if (c[0] === "u" && c.length === 5 || c[0] === "x" && c.length === 3) { - return String.fromCharCode(parseInt(c.slice(1), 16)); - } - return ESCAPES.get(c) || c; - } - function parseArguments(name, args) { - const results = []; - const chunks = args.trim().split(/\s*,\s*/g); - let matches; - for (const chunk of chunks) { - if (!isNaN(chunk)) { - results.push(Number(chunk)); - } else if (matches = chunk.match(STRING_REGEX)) { - results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr)); - } else { - throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); - } - } - return results; - } - function parseStyle(style) { - STYLE_REGEX.lastIndex = 0; - const results = []; - let matches; - while ((matches = STYLE_REGEX.exec(style)) !== null) { - const name = matches[1]; - if (matches[2]) { - const args = parseArguments(name, matches[2]); - results.push([name].concat(args)); - } else { - results.push([name]); - } - } - return results; - } - function buildStyle(chalk, styles) { - const enabled = {}; - for (const layer of styles) { - for (const style of layer.styles) { - enabled[style[0]] = layer.inverse ? null : style.slice(1); - } - } - let current = chalk; - for (const styleName of Object.keys(enabled)) { - if (Array.isArray(enabled[styleName])) { - if (!(styleName in current)) { - throw new Error(`Unknown Chalk style: ${styleName}`); - } - if (enabled[styleName].length > 0) { - current = current[styleName].apply(current, enabled[styleName]); - } else { - current = current[styleName]; - } - } - } - return current; - } - module.exports = (chalk, tmp) => { - const styles = []; - const chunks = []; - let chunk = []; - tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => { - if (escapeChar) { - chunk.push(unescape(escapeChar)); - } else if (style) { - const str = chunk.join(""); - chunk = []; - chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str)); - styles.push({ inverse, styles: parseStyle(style) }); - } else if (close) { - if (styles.length === 0) { - throw new Error("Found extraneous } in Chalk template literal"); - } - chunks.push(buildStyle(chalk, styles)(chunk.join(""))); - chunk = []; - styles.pop(); - } else { - chunk.push(chr); - } - }); - chunks.push(chunk.join("")); - if (styles.length > 0) { - const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`; - throw new Error(errMsg); - } - return chunks.join(""); - }; - } - }); - - // node_modules/@babel/highlight/node_modules/chalk/index.js - var require_chalk2 = __commonJS({ - "node_modules/@babel/highlight/node_modules/chalk/index.js"(exports, module) { - "use strict"; - var escapeStringRegexp = require_escape_string_regexp2(); - var ansiStyles = require_ansi_styles(); - var stdoutColor = require_browser2().stdout; - var template = require_templates2(); - var isSimpleWindowsTerm = process.platform === "win32" && !(process.env.TERM || "").toLowerCase().startsWith("xterm"); - var levelMapping = ["ansi", "ansi", "ansi256", "ansi16m"]; - var skipModels = /* @__PURE__ */ new Set(["gray"]); - var styles = /* @__PURE__ */ Object.create(null); - function applyOptions(obj, options) { - options = options || {}; - const scLevel = stdoutColor ? stdoutColor.level : 0; - obj.level = options.level === void 0 ? scLevel : options.level; - obj.enabled = "enabled" in options ? options.enabled : obj.level > 0; - } - function Chalk(options) { - if (!this || !(this instanceof Chalk) || this.template) { - const chalk = {}; - applyOptions(chalk, options); - chalk.template = function() { - const args = [].slice.call(arguments); - return chalkTag.apply(null, [chalk.template].concat(args)); - }; - Object.setPrototypeOf(chalk, Chalk.prototype); - Object.setPrototypeOf(chalk.template, chalk); - chalk.template.constructor = Chalk; - return chalk.template; - } - applyOptions(this, options); - } - if (isSimpleWindowsTerm) { - ansiStyles.blue.open = "\x1B[94m"; - } - for (const key of Object.keys(ansiStyles)) { - ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), "g"); - styles[key] = { - get() { - const codes = ansiStyles[key]; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); - } - }; - } - styles.visible = { - get() { - return build.call(this, this._styles || [], true, "visible"); - } - }; - ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), "g"); - for (const model of Object.keys(ansiStyles.color.ansi)) { - if (skipModels.has(model)) { - continue; - } - styles[model] = { - get() { - const level = this.level; - return function() { - const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments); - const codes = { - open, - close: ansiStyles.color.close, - closeRe: ansiStyles.color.closeRe - }; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); - }; - } - }; - } - ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), "g"); - for (const model of Object.keys(ansiStyles.bgColor.ansi)) { - if (skipModels.has(model)) { - continue; - } - const bgModel = "bg" + model[0].toUpperCase() + model.slice(1); - styles[bgModel] = { - get() { - const level = this.level; - return function() { - const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments); - const codes = { - open, - close: ansiStyles.bgColor.close, - closeRe: ansiStyles.bgColor.closeRe - }; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); - }; - } - }; - } - var proto = Object.defineProperties(() => { - }, styles); - function build(_styles, _empty, key) { - const builder = function() { - return applyStyle.apply(builder, arguments); - }; - builder._styles = _styles; - builder._empty = _empty; - const self = this; - Object.defineProperty(builder, "level", { - enumerable: true, - get() { - return self.level; - }, - set(level) { - self.level = level; - } - }); - Object.defineProperty(builder, "enabled", { - enumerable: true, - get() { - return self.enabled; - }, - set(enabled) { - self.enabled = enabled; - } - }); - builder.hasGrey = this.hasGrey || key === "gray" || key === "grey"; - builder.__proto__ = proto; - return builder; - } - function applyStyle() { - const args = arguments; - const argsLen = args.length; - let str = String(arguments[0]); - if (argsLen === 0) { - return ""; - } - if (argsLen > 1) { - for (let a = 1; a < argsLen; a++) { - str += " " + args[a]; - } - } - if (!this.enabled || this.level <= 0 || !str) { - return this._empty ? "" : str; - } - const originalDim = ansiStyles.dim.open; - if (isSimpleWindowsTerm && this.hasGrey) { - ansiStyles.dim.open = ""; - } - for (const code of this._styles.slice().reverse()) { - str = code.open + str.replace(code.closeRe, code.open) + code.close; - str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); - } - ansiStyles.dim.open = originalDim; - return str; - } - function chalkTag(chalk, strings) { - if (!Array.isArray(strings)) { - return [].slice.call(arguments, 1).join(" "); - } - const args = [].slice.call(arguments, 2); - const parts = [strings.raw[0]]; - for (let i = 1; i < strings.length; i++) { - parts.push(String(args[i - 1]).replace(/[{}\\]/g, "\\$&")); - parts.push(String(strings.raw[i])); - } - return template(chalk, parts.join("")); - } - Object.defineProperties(Chalk.prototype, styles); - module.exports = Chalk(); - module.exports.supportsColor = stdoutColor; - module.exports.default = module.exports; + // scripts/build/shims/chalk.cjs + var require_chalk = __commonJS({ + "scripts/build/shims/chalk.cjs"(exports, module) { + "use strict"; + var chalk4 = new Proxy(String, { get: () => chalk4 }); + module.exports = chalk4; } }); - // node_modules/@babel/highlight/lib/index.js - var require_lib3 = __commonJS({ - "node_modules/@babel/highlight/lib/index.js"(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = highlight; - exports.getChalk = getChalk; - exports.shouldHighlight = shouldHighlight; - var _jsTokens = require_js_tokens(); - var _helperValidatorIdentifier = require_lib2(); - var _chalk = require_chalk2(); - var sometimesKeywords = /* @__PURE__ */ new Set(["as", "async", "from", "get", "of", "set"]); - function getDefs(chalk) { - return { - keyword: chalk.cyan, - capitalized: chalk.yellow, - jsxIdentifier: chalk.yellow, - punctuator: chalk.yellow, - number: chalk.magenta, - string: chalk.green, - regex: chalk.magenta, - comment: chalk.grey, - invalid: chalk.white.bgRed.bold - }; - } - var NEWLINE = /\r\n|[\n\r\u2028\u2029]/; - var BRACKET = /^[()[\]{}]$/; - var tokenize; - { - const JSX_TAG = /^[a-z][\w-]*$/i; - const getTokenType = function(token, offset, text) { - if (token.type === "name") { - if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) { - return "keyword"; - } - if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) == " colorize(str)).join("\n"); - } else { - highlighted += value; - } - } - return highlighted; - } - function shouldHighlight(options) { - return !!_chalk.supportsColor || options.forceColor; - } - function getChalk(options) { - return options.forceColor ? new _chalk.constructor({ - enabled: true, - level: 1 - }) : _chalk; - } - function highlight(code, options = {}) { - if (code !== "" && shouldHighlight(options)) { - const chalk = getChalk(options); - const defs = getDefs(chalk); - return highlightTokens(defs, code); - } else { - return code; - } - } + // scripts/build/shims/babel-highlight.js + var babel_highlight_exports = {}; + __export(babel_highlight_exports, { + default: () => babel_highlight_default, + shouldHighlight: () => shouldHighlight + }); + var shouldHighlight, babel_highlight_default; + var init_babel_highlight = __esm({ + "scripts/build/shims/babel-highlight.js"() { + shouldHighlight = () => false; + babel_highlight_default = String; } }); // node_modules/@babel/code-frame/lib/index.js - var require_lib4 = __commonJS({ + var require_lib = __commonJS({ "node_modules/@babel/code-frame/lib/index.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3279,13 +100,27 @@ }); exports.codeFrameColumns = codeFrameColumns2; exports.default = _default; - var _highlight = require_lib3(); + var _highlight = (init_babel_highlight(), __toCommonJS(babel_highlight_exports)); + var _chalk2 = require_chalk(); + var chalk4 = _chalk2; + var chalkWithForcedColor = void 0; + function getChalk(forceColor) { + if (forceColor) { + var _chalkWithForcedColor; + (_chalkWithForcedColor = chalkWithForcedColor) != null ? _chalkWithForcedColor : chalkWithForcedColor = new chalk4.constructor({ + enabled: true, + level: 1 + }); + return chalkWithForcedColor; + } + return chalk4; + } var deprecationWarningShown = false; - function getDefs(chalk) { + function getDefs(chalk5) { return { - gutter: chalk.grey, - marker: chalk.red.bold, - message: chalk.red.bold + gutter: chalk5.grey, + marker: chalk5.red.bold, + message: chalk5.red.bold }; } var NEWLINE = /\r\n|[\n\r\u2028\u2029]/; @@ -3347,8 +182,8 @@ } function codeFrameColumns2(rawLines, loc, opts = {}) { const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts); - const chalk = (0, _highlight.getChalk)(opts); - const defs = getDefs(chalk); + const chalk5 = getChalk(opts.forceColor); + const defs = getDefs(chalk5); const maybeHighlight = (chalkFn, string) => { return highlighted ? chalkFn(string) : string; }; @@ -3387,7 +222,7 @@ ${frame}`; } if (highlighted) { - return chalk.reset(frame); + return chalk5.reset(frame); } else { return frame; } @@ -4057,10 +892,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; } // scripts/build/shims/assert.js - var assert = () => { - }; - assert.ok = assert; - assert.strictEqual = assert; + var assert = new Proxy(() => { + }, { get: () => assert }); var assert_default = assert; // src/utils/skip.js @@ -4611,8 +1444,10 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; // src/common/errors.js var ConfigError = class extends Error { + name = "ConfigError"; }; var UndefinedParserError = class extends Error { + name = "UndefinedParserError"; }; // src/main/core-options.evaluate.js @@ -4983,8 +1818,700 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; } var infer_parser_default = inferParser; + // node_modules/vnopts/lib/descriptors/api.js + var apiDescriptor = { + key: (key) => /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(key) ? key : JSON.stringify(key), + value(value) { + if (value === null || typeof value !== "object") { + return JSON.stringify(value); + } + if (Array.isArray(value)) { + return `[${value.map((subValue) => apiDescriptor.value(subValue)).join(", ")}]`; + } + const keys = Object.keys(value); + return keys.length === 0 ? "{}" : `{ ${keys.map((key) => `${apiDescriptor.key(key)}: ${apiDescriptor.value(value[key])}`).join(", ")} }`; + }, + pair: ({ key, value }) => apiDescriptor.value({ [key]: value }) + }; + + // node_modules/vnopts/lib/handlers/deprecated/common.js + var import_chalk = __toESM(require_chalk(), 1); + var commonDeprecatedHandler = (keyOrPair, redirectTo, { descriptor }) => { + const messages = [ + `${import_chalk.default.yellow(typeof keyOrPair === "string" ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair))} is deprecated` + ]; + if (redirectTo) { + messages.push(`we now treat it as ${import_chalk.default.blue(typeof redirectTo === "string" ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))}`); + } + return messages.join("; ") + "."; + }; + + // node_modules/vnopts/lib/handlers/invalid/common.js + var import_chalk2 = __toESM(require_chalk(), 1); + + // node_modules/vnopts/lib/constants.js + var VALUE_NOT_EXIST = Symbol.for("vnopts.VALUE_NOT_EXIST"); + var VALUE_UNCHANGED = Symbol.for("vnopts.VALUE_UNCHANGED"); + + // node_modules/vnopts/lib/handlers/invalid/common.js + var INDENTATION = " ".repeat(2); + var commonInvalidHandler = (key, value, utils) => { + const { text, list } = utils.normalizeExpectedResult(utils.schemas[key].expected(utils)); + const descriptions = []; + if (text) { + descriptions.push(getDescription(key, value, text, utils.descriptor)); + } + if (list) { + descriptions.push([getDescription(key, value, list.title, utils.descriptor)].concat(list.values.map((valueDescription) => getListDescription(valueDescription, utils.loggerPrintWidth))).join("\n")); + } + return chooseDescription(descriptions, utils.loggerPrintWidth); + }; + function getDescription(key, value, expected, descriptor) { + return [ + `Invalid ${import_chalk2.default.red(descriptor.key(key))} value.`, + `Expected ${import_chalk2.default.blue(expected)},`, + `but received ${value === VALUE_NOT_EXIST ? import_chalk2.default.gray("nothing") : import_chalk2.default.red(descriptor.value(value))}.` + ].join(" "); + } + function getListDescription({ text, list }, printWidth) { + const descriptions = []; + if (text) { + descriptions.push(`- ${import_chalk2.default.blue(text)}`); + } + if (list) { + descriptions.push([`- ${import_chalk2.default.blue(list.title)}:`].concat(list.values.map((valueDescription) => getListDescription(valueDescription, printWidth - INDENTATION.length).replace(/^|\n/g, `$&${INDENTATION}`))).join("\n")); + } + return chooseDescription(descriptions, printWidth); + } + function chooseDescription(descriptions, printWidth) { + if (descriptions.length === 1) { + return descriptions[0]; + } + const [firstDescription, secondDescription] = descriptions; + const [firstWidth, secondWidth] = descriptions.map((description) => description.split("\n", 1)[0].length); + return firstWidth > printWidth && firstWidth > secondWidth ? secondDescription : firstDescription; + } + + // node_modules/vnopts/lib/handlers/unknown/leven.js + var import_chalk3 = __toESM(require_chalk(), 1); + + // node_modules/leven/index.js + var array = []; + var characterCodeCache = []; + function leven(first, second) { + if (first === second) { + return 0; + } + const swap = first; + if (first.length > second.length) { + first = second; + second = swap; + } + let firstLength = first.length; + let secondLength = second.length; + while (firstLength > 0 && first.charCodeAt(~-firstLength) === second.charCodeAt(~-secondLength)) { + firstLength--; + secondLength--; + } + let start = 0; + while (start < firstLength && first.charCodeAt(start) === second.charCodeAt(start)) { + start++; + } + firstLength -= start; + secondLength -= start; + if (firstLength === 0) { + return secondLength; + } + let bCharacterCode; + let result; + let temporary; + let temporary2; + let index = 0; + let index2 = 0; + while (index < firstLength) { + characterCodeCache[index] = first.charCodeAt(start + index); + array[index] = ++index; + } + while (index2 < secondLength) { + bCharacterCode = second.charCodeAt(start + index2); + temporary = index2++; + result = index2; + for (index = 0; index < firstLength; index++) { + temporary2 = bCharacterCode === characterCodeCache[index] ? temporary : temporary + 1; + temporary = array[index]; + result = array[index] = temporary > result ? temporary2 > result ? result + 1 : temporary2 : temporary2 > temporary ? temporary + 1 : temporary2; + } + } + return result; + } + + // node_modules/vnopts/lib/handlers/unknown/leven.js + var levenUnknownHandler = (key, value, { descriptor, logger, schemas }) => { + const messages = [ + `Ignored unknown option ${import_chalk3.default.yellow(descriptor.pair({ key, value }))}.` + ]; + const suggestion = Object.keys(schemas).sort().find((knownKey) => leven(key, knownKey) < 3); + if (suggestion) { + messages.push(`Did you mean ${import_chalk3.default.blue(descriptor.key(suggestion))}?`); + } + logger.warn(messages.join(" ")); + }; + + // node_modules/vnopts/lib/schema.js + var HANDLER_KEYS = [ + "default", + "expected", + "validate", + "deprecated", + "forward", + "redirect", + "overlap", + "preprocess", + "postprocess" + ]; + function createSchema(SchemaConstructor, parameters) { + const schema = new SchemaConstructor(parameters); + const subSchema = Object.create(schema); + for (const handlerKey of HANDLER_KEYS) { + if (handlerKey in parameters) { + subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length); + } + } + return subSchema; + } + var Schema = class { + static create(parameters) { + return createSchema(this, parameters); + } + constructor(parameters) { + this.name = parameters.name; + } + default(_utils) { + return void 0; + } + // this is actually an abstract method but we need a placeholder to get `function.length` + /* c8 ignore start */ + expected(_utils) { + return "nothing"; + } + /* c8 ignore stop */ + // this is actually an abstract method but we need a placeholder to get `function.length` + /* c8 ignore start */ + validate(_value, _utils) { + return false; + } + /* c8 ignore stop */ + deprecated(_value, _utils) { + return false; + } + forward(_value, _utils) { + return void 0; + } + redirect(_value, _utils) { + return void 0; + } + overlap(currentValue, _newValue, _utils) { + return currentValue; + } + preprocess(value, _utils) { + return value; + } + postprocess(_value, _utils) { + return VALUE_UNCHANGED; + } + }; + function normalizeHandler(handler, superSchema, handlerArgumentsLength) { + return typeof handler === "function" ? (...args) => handler(...args.slice(0, handlerArgumentsLength - 1), superSchema, ...args.slice(handlerArgumentsLength - 1)) : () => handler; + } + + // node_modules/vnopts/lib/schemas/alias.js + var AliasSchema = class extends Schema { + constructor(parameters) { + super(parameters); + this._sourceName = parameters.sourceName; + } + expected(utils) { + return utils.schemas[this._sourceName].expected(utils); + } + validate(value, utils) { + return utils.schemas[this._sourceName].validate(value, utils); + } + redirect(_value, _utils) { + return this._sourceName; + } + }; + + // node_modules/vnopts/lib/schemas/any.js + var AnySchema = class extends Schema { + expected() { + return "anything"; + } + validate() { + return true; + } + }; + + // node_modules/vnopts/lib/schemas/array.js + var ArraySchema = class extends Schema { + constructor({ valueSchema, name = valueSchema.name, ...handlers }) { + super({ ...handlers, name }); + this._valueSchema = valueSchema; + } + expected(utils) { + const { text, list } = utils.normalizeExpectedResult(this._valueSchema.expected(utils)); + return { + text: text && `an array of ${text}`, + list: list && { + title: `an array of the following values`, + values: [{ list }] + } + }; + } + validate(value, utils) { + if (!Array.isArray(value)) { + return false; + } + const invalidValues = []; + for (const subValue of value) { + const subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue); + if (subValidateResult !== true) { + invalidValues.push(subValidateResult.value); + } + } + return invalidValues.length === 0 ? true : { value: invalidValues }; + } + deprecated(value, utils) { + const deprecatedResult = []; + for (const subValue of value) { + const subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue); + if (subDeprecatedResult !== false) { + deprecatedResult.push(...subDeprecatedResult.map(({ value: deprecatedValue }) => ({ + value: [deprecatedValue] + }))); + } + } + return deprecatedResult; + } + forward(value, utils) { + const forwardResult = []; + for (const subValue of value) { + const subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue); + forwardResult.push(...subForwardResult.map(wrapTransferResult)); + } + return forwardResult; + } + redirect(value, utils) { + const remain = []; + const redirect = []; + for (const subValue of value) { + const subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue); + if ("remain" in subRedirectResult) { + remain.push(subRedirectResult.remain); + } + redirect.push(...subRedirectResult.redirect.map(wrapTransferResult)); + } + return remain.length === 0 ? { redirect } : { redirect, remain }; + } + overlap(currentValue, newValue) { + return currentValue.concat(newValue); + } + }; + function wrapTransferResult({ from, to }) { + return { from: [from], to }; + } + + // node_modules/vnopts/lib/schemas/boolean.js + var BooleanSchema = class extends Schema { + expected() { + return "true or false"; + } + validate(value) { + return typeof value === "boolean"; + } + }; + + // node_modules/vnopts/lib/utils.js + function recordFromArray(array2, mainKey) { + const record = /* @__PURE__ */ Object.create(null); + for (const value of array2) { + const key = value[mainKey]; + if (record[key]) { + throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`); + } + record[key] = value; + } + return record; + } + function mapFromArray(array2, mainKey) { + const map = /* @__PURE__ */ new Map(); + for (const value of array2) { + const key = value[mainKey]; + if (map.has(key)) { + throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`); + } + map.set(key, value); + } + return map; + } + function createAutoChecklist() { + const map = /* @__PURE__ */ Object.create(null); + return (id) => { + const idString = JSON.stringify(id); + if (map[idString]) { + return true; + } + map[idString] = true; + return false; + }; + } + function partition(array2, predicate) { + const trueArray = []; + const falseArray = []; + for (const value of array2) { + if (predicate(value)) { + trueArray.push(value); + } else { + falseArray.push(value); + } + } + return [trueArray, falseArray]; + } + function isInt(value) { + return value === Math.floor(value); + } + function comparePrimitive(a, b) { + if (a === b) { + return 0; + } + const typeofA = typeof a; + const typeofB = typeof b; + const orders = [ + "undefined", + "object", + "boolean", + "number", + "string" + ]; + if (typeofA !== typeofB) { + return orders.indexOf(typeofA) - orders.indexOf(typeofB); + } + if (typeofA !== "string") { + return Number(a) - Number(b); + } + return a.localeCompare(b); + } + function normalizeInvalidHandler(invalidHandler) { + return (...args) => { + const errorMessageOrError = invalidHandler(...args); + return typeof errorMessageOrError === "string" ? new Error(errorMessageOrError) : errorMessageOrError; + }; + } + function normalizeDefaultResult(result) { + return result === void 0 ? {} : result; + } + function normalizeExpectedResult(result) { + if (typeof result === "string") { + return { text: result }; + } + const { text, list } = result; + assert2((text || list) !== void 0, "Unexpected `expected` result, there should be at least one field."); + if (!list) { + return { text }; + } + return { + text, + list: { + title: list.title, + values: list.values.map(normalizeExpectedResult) + } + }; + } + function normalizeValidateResult(result, value) { + return result === true ? true : result === false ? { value } : result; + } + function normalizeDeprecatedResult(result, value, doNotNormalizeTrue = false) { + return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{ value }] : "value" in result ? [result] : result.length === 0 ? false : result; + } + function normalizeTransferResult(result, value) { + return typeof result === "string" || "key" in result ? { from: value, to: result } : "from" in result ? { from: result.from, to: result.to } : { from: value, to: result.to }; + } + function normalizeForwardResult(result, value) { + return result === void 0 ? [] : Array.isArray(result) ? result.map((transferResult) => normalizeTransferResult(transferResult, value)) : [normalizeTransferResult(result, value)]; + } + function normalizeRedirectResult(result, value) { + const redirect = normalizeForwardResult(typeof result === "object" && "redirect" in result ? result.redirect : result, value); + return redirect.length === 0 ? { remain: value, redirect } : typeof result === "object" && "remain" in result ? { remain: result.remain, redirect } : { redirect }; + } + function assert2(isValid, message) { + if (!isValid) { + throw new Error(message); + } + } + + // node_modules/vnopts/lib/schemas/choice.js + var ChoiceSchema = class extends Schema { + constructor(parameters) { + super(parameters); + this._choices = mapFromArray(parameters.choices.map((choice) => choice && typeof choice === "object" ? choice : { value: choice }), "value"); + } + expected({ descriptor }) { + const choiceDescriptions = Array.from(this._choices.keys()).map((value) => this._choices.get(value)).filter(({ hidden }) => !hidden).map((choiceInfo) => choiceInfo.value).sort(comparePrimitive).map(descriptor.value); + const head = choiceDescriptions.slice(0, -2); + const tail = choiceDescriptions.slice(-2); + const message = head.concat(tail.join(" or ")).join(", "); + return { + text: message, + list: { + title: "one of the following values", + values: choiceDescriptions + } + }; + } + validate(value) { + return this._choices.has(value); + } + deprecated(value) { + const choiceInfo = this._choices.get(value); + return choiceInfo && choiceInfo.deprecated ? { value } : false; + } + forward(value) { + const choiceInfo = this._choices.get(value); + return choiceInfo ? choiceInfo.forward : void 0; + } + redirect(value) { + const choiceInfo = this._choices.get(value); + return choiceInfo ? choiceInfo.redirect : void 0; + } + }; + + // node_modules/vnopts/lib/schemas/number.js + var NumberSchema = class extends Schema { + expected() { + return "a number"; + } + validate(value, _utils) { + return typeof value === "number"; + } + }; + + // node_modules/vnopts/lib/schemas/integer.js + var IntegerSchema = class extends NumberSchema { + expected() { + return "an integer"; + } + validate(value, utils) { + return utils.normalizeValidateResult(super.validate(value, utils), value) === true && isInt(value); + } + }; + + // node_modules/vnopts/lib/schemas/string.js + var StringSchema = class extends Schema { + expected() { + return "a string"; + } + validate(value) { + return typeof value === "string"; + } + }; + + // node_modules/vnopts/lib/defaults.js + var defaultDescriptor = apiDescriptor; + var defaultUnknownHandler = levenUnknownHandler; + var defaultInvalidHandler = commonInvalidHandler; + var defaultDeprecatedHandler = commonDeprecatedHandler; + + // node_modules/vnopts/lib/normalize.js + var Normalizer = class { + constructor(schemas, opts) { + const { logger = console, loggerPrintWidth = 80, descriptor = defaultDescriptor, unknown = defaultUnknownHandler, invalid = defaultInvalidHandler, deprecated = defaultDeprecatedHandler, missing = () => false, required = () => false, preprocess = (x) => x, postprocess = () => VALUE_UNCHANGED } = opts || {}; + this._utils = { + descriptor, + logger: ( + /* c8 ignore next */ + logger || { warn: () => { + } } + ), + loggerPrintWidth, + schemas: recordFromArray(schemas, "name"), + normalizeDefaultResult, + normalizeExpectedResult, + normalizeDeprecatedResult, + normalizeForwardResult, + normalizeRedirectResult, + normalizeValidateResult + }; + this._unknownHandler = unknown; + this._invalidHandler = normalizeInvalidHandler(invalid); + this._deprecatedHandler = deprecated; + this._identifyMissing = (k, o) => !(k in o) || missing(k, o); + this._identifyRequired = required; + this._preprocess = preprocess; + this._postprocess = postprocess; + this.cleanHistory(); + } + cleanHistory() { + this._hasDeprecationWarned = createAutoChecklist(); + } + normalize(options) { + const newOptions = {}; + const preprocessed = this._preprocess(options, this._utils); + const restOptionsArray = [preprocessed]; + const applyNormalization = () => { + while (restOptionsArray.length !== 0) { + const currentOptions = restOptionsArray.shift(); + const transferredOptionsArray = this._applyNormalization(currentOptions, newOptions); + restOptionsArray.push(...transferredOptionsArray); + } + }; + applyNormalization(); + for (const key of Object.keys(this._utils.schemas)) { + const schema = this._utils.schemas[key]; + if (!(key in newOptions)) { + const defaultResult = normalizeDefaultResult(schema.default(this._utils)); + if ("value" in defaultResult) { + restOptionsArray.push({ [key]: defaultResult.value }); + } + } + } + applyNormalization(); + for (const key of Object.keys(this._utils.schemas)) { + if (!(key in newOptions)) { + continue; + } + const schema = this._utils.schemas[key]; + const value = newOptions[key]; + const newValue = schema.postprocess(value, this._utils); + if (newValue === VALUE_UNCHANGED) { + continue; + } + this._applyValidation(newValue, key, schema); + newOptions[key] = newValue; + } + this._applyPostprocess(newOptions); + this._applyRequiredCheck(newOptions); + return newOptions; + } + _applyNormalization(options, newOptions) { + const transferredOptionsArray = []; + const { knownKeys, unknownKeys } = this._partitionOptionKeys(options); + for (const key of knownKeys) { + const schema = this._utils.schemas[key]; + const value = schema.preprocess(options[key], this._utils); + this._applyValidation(value, key, schema); + const appendTransferredOptions = ({ from, to }) => { + transferredOptionsArray.push(typeof to === "string" ? { [to]: from } : { [to.key]: to.value }); + }; + const warnDeprecated = ({ value: currentValue, redirectTo }) => { + const deprecatedResult = normalizeDeprecatedResult( + schema.deprecated(currentValue, this._utils), + value, + /* doNotNormalizeTrue */ + true + ); + if (deprecatedResult === false) { + return; + } + if (deprecatedResult === true) { + if (!this._hasDeprecationWarned(key)) { + this._utils.logger.warn(this._deprecatedHandler(key, redirectTo, this._utils)); + } + } else { + for (const { value: deprecatedValue } of deprecatedResult) { + const pair = { key, value: deprecatedValue }; + if (!this._hasDeprecationWarned(pair)) { + const redirectToPair = typeof redirectTo === "string" ? { key: redirectTo, value: deprecatedValue } : redirectTo; + this._utils.logger.warn(this._deprecatedHandler(pair, redirectToPair, this._utils)); + } + } + } + }; + const forwardResult = normalizeForwardResult(schema.forward(value, this._utils), value); + forwardResult.forEach(appendTransferredOptions); + const redirectResult = normalizeRedirectResult(schema.redirect(value, this._utils), value); + redirectResult.redirect.forEach(appendTransferredOptions); + if ("remain" in redirectResult) { + const remainingValue = redirectResult.remain; + newOptions[key] = key in newOptions ? schema.overlap(newOptions[key], remainingValue, this._utils) : remainingValue; + warnDeprecated({ value: remainingValue }); + } + for (const { from, to } of redirectResult.redirect) { + warnDeprecated({ value: from, redirectTo: to }); + } + } + for (const key of unknownKeys) { + const value = options[key]; + this._applyUnknownHandler(key, value, newOptions, (knownResultKey, knownResultValue) => { + transferredOptionsArray.push({ [knownResultKey]: knownResultValue }); + }); + } + return transferredOptionsArray; + } + _applyRequiredCheck(options) { + for (const key of Object.keys(this._utils.schemas)) { + if (this._identifyMissing(key, options)) { + if (this._identifyRequired(key)) { + throw this._invalidHandler(key, VALUE_NOT_EXIST, this._utils); + } + } + } + } + _partitionOptionKeys(options) { + const [knownKeys, unknownKeys] = partition(Object.keys(options).filter((key) => !this._identifyMissing(key, options)), (key) => key in this._utils.schemas); + return { knownKeys, unknownKeys }; + } + _applyValidation(value, key, schema) { + const validateResult = normalizeValidateResult(schema.validate(value, this._utils), value); + if (validateResult !== true) { + throw this._invalidHandler(key, validateResult.value, this._utils); + } + } + _applyUnknownHandler(key, value, newOptions, knownResultHandler) { + const unknownResult = this._unknownHandler(key, value, this._utils); + if (!unknownResult) { + return; + } + for (const resultKey of Object.keys(unknownResult)) { + if (this._identifyMissing(resultKey, unknownResult)) { + continue; + } + const resultValue = unknownResult[resultKey]; + if (resultKey in this._utils.schemas) { + knownResultHandler(resultKey, resultValue); + } else { + newOptions[resultKey] = resultValue; + } + } + } + _applyPostprocess(options) { + const postprocessed = this._postprocess(options, this._utils); + if (postprocessed === VALUE_UNCHANGED) { + return; + } + if (postprocessed.delete) { + for (const deleteKey of postprocessed.delete) { + delete options[deleteKey]; + } + } + if (postprocessed.override) { + const { knownKeys, unknownKeys } = this._partitionOptionKeys(postprocessed.override); + for (const key of knownKeys) { + const value = postprocessed.override[key]; + this._applyValidation(value, key, this._utils.schemas[key]); + options[key] = value; + } + for (const key of unknownKeys) { + const value = postprocessed.override[key]; + this._applyUnknownHandler(key, value, options, (knownResultKey, knownResultValue) => { + const schema = this._utils.schemas[knownResultKey]; + this._applyValidation(knownResultValue, knownResultKey, schema); + options[knownResultKey] = knownResultValue; + }); + } + } + } + }; + // src/main/normalize-options.js - var import_vnopts = __toESM(require_lib(), 1); var hasDeprecationWarned; function normalizeOptions(options, optionInfos, { logger = false, @@ -5001,14 +2528,14 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; throw new Error("'descriptor' option is required."); } } else { - descriptor = import_vnopts.default.apiDescriptor; + descriptor = apiDescriptor; } const unknown = !passThrough ? (key, value, options2) => { const { _, ...schemas2 } = options2.schemas; - return import_vnopts.default.levenUnknownHandler(key, value, { + return levenUnknownHandler(key, value, { ...options2, schemas: schemas2 }); @@ -5021,7 +2548,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; isCLI, FlagSchema }); - const normalizer = new import_vnopts.default.Normalizer(schemas, { + const normalizer = new Normalizer(schemas, { logger, unknown, descriptor @@ -5042,7 +2569,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; }) { const schemas = []; if (isCLI) { - schemas.push(import_vnopts.default.AnySchema.create({ + schemas.push(AnySchema.create({ name: "_" })); } @@ -5053,7 +2580,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; FlagSchema })); if (optionInfo.alias && isCLI) { - schemas.push(import_vnopts.default.AliasSchema.create({ + schemas.push(AliasSchema.create({ // @ts-expect-error name: optionInfo.alias, sourceName: optionInfo.name @@ -5077,16 +2604,16 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; const handlers = {}; switch (optionInfo.type) { case "int": - SchemaConstructor = import_vnopts.default.IntegerSchema; + SchemaConstructor = IntegerSchema; if (isCLI) { parameters.preprocess = Number; } break; case "string": - SchemaConstructor = import_vnopts.default.StringSchema; + SchemaConstructor = StringSchema; break; case "choice": - SchemaConstructor = import_vnopts.default.ChoiceSchema; + SchemaConstructor = ChoiceSchema; parameters.choices = optionInfo.choices.map((choiceInfo) => (choiceInfo == null ? void 0 : choiceInfo.redirect) ? { ...choiceInfo, redirect: { @@ -5098,14 +2625,14 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; } : choiceInfo); break; case "boolean": - SchemaConstructor = import_vnopts.default.BooleanSchema; + SchemaConstructor = BooleanSchema; break; case "flag": SchemaConstructor = FlagSchema; parameters.flags = optionInfos.flatMap((optionInfo2) => [optionInfo2.alias, optionInfo2.description && optionInfo2.name, optionInfo2.oppositeDescription && `no-${optionInfo2.name}`].filter(Boolean)); break; case "path": - SchemaConstructor = import_vnopts.default.StringSchema; + SchemaConstructor = StringSchema; break; default: throw new Error(`Unexpected type ${optionInfo.type}`); @@ -5135,7 +2662,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; -1 ) : value), utils); } - return optionInfo.array ? import_vnopts.default.ArraySchema.create({ + return optionInfo.array ? ArraySchema.create({ ...isCLI ? { preprocess: (v) => Array.isArray(v) ? v : [v] } : {}, @@ -5268,7 +2795,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; var normalize_format_options_default = normalizeFormatOptions; // src/main/parse.js - var import_code_frame = __toESM(require_lib4(), 1); + var import_code_frame = __toESM(require_lib(), 1); function parse(originalText, options) { const parser = resolveParser(options); const text = parser.preprocess ? parser.preprocess(originalText, options) : originalText; @@ -5492,12 +3019,12 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; } else { doc = printer.print(path, options, printPath, args); } - if (printer.printComment && (!printer.willPrintOwnComments || !printer.willPrintOwnComments(path, options))) { - doc = printComments(path, doc, options); - } if (node === options.cursorNode) { doc = inheritLabel(doc, (doc2) => [cursor, doc2, cursor]); } + if (printer.printComment && (!printer.willPrintOwnComments || !printer.willPrintOwnComments(path, options))) { + doc = printComments(path, doc, options); + } return doc; } function prepareToPrint(ast, options) { diff --git a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/estree.js b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/estree.js index 87e1b1b63d1..019b529d54c 100644 --- a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/estree.js +++ b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/estree.js @@ -257,7 +257,7 @@ function getDocErrorMessage(doc) { const type = doc === null ? "null" : typeof doc; if (type !== "string" && type !== "object") { - return `Unexpected doc '${type}', + return `Unexpected doc '${type}', Expected it to be 'string' or 'object'.`; } if (get_doc_type_default(doc)) { @@ -1237,7 +1237,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "typeParameters", "superTypeParameters", "implements", - "decorators" + "decorators", + "superTypeArguments" ], "ClassDeclaration": [ "id", @@ -1247,12 +1248,14 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "typeParameters", "superTypeParameters", "implements", - "decorators" + "decorators", + "superTypeArguments" ], "ExportAllDeclaration": [ "source", - "exported", - "assertions" + "attributes", + "assertions", + "exported" ], "ExportDefaultDeclaration": [ "declaration" @@ -1261,6 +1264,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "declaration", "specifiers", "source", + "attributes", "assertions" ], "ExportSpecifier": [ @@ -1275,6 +1279,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "ImportDeclaration": [ "specifiers", "source", + "attributes", "assertions" ], "ImportDefaultSpecifier": [ @@ -1311,7 +1316,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "TaggedTemplateExpression": [ "tag", "quasi", - "typeParameters" + "typeParameters", + "typeArguments" ], "TemplateElement": [], "TemplateLiteral": [ @@ -1623,6 +1629,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "JSXOpeningElement": [ "name", "attributes", + "typeArguments", "typeParameters" ], "JSXSpreadAttribute": [ @@ -1757,7 +1764,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; ], "TSTypeReference": [ "typeName", - "typeParameters" + "typeParameters", + "typeArguments" ], "TSTypePredicate": [ "parameterName", @@ -1765,7 +1773,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; ], "TSTypeQuery": [ "exprName", - "typeParameters" + "typeParameters", + "typeArguments" ], "TSTypeLiteral": [ "members" @@ -1839,7 +1848,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; ], "TSInstantiationExpression": [ "expression", - "typeParameters" + "typeParameters", + "typeArguments" ], "TSAsExpression": [ "expression", @@ -1872,7 +1882,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "argument", "qualifier", "typeParameters", - "parameter" + "typeArguments" ], "TSImportEqualsDeclaration": [ "id", @@ -1959,6 +1969,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "TSAsyncKeyword": [], "TSClassImplements": [ "expression", + "typeArguments", "typeParameters" ], "TSDeclareKeyword": [], @@ -1971,6 +1982,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "TSExportKeyword": [], "TSInterfaceHeritage": [ "expression", + "typeArguments", "typeParameters" ], "TSPrivateKeyword": [], @@ -2047,6 +2059,9 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; "label", "typeAnnotation" ], + "TypeOperator": [ + "typeAnnotation" + ], "TypePredicate": [ "parameterName", "typeAnnotation", @@ -3015,13 +3030,19 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; return parent.type === "TSArrayType" || parent.type === "TSOptionalType" || parent.type === "TSRestType" || key === "objectType" && parent.type === "TSIndexedAccessType" || parent.type === "TSTypeOperator" || parent.type === "TSTypeAnnotation" && path.grandparent.type.startsWith("TSJSDoc"); case "TSTypeQuery": return key === "objectType" && parent.type === "TSIndexedAccessType" || key === "elementType" && parent.type === "TSArrayType"; + case "TypeOperator": + return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || key === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType") || parent.type === "TypeOperator"; case "TypeofTypeAnnotation": return key === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType") || key === "elementType" && parent.type === "ArrayTypeAnnotation"; case "ArrayTypeAnnotation": return parent.type === "NullableTypeAnnotation"; case "IntersectionTypeAnnotation": case "UnionTypeAnnotation": - return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation" || key === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType"); + return parent.type === "TypeOperator" || parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation" || key === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType") || path.match( + void 0, + (node2, key2) => node2.type === "TypeAnnotation", + (node2, key2) => key2 === "rendersType" && (node2.type === "ComponentDeclaration" || node2.type === "ComponentTypeAnnotation" || node2.type === "DeclareComponent") + ); case "InferTypeAnnotation": case "NullableTypeAnnotation": return parent.type === "ArrayTypeAnnotation" || key === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType"); @@ -3786,7 +3807,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; const isSingleLineComment = comment.type === "SingleLine" || comment.loc.start.line === comment.loc.end.line; const isSameLineComment = comment.loc.start.line === precedingNode.loc.start.line; if (isSingleLineComment && isSameLineComment) { - addDanglingComment(precedingNode, comment, markerForIfWithoutBlockAndSameLineComment); + addDanglingComment(precedingNode, comment, precedingNode.type === "ExpressionStatement" ? markerForIfWithoutBlockAndSameLineComment : void 0); } else { addDanglingComment(enclosingNode, comment); } @@ -4909,7 +4930,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; const shouldInline = shouldInlineLogicalExpression(node); const lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || isVueFilterSequenceExpression(path, options2)) && !hasLeadingOwnLineComment(options2.originalText, node.right); const operator = node.type === "NGPipeExpression" ? "|" : node.operator; - const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length > 0 ? group(indent([line, ": ", join([line, ": "], path.map(() => align(2, group(print3())), "arguments"))])) : ""; + const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length > 0 ? group(indent([softline, ": ", join([line, ": "], path.map(() => align(2, group(print3())), "arguments"))])) : ""; let right; if (shouldInline) { right = [operator, " ", print3("right"), rightSuffix]; @@ -4964,6 +4985,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; // src/common/errors.js var ArgExpansionBailout = class extends Error { + name = "ArgExpansionBailout"; }; // src/language-js/print/array.js @@ -5552,7 +5574,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; return false; } if (node.callee.name === "require") { - return true; + const args = getCallArguments(node); + return args.length === 1 && isStringLiteral(args[0]) || args.length > 1; } if (node.callee.name === "define") { const args = getCallArguments(node); @@ -5786,7 +5809,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; let node = rightNode; const propertiesForPath = []; for (; ; ) { - if (node.type === "UnaryExpression") { + if (node.type === "UnaryExpression" || node.type === "AwaitExpression" || node.type === "YieldExpression" && node.argument !== null) { node = node.argument; propertiesForPath.push("argument"); } else if (node.type === "TSNonNullExpression") { @@ -5997,7 +6020,9 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; } return group([removeLines(typeParams), "(", removeLines(printed), ")"]); } - const hasNotParameterDecorator = parameters.every((node) => !node.decorators); + const hasNotParameterDecorator = parameters.every( + (node) => !is_non_empty_array_default(node.decorators) + ); if (shouldHugParameters && hasNotParameterDecorator) { return [typeParams, "(", ...printed, ")"]; } @@ -6313,7 +6338,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; (node, key) => key === "typeAnnotation" && (node.type === "TSJSDocNullableType" || node.type === "TSJSDocNonNullableType" || node.type === "TSTypePredicate") ) || /* Flow - + ```js declare function foo(): void; ^^^^^^^^ `TypeAnnotation` @@ -6325,7 +6350,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; (node, key) => key === "id" && node.type === "DeclareFunction" ) || /* Flow - + ```js type A = () => infer R extends string; ^^^^^^ `TypeAnnotation` @@ -6506,7 +6531,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; printImportKind(node), printModuleSpecifiers(path, options2, print3), printModuleSource(path, options2, print3), - printImportAssertions(path, options2, print3), + printImportAttributes(path, options2, print3), options2.semi ? ";" : "" ]; } @@ -6540,7 +6565,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; } parts.push( printModuleSource(path, options2, print3), - printImportAssertions(path, options2, print3) + printImportAttributes(path, options2, print3) ); } parts.push(printSemicolonAfterExportDeclaration(node, options2)); @@ -6646,15 +6671,18 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; options2.originalText.slice(locStart(node), locStart(source)) ); } - function printImportAssertions(path, options2, print3) { + function printImportAttributes(path, options2, print3) { + var _a; const { node } = path; - if (!is_non_empty_array_default(node.assertions)) { + const property = is_non_empty_array_default(node.attributes) ? "attributes" : is_non_empty_array_default(node.assertions) ? "assertions" : void 0; + if (!property) { return ""; } + const keyword = property === "assertions" || ((_a = node.extra) == null ? void 0 : _a.deprecatedAssertSyntax) ? "assert" : "with"; return [ - " assert {", + ` ${keyword} {`, options2.bracketSpacing ? " " : "", - join(", ", path.map(print3, "assertions")), + join(", ", path.map(print3, property)), options2.bracketSpacing ? " " : "", "}" ]; @@ -7790,7 +7818,13 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; parts.push(printTypeAnnotationProperty(path, print3, "bound")); } if (node.constraint) { - parts.push(" extends", indent([line, print3("constraint")])); + const groupId = Symbol("constraint"); + parts.push( + " extends", + group(indent(line), { id: groupId }), + lineSuffixBoundary, + indentIfBreak(print3("constraint"), { groupId }) + ); } if (node.default) { parts.push(" = ", print3("default")); @@ -7799,10 +7833,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; } // scripts/build/shims/assert.js - var assert = () => { - }; - assert.ok = assert; - assert.strictEqual = assert; + var assert = new Proxy(() => { + }, { get: () => assert }); var assert_default = assert; // src/language-js/print/property.js @@ -8014,7 +8046,15 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; return ["throw", printReturnOrThrowArgument(path, options2, print3)]; } function returnArgumentHasLeadingComment(options2, argument) { - if (hasLeadingOwnLineComment(options2.originalText, argument)) { + if (hasLeadingOwnLineComment(options2.originalText, argument) || hasComment( + argument, + CommentCheckFlags.Leading, + (comment) => has_newline_in_range_default( + options2.originalText, + locStart(comment), + locEnd(comment) + ) + ) && !isJsxElement(argument)) { return true; } if (hasNakedLeftSide(argument)) { @@ -8339,7 +8379,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; } else { content = [isFlowInterfaceLikeBody && is_non_empty_array_default(node.properties) ? printHardlineAfterHeritage(parent) : "", leftBrace, indent([options2.bracketSpacing ? line : softline, ...props]), ifBreak(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma(options2)) ? separator : ""), options2.bracketSpacing ? line : softline, rightBrace, printOptionalToken(path), printTypeAnnotationProperty(path, print3)]; } - if (path.match((node2) => node2.type === "ObjectPattern" && !node2.decorators, shouldHugTheOnlyParameter) || isObjectType(node) && (path.match(void 0, (node2, name) => name === "typeAnnotation", (node2, name) => name === "typeAnnotation", shouldHugTheOnlyParameter) || path.match(void 0, (node2, name) => node2.type === "FunctionTypeParam" && name === "typeAnnotation", shouldHugTheOnlyParameter)) || // Assignment printing logic (printAssignment) is responsible + if (path.match((node2) => node2.type === "ObjectPattern" && !is_non_empty_array_default(node2.decorators), shouldHugTheOnlyParameter) || isObjectType(node) && (path.match(void 0, (node2, name) => name === "typeAnnotation", (node2, name) => name === "typeAnnotation", shouldHugTheOnlyParameter) || path.match(void 0, (node2, name) => node2.type === "FunctionTypeParam" && name === "typeAnnotation", shouldHugTheOnlyParameter)) || // Assignment printing logic (printAssignment) is responsible // for adding a group if needed !shouldBreak && path.match((node2) => node2.type === "ObjectPattern", (node2) => node2.type === "AssignmentExpression" || node2.type === "VariableDeclarator")) { return content; @@ -8736,6 +8776,17 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; const doc = join([",", line], parameterDocs); return options2.__isVueForBindingLeft ? ["(", indent([softline, group(doc)]), softline, ")"] : doc; } + if (options2.__isEmbeddedTypescriptGenericParameters) { + const parameterDocs = path.map( + print3, + "program", + "body", + 0, + "typeParameters", + "params" + ); + return join([",", line], parameterDocs); + } } // src/language-js/print/estree.js @@ -9663,6 +9714,8 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; ]; case "TypePredicate": return printTypePredicate(path, print3); + case "TypeOperator": + return [node.operator, " ", print3("typeAnnotation")]; case "TypeParameterDeclaration": case "TypeParameterInstantiation": return printTypeParameters(path, options2, print3, "params"); @@ -9814,10 +9867,15 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; return [ !node.isTypeOf ? "" : "typeof ", "import(", - print3(node.parameter ? "parameter" : "argument"), + print3("argument"), ")", !node.qualifier ? "" : [".", print3("qualifier")], - printTypeParameters(path, options2, print3, "typeParameters") + printTypeParameters( + path, + options2, + print3, + node.typeArguments ? "typeArguments" : "typeParameters" + ) ]; case "TSLiteralType": return print3("literal"); @@ -10396,7 +10454,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "ClassMethod" || ast.type === "PropertyDefinition" || ast.type === "TSDeclareMethod" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && typeof ast.key === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "NumericLiteral" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) { delete newObj.key; } - if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some((attr) => attr.name.name === "jsx")) { + if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some((attr) => attr.type === "JSXAttribute" && attr.name.name === "jsx")) { for (const { type, expression: expression2 @@ -10898,6 +10956,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; ".yyp" ], "filenames": [ + ".all-contributorsrc", ".arcconfig", ".auto-changelog", ".c8rc", @@ -10909,6 +10968,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; ".watchmanconfig", "Pipfile.lock", "composer.lock", + "flake.lock", "mcmod.info" ], "parsers": [ @@ -10955,14 +11015,14 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; ".jscsrc", ".jshintrc", ".jslintrc", + ".swcrc", "api-extractor.json", "devcontainer.json", "jsconfig.json", "language-configuration.json", "tsconfig.json", "tslint.json", - ".eslintrc", - ".swcrc" + ".eslintrc" ], "parsers": [ "json" @@ -11130,4 +11190,4 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; }; var languages = [...languages_evaluate_default, ...languages_evaluate_default2]; return __toCommonJS(estree_exports); -}); +}); \ No newline at end of file diff --git a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/graphql.js b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/graphql.js index f93d9859e33..71fccfe84b8 100644 --- a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/graphql.js +++ b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/graphql.js @@ -853,7 +853,7 @@ } return firstArg; } - var GraphQLError = class extends Error { + var GraphQLError = class _GraphQLError extends Error { /** * An array of `{ line, column }` locations within the source GraphQL document * which correspond to this error. @@ -940,7 +940,7 @@ configurable: true }); } else if (Error.captureStackTrace) { - Error.captureStackTrace(this, GraphQLError); + Error.captureStackTrace(this, _GraphQLError); } else { Object.defineProperty(this, "stack", { value: Error().stack, @@ -1740,8 +1740,7 @@ var instanceOf = ( /* c8 ignore next 6 */ // FIXME: https://github.com/graphql/graphql-js/issues/2317 - // eslint-disable-next-line no-undef - true ? function instanceOf2(value, constructor) { + globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function instanceOf2(value, constructor) { return value instanceof constructor; } : function instanceOf3(value, constructor) { if (value instanceof constructor) { diff --git a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/postcss.js b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/postcss.js index e3c9cd4f8e6..e99c2a9915c 100644 --- a/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/postcss.js +++ b/tools/hermes-parser/js/prettier-plugin-hermes-parser/src/third-party/internal-prettier-v3/plugins/postcss.js @@ -170,7 +170,7 @@ "use strict"; var pico = require_picocolors_browser(); var terminalHighlight = require_terminal_highlight(); - var CssSyntaxError = class extends Error { + var CssSyntaxError = class _CssSyntaxError extends Error { constructor(message, line2, column, source, file, plugin) { super(message); this.name = "CssSyntaxError"; @@ -197,7 +197,7 @@ } this.setMessage(); if (Error.captureStackTrace) { - Error.captureStackTrace(this, CssSyntaxError); + Error.captureStackTrace(this, _CssSyntaxError); } } setMessage() { @@ -224,7 +224,7 @@ let maxWidth = String(end).length; let mark, aside; if (color) { - let { bold, red, gray } = pico.createColors(true); + let { bold, gray, red } = pico.createColors(true); mark = (text) => bold(red(text)); aside = (text) => gray(text); } else { @@ -258,17 +258,17 @@ "node_modules/postcss/lib/stringifier.js"(exports, module) { "use strict"; var DEFAULT_RAW = { - colon: ": ", - indent: " ", - beforeDecl: "\n", - beforeRule: "\n", - beforeOpen: " ", + after: "\n", beforeClose: "\n", beforeComment: "\n", - after: "\n", - emptyBody: "", + beforeDecl: "\n", + beforeOpen: " ", + beforeRule: "\n", + colon: ": ", commentLeft: " ", commentRight: " ", + emptyBody: "", + indent: " ", semicolon: false }; function capitalize(str) { @@ -278,43 +278,6 @@ constructor(builder) { this.builder = builder; } - stringify(node, semicolon) { - if (!this[node.type]) { - throw new Error( - "Unknown AST node type " + node.type + ". Maybe you need to change PostCSS stringifier." - ); - } - this[node.type](node, semicolon); - } - document(node) { - this.body(node); - } - root(node) { - this.body(node); - if (node.raws.after) - this.builder(node.raws.after); - } - comment(node) { - let left = this.raw(node, "left", "commentLeft"); - let right = this.raw(node, "right", "commentRight"); - this.builder("/*" + left + node.text + right + "*/", node); - } - decl(node, semicolon) { - let between = this.raw(node, "between", "colon"); - let string = node.prop + between + this.rawValue(node, "value"); - if (node.important) { - string += node.raws.important || " !important"; - } - if (semicolon) - string += ";"; - this.builder(string, node); - } - rule(node) { - this.block(node, this.rawValue(node, "selector")); - if (node.raws.ownSemicolon) { - this.builder(node.raws.ownSemicolon, node, "end"); - } - } atrule(node, semicolon) { let name = "@" + node.name; let params = node.params ? this.rawValue(node, "params") : ""; @@ -330,6 +293,46 @@ this.builder(name + params + end, node); } } + beforeAfter(node, detect) { + let value; + if (node.type === "decl") { + value = this.raw(node, null, "beforeDecl"); + } else if (node.type === "comment") { + value = this.raw(node, null, "beforeComment"); + } else if (detect === "before") { + value = this.raw(node, null, "beforeRule"); + } else { + value = this.raw(node, null, "beforeClose"); + } + let buf = node.parent; + let depth = 0; + while (buf && buf.type !== "root") { + depth += 1; + buf = buf.parent; + } + if (value.includes("\n")) { + let indent2 = this.raw(node, null, "indent"); + if (indent2.length) { + for (let step = 0; step < depth; step++) + value += indent2; + } + } + return value; + } + block(node, start) { + let between = this.raw(node, "between", "beforeOpen"); + this.builder(start + between + "{", node, "start"); + let after; + if (node.nodes && node.nodes.length) { + this.body(node); + after = this.raw(node, "after"); + } else { + after = this.raw(node, "after", "emptyBody"); + } + if (after) + this.builder(after); + this.builder("}", node, "end"); + } body(node) { let last = node.nodes.length - 1; while (last > 0) { @@ -346,19 +349,23 @@ this.stringify(child, last !== i || semicolon); } } - block(node, start) { - let between = this.raw(node, "between", "beforeOpen"); - this.builder(start + between + "{", node, "start"); - let after; - if (node.nodes && node.nodes.length) { - this.body(node); - after = this.raw(node, "after"); - } else { - after = this.raw(node, "after", "emptyBody"); + comment(node) { + let left = this.raw(node, "left", "commentLeft"); + let right = this.raw(node, "right", "commentRight"); + this.builder("/*" + left + node.text + right + "*/", node); + } + decl(node, semicolon) { + let between = this.raw(node, "between", "colon"); + let string = node.prop + between + this.rawValue(node, "value"); + if (node.important) { + string += node.raws.important || " !important"; } - if (after) - this.builder(after); - this.builder("}", node, "end"); + if (semicolon) + string += ";"; + this.builder(string, node); + } + document(node) { + this.body(node); } raw(node, own, detect) { let value; @@ -405,43 +412,21 @@ root.rawCache[detect] = value; return value; } - rawSemicolon(root) { - let value; - root.walk((i) => { - if (i.nodes && i.nodes.length && i.last.type === "decl") { - value = i.raws.semicolon; - if (typeof value !== "undefined") - return false; - } - }); - return value; - } - rawEmptyBody(root) { - let value; - root.walk((i) => { - if (i.nodes && i.nodes.length === 0) { - value = i.raws.after; - if (typeof value !== "undefined") - return false; - } - }); - return value; - } - rawIndent(root) { - if (root.raws.indent) - return root.raws.indent; + rawBeforeClose(root) { let value; root.walk((i) => { - let p = i.parent; - if (p && p !== root && p.parent && p.parent === root) { - if (typeof i.raws.before !== "undefined") { - let parts = i.raws.before.split("\n"); - value = parts[parts.length - 1]; - value = value.replace(/\S/g, ""); + if (i.nodes && i.nodes.length > 0) { + if (typeof i.raws.after !== "undefined") { + value = i.raws.after; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } return false; } } }); + if (value) + value = value.replace(/\S/g, ""); return value; } rawBeforeComment(root, node) { @@ -480,6 +465,17 @@ } return value; } + rawBeforeOpen(root) { + let value; + root.walk((i) => { + if (i.type !== "decl") { + value = i.raws.between; + if (typeof value !== "undefined") + return false; + } + }); + return value; + } rawBeforeRule(root) { let value; root.walk((i) => { @@ -497,68 +493,53 @@ value = value.replace(/\S/g, ""); return value; } - rawBeforeClose(root) { + rawColon(root) { let value; - root.walk((i) => { - if (i.nodes && i.nodes.length > 0) { - if (typeof i.raws.after !== "undefined") { - value = i.raws.after; - if (value.includes("\n")) { - value = value.replace(/[^\n]+$/, ""); - } - return false; - } + root.walkDecls((i) => { + if (typeof i.raws.between !== "undefined") { + value = i.raws.between.replace(/[^\s:]/g, ""); + return false; } }); - if (value) - value = value.replace(/\S/g, ""); return value; } - rawBeforeOpen(root) { + rawEmptyBody(root) { let value; root.walk((i) => { - if (i.type !== "decl") { - value = i.raws.between; + if (i.nodes && i.nodes.length === 0) { + value = i.raws.after; if (typeof value !== "undefined") return false; } }); return value; } - rawColon(root) { + rawIndent(root) { + if (root.raws.indent) + return root.raws.indent; let value; - root.walkDecls((i) => { - if (typeof i.raws.between !== "undefined") { - value = i.raws.between.replace(/[^\s:]/g, ""); - return false; + root.walk((i) => { + let p = i.parent; + if (p && p !== root && p.parent && p.parent === root) { + if (typeof i.raws.before !== "undefined") { + let parts = i.raws.before.split("\n"); + value = parts[parts.length - 1]; + value = value.replace(/\S/g, ""); + return false; + } } }); return value; } - beforeAfter(node, detect) { + rawSemicolon(root) { let value; - if (node.type === "decl") { - value = this.raw(node, null, "beforeDecl"); - } else if (node.type === "comment") { - value = this.raw(node, null, "beforeComment"); - } else if (detect === "before") { - value = this.raw(node, null, "beforeRule"); - } else { - value = this.raw(node, null, "beforeClose"); - } - let buf = node.parent; - let depth = 0; - while (buf && buf.type !== "root") { - depth += 1; - buf = buf.parent; - } - if (value.includes("\n")) { - let indent2 = this.raw(node, null, "indent"); - if (indent2.length) { - for (let step = 0; step < depth; step++) - value += indent2; + root.walk((i) => { + if (i.nodes && i.nodes.length && i.last.type === "decl") { + value = i.raws.semicolon; + if (typeof value !== "undefined") + return false; } - } + }); return value; } rawValue(node, prop) { @@ -569,23 +550,42 @@ } return value; } - }; - module.exports = Stringifier; - Stringifier.default = Stringifier; - } - }); - - // node_modules/postcss/lib/stringify.js - var require_stringify = __commonJS({ - "node_modules/postcss/lib/stringify.js"(exports, module) { - "use strict"; - var Stringifier = require_stringifier(); - function stringify(node, builder) { - let str = new Stringifier(builder); - str.stringify(node); - } - module.exports = stringify; - stringify.default = stringify; + root(node) { + this.body(node); + if (node.raws.after) + this.builder(node.raws.after); + } + rule(node) { + this.block(node, this.rawValue(node, "selector")); + if (node.raws.ownSemicolon) { + this.builder(node.raws.ownSemicolon, node, "end"); + } + } + stringify(node, semicolon) { + if (!this[node.type]) { + throw new Error( + "Unknown AST node type " + node.type + ". Maybe you need to change PostCSS stringifier." + ); + } + this[node.type](node, semicolon); + } + }; + module.exports = Stringifier; + Stringifier.default = Stringifier; + } + }); + + // node_modules/postcss/lib/stringify.js + var require_stringify = __commonJS({ + "node_modules/postcss/lib/stringify.js"(exports, module) { + "use strict"; + var Stringifier = require_stringifier(); + function stringify(node, builder) { + let str = new Stringifier(builder); + str.stringify(node); + } + module.exports = stringify; + stringify.default = stringify; } }); @@ -642,46 +642,37 @@ } } } - error(message, opts = {}) { - if (this.source) { - let { start, end } = this.rangeBy(opts); - return this.source.input.error( - message, - { line: start.line, column: start.column }, - { line: end.line, column: end.column }, - opts + addToError(error) { + error.postcssNode = this; + if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) { + let s = this.source; + error.stack = error.stack.replace( + /\n\s{4}at /, + `$&${s.input.from}:${s.start.line}:${s.start.column}$&` ); } - return new CssSyntaxError(message); - } - warn(result, text, opts) { - let data = { node: this }; - for (let i in opts) - data[i] = opts[i]; - return result.warn(text, data); + return error; } - remove() { - if (this.parent) { - this.parent.removeChild(this); - } - this.parent = void 0; + after(add) { + this.parent.insertAfter(this, add); return this; } - toString(stringifier = stringify) { - if (stringifier.stringify) - stringifier = stringifier.stringify; - let result = ""; - stringifier(this, (i) => { - result += i; - }); - return result; - } assign(overrides = {}) { for (let name in overrides) { this[name] = overrides[name]; } return this; } + before(add) { + this.parent.insertBefore(this, add); + return this; + } + cleanRaws(keepBetween) { + delete this.raws.before; + delete this.raws.after; + if (!keepBetween) + delete this.raws.between; + } clone(overrides = {}) { let cloned = cloneNode(this); for (let name in overrides) { @@ -689,35 +680,59 @@ } return cloned; } - cloneBefore(overrides = {}) { + cloneAfter(overrides = {}) { let cloned = this.clone(overrides); - this.parent.insertBefore(this, cloned); + this.parent.insertAfter(this, cloned); return cloned; } - cloneAfter(overrides = {}) { + cloneBefore(overrides = {}) { let cloned = this.clone(overrides); - this.parent.insertAfter(this, cloned); + this.parent.insertBefore(this, cloned); return cloned; } - replaceWith(...nodes) { - if (this.parent) { - let bookmark = this; - let foundSelf = false; - for (let node of nodes) { - if (node === this) { - foundSelf = true; - } else if (foundSelf) { - this.parent.insertAfter(bookmark, node); - bookmark = node; + error(message, opts = {}) { + if (this.source) { + let { end, start } = this.rangeBy(opts); + return this.source.input.error( + message, + { column: start.column, line: start.line }, + { column: end.column, line: end.line }, + opts + ); + } + return new CssSyntaxError(message); + } + getProxyProcessor() { + return { + get(node, prop) { + if (prop === "proxyOf") { + return node; + } else if (prop === "root") { + return () => node.root().toProxy(); } else { - this.parent.insertBefore(bookmark, node); + return node[prop]; + } + }, + set(node, prop, value) { + if (node[prop] === value) + return true; + node[prop] = value; + if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ + prop === "text") { + node.markDirty(); } + return true; } - if (!foundSelf) { - this.remove(); + }; + } + markDirty() { + if (this[isClean]) { + this[isClean] = false; + let next = this; + while (next = next.parent) { + next[isClean] = false; } } - return this; } next() { if (!this.parent) @@ -725,18 +740,114 @@ let index = this.parent.index(this); return this.parent.nodes[index + 1]; } + positionBy(opts, stringRepresentation) { + let pos = this.source.start; + if (opts.index) { + pos = this.positionInside(opts.index, stringRepresentation); + } else if (opts.word) { + stringRepresentation = this.toString(); + let index = stringRepresentation.indexOf(opts.word); + if (index !== -1) + pos = this.positionInside(index, stringRepresentation); + } + return pos; + } + positionInside(index, stringRepresentation) { + let string = stringRepresentation || this.toString(); + let column = this.source.start.column; + let line2 = this.source.start.line; + for (let i = 0; i < index; i++) { + if (string[i] === "\n") { + column = 1; + line2 += 1; + } else { + column += 1; + } + } + return { column, line: line2 }; + } prev() { if (!this.parent) return void 0; let index = this.parent.index(this); return this.parent.nodes[index - 1]; } - before(add) { - this.parent.insertBefore(this, add); + get proxyOf() { return this; } - after(add) { - this.parent.insertAfter(this, add); + rangeBy(opts) { + let start = { + column: this.source.start.column, + line: this.source.start.line + }; + let end = this.source.end ? { + column: this.source.end.column + 1, + line: this.source.end.line + } : { + column: start.column + 1, + line: start.line + }; + if (opts.word) { + let stringRepresentation = this.toString(); + let index = stringRepresentation.indexOf(opts.word); + if (index !== -1) { + start = this.positionInside(index, stringRepresentation); + end = this.positionInside(index + opts.word.length, stringRepresentation); + } + } else { + if (opts.start) { + start = { + column: opts.start.column, + line: opts.start.line + }; + } else if (opts.index) { + start = this.positionInside(opts.index); + } + if (opts.end) { + end = { + column: opts.end.column, + line: opts.end.line + }; + } else if (opts.endIndex) { + end = this.positionInside(opts.endIndex); + } else if (opts.index) { + end = this.positionInside(opts.index + 1); + } + } + if (end.line < start.line || end.line === start.line && end.column <= start.column) { + end = { column: start.column + 1, line: start.line }; + } + return { end, start }; + } + raw(prop, defaultType) { + let str = new Stringifier(); + return str.raw(this, prop, defaultType); + } + remove() { + if (this.parent) { + this.parent.removeChild(this); + } + this.parent = void 0; + return this; + } + replaceWith(...nodes) { + if (this.parent) { + let bookmark = this; + let foundSelf = false; + for (let node of nodes) { + if (node === this) { + foundSelf = true; + } else if (foundSelf) { + this.parent.insertAfter(bookmark, node); + bookmark = node; + } else { + this.parent.insertBefore(bookmark, node); + } + } + if (!foundSelf) { + this.remove(); + } + } return this; } root() { @@ -746,16 +857,6 @@ } return result; } - raw(prop, defaultType) { - let str = new Stringifier(); - return str.raw(this, prop, defaultType); - } - cleanRaws(keepBetween) { - delete this.raws.before; - delete this.raws.after; - if (!keepBetween) - delete this.raws.between; - } toJSON(_, inputs) { let fixed = {}; let emitInputs = inputs == null; @@ -786,9 +887,9 @@ inputsNextIndex++; } fixed[name] = { + end: value.end, inputId, - start: value.start, - end: value.end + start: value.start }; } else { fixed[name] = value; @@ -799,125 +900,26 @@ } return fixed; } - positionInside(index) { - let string = this.toString(); - let column = this.source.start.column; - let line2 = this.source.start.line; - for (let i = 0; i < index; i++) { - if (string[i] === "\n") { - column = 1; - line2 += 1; - } else { - column += 1; - } - } - return { line: line2, column }; - } - positionBy(opts) { - let pos = this.source.start; - if (opts.index) { - pos = this.positionInside(opts.index); - } else if (opts.word) { - let index = this.toString().indexOf(opts.word); - if (index !== -1) - pos = this.positionInside(index); + toProxy() { + if (!this.proxyCache) { + this.proxyCache = new Proxy(this, this.getProxyProcessor()); } - return pos; + return this.proxyCache; } - rangeBy(opts) { - let start = { - line: this.source.start.line, - column: this.source.start.column - }; - let end = this.source.end ? { - line: this.source.end.line, - column: this.source.end.column + 1 - } : { - line: start.line, - column: start.column + 1 - }; - if (opts.word) { - let index = this.toString().indexOf(opts.word); - if (index !== -1) { - start = this.positionInside(index); - end = this.positionInside(index + opts.word.length); - } - } else { - if (opts.start) { - start = { - line: opts.start.line, - column: opts.start.column - }; - } else if (opts.index) { - start = this.positionInside(opts.index); - } - if (opts.end) { - end = { - line: opts.end.line, - column: opts.end.column - }; - } else if (opts.endIndex) { - end = this.positionInside(opts.endIndex); - } else if (opts.index) { - end = this.positionInside(opts.index + 1); - } - } - if (end.line < start.line || end.line === start.line && end.column <= start.column) { - end = { line: start.line, column: start.column + 1 }; - } - return { start, end }; - } - getProxyProcessor() { - return { - set(node, prop, value) { - if (node[prop] === value) - return true; - node[prop] = value; - if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ - prop === "text") { - node.markDirty(); - } - return true; - }, - get(node, prop) { - if (prop === "proxyOf") { - return node; - } else if (prop === "root") { - return () => node.root().toProxy(); - } else { - return node[prop]; - } - } - }; - } - toProxy() { - if (!this.proxyCache) { - this.proxyCache = new Proxy(this, this.getProxyProcessor()); - } - return this.proxyCache; - } - addToError(error) { - error.postcssNode = this; - if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) { - let s = this.source; - error.stack = error.stack.replace( - /\n\s{4}at /, - `$&${s.input.from}:${s.start.line}:${s.start.column}$&` - ); - } - return error; - } - markDirty() { - if (this[isClean]) { - this[isClean] = false; - let next = this; - while (next = next.parent) { - next[isClean] = false; - } - } + toString(stringifier = stringify) { + if (stringifier.stringify) + stringifier = stringifier.stringify; + let result = ""; + stringifier(this, (i) => { + result += i; + }); + return result; } - get proxyOf() { - return this; + warn(result, text, opts) { + let data = { node: this }; + for (let i in opts) + data[i] = opts[i]; + return result.warn(text, data); } }; module.exports = Node; @@ -991,12 +993,23 @@ } } } - var Container = class extends Node { - push(child) { - child.parent = this; - this.proxyOf.nodes.push(child); + var Container = class _Container extends Node { + append(...children) { + for (let child of children) { + let nodes = this.normalize(child, this.last); + for (let node of nodes) + this.proxyOf.nodes.push(node); + } + this.markDirty(); return this; } + cleanRaws(keepBetween) { + super.cleanRaws(keepBetween); + if (this.nodes) { + for (let node of this.nodes) + node.cleanRaws(keepBetween); + } + } each(callback) { if (!this.proxyOf.nodes) return void 0; @@ -1012,138 +1025,76 @@ delete this.indexes[iterator]; return result; } - walk(callback) { - return this.each((child, i) => { - let result; - try { - result = callback(child, i); - } catch (e) { - throw child.addToError(e); - } - if (result !== false && child.walk) { - result = child.walk(callback); - } - return result; - }); + every(condition) { + return this.nodes.every(condition); } - walkDecls(prop, callback) { - if (!callback) { - callback = prop; - return this.walk((child, i) => { - if (child.type === "decl") { - return callback(child, i); - } - }); - } - if (prop instanceof RegExp) { - return this.walk((child, i) => { - if (child.type === "decl" && prop.test(child.prop)) { - return callback(child, i); - } - }); - } - return this.walk((child, i) => { - if (child.type === "decl" && child.prop === prop) { - return callback(child, i); - } - }); + get first() { + if (!this.proxyOf.nodes) + return void 0; + return this.proxyOf.nodes[0]; } - walkRules(selector, callback) { - if (!callback) { - callback = selector; - return this.walk((child, i) => { - if (child.type === "rule") { - return callback(child, i); - } - }); - } - if (selector instanceof RegExp) { - return this.walk((child, i) => { - if (child.type === "rule" && selector.test(child.selector)) { - return callback(child, i); - } - }); - } - return this.walk((child, i) => { - if (child.type === "rule" && child.selector === selector) { - return callback(child, i); - } - }); + getIterator() { + if (!this.lastEach) + this.lastEach = 0; + if (!this.indexes) + this.indexes = {}; + this.lastEach += 1; + let iterator = this.lastEach; + this.indexes[iterator] = 0; + return iterator; } - walkAtRules(name, callback) { - if (!callback) { - callback = name; - return this.walk((child, i) => { - if (child.type === "atrule") { - return callback(child, i); + getProxyProcessor() { + return { + get(node, prop) { + if (prop === "proxyOf") { + return node; + } else if (!node[prop]) { + return node[prop]; + } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) { + return (...args) => { + return node[prop]( + ...args.map((i) => { + if (typeof i === "function") { + return (child, index) => i(child.toProxy(), index); + } else { + return i; + } + }) + ); + }; + } else if (prop === "every" || prop === "some") { + return (cb) => { + return node[prop]( + (child, ...other) => cb(child.toProxy(), ...other) + ); + }; + } else if (prop === "root") { + return () => node.root().toProxy(); + } else if (prop === "nodes") { + return node.nodes.map((i) => i.toProxy()); + } else if (prop === "first" || prop === "last") { + return node[prop].toProxy(); + } else { + return node[prop]; } - }); - } - if (name instanceof RegExp) { - return this.walk((child, i) => { - if (child.type === "atrule" && name.test(child.name)) { - return callback(child, i); + }, + set(node, prop, value) { + if (node[prop] === value) + return true; + node[prop] = value; + if (prop === "name" || prop === "params" || prop === "selector") { + node.markDirty(); } - }); - } - return this.walk((child, i) => { - if (child.type === "atrule" && child.name === name) { - return callback(child, i); + return true; } - }); + }; } - walkComments(callback) { - return this.walk((child, i) => { - if (child.type === "comment") { - return callback(child, i); - } - }); - } - append(...children) { - for (let child of children) { - let nodes = this.normalize(child, this.last); - for (let node of nodes) - this.proxyOf.nodes.push(node); - } - this.markDirty(); - return this; - } - prepend(...children) { - children = children.reverse(); - for (let child of children) { - let nodes = this.normalize(child, this.first, "prepend").reverse(); - for (let node of nodes) - this.proxyOf.nodes.unshift(node); - for (let id in this.indexes) { - this.indexes[id] = this.indexes[id] + nodes.length; - } - } - this.markDirty(); - return this; - } - cleanRaws(keepBetween) { - super.cleanRaws(keepBetween); - if (this.nodes) { - for (let node of this.nodes) - node.cleanRaws(keepBetween); - } - } - insertBefore(exist, add) { - let existIndex = this.index(exist); - let type = existIndex === 0 ? "prepend" : false; - let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse(); - existIndex = this.index(exist); - for (let node of nodes) - this.proxyOf.nodes.splice(existIndex, 0, node); - let index; - for (let id in this.indexes) { - index = this.indexes[id]; - if (existIndex <= index) { - this.indexes[id] = index + nodes.length; - } - } - this.markDirty(); - return this; + index(child) { + if (typeof child === "number") + return child; + if (child.proxyOf) + child = child.proxyOf; + return this.proxyOf.nodes.indexOf(child); } insertAfter(exist, add) { let existIndex = this.index(exist); @@ -1161,60 +1112,23 @@ this.markDirty(); return this; } - removeChild(child) { - child = this.index(child); - this.proxyOf.nodes[child].parent = void 0; - this.proxyOf.nodes.splice(child, 1); + insertBefore(exist, add) { + let existIndex = this.index(exist); + let type = existIndex === 0 ? "prepend" : false; + let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse(); + existIndex = this.index(exist); + for (let node of nodes) + this.proxyOf.nodes.splice(existIndex, 0, node); let index; for (let id in this.indexes) { index = this.indexes[id]; - if (index >= child) { - this.indexes[id] = index - 1; + if (existIndex <= index) { + this.indexes[id] = index + nodes.length; } } this.markDirty(); return this; } - removeAll() { - for (let node of this.proxyOf.nodes) - node.parent = void 0; - this.proxyOf.nodes = []; - this.markDirty(); - return this; - } - replaceValues(pattern, opts, callback) { - if (!callback) { - callback = opts; - opts = {}; - } - this.walkDecls((decl) => { - if (opts.props && !opts.props.includes(decl.prop)) - return; - if (opts.fast && !decl.value.includes(opts.fast)) - return; - decl.value = decl.value.replace(pattern, callback); - }); - this.markDirty(); - return this; - } - every(condition) { - return this.nodes.every(condition); - } - some(condition) { - return this.nodes.some(condition); - } - index(child) { - if (typeof child === "number") - return child; - if (child.proxyOf) - child = child.proxyOf; - return this.proxyOf.nodes.indexOf(child); - } - get first() { - if (!this.proxyOf.nodes) - return void 0; - return this.proxyOf.nodes[0]; - } get last() { if (!this.proxyOf.nodes) return void 0; @@ -1255,7 +1169,7 @@ } let processed = nodes.map((i) => { if (!i[my]) - Container.rebuild(i); + _Container.rebuild(i); i = i.proxyOf; if (i.parent) i.parent.removeChild(i); @@ -1271,61 +1185,149 @@ }); return processed; } - getProxyProcessor() { - return { - set(node, prop, value) { - if (node[prop] === value) - return true; - node[prop] = value; - if (prop === "name" || prop === "params" || prop === "selector") { - node.markDirty(); + prepend(...children) { + children = children.reverse(); + for (let child of children) { + let nodes = this.normalize(child, this.first, "prepend").reverse(); + for (let node of nodes) + this.proxyOf.nodes.unshift(node); + for (let id in this.indexes) { + this.indexes[id] = this.indexes[id] + nodes.length; + } + } + this.markDirty(); + return this; + } + push(child) { + child.parent = this; + this.proxyOf.nodes.push(child); + return this; + } + removeAll() { + for (let node of this.proxyOf.nodes) + node.parent = void 0; + this.proxyOf.nodes = []; + this.markDirty(); + return this; + } + removeChild(child) { + child = this.index(child); + this.proxyOf.nodes[child].parent = void 0; + this.proxyOf.nodes.splice(child, 1); + let index; + for (let id in this.indexes) { + index = this.indexes[id]; + if (index >= child) { + this.indexes[id] = index - 1; + } + } + this.markDirty(); + return this; + } + replaceValues(pattern, opts, callback) { + if (!callback) { + callback = opts; + opts = {}; + } + this.walkDecls((decl) => { + if (opts.props && !opts.props.includes(decl.prop)) + return; + if (opts.fast && !decl.value.includes(opts.fast)) + return; + decl.value = decl.value.replace(pattern, callback); + }); + this.markDirty(); + return this; + } + some(condition) { + return this.nodes.some(condition); + } + walk(callback) { + return this.each((child, i) => { + let result; + try { + result = callback(child, i); + } catch (e) { + throw child.addToError(e); + } + if (result !== false && child.walk) { + result = child.walk(callback); + } + return result; + }); + } + walkAtRules(name, callback) { + if (!callback) { + callback = name; + return this.walk((child, i) => { + if (child.type === "atrule") { + return callback(child, i); } - return true; - }, - get(node, prop) { - if (prop === "proxyOf") { - return node; - } else if (!node[prop]) { - return node[prop]; - } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) { - return (...args) => { - return node[prop]( - ...args.map((i) => { - if (typeof i === "function") { - return (child, index) => i(child.toProxy(), index); - } else { - return i; - } - }) - ); - }; - } else if (prop === "every" || prop === "some") { - return (cb) => { - return node[prop]( - (child, ...other) => cb(child.toProxy(), ...other) - ); - }; - } else if (prop === "root") { - return () => node.root().toProxy(); - } else if (prop === "nodes") { - return node.nodes.map((i) => i.toProxy()); - } else if (prop === "first" || prop === "last") { - return node[prop].toProxy(); - } else { - return node[prop]; + }); + } + if (name instanceof RegExp) { + return this.walk((child, i) => { + if (child.type === "atrule" && name.test(child.name)) { + return callback(child, i); } + }); + } + return this.walk((child, i) => { + if (child.type === "atrule" && child.name === name) { + return callback(child, i); } - }; + }); } - getIterator() { - if (!this.lastEach) - this.lastEach = 0; - if (!this.indexes) - this.indexes = {}; - this.lastEach += 1; - let iterator = this.lastEach; - this.indexes[iterator] = 0; - return iterator; + walkComments(callback) { + return this.walk((child, i) => { + if (child.type === "comment") { + return callback(child, i); + } + }); + } + walkDecls(prop, callback) { + if (!callback) { + callback = prop; + return this.walk((child, i) => { + if (child.type === "decl") { + return callback(child, i); + } + }); + } + if (prop instanceof RegExp) { + return this.walk((child, i) => { + if (child.type === "decl" && prop.test(child.prop)) { + return callback(child, i); + } + }); + } + return this.walk((child, i) => { + if (child.type === "decl" && child.prop === prop) { + return callback(child, i); + } + }); + } + walkRules(selector, callback) { + if (!callback) { + callback = selector; + return this.walk((child, i) => { + if (child.type === "rule") { + return callback(child, i); + } + }); + } + if (selector instanceof RegExp) { + return this.walk((child, i) => { + if (child.type === "rule" && selector.test(child.selector)) { + return callback(child, i); + } + }); + } + return this.walk((child, i) => { + if (child.type === "rule" && child.selector === selector) { + return callback(child, i); + } + }); } }; Container.registerParse = (dependant) => { @@ -1573,8 +1575,8 @@ } return { back, - nextToken, endOfFile, + nextToken, position }; }; @@ -1622,13 +1624,6 @@ if (!this.nodes) this.nodes = []; } - removeChild(child, ignore) { - let index = this.index(child); - if (!ignore && index === 0 && this.nodes.length > 1) { - this.nodes[1].raws.before = this.nodes[index].raws.before; - } - return super.removeChild(child); - } normalize(child, sample, type) { let nodes = super.normalize(child); if (sample) { @@ -1646,6 +1641,13 @@ } return nodes; } + removeChild(child, ignore) { + let index = this.index(child); + if (!ignore && index === 0 && this.nodes.length > 1) { + this.nodes[1].raws.before = this.nodes[index].raws.before; + } + return super.removeChild(child); + } toResult(opts = {}) { let lazy = new LazyResult(new Processor(), this, opts); return lazy.stringify(); @@ -1668,6 +1670,13 @@ "node_modules/postcss/lib/list.js"(exports, module) { "use strict"; var list = { + comma(string) { + return list.split(string, [","], true); + }, + space(string) { + let spaces = [" ", "\n", " "]; + return list.split(string, spaces); + }, split(string, separators, last) { let array = []; let current = ""; @@ -1709,13 +1718,6 @@ if (last || current !== "") array.push(current.trim()); return array; - }, - space(string) { - let spaces = [" ", "\n", " "]; - return list.split(string, spaces); - }, - comma(string) { - return list.split(string, [","], true); } }; module.exports = list; @@ -1782,40 +1784,126 @@ this.semicolon = false; this.customProperty = false; this.createTokenizer(); - this.root.source = { input, start: { offset: 0, line: 1, column: 1 } }; - } - createTokenizer() { - this.tokenizer = tokenizer(this.input); + this.root.source = { input, start: { column: 1, line: 1, offset: 0 } }; } - parse() { - let token; + atrule(token) { + let node = new AtRule(); + node.name = token[1].slice(1); + if (node.name === "") { + this.unnamedAtrule(node, token); + } + this.init(node, token[2]); + let type; + let prev; + let shift; + let last = false; + let open = false; + let params = []; + let brackets = []; while (!this.tokenizer.endOfFile()) { token = this.tokenizer.nextToken(); - switch (token[0]) { - case "space": - this.spaces += token[1]; + type = token[0]; + if (type === "(" || type === "[") { + brackets.push(type === "(" ? ")" : "]"); + } else if (type === "{" && brackets.length > 0) { + brackets.push("}"); + } else if (type === brackets[brackets.length - 1]) { + brackets.pop(); + } + if (brackets.length === 0) { + if (type === ";") { + node.source.end = this.getPosition(token[2]); + this.semicolon = true; break; - case ";": - this.freeSemicolon(token); + } else if (type === "{") { + open = true; break; - case "}": + } else if (type === "}") { + if (params.length > 0) { + shift = params.length - 1; + prev = params[shift]; + while (prev && prev[0] === "space") { + prev = params[--shift]; + } + if (prev) { + node.source.end = this.getPosition(prev[3] || prev[2]); + } + } this.end(token); break; - case "comment": - this.comment(token); - break; - case "at-word": - this.atrule(token); - break; - case "{": - this.emptyRule(token); - break; - default: - this.other(token); + } else { + params.push(token); + } + } else { + params.push(token); + } + if (this.tokenizer.endOfFile()) { + last = true; + break; + } + } + node.raws.between = this.spacesAndCommentsFromEnd(params); + if (params.length) { + node.raws.afterName = this.spacesAndCommentsFromStart(params); + this.raw(node, "params", params); + if (last) { + token = params[params.length - 1]; + node.source.end = this.getPosition(token[3] || token[2]); + this.spaces = node.raws.between; + node.raws.between = ""; + } + } else { + node.raws.afterName = ""; + node.params = ""; + } + if (open) { + node.nodes = []; + this.current = node; + } + } + checkMissedSemicolon(tokens) { + let colon = this.colon(tokens); + if (colon === false) + return; + let founded = 0; + let token; + for (let j = colon - 1; j >= 0; j--) { + token = tokens[j]; + if (token[0] !== "space") { + founded += 1; + if (founded === 2) break; } } - this.endFile(); + throw this.input.error( + "Missed semicolon", + token[0] === "word" ? token[3] + 1 : token[2] + ); + } + colon(tokens) { + let brackets = 0; + let token, type, prev; + for (let [i, element] of tokens.entries()) { + token = element; + type = token[0]; + if (type === "(") { + brackets += 1; + } + if (type === ")") { + brackets -= 1; + } + if (brackets === 0 && type === ":") { + if (!prev) { + this.doubleColon(token); + } else if (prev[0] === "word" && prev[1] === "progid") { + continue; + } else { + return i; + } + } + prev = token; + } + return false; } comment(token) { let node = new Comment(); @@ -1833,83 +1921,8 @@ node.raws.right = match[3]; } } - emptyRule(token) { - let node = new Rule(); - this.init(node, token[2]); - node.selector = ""; - node.raws.between = ""; - this.current = node; - } - other(start) { - let end = false; - let type = null; - let colon = false; - let bracket = null; - let brackets = []; - let customProperty = start[1].startsWith("--"); - let tokens = []; - let token = start; - while (token) { - type = token[0]; - tokens.push(token); - if (type === "(" || type === "[") { - if (!bracket) - bracket = token; - brackets.push(type === "(" ? ")" : "]"); - } else if (customProperty && colon && type === "{") { - if (!bracket) - bracket = token; - brackets.push("}"); - } else if (brackets.length === 0) { - if (type === ";") { - if (colon) { - this.decl(tokens, customProperty); - return; - } else { - break; - } - } else if (type === "{") { - this.rule(tokens); - return; - } else if (type === "}") { - this.tokenizer.back(tokens.pop()); - end = true; - break; - } else if (type === ":") { - colon = true; - } - } else if (type === brackets[brackets.length - 1]) { - brackets.pop(); - if (brackets.length === 0) - bracket = null; - } - token = this.tokenizer.nextToken(); - } - if (this.tokenizer.endOfFile()) - end = true; - if (brackets.length > 0) - this.unclosedBracket(bracket); - if (end && colon) { - if (!customProperty) { - while (tokens.length) { - token = tokens[tokens.length - 1][0]; - if (token !== "space" && token !== "comment") - break; - this.tokenizer.back(tokens.pop()); - } - } - this.decl(tokens, customProperty); - } else { - this.unknownWord(tokens); - } - } - rule(tokens) { - tokens.pop(); - let node = new Rule(); - this.init(node, tokens[0][2]); - node.raws.between = this.spacesAndCommentsFromEnd(tokens); - this.raw(node, "selector", tokens); - this.current = node; + createTokenizer() { + this.tokenizer = tokenizer(this.input); } decl(tokens, customProperty) { let node = new Declaration(); @@ -1997,86 +2010,25 @@ node.raws.between += firstSpaces.map((i) => i[1]).join(""); firstSpaces = []; } - this.raw(node, "value", firstSpaces.concat(tokens), customProperty); - if (node.value.includes(":") && !customProperty) { - this.checkMissedSemicolon(tokens); - } - } - atrule(token) { - let node = new AtRule(); - node.name = token[1].slice(1); - if (node.name === "") { - this.unnamedAtrule(node, token); - } - this.init(node, token[2]); - let type; - let prev; - let shift; - let last = false; - let open = false; - let params = []; - let brackets = []; - while (!this.tokenizer.endOfFile()) { - token = this.tokenizer.nextToken(); - type = token[0]; - if (type === "(" || type === "[") { - brackets.push(type === "(" ? ")" : "]"); - } else if (type === "{" && brackets.length > 0) { - brackets.push("}"); - } else if (type === brackets[brackets.length - 1]) { - brackets.pop(); - } - if (brackets.length === 0) { - if (type === ";") { - node.source.end = this.getPosition(token[2]); - this.semicolon = true; - break; - } else if (type === "{") { - open = true; - break; - } else if (type === "}") { - if (params.length > 0) { - shift = params.length - 1; - prev = params[shift]; - while (prev && prev[0] === "space") { - prev = params[--shift]; - } - if (prev) { - node.source.end = this.getPosition(prev[3] || prev[2]); - } - } - this.end(token); - break; - } else { - params.push(token); - } - } else { - params.push(token); - } - if (this.tokenizer.endOfFile()) { - last = true; - break; - } - } - node.raws.between = this.spacesAndCommentsFromEnd(params); - if (params.length) { - node.raws.afterName = this.spacesAndCommentsFromStart(params); - this.raw(node, "params", params); - if (last) { - token = params[params.length - 1]; - node.source.end = this.getPosition(token[3] || token[2]); - this.spaces = node.raws.between; - node.raws.between = ""; - } - } else { - node.raws.afterName = ""; - node.params = ""; - } - if (open) { - node.nodes = []; - this.current = node; + this.raw(node, "value", firstSpaces.concat(tokens), customProperty); + if (node.value.includes(":") && !customProperty) { + this.checkMissedSemicolon(tokens); } } + doubleColon(token) { + throw this.input.error( + "Double colon", + { offset: token[2] }, + { offset: token[2] + token[1].length } + ); + } + emptyRule(token) { + let node = new Rule(); + this.init(node, token[2]); + node.selector = ""; + node.raws.between = ""; + this.current = node; + } end(token) { if (this.current.nodes && this.current.nodes.length) { this.current.raws.semicolon = this.semicolon; @@ -2098,6 +2050,7 @@ this.current.raws.semicolon = this.semicolon; } this.current.raws.after = (this.current.raws.after || "") + this.spaces; + this.root.source.end = this.getPosition(this.tokenizer.position()); } freeSemicolon(token) { this.spaces += token[1]; @@ -2113,22 +2066,117 @@ getPosition(offset) { let pos = this.input.fromOffset(offset); return { - offset, + column: pos.col, line: pos.line, - column: pos.col + offset }; } init(node, offset) { this.current.push(node); node.source = { - start: this.getPosition(offset), - input: this.input + input: this.input, + start: this.getPosition(offset) }; node.raws.before = this.spaces; this.spaces = ""; if (node.type !== "comment") this.semicolon = false; } + other(start) { + let end = false; + let type = null; + let colon = false; + let bracket = null; + let brackets = []; + let customProperty = start[1].startsWith("--"); + let tokens = []; + let token = start; + while (token) { + type = token[0]; + tokens.push(token); + if (type === "(" || type === "[") { + if (!bracket) + bracket = token; + brackets.push(type === "(" ? ")" : "]"); + } else if (customProperty && colon && type === "{") { + if (!bracket) + bracket = token; + brackets.push("}"); + } else if (brackets.length === 0) { + if (type === ";") { + if (colon) { + this.decl(tokens, customProperty); + return; + } else { + break; + } + } else if (type === "{") { + this.rule(tokens); + return; + } else if (type === "}") { + this.tokenizer.back(tokens.pop()); + end = true; + break; + } else if (type === ":") { + colon = true; + } + } else if (type === brackets[brackets.length - 1]) { + brackets.pop(); + if (brackets.length === 0) + bracket = null; + } + token = this.tokenizer.nextToken(); + } + if (this.tokenizer.endOfFile()) + end = true; + if (brackets.length > 0) + this.unclosedBracket(bracket); + if (end && colon) { + if (!customProperty) { + while (tokens.length) { + token = tokens[tokens.length - 1][0]; + if (token !== "space" && token !== "comment") + break; + this.tokenizer.back(tokens.pop()); + } + } + this.decl(tokens, customProperty); + } else { + this.unknownWord(tokens); + } + } + parse() { + let token; + while (!this.tokenizer.endOfFile()) { + token = this.tokenizer.nextToken(); + switch (token[0]) { + case "space": + this.spaces += token[1]; + break; + case ";": + this.freeSemicolon(token); + break; + case "}": + this.end(token); + break; + case "comment": + this.comment(token); + break; + case "at-word": + this.atrule(token); + break; + case "{": + this.emptyRule(token); + break; + default: + this.other(token); + break; + } + } + this.endFile(); + } + precheckMissedSemicolon() { + } raw(node, prop, tokens, customProperty) { let token, type; let length = tokens.length; @@ -2158,10 +2206,18 @@ } if (!clean2) { let raw = tokens.reduce((all, i) => all + i[1], ""); - node.raws[prop] = { value, raw }; + node.raws[prop] = { raw, value }; } node[prop] = value; } + rule(tokens) { + tokens.pop(); + let node = new Rule(); + this.init(node, tokens[0][2]); + node.raws.between = this.spacesAndCommentsFromEnd(tokens); + this.raw(node, "selector", tokens); + this.current = node; + } spacesAndCommentsFromEnd(tokens) { let lastTokenType; let spaces = ""; @@ -2173,6 +2229,7 @@ } return spaces; } + // Errors spacesAndCommentsFromStart(tokens) { let next; let spaces = ""; @@ -2203,32 +2260,10 @@ tokens.splice(from, tokens.length - from); return result; } - colon(tokens) { - let brackets = 0; - let token, type, prev; - for (let [i, element] of tokens.entries()) { - token = element; - type = token[0]; - if (type === "(") { - brackets += 1; - } - if (type === ")") { - brackets -= 1; - } - if (brackets === 0 && type === ":") { - if (!prev) { - this.doubleColon(token); - } else if (prev[0] === "word" && prev[1] === "progid") { - continue; - } else { - return i; - } - } - prev = token; - } - return false; + unclosedBlock() { + let pos = this.current.source.start; + throw this.input.error("Unclosed block", pos.line, pos.column); } - // Errors unclosedBracket(bracket) { throw this.input.error( "Unclosed bracket", @@ -2236,13 +2271,6 @@ { offset: bracket[2] + 1 } ); } - unknownWord(tokens) { - throw this.input.error( - "Unknown word", - { offset: tokens[0][2] }, - { offset: tokens[0][2] + tokens[0][1].length } - ); - } unexpectedClose(token) { throw this.input.error( "Unexpected }", @@ -2250,15 +2278,11 @@ { offset: token[2] + 1 } ); } - unclosedBlock() { - let pos = this.current.source.start; - throw this.input.error("Unclosed block", pos.line, pos.column); - } - doubleColon(token) { + unknownWord(tokens) { throw this.input.error( - "Double colon", - { offset: token[2] }, - { offset: token[2] + token[1].length } + "Unknown word", + { offset: tokens[0][2] }, + { offset: tokens[0][2] + tokens[0][1].length } ); } unnamedAtrule(node, token) { @@ -2268,27 +2292,6 @@ { offset: token[2] + token[1].length } ); } - precheckMissedSemicolon() { - } - checkMissedSemicolon(tokens) { - let colon = this.colon(tokens); - if (colon === false) - return; - let founded = 0; - let token; - for (let j = colon - 1; j >= 0; j--) { - token = tokens[j]; - if (token[0] !== "space") { - founded += 1; - if (founded === 2) - break; - } - } - throw this.input.error( - "Missed semicolon", - token[0] === "word" ? token[3] + 1 : token[2] - ); - } }; module.exports = Parser; } @@ -2340,7 +2343,7 @@ "use strict"; var { SourceMapConsumer, SourceMapGenerator } = require_source_map(); var { fileURLToPath, pathToFileURL } = {}; - var { resolve, isAbsolute } = {}; + var { isAbsolute, resolve } = {}; var { nanoid } = require_non_secure(); var terminalHighlight = require_terminal_highlight(); var CssSyntaxError = require_css_syntax_error(); @@ -2382,44 +2385,6 @@ if (this.map) this.map.file = this.from; } - fromOffset(offset) { - let lastLine, lineToIndex; - if (!this[fromOffsetCache]) { - let lines = this.css.split("\n"); - lineToIndex = new Array(lines.length); - let prevIndex = 0; - for (let i = 0, l = lines.length; i < l; i++) { - lineToIndex[i] = prevIndex; - prevIndex += lines[i].length + 1; - } - this[fromOffsetCache] = lineToIndex; - } else { - lineToIndex = this[fromOffsetCache]; - } - lastLine = lineToIndex[lineToIndex.length - 1]; - let min = 0; - if (offset >= lastLine) { - min = lineToIndex.length - 1; - } else { - let max = lineToIndex.length - 2; - let mid; - while (min < max) { - mid = min + (max - min >> 1); - if (offset < lineToIndex[mid]) { - max = mid - 1; - } else if (offset >= lineToIndex[mid + 1]) { - min = mid + 1; - } else { - min = mid; - break; - } - } - } - return { - line: min + 1, - col: offset - lineToIndex[min] + 1 - }; - } error(message, line2, column, opts = {}) { let result, endLine, endColumn; if (line2 && typeof line2 === "object") { @@ -2450,8 +2415,8 @@ if (origin) { result = new CssSyntaxError( message, - origin.endLine === void 0 ? origin.line : { line: origin.line, column: origin.column }, - origin.endLine === void 0 ? origin.column : { line: origin.endLine, column: origin.endColumn }, + origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line }, + origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine }, origin.source, origin.file, opts.plugin @@ -2459,32 +2424,79 @@ } else { result = new CssSyntaxError( message, - endLine === void 0 ? line2 : { line: line2, column }, - endLine === void 0 ? column : { line: endLine, column: endColumn }, + endLine === void 0 ? line2 : { column, line: line2 }, + endLine === void 0 ? column : { column: endColumn, line: endLine }, this.css, this.file, opts.plugin ); } - result.input = { line: line2, column, endLine, endColumn, source: this.css }; + result.input = { column, endColumn, endLine, line: line2, source: this.css }; if (this.file) { if (pathToFileURL) { result.input.url = pathToFileURL(this.file).toString(); } - result.input.file = this.file; + result.input.file = this.file; + } + return result; + } + get from() { + return this.file || this.id; + } + fromOffset(offset) { + let lastLine, lineToIndex; + if (!this[fromOffsetCache]) { + let lines = this.css.split("\n"); + lineToIndex = new Array(lines.length); + let prevIndex = 0; + for (let i = 0, l = lines.length; i < l; i++) { + lineToIndex[i] = prevIndex; + prevIndex += lines[i].length + 1; + } + this[fromOffsetCache] = lineToIndex; + } else { + lineToIndex = this[fromOffsetCache]; + } + lastLine = lineToIndex[lineToIndex.length - 1]; + let min = 0; + if (offset >= lastLine) { + min = lineToIndex.length - 1; + } else { + let max = lineToIndex.length - 2; + let mid; + while (min < max) { + mid = min + (max - min >> 1); + if (offset < lineToIndex[mid]) { + max = mid - 1; + } else if (offset >= lineToIndex[mid + 1]) { + min = mid + 1; + } else { + min = mid; + break; + } + } } - return result; + return { + col: offset - lineToIndex[min] + 1, + line: min + 1 + }; + } + mapResolve(file) { + if (/^\w+:\/\//.test(file)) { + return file; + } + return resolve(this.map.consumer().sourceRoot || this.map.root || ".", file); } origin(line2, column, endLine, endColumn) { if (!this.map) return false; let consumer = this.map.consumer(); - let from = consumer.originalPositionFor({ line: line2, column }); + let from = consumer.originalPositionFor({ column, line: line2 }); if (!from.source) return false; let to; if (typeof endLine === "number") { - to = consumer.originalPositionFor({ line: endLine, column: endColumn }); + to = consumer.originalPositionFor({ column: endColumn, line: endLine }); } let fromUrl; if (isAbsolute(from.source)) { @@ -2496,11 +2508,11 @@ ); } let result = { - url: fromUrl.toString(), - line: from.line, column: from.column, + endColumn: to && to.column, endLine: to && to.line, - endColumn: to && to.column + line: from.line, + url: fromUrl.toString() }; if (fromUrl.protocol === "file:") { if (fileURLToPath) { @@ -2514,15 +2526,6 @@ result.source = source; return result; } - mapResolve(file) { - if (/^\w+:\/\//.test(file)) { - return file; - } - return resolve(this.map.consumer().sourceRoot || this.map.root || ".", file); - } - get from() { - return this.file || this.id; - } toJSON() { let json = {}; for (let name of ["hasBOM", "css", "file", "id"]) { @@ -3064,8 +3067,8 @@ toString() { if (this.node) { return this.node.error(this.text, { - plugin: this.plugin, index: this.index, + plugin: this.plugin, word: this.word }).message; } @@ -3094,6 +3097,9 @@ this.css = void 0; this.map = void 0; } + get content() { + return this.css; + } toString() { return this.css; } @@ -3110,9 +3116,6 @@ warnings() { return this.messages.filter((i) => i.type === "warning"); } - get content() { - return this.css; - } }; module.exports = Result; Result.default = Result; @@ -3133,35 +3136,35 @@ var parse3 = require_parse(); var Root = require_root(); var TYPE_TO_CLASS_NAME = { - document: "Document", - root: "Root", atrule: "AtRule", - rule: "Rule", + comment: "Comment", decl: "Declaration", - comment: "Comment" + document: "Document", + root: "Root", + rule: "Rule" }; var PLUGIN_PROPS = { - postcssPlugin: true, - prepare: true, - Once: true, - Document: true, - Root: true, - Declaration: true, - Rule: true, AtRule: true, - Comment: true, - DeclarationExit: true, - RuleExit: true, AtRuleExit: true, + Comment: true, CommentExit: true, - RootExit: true, + Declaration: true, + DeclarationExit: true, + Document: true, DocumentExit: true, - OnceExit: true + Once: true, + OnceExit: true, + postcssPlugin: true, + prepare: true, + Root: true, + RootExit: true, + Rule: true, + RuleExit: true }; var NOT_VISITORS = { + Once: true, postcssPlugin: true, - prepare: true, - Once: true + prepare: true }; var CHILDREN = 0; function isPromise(obj) { @@ -3192,242 +3195,95 @@ } } function toStack(node) { - let events; - if (node.type === "document") { - events = ["Document", CHILDREN, "DocumentExit"]; - } else if (node.type === "root") { - events = ["Root", CHILDREN, "RootExit"]; - } else { - events = getEvents(node); - } - return { - node, - events, - eventIndex: 0, - visitors: [], - visitorIndex: 0, - iterator: 0 - }; - } - function cleanMarks(node) { - node[isClean] = false; - if (node.nodes) - node.nodes.forEach((i) => cleanMarks(i)); - return node; - } - var postcss = {}; - var LazyResult = class { - constructor(processor, css2, opts) { - this.stringified = false; - this.processed = false; - let root; - if (typeof css2 === "object" && css2 !== null && (css2.type === "root" || css2.type === "document")) { - root = cleanMarks(css2); - } else if (css2 instanceof LazyResult || css2 instanceof Result) { - root = cleanMarks(css2.root); - if (css2.map) { - if (typeof opts.map === "undefined") - opts.map = {}; - if (!opts.map.inline) - opts.map.inline = false; - opts.map.prev = css2.map; - } - } else { - let parser = parse3; - if (opts.syntax) - parser = opts.syntax.parse; - if (opts.parser) - parser = opts.parser; - if (parser.parse) - parser = parser.parse; - try { - root = parser(css2, opts); - } catch (error) { - this.processed = true; - this.error = error; - } - if (root && !root[my]) { - Container.rebuild(root); - } - } - this.result = new Result(processor, root, opts); - this.helpers = { ...postcss, result: this.result, postcss }; - this.plugins = this.processor.plugins.map((plugin) => { - if (typeof plugin === "object" && plugin.prepare) { - return { ...plugin, ...plugin.prepare(this.result) }; - } else { - return plugin; - } - }); - } - get [Symbol.toStringTag]() { - return "LazyResult"; - } - get processor() { - return this.result.processor; - } - get opts() { - return this.result.opts; - } - get css() { - return this.stringify().css; - } - get content() { - return this.stringify().content; - } - get map() { - return this.stringify().map; - } - get root() { - return this.sync().root; - } - get messages() { - return this.sync().messages; - } - warnings() { - return this.sync().warnings(); - } - toString() { - return this.css; - } - then(onFulfilled, onRejected) { - if (false) { - if (!("from" in this.opts)) { - warnOnce( - "Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning." - ); - } - } - return this.async().then(onFulfilled, onRejected); - } - catch(onRejected) { - return this.async().catch(onRejected); - } - finally(onFinally) { - return this.async().then(onFinally, onFinally); - } - async() { - if (this.error) - return Promise.reject(this.error); - if (this.processed) - return Promise.resolve(this.result); - if (!this.processing) { - this.processing = this.runAsync(); - } - return this.processing; - } - sync() { - if (this.error) - throw this.error; - if (this.processed) - return this.result; - this.processed = true; - if (this.processing) { - throw this.getAsyncError(); - } - for (let plugin of this.plugins) { - let promise = this.runOnRoot(plugin); - if (isPromise(promise)) { - throw this.getAsyncError(); - } - } - this.prepareVisitors(); - if (this.hasListener) { - let root = this.result.root; - while (!root[isClean]) { - root[isClean] = true; - this.walkSync(root); - } - if (this.listeners.OnceExit) { - if (root.type === "document") { - for (let subRoot of root.nodes) { - this.visitSync(this.listeners.OnceExit, subRoot); - } - } else { - this.visitSync(this.listeners.OnceExit, root); - } - } - } - return this.result; - } - stringify() { - if (this.error) - throw this.error; - if (this.stringified) - return this.result; - this.stringified = true; - this.sync(); - let opts = this.result.opts; - let str = stringify; - if (opts.syntax) - str = opts.syntax.stringify; - if (opts.stringifier) - str = opts.stringifier; - if (str.stringify) - str = str.stringify; - let map = new MapGenerator(str, this.result.root, this.result.opts); - let data = map.generate(); - this.result.css = data[0]; - this.result.map = data[1]; - return this.result; - } - walkSync(node) { - node[isClean] = true; - let events = getEvents(node); - for (let event of events) { - if (event === CHILDREN) { - if (node.nodes) { - node.each((child) => { - if (!child[isClean]) - this.walkSync(child); - }); - } - } else { - let visitors = this.listeners[event]; - if (visitors) { - if (this.visitSync(visitors, node.toProxy())) - return; - } - } - } + let events; + if (node.type === "document") { + events = ["Document", CHILDREN, "DocumentExit"]; + } else if (node.type === "root") { + events = ["Root", CHILDREN, "RootExit"]; + } else { + events = getEvents(node); } - visitSync(visitors, node) { - for (let [plugin, visitor] of visitors) { - this.result.lastPlugin = plugin; - let promise; - try { - promise = visitor(node, this.helpers); - } catch (e) { - throw this.handleError(e, node.proxyOf); + return { + eventIndex: 0, + events, + iterator: 0, + node, + visitorIndex: 0, + visitors: [] + }; + } + function cleanMarks(node) { + node[isClean] = false; + if (node.nodes) + node.nodes.forEach((i) => cleanMarks(i)); + return node; + } + var postcss = {}; + var LazyResult = class _LazyResult { + constructor(processor, css2, opts) { + this.stringified = false; + this.processed = false; + let root; + if (typeof css2 === "object" && css2 !== null && (css2.type === "root" || css2.type === "document")) { + root = cleanMarks(css2); + } else if (css2 instanceof _LazyResult || css2 instanceof Result) { + root = cleanMarks(css2.root); + if (css2.map) { + if (typeof opts.map === "undefined") + opts.map = {}; + if (!opts.map.inline) + opts.map.inline = false; + opts.map.prev = css2.map; } - if (node.type !== "root" && node.type !== "document" && !node.parent) { - return true; + } else { + let parser = parse3; + if (opts.syntax) + parser = opts.syntax.parse; + if (opts.parser) + parser = opts.parser; + if (parser.parse) + parser = parser.parse; + try { + root = parser(css2, opts); + } catch (error) { + this.processed = true; + this.error = error; } - if (isPromise(promise)) { - throw this.getAsyncError(); + if (root && !root[my]) { + Container.rebuild(root); } } - } - runOnRoot(plugin) { - this.result.lastPlugin = plugin; - try { - if (typeof plugin === "object" && plugin.Once) { - if (this.result.root.type === "document") { - let roots = this.result.root.nodes.map( - (root) => plugin.Once(root, this.helpers) - ); - if (isPromise(roots[0])) { - return Promise.all(roots); - } - return roots; - } - return plugin.Once(this.result.root, this.helpers); - } else if (typeof plugin === "function") { - return plugin(this.result.root, this.result); + this.result = new Result(processor, root, opts); + this.helpers = { ...postcss, postcss, result: this.result }; + this.plugins = this.processor.plugins.map((plugin) => { + if (typeof plugin === "object" && plugin.prepare) { + return { ...plugin, ...plugin.prepare(this.result) }; + } else { + return plugin; } - } catch (error) { - throw this.handleError(error); + }); + } + async() { + if (this.error) + return Promise.reject(this.error); + if (this.processed) + return Promise.resolve(this.result); + if (!this.processing) { + this.processing = this.runAsync(); } + return this.processing; + } + catch(onRejected) { + return this.async().catch(onRejected); + } + get content() { + return this.stringify().content; + } + get css() { + return this.stringify().css; + } + finally(onFinally) { + return this.async().then(onFinally, onFinally); } getAsyncError() { throw new Error("Use process(css).then(cb) to work with async plugins"); @@ -3461,6 +3317,58 @@ } return error; } + get map() { + return this.stringify().map; + } + get messages() { + return this.sync().messages; + } + get opts() { + return this.result.opts; + } + prepareVisitors() { + this.listeners = {}; + let add = (plugin, type, cb) => { + if (!this.listeners[type]) + this.listeners[type] = []; + this.listeners[type].push([plugin, cb]); + }; + for (let plugin of this.plugins) { + if (typeof plugin === "object") { + for (let event in plugin) { + if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) { + throw new Error( + `Unknown event ${event} in ${plugin.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).` + ); + } + if (!NOT_VISITORS[event]) { + if (typeof plugin[event] === "object") { + for (let filter in plugin[event]) { + if (filter === "*") { + add(plugin, event, plugin[event][filter]); + } else { + add( + plugin, + event + "-" + filter.toLowerCase(), + plugin[event][filter] + ); + } + } + } else if (typeof plugin[event] === "function") { + add(plugin, event, plugin[event]); + } + } + } + } + } + this.hasListener = Object.keys(this.listeners).length > 0; + } + get processor() { + return this.result.processor; + } + get root() { + return this.sync().root; + } async runAsync() { this.plugin = 0; for (let i = 0; i < this.plugins.length; i++) { @@ -3513,42 +3421,114 @@ this.processed = true; return this.stringify(); } - prepareVisitors() { - this.listeners = {}; - let add = (plugin, type, cb) => { - if (!this.listeners[type]) - this.listeners[type] = []; - this.listeners[type].push([plugin, cb]); - }; - for (let plugin of this.plugins) { - if (typeof plugin === "object") { - for (let event in plugin) { - if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) { - throw new Error( - `Unknown event ${event} in ${plugin.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).` - ); + runOnRoot(plugin) { + this.result.lastPlugin = plugin; + try { + if (typeof plugin === "object" && plugin.Once) { + if (this.result.root.type === "document") { + let roots = this.result.root.nodes.map( + (root) => plugin.Once(root, this.helpers) + ); + if (isPromise(roots[0])) { + return Promise.all(roots); } - if (!NOT_VISITORS[event]) { - if (typeof plugin[event] === "object") { - for (let filter in plugin[event]) { - if (filter === "*") { - add(plugin, event, plugin[event][filter]); - } else { - add( - plugin, - event + "-" + filter.toLowerCase(), - plugin[event][filter] - ); - } - } - } else if (typeof plugin[event] === "function") { - add(plugin, event, plugin[event]); - } + return roots; + } + return plugin.Once(this.result.root, this.helpers); + } else if (typeof plugin === "function") { + return plugin(this.result.root, this.result); + } + } catch (error) { + throw this.handleError(error); + } + } + stringify() { + if (this.error) + throw this.error; + if (this.stringified) + return this.result; + this.stringified = true; + this.sync(); + let opts = this.result.opts; + let str = stringify; + if (opts.syntax) + str = opts.syntax.stringify; + if (opts.stringifier) + str = opts.stringifier; + if (str.stringify) + str = str.stringify; + let map = new MapGenerator(str, this.result.root, this.result.opts); + let data = map.generate(); + this.result.css = data[0]; + this.result.map = data[1]; + return this.result; + } + get [Symbol.toStringTag]() { + return "LazyResult"; + } + sync() { + if (this.error) + throw this.error; + if (this.processed) + return this.result; + this.processed = true; + if (this.processing) { + throw this.getAsyncError(); + } + for (let plugin of this.plugins) { + let promise = this.runOnRoot(plugin); + if (isPromise(promise)) { + throw this.getAsyncError(); + } + } + this.prepareVisitors(); + if (this.hasListener) { + let root = this.result.root; + while (!root[isClean]) { + root[isClean] = true; + this.walkSync(root); + } + if (this.listeners.OnceExit) { + if (root.type === "document") { + for (let subRoot of root.nodes) { + this.visitSync(this.listeners.OnceExit, subRoot); } + } else { + this.visitSync(this.listeners.OnceExit, root); } } } - this.hasListener = Object.keys(this.listeners).length > 0; + return this.result; + } + then(onFulfilled, onRejected) { + if (false) { + if (!("from" in this.opts)) { + warnOnce( + "Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning." + ); + } + } + return this.async().then(onFulfilled, onRejected); + } + toString() { + return this.css; + } + visitSync(visitors, node) { + for (let [plugin, visitor] of visitors) { + this.result.lastPlugin = plugin; + let promise; + try { + promise = visitor(node, this.helpers); + } catch (e) { + throw this.handleError(e, node.proxyOf); + } + if (node.type !== "root" && node.type !== "document" && !node.parent) { + return true; + } + if (isPromise(promise)) { + throw this.getAsyncError(); + } + } } visitTick(stack) { let visit = stack[stack.length - 1]; @@ -3602,6 +3582,29 @@ } stack.pop(); } + walkSync(node) { + node[isClean] = true; + let events = getEvents(node); + for (let event of events) { + if (event === CHILDREN) { + if (node.nodes) { + node.each((child) => { + if (!child[isClean]) + this.walkSync(child); + }); + } + } else { + let visitors = this.listeners[event]; + if (visitors) { + if (this.visitSync(visitors, node.toProxy())) + return; + } + } + } + } + warnings() { + return this.sync().warnings(); + } }; LazyResult.registerPostcss = (dependant) => { postcss = dependant; @@ -3651,24 +3654,35 @@ } } } - get [Symbol.toStringTag]() { - return "NoWorkResult"; + async() { + if (this.error) + return Promise.reject(this.error); + return Promise.resolve(this.result); } - get processor() { - return this.result.processor; + catch(onRejected) { + return this.async().catch(onRejected); } - get opts() { - return this.result.opts; + get content() { + return this.result.css; } get css() { return this.result.css; } - get content() { - return this.result.css; + finally(onFinally) { + return this.async().then(onFinally, onFinally); } get map() { return this.result.map; } + get messages() { + return []; + } + get opts() { + return this.result.opts; + } + get processor() { + return this.result.processor; + } get root() { if (this._root) { return this._root; @@ -3687,14 +3701,13 @@ return root; } } - get messages() { - return []; - } - warnings() { - return []; + get [Symbol.toStringTag]() { + return "NoWorkResult"; } - toString() { - return this._css; + sync() { + if (this.error) + throw this.error; + return this.result; } then(onFulfilled, onRejected) { if (false) { @@ -3706,21 +3719,11 @@ } return this.async().then(onFulfilled, onRejected); } - catch(onRejected) { - return this.async().catch(onRejected); - } - finally(onFinally) { - return this.async().then(onFinally, onFinally); - } - async() { - if (this.error) - return Promise.reject(this.error); - return Promise.resolve(this.result); + toString() { + return this._css; } - sync() { - if (this.error) - throw this.error; - return this.result; + warnings() { + return []; } }; module.exports = NoWorkResult; @@ -3738,20 +3741,9 @@ var Root = require_root(); var Processor = class { constructor(plugins = []) { - this.version = "8.4.23"; + this.version = "8.4.28"; this.plugins = this.normalize(plugins); } - use(plugin) { - this.plugins = this.plugins.concat(this.normalize([plugin])); - return this; - } - process(css2, opts = {}) { - if (this.plugins.length === 0 && typeof opts.parser === "undefined" && typeof opts.stringifier === "undefined" && typeof opts.syntax === "undefined") { - return new NoWorkResult(this, css2, opts); - } else { - return new LazyResult(this, css2, opts); - } - } normalize(plugins) { let normalized = []; for (let i of plugins) { @@ -3778,6 +3770,17 @@ } return normalized; } + process(css2, opts = {}) { + if (this.plugins.length === 0 && typeof opts.parser === "undefined" && typeof opts.stringifier === "undefined" && typeof opts.syntax === "undefined") { + return new NoWorkResult(this, css2, opts); + } else { + return new LazyResult(this, css2, opts); + } + } + use(plugin) { + this.plugins = this.plugins.concat(this.normalize([plugin])); + return this; + } }; module.exports = Processor; Processor.default = Processor; @@ -4210,8 +4213,8 @@ } return { back, - nextToken, endOfFile, + nextToken, position }; }; @@ -4226,9 +4229,65 @@ var NestedDeclaration = require_nested_declaration(); var scssTokenizer = require_scss_tokenize(); var ScssParser = class extends Parser { + atrule(token) { + let name = token[1]; + let prev = token; + while (!this.tokenizer.endOfFile()) { + let next = this.tokenizer.nextToken(); + if (next[0] === "word" && next[2] === prev[3] + 1) { + name += next[1]; + prev = next; + } else { + this.tokenizer.back(next); + break; + } + } + super.atrule(["at-word", name, token[2], prev[3]]); + } + comment(token) { + if (token[4] === "inline") { + let node = new Comment(); + this.init(node, token[2]); + node.raws.inline = true; + let pos = this.input.fromOffset(token[3]); + node.source.end = { column: pos.col, line: pos.line, offset: token[3] }; + let text = token[1].slice(2); + if (/^\s*$/.test(text)) { + node.text = ""; + node.raws.left = text; + node.raws.right = ""; + } else { + let match = text.match(/^(\s*)([^]*\S)(\s*)$/); + let fixed = match[2].replace(/(\*\/|\/\*)/g, "*//*"); + node.text = fixed; + node.raws.left = match[1]; + node.raws.right = match[3]; + node.raws.text = match[2]; + } + } else { + super.comment(token); + } + } createTokenizer() { this.tokenizer = scssTokenizer(this.input); } + raw(node, prop, tokens, customProperty) { + super.raw(node, prop, tokens, customProperty); + if (node.raws[prop]) { + let scss2 = node.raws[prop].raw; + node.raws[prop].raw = tokens.reduce((all, i) => { + if (i[0] === "comment" && i[4] === "inline") { + let text = i[1].slice(2).replace(/(\*\/|\/\*)/g, "*//*"); + return all + "/*" + text + "*/"; + } else { + return all + i[1]; + } + }, ""); + if (scss2 !== node.raws[prop].raw) { + node.raws[prop].scss = scss2; + } + } + } rule(tokens) { let withColon = false; let brackets = 0; @@ -4263,10 +4322,10 @@ } if (last[3]) { let pos = this.input.fromOffset(last[3]); - node.source.end = { offset: last[3], line: pos.line, column: pos.col }; + node.source.end = { column: pos.col, line: pos.line, offset: last[3] }; } else { let pos = this.input.fromOffset(last[2]); - node.source.end = { offset: last[2], line: pos.line, column: pos.col }; + node.source.end = { column: pos.col, line: pos.line, offset: last[2] }; } while (tokens[0][0] !== "word") { node.raws.before += tokens.shift()[1]; @@ -4274,9 +4333,9 @@ if (tokens[0][2]) { let pos = this.input.fromOffset(tokens[0][2]); node.source.start = { - offset: tokens[0][2], + column: pos.col, line: pos.line, - column: pos.col + offset: tokens[0][2] }; } node.prop = ""; @@ -4341,62 +4400,6 @@ this.current = node; } } - comment(token) { - if (token[4] === "inline") { - let node = new Comment(); - this.init(node, token[2]); - node.raws.inline = true; - let pos = this.input.fromOffset(token[3]); - node.source.end = { offset: token[3], line: pos.line, column: pos.col }; - let text = token[1].slice(2); - if (/^\s*$/.test(text)) { - node.text = ""; - node.raws.left = text; - node.raws.right = ""; - } else { - let match = text.match(/^(\s*)([^]*\S)(\s*)$/); - let fixed = match[2].replace(/(\*\/|\/\*)/g, "*//*"); - node.text = fixed; - node.raws.left = match[1]; - node.raws.right = match[3]; - node.raws.text = match[2]; - } - } else { - super.comment(token); - } - } - atrule(token) { - let name = token[1]; - let prev = token; - while (!this.tokenizer.endOfFile()) { - let next = this.tokenizer.nextToken(); - if (next[0] === "word" && next[2] === prev[3] + 1) { - name += next[1]; - prev = next; - } else { - this.tokenizer.back(next); - break; - } - } - super.atrule(["at-word", name, token[2], prev[3]]); - } - raw(node, prop, tokens, customProperty) { - super.raw(node, prop, tokens, customProperty); - if (node.raws[prop]) { - let scss2 = node.raws[prop].raw; - node.raws[prop].raw = tokens.reduce((all, i) => { - if (i[0] === "comment" && i[4] === "inline") { - let text = i[1].slice(2).replace(/(\*\/|\/\*)/g, "*//*"); - return all + "/*" + text + "*/"; - } else { - return all + i[1]; - } - }, ""); - if (scss2 !== node.raws[prop].raw) { - node.raws[prop].scss = scss2; - } - } - } }; module.exports = ScssParser; } @@ -9942,6 +9945,10 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; const isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode); const requireSpaceBeforeOperator = (iNextNextNode == null ? void 0 : iNextNextNode.type) === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode); const requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || (iPrevNode == null ? void 0 : iPrevNode.type) === "value-func" || iPrevNode && isWordNode(iPrevNode); + if (options2.parser === "scss" && isMathOperator && iNode.value === "-" && iNextNode.type === "value-func") { + parts.push(" "); + continue; + } if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) { continue; } @@ -10105,7 +10112,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`; if (isVarFunctionNode(path.grandparent) && hasComma(path, options2)) { return ","; } - if (path.node.type !== "value-comment" && shouldPrintTrailingComma(options2) && path.callParent(() => isSCSSMapItemNode(path, options2))) { + if (path.node.type !== "value-comment" && !(path.node.type === "value-comma_group" && path.node.groups.every((group2) => group2.type === "value-comment")) && shouldPrintTrailingComma(options2) && path.callParent(() => isSCSSMapItemNode(path, options2))) { return ifBreak(","); } return "";