first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

201
node_modules/@n8n/tournament/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2023 n8n GmbH
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

23
node_modules/@n8n/tournament/dist/Analysis.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import type { ExpressionAnalysis } from './ExpressionBuilder';
interface TmplOrTournament {
tmpl: boolean;
tournament: boolean;
}
interface TmplSame {
same: true;
expression?: SanitizedString;
}
interface TmplDiff {
same: false;
expression: SanitizedString | 'UNPARSEABLE';
has?: ExpressionAnalysis['has'];
parserError?: TmplOrTournament;
}
export type TmplDifference = TmplSame | TmplDiff;
export declare const getTmplDifference: (expr: string, dataNodeName: string) => TmplDifference;
export interface SanitizedString {
value: string;
sanitized: 'ACTUALLY_SANITIZED_DO_NOT_MANUALLY_MAKE_THIS_OBJECT';
}
export declare const stripIdentifyingInformation: (expr: string) => SanitizedString;
export {};

134
node_modules/@n8n/tournament/dist/Analysis.js generated vendored Normal file
View File

@@ -0,0 +1,134 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stripIdentifyingInformation = exports.getTmplDifference = void 0;
const tmpl = __importStar(require("@n8n_io/riot-tmpl"));
const recast_1 = require("recast");
const Differ_1 = require("./Differ");
const ExpressionBuilder_1 = require("./ExpressionBuilder");
const ExpressionSplitter_1 = require("./ExpressionSplitter");
const getTmplDifference = (expr, dataNodeName) => {
if (!expr) {
return { same: true };
}
if (tmpl.brackets.settings.brackets !== '{{ }}') {
tmpl.brackets.set('{{ }}');
}
let tournParsed;
let tmplParsed;
let analysis;
try {
[tournParsed, analysis] = (0, ExpressionBuilder_1.getExpressionCode)(expr, dataNodeName, { before: [], after: [] });
}
catch (e) {
tournParsed = null;
analysis = null;
}
try {
tmplParsed = tmpl.tmpl.getStr(expr);
}
catch (e) {
tmplParsed = null;
}
if ((analysis === null || analysis === void 0 ? void 0 : analysis.has.function) || (analysis === null || analysis === void 0 ? void 0 : analysis.has.templateString)) {
return {
same: false,
expression: (0, exports.stripIdentifyingInformation)(expr),
has: analysis.has,
};
}
if (tournParsed === null && tmplParsed === null) {
return { same: true };
}
else if (tournParsed === null) {
return {
same: false,
expression: 'UNPARSEABLE',
parserError: {
tmpl: false,
tournament: true,
},
};
}
else if (tmplParsed === null) {
return {
same: false,
expression: (0, exports.stripIdentifyingInformation)(expr),
parserError: {
tmpl: true,
tournament: false,
},
};
}
const different = (0, Differ_1.isDifferent)(tmplParsed, tournParsed);
if (different) {
return {
same: false,
expression: (0, exports.stripIdentifyingInformation)(expr),
};
}
return { same: true, expression: (0, exports.stripIdentifyingInformation)(expr) };
};
exports.getTmplDifference = getTmplDifference;
const CHAR_REPLACE = /\S/gu;
const replaceValue = (value) => {
return value.replace(CHAR_REPLACE, 'v');
};
const stripIdentifyingInformation = (expr) => {
const chunks = (0, ExpressionBuilder_1.getParsedExpression)(expr);
for (const chunk of chunks) {
if (chunk.type === 'text') {
chunk.text = replaceValue(chunk.text);
}
else {
(0, recast_1.visit)(chunk.parsed, {
visitLiteral(path) {
this.traverse(path);
if (typeof path.node.value === 'string') {
path.node.value = replaceValue(path.node.value);
}
},
visitStringLiteral(path) {
this.traverse(path);
path.node.value = replaceValue(path.node.value);
},
visitTemplateElement(path) {
this.traverse(path);
if (path.node.value.cooked !== null) {
path.node.value.cooked = replaceValue(path.node.value.cooked);
}
path.node.value.raw = replaceValue(path.node.value.raw);
},
});
chunk.text = (0, recast_1.print)(chunk.parsed).code;
}
}
return {
value: (0, ExpressionSplitter_1.joinExpression)(chunks),
sanitized: 'ACTUALLY_SANITIZED_DO_NOT_MANUALLY_MAKE_THIS_OBJECT',
};
};
exports.stripIdentifyingInformation = stripIdentifyingInformation;
//# sourceMappingURL=Analysis.js.map

1
node_modules/@n8n/tournament/dist/Analysis.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Analysis.js","sourceRoot":"","sources":["../src/Analysis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAC1C,mCAAsC;AACtC,qCAAuC;AAGvC,2DAA6E;AAC7E,6DAAsD;AAkB/C,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,YAAoB,EAAkB,EAAE;IACvF,IAAI,CAAC,IAAI,EAAE;QACV,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KACtB;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,KAAK,OAAO,EAAE;QAChD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAC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,CAAC,IAAI,CAAC,CAAC;oBACpB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACjD,CAAC;gBACD,oBAAoB,CAAC,IAAI;oBACxB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACpB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,IAAI,EAAE;wBACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;qBAC9D;oBACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACzD,CAAC;aACD,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,GAAG,IAAA,cAAK,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;SACtC;KACD;IAED,OAAO;QACN,KAAK,EAAE,IAAA,mCAAc,EAAC,MAAM,CAAC;QAC7B,SAAS,EAAE,qDAAqD;KAChE,CAAC;AACH,CAAC,CAAC;AAlCW,QAAA,2BAA2B,+BAkCtC"}

3
node_modules/@n8n/tournament/dist/Constants.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { CatchClauseKind, ExpressionKind, PatternKind, PropertyKind, StatementKind, VariableDeclaratorKind } from 'ast-types/lib/gen/kinds';
export declare const EXEMPT_IDENTIFIER_LIST: string[];
export type ParentKind = ExpressionKind | StatementKind | PropertyKind | PatternKind | VariableDeclaratorKind | CatchClauseKind;

13
node_modules/@n8n/tournament/dist/Constants.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EXEMPT_IDENTIFIER_LIST = void 0;
exports.EXEMPT_IDENTIFIER_LIST = [
'isFinite',
'isNaN',
'NaN',
'Date',
'RegExp',
'Math',
'undefined',
];
//# sourceMappingURL=Constants.js.map

1
node_modules/@n8n/tournament/dist/Constants.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";;;AASa,QAAA,sBAAsB,GAAG;IACrC,UAAU;IACV,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,MAAM;IACN,WAAW;CACX,CAAC"}

1
node_modules/@n8n/tournament/dist/Differ.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare const isDifferent: (tmpl: string, tourn: string) => boolean;

80
node_modules/@n8n/tournament/dist/Differ.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isDifferent = void 0;
const recast_1 = require("recast");
const Parser_1 = require("./Parser");
const isWrapped = (node) => {
var _a;
return ((_a = node.program.body[1]) === null || _a === void 0 ? void 0 : _a.type) === 'TryStatement';
};
const getWrapped = (node) => {
var _a;
return (_a = node.program.body[1]) === null || _a === void 0 ? void 0 : _a.block.body[0];
};
const isMultiPartExpression = (node) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
return (((_a = node.program.body[1]) === null || _a === void 0 ? void 0 : _a.type) === 'ReturnStatement' &&
((_b = node.program.body[1].argument) === null || _b === void 0 ? void 0 : _b.type) === 'CallExpression' &&
((_d = (_c = node.program.body[1].argument) === null || _c === void 0 ? void 0 : _c.arguments[0]) === null || _d === void 0 ? void 0 : _d.type) === 'Literal' &&
((_f = (_e = node.program.body[1].argument) === null || _e === void 0 ? void 0 : _e.arguments[0]) === null || _f === void 0 ? void 0 : _f.value) === '' &&
((_g = node.program.body[1].argument) === null || _g === void 0 ? void 0 : _g.callee.type) === 'MemberExpression' &&
((_h = node.program.body[1].argument) === null || _h === void 0 ? void 0 : _h.callee.object.type) === 'ArrayExpression' &&
((_j = node.program.body[1].argument) === null || _j === void 0 ? void 0 : _j.callee.property.type) === 'Identifier' &&
((_k = node.program.body[1].argument) === null || _k === void 0 ? void 0 : _k.callee.property.name) === 'join');
};
const getMultiPartExpression = (node) => {
var _a, _b, _c, _d, _e, _f, _g, _h;
if (!(((_a = node.program.body[1]) === null || _a === void 0 ? void 0 : _a.type) === 'ReturnStatement' &&
((_b = node.program.body[1].argument) === null || _b === void 0 ? void 0 : _b.type) === 'CallExpression' &&
((_d = (_c = node.program.body[1].argument) === null || _c === void 0 ? void 0 : _c.arguments[0]) === null || _d === void 0 ? void 0 : _d.type) === 'Literal' &&
((_f = (_e = node.program.body[1].argument) === null || _e === void 0 ? void 0 : _e.arguments[0]) === null || _f === void 0 ? void 0 : _f.value) === '' &&
((_g = node.program.body[1].argument) === null || _g === void 0 ? void 0 : _g.callee.type) === 'MemberExpression' &&
((_h = node.program.body[1].argument) === null || _h === void 0 ? void 0 : _h.callee.object.type) === 'ArrayExpression')) {
return [];
}
return node.program.body[1].argument.callee.object.elements
.map((e) => {
if ((e === null || e === void 0 ? void 0 : e.type) !== 'CallExpression' ||
e.callee.type !== 'MemberExpression' ||
e.callee.object.type !== 'FunctionExpression') {
return null;
}
const maybeExpr = e.callee.object.body.body[0];
if (maybeExpr.type !== 'TryStatement') {
return maybeExpr;
}
return maybeExpr.block.body[0];
})
.filter((e) => e !== null);
};
const isDifferent = (tmpl, tourn) => {
const tmplParsed = (0, recast_1.parse)(tmpl, {
parser: { parse: Parser_1.parseWithEsprimaNext },
});
const tournParsed = (0, recast_1.parse)(tourn, {
parser: { parse: Parser_1.parseWithEsprimaNext },
});
const problemPaths = [];
let same = recast_1.types.astNodesAreEquivalent(tmplParsed, tournParsed, problemPaths);
if (!same) {
if (isWrapped(tournParsed) && !isWrapped(tmplParsed)) {
const tournWrapped = getWrapped(tournParsed);
same = recast_1.types.astNodesAreEquivalent(tmplParsed.program.body[1], tournWrapped);
}
else if (isMultiPartExpression(tournParsed) && isMultiPartExpression(tmplParsed)) {
const tournExprs = getMultiPartExpression(tournParsed);
const tmplExprs = getMultiPartExpression(tmplParsed);
if (tournExprs.length === tmplExprs.length) {
for (let i = 0; i < tournExprs.length; i++) {
same = recast_1.types.astNodesAreEquivalent(tmplExprs[i], tournExprs[i], problemPaths);
if (!same) {
break;
}
}
}
}
}
return !same;
};
exports.isDifferent = isDifferent;
//# sourceMappingURL=Differ.js.map

1
node_modules/@n8n/tournament/dist/Differ.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Differ.js","sourceRoot":"","sources":["../src/Differ.ts"],"names":[],"mappings":";;;AACA,mCAAsC;AACtC,qCAAgD;AAEhD,MAAM,SAAS,GAAG,CAAC,IAA2B,EAAW,EAAE;;IAC1D,OAAO,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,MAAK,cAAc,CAAC;AACtD,CAAC,CAAC;AACF,MAAM,UAAU,GAAG,CAAC,IAA2B,EAAE,EAAE;;IAClD,OAAO,MAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAmC,0CAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,IAA2B,EAAW,EAAE;;IACtE,OAAO,CACN,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,MAAK,iBAAiB;QAChD,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,0CAAE,IAAI,MAAK,gBAAgB;QACxD,CAAA,MAAA,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,0CAAE,SAAS,CAAC,CAAC,CAAC,0CAAE,IAAI,MAAK,SAAS;QAC/D,CAAA,MAAA,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC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AAE,KAAK,EAAE,6BAAoB,EAAE;KACvC,CAA0B,CAAC;IAE5B,MAAM,YAAY,GAAU,EAAE,CAAC;IAC/B,IAAI,IAAI,GAAG,cAAK,CAAC,qBAAqB,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IAQ9E,IAAI,CAAC,IAAI,EAAE;QACV,IAAI,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;YAErD,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;YAC7C,IAAI,GAAG,cAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;SAC7E;aAAM,IAAI,qBAAqB,CAAC,WAAW,CAAC,IAAI,qBAAqB,CAAC,UAAU,CAAC,EAAE;YAEnF,MAAM,UAAU,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;YACvD,MAAM,SAAS,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;YACrD,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,EAAE;gBAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC3C,IAAI,GAAG,cAAK,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;oBAC9E,IAAI,CAAC,IAAI,EAAE;wBACV,MAAM;qBACN;iBACD;aACD;SACD;KACD;IAED,OAAO,CAAC,IAAI,CAAC;AACd,CAAC,CAAC;AAtCW,QAAA,WAAW,eAsCtB"}

7
node_modules/@n8n/tournament/dist/Evaluator.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import type { ReturnValue, Tournament } from '.';
export interface ExpressionEvaluator {
evaluate(code: string, data: unknown): ReturnValue;
}
export interface ExpressionEvaluatorClass {
new (instance: Tournament): ExpressionEvaluator;
}

3
node_modules/@n8n/tournament/dist/Evaluator.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Evaluator.js.map

1
node_modules/@n8n/tournament/dist/Evaluator.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Evaluator.js","sourceRoot":"","sources":["../src/Evaluator.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,15 @@
import type { types } from 'recast';
import type { ExpressionCode, ExpressionText } from './ExpressionSplitter';
import type { TournamentHooks } from './ast';
export interface ExpressionAnalysis {
has: {
function: boolean;
templateString: boolean;
};
}
type ParsedCode = ExpressionCode & {
parsed: types.namedTypes.File;
};
export declare const getParsedExpression: (expr: string) => Array<ExpressionText | ParsedCode>;
export declare const getExpressionCode: (expr: string, dataNodeName: string, hooks: TournamentHooks) => [string, ExpressionAnalysis];
export {};

186
node_modules/@n8n/tournament/dist/ExpressionBuilder.js generated vendored Normal file
View File

@@ -0,0 +1,186 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExpressionCode = exports.getParsedExpression = void 0;
const recast_1 = require("recast");
const ast_types_1 = require("ast-types");
const VariablePolyfill_1 = require("./VariablePolyfill");
const ExpressionSplitter_1 = require("./ExpressionSplitter");
const Parser_1 = require("./Parser");
const v = ast_types_1.builders.identifier('v');
const shouldAlwaysWrapList = ['window', 'global', 'this'];
const shouldWrapInTry = (node) => {
let shouldWrap = false;
(0, recast_1.visit)(node, {
visitMemberExpression() {
shouldWrap = true;
return false;
},
visitCallExpression() {
shouldWrap = true;
return false;
},
visitIdentifier(path) {
if (shouldAlwaysWrapList.includes(path.node.name)) {
shouldWrap = true;
return false;
}
this.traverse(path);
return;
},
});
return shouldWrap;
};
const hasFunction = (node) => {
let hasFn = false;
(0, recast_1.visit)(node, {
visitFunctionExpression() {
hasFn = true;
return false;
},
visitFunctionDeclaration() {
hasFn = true;
return false;
},
visitArrowFunctionExpression() {
hasFn = true;
return false;
},
});
return hasFn;
};
const hasTemplateString = (node) => {
let hasTemp = false;
(0, recast_1.visit)(node, {
visitTemplateLiteral(path) {
if (path.node.expressions.length) {
hasTemp = true;
return false;
}
this.traverse(path);
return;
},
});
return hasTemp;
};
const wrapInErrorHandler = (node) => {
return ast_types_1.builders.tryStatement(ast_types_1.builders.blockStatement([node]), ast_types_1.builders.catchClause(ast_types_1.builders.identifier('e'), null, ast_types_1.builders.blockStatement([
ast_types_1.builders.expressionStatement(ast_types_1.builders.callExpression(ast_types_1.builders.identifier('E'), [ast_types_1.builders.identifier('e'), ast_types_1.builders.thisExpression()])),
])));
};
const maybeWrapExpr = (expr) => {
if (expr.trimStart()[0] === '{') {
return '(' + expr + ')';
}
return expr;
};
const buildFunctionBody = (expr) => {
return ast_types_1.builders.blockStatement([
ast_types_1.builders.expressionStatement(ast_types_1.builders.assignmentExpression('=', v, expr)),
ast_types_1.builders.returnStatement(ast_types_1.builders.conditionalExpression(ast_types_1.builders.logicalExpression('||', ast_types_1.builders.logicalExpression('||', v, ast_types_1.builders.binaryExpression('===', v, ast_types_1.builders.literal(0))), ast_types_1.builders.binaryExpression('===', v, ast_types_1.builders.literal(false))), v, ast_types_1.builders.literal(''))),
]);
};
const fixStringNewLines = (node) => {
const replace = (str) => {
return str.replace(/\n/g, '\\n');
};
(0, recast_1.visit)(node, {
visitTemplateElement(path) {
this.traverse(path);
const el = ast_types_1.builders.templateElement({
cooked: path.node.value.cooked === null ? null : replace(path.node.value.cooked),
raw: replace(path.node.value.raw),
}, path.node.tail);
path.replace(el);
},
});
return node;
};
const getParsedExpression = (expr) => {
return (0, ExpressionSplitter_1.splitExpression)(expr).map((chunk) => {
if (chunk.type === 'code') {
const code = maybeWrapExpr(chunk.text);
const node = (0, recast_1.parse)(code, {
parser: { parse: Parser_1.parseWithEsprimaNext },
});
return { ...chunk, parsed: node };
}
return chunk;
});
};
exports.getParsedExpression = getParsedExpression;
const getExpressionCode = (expr, dataNodeName, hooks) => {
var _a, _b;
const chunks = (0, exports.getParsedExpression)(expr);
const newProg = ast_types_1.builders.program([
ast_types_1.builders.variableDeclaration('var', [ast_types_1.builders.variableDeclarator(VariablePolyfill_1.globalIdentifier, ast_types_1.builders.objectExpression([]))]),
]);
let dataNode = ast_types_1.builders.thisExpression();
const hasFn = chunks.filter((c) => c.type === 'code').some((c) => hasFunction(c.parsed));
if (hasFn) {
dataNode = ast_types_1.builders.identifier(dataNodeName);
newProg.body.push(ast_types_1.builders.variableDeclaration('var', [ast_types_1.builders.variableDeclarator(dataNode, ast_types_1.builders.thisExpression())]));
}
const hasTempString = chunks.filter((c) => c.type === 'code').some((c) => hasTemplateString(c.parsed));
if (chunks.length > 2 ||
chunks[0].text !== '' ||
(chunks[0].text === '' && chunks.length === 1)) {
let parts = [];
for (const chunk of chunks) {
if (chunk.type === 'text') {
parts.push(ast_types_1.builders.literal(chunk.text));
}
else {
const fixed = fixStringNewLines(chunk.parsed);
for (const hook of hooks.before) {
hook(fixed, dataNode);
}
const parsed = (_a = (0, VariablePolyfill_1.jsVariablePolyfill)(fixed, dataNode)) === null || _a === void 0 ? void 0 : _a[0];
if (!parsed || parsed.type !== 'ExpressionStatement') {
throw new SyntaxError('Not a expression statement');
}
for (const hook of hooks.after) {
hook(parsed, dataNode);
}
const functionBody = buildFunctionBody(parsed.expression);
if (shouldWrapInTry(parsed)) {
functionBody.body = [
wrapInErrorHandler(functionBody.body[0]),
ast_types_1.builders.expressionStatement(ast_types_1.builders.identifier('')),
functionBody.body[1],
];
}
parts.push(ast_types_1.builders.callExpression(ast_types_1.builders.memberExpression(ast_types_1.builders.functionExpression(null, [v], functionBody), ast_types_1.builders.identifier('call')), [ast_types_1.builders.thisExpression()]));
}
}
if (chunks.length < 2) {
newProg.body.push(ast_types_1.builders.returnStatement(parts[0]));
}
else {
parts = parts.filter((i) => !(i.type === 'Literal' && i.value === ''));
newProg.body.push(ast_types_1.builders.returnStatement(ast_types_1.builders.callExpression(ast_types_1.builders.memberExpression(ast_types_1.builders.arrayExpression(parts), ast_types_1.builders.identifier('join')), [
ast_types_1.builders.literal(''),
])));
}
}
else {
const fixed = fixStringNewLines(chunks[1].parsed);
for (const hook of hooks.before) {
hook(fixed, dataNode);
}
const parsed = (_b = (0, VariablePolyfill_1.jsVariablePolyfill)(fixed, dataNode)) === null || _b === void 0 ? void 0 : _b[0];
if (!parsed || parsed.type !== 'ExpressionStatement') {
throw new SyntaxError('Not a expression statement');
}
for (const hook of hooks.after) {
hook(parsed, dataNode);
}
let retData = ast_types_1.builders.returnStatement(parsed.expression);
if (shouldWrapInTry(parsed)) {
retData = wrapInErrorHandler(retData);
}
newProg.body.push(retData);
}
return [(0, recast_1.print)(newProg).code, { has: { function: hasFn, templateString: hasTempString } }];
};
exports.getExpressionCode = getExpressionCode;
//# sourceMappingURL=ExpressionBuilder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
export interface ExpressionText {
type: 'text';
text: string;
}
export interface ExpressionCode {
type: 'code';
text: string;
hasClosingBrackets: boolean;
}
export type ExpressionChunk = ExpressionCode | ExpressionText;
export declare const escapeCode: (text: string) => string;
export declare const splitExpression: (expression: string) => ExpressionChunk[];
export declare const joinExpression: (parts: ExpressionChunk[]) => string;

View File

@@ -0,0 +1,87 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.joinExpression = exports.splitExpression = exports.escapeCode = void 0;
const OPEN_BRACKET = /(?<brackets>\{\{)/;
const CLOSE_BRACKET = /(?<brackets>\}\})/;
const escapeCode = (text) => {
return text.replace('\\}}', '}}');
};
exports.escapeCode = escapeCode;
const normalizeBackslashes = (text) => {
return text.replace(/\\\\/g, '\\');
};
const splitExpression = (expression) => {
var _a, _b, _c;
const chunks = [];
let searchingFor = 'open';
let activeRegex = OPEN_BRACKET;
let buffer = '';
let index = 0;
while (index < expression.length) {
const expr = expression.slice(index);
const res = activeRegex.exec(expr);
if (!(res === null || res === void 0 ? void 0 : res.groups)) {
buffer += expr;
if (searchingFor === 'open') {
chunks.push({
type: 'text',
text: buffer,
});
}
else {
chunks.push({
type: 'code',
text: (0, exports.escapeCode)(buffer),
hasClosingBrackets: false,
});
}
break;
}
const beforeMatch = expr.slice(0, res.index);
const backslashCount = (_c = (_b = (_a = beforeMatch.match(/\\*$/)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
const isEscaped = backslashCount % 2 === 1;
if (isEscaped) {
buffer += expr.slice(0, res.index + '{{'.length);
index += res.index + '{{'.length;
}
else {
buffer += expr.slice(0, res.index);
if (searchingFor === 'open') {
chunks.push({
type: 'text',
text: normalizeBackslashes(buffer),
});
searchingFor = 'close';
activeRegex = CLOSE_BRACKET;
}
else {
chunks.push({
type: 'code',
text: (0, exports.escapeCode)(buffer),
hasClosingBrackets: true,
});
searchingFor = 'open';
activeRegex = OPEN_BRACKET;
}
index += res.index + 2;
buffer = '';
}
}
return chunks;
};
exports.splitExpression = splitExpression;
const escapeTmplExpression = (part) => {
return part.replace('}}', '\\}}');
};
const joinExpression = (parts) => {
return parts
.map((chunk) => {
if (chunk.type === 'code') {
return `{{${escapeTmplExpression(chunk.text)}${chunk.hasClosingBrackets ? '}}' : ''}`;
}
return chunk.text;
})
.join('');
};
exports.joinExpression = joinExpression;
//# sourceMappingURL=ExpressionSplitter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExpressionSplitter.js","sourceRoot":"","sources":["../src/ExpressionSplitter.ts"],"names":[],"mappings":";;;AAeA,MAAM,YAAY,GAAG,mBAAmB,CAAC;AACzC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAEnC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE;IAClD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEF,M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,OAAO,KAAK,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;SACtF;QACD,OAAO,KAAK,CAAC,IAAI,CAAC;IACnB,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC,CAAC;AATW,QAAA,cAAc,kBASzB"}

View File

@@ -0,0 +1,8 @@
import type { ExpressionEvaluator, ReturnValue, Tournament } from '.';
export declare class FunctionEvaluator implements ExpressionEvaluator {
private instance;
private _codeCache;
constructor(instance: Tournament);
private getFunction;
evaluate(expr: string, data: unknown): ReturnValue;
}

24
node_modules/@n8n/tournament/dist/FunctionEvaluator.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FunctionEvaluator = void 0;
class FunctionEvaluator {
constructor(instance) {
this.instance = instance;
this._codeCache = {};
}
getFunction(expr) {
if (expr in this._codeCache) {
return this._codeCache[expr];
}
const [code] = this.instance.getExpressionCode(expr);
const func = new Function('E', code + ';');
this._codeCache[expr] = func;
return func;
}
evaluate(expr, data) {
const fn = this.getFunction(expr);
return fn.call(data, this.instance.errorHandler);
}
}
exports.FunctionEvaluator = FunctionEvaluator;
//# sourceMappingURL=FunctionEvaluator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FunctionEvaluator.js","sourceRoot":"","sources":["../src/FunctionEvaluator.ts"],"names":[],"mappings":";;;AAEA,MAAa,iBAAiB;IAG7B,YAAoB,QAAoB;QAApB,aAAQ,GAAR,QAAQ,CAAY;QAFhC,eAAU,GAA6B,EAAE,CAAC;IAEP,CAAC;IAEpC,WAAW,CAAC,IAAY;QAC/B,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;YAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SAC7B;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,IAAI,GAAG,GAAG,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,QAAQ,CAAC,IAAY,EAAE,IAAa;QACnC,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;CACD;AAnBD,8CAmBC"}

1
node_modules/@n8n/tournament/dist/Parser.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function parseWithEsprimaNext(source: string, options?: any): any;

27
node_modules/@n8n/tournament/dist/Parser.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseWithEsprimaNext = void 0;
const esprima_next_1 = require("esprima-next");
const util_1 = require("recast/lib/util");
function parseWithEsprimaNext(source, options) {
try {
const ast = (0, esprima_next_1.parse)(source, {
loc: true,
locations: true,
comment: true,
range: (0, util_1.getOption)(options, 'range', false),
tolerant: (0, util_1.getOption)(options, 'tolerant', true),
tokens: true,
jsx: (0, util_1.getOption)(options, 'jsx', false),
sourceType: (0, util_1.getOption)(options, 'sourceType', 'module'),
});
return ast;
}
catch (error) {
if (error instanceof Error)
throw new SyntaxError(error.message);
throw error;
}
}
exports.parseWithEsprimaNext = parseWithEsprimaNext;
//# sourceMappingURL=Parser.js.map

1
node_modules/@n8n/tournament/dist/Parser.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../src/Parser.ts"],"names":[],"mappings":";;;AAAA,+CAAqD;AAErD,0CAA4C;AAE5C,SAAgB,oBAAoB,CAAC,MAAc,EAAE,OAAa;IACjE,IAAI;QACH,MAAM,GAAG,GAAG,IAAA,oBAAY,EAAC,MAAM,EAAE;YAChC,GAAG,EAAE,IAAI;YACT,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,IAAA,gBAAS,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAY;YACpD,QAAQ,EAAE,IAAA,gBAAS,EAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAY;YACzD,MAAM,EAAE,IAAI;YACZ,GAAG,EAAE,IAAA,gBAAS,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAY;YAChD,UAAU,EAAE,IAAA,gBAAS,EAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAW;SAC/C,CAAC,CAAC;QAEpB,OAAO,GAAG,CAAC;KACX;IAAC,OAAO,KAAK,EAAE;QACf,IAAI,KAAK,YAAY,KAAK;YAAE,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjE,MAAM,KAAK,CAAC;KACZ;AACF,CAAC;AAlBD,oDAkBC"}

View File

@@ -0,0 +1,6 @@
import type { types } from 'recast';
import type { StatementKind } from 'ast-types/lib/gen/kinds';
import type { namedTypes } from 'ast-types';
export declare const globalIdentifier: namedTypes.Identifier;
export type DataNode = namedTypes.ThisExpression | namedTypes.Identifier;
export declare const jsVariablePolyfill: (ast: types.namedTypes.File, dataNode: DataNode) => StatementKind[] | undefined;

253
node_modules/@n8n/tournament/dist/VariablePolyfill.js generated vendored Normal file
View File

@@ -0,0 +1,253 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.jsVariablePolyfill = exports.globalIdentifier = void 0;
const recast_1 = require("recast");
const ast_types_1 = require("ast-types");
const Constants_1 = require("./Constants");
function assertNever(value) {
return true;
}
exports.globalIdentifier = ast_types_1.builders.identifier(typeof window !== 'object' ? 'global' : 'window');
const buildGlobalSwitch = (node, dataNode) => {
return ast_types_1.builders.memberExpression(ast_types_1.builders.conditionalExpression(ast_types_1.builders.binaryExpression('in', ast_types_1.builders.literal(node.name), dataNode), dataNode, exports.globalIdentifier), ast_types_1.builders.identifier(node.name));
};
const isInScope = (path) => {
let scope = path.scope;
while (scope !== null) {
if (scope.declares(path.node.name)) {
return true;
}
scope = scope.parent;
}
return false;
};
const polyfillExceptions = ['this', 'window', 'global'];
const polyfillVar = (path, dataNode, force = false) => {
if (!force) {
if (isInScope(path)) {
return;
}
}
if (polyfillExceptions.includes(path.node.name)) {
return;
}
path.replace(buildGlobalSwitch(path.node, dataNode));
};
const customPatches = {
MemberExpression(path, parent, dataNode) {
if (parent.object === path.node || parent.computed) {
polyfillVar(path, dataNode);
}
},
OptionalMemberExpression(path, parent, dataNode) {
if (parent.object === path.node) {
polyfillVar(path, dataNode);
}
},
Property(path, parent, dataNode) {
var _a, _b, _c;
if (path.node !== parent.value) {
return;
}
const objPattern = (_b = (_a = path.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.node;
if (!objPattern) {
return;
}
const objParent = (_c = path.parent.parent.parent) === null || _c === void 0 ? void 0 : _c.node;
if (!objParent) {
return;
}
if (objParent.type === 'VariableDeclarator' && objParent.id === objPattern) {
return;
}
parent.shorthand = false;
polyfillVar(path, dataNode);
},
AssignmentPattern(path, parent, dataNode) {
if (parent.right === path.node) {
polyfillVar(path, dataNode);
}
},
VariableDeclarator(path, parent, dataNode) {
if (parent.init === path.node) {
polyfillVar(path, dataNode);
}
},
};
const jsVariablePolyfill = (ast, dataNode) => {
(0, recast_1.visit)(ast, {
visitImportExpression(_path) {
throw new Error('Imports are not supported');
},
visitIdentifier(path) {
this.traverse(path);
const parent = path.parent.node;
if (Constants_1.EXEMPT_IDENTIFIER_LIST.includes(path.node.name)) {
return;
}
switch (parent.type) {
case 'AssignmentPattern':
case 'Property':
case 'MemberExpression':
case 'OptionalMemberExpression':
case 'VariableDeclarator':
if (!customPatches[parent.type]) {
throw new Error(`Couldn\'t find custom patcher for parent type: ${parent.type}`);
}
customPatches[parent.type](path, parent, dataNode);
break;
case 'BinaryExpression':
case 'UnaryExpression':
case 'ArrayExpression':
case 'AssignmentExpression':
case 'SequenceExpression':
case 'YieldExpression':
case 'UpdateExpression':
case 'LogicalExpression':
case 'ConditionalExpression':
case 'NewExpression':
case 'CallExpression':
case 'OptionalCallExpression':
case 'TaggedTemplateExpression':
case 'TemplateLiteral':
case 'AwaitExpression':
case 'ImportExpression':
case 'ForStatement':
case 'IfStatement':
case 'WhileStatement':
case 'ForInStatement':
case 'ForOfStatement':
case 'SwitchStatement':
case 'ReturnStatement':
case 'DoWhileStatement':
case 'ExpressionStatement':
case 'ForAwaitStatement':
case 'ThrowStatement':
case 'WithStatement':
case 'TupleExpression':
polyfillVar(path, dataNode);
break;
case 'Super':
case 'Identifier':
case 'ArrowFunctionExpression':
case 'FunctionDeclaration':
case 'FunctionExpression':
case 'ThisExpression':
case 'ObjectExpression':
case 'MetaProperty':
case 'ChainExpression':
case 'PrivateName':
case 'ParenthesizedExpression':
case 'Import':
case 'VariableDeclaration':
case 'CatchClause':
case 'BlockStatement':
case 'TryStatement':
case 'EmptyStatement':
case 'LabeledStatement':
case 'BreakStatement':
case 'ContinueStatement':
case 'DebuggerStatement':
case 'ImportDeclaration':
case 'ExportDeclaration':
case 'ExportAllDeclaration':
case 'ExportDefaultDeclaration':
case 'Noop':
case 'ClassMethod':
case 'ClassPrivateMethod':
case 'RestElement':
case 'ArrayPattern':
case 'ObjectPattern':
case 'ClassExpression':
case 'RecordExpression':
case 'V8IntrinsicIdentifier':
case 'TopicReference':
case 'MethodDefinition':
case 'ClassDeclaration':
case 'ClassProperty':
case 'StaticBlock':
case 'ClassBody':
case 'ExportNamedDeclaration':
case 'ClassPrivateProperty':
case 'ClassAccessorProperty':
case 'PropertyPattern':
break;
case 'SpreadElementPattern':
case 'SpreadPropertyPattern':
case 'ClassPropertyDefinition':
break;
case 'DeclareClass':
case 'DeclareModule':
case 'DeclareVariable':
case 'DeclareFunction':
case 'DeclareInterface':
case 'DeclareTypeAlias':
case 'DeclareOpaqueType':
case 'DeclareModuleExports':
case 'DeclareExportDeclaration':
case 'DeclareExportAllDeclaration':
case 'InterfaceDeclaration':
case 'TypeAlias':
case 'OpaqueType':
case 'EnumDeclaration':
case 'TypeCastExpression':
break;
case 'TSAsExpression':
case 'TSTypeParameter':
case 'TSTypeAssertion':
case 'TSDeclareMethod':
case 'TSIndexSignature':
case 'TSDeclareFunction':
case 'TSMethodSignature':
case 'TSEnumDeclaration':
case 'TSExportAssignment':
case 'TSNonNullExpression':
case 'TSPropertySignature':
case 'TSModuleDeclaration':
case 'TSParameterProperty':
case 'TSTypeCastExpression':
case 'TSSatisfiesExpression':
case 'TSTypeAliasDeclaration':
case 'TSInterfaceDeclaration':
case 'TSImportEqualsDeclaration':
case 'TSExternalModuleReference':
case 'TSInstantiationExpression':
case 'TSTypeParameterDeclaration':
case 'TSCallSignatureDeclaration':
case 'TSNamespaceExportDeclaration':
case 'TSConstructSignatureDeclaration':
break;
case 'DirectiveLiteral':
case 'StringLiteral':
case 'NumericLiteral':
case 'BigIntLiteral':
case 'NullLiteral':
case 'Literal':
case 'RegExpLiteral':
case 'BooleanLiteral':
case 'DecimalLiteral':
break;
case 'DoExpression':
case 'BindExpression':
break;
case 'JSXIdentifier':
case 'JSXText':
case 'JSXElement':
case 'JSXFragment':
case 'JSXMemberExpression':
case 'JSXExpressionContainer':
break;
case 'ComprehensionExpression':
case 'GeneratorExpression':
polyfillVar(path, dataNode);
break;
default:
assertNever(parent);
break;
}
},
});
return ast.program.body;
};
exports.jsVariablePolyfill = jsVariablePolyfill;
//# sourceMappingURL=VariablePolyfill.js.map

File diff suppressed because one or more lines are too long

11
node_modules/@n8n/tournament/dist/ast.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export type { types as astTypes } from 'recast';
export { visit as astVisit } from 'recast';
export { builders as astBuilders, type namedTypes as astNamedTypes } from 'ast-types';
import type { types } from 'recast';
import type { namedTypes } from 'ast-types';
export interface TournamentHooks {
before: ASTBeforeHook[];
after: ASTAfterHook[];
}
export type ASTAfterHook = (ast: namedTypes.ExpressionStatement, dataNode: namedTypes.ThisExpression | namedTypes.Identifier) => void;
export type ASTBeforeHook = (ast: types.namedTypes.File, dataNode: namedTypes.ThisExpression | namedTypes.Identifier) => void;

8
node_modules/@n8n/tournament/dist/ast.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.astBuilders = exports.astVisit = void 0;
var recast_1 = require("recast");
Object.defineProperty(exports, "astVisit", { enumerable: true, get: function () { return recast_1.visit; } });
var ast_types_1 = require("ast-types");
Object.defineProperty(exports, "astBuilders", { enumerable: true, get: function () { return ast_types_1.builders; } });
//# sourceMappingURL=ast.js.map

1
node_modules/@n8n/tournament/dist/ast.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":";;;AACA,iCAA2C;AAAlC,kGAAA,KAAK,OAAY;AAC1B,uCAAsF;AAA7E,wGAAA,QAAQ,OAAe"}

1
node_modules/@n8n/tournament/dist/build.tsbuildinfo generated vendored Normal file

File diff suppressed because one or more lines are too long

18
node_modules/@n8n/tournament/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import type { ExpressionAnalysis } from './ExpressionBuilder';
import type { ExpressionEvaluatorClass } from './Evaluator';
import type { TournamentHooks } from './ast';
export type { TmplDifference } from './Analysis';
export type { ExpressionEvaluator, ExpressionEvaluatorClass } from './Evaluator';
export * from './ast';
export type ReturnValue = string | null | (() => unknown);
export declare class Tournament {
errorHandler: (error: Error) => void;
private _dataNodeName;
private readonly astHooks;
private evaluator;
constructor(errorHandler?: (error: Error) => void, _dataNodeName?: string, Evaluator?: ExpressionEvaluatorClass, astHooks?: TournamentHooks);
setEvaluator(Evaluator: ExpressionEvaluatorClass): void;
getExpressionCode(expr: string): [string, ExpressionAnalysis];
tmplDiff(expr: string): import("./Analysis").TmplDifference;
execute(expr: string, data: unknown): ReturnValue;
}

47
node_modules/@n8n/tournament/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tournament = void 0;
const ExpressionBuilder_1 = require("./ExpressionBuilder");
const Analysis_1 = require("./Analysis");
const FunctionEvaluator_1 = require("./FunctionEvaluator");
__exportStar(require("./ast"), exports);
const DATA_NODE_NAME = '___n8n_data';
class Tournament {
constructor(errorHandler = () => { }, _dataNodeName = DATA_NODE_NAME, Evaluator = FunctionEvaluator_1.FunctionEvaluator, astHooks = { before: [], after: [] }) {
this.errorHandler = errorHandler;
this._dataNodeName = _dataNodeName;
this.astHooks = astHooks;
this.setEvaluator(Evaluator);
}
setEvaluator(Evaluator) {
this.evaluator = new Evaluator(this);
}
getExpressionCode(expr) {
return (0, ExpressionBuilder_1.getExpressionCode)(expr, this._dataNodeName, this.astHooks);
}
tmplDiff(expr) {
return (0, Analysis_1.getTmplDifference)(expr, this._dataNodeName);
}
execute(expr, data) {
if (!expr) {
return expr;
}
return this.evaluator.evaluate(expr, data);
}
}
exports.Tournament = Tournament;
//# sourceMappingURL=index.js.map

1
node_modules/@n8n/tournament/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAwD;AAExD,yCAA+C;AAE/C,2DAAwD;AAKxD,wCAAsB;AAEtB,MAAM,cAAc,GAAG,aAAa,CAAC;AAGrC,MAAa,UAAU;IAGtB,YACQ,eAAuC,GAAG,EAAE,GAAE,CAAC,EAC9C,gBAAwB,cAAc,EAC9C,YAAsC,qCAAiB,EACtC,WAA4B,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAH/D,iBAAY,GAAZ,YAAY,CAAmC;QAC9C,kBAAa,GAAb,aAAa,CAAyB;QAE7B,aAAQ,GAAR,QAAQ,CAA6C;QAEtE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED,YAAY,CAAC,SAAmC;QAC/C,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,iBAAiB,CAAC,IAAY;QAC7B,OAAO,IAAA,qCAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnE,CAAC;IAED,QAAQ,CAAC,IAAY;QACpB,OAAO,IAAA,4BAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,CAAC,IAAY,EAAE,IAAa;QAGlC,IAAI,CAAC,IAAI,EAAE;YACV,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;CACD;AAhCD,gCAgCC"}

View File

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

View File

@@ -0,0 +1,512 @@
# AST Types ![CI](https://github.com/benjamn/ast-types/workflows/CI/badge.svg)
This module provides an efficient, modular,
[Esprima](https://github.com/ariya/esprima)-compatible implementation of
the [abstract syntax
tree](http://en.wikipedia.org/wiki/Abstract_syntax_tree) type hierarchy
pioneered by the [Mozilla Parser
API](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API).
Installation
---
From NPM:
npm install ast-types
From GitHub:
cd path/to/node_modules
git clone git://github.com/benjamn/ast-types.git
cd ast-types
npm install .
Basic Usage
---
```js
import assert from "assert";
import {
namedTypes as n,
builders as b,
} from "ast-types";
var fooId = b.identifier("foo");
var ifFoo = b.ifStatement(fooId, b.blockStatement([
b.expressionStatement(b.callExpression(fooId, []))
]));
assert.ok(n.IfStatement.check(ifFoo));
assert.ok(n.Statement.check(ifFoo));
assert.ok(n.Node.check(ifFoo));
assert.ok(n.BlockStatement.check(ifFoo.consequent));
assert.strictEqual(
ifFoo.consequent.body[0].expression.arguments.length,
0,
);
assert.strictEqual(ifFoo.test, fooId);
assert.ok(n.Expression.check(ifFoo.test));
assert.ok(n.Identifier.check(ifFoo.test));
assert.ok(!n.Statement.check(ifFoo.test));
```
AST Traversal
---
Because it understands the AST type system so thoroughly, this library
is able to provide excellent node iteration and traversal mechanisms.
If you want complete control over the traversal, and all you need is a way
of enumerating the known fields of your AST nodes and getting their
values, you may be interested in the primitives `getFieldNames` and
`getFieldValue`:
```js
import {
getFieldNames,
getFieldValue,
} from "ast-types";
const partialFunExpr = { type: "FunctionExpression" };
// Even though partialFunExpr doesn't actually contain all the fields that
// are expected for a FunctionExpression, types.getFieldNames knows:
console.log(getFieldNames(partialFunExpr));
// [ 'type', 'id', 'params', 'body', 'generator', 'expression',
// 'defaults', 'rest', 'async' ]
// For fields that have default values, types.getFieldValue will return
// the default if the field is not actually defined.
console.log(getFieldValue(partialFunExpr, "generator"));
// false
```
Two more low-level helper functions, `eachField` and `someField`, are
defined in terms of `getFieldNames` and `getFieldValue`:
```js
// Iterate over all defined fields of an object, including those missing
// or undefined, passing each field name and effective value (as returned
// by getFieldValue) to the callback. If the object has no corresponding
// Def, the callback will never be called.
export function eachField(object, callback, context) {
getFieldNames(object).forEach(function(name) {
callback.call(this, name, getFieldValue(object, name));
}, context);
}
// Similar to eachField, except that iteration stops as soon as the
// callback returns a truthy value. Like Array.prototype.some, the final
// result is either true or false to indicates whether the callback
// returned true for any element or not.
export function someField(object, callback, context) {
return getFieldNames(object).some(function(name) {
return callback.call(this, name, getFieldValue(object, name));
}, context);
}
```
So here's how you might make a copy of an AST node:
```js
import { eachField } from "ast-types";
const copy = {};
eachField(node, function(name, value) {
// Note that undefined fields will be visited too, according to
// the rules associated with node.type, and default field values
// will be substituted if appropriate.
copy[name] = value;
})
```
But that's not all! You can also easily visit entire syntax trees using
the powerful `types.visit` abstraction.
Here's a trivial example of how you might assert that `arguments.callee`
is never used in `ast`:
```js
import assert from "assert";
import {
visit,
namedTypes as n,
} from "ast-types";
visit(ast, {
// This method will be called for any node with .type "MemberExpression":
visitMemberExpression(path) {
// Visitor methods receive a single argument, a NodePath object
// wrapping the node of interest.
var node = path.node;
if (
n.Identifier.check(node.object) &&
node.object.name === "arguments" &&
n.Identifier.check(node.property)
) {
assert.notStrictEqual(node.property.name, "callee");
}
// It's your responsibility to call this.traverse with some
// NodePath object (usually the one passed into the visitor
// method) before the visitor method returns, or return false to
// indicate that the traversal need not continue any further down
// this subtree.
this.traverse(path);
}
});
```
Here's a slightly more involved example of transforming `...rest`
parameters into browser-runnable ES5 JavaScript:
```js
import { builders as b, visit } from "ast-types";
// Reuse the same AST structure for Array.prototype.slice.call.
var sliceExpr = b.memberExpression(
b.memberExpression(
b.memberExpression(
b.identifier("Array"),
b.identifier("prototype"),
false
),
b.identifier("slice"),
false
),
b.identifier("call"),
false
);
visit(ast, {
// This method will be called for any node whose type is a subtype of
// Function (e.g., FunctionDeclaration, FunctionExpression, and
// ArrowFunctionExpression). Note that types.visit precomputes a
// lookup table from every known type to the appropriate visitor
// method to call for nodes of that type, so the dispatch takes
// constant time.
visitFunction(path) {
// Visitor methods receive a single argument, a NodePath object
// wrapping the node of interest.
const node = path.node;
// It's your responsibility to call this.traverse with some
// NodePath object (usually the one passed into the visitor
// method) before the visitor method returns, or return false to
// indicate that the traversal need not continue any further down
// this subtree. An assertion will fail if you forget, which is
// awesome, because it means you will never again make the
// disastrous mistake of forgetting to traverse a subtree. Also
// cool: because you can call this method at any point in the
// visitor method, it's up to you whether your traversal is
// pre-order, post-order, or both!
this.traverse(path);
// This traversal is only concerned with Function nodes that have
// rest parameters.
if (!node.rest) {
return;
}
// For the purposes of this example, we won't worry about functions
// with Expression bodies.
n.BlockStatement.assert(node.body);
// Use types.builders to build a variable declaration of the form
//
// var rest = Array.prototype.slice.call(arguments, n);
//
// where `rest` is the name of the rest parameter, and `n` is a
// numeric literal specifying the number of named parameters the
// function takes.
const restVarDecl = b.variableDeclaration("var", [
b.variableDeclarator(
node.rest,
b.callExpression(sliceExpr, [
b.identifier("arguments"),
b.literal(node.params.length)
])
)
]);
// Similar to doing node.body.body.unshift(restVarDecl), except
// that the other NodePath objects wrapping body statements will
// have their indexes updated to accommodate the new statement.
path.get("body", "body").unshift(restVarDecl);
// Nullify node.rest now that we have simulated the behavior of
// the rest parameter using ordinary JavaScript.
path.get("rest").replace(null);
// There's nothing wrong with doing node.rest = null, but I wanted
// to point out that the above statement has the same effect.
assert.strictEqual(node.rest, null);
}
});
```
Here's how you might use `types.visit` to implement a function that
determines if a given function node refers to `this`:
```js
function usesThis(funcNode) {
n.Function.assert(funcNode);
var result = false;
visit(funcNode, {
visitThisExpression(path) {
result = true;
// The quickest way to terminate the traversal is to call
// this.abort(), which throws a special exception (instanceof
// this.AbortRequest) that will be caught in the top-level
// types.visit method, so you don't have to worry about
// catching the exception yourself.
this.abort();
},
visitFunction(path) {
// ThisExpression nodes in nested scopes don't count as `this`
// references for the original function node, so we can safely
// avoid traversing this subtree.
return false;
},
visitCallExpression(path) {
const node = path.node;
// If the function contains CallExpression nodes involving
// super, those expressions will implicitly depend on the
// value of `this`, even though they do not explicitly contain
// any ThisExpression nodes.
if (this.isSuperCallExpression(node)) {
result = true;
this.abort(); // Throws AbortRequest exception.
}
this.traverse(path);
},
// Yes, you can define arbitrary helper methods.
isSuperCallExpression(callExpr) {
n.CallExpression.assert(callExpr);
return this.isSuperIdentifier(callExpr.callee)
|| this.isSuperMemberExpression(callExpr.callee);
},
// And even helper helper methods!
isSuperIdentifier(node) {
return n.Identifier.check(node.callee)
&& node.callee.name === "super";
},
isSuperMemberExpression(node) {
return n.MemberExpression.check(node.callee)
&& n.Identifier.check(node.callee.object)
&& node.callee.object.name === "super";
}
});
return result;
}
```
As you might guess, when an `AbortRequest` is thrown from a subtree, the
exception will propagate from the corresponding calls to `this.traverse`
in the ancestor visitor methods. If you decide you want to cancel the
request, simply catch the exception and call its `.cancel()` method. The
rest of the subtree beneath the `try`-`catch` block will be abandoned, but
the remaining siblings of the ancestor node will still be visited.
NodePath
---
The `NodePath` object passed to visitor methods is a wrapper around an AST
node, and it serves to provide access to the chain of ancestor objects
(all the way back to the root of the AST) and scope information.
In general, `path.node` refers to the wrapped node, `path.parent.node`
refers to the nearest `Node` ancestor, `path.parent.parent.node` to the
grandparent, and so on.
Note that `path.node` may not be a direct property value of
`path.parent.node`; for instance, it might be the case that `path.node` is
an element of an array that is a direct child of the parent node:
```js
path.node === path.parent.node.elements[3]
```
in which case you should know that `path.parentPath` provides
finer-grained access to the complete path of objects (not just the `Node`
ones) from the root of the AST:
```js
// In reality, path.parent is the grandparent of path:
path.parentPath.parentPath === path.parent
// The path.parentPath object wraps the elements array (note that we use
// .value because the elements array is not a Node):
path.parentPath.value === path.parent.node.elements
// The path.node object is the fourth element in that array:
path.parentPath.value[3] === path.node
// Unlike path.node and path.value, which are synonyms because path.node
// is a Node object, path.parentPath.node is distinct from
// path.parentPath.value, because the elements array is not a
// Node. Instead, path.parentPath.node refers to the closest ancestor
// Node, which happens to be the same as path.parent.node:
path.parentPath.node === path.parent.node
// The path is named for its index in the elements array:
path.name === 3
// Likewise, path.parentPath is named for the property by which
// path.parent.node refers to it:
path.parentPath.name === "elements"
// Putting it all together, we can follow the chain of object references
// from path.parent.node all the way to path.node by accessing each
// property by name:
path.parent.node[path.parentPath.name][path.name] === path.node
```
These `NodePath` objects are created during the traversal without
modifying the AST nodes themselves, so it's not a problem if the same node
appears more than once in the AST (like `Array.prototype.slice.call` in
the example above), because it will be visited with a distict `NodePath`
each time it appears.
Child `NodePath` objects are created lazily, by calling the `.get` method
of a parent `NodePath` object:
```js
// If a NodePath object for the elements array has never been created
// before, it will be created here and cached in the future:
path.get("elements").get(3).value === path.value.elements[3]
// Alternatively, you can pass multiple property names to .get instead of
// chaining multiple .get calls:
path.get("elements", 0).value === path.value.elements[0]
```
`NodePath` objects support a number of useful methods:
```js
// Replace one node with another node:
var fifth = path.get("elements", 4);
fifth.replace(newNode);
// Now do some stuff that might rearrange the list, and this replacement
// remains safe:
fifth.replace(newerNode);
// Replace the third element in an array with two new nodes:
path.get("elements", 2).replace(
b.identifier("foo"),
b.thisExpression()
);
// Remove a node and its parent if it would leave a redundant AST node:
//e.g. var t = 1, y =2; removing the `t` and `y` declarators results in `var undefined`.
path.prune(); //returns the closest parent `NodePath`.
// Remove a node from a list of nodes:
path.get("elements", 3).replace();
// Add three new nodes to the beginning of a list of nodes:
path.get("elements").unshift(a, b, c);
// Remove and return the first node in a list of nodes:
path.get("elements").shift();
// Push two new nodes onto the end of a list of nodes:
path.get("elements").push(d, e);
// Remove and return the last node in a list of nodes:
path.get("elements").pop();
// Insert a new node before/after the seventh node in a list of nodes:
var seventh = path.get("elements", 6);
seventh.insertBefore(newNode);
seventh.insertAfter(newNode);
// Insert a new element at index 5 in a list of nodes:
path.get("elements").insertAt(5, newNode);
```
Scope
---
The object exposed as `path.scope` during AST traversals provides
information about variable and function declarations in the scope that
contains `path.node`. See [scope.ts](lib/scope.ts) for its public
interface, which currently includes `.isGlobal`, `.getGlobalScope()`,
`.depth`, `.declares(name)`, `.lookup(name)`, and `.getBindings()`.
Custom AST Node Types
---
The `ast-types` module was designed to be extended. To that end, it
provides a readable, declarative syntax for specifying new AST node types,
based primarily upon the `require("ast-types").Type.def` function:
```js
import {
Type,
builtInTypes,
builders as b,
finalize,
} from "ast-types";
const { def } = Type;
const { string } = builtInTypes;
// Suppose you need a named File type to wrap your Programs.
def("File")
.bases("Node")
.build("name", "program")
.field("name", string)
.field("program", def("Program"));
// Prevent further modifications to the File type (and any other
// types newly introduced by def(...)).
finalize();
// The b.file builder function is now available. It expects two
// arguments, as named by .build("name", "program") above.
const main = b.file("main.js", b.program([
// Pointless program contents included for extra color.
b.functionDeclaration(b.identifier("succ"), [
b.identifier("x")
], b.blockStatement([
b.returnStatement(
b.binaryExpression(
"+", b.identifier("x"), b.literal(1)
)
)
]))
]));
assert.strictEqual(main.name, "main.js");
assert.strictEqual(main.program.body[0].params[0].name, "x");
// etc.
// If you pass the wrong type of arguments, or fail to pass enough
// arguments, an AssertionError will be thrown.
b.file(b.blockStatement([]));
// ==> AssertionError: {"body":[],"type":"BlockStatement","loc":null} does not match type string
b.file("lib/types.js", b.thisExpression());
// ==> AssertionError: {"type":"ThisExpression","loc":null} does not match type Program
```
The `def` syntax is used to define all the default AST node types found in
[babel-core.ts](def/babel-core.ts),
[babel.ts](def/babel.ts),
[core.ts](def/core.ts),
[es-proposals.ts](def/es-proposals.ts),
[es6.ts](def/es6.ts),
[es7.ts](def/es7.ts),
[es2020.ts](def/es2020.ts),
[esprima.ts](def/esprima.ts),
[flow.ts](def/flow.ts),
[jsx.ts](def/jsx.ts),
[type-annotations.ts](def/type-annotations.ts),
and
[typescript.ts](def/typescript.ts),
so you have
no shortage of examples to learn from.

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,241 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es_proposals_1 = tslib_1.__importDefault(require("./es-proposals"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
var _a, _b, _c, _d, _e;
fork.use(es_proposals_1.default);
var types = fork.use(types_1.default);
var defaults = fork.use(shared_1.default).defaults;
var def = types.Type.def;
var or = types.Type.or;
var isUndefined = types.builtInTypes.undefined;
def("Noop")
.bases("Statement")
.build();
def("DoExpression")
.bases("Expression")
.build("body")
.field("body", [def("Statement")]);
def("BindExpression")
.bases("Expression")
.build("object", "callee")
.field("object", or(def("Expression"), null))
.field("callee", def("Expression"));
def("ParenthesizedExpression")
.bases("Expression")
.build("expression")
.field("expression", def("Expression"));
def("ExportNamespaceSpecifier")
.bases("Specifier")
.build("exported")
.field("exported", def("Identifier"));
def("ExportDefaultSpecifier")
.bases("Specifier")
.build("exported")
.field("exported", def("Identifier"));
def("CommentBlock")
.bases("Comment")
.build("value", /*optional:*/ "leading", "trailing");
def("CommentLine")
.bases("Comment")
.build("value", /*optional:*/ "leading", "trailing");
def("Directive")
.bases("Node")
.build("value")
.field("value", def("DirectiveLiteral"));
def("DirectiveLiteral")
.bases("Node", "Expression")
.build("value")
.field("value", String, defaults["use strict"]);
def("InterpreterDirective")
.bases("Node")
.build("value")
.field("value", String);
def("BlockStatement")
.bases("Statement")
.build("body")
.field("body", [def("Statement")])
.field("directives", [def("Directive")], defaults.emptyArray);
def("Program")
.bases("Node")
.build("body")
.field("body", [def("Statement")])
.field("directives", [def("Directive")], defaults.emptyArray)
.field("interpreter", or(def("InterpreterDirective"), null), defaults["null"]);
function makeLiteralExtra(rawValueType, toRaw) {
if (rawValueType === void 0) { rawValueType = String; }
return [
"extra",
{
rawValue: rawValueType,
raw: String,
},
function getDefault() {
var value = types.getFieldValue(this, "value");
return {
rawValue: value,
raw: toRaw ? toRaw(value) : String(value),
};
},
];
}
// Split Literal
(_a = def("StringLiteral")
.bases("Literal")
.build("value")
.field("value", String))
.field.apply(_a, makeLiteralExtra(String, function (val) { return JSON.stringify(val); }));
(_b = def("NumericLiteral")
.bases("Literal")
.build("value")
.field("value", Number)
.field("raw", or(String, null), defaults["null"]))
.field.apply(_b, makeLiteralExtra(Number));
(_c = def("BigIntLiteral")
.bases("Literal")
.build("value")
// Only String really seems appropriate here, since BigInt values
// often exceed the limits of JS numbers.
.field("value", or(String, Number)))
.field.apply(_c, makeLiteralExtra(String, function (val) { return val + "n"; }));
// https://github.com/tc39/proposal-decimal
// https://github.com/babel/babel/pull/11640
(_d = def("DecimalLiteral")
.bases("Literal")
.build("value")
.field("value", String))
.field.apply(_d, makeLiteralExtra(String, function (val) { return val + "m"; }));
def("NullLiteral")
.bases("Literal")
.build()
.field("value", null, defaults["null"]);
def("BooleanLiteral")
.bases("Literal")
.build("value")
.field("value", Boolean);
(_e = def("RegExpLiteral")
.bases("Literal")
.build("pattern", "flags")
.field("pattern", String)
.field("flags", String)
.field("value", RegExp, function () {
return new RegExp(this.pattern, this.flags);
}))
.field.apply(_e, makeLiteralExtra(or(RegExp, isUndefined), function (exp) { return "/".concat(exp.pattern, "/").concat(exp.flags || ""); })).field("regex", {
pattern: String,
flags: String
}, function () {
return {
pattern: this.pattern,
flags: this.flags,
};
});
var ObjectExpressionProperty = or(def("Property"), def("ObjectMethod"), def("ObjectProperty"), def("SpreadProperty"), def("SpreadElement"));
// Split Property -> ObjectProperty and ObjectMethod
def("ObjectExpression")
.bases("Expression")
.build("properties")
.field("properties", [ObjectExpressionProperty]);
// ObjectMethod hoist .value properties to own properties
def("ObjectMethod")
.bases("Node", "Function")
.build("kind", "key", "params", "body", "computed")
.field("kind", or("method", "get", "set"))
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
.field("params", [def("Pattern")])
.field("body", def("BlockStatement"))
.field("computed", Boolean, defaults["false"])
.field("generator", Boolean, defaults["false"])
.field("async", Boolean, defaults["false"])
.field("accessibility", // TypeScript
or(def("Literal"), null), defaults["null"])
.field("decorators", or([def("Decorator")], null), defaults["null"]);
def("ObjectProperty")
.bases("Node")
.build("key", "value")
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
.field("value", or(def("Expression"), def("Pattern")))
.field("accessibility", // TypeScript
or(def("Literal"), null), defaults["null"])
.field("computed", Boolean, defaults["false"]);
var ClassBodyElement = or(def("MethodDefinition"), def("VariableDeclarator"), def("ClassPropertyDefinition"), def("ClassProperty"), def("ClassPrivateProperty"), def("ClassMethod"), def("ClassPrivateMethod"), def("ClassAccessorProperty"), def("StaticBlock"));
// MethodDefinition -> ClassMethod
def("ClassBody")
.bases("Declaration")
.build("body")
.field("body", [ClassBodyElement]);
def("ClassMethod")
.bases("Declaration", "Function")
.build("kind", "key", "params", "body", "computed", "static")
.field("key", or(def("Literal"), def("Identifier"), def("Expression")));
def("ClassPrivateMethod")
.bases("Declaration", "Function")
.build("key", "params", "body", "kind", "computed", "static")
.field("key", def("PrivateName"));
def("ClassAccessorProperty")
.bases("Declaration")
.build("key", "value", "decorators", "computed", "static")
.field("key", or(def("Literal"), def("Identifier"), def("PrivateName"),
// Only when .computed is true (TODO enforce this)
def("Expression")))
.field("value", or(def("Expression"), null), defaults["null"]);
["ClassMethod",
"ClassPrivateMethod",
].forEach(function (typeName) {
def(typeName)
.field("kind", or("get", "set", "method", "constructor"), function () { return "method"; })
.field("body", def("BlockStatement"))
// For backwards compatibility only. Expect accessibility instead (see below).
.field("access", or("public", "private", "protected", null), defaults["null"]);
});
["ClassMethod",
"ClassPrivateMethod",
"ClassAccessorProperty",
].forEach(function (typeName) {
def(typeName)
.field("computed", Boolean, defaults["false"])
.field("static", Boolean, defaults["false"])
.field("abstract", Boolean, defaults["false"])
.field("accessibility", or("public", "private", "protected", null), defaults["null"])
.field("decorators", or([def("Decorator")], null), defaults["null"])
.field("definite", Boolean, defaults["false"])
.field("optional", Boolean, defaults["false"])
.field("override", Boolean, defaults["false"])
.field("readonly", Boolean, defaults["false"]);
});
var ObjectPatternProperty = or(def("Property"), def("PropertyPattern"), def("SpreadPropertyPattern"), def("SpreadProperty"), // Used by Esprima
def("ObjectProperty"), // Babel 6
def("RestProperty"), // Babel 6
def("RestElement"));
// Split into RestProperty and SpreadProperty
def("ObjectPattern")
.bases("Pattern")
.build("properties")
.field("properties", [ObjectPatternProperty])
.field("decorators", or([def("Decorator")], null), defaults["null"]);
def("SpreadProperty")
.bases("Node")
.build("argument")
.field("argument", def("Expression"));
def("RestProperty")
.bases("Node")
.build("argument")
.field("argument", def("Expression"));
def("ForAwaitStatement")
.bases("Statement")
.build("left", "right", "body")
.field("left", or(def("VariableDeclaration"), def("Expression")))
.field("right", def("Expression"))
.field("body", def("Statement"));
// The callee node of a dynamic import(...) expression.
def("Import")
.bases("Expression")
.build();
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=babel-core.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = tslib_1.__importDefault(require("../types"));
var babel_core_1 = tslib_1.__importDefault(require("./babel-core"));
var flow_1 = tslib_1.__importDefault(require("./flow"));
var shared_1 = require("../shared");
function default_1(fork) {
var types = fork.use(types_1.default);
var def = types.Type.def;
fork.use(babel_core_1.default);
fork.use(flow_1.default);
// https://github.com/babel/babel/pull/10148
def("V8IntrinsicIdentifier")
.bases("Expression")
.build("name")
.field("name", String);
// https://github.com/babel/babel/pull/13191
// https://github.com/babel/website/pull/2541
def("TopicReference")
.bases("Expression")
.build();
}
exports.default = default_1;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=babel.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"babel.js","sourceRoot":"","sources":["../../src/def/babel.ts"],"names":[],"mappings":";;;AACA,2DAAmC;AACnC,oEAAwC;AACxC,wDAA6B;AAC7B,oCAAkD;AAElD,mBAAyB,IAAU;IACjC,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAW,CAAC,CAAC;IACpC,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IAE3B,IAAI,CAAC,GAAG,CAAC,oBAAY,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC,cAAO,CAAC,CAAC;IAElB,4CAA4C;IAC5C,GAAG,CAAC,uBAAuB,CAAC;SACzB,KAAK,CAAC,YAAY,CAAC;SACnB,KAAK,CAAC,MAAM,CAAC;SACb,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzB,4CAA4C;IAC5C,6CAA6C;IAC7C,GAAG,CAAC,gBAAgB,CAAC;SAClB,KAAK,CAAC,YAAY,CAAC;SACnB,KAAK,EAAE,CAAC;AACb,CAAC;AAlBD,4BAkBC;AAED,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,281 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var core_1 = tslib_1.__importDefault(require("./operators/core"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
var types = fork.use(types_1.default);
var Type = types.Type;
var def = Type.def;
var or = Type.or;
var shared = fork.use(shared_1.default);
var defaults = shared.defaults;
var geq = shared.geq;
var _a = fork.use(core_1.default), BinaryOperators = _a.BinaryOperators, AssignmentOperators = _a.AssignmentOperators, LogicalOperators = _a.LogicalOperators;
// Abstract supertype of all syntactic entities that are allowed to have a
// .loc field.
def("Printable")
.field("loc", or(def("SourceLocation"), null), defaults["null"], true);
def("Node")
.bases("Printable")
.field("type", String)
.field("comments", or([def("Comment")], null), defaults["null"], true);
def("SourceLocation")
.field("start", def("Position"))
.field("end", def("Position"))
.field("source", or(String, null), defaults["null"]);
def("Position")
.field("line", geq(1))
.field("column", geq(0));
def("File")
.bases("Node")
.build("program", "name")
.field("program", def("Program"))
.field("name", or(String, null), defaults["null"]);
def("Program")
.bases("Node")
.build("body")
.field("body", [def("Statement")]);
def("Function")
.bases("Node")
.field("id", or(def("Identifier"), null), defaults["null"])
.field("params", [def("Pattern")])
.field("body", def("BlockStatement"))
.field("generator", Boolean, defaults["false"])
.field("async", Boolean, defaults["false"]);
def("Statement").bases("Node");
// The empty .build() here means that an EmptyStatement can be constructed
// (i.e. it's not abstract) but that it needs no arguments.
def("EmptyStatement").bases("Statement").build();
def("BlockStatement")
.bases("Statement")
.build("body")
.field("body", [def("Statement")]);
// TODO Figure out how to silently coerce Expressions to
// ExpressionStatements where a Statement was expected.
def("ExpressionStatement")
.bases("Statement")
.build("expression")
.field("expression", def("Expression"));
def("IfStatement")
.bases("Statement")
.build("test", "consequent", "alternate")
.field("test", def("Expression"))
.field("consequent", def("Statement"))
.field("alternate", or(def("Statement"), null), defaults["null"]);
def("LabeledStatement")
.bases("Statement")
.build("label", "body")
.field("label", def("Identifier"))
.field("body", def("Statement"));
def("BreakStatement")
.bases("Statement")
.build("label")
.field("label", or(def("Identifier"), null), defaults["null"]);
def("ContinueStatement")
.bases("Statement")
.build("label")
.field("label", or(def("Identifier"), null), defaults["null"]);
def("WithStatement")
.bases("Statement")
.build("object", "body")
.field("object", def("Expression"))
.field("body", def("Statement"));
def("SwitchStatement")
.bases("Statement")
.build("discriminant", "cases", "lexical")
.field("discriminant", def("Expression"))
.field("cases", [def("SwitchCase")])
.field("lexical", Boolean, defaults["false"]);
def("ReturnStatement")
.bases("Statement")
.build("argument")
.field("argument", or(def("Expression"), null));
def("ThrowStatement")
.bases("Statement")
.build("argument")
.field("argument", def("Expression"));
def("TryStatement")
.bases("Statement")
.build("block", "handler", "finalizer")
.field("block", def("BlockStatement"))
.field("handler", or(def("CatchClause"), null), function () {
return this.handlers && this.handlers[0] || null;
})
.field("handlers", [def("CatchClause")], function () {
return this.handler ? [this.handler] : [];
}, true) // Indicates this field is hidden from eachField iteration.
.field("guardedHandlers", [def("CatchClause")], defaults.emptyArray)
.field("finalizer", or(def("BlockStatement"), null), defaults["null"]);
def("CatchClause")
.bases("Node")
.build("param", "guard", "body")
.field("param", def("Pattern"))
.field("guard", or(def("Expression"), null), defaults["null"])
.field("body", def("BlockStatement"));
def("WhileStatement")
.bases("Statement")
.build("test", "body")
.field("test", def("Expression"))
.field("body", def("Statement"));
def("DoWhileStatement")
.bases("Statement")
.build("body", "test")
.field("body", def("Statement"))
.field("test", def("Expression"));
def("ForStatement")
.bases("Statement")
.build("init", "test", "update", "body")
.field("init", or(def("VariableDeclaration"), def("Expression"), null))
.field("test", or(def("Expression"), null))
.field("update", or(def("Expression"), null))
.field("body", def("Statement"));
def("ForInStatement")
.bases("Statement")
.build("left", "right", "body")
.field("left", or(def("VariableDeclaration"), def("Expression")))
.field("right", def("Expression"))
.field("body", def("Statement"));
def("DebuggerStatement").bases("Statement").build();
def("Declaration").bases("Statement");
def("FunctionDeclaration")
.bases("Function", "Declaration")
.build("id", "params", "body")
.field("id", def("Identifier"));
def("FunctionExpression")
.bases("Function", "Expression")
.build("id", "params", "body");
def("VariableDeclaration")
.bases("Declaration")
.build("kind", "declarations")
.field("kind", or("var", "let", "const"))
.field("declarations", [def("VariableDeclarator")]);
def("VariableDeclarator")
.bases("Node")
.build("id", "init")
.field("id", def("Pattern"))
.field("init", or(def("Expression"), null), defaults["null"]);
def("Expression").bases("Node");
def("ThisExpression").bases("Expression").build();
def("ArrayExpression")
.bases("Expression")
.build("elements")
.field("elements", [or(def("Expression"), null)]);
def("ObjectExpression")
.bases("Expression")
.build("properties")
.field("properties", [def("Property")]);
// TODO Not in the Mozilla Parser API, but used by Esprima.
def("Property")
.bases("Node") // Want to be able to visit Property Nodes.
.build("kind", "key", "value")
.field("kind", or("init", "get", "set"))
.field("key", or(def("Literal"), def("Identifier")))
.field("value", def("Expression"));
def("SequenceExpression")
.bases("Expression")
.build("expressions")
.field("expressions", [def("Expression")]);
var UnaryOperator = or("-", "+", "!", "~", "typeof", "void", "delete");
def("UnaryExpression")
.bases("Expression")
.build("operator", "argument", "prefix")
.field("operator", UnaryOperator)
.field("argument", def("Expression"))
// Esprima doesn't bother with this field, presumably because it's
// always true for unary operators.
.field("prefix", Boolean, defaults["true"]);
var BinaryOperator = or.apply(void 0, BinaryOperators);
def("BinaryExpression")
.bases("Expression")
.build("operator", "left", "right")
.field("operator", BinaryOperator)
.field("left", def("Expression"))
.field("right", def("Expression"));
var AssignmentOperator = or.apply(void 0, AssignmentOperators);
def("AssignmentExpression")
.bases("Expression")
.build("operator", "left", "right")
.field("operator", AssignmentOperator)
.field("left", or(def("Pattern"), def("MemberExpression")))
.field("right", def("Expression"));
var UpdateOperator = or("++", "--");
def("UpdateExpression")
.bases("Expression")
.build("operator", "argument", "prefix")
.field("operator", UpdateOperator)
.field("argument", def("Expression"))
.field("prefix", Boolean);
var LogicalOperator = or.apply(void 0, LogicalOperators);
def("LogicalExpression")
.bases("Expression")
.build("operator", "left", "right")
.field("operator", LogicalOperator)
.field("left", def("Expression"))
.field("right", def("Expression"));
def("ConditionalExpression")
.bases("Expression")
.build("test", "consequent", "alternate")
.field("test", def("Expression"))
.field("consequent", def("Expression"))
.field("alternate", def("Expression"));
def("NewExpression")
.bases("Expression")
.build("callee", "arguments")
.field("callee", def("Expression"))
// The Mozilla Parser API gives this type as [or(def("Expression"),
// null)], but null values don't really make sense at the call site.
// TODO Report this nonsense.
.field("arguments", [def("Expression")]);
def("CallExpression")
.bases("Expression")
.build("callee", "arguments")
.field("callee", def("Expression"))
// See comment for NewExpression above.
.field("arguments", [def("Expression")]);
def("MemberExpression")
.bases("Expression")
.build("object", "property", "computed")
.field("object", def("Expression"))
.field("property", or(def("Identifier"), def("Expression")))
.field("computed", Boolean, function () {
var type = this.property.type;
if (type === 'Literal' ||
type === 'MemberExpression' ||
type === 'BinaryExpression') {
return true;
}
return false;
});
def("Pattern").bases("Node");
def("SwitchCase")
.bases("Node")
.build("test", "consequent")
.field("test", or(def("Expression"), null))
.field("consequent", [def("Statement")]);
def("Identifier")
.bases("Expression", "Pattern")
.build("name")
.field("name", String)
.field("optional", Boolean, defaults["false"]);
def("Literal")
.bases("Expression")
.build("value")
.field("value", or(String, Boolean, null, Number, RegExp, BigInt));
// Abstract (non-buildable) comment supertype. Not a Node.
def("Comment")
.bases("Printable")
.field("value", String)
// A .leading comment comes before the node, whereas a .trailing
// comment comes after it. These two fields should not both be true,
// but they might both be false when the comment falls inside a node
// and the node has no children for the comment to lead or trail,
// e.g. { /*dangling*/ }.
.field("leading", Boolean, defaults["true"])
.field("trailing", Boolean, defaults["false"]);
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=core.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
var es2022_1 = tslib_1.__importDefault(require("./es2022"));
function default_1(fork) {
fork.use(es2022_1.default);
var types = fork.use(types_1.default);
var Type = types.Type;
var def = types.Type.def;
var or = Type.or;
var shared = fork.use(shared_1.default);
var defaults = shared.defaults;
def("AwaitExpression")
.build("argument", "all")
.field("argument", or(def("Expression"), null))
.field("all", Boolean, defaults["false"]);
// Decorators
def("Decorator")
.bases("Node")
.build("expression")
.field("expression", def("Expression"));
def("Property")
.field("decorators", or([def("Decorator")], null), defaults["null"]);
def("MethodDefinition")
.field("decorators", or([def("Decorator")], null), defaults["null"]);
// Private names
def("PrivateName")
.bases("Expression", "Pattern")
.build("id")
.field("id", def("Identifier"));
def("ClassPrivateProperty")
.bases("ClassProperty")
.build("key", "value")
.field("key", def("PrivateName"))
.field("value", or(def("Expression"), null), defaults["null"]);
// https://github.com/tc39/proposal-import-assertions
def("ImportAttribute")
.bases("Node")
.build("key", "value")
.field("key", or(def("Identifier"), def("Literal")))
.field("value", def("Expression"));
["ImportDeclaration",
"ExportAllDeclaration",
"ExportNamedDeclaration",
].forEach(function (decl) {
def(decl).field("assertions", [def("ImportAttribute")], defaults.emptyArray);
});
// https://github.com/tc39/proposal-record-tuple
// https://github.com/babel/babel/pull/10865
def("RecordExpression")
.bases("Expression")
.build("properties")
.field("properties", [or(def("ObjectProperty"), def("ObjectMethod"), def("SpreadElement"))]);
def("TupleExpression")
.bases("Expression")
.build("elements")
.field("elements", [or(def("Expression"), def("SpreadElement"), null)]);
// https://github.com/tc39/proposal-js-module-blocks
// https://github.com/babel/babel/pull/12469
def("ModuleExpression")
.bases("Node")
.build("body")
.field("body", def("Program"));
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es-proposals.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es-proposals.js","sourceRoot":"","sources":["../../src/def/es-proposals.ts"],"names":[],"mappings":";;;AACA,2DAAmC;AACnC,0DAAgE;AAChE,4DAAiC;AAEjC,mBAAyB,IAAU;IACjC,I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,CAAC;SACnB,KAAK,CAAC,YAAY,CAAC;SACnB,KAAK,CAAC,UAAU,CAAC;SACjB,KAAK,CAAC,UAAU,EAAE,CAAC,EAAE,CACpB,GAAG,CAAC,YAAY,CAAC,EACjB,GAAG,CAAC,eAAe,CAAC,EACpB,IAAI,CACL,CAAC,CAAC,CAAC;IAEN,oDAAoD;IACpD,4CAA4C;IAC5C,GAAG,CAAC,kBAAkB,CAAC;SACpB,KAAK,CAAC,MAAM,CAAC;SACb,KAAK,CAAC,MAAM,CAAC;SACb,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;AACnC,CAAC;AAvFD,4BAuFC;AAAA,CAAC;AAEF,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es2016_1 = tslib_1.__importDefault(require("./operators/es2016"));
var es6_1 = tslib_1.__importDefault(require("./es6"));
var shared_1 = require("../shared");
function default_1(fork) {
// The es2016OpsDef plugin comes before es6Def so BinaryOperators and
// AssignmentOperators will be appropriately augmented before they are first
// used in the core definitions for this fork.
fork.use(es2016_1.default);
fork.use(es6_1.default);
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2016.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2016.js","sourceRoot":"","sources":["../../src/def/es2016.ts"],"names":[],"mappings":";;;AACA,sEAA8C;AAC9C,sDAA2B;AAC3B,oCAAkD;AAElD,mBAAyB,IAAU;IACjC,qEAAqE;IACrE,4EAA4E;IAC5E,8CAA8C;IAC9C,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC,aAAM,CAAC,CAAC;AACnB,CAAC;AAND,4BAMC;AAAA,CAAC;AAEF,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es2016_1 = tslib_1.__importDefault(require("./es2016"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
fork.use(es2016_1.default);
var types = fork.use(types_1.default);
var def = types.Type.def;
var defaults = fork.use(shared_1.default).defaults;
def("Function")
.field("async", Boolean, defaults["false"]);
def("AwaitExpression")
.bases("Expression")
.build("argument")
.field("argument", def("Expression"));
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2017.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2017.js","sourceRoot":"","sources":["../../src/def/es2017.ts"],"names":[],"mappings":";;;AACA,4DAAiC;AACjC,2DAAmC;AACnC,0DAAgE;AAEhE,mBAAyB,IAAU;IACjC,IAAI,CAAC,GAAG,CAAC,gBAAS,CAAC,CAAC;IAEpB,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAW,CAAC,CAAC;IACpC,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IAC3B,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC,QAAQ,CAAC;IAEjD,GAAG,CAAC,UAAU,CAAC;SACZ,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9C,GAAG,CAAC,iBAAiB,CAAC;SACnB,KAAK,CAAC,YAAY,CAAC;SACnB,KAAK,CAAC,UAAU,CAAC;SACjB,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;AAC1C,CAAC;AAdD,4BAcC;AAAA,CAAC;AAEF,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es2017_1 = tslib_1.__importDefault(require("./es2017"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
fork.use(es2017_1.default);
var types = fork.use(types_1.default);
var def = types.Type.def;
var or = types.Type.or;
var defaults = fork.use(shared_1.default).defaults;
def("ForOfStatement")
.field("await", Boolean, defaults["false"]);
// Legacy
def("SpreadProperty")
.bases("Node")
.build("argument")
.field("argument", def("Expression"));
def("ObjectExpression")
.field("properties", [or(def("Property"), def("SpreadProperty"), // Legacy
def("SpreadElement"))]);
def("TemplateElement")
.field("value", { "cooked": or(String, null), "raw": String });
// Legacy
def("SpreadPropertyPattern")
.bases("Pattern")
.build("argument")
.field("argument", def("Pattern"));
def("ObjectPattern")
.field("properties", [or(def("PropertyPattern"), def("Property"), def("RestElement"), def("SpreadPropertyPattern"))]);
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2018.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2018.js","sourceRoot":"","sources":["../../src/def/es2018.ts"],"names":[],"mappings":";;;AACA,4DAAiC;AACjC,2DAAmC;AACnC,0DAAgE;AAEhE,mBAAyB,IAAU;IACjC,IAAI,CAAC,GAAG,CAAC,gBAAS,CAAC,CAAC;IAEpB,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAW,CAAC,CAAC;IACpC,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IAC3B,IAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAA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AAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es2018_1 = tslib_1.__importDefault(require("./es2018"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
fork.use(es2018_1.default);
var types = fork.use(types_1.default);
var def = types.Type.def;
var or = types.Type.or;
var defaults = fork.use(shared_1.default).defaults;
def("CatchClause")
.field("param", or(def("Pattern"), null), defaults["null"]);
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2019.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2019.js","sourceRoot":"","sources":["../../src/def/es2019.ts"],"names":[],"mappings":";;;AACA,4DAAiC;AACjC,2DAAmC;AACnC,0DAAgE;AAEhE,mBAAyB,IAAU;IACjC,IAAI,CAAC,GAAG,CAAC,gBAAS,CAAC,CAAC;IAEpB,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAW,CAAC,CAAC;IACpC,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IAC3B,IAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IACzB,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC,QAAQ,CAAC;IAEjD,GAAG,CAAC,aAAa,CAAC;SACf,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAChE,CAAC;AAVD,4BAUC;AAAA,CAAC;AAEF,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es2020_1 = tslib_1.__importDefault(require("./operators/es2020"));
var es2019_1 = tslib_1.__importDefault(require("./es2019"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
// The es2020OpsDef plugin comes before es2019Def so LogicalOperators will be
// appropriately augmented before first used.
fork.use(es2020_1.default);
fork.use(es2019_1.default);
var types = fork.use(types_1.default);
var def = types.Type.def;
var or = types.Type.or;
var shared = fork.use(shared_1.default);
var defaults = shared.defaults;
def("ImportExpression")
.bases("Expression")
.build("source")
.field("source", def("Expression"));
def("ExportAllDeclaration")
.bases("Declaration")
.build("source", "exported")
.field("source", def("Literal"))
.field("exported", or(def("Identifier"), null, void 0), defaults["null"]);
// Optional chaining
def("ChainElement")
.bases("Node")
.field("optional", Boolean, defaults["false"]);
def("CallExpression")
.bases("Expression", "ChainElement");
def("MemberExpression")
.bases("Expression", "ChainElement");
def("ChainExpression")
.bases("Expression")
.build("expression")
.field("expression", def("ChainElement"));
def("OptionalCallExpression")
.bases("CallExpression")
.build("callee", "arguments", "optional")
.field("optional", Boolean, defaults["true"]);
// Deprecated optional chaining type, doesn't work with babelParser@7.11.0 or newer
def("OptionalMemberExpression")
.bases("MemberExpression")
.build("object", "property", "computed", "optional")
.field("optional", Boolean, defaults["true"]);
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2020.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2020.js","sourceRoot":"","sources":["../../src/def/es2020.ts"],"names":[],"mappings":";;;AACA,sEAA8C;AAC9C,4DAAiC;AACjC,2DAAmC;AACnC,0DAAgE;AAEhE,mBAAyB,IAAU;IACjC,6EAA6E;IAC7E,6CAA6C;IAC7C,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC;IAEvB,I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CAAC;SACnB,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;IAE5C,GAAG,CAAC,wBAAwB,CAAC;SAC1B,KAAK,CAAC,gBAAgB,CAAC;SACvB,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAC;SACxC,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAEhD,mFAAmF;IACnF,GAAG,CAAC,0BAA0B,CAAC;SAC5B,KAAK,CAAC,kBAAkB,CAAC;SACzB,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC;SACnD,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC;AAvDD,4BAuDC;AAAA,CAAC;AAEF,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es2021_1 = tslib_1.__importDefault(require("./operators/es2021"));
var es2020_1 = tslib_1.__importDefault(require("./es2020"));
var shared_1 = require("../shared");
function default_1(fork) {
// The es2021OpsDef plugin comes before es2020Def so AssignmentOperators will
// be appropriately augmented before first used.
fork.use(es2021_1.default);
fork.use(es2020_1.default);
}
exports.default = default_1;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2021.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2021.js","sourceRoot":"","sources":["../../src/def/es2021.ts"],"names":[],"mappings":";;;AACA,sEAA8C;AAC9C,4DAAiC;AACjC,oCAAkD;AAElD,mBAAyB,IAAU;IACjC,6EAA6E;IAC7E,gDAAgD;IAChD,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC,gBAAS,CAAC,CAAC;AACtB,CAAC;AALD,4BAKC;AAED,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es2021_1 = tslib_1.__importDefault(require("./es2021"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = require("../shared");
function default_1(fork) {
fork.use(es2021_1.default);
var types = fork.use(types_1.default);
var def = types.Type.def;
def("StaticBlock")
.bases("Declaration")
.build("body")
.field("body", [def("Statement")]);
}
exports.default = default_1;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2022.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2022.js","sourceRoot":"","sources":["../../src/def/es2022.ts"],"names":[],"mappings":";;;AACA,4DAAiC;AACjC,2DAAmC;AACnC,oCAAkD;AAElD,mBAAyB,IAAU;IACjC,IAAI,CAAC,GAAG,CAAC,gBAAS,CAAC,CAAC;IAEpB,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAW,CAAC,CAAC;IACpC,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IAE3B,GAAG,CAAC,aAAa,CAAC;SACf,KAAK,CAAC,aAAa,CAAC;SACpB,KAAK,CAAC,MAAM,CAAC;SACb,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAVD,4BAUC;AAED,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,238 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var core_1 = tslib_1.__importDefault(require("./core"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
fork.use(core_1.default);
var types = fork.use(types_1.default);
var def = types.Type.def;
var or = types.Type.or;
var defaults = fork.use(shared_1.default).defaults;
def("Function")
.field("generator", Boolean, defaults["false"])
.field("expression", Boolean, defaults["false"])
.field("defaults", [or(def("Expression"), null)], defaults.emptyArray)
// Legacy
.field("rest", or(def("Identifier"), null), defaults["null"]);
// The ESTree way of representing a ...rest parameter.
def("RestElement")
.bases("Pattern")
.build("argument")
.field("argument", def("Pattern"))
.field("typeAnnotation", // for Babylon. Flow parser puts it on the identifier
or(def("TypeAnnotation"), def("TSTypeAnnotation"), null), defaults["null"]);
def("SpreadElementPattern")
.bases("Pattern")
.build("argument")
.field("argument", def("Pattern"));
def("FunctionDeclaration")
.build("id", "params", "body", "generator", "expression")
// May be `null` in the context of `export default function () {}`
.field("id", or(def("Identifier"), null));
def("FunctionExpression")
.build("id", "params", "body", "generator", "expression");
def("ArrowFunctionExpression")
.bases("Function", "Expression")
.build("params", "body", "expression")
// The forced null value here is compatible with the overridden
// definition of the "id" field in the Function interface.
.field("id", null, defaults["null"])
// Arrow function bodies are allowed to be expressions.
.field("body", or(def("BlockStatement"), def("Expression")))
// The current spec forbids arrow generators, so I have taken the
// liberty of enforcing that. TODO Report this.
.field("generator", false, defaults["false"]);
def("ForOfStatement")
.bases("Statement")
.build("left", "right", "body")
.field("left", or(def("VariableDeclaration"), def("Pattern")))
.field("right", def("Expression"))
.field("body", def("Statement"));
def("YieldExpression")
.bases("Expression")
.build("argument", "delegate")
.field("argument", or(def("Expression"), null))
.field("delegate", Boolean, defaults["false"]);
def("GeneratorExpression")
.bases("Expression")
.build("body", "blocks", "filter")
.field("body", def("Expression"))
.field("blocks", [def("ComprehensionBlock")])
.field("filter", or(def("Expression"), null));
def("ComprehensionExpression")
.bases("Expression")
.build("body", "blocks", "filter")
.field("body", def("Expression"))
.field("blocks", [def("ComprehensionBlock")])
.field("filter", or(def("Expression"), null));
def("ComprehensionBlock")
.bases("Node")
.build("left", "right", "each")
.field("left", def("Pattern"))
.field("right", def("Expression"))
.field("each", Boolean);
def("Property")
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
.field("value", or(def("Expression"), def("Pattern")))
.field("method", Boolean, defaults["false"])
.field("shorthand", Boolean, defaults["false"])
.field("computed", Boolean, defaults["false"]);
def("ObjectProperty")
.field("shorthand", Boolean, defaults["false"]);
def("PropertyPattern")
.bases("Pattern")
.build("key", "pattern")
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
.field("pattern", def("Pattern"))
.field("computed", Boolean, defaults["false"]);
def("ObjectPattern")
.bases("Pattern")
.build("properties")
.field("properties", [or(def("PropertyPattern"), def("Property"))]);
def("ArrayPattern")
.bases("Pattern")
.build("elements")
.field("elements", [or(def("Pattern"), null)]);
def("SpreadElement")
.bases("Node")
.build("argument")
.field("argument", def("Expression"));
def("ArrayExpression")
.field("elements", [or(def("Expression"), def("SpreadElement"), def("RestElement"), null)]);
def("NewExpression")
.field("arguments", [or(def("Expression"), def("SpreadElement"))]);
def("CallExpression")
.field("arguments", [or(def("Expression"), def("SpreadElement"))]);
// Note: this node type is *not* an AssignmentExpression with a Pattern on
// the left-hand side! The existing AssignmentExpression type already
// supports destructuring assignments. AssignmentPattern nodes may appear
// wherever a Pattern is allowed, and the right-hand side represents a
// default value to be destructured against the left-hand side, if no
// value is otherwise provided. For example: default parameter values.
def("AssignmentPattern")
.bases("Pattern")
.build("left", "right")
.field("left", def("Pattern"))
.field("right", def("Expression"));
def("MethodDefinition")
.bases("Declaration")
.build("kind", "key", "value", "static")
.field("kind", or("constructor", "method", "get", "set"))
.field("key", def("Expression"))
.field("value", def("Function"))
.field("computed", Boolean, defaults["false"])
.field("static", Boolean, defaults["false"]);
var ClassBodyElement = or(def("MethodDefinition"), def("VariableDeclarator"), def("ClassPropertyDefinition"), def("ClassProperty"), def("StaticBlock"));
def("ClassProperty")
.bases("Declaration")
.build("key")
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
.field("computed", Boolean, defaults["false"]);
def("ClassPropertyDefinition") // static property
.bases("Declaration")
.build("definition")
// Yes, Virginia, circular definitions are permitted.
.field("definition", ClassBodyElement);
def("ClassBody")
.bases("Declaration")
.build("body")
.field("body", [ClassBodyElement]);
def("ClassDeclaration")
.bases("Declaration")
.build("id", "body", "superClass")
.field("id", or(def("Identifier"), null))
.field("body", def("ClassBody"))
.field("superClass", or(def("Expression"), null), defaults["null"]);
def("ClassExpression")
.bases("Expression")
.build("id", "body", "superClass")
.field("id", or(def("Identifier"), null), defaults["null"])
.field("body", def("ClassBody"))
.field("superClass", or(def("Expression"), null), defaults["null"]);
def("Super")
.bases("Expression")
.build();
// Specifier and ModuleSpecifier are abstract non-standard types
// introduced for definitional convenience.
def("Specifier").bases("Node");
// This supertype is shared/abused by both def/babel.js and
// def/esprima.js. In the future, it will be possible to load only one set
// of definitions appropriate for a given parser, but until then we must
// rely on default functions to reconcile the conflicting AST formats.
def("ModuleSpecifier")
.bases("Specifier")
// This local field is used by Babel/Acorn. It should not technically
// be optional in the Babel/Acorn AST format, but it must be optional
// in the Esprima AST format.
.field("local", or(def("Identifier"), null), defaults["null"])
// The id and name fields are used by Esprima. The id field should not
// technically be optional in the Esprima AST format, but it must be
// optional in the Babel/Acorn AST format.
.field("id", or(def("Identifier"), null), defaults["null"])
.field("name", or(def("Identifier"), null), defaults["null"]);
// import {<id [as name]>} from ...;
def("ImportSpecifier")
.bases("ModuleSpecifier")
.build("imported", "local")
.field("imported", def("Identifier"));
// import <id> from ...;
def("ImportDefaultSpecifier")
.bases("ModuleSpecifier")
.build("local");
// import <* as id> from ...;
def("ImportNamespaceSpecifier")
.bases("ModuleSpecifier")
.build("local");
def("ImportDeclaration")
.bases("Declaration")
.build("specifiers", "source", "importKind")
.field("specifiers", [or(def("ImportSpecifier"), def("ImportNamespaceSpecifier"), def("ImportDefaultSpecifier"))], defaults.emptyArray)
.field("source", def("Literal"))
.field("importKind", or("value", "type"), function () {
return "value";
});
def("ExportNamedDeclaration")
.bases("Declaration")
.build("declaration", "specifiers", "source")
.field("declaration", or(def("Declaration"), null))
.field("specifiers", [def("ExportSpecifier")], defaults.emptyArray)
.field("source", or(def("Literal"), null), defaults["null"]);
def("ExportSpecifier")
.bases("ModuleSpecifier")
.build("local", "exported")
.field("exported", def("Identifier"));
def("ExportDefaultDeclaration")
.bases("Declaration")
.build("declaration")
.field("declaration", or(def("Declaration"), def("Expression")));
def("ExportAllDeclaration")
.bases("Declaration")
.build("source")
.field("source", def("Literal"));
def("TaggedTemplateExpression")
.bases("Expression")
.build("tag", "quasi")
.field("tag", def("Expression"))
.field("quasi", def("TemplateLiteral"));
def("TemplateLiteral")
.bases("Expression")
.build("quasis", "expressions")
.field("quasis", [def("TemplateElement")])
.field("expressions", [def("Expression")]);
def("TemplateElement")
.bases("Node")
.build("value", "tail")
.field("value", { "cooked": String, "raw": String })
.field("tail", Boolean);
def("MetaProperty")
.bases("Expression")
.build("meta", "property")
.field("meta", def("Identifier"))
.field("property", def("Identifier"));
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es6.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es_proposals_1 = tslib_1.__importDefault(require("./es-proposals"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
fork.use(es_proposals_1.default);
var types = fork.use(types_1.default);
var defaults = fork.use(shared_1.default).defaults;
var def = types.Type.def;
var or = types.Type.or;
def("VariableDeclaration")
.field("declarations", [or(def("VariableDeclarator"), def("Identifier") // Esprima deviation.
)]);
def("Property")
.field("value", or(def("Expression"), def("Pattern") // Esprima deviation.
));
def("ArrayPattern")
.field("elements", [or(def("Pattern"), def("SpreadElement"), null)]);
def("ObjectPattern")
.field("properties", [or(def("Property"), def("PropertyPattern"), def("SpreadPropertyPattern"), def("SpreadProperty") // Used by Esprima.
)]);
// Like ModuleSpecifier, except type:"ExportSpecifier" and buildable.
// export {<id [as name]>} [from ...];
def("ExportSpecifier")
.bases("ModuleSpecifier")
.build("id", "name");
// export <*> from ...;
def("ExportBatchSpecifier")
.bases("Specifier")
.build();
def("ExportDeclaration")
.bases("Declaration")
.build("default", "declaration", "specifiers", "source")
.field("default", Boolean)
.field("declaration", or(def("Declaration"), def("Expression"), // Implies default.
null))
.field("specifiers", [or(def("ExportSpecifier"), def("ExportBatchSpecifier"))], defaults.emptyArray)
.field("source", or(def("Literal"), null), defaults["null"]);
def("Block")
.bases("Comment")
.build("value", /*optional:*/ "leading", "trailing");
def("Line")
.bases("Comment")
.build("value", /*optional:*/ "leading", "trailing");
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=esprima.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"esprima.js","sourceRoot":"","sources":["../../src/def/esprima.ts"],"names":[],"mappings":";;;AACA,wEAA4C;AAC5C,2DAAmC;AACnC,0DAAgE;AAEhE,mBAAyB,IAAU;IACjC,IAAI,CAAC,GAAG,CAAC,sBAAc,CAAC,CAAC;IAEzB,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAW,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC,QAAQ,CAAC;IAC/C,IAAI,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IACzB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IAEvB,GAAG,CAAC,qBAAqB,CAAC;SACvB,KAAK,CAAC,cAAc,E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SACD,KAAK,CAAC,YAAY,EAAE,CAAC,EAAE,CACtB,GAAG,CAAC,iBAAiB,CAAC,EACtB,GAAG,CAAC,sBAAsB,CAAC,CAC5B,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC;SACvB,KAAK,CAAC,QAAQ,EAAE,EAAE,CACjB,GAAG,CAAC,SAAS,CAAC,EACd,IAAI,CACL,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvB,GAAG,CAAC,OAAO,CAAC;SACT,KAAK,CAAC,SAAS,CAAC;SAChB,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAEvD,GAAG,CAAC,MAAM,CAAC;SACR,KAAK,CAAC,SAAS,CAAC;SAChB,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC;AAvED,4BAuEC;AAAA,CAAC;AAEF,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,362 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es_proposals_1 = tslib_1.__importDefault(require("./es-proposals"));
var type_annotations_1 = tslib_1.__importDefault(require("./type-annotations"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
fork.use(es_proposals_1.default);
fork.use(type_annotations_1.default);
var types = fork.use(types_1.default);
var def = types.Type.def;
var or = types.Type.or;
var defaults = fork.use(shared_1.default).defaults;
// Base types
def("Flow").bases("Node");
def("FlowType").bases("Flow");
// Type annotations
def("AnyTypeAnnotation")
.bases("FlowType")
.build();
def("EmptyTypeAnnotation")
.bases("FlowType")
.build();
def("MixedTypeAnnotation")
.bases("FlowType")
.build();
def("VoidTypeAnnotation")
.bases("FlowType")
.build();
def("SymbolTypeAnnotation")
.bases("FlowType")
.build();
def("NumberTypeAnnotation")
.bases("FlowType")
.build();
def("BigIntTypeAnnotation")
.bases("FlowType")
.build();
def("NumberLiteralTypeAnnotation")
.bases("FlowType")
.build("value", "raw")
.field("value", Number)
.field("raw", String);
// Babylon 6 differs in AST from Flow
// same as NumberLiteralTypeAnnotation
def("NumericLiteralTypeAnnotation")
.bases("FlowType")
.build("value", "raw")
.field("value", Number)
.field("raw", String);
def("BigIntLiteralTypeAnnotation")
.bases("FlowType")
.build("value", "raw")
.field("value", null)
.field("raw", String);
def("StringTypeAnnotation")
.bases("FlowType")
.build();
def("StringLiteralTypeAnnotation")
.bases("FlowType")
.build("value", "raw")
.field("value", String)
.field("raw", String);
def("BooleanTypeAnnotation")
.bases("FlowType")
.build();
def("BooleanLiteralTypeAnnotation")
.bases("FlowType")
.build("value", "raw")
.field("value", Boolean)
.field("raw", String);
def("TypeAnnotation")
.bases("Node")
.build("typeAnnotation")
.field("typeAnnotation", def("FlowType"));
def("NullableTypeAnnotation")
.bases("FlowType")
.build("typeAnnotation")
.field("typeAnnotation", def("FlowType"));
def("NullLiteralTypeAnnotation")
.bases("FlowType")
.build();
def("NullTypeAnnotation")
.bases("FlowType")
.build();
def("ThisTypeAnnotation")
.bases("FlowType")
.build();
def("ExistsTypeAnnotation")
.bases("FlowType")
.build();
def("ExistentialTypeParam")
.bases("FlowType")
.build();
def("FunctionTypeAnnotation")
.bases("FlowType")
.build("params", "returnType", "rest", "typeParameters")
.field("params", [def("FunctionTypeParam")])
.field("returnType", def("FlowType"))
.field("rest", or(def("FunctionTypeParam"), null))
.field("typeParameters", or(def("TypeParameterDeclaration"), null));
def("FunctionTypeParam")
.bases("Node")
.build("name", "typeAnnotation", "optional")
.field("name", or(def("Identifier"), null))
.field("typeAnnotation", def("FlowType"))
.field("optional", Boolean);
def("ArrayTypeAnnotation")
.bases("FlowType")
.build("elementType")
.field("elementType", def("FlowType"));
def("ObjectTypeAnnotation")
.bases("FlowType")
.build("properties", "indexers", "callProperties")
.field("properties", [
or(def("ObjectTypeProperty"), def("ObjectTypeSpreadProperty"))
])
.field("indexers", [def("ObjectTypeIndexer")], defaults.emptyArray)
.field("callProperties", [def("ObjectTypeCallProperty")], defaults.emptyArray)
.field("inexact", or(Boolean, void 0), defaults["undefined"])
.field("exact", Boolean, defaults["false"])
.field("internalSlots", [def("ObjectTypeInternalSlot")], defaults.emptyArray);
def("Variance")
.bases("Node")
.build("kind")
.field("kind", or("plus", "minus"));
var LegacyVariance = or(def("Variance"), "plus", "minus", null);
def("ObjectTypeProperty")
.bases("Node")
.build("key", "value", "optional")
.field("key", or(def("Literal"), def("Identifier")))
.field("value", def("FlowType"))
.field("optional", Boolean)
.field("variance", LegacyVariance, defaults["null"]);
def("ObjectTypeIndexer")
.bases("Node")
.build("id", "key", "value")
.field("id", def("Identifier"))
.field("key", def("FlowType"))
.field("value", def("FlowType"))
.field("variance", LegacyVariance, defaults["null"])
.field("static", Boolean, defaults["false"]);
def("ObjectTypeCallProperty")
.bases("Node")
.build("value")
.field("value", def("FunctionTypeAnnotation"))
.field("static", Boolean, defaults["false"]);
def("QualifiedTypeIdentifier")
.bases("Node")
.build("qualification", "id")
.field("qualification", or(def("Identifier"), def("QualifiedTypeIdentifier")))
.field("id", def("Identifier"));
def("GenericTypeAnnotation")
.bases("FlowType")
.build("id", "typeParameters")
.field("id", or(def("Identifier"), def("QualifiedTypeIdentifier")))
.field("typeParameters", or(def("TypeParameterInstantiation"), null));
def("MemberTypeAnnotation")
.bases("FlowType")
.build("object", "property")
.field("object", def("Identifier"))
.field("property", or(def("MemberTypeAnnotation"), def("GenericTypeAnnotation")));
def("IndexedAccessType")
.bases("FlowType")
.build("objectType", "indexType")
.field("objectType", def("FlowType"))
.field("indexType", def("FlowType"));
def("OptionalIndexedAccessType")
.bases("FlowType")
.build("objectType", "indexType", "optional")
.field("objectType", def("FlowType"))
.field("indexType", def("FlowType"))
.field('optional', Boolean);
def("UnionTypeAnnotation")
.bases("FlowType")
.build("types")
.field("types", [def("FlowType")]);
def("IntersectionTypeAnnotation")
.bases("FlowType")
.build("types")
.field("types", [def("FlowType")]);
def("TypeofTypeAnnotation")
.bases("FlowType")
.build("argument")
.field("argument", def("FlowType"));
def("ObjectTypeSpreadProperty")
.bases("Node")
.build("argument")
.field("argument", def("FlowType"));
def("ObjectTypeInternalSlot")
.bases("Node")
.build("id", "value", "optional", "static", "method")
.field("id", def("Identifier"))
.field("value", def("FlowType"))
.field("optional", Boolean)
.field("static", Boolean)
.field("method", Boolean);
def("TypeParameterDeclaration")
.bases("Node")
.build("params")
.field("params", [def("TypeParameter")]);
def("TypeParameterInstantiation")
.bases("Node")
.build("params")
.field("params", [def("FlowType")]);
def("TypeParameter")
.bases("FlowType")
.build("name", "variance", "bound", "default")
.field("name", String)
.field("variance", LegacyVariance, defaults["null"])
.field("bound", or(def("TypeAnnotation"), null), defaults["null"])
.field("default", or(def("FlowType"), null), defaults["null"]);
def("ClassProperty")
.field("variance", LegacyVariance, defaults["null"]);
def("ClassImplements")
.bases("Node")
.build("id")
.field("id", def("Identifier"))
.field("superClass", or(def("Expression"), null), defaults["null"])
.field("typeParameters", or(def("TypeParameterInstantiation"), null), defaults["null"]);
def("InterfaceTypeAnnotation")
.bases("FlowType")
.build("body", "extends")
.field("body", def("ObjectTypeAnnotation"))
.field("extends", or([def("InterfaceExtends")], null), defaults["null"]);
def("InterfaceDeclaration")
.bases("Declaration")
.build("id", "body", "extends")
.field("id", def("Identifier"))
.field("typeParameters", or(def("TypeParameterDeclaration"), null), defaults["null"])
.field("body", def("ObjectTypeAnnotation"))
.field("extends", [def("InterfaceExtends")]);
def("DeclareInterface")
.bases("InterfaceDeclaration")
.build("id", "body", "extends");
def("InterfaceExtends")
.bases("Node")
.build("id")
.field("id", def("Identifier"))
.field("typeParameters", or(def("TypeParameterInstantiation"), null), defaults["null"]);
def("TypeAlias")
.bases("Declaration")
.build("id", "typeParameters", "right")
.field("id", def("Identifier"))
.field("typeParameters", or(def("TypeParameterDeclaration"), null))
.field("right", def("FlowType"));
def("DeclareTypeAlias")
.bases("TypeAlias")
.build("id", "typeParameters", "right");
def("OpaqueType")
.bases("Declaration")
.build("id", "typeParameters", "impltype", "supertype")
.field("id", def("Identifier"))
.field("typeParameters", or(def("TypeParameterDeclaration"), null))
.field("impltype", def("FlowType"))
.field("supertype", or(def("FlowType"), null));
def("DeclareOpaqueType")
.bases("OpaqueType")
.build("id", "typeParameters", "supertype")
.field("impltype", or(def("FlowType"), null));
def("TypeCastExpression")
.bases("Expression")
.build("expression", "typeAnnotation")
.field("expression", def("Expression"))
.field("typeAnnotation", def("TypeAnnotation"));
def("TupleTypeAnnotation")
.bases("FlowType")
.build("types")
.field("types", [def("FlowType")]);
def("DeclareVariable")
.bases("Statement")
.build("id")
.field("id", def("Identifier"));
def("DeclareFunction")
.bases("Statement")
.build("id")
.field("id", def("Identifier"))
.field("predicate", or(def("FlowPredicate"), null), defaults["null"]);
def("DeclareClass")
.bases("InterfaceDeclaration")
.build("id");
def("DeclareModule")
.bases("Statement")
.build("id", "body")
.field("id", or(def("Identifier"), def("Literal")))
.field("body", def("BlockStatement"));
def("DeclareModuleExports")
.bases("Statement")
.build("typeAnnotation")
.field("typeAnnotation", def("TypeAnnotation"));
def("DeclareExportDeclaration")
.bases("Declaration")
.build("default", "declaration", "specifiers", "source")
.field("default", Boolean)
.field("declaration", or(def("DeclareVariable"), def("DeclareFunction"), def("DeclareClass"), def("FlowType"), // Implies default.
def("TypeAlias"), // Implies named type
def("DeclareOpaqueType"), // Implies named opaque type
def("InterfaceDeclaration"), null))
.field("specifiers", [or(def("ExportSpecifier"), def("ExportBatchSpecifier"))], defaults.emptyArray)
.field("source", or(def("Literal"), null), defaults["null"]);
def("DeclareExportAllDeclaration")
.bases("Declaration")
.build("source")
.field("source", or(def("Literal"), null), defaults["null"]);
def("ImportDeclaration")
.field("importKind", or("value", "type", "typeof"), function () { return "value"; });
def("FlowPredicate").bases("Flow");
def("InferredPredicate")
.bases("FlowPredicate")
.build();
def("DeclaredPredicate")
.bases("FlowPredicate")
.build("value")
.field("value", def("Expression"));
def("Function")
.field("predicate", or(def("FlowPredicate"), null), defaults["null"]);
def("CallExpression")
.field("typeArguments", or(null, def("TypeParameterInstantiation")), defaults["null"]);
def("NewExpression")
.field("typeArguments", or(null, def("TypeParameterInstantiation")), defaults["null"]);
// Enums
def("EnumDeclaration")
.bases("Declaration")
.build("id", "body")
.field("id", def("Identifier"))
.field("body", or(def("EnumBooleanBody"), def("EnumNumberBody"), def("EnumStringBody"), def("EnumSymbolBody")));
def("EnumBooleanBody")
.build("members", "explicitType")
.field("members", [def("EnumBooleanMember")])
.field("explicitType", Boolean);
def("EnumNumberBody")
.build("members", "explicitType")
.field("members", [def("EnumNumberMember")])
.field("explicitType", Boolean);
def("EnumStringBody")
.build("members", "explicitType")
.field("members", or([def("EnumStringMember")], [def("EnumDefaultedMember")]))
.field("explicitType", Boolean);
def("EnumSymbolBody")
.build("members")
.field("members", [def("EnumDefaultedMember")]);
def("EnumBooleanMember")
.build("id", "init")
.field("id", def("Identifier"))
.field("init", or(def("Literal"), Boolean));
def("EnumNumberMember")
.build("id", "init")
.field("id", def("Identifier"))
.field("init", def("Literal"));
def("EnumStringMember")
.build("id", "init")
.field("id", def("Identifier"))
.field("init", def("Literal"));
def("EnumDefaultedMember")
.build("id")
.field("id", def("Identifier"));
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=flow.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,110 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var es_proposals_1 = tslib_1.__importDefault(require("./es-proposals"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
fork.use(es_proposals_1.default);
var types = fork.use(types_1.default);
var def = types.Type.def;
var or = types.Type.or;
var defaults = fork.use(shared_1.default).defaults;
def("JSXAttribute")
.bases("Node")
.build("name", "value")
.field("name", or(def("JSXIdentifier"), def("JSXNamespacedName")))
.field("value", or(def("Literal"), // attr="value"
def("JSXExpressionContainer"), // attr={value}
def("JSXElement"), // attr=<div />
def("JSXFragment"), // attr=<></>
null // attr= or just attr
), defaults["null"]);
def("JSXIdentifier")
.bases("Identifier")
.build("name")
.field("name", String);
def("JSXNamespacedName")
.bases("Node")
.build("namespace", "name")
.field("namespace", def("JSXIdentifier"))
.field("name", def("JSXIdentifier"));
def("JSXMemberExpression")
.bases("MemberExpression")
.build("object", "property")
.field("object", or(def("JSXIdentifier"), def("JSXMemberExpression")))
.field("property", def("JSXIdentifier"))
.field("computed", Boolean, defaults.false);
var JSXElementName = or(def("JSXIdentifier"), def("JSXNamespacedName"), def("JSXMemberExpression"));
def("JSXSpreadAttribute")
.bases("Node")
.build("argument")
.field("argument", def("Expression"));
var JSXAttributes = [or(def("JSXAttribute"), def("JSXSpreadAttribute"))];
def("JSXExpressionContainer")
.bases("Expression")
.build("expression")
.field("expression", or(def("Expression"), def("JSXEmptyExpression")));
var JSXChildren = [or(def("JSXText"), def("JSXExpressionContainer"), def("JSXSpreadChild"), def("JSXElement"), def("JSXFragment"), def("Literal") // Legacy: Esprima should return JSXText instead.
)];
def("JSXElement")
.bases("Expression")
.build("openingElement", "closingElement", "children")
.field("openingElement", def("JSXOpeningElement"))
.field("closingElement", or(def("JSXClosingElement"), null), defaults["null"])
.field("children", JSXChildren, defaults.emptyArray)
.field("name", JSXElementName, function () {
// Little-known fact: the `this` object inside a default function
// is none other than the partially-built object itself, and any
// fields initialized directly from builder function arguments
// (like openingElement, closingElement, and children) are
// guaranteed to be available.
return this.openingElement.name;
}, true) // hidden from traversal
.field("selfClosing", Boolean, function () {
return this.openingElement.selfClosing;
}, true) // hidden from traversal
.field("attributes", JSXAttributes, function () {
return this.openingElement.attributes;
}, true); // hidden from traversal
def("JSXOpeningElement")
.bases("Node")
.build("name", "attributes", "selfClosing")
.field("name", JSXElementName)
.field("attributes", JSXAttributes, defaults.emptyArray)
.field("selfClosing", Boolean, defaults["false"]);
def("JSXClosingElement")
.bases("Node")
.build("name")
.field("name", JSXElementName);
def("JSXFragment")
.bases("Expression")
.build("openingFragment", "closingFragment", "children")
.field("openingFragment", def("JSXOpeningFragment"))
.field("closingFragment", def("JSXClosingFragment"))
.field("children", JSXChildren, defaults.emptyArray);
def("JSXOpeningFragment")
.bases("Node")
.build();
def("JSXClosingFragment")
.bases("Node")
.build();
def("JSXText")
.bases("Literal")
.build("value", "raw")
.field("value", String)
.field("raw", String, function () {
return this.value;
});
def("JSXEmptyExpression")
.bases("Node")
.build();
def("JSXSpreadChild")
.bases("Node")
.build("expression")
.field("expression", def("Expression"));
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=jsx.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"jsx.js","sourceRoot":"","sources":["../../src/def/jsx.ts"],"names":[],"mappings":";;;AACA,wEAA4C;AAC5C,2DAAmC;AACnC,0DAAgE;AAGhE,mBAAyB,IAAU;IACjC,IAAI,CAAC,GAAG,CAAC,sBAAc,CAAC,CAAC;IAEzB,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAW,CAAC,CAAC;IACpC,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IAC3B,IAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IACzB,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC,QAAQ,CAAC;IAEjD,GAAG,CAAC,cAAc,CAAC;SAChB,KAAK,CAAC,MAAM,CAAC;SACb,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC;SACtB,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC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ACtB,KAAK,CAAC,MAAM,CAAC;SACb,KAAK,EAAE,CAAC;IAEX,GAAG,CAAC,SAAS,CAAC;SACX,KAAK,CAAC,SAAS,CAAC;SAChB,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC;SACrB,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC;SACtB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC,CAAC,CAAC;IAEN,GAAG,CAAC,oBAAoB,CAAC;SACtB,KAAK,CAAC,MAAM,CAAC;SACb,KAAK,EAAE,CAAC;IAEX,GAAG,CAAC,gBAAgB,CAAC;SAClB,KAAK,CAAC,MAAM,CAAC;SACb,KAAK,CAAC,YAAY,CAAC;SACnB,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;AAC5C,CAAC;AApID,4BAoIC;AAAA,CAAC;AAEF,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,5 @@
export default function (): {
BinaryOperators: string[];
AssignmentOperators: string[];
LogicalOperators: string[];
};

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var shared_1 = require("../../shared");
function default_1() {
return {
BinaryOperators: [
"==", "!=", "===", "!==",
"<", "<=", ">", ">=",
"<<", ">>", ">>>",
"+", "-", "*", "/", "%",
"&",
"|", "^", "in",
"instanceof",
],
AssignmentOperators: [
"=", "+=", "-=", "*=", "/=", "%=",
"<<=", ">>=", ">>>=",
"|=", "^=", "&=",
],
LogicalOperators: [
"||", "&&",
],
};
}
exports.default = default_1;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=core.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/def/operators/core.ts"],"names":[],"mappings":";;AAAA,uCAAqD;AAErD;IACE,OAAO;QACL,eAAe,EAAE;YACf,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK;YACxB,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI;YACpB,IAAI,EAAE,IAAI,EAAE,KAAK;YACjB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;YACvB,GAAG;YACH,GAAG,EAAE,GAAG,EAAE,IAAI;YACd,YAAY;SACb;QAED,mBAAmB,EAAE;YACnB,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;YACjC,KAAK,EAAE,KAAK,EAAE,MAAM;YACpB,IAAI,EAAE,IAAI,EAAE,IAAI;SACjB;QAED,gBAAgB,EAAE;YAChB,IAAI,EAAE,IAAI;SACX;KACF,CAAC;AACJ,CAAC;AAtBD,4BAsBC;AAED,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,5 @@
export default function (fork: import("../../types").Fork): {
BinaryOperators: string[];
AssignmentOperators: string[];
LogicalOperators: string[];
};

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var shared_1 = require("../../shared");
var core_1 = tslib_1.__importDefault(require("./core"));
function default_1(fork) {
var result = fork.use(core_1.default);
// Exponentiation operators. Must run before BinaryOperators or
// AssignmentOperators are used (hence before fork.use(es6Def)).
// https://github.com/tc39/proposal-exponentiation-operator
if (result.BinaryOperators.indexOf("**") < 0) {
result.BinaryOperators.push("**");
}
if (result.AssignmentOperators.indexOf("**=") < 0) {
result.AssignmentOperators.push("**=");
}
return result;
}
exports.default = default_1;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2016.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2016.js","sourceRoot":"","sources":["../../../src/def/operators/es2016.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AACrD,wDAAgC;AAEhC,mBAAyB,IAAgC;IACvD,IAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,cAAU,CAAC,CAAC;IAEpC,+DAA+D;IAC/D,gEAAgE;IAChE,2DAA2D;IAC3D,IAAI,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC5C,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACnC;IACD,IAAI,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACjD,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACxC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAdD,4BAcC;AAED,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,5 @@
export default function (fork: import("../../types").Fork): {
BinaryOperators: string[];
AssignmentOperators: string[];
LogicalOperators: string[];
};

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var shared_1 = require("../../shared");
var es2016_1 = tslib_1.__importDefault(require("./es2016"));
function default_1(fork) {
var result = fork.use(es2016_1.default);
// Nullish coalescing. Must run before LogicalOperators is used.
// https://github.com/tc39/proposal-nullish-coalescing
if (result.LogicalOperators.indexOf("??") < 0) {
result.LogicalOperators.push("??");
}
return result;
}
exports.default = default_1;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2020.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2020.js","sourceRoot":"","sources":["../../../src/def/operators/es2020.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AACrD,4DAAoC;AAEpC,mBAAyB,IAAgC;IACvD,IAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC;IAEtC,gEAAgE;IAChE,sDAAsD;IACtD,IAAI,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC7C,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,4BAUC;AAED,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,5 @@
export default function (fork: import("../../types").Fork): {
BinaryOperators: string[];
AssignmentOperators: string[];
LogicalOperators: string[];
};

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var shared_1 = require("../../shared");
var es2020_1 = tslib_1.__importDefault(require("./es2020"));
function default_1(fork) {
var result = fork.use(es2020_1.default);
// Logical assignment operators. Must run before AssignmentOperators is used.
// https://github.com/tc39/proposal-logical-assignment
result.LogicalOperators.forEach(function (op) {
var assignOp = op + "=";
if (result.AssignmentOperators.indexOf(assignOp) < 0) {
result.AssignmentOperators.push(assignOp);
}
});
return result;
}
exports.default = default_1;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=es2021.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"es2021.js","sourceRoot":"","sources":["../../../src/def/operators/es2021.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AACrD,4DAAoC;AAEpC,mBAAyB,IAAgC;IACvD,IAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC;IAEtC,6EAA6E;IAC7E,sDAAsD;IACtD,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAA,EAAE;QAChC,IAAM,QAAQ,GAAG,EAAE,GAAG,GAAG,CAAC;QAC1B,IAAI,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACpD,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC3C;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAbD,4BAaC;AAED,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,7 @@
/**
* Type annotation defs shared between Flow and TypeScript.
* These defs could not be defined in ./flow.ts or ./typescript.ts directly
* because they use the same name.
*/
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,42 @@
"use strict";
/**
* Type annotation defs shared between Flow and TypeScript.
* These defs could not be defined in ./flow.ts or ./typescript.ts directly
* because they use the same name.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
var types = fork.use(types_1.default);
var def = types.Type.def;
var or = types.Type.or;
var defaults = fork.use(shared_1.default).defaults;
var TypeAnnotation = or(def("TypeAnnotation"), def("TSTypeAnnotation"), null);
var TypeParamDecl = or(def("TypeParameterDeclaration"), def("TSTypeParameterDeclaration"), null);
def("Identifier")
.field("typeAnnotation", TypeAnnotation, defaults["null"]);
def("ObjectPattern")
.field("typeAnnotation", TypeAnnotation, defaults["null"]);
def("Function")
.field("returnType", TypeAnnotation, defaults["null"])
.field("typeParameters", TypeParamDecl, defaults["null"]);
def("ClassProperty")
.build("key", "value", "typeAnnotation", "static")
.field("value", or(def("Expression"), null))
.field("static", Boolean, defaults["false"])
.field("typeAnnotation", TypeAnnotation, defaults["null"]);
["ClassDeclaration",
"ClassExpression",
].forEach(function (typeName) {
def(typeName)
.field("typeParameters", TypeParamDecl, defaults["null"])
.field("superTypeParameters", or(def("TypeParameterInstantiation"), def("TSTypeParameterInstantiation"), null), defaults["null"])
.field("implements", or([def("ClassImplements")], [def("TSExpressionWithTypeArguments")]), defaults.emptyArray);
});
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=type-annotations.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"type-annotations.js","sourceRoot":"","sources":["../../src/def/type-annotations.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,2DAAmC;AACnC,0DAAgE;AAEhE,mBAAyB,IAAU;IACjC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,eAAW,CAAC,CAAC;IAClC,IAAI,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IACzB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAY,CAAC,CAAC,QAAQ,CAAC;IAE/C,IAAI,cAAc,GAAG,EAAE,CACrB,GAAG,CAAC,gBAAgB,CAAC,EACrB,GAAG,CAAC,kBAAkB,CAAC,EACvB,IAAI,CACL,CAAC;IAEF,IAAI,aAAa,GAAG,EAAE,CACpB,GAAG,CAAC,0BAA0B,CAAC,EAC/B,GAAG,CAAC,4BAA4B,CAAC,EACjC,IAAI,CACL,CAAC;IAEF,GAAG,CAAC,YAAY,CAAC;SACd,KAAK,CAAC,gBAAgB,EAAE,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAE7D,GAAG,CAAC,eAAe,CAAC;SACjB,KAAK,CAAC,gBAAgB,EAAE,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAE7D,GAAG,CAAC,UAAU,CAAC;SACZ,KAAK,CAAC,YAAY,EAAE,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;SACrD,KAAK,CAAC,gBAAgB,EAAE,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5D,GAAG,CAAC,eAAe,CAAC;SACjB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,CAAC;SACjD,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC;SAC3C,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;SAC3C,KAAK,CAAC,gBAAgB,EAAE,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAE7D,CAAC,kBAAkB;QAClB,iBAAiB;KACjB,CAAC,OAAO,CAAC,UAAA,QAAQ;QAChB,GAAG,CAAC,QAAQ,CAAC;aACV,KAAK,CAAC,gBAAgB,EAAE,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;aACxD,KAAK,CAAC,qBAAqB,EACrB,EAAE,CAAC,GAAG,CAAC,4BAA4B,CAAC,EACjC,GAAG,CAAC,8BAA8B,CAAC,EACnC,IAAI,CAAC,EACR,QAAQ,CAAC,MAAM,CAAC,CAAC;aACvB,KAAK,CAAC,YAAY,EACZ,EAAE,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,EACxB,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC,CAAC,EAC1C,QAAQ,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAjDD,4BAiDC;AAAA,CAAC;AAEF,IAAA,8BAAqB,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
import { Fork } from "../types";
export default function (fork: Fork): void;

View File

@@ -0,0 +1,369 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var babel_core_1 = tslib_1.__importDefault(require("./babel-core"));
var type_annotations_1 = tslib_1.__importDefault(require("./type-annotations"));
var types_1 = tslib_1.__importDefault(require("../types"));
var shared_1 = tslib_1.__importStar(require("../shared"));
function default_1(fork) {
// Since TypeScript is parsed by Babylon, include the core Babylon types
// but omit the Flow-related types.
fork.use(babel_core_1.default);
fork.use(type_annotations_1.default);
var types = fork.use(types_1.default);
var n = types.namedTypes;
var def = types.Type.def;
var or = types.Type.or;
var defaults = fork.use(shared_1.default).defaults;
var StringLiteral = types.Type.from(function (value, deep) {
if (n.StringLiteral &&
n.StringLiteral.check(value, deep)) {
return true;
}
if (n.Literal &&
n.Literal.check(value, deep) &&
typeof value.value === "string") {
return true;
}
return false;
}, "StringLiteral");
def("TSType")
.bases("Node");
var TSEntityName = or(def("Identifier"), def("TSQualifiedName"));
def("TSTypeReference")
.bases("TSType", "TSHasOptionalTypeParameterInstantiation")
.build("typeName", "typeParameters")
.field("typeName", TSEntityName);
// An abstract (non-buildable) base type that provide a commonly-needed
// optional .typeParameters field.
def("TSHasOptionalTypeParameterInstantiation")
.field("typeParameters", or(def("TSTypeParameterInstantiation"), null), defaults["null"]);
// An abstract (non-buildable) base type that provide a commonly-needed
// optional .typeParameters field.
def("TSHasOptionalTypeParameters")
.field("typeParameters", or(def("TSTypeParameterDeclaration"), null, void 0), defaults["null"]);
// An abstract (non-buildable) base type that provide a commonly-needed
// optional .typeAnnotation field.
def("TSHasOptionalTypeAnnotation")
.field("typeAnnotation", or(def("TSTypeAnnotation"), null), defaults["null"]);
def("TSQualifiedName")
.bases("Node")
.build("left", "right")
.field("left", TSEntityName)
.field("right", TSEntityName);
def("TSAsExpression")
.bases("Expression", "Pattern")
.build("expression", "typeAnnotation")
.field("expression", def("Expression"))
.field("typeAnnotation", def("TSType"))
.field("extra", or({ parenthesized: Boolean }, null), defaults["null"]);
def("TSTypeCastExpression")
.bases("Expression")
.build("expression", "typeAnnotation")
.field("expression", def("Expression"))
.field("typeAnnotation", def("TSType"));
def("TSSatisfiesExpression")
.bases("Expression", "Pattern")
.build("expression", "typeAnnotation")
.field("expression", def("Expression"))
.field("typeAnnotation", def("TSType"));
def("TSNonNullExpression")
.bases("Expression", "Pattern")
.build("expression")
.field("expression", def("Expression"));
[
"TSAnyKeyword",
"TSBigIntKeyword",
"TSBooleanKeyword",
"TSNeverKeyword",
"TSNullKeyword",
"TSNumberKeyword",
"TSObjectKeyword",
"TSStringKeyword",
"TSSymbolKeyword",
"TSUndefinedKeyword",
"TSUnknownKeyword",
"TSVoidKeyword",
"TSIntrinsicKeyword",
"TSThisType",
].forEach(function (keywordType) {
def(keywordType)
.bases("TSType")
.build();
});
def("TSArrayType")
.bases("TSType")
.build("elementType")
.field("elementType", def("TSType"));
def("TSLiteralType")
.bases("TSType")
.build("literal")
.field("literal", or(def("NumericLiteral"), def("StringLiteral"), def("BooleanLiteral"), def("TemplateLiteral"), def("UnaryExpression"), def("BigIntLiteral")));
def("TemplateLiteral")
// The TemplateLiteral type appears to be reused for TypeScript template
// literal types (instead of introducing a new TSTemplateLiteralType type),
// so we allow the templateLiteral.expressions array to be either all
// expressions or all TypeScript types.
.field("expressions", or([def("Expression")], [def("TSType")]));
["TSUnionType",
"TSIntersectionType",
].forEach(function (typeName) {
def(typeName)
.bases("TSType")
.build("types")
.field("types", [def("TSType")]);
});
def("TSConditionalType")
.bases("TSType")
.build("checkType", "extendsType", "trueType", "falseType")
.field("checkType", def("TSType"))
.field("extendsType", def("TSType"))
.field("trueType", def("TSType"))
.field("falseType", def("TSType"));
def("TSInferType")
.bases("TSType")
.build("typeParameter")
.field("typeParameter", def("TSTypeParameter"));
def("TSParenthesizedType")
.bases("TSType")
.build("typeAnnotation")
.field("typeAnnotation", def("TSType"));
var ParametersType = [or(def("Identifier"), def("RestElement"), def("ArrayPattern"), def("ObjectPattern"))];
["TSFunctionType",
"TSConstructorType",
].forEach(function (typeName) {
def(typeName)
.bases("TSType", "TSHasOptionalTypeParameters", "TSHasOptionalTypeAnnotation")
.build("parameters")
.field("parameters", ParametersType);
});
def("TSDeclareFunction")
.bases("Declaration", "TSHasOptionalTypeParameters")
.build("id", "params", "returnType")
.field("declare", Boolean, defaults["false"])
.field("async", Boolean, defaults["false"])
.field("generator", Boolean, defaults["false"])
.field("id", or(def("Identifier"), null), defaults["null"])
.field("params", [def("Pattern")])
// tSFunctionTypeAnnotationCommon
.field("returnType", or(def("TSTypeAnnotation"), def("Noop"), // Still used?
null), defaults["null"]);
def("TSDeclareMethod")
.bases("Declaration", "TSHasOptionalTypeParameters")
.build("key", "params", "returnType")
.field("async", Boolean, defaults["false"])
.field("generator", Boolean, defaults["false"])
.field("params", [def("Pattern")])
// classMethodOrPropertyCommon
.field("abstract", Boolean, defaults["false"])
.field("accessibility", or("public", "private", "protected", void 0), defaults["undefined"])
.field("static", Boolean, defaults["false"])
.field("computed", Boolean, defaults["false"])
.field("optional", Boolean, defaults["false"])
.field("key", or(def("Identifier"), def("StringLiteral"), def("NumericLiteral"),
// Only allowed if .computed is true.
def("Expression")))
// classMethodOrDeclareMethodCommon
.field("kind", or("get", "set", "method", "constructor"), function getDefault() { return "method"; })
.field("access", // Not "accessibility"?
or("public", "private", "protected", void 0), defaults["undefined"])
.field("decorators", or([def("Decorator")], null), defaults["null"])
// tSFunctionTypeAnnotationCommon
.field("returnType", or(def("TSTypeAnnotation"), def("Noop"), // Still used?
null), defaults["null"]);
def("TSMappedType")
.bases("TSType")
.build("typeParameter", "typeAnnotation")
.field("readonly", or(Boolean, "+", "-"), defaults["false"])
.field("typeParameter", def("TSTypeParameter"))
.field("optional", or(Boolean, "+", "-"), defaults["false"])
.field("typeAnnotation", or(def("TSType"), null), defaults["null"]);
def("TSTupleType")
.bases("TSType")
.build("elementTypes")
.field("elementTypes", [or(def("TSType"), def("TSNamedTupleMember"))]);
def("TSNamedTupleMember")
.bases("TSType")
.build("label", "elementType", "optional")
.field("label", def("Identifier"))
.field("optional", Boolean, defaults["false"])
.field("elementType", def("TSType"));
def("TSRestType")
.bases("TSType")
.build("typeAnnotation")
.field("typeAnnotation", def("TSType"));
def("TSOptionalType")
.bases("TSType")
.build("typeAnnotation")
.field("typeAnnotation", def("TSType"));
def("TSIndexedAccessType")
.bases("TSType")
.build("objectType", "indexType")
.field("objectType", def("TSType"))
.field("indexType", def("TSType"));
def("TSTypeOperator")
.bases("TSType")
.build("operator")
.field("operator", String)
.field("typeAnnotation", def("TSType"));
def("TSTypeAnnotation")
.bases("Node")
.build("typeAnnotation")
.field("typeAnnotation", or(def("TSType"), def("TSTypeAnnotation")));
def("TSIndexSignature")
.bases("Declaration", "TSHasOptionalTypeAnnotation")
.build("parameters", "typeAnnotation")
.field("parameters", [def("Identifier")]) // Length === 1
.field("readonly", Boolean, defaults["false"]);
def("TSPropertySignature")
.bases("Declaration", "TSHasOptionalTypeAnnotation")
.build("key", "typeAnnotation", "optional")
.field("key", def("Expression"))
.field("computed", Boolean, defaults["false"])
.field("readonly", Boolean, defaults["false"])
.field("optional", Boolean, defaults["false"])
.field("initializer", or(def("Expression"), null), defaults["null"]);
def("TSMethodSignature")
.bases("Declaration", "TSHasOptionalTypeParameters", "TSHasOptionalTypeAnnotation")
.build("key", "parameters", "typeAnnotation")
.field("key", def("Expression"))
.field("computed", Boolean, defaults["false"])
.field("optional", Boolean, defaults["false"])
.field("parameters", ParametersType);
def("TSTypePredicate")
.bases("TSTypeAnnotation", "TSType")
.build("parameterName", "typeAnnotation", "asserts")
.field("parameterName", or(def("Identifier"), def("TSThisType")))
.field("typeAnnotation", or(def("TSTypeAnnotation"), null), defaults["null"])
.field("asserts", Boolean, defaults["false"]);
["TSCallSignatureDeclaration",
"TSConstructSignatureDeclaration",
].forEach(function (typeName) {
def(typeName)
.bases("Declaration", "TSHasOptionalTypeParameters", "TSHasOptionalTypeAnnotation")
.build("parameters", "typeAnnotation")
.field("parameters", ParametersType);
});
def("TSEnumMember")
.bases("Node")
.build("id", "initializer")
.field("id", or(def("Identifier"), StringLiteral))
.field("initializer", or(def("Expression"), null), defaults["null"]);
def("TSTypeQuery")
.bases("TSType")
.build("exprName")
.field("exprName", or(TSEntityName, def("TSImportType")));
// Inferred from Babylon's tsParseTypeMember method.
var TSTypeMember = or(def("TSCallSignatureDeclaration"), def("TSConstructSignatureDeclaration"), def("TSIndexSignature"), def("TSMethodSignature"), def("TSPropertySignature"));
def("TSTypeLiteral")
.bases("TSType")
.build("members")
.field("members", [TSTypeMember]);
def("TSTypeParameter")
.bases("Identifier")
.build("name", "constraint", "default")
.field("name", or(def("Identifier"), String))
.field("constraint", or(def("TSType"), void 0), defaults["undefined"])
.field("default", or(def("TSType"), void 0), defaults["undefined"]);
def("TSTypeAssertion")
.bases("Expression", "Pattern")
.build("typeAnnotation", "expression")
.field("typeAnnotation", def("TSType"))
.field("expression", def("Expression"))
.field("extra", or({ parenthesized: Boolean }, null), defaults["null"]);
def("TSTypeParameterDeclaration")
.bases("Declaration")
.build("params")
.field("params", [def("TSTypeParameter")]);
def("TSInstantiationExpression")
.bases("Expression", "TSHasOptionalTypeParameterInstantiation")
.build("expression", "typeParameters")
.field("expression", def("Expression"));
def("TSTypeParameterInstantiation")
.bases("Node")
.build("params")
.field("params", [def("TSType")]);
def("TSEnumDeclaration")
.bases("Declaration")
.build("id", "members")
.field("id", def("Identifier"))
.field("const", Boolean, defaults["false"])
.field("declare", Boolean, defaults["false"])
.field("members", [def("TSEnumMember")])
.field("initializer", or(def("Expression"), null), defaults["null"]);
def("TSTypeAliasDeclaration")
.bases("Declaration", "TSHasOptionalTypeParameters")
.build("id", "typeAnnotation")
.field("id", def("Identifier"))
.field("declare", Boolean, defaults["false"])
.field("typeAnnotation", def("TSType"));
def("TSModuleBlock")
.bases("Node")
.build("body")
.field("body", [def("Statement")]);
def("TSModuleDeclaration")
.bases("Declaration")
.build("id", "body")
.field("id", or(StringLiteral, TSEntityName))
.field("declare", Boolean, defaults["false"])
.field("global", Boolean, defaults["false"])
.field("body", or(def("TSModuleBlock"), def("TSModuleDeclaration"), null), defaults["null"]);
def("TSImportType")
.bases("TSType", "TSHasOptionalTypeParameterInstantiation")
.build("argument", "qualifier", "typeParameters")
.field("argument", StringLiteral)
.field("qualifier", or(TSEntityName, void 0), defaults["undefined"]);
def("TSImportEqualsDeclaration")
.bases("Declaration")
.build("id", "moduleReference")
.field("id", def("Identifier"))
.field("isExport", Boolean, defaults["false"])
.field("moduleReference", or(TSEntityName, def("TSExternalModuleReference")));
def("TSExternalModuleReference")
.bases("Declaration")
.build("expression")
.field("expression", StringLiteral);
def("TSExportAssignment")
.bases("Statement")
.build("expression")
.field("expression", def("Expression"));
def("TSNamespaceExportDeclaration")
.bases("Declaration")
.build("id")
.field("id", def("Identifier"));
def("TSInterfaceBody")
.bases("Node")
.build("body")
.field("body", [TSTypeMember]);
def("TSExpressionWithTypeArguments")
.bases("TSType", "TSHasOptionalTypeParameterInstantiation")
.build("expression", "typeParameters")
.field("expression", TSEntityName);
def("TSInterfaceDeclaration")
.bases("Declaration", "TSHasOptionalTypeParameters")
.build("id", "body")
.field("id", TSEntityName)
.field("declare", Boolean, defaults["false"])
.field("extends", or([def("TSExpressionWithTypeArguments")], null), defaults["null"])
.field("body", def("TSInterfaceBody"));
def("TSParameterProperty")
.bases("Pattern")
.build("parameter")
.field("accessibility", or("public", "private", "protected", void 0), defaults["undefined"])
.field("readonly", Boolean, defaults["false"])
.field("parameter", or(def("Identifier"), def("AssignmentPattern")));
def("ClassProperty")
.field("access", // Not "accessibility"?
or("public", "private", "protected", void 0), defaults["undefined"]);
def("ClassAccessorProperty")
.bases("Declaration", "TSHasOptionalTypeAnnotation");
// Defined already in es6 and babel-core.
def("ClassBody")
.field("body", [or(def("MethodDefinition"), def("VariableDeclarator"), def("ClassPropertyDefinition"), def("ClassProperty"), def("ClassPrivateProperty"), def("ClassAccessorProperty"), def("ClassMethod"), def("ClassPrivateMethod"), def("StaticBlock"),
// Just need to add these types:
def("TSDeclareMethod"), TSTypeMember)]);
}
exports.default = default_1;
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=typescript.js.map

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More