@runeditrun/rer 0.2.82 → 0.2.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/authoring.mjs +1 -0
- package/cli/contract.mjs +1 -1
- package/cli/demo-host.mjs +5 -1
- package/cli/demo.mjs +6 -1
- package/cli/export.mjs +1 -1
- package/cli/parse.mjs +1 -1
- package/edition-authoring/base-copies.mjs +72 -25
- package/edition-authoring/copy-checkout.mjs +7 -120
- package/edition-authoring/edition-migrations.mjs +41 -0
- package/edition-authoring/files.mjs +67 -0
- package/edition-authoring/lock.mjs +2 -2
- package/edition-authoring/module-closure.mjs +232 -0
- package/edition-authoring/module-edges.mjs +100 -0
- package/edition-authoring/module-resolution.mjs +66 -0
- package/edition-authoring/module-syntax.mjs +57 -0
- package/edition-authoring/package-target.mjs +92 -0
- package/edition-authoring/runtime-dependencies.mjs +74 -97
- package/edition-authoring/vendor/babel-parser/LICENSE +22 -0
- package/edition-authoring/vendor/babel-parser/README.md +21 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-string-parser/index.mjs +292 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/identifier.mjs +66 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/index.mjs +13 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/keyword.mjs +31 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/index.mjs +99 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/options.mjs +81 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/bind-operator-errors.mjs +8 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/module-errors.mjs +15 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/parse-expression-errors.mjs +10 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/pipeline-operator-errors.mjs +29 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/standard-errors.mjs +224 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/strict-mode-errors.mjs +17 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/to-node-description.mjs +31 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error.mjs +114 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/base.mjs +34 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/comments.mjs +199 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/expression.mjs +1794 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/index.mjs +76 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/lval.mjs +439 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/node.mjs +111 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/statement.mjs +1962 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/util.mjs +244 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugin-utils.mjs +116 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/estree.mjs +417 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/index.mjs +2412 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/scope.mjs +37 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/index.mjs +420 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/xhtml.mjs +261 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/placeholders.mjs +205 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/index.mjs +2889 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/scope.mjs +115 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/v8intrinsic.mjs +26 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/context.mjs +22 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/index.mjs +1037 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/state.mjs +178 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/types.mjs +583 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/types.mjs +1 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/class-scope.mjs +82 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/expression-scope.mjs +121 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/identifier.mjs +23 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/location.mjs +34 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/production-parameter.mjs +40 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/scope.mjs +173 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/scopeflags.mjs +66 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/whitespace.mjs +61 -0
- package/edition-authoring/vendor/yaml/LICENSE +13 -0
- package/edition-authoring/vendor/yaml/README.md +11 -0
- package/edition-authoring/vendor/yaml/compose/compose-collection.mjs +88 -0
- package/edition-authoring/vendor/yaml/compose/compose-doc.mjs +43 -0
- package/edition-authoring/vendor/yaml/compose/compose-node.mjs +110 -0
- package/edition-authoring/vendor/yaml/compose/compose-scalar.mjs +86 -0
- package/edition-authoring/vendor/yaml/compose/composer.mjs +218 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-map.mjs +115 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-scalar.mjs +198 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-seq.mjs +49 -0
- package/edition-authoring/vendor/yaml/compose/resolve-end.mjs +37 -0
- package/edition-authoring/vendor/yaml/compose/resolve-flow-collection.mjs +207 -0
- package/edition-authoring/vendor/yaml/compose/resolve-flow-scalar.mjs +228 -0
- package/edition-authoring/vendor/yaml/compose/resolve-props.mjs +148 -0
- package/edition-authoring/vendor/yaml/compose/util-contains-newline.mjs +34 -0
- package/edition-authoring/vendor/yaml/compose/util-empty-scalar-position.mjs +27 -0
- package/edition-authoring/vendor/yaml/compose/util-flow-indent-check.mjs +15 -0
- package/edition-authoring/vendor/yaml/compose/util-map-includes.mjs +13 -0
- package/edition-authoring/vendor/yaml/doc/Document.mjs +333 -0
- package/edition-authoring/vendor/yaml/doc/anchors.mjs +74 -0
- package/edition-authoring/vendor/yaml/doc/applyReviver.mjs +54 -0
- package/edition-authoring/vendor/yaml/doc/createNode.mjs +88 -0
- package/edition-authoring/vendor/yaml/doc/directives.mjs +176 -0
- package/edition-authoring/vendor/yaml/errors.mjs +57 -0
- package/edition-authoring/vendor/yaml/index.mjs +17 -0
- package/edition-authoring/vendor/yaml/log.mjs +11 -0
- package/edition-authoring/vendor/yaml/nodes/Alias.mjs +119 -0
- package/edition-authoring/vendor/yaml/nodes/Collection.mjs +147 -0
- package/edition-authoring/vendor/yaml/nodes/Node.mjs +38 -0
- package/edition-authoring/vendor/yaml/nodes/Pair.mjs +36 -0
- package/edition-authoring/vendor/yaml/nodes/Scalar.mjs +24 -0
- package/edition-authoring/vendor/yaml/nodes/YAMLMap.mjs +144 -0
- package/edition-authoring/vendor/yaml/nodes/YAMLSeq.mjs +113 -0
- package/edition-authoring/vendor/yaml/nodes/addPairToJSMap.mjs +62 -0
- package/edition-authoring/vendor/yaml/nodes/identity.mjs +36 -0
- package/edition-authoring/vendor/yaml/nodes/toJS.mjs +35 -0
- package/edition-authoring/vendor/yaml/parse/cst-scalar.mjs +214 -0
- package/edition-authoring/vendor/yaml/parse/cst-stringify.mjs +61 -0
- package/edition-authoring/vendor/yaml/parse/cst-visit.mjs +97 -0
- package/edition-authoring/vendor/yaml/parse/cst.mjs +98 -0
- package/edition-authoring/vendor/yaml/parse/lexer.mjs +722 -0
- package/edition-authoring/vendor/yaml/parse/line-counter.mjs +39 -0
- package/edition-authoring/vendor/yaml/parse/parser.mjs +975 -0
- package/edition-authoring/vendor/yaml/public-api.mjs +102 -0
- package/edition-authoring/vendor/yaml/schema/Schema.mjs +37 -0
- package/edition-authoring/vendor/yaml/schema/common/map.mjs +17 -0
- package/edition-authoring/vendor/yaml/schema/common/null.mjs +15 -0
- package/edition-authoring/vendor/yaml/schema/common/seq.mjs +17 -0
- package/edition-authoring/vendor/yaml/schema/common/string.mjs +14 -0
- package/edition-authoring/vendor/yaml/schema/core/bool.mjs +19 -0
- package/edition-authoring/vendor/yaml/schema/core/float.mjs +43 -0
- package/edition-authoring/vendor/yaml/schema/core/int.mjs +38 -0
- package/edition-authoring/vendor/yaml/schema/core/schema.mjs +23 -0
- package/edition-authoring/vendor/yaml/schema/json/schema.mjs +62 -0
- package/edition-authoring/vendor/yaml/schema/tags.mjs +96 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/binary.mjs +59 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/bool.mjs +26 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/float.mjs +46 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/int.mjs +71 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/merge.mjs +67 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/omap.mjs +74 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/pairs.mjs +78 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/schema.mjs +39 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/set.mjs +93 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/timestamp.mjs +101 -0
- package/edition-authoring/vendor/yaml/stringify/foldFlowLines.mjs +146 -0
- package/edition-authoring/vendor/yaml/stringify/stringify.mjs +130 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyCollection.mjs +155 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyComment.mjs +20 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyDocument.mjs +85 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyNumber.mjs +25 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyPair.mjs +150 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyString.mjs +338 -0
- package/edition-authoring/vendor/yaml/util.mjs +11 -0
- package/edition-authoring/vendor/yaml/visit.mjs +233 -0
- package/edition-authoring/workflow-copies.mjs +125 -0
- package/edition-authoring/workflow-scripts.mjs +112 -0
- package/foundation/runtime/contract-docs.mjs +753 -0
- package/global/CHANGELOG.md +33 -2
- package/modules/demo/declaration.mjs +1 -4
- package/modules/demo/vite.mjs +1 -1
- package/modules/deploy-kit/README.md +1 -1
- package/modules/deploy-kit/templates.mjs +3 -3
- package/onboarding/operator-installer.mjs +2 -2
- package/package.json +1 -1
- package/scripts/publish-check/README.md +6 -0
- package/scripts/publish-check/history_scan.py +5 -3
- package/scripts/publish-check/hygiene_config.py +2 -1
- package/scripts/publish-check/report.py +9 -3
- package/scripts/publish-check/third-party-notices.json +13 -0
- package/scripts/publish-check/third_party_notices.py +38 -0
- package/scripts/publish-check/tree_scan.py +6 -0
- package/scripts/publish-check.mjs +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Generated from Babel v7.29.8 (MIT); see README.md.
|
|
2
|
+
import { getOptions, OptionFlags } from "../options.mjs";
|
|
3
|
+
import StatementParser from "./statement.mjs";
|
|
4
|
+
import ScopeHandler from "../util/scope.mjs";
|
|
5
|
+
class Parser extends StatementParser {
|
|
6
|
+
constructor(options, input, pluginsMap) {
|
|
7
|
+
const normalizedOptions = getOptions(options);
|
|
8
|
+
super(normalizedOptions, input);
|
|
9
|
+
this.options = normalizedOptions;
|
|
10
|
+
this.initializeScopes();
|
|
11
|
+
this.plugins = pluginsMap;
|
|
12
|
+
this.filename = normalizedOptions.sourceFilename;
|
|
13
|
+
this.startIndex = normalizedOptions.startIndex;
|
|
14
|
+
let optionFlags = 0;
|
|
15
|
+
if (normalizedOptions.allowAwaitOutsideFunction) {
|
|
16
|
+
optionFlags |= OptionFlags.AllowAwaitOutsideFunction;
|
|
17
|
+
}
|
|
18
|
+
if (normalizedOptions.allowReturnOutsideFunction) {
|
|
19
|
+
optionFlags |= OptionFlags.AllowReturnOutsideFunction;
|
|
20
|
+
}
|
|
21
|
+
if (normalizedOptions.allowImportExportEverywhere) {
|
|
22
|
+
optionFlags |= OptionFlags.AllowImportExportEverywhere;
|
|
23
|
+
}
|
|
24
|
+
if (normalizedOptions.allowSuperOutsideMethod) {
|
|
25
|
+
optionFlags |= OptionFlags.AllowSuperOutsideMethod;
|
|
26
|
+
}
|
|
27
|
+
if (normalizedOptions.allowUndeclaredExports) {
|
|
28
|
+
optionFlags |= OptionFlags.AllowUndeclaredExports;
|
|
29
|
+
}
|
|
30
|
+
if (normalizedOptions.allowNewTargetOutsideFunction) {
|
|
31
|
+
optionFlags |= OptionFlags.AllowNewTargetOutsideFunction;
|
|
32
|
+
}
|
|
33
|
+
if (normalizedOptions.allowYieldOutsideFunction) {
|
|
34
|
+
optionFlags |= OptionFlags.AllowYieldOutsideFunction;
|
|
35
|
+
}
|
|
36
|
+
if (normalizedOptions.ranges) {
|
|
37
|
+
optionFlags |= OptionFlags.Ranges;
|
|
38
|
+
}
|
|
39
|
+
if (normalizedOptions.tokens) {
|
|
40
|
+
optionFlags |= OptionFlags.Tokens;
|
|
41
|
+
}
|
|
42
|
+
if (normalizedOptions.createImportExpressions) {
|
|
43
|
+
optionFlags |= OptionFlags.CreateImportExpressions;
|
|
44
|
+
}
|
|
45
|
+
if (normalizedOptions.createParenthesizedExpressions) {
|
|
46
|
+
optionFlags |= OptionFlags.CreateParenthesizedExpressions;
|
|
47
|
+
}
|
|
48
|
+
if (normalizedOptions.errorRecovery) {
|
|
49
|
+
optionFlags |= OptionFlags.ErrorRecovery;
|
|
50
|
+
}
|
|
51
|
+
if (normalizedOptions.attachComment) {
|
|
52
|
+
optionFlags |= OptionFlags.AttachComment;
|
|
53
|
+
}
|
|
54
|
+
if (normalizedOptions.annexB) {
|
|
55
|
+
optionFlags |= OptionFlags.AnnexB;
|
|
56
|
+
}
|
|
57
|
+
this.optionFlags = optionFlags;
|
|
58
|
+
}
|
|
59
|
+
getScopeHandler() {
|
|
60
|
+
return ScopeHandler;
|
|
61
|
+
}
|
|
62
|
+
parse() {
|
|
63
|
+
this.enterInitialScopes();
|
|
64
|
+
const file = this.startNode();
|
|
65
|
+
const program = this.startNode();
|
|
66
|
+
this.nextToken();
|
|
67
|
+
file.errors = null;
|
|
68
|
+
const result = this.parseTopLevel(file, program);
|
|
69
|
+
result.errors = this.state.errors;
|
|
70
|
+
result.comments.length = this.state.commentsLen;
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
Parser as default
|
|
76
|
+
};
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
// Generated from Babel v7.29.8 (MIT); see README.md.
|
|
2
|
+
import { tt } from "../tokenizer/types.mjs";
|
|
3
|
+
import { isStrictBindOnlyReservedWord, isStrictBindReservedWord } from "../util/identifier.mjs";
|
|
4
|
+
import { NodeUtils } from "./node.mjs";
|
|
5
|
+
import { BindingFlag } from "../util/scopeflags.mjs";
|
|
6
|
+
import { Errors } from "../parse-error.mjs";
|
|
7
|
+
import { OptionFlags } from "../options.mjs";
|
|
8
|
+
const unwrapParenthesizedExpression = (node) => {
|
|
9
|
+
return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
|
|
10
|
+
};
|
|
11
|
+
var ParseBindingListFlags = {
|
|
12
|
+
ALLOW_EMPTY: 1,
|
|
13
|
+
IS_FUNCTION_PARAMS: 2,
|
|
14
|
+
IS_CONSTRUCTOR_PARAMS: 4
|
|
15
|
+
};
|
|
16
|
+
class LValParser extends NodeUtils {
|
|
17
|
+
toAssignable(node, isLHS = false) {
|
|
18
|
+
let parenthesized = void 0;
|
|
19
|
+
if (node.type === "ParenthesizedExpression" || node.extra?.parenthesized) {
|
|
20
|
+
parenthesized = unwrapParenthesizedExpression(node);
|
|
21
|
+
if (isLHS) {
|
|
22
|
+
if (parenthesized.type === "Identifier") {
|
|
23
|
+
this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
|
|
24
|
+
} else if (parenthesized.type !== "CallExpression" && parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
|
|
25
|
+
this.raise(Errors.InvalidParenthesizedAssignment, node);
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
this.raise(Errors.InvalidParenthesizedAssignment, node);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
switch (node.type) {
|
|
32
|
+
case "Identifier":
|
|
33
|
+
case "ObjectPattern":
|
|
34
|
+
case "ArrayPattern":
|
|
35
|
+
case "AssignmentPattern":
|
|
36
|
+
case "RestElement":
|
|
37
|
+
case "VoidPattern":
|
|
38
|
+
break;
|
|
39
|
+
case "ObjectExpression":
|
|
40
|
+
this.castNodeTo(node, "ObjectPattern");
|
|
41
|
+
for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
|
|
42
|
+
const prop = node.properties[i];
|
|
43
|
+
const isLast = i === last;
|
|
44
|
+
this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
|
|
45
|
+
if (isLast && prop.type === "RestElement" && node.extra?.trailingCommaLoc) {
|
|
46
|
+
this.raise(Errors.RestTrailingComma, node.extra.trailingCommaLoc);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
case "ObjectProperty": {
|
|
51
|
+
const {
|
|
52
|
+
key,
|
|
53
|
+
value
|
|
54
|
+
} = node;
|
|
55
|
+
if (this.isPrivateName(key)) {
|
|
56
|
+
this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
|
|
57
|
+
}
|
|
58
|
+
this.toAssignable(value, isLHS);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case "SpreadElement": {
|
|
62
|
+
throw new Error("Internal @babel/parser error (this is a bug, please report it). SpreadElement should be converted by .toAssignable's caller.");
|
|
63
|
+
}
|
|
64
|
+
case "ArrayExpression":
|
|
65
|
+
this.castNodeTo(node, "ArrayPattern");
|
|
66
|
+
this.toAssignableList(node.elements, node.extra?.trailingCommaLoc, isLHS);
|
|
67
|
+
break;
|
|
68
|
+
case "AssignmentExpression":
|
|
69
|
+
if (node.operator !== "=") {
|
|
70
|
+
this.raise(Errors.MissingEqInAssignment, node.left.loc.end);
|
|
71
|
+
}
|
|
72
|
+
this.castNodeTo(node, "AssignmentPattern");
|
|
73
|
+
delete node.operator;
|
|
74
|
+
if (node.left.type === "VoidPattern") {
|
|
75
|
+
this.raise(Errors.VoidPatternInitializer, node.left);
|
|
76
|
+
}
|
|
77
|
+
this.toAssignable(node.left, isLHS);
|
|
78
|
+
break;
|
|
79
|
+
case "ParenthesizedExpression":
|
|
80
|
+
this.toAssignable(parenthesized, isLHS);
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
toAssignableObjectExpressionProp(prop, isLast, isLHS) {
|
|
86
|
+
if (prop.type === "ObjectMethod") {
|
|
87
|
+
this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, prop.key);
|
|
88
|
+
} else if (prop.type === "SpreadElement") {
|
|
89
|
+
this.castNodeTo(prop, "RestElement");
|
|
90
|
+
const arg = prop.argument;
|
|
91
|
+
this.checkToRestConversion(arg, false);
|
|
92
|
+
this.toAssignable(arg, isLHS);
|
|
93
|
+
if (!isLast) {
|
|
94
|
+
this.raise(Errors.RestTrailingComma, prop);
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
this.toAssignable(prop, isLHS);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
toAssignableList(exprList, trailingCommaLoc, isLHS) {
|
|
101
|
+
const end = exprList.length - 1;
|
|
102
|
+
for (let i = 0; i <= end; i++) {
|
|
103
|
+
const elt = exprList[i];
|
|
104
|
+
if (!elt) continue;
|
|
105
|
+
this.toAssignableListItem(exprList, i, isLHS);
|
|
106
|
+
if (elt.type === "RestElement") {
|
|
107
|
+
if (i < end) {
|
|
108
|
+
this.raise(Errors.RestTrailingComma, elt);
|
|
109
|
+
} else if (trailingCommaLoc) {
|
|
110
|
+
this.raise(Errors.RestTrailingComma, trailingCommaLoc);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
toAssignableListItem(exprList, index, isLHS) {
|
|
116
|
+
const node = exprList[index];
|
|
117
|
+
if (node.type === "SpreadElement") {
|
|
118
|
+
this.castNodeTo(node, "RestElement");
|
|
119
|
+
const arg = node.argument;
|
|
120
|
+
this.checkToRestConversion(arg, true);
|
|
121
|
+
this.toAssignable(arg, isLHS);
|
|
122
|
+
} else {
|
|
123
|
+
this.toAssignable(node, isLHS);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
isAssignable(node, isBinding) {
|
|
127
|
+
switch (node.type) {
|
|
128
|
+
case "Identifier":
|
|
129
|
+
case "ObjectPattern":
|
|
130
|
+
case "ArrayPattern":
|
|
131
|
+
case "AssignmentPattern":
|
|
132
|
+
case "RestElement":
|
|
133
|
+
case "VoidPattern":
|
|
134
|
+
return true;
|
|
135
|
+
case "ObjectExpression": {
|
|
136
|
+
const last = node.properties.length - 1;
|
|
137
|
+
return node.properties.every((prop, i) => {
|
|
138
|
+
return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
case "ObjectProperty":
|
|
142
|
+
return this.isAssignable(node.value);
|
|
143
|
+
case "SpreadElement":
|
|
144
|
+
return this.isAssignable(node.argument);
|
|
145
|
+
case "ArrayExpression":
|
|
146
|
+
return node.elements.every((element) => element === null || this.isAssignable(element));
|
|
147
|
+
case "AssignmentExpression":
|
|
148
|
+
return node.operator === "=";
|
|
149
|
+
case "ParenthesizedExpression":
|
|
150
|
+
return this.isAssignable(node.expression);
|
|
151
|
+
case "MemberExpression":
|
|
152
|
+
case "OptionalMemberExpression":
|
|
153
|
+
return !isBinding;
|
|
154
|
+
default:
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Retain the upstream parser interface and bindings.
|
|
159
|
+
toReferencedList(exprList, isParenthesizedExpr) {
|
|
160
|
+
return exprList;
|
|
161
|
+
}
|
|
162
|
+
toReferencedListDeep(exprList, isParenthesizedExpr) {
|
|
163
|
+
this.toReferencedList(exprList, isParenthesizedExpr);
|
|
164
|
+
for (const expr of exprList) {
|
|
165
|
+
if (expr?.type === "ArrayExpression") {
|
|
166
|
+
this.toReferencedListDeep(expr.elements);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
parseSpread(refExpressionErrors) {
|
|
171
|
+
const node = this.startNode();
|
|
172
|
+
this.next();
|
|
173
|
+
node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, void 0);
|
|
174
|
+
return this.finishNode(node, "SpreadElement");
|
|
175
|
+
}
|
|
176
|
+
parseRestBinding() {
|
|
177
|
+
const node = this.startNode();
|
|
178
|
+
this.next();
|
|
179
|
+
const argument = this.parseBindingAtom();
|
|
180
|
+
if (argument.type === "VoidPattern") {
|
|
181
|
+
this.raise(Errors.UnexpectedVoidPattern, argument);
|
|
182
|
+
}
|
|
183
|
+
node.argument = argument;
|
|
184
|
+
return this.finishNode(node, "RestElement");
|
|
185
|
+
}
|
|
186
|
+
parseBindingAtom() {
|
|
187
|
+
switch (this.state.type) {
|
|
188
|
+
case tt.bracketL: {
|
|
189
|
+
const node = this.startNode();
|
|
190
|
+
this.next();
|
|
191
|
+
node.elements = this.parseBindingList(tt.bracketR, 93, ParseBindingListFlags.ALLOW_EMPTY);
|
|
192
|
+
return this.finishNode(node, "ArrayPattern");
|
|
193
|
+
}
|
|
194
|
+
case tt.braceL:
|
|
195
|
+
return this.parseObjectLike(tt.braceR, true);
|
|
196
|
+
case tt._void:
|
|
197
|
+
return this.parseVoidPattern(null);
|
|
198
|
+
}
|
|
199
|
+
return this.parseIdentifier();
|
|
200
|
+
}
|
|
201
|
+
parseBindingList(close, closeCharCode, flags) {
|
|
202
|
+
const allowEmpty = flags & ParseBindingListFlags.ALLOW_EMPTY;
|
|
203
|
+
const elts = [];
|
|
204
|
+
let first = true;
|
|
205
|
+
while (!this.eat(close)) {
|
|
206
|
+
if (first) {
|
|
207
|
+
first = false;
|
|
208
|
+
} else {
|
|
209
|
+
this.expect(tt.comma);
|
|
210
|
+
}
|
|
211
|
+
if (allowEmpty && this.match(tt.comma)) {
|
|
212
|
+
elts.push(null);
|
|
213
|
+
} else if (this.eat(close)) {
|
|
214
|
+
break;
|
|
215
|
+
} else if (this.match(tt.ellipsis)) {
|
|
216
|
+
let rest = this.parseRestBinding();
|
|
217
|
+
if (this.hasPlugin("flow") || flags & ParseBindingListFlags.IS_FUNCTION_PARAMS) {
|
|
218
|
+
rest = this.parseFunctionParamType(rest);
|
|
219
|
+
}
|
|
220
|
+
elts.push(rest);
|
|
221
|
+
if (!this.checkCommaAfterRest(closeCharCode)) {
|
|
222
|
+
this.expect(close);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
const decorators = [];
|
|
227
|
+
if (flags & ParseBindingListFlags.IS_FUNCTION_PARAMS) {
|
|
228
|
+
if (this.match(tt.at) && this.hasPlugin("decorators")) {
|
|
229
|
+
this.raise(Errors.UnsupportedParameterDecorator, this.state.startLoc);
|
|
230
|
+
}
|
|
231
|
+
while (this.match(tt.at)) {
|
|
232
|
+
decorators.push(this.parseDecorator());
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
elts.push(this.parseBindingElement(flags, decorators));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return elts;
|
|
239
|
+
}
|
|
240
|
+
parseBindingRestProperty(prop) {
|
|
241
|
+
this.next();
|
|
242
|
+
if (this.hasPlugin("discardBinding") && this.match(tt._void)) {
|
|
243
|
+
prop.argument = this.parseVoidPattern(null);
|
|
244
|
+
this.raise(Errors.UnexpectedVoidPattern, prop.argument);
|
|
245
|
+
} else {
|
|
246
|
+
prop.argument = this.parseIdentifier();
|
|
247
|
+
}
|
|
248
|
+
this.checkCommaAfterRest(125);
|
|
249
|
+
return this.finishNode(prop, "RestElement");
|
|
250
|
+
}
|
|
251
|
+
parseBindingProperty() {
|
|
252
|
+
const {
|
|
253
|
+
type,
|
|
254
|
+
startLoc
|
|
255
|
+
} = this.state;
|
|
256
|
+
if (type === tt.ellipsis) {
|
|
257
|
+
return this.parseBindingRestProperty(this.startNode());
|
|
258
|
+
}
|
|
259
|
+
const prop = this.startNode();
|
|
260
|
+
if (type === tt.privateName) {
|
|
261
|
+
this.expectPlugin("destructuringPrivate", startLoc);
|
|
262
|
+
this.classScope.usePrivateName(this.state.value, startLoc);
|
|
263
|
+
prop.key = this.parsePrivateName();
|
|
264
|
+
} else {
|
|
265
|
+
this.parsePropertyName(prop);
|
|
266
|
+
}
|
|
267
|
+
prop.method = false;
|
|
268
|
+
return this.parseObjPropValue(prop, startLoc, false, false, true, false);
|
|
269
|
+
}
|
|
270
|
+
parseBindingElement(flags, decorators) {
|
|
271
|
+
const left = this.parseMaybeDefault();
|
|
272
|
+
if (this.hasPlugin("flow") || flags & ParseBindingListFlags.IS_FUNCTION_PARAMS) {
|
|
273
|
+
this.parseFunctionParamType(left);
|
|
274
|
+
}
|
|
275
|
+
if (decorators.length) {
|
|
276
|
+
left.decorators = decorators;
|
|
277
|
+
this.resetStartLocationFromNode(left, decorators[0]);
|
|
278
|
+
}
|
|
279
|
+
const elt = this.parseMaybeDefault(left.loc.start, left);
|
|
280
|
+
return elt;
|
|
281
|
+
}
|
|
282
|
+
parseFunctionParamType(param) {
|
|
283
|
+
return param;
|
|
284
|
+
}
|
|
285
|
+
parseMaybeDefault(startLoc, left) {
|
|
286
|
+
startLoc ??= this.state.startLoc;
|
|
287
|
+
left = left ?? this.parseBindingAtom();
|
|
288
|
+
if (!this.eat(tt.eq)) return left;
|
|
289
|
+
const node = this.startNodeAt(startLoc);
|
|
290
|
+
if (left.type === "VoidPattern") {
|
|
291
|
+
this.raise(Errors.VoidPatternInitializer, left);
|
|
292
|
+
}
|
|
293
|
+
node.left = left;
|
|
294
|
+
node.right = this.parseMaybeAssignAllowIn();
|
|
295
|
+
return this.finishNode(node, "AssignmentPattern");
|
|
296
|
+
}
|
|
297
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Retain the upstream parser interface and bindings.
|
|
298
|
+
isValidLVal(type, disallowCallExpression, isUnparenthesizedInAssign, binding) {
|
|
299
|
+
switch (type) {
|
|
300
|
+
case "AssignmentPattern":
|
|
301
|
+
return "left";
|
|
302
|
+
case "RestElement":
|
|
303
|
+
return "argument";
|
|
304
|
+
case "ObjectProperty":
|
|
305
|
+
return "value";
|
|
306
|
+
case "ParenthesizedExpression":
|
|
307
|
+
return "expression";
|
|
308
|
+
case "ArrayPattern":
|
|
309
|
+
return "elements";
|
|
310
|
+
case "ObjectPattern":
|
|
311
|
+
return "properties";
|
|
312
|
+
case "VoidPattern":
|
|
313
|
+
return true;
|
|
314
|
+
case "CallExpression":
|
|
315
|
+
if (!disallowCallExpression && !this.state.strict && this.optionFlags & OptionFlags.AnnexB) {
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
isOptionalMemberExpression(expression) {
|
|
322
|
+
return expression.type === "OptionalMemberExpression";
|
|
323
|
+
}
|
|
324
|
+
checkLVal(expression, ancestor, binding = BindingFlag.TYPE_NONE, checkClashes = false, strictModeChanged = false, hasParenthesizedAncestor = false, disallowCallExpression = false) {
|
|
325
|
+
const type = expression.type;
|
|
326
|
+
if (this.isObjectMethod(expression)) return;
|
|
327
|
+
const isOptionalMemberExpression = this.isOptionalMemberExpression(expression);
|
|
328
|
+
if (isOptionalMemberExpression || type === "MemberExpression") {
|
|
329
|
+
if (isOptionalMemberExpression) {
|
|
330
|
+
this.expectPlugin("optionalChainingAssign", expression.loc.start);
|
|
331
|
+
if (ancestor.type !== "AssignmentExpression") {
|
|
332
|
+
this.raise(Errors.InvalidLhsOptionalChaining, expression, {
|
|
333
|
+
ancestor
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (binding !== BindingFlag.TYPE_NONE) {
|
|
338
|
+
this.raise(Errors.InvalidPropertyBindingPattern, expression);
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (type === "Identifier") {
|
|
343
|
+
this.checkIdentifier(expression, binding, strictModeChanged);
|
|
344
|
+
const {
|
|
345
|
+
name
|
|
346
|
+
} = expression;
|
|
347
|
+
if (checkClashes) {
|
|
348
|
+
if (checkClashes.has(name)) {
|
|
349
|
+
this.raise(Errors.ParamDupe, expression);
|
|
350
|
+
} else {
|
|
351
|
+
checkClashes.add(name);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return;
|
|
355
|
+
} else if (type === "VoidPattern" && ancestor.type === "CatchClause") {
|
|
356
|
+
this.raise(Errors.VoidPatternCatchClauseParam, expression);
|
|
357
|
+
}
|
|
358
|
+
const unwrappedExpression = unwrapParenthesizedExpression(expression);
|
|
359
|
+
disallowCallExpression ||= unwrappedExpression.type === "CallExpression" && (unwrappedExpression.callee.type === "Import" || unwrappedExpression.callee.type === "Super");
|
|
360
|
+
const validity = this.isValidLVal(type, disallowCallExpression, !(hasParenthesizedAncestor || expression.extra?.parenthesized) && ancestor.type === "AssignmentExpression", binding);
|
|
361
|
+
if (validity === true) return;
|
|
362
|
+
if (validity === false) {
|
|
363
|
+
const ParseErrorClass = binding === BindingFlag.TYPE_NONE ? Errors.InvalidLhs : Errors.InvalidLhsBinding;
|
|
364
|
+
this.raise(ParseErrorClass, expression, {
|
|
365
|
+
ancestor
|
|
366
|
+
});
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
let key, isParenthesizedExpression;
|
|
370
|
+
if (typeof validity === "string") {
|
|
371
|
+
key = validity;
|
|
372
|
+
isParenthesizedExpression = type === "ParenthesizedExpression";
|
|
373
|
+
} else {
|
|
374
|
+
[key, isParenthesizedExpression] = validity;
|
|
375
|
+
}
|
|
376
|
+
const nextAncestor = type === "ArrayPattern" || type === "ObjectPattern" ? {
|
|
377
|
+
type
|
|
378
|
+
} : ancestor;
|
|
379
|
+
const val = expression[key];
|
|
380
|
+
if (Array.isArray(val)) {
|
|
381
|
+
for (const child of val) {
|
|
382
|
+
if (child) {
|
|
383
|
+
this.checkLVal(child, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression, true);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
} else if (val) {
|
|
387
|
+
this.checkLVal(val, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression, disallowCallExpression);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
checkIdentifier(at, bindingType, strictModeChanged = false) {
|
|
391
|
+
if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(at.name, this.inModule) : isStrictBindOnlyReservedWord(at.name))) {
|
|
392
|
+
if (bindingType === BindingFlag.TYPE_NONE) {
|
|
393
|
+
this.raise(Errors.StrictEvalArguments, at, {
|
|
394
|
+
referenceName: at.name
|
|
395
|
+
});
|
|
396
|
+
} else {
|
|
397
|
+
this.raise(Errors.StrictEvalArgumentsBinding, at, {
|
|
398
|
+
bindingName: at.name
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (bindingType & BindingFlag.FLAG_NO_LET_IN_LEXICAL && at.name === "let") {
|
|
403
|
+
this.raise(Errors.LetInLexicalBinding, at);
|
|
404
|
+
}
|
|
405
|
+
if (!(bindingType & BindingFlag.TYPE_NONE)) {
|
|
406
|
+
this.declareNameFromIdentifier(at, bindingType);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
declareNameFromIdentifier(identifier, binding) {
|
|
410
|
+
this.scope.declareName(identifier.name, binding, identifier.loc.start);
|
|
411
|
+
}
|
|
412
|
+
checkToRestConversion(node, allowPattern) {
|
|
413
|
+
switch (node.type) {
|
|
414
|
+
case "ParenthesizedExpression":
|
|
415
|
+
this.checkToRestConversion(node.expression, allowPattern);
|
|
416
|
+
break;
|
|
417
|
+
case "Identifier":
|
|
418
|
+
case "MemberExpression":
|
|
419
|
+
break;
|
|
420
|
+
case "ArrayExpression":
|
|
421
|
+
case "ObjectExpression":
|
|
422
|
+
if (allowPattern) break;
|
|
423
|
+
// falls through (upstream parser grammar)
|
|
424
|
+
default:
|
|
425
|
+
this.raise(Errors.InvalidRestAssignmentPattern, node);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
checkCommaAfterRest(close) {
|
|
429
|
+
if (!this.match(tt.comma)) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
this.raise(this.lookaheadCharCode() === close ? Errors.RestTrailingComma : Errors.ElementAfterRest, this.state.startLoc);
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
export {
|
|
437
|
+
ParseBindingListFlags,
|
|
438
|
+
LValParser as default
|
|
439
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Generated from Babel v7.29.8 (MIT); see README.md.
|
|
2
|
+
import UtilParser from "./util.mjs";
|
|
3
|
+
import { SourceLocation } from "../util/location.mjs";
|
|
4
|
+
import { OptionFlags } from "../options.mjs";
|
|
5
|
+
class Node {
|
|
6
|
+
constructor(parser, pos, loc) {
|
|
7
|
+
this.start = pos;
|
|
8
|
+
this.end = 0;
|
|
9
|
+
this.loc = new SourceLocation(loc);
|
|
10
|
+
if (parser?.optionFlags & OptionFlags.Ranges) this.range = [pos, 0];
|
|
11
|
+
if (parser?.filename) this.loc.filename = parser.filename;
|
|
12
|
+
}
|
|
13
|
+
type = "";
|
|
14
|
+
}
|
|
15
|
+
const NodePrototype = Node.prototype;
|
|
16
|
+
{
|
|
17
|
+
NodePrototype.__clone = function() {
|
|
18
|
+
const newNode = new Node(void 0, this.start, this.loc.start);
|
|
19
|
+
const keys = Object.keys(this);
|
|
20
|
+
for (let i = 0, length = keys.length; i < length; i++) {
|
|
21
|
+
const key = keys[i];
|
|
22
|
+
if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
|
|
23
|
+
newNode[key] = this[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return newNode;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
class NodeUtils extends UtilParser {
|
|
30
|
+
startNode() {
|
|
31
|
+
const loc = this.state.startLoc;
|
|
32
|
+
return new Node(this, loc.index, loc);
|
|
33
|
+
}
|
|
34
|
+
startNodeAt(loc) {
|
|
35
|
+
return new Node(this, loc.index, loc);
|
|
36
|
+
}
|
|
37
|
+
startNodeAtNode(type) {
|
|
38
|
+
return this.startNodeAt(type.loc.start);
|
|
39
|
+
}
|
|
40
|
+
finishNode(node, type) {
|
|
41
|
+
return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
|
|
42
|
+
}
|
|
43
|
+
finishNodeAt(node, type, endLoc) {
|
|
44
|
+
node.type = type;
|
|
45
|
+
node.end = endLoc.index;
|
|
46
|
+
node.loc.end = endLoc;
|
|
47
|
+
if (this.optionFlags & OptionFlags.Ranges) node.range[1] = endLoc.index;
|
|
48
|
+
if (this.optionFlags & OptionFlags.AttachComment) {
|
|
49
|
+
this.processComment(node);
|
|
50
|
+
}
|
|
51
|
+
return node;
|
|
52
|
+
}
|
|
53
|
+
resetStartLocation(node, startLoc) {
|
|
54
|
+
node.start = startLoc.index;
|
|
55
|
+
node.loc.start = startLoc;
|
|
56
|
+
if (this.optionFlags & OptionFlags.Ranges) node.range[0] = startLoc.index;
|
|
57
|
+
}
|
|
58
|
+
resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
|
|
59
|
+
node.end = endLoc.index;
|
|
60
|
+
node.loc.end = endLoc;
|
|
61
|
+
if (this.optionFlags & OptionFlags.Ranges) node.range[1] = endLoc.index;
|
|
62
|
+
}
|
|
63
|
+
resetStartLocationFromNode(node, locationNode) {
|
|
64
|
+
this.resetStartLocation(node, locationNode.loc.start);
|
|
65
|
+
}
|
|
66
|
+
castNodeTo(node, type) {
|
|
67
|
+
node.type = type;
|
|
68
|
+
return node;
|
|
69
|
+
}
|
|
70
|
+
cloneIdentifier(node) {
|
|
71
|
+
const {
|
|
72
|
+
type,
|
|
73
|
+
start,
|
|
74
|
+
end,
|
|
75
|
+
loc,
|
|
76
|
+
range,
|
|
77
|
+
name
|
|
78
|
+
} = node;
|
|
79
|
+
const cloned = Object.create(NodePrototype);
|
|
80
|
+
cloned.type = type;
|
|
81
|
+
cloned.start = start;
|
|
82
|
+
cloned.end = end;
|
|
83
|
+
cloned.loc = loc;
|
|
84
|
+
cloned.range = range;
|
|
85
|
+
cloned.name = name;
|
|
86
|
+
if (node.extra) cloned.extra = node.extra;
|
|
87
|
+
return cloned;
|
|
88
|
+
}
|
|
89
|
+
cloneStringLiteral(node) {
|
|
90
|
+
const {
|
|
91
|
+
type,
|
|
92
|
+
start,
|
|
93
|
+
end,
|
|
94
|
+
loc,
|
|
95
|
+
range,
|
|
96
|
+
extra
|
|
97
|
+
} = node;
|
|
98
|
+
const cloned = Object.create(NodePrototype);
|
|
99
|
+
cloned.type = type;
|
|
100
|
+
cloned.start = start;
|
|
101
|
+
cloned.end = end;
|
|
102
|
+
cloned.loc = loc;
|
|
103
|
+
cloned.range = range;
|
|
104
|
+
cloned.extra = extra;
|
|
105
|
+
cloned.value = node.value;
|
|
106
|
+
return cloned;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
NodeUtils
|
|
111
|
+
};
|