@weapp-vite/miniprogram-automator 1.5.1 → 1.5.2
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/dist/index.d.mts +3 -0
- package/dist/index.mjs +5 -3
- package/dist/{launch-DYvZy3JW.mjs → launch-f8nEl-FE.mjs} +2295 -789
- package/package.json +2 -2
|
@@ -861,7 +861,7 @@ const mix = (del = delimiter) => {
|
|
|
861
861
|
const posix = /* @__PURE__ */ mix(":");
|
|
862
862
|
const win32 = /* @__PURE__ */ mix(";");
|
|
863
863
|
// ../../mpcore/packages/simulator/src/runtime/componentInstance/relations.ts
|
|
864
|
-
const states = /* @__PURE__ */ new WeakMap();
|
|
864
|
+
const states$1 = /* @__PURE__ */ new WeakMap();
|
|
865
865
|
const opposite = {
|
|
866
866
|
ancestor: "descendant",
|
|
867
867
|
descendant: "ancestor",
|
|
@@ -880,13 +880,13 @@ function matches(source, key, relation, target) {
|
|
|
880
880
|
return posix.normalize(targetPath) === target.is;
|
|
881
881
|
}
|
|
882
882
|
function getComponentRelationNodes(instance, key) {
|
|
883
|
-
return [...states.get(instance)?.get(key)?.targets ?? []];
|
|
883
|
+
return [...states$1.get(instance)?.get(key)?.targets ?? []];
|
|
884
884
|
}
|
|
885
885
|
function publishRelations(nextStates) {
|
|
886
886
|
const callbacks = [];
|
|
887
887
|
let changed = false;
|
|
888
888
|
for (const [instance, next] of nextStates) {
|
|
889
|
-
const previous = states.get(instance) ?? /* @__PURE__ */ new Map();
|
|
889
|
+
const previous = states$1.get(instance) ?? /* @__PURE__ */ new Map();
|
|
890
890
|
for (const [key, previousState] of previous) {
|
|
891
891
|
const nextTargets = next.get(key)?.targets ?? [];
|
|
892
892
|
for (const target of previousState.targets) if (!nextTargets.includes(target)) {
|
|
@@ -901,7 +901,7 @@ function publishRelations(nextStates) {
|
|
|
901
901
|
callbacks.push(() => nextState.definition.linked?.call(instance, target));
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
|
-
states.set(instance, next);
|
|
904
|
+
states$1.set(instance, next);
|
|
905
905
|
}
|
|
906
906
|
for (const callback of callbacks) callback();
|
|
907
907
|
return changed;
|
|
@@ -938,7 +938,7 @@ function detachComponentRelations(instances) {
|
|
|
938
938
|
const nextStates = /* @__PURE__ */ new Map();
|
|
939
939
|
for (const instance of instances) {
|
|
940
940
|
nextStates.set(instance, /* @__PURE__ */ new Map());
|
|
941
|
-
for (const relation of states.get(instance)?.values() ?? []) for (const target of relation.targets) if (!removed.has(target) && !nextStates.has(target)) nextStates.set(target, new Map([...states.get(target) ?? []].map(([key, state]) => [key, {
|
|
941
|
+
for (const relation of states$1.get(instance)?.values() ?? []) for (const target of relation.targets) if (!removed.has(target) && !nextStates.has(target)) nextStates.set(target, new Map([...states$1.get(target) ?? []].map(([key, state]) => [key, {
|
|
942
942
|
...state,
|
|
943
943
|
targets: state.targets.filter((candidate) => !removed.has(candidate))
|
|
944
944
|
}])));
|
|
@@ -1932,7 +1932,7 @@ function registerSlotDeclarations(pass, slots, parent, scopeId) {
|
|
|
1932
1932
|
scopeId
|
|
1933
1933
|
});
|
|
1934
1934
|
}
|
|
1935
|
-
// ../../node_modules/.pnpm/@babel+parser@8.0
|
|
1935
|
+
// ../../node_modules/.pnpm/@babel+parser@8.1.0/node_modules/@babel/parser/lib/index.js
|
|
1936
1936
|
var Position = class {
|
|
1937
1937
|
constructor(line, col, index) {
|
|
1938
1938
|
this.line = void 0;
|
|
@@ -2018,6 +2018,7 @@ const StandardErrors = {
|
|
|
2018
2018
|
DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
|
|
2019
2019
|
DecoratorStaticBlock: "Decorators can't be used with a static block.",
|
|
2020
2020
|
DeferImportRequiresNamespace: "Only `import defer * as x from \"./module\"` is valid.",
|
|
2021
|
+
DeferExportInvalidAll: "`export defer * from \"./module\"` is invalid. Explicitly list the re-exported names.",
|
|
2021
2022
|
DeletePrivateField: "Deleting a private field is not allowed.",
|
|
2022
2023
|
DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
|
|
2023
2024
|
DuplicateConstructor: "Duplicate constructor in the same class.",
|
|
@@ -2029,6 +2030,9 @@ const StandardErrors = {
|
|
|
2029
2030
|
EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
|
|
2030
2031
|
ExportBindingIsString: ({ localName, exportName }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
|
|
2031
2032
|
ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
|
|
2033
|
+
FilteredNamespaceDuplicateName: ({ name }) => `Duplicate name '${name}' in filtered namespace.`,
|
|
2034
|
+
FilteredNamespaceRename: "Names in a filtered namespace cannot be renamed using `as`.",
|
|
2035
|
+
FilteredNamespaceTypeModifier: "Names in a filtered namespace cannot have a type modifier.",
|
|
2032
2036
|
ForInOfLoopInitializer: ({ type }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
|
|
2033
2037
|
ForInUsing: "For-in loop may not start with 'using' declaration.",
|
|
2034
2038
|
ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
|
|
@@ -2038,9 +2042,9 @@ const StandardErrors = {
|
|
|
2038
2042
|
IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
|
|
2039
2043
|
IllegalReturn: "'return' outside of function.",
|
|
2040
2044
|
ImportBindingIsString: ({ importName }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
|
|
2041
|
-
ImportCallArity: ({ phase }) => `\`import${phase ? `.${phase}` : ""}()\` requires exactly one or two arguments.`,
|
|
2042
|
-
ImportCallNotNewExpression: ({ phase }) => `Cannot use new with import${phase ? `.${phase}` : ""}().`,
|
|
2043
|
-
ImportCallSpreadArgument: ({ phase }) => `\`...\` is not allowed in \`import${phase ? `.${phase}` : ""}()\`.`,
|
|
2045
|
+
ImportCallArity: ({ phase, sync }) => `\`import${phase ? `.${phase}` : sync ? ".sync" : ""}()\` requires exactly one or two arguments.`,
|
|
2046
|
+
ImportCallNotNewExpression: ({ phase, sync }) => `Cannot use new with import${phase ? `.${phase}` : sync ? ".sync" : ""}().`,
|
|
2047
|
+
ImportCallSpreadArgument: ({ phase, sync }) => `\`...\` is not allowed in \`import${phase ? `.${phase}` : sync ? ".sync" : ""}()\`.`,
|
|
2044
2048
|
IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
|
|
2045
2049
|
InvalidBigIntLiteral: "Invalid BigIntLiteral.",
|
|
2046
2050
|
InvalidCodePoint: "Code point out of bounds.",
|
|
@@ -2505,7 +2509,7 @@ const estree = (superClass) => class ESTreeParserMixin extends superClass {
|
|
|
2505
2509
|
case "ExportAllDeclaration":
|
|
2506
2510
|
node.exported = null;
|
|
2507
2511
|
break;
|
|
2508
|
-
case "ExportNamedDeclaration": if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
|
|
2512
|
+
case "ExportNamedDeclaration": if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier" && !node.specifiers[0].exportsFilter) {
|
|
2509
2513
|
this.castNodeTo(node, "ExportAllDeclaration");
|
|
2510
2514
|
node.exported = node.specifiers[0].exported;
|
|
2511
2515
|
delete node.specifiers;
|
|
@@ -2647,7 +2651,7 @@ function createKeywordLike(name, options = {}) {
|
|
|
2647
2651
|
tokenTypes.push(new ExportedTokenType("name", options));
|
|
2648
2652
|
return tokenTypeCounter;
|
|
2649
2653
|
}
|
|
2650
|
-
const tt = {
|
|
2654
|
+
const tt$1 = {
|
|
2651
2655
|
bracketL: createToken("[", {
|
|
2652
2656
|
beforeExpr,
|
|
2653
2657
|
startsExpr
|
|
@@ -2837,6 +2841,8 @@ const tt = {
|
|
|
2837
2841
|
_set: createKeywordLike("set", { startsExpr }),
|
|
2838
2842
|
_source: createKeywordLike("source", { startsExpr }),
|
|
2839
2843
|
_static: createKeywordLike("static", { startsExpr }),
|
|
2844
|
+
_struct: createKeywordLike("struct", { startsExpr }),
|
|
2845
|
+
_sync: createKeywordLike("sync", { startsExpr }),
|
|
2840
2846
|
_using: createKeywordLike("using", { startsExpr }),
|
|
2841
2847
|
_yield: createKeywordLike("yield", { startsExpr }),
|
|
2842
2848
|
_asserts: createKeywordLike("asserts", { startsExpr }),
|
|
@@ -2876,16 +2882,16 @@ const tt = {
|
|
|
2876
2882
|
jsxTagEnd: createToken("jsxTagEnd")
|
|
2877
2883
|
};
|
|
2878
2884
|
function tokenIsIdentifier(token) {
|
|
2879
|
-
return token >= 89 && token <=
|
|
2885
|
+
return token >= 89 && token <= 132;
|
|
2880
2886
|
}
|
|
2881
2887
|
function tokenKeywordOrIdentifierIsKeyword(token) {
|
|
2882
2888
|
return token <= 88;
|
|
2883
2889
|
}
|
|
2884
2890
|
function tokenIsKeywordOrIdentifier(token) {
|
|
2885
|
-
return token >= 54 && token <=
|
|
2891
|
+
return token >= 54 && token <= 132;
|
|
2886
2892
|
}
|
|
2887
2893
|
function tokenIsLiteralPropertyName(token) {
|
|
2888
|
-
return token >= 54 && token <=
|
|
2894
|
+
return token >= 54 && token <= 135;
|
|
2889
2895
|
}
|
|
2890
2896
|
function tokenComesBeforeExpression(token) {
|
|
2891
2897
|
return tokenBeforeExprs[token];
|
|
@@ -2897,7 +2903,7 @@ function tokenIsAssignment(token) {
|
|
|
2897
2903
|
return token >= 25 && token <= 29;
|
|
2898
2904
|
}
|
|
2899
2905
|
function tokenIsFlowInterfaceOrTypeOrOpaque(token) {
|
|
2900
|
-
return token >=
|
|
2906
|
+
return token >= 128 && token <= 130;
|
|
2901
2907
|
}
|
|
2902
2908
|
function tokenIsLoop(token) {
|
|
2903
2909
|
return token >= 86 && token <= 88;
|
|
@@ -2915,10 +2921,10 @@ function tokenIsPrefix(token) {
|
|
|
2915
2921
|
return tokenPrefixes[token];
|
|
2916
2922
|
}
|
|
2917
2923
|
function tokenIsTSTypeOperator(token) {
|
|
2918
|
-
return token >=
|
|
2924
|
+
return token >= 120 && token <= 122;
|
|
2919
2925
|
}
|
|
2920
2926
|
function tokenIsTSDeclarationStart(token) {
|
|
2921
|
-
return token >=
|
|
2927
|
+
return token >= 123 && token <= 129;
|
|
2922
2928
|
}
|
|
2923
2929
|
function tokenLabelName(token) {
|
|
2924
2930
|
return tokenLabels[token];
|
|
@@ -3455,7 +3461,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3455
3461
|
return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
|
|
3456
3462
|
}
|
|
3457
3463
|
finishToken(type, val) {
|
|
3458
|
-
if (type !==
|
|
3464
|
+
if (type !== 133 && type !== 9 && type !== 24) {
|
|
3459
3465
|
if (this.flowPragma === void 0) this.flowPragma = null;
|
|
3460
3466
|
}
|
|
3461
3467
|
super.finishToken(type, val);
|
|
@@ -3482,7 +3488,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3482
3488
|
const node = this.startNode();
|
|
3483
3489
|
const moduloLoc = this.state.startLoc;
|
|
3484
3490
|
this.next();
|
|
3485
|
-
this.expectContextual(
|
|
3491
|
+
this.expectContextual(109);
|
|
3486
3492
|
if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc);
|
|
3487
3493
|
if (this.eat(6)) {
|
|
3488
3494
|
node.value = super.parseExpression();
|
|
@@ -3536,15 +3542,15 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3536
3542
|
if (this.match(76)) return this.flowParseDeclareClass(node);
|
|
3537
3543
|
else if (this.match(64)) return this.flowParseDeclareFunction(node);
|
|
3538
3544
|
else if (this.match(70)) return this.flowParseDeclareVariable(node);
|
|
3539
|
-
else if (this.eatContextual(
|
|
3545
|
+
else if (this.eatContextual(126)) {
|
|
3540
3546
|
if (this.match(12)) return this.flowParseDeclareModuleExports(node);
|
|
3541
3547
|
else {
|
|
3542
3548
|
if (insideModule) this.raise(FlowErrors.NestedDeclareModule, this.state.lastTokStartLoc);
|
|
3543
3549
|
return this.flowParseDeclareModule(node);
|
|
3544
3550
|
}
|
|
3545
|
-
} else if (this.isContextual(
|
|
3546
|
-
else if (this.isContextual(
|
|
3547
|
-
else if (this.isContextual(
|
|
3551
|
+
} else if (this.isContextual(129)) return this.flowParseDeclareTypeAlias(node);
|
|
3552
|
+
else if (this.isContextual(130)) return this.flowParseDeclareOpaqueType(node);
|
|
3553
|
+
else if (this.isContextual(128)) return this.flowParseDeclareInterface(node);
|
|
3548
3554
|
else if (this.match(78)) return this.flowParseDeclareExportDeclaration(node, insideModule);
|
|
3549
3555
|
throw this.unexpected();
|
|
3550
3556
|
}
|
|
@@ -3557,7 +3563,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3557
3563
|
}
|
|
3558
3564
|
flowParseDeclareModule(node) {
|
|
3559
3565
|
this.scope.enter(0);
|
|
3560
|
-
if (this.match(
|
|
3566
|
+
if (this.match(133)) node.id = super.parseExprAtom();
|
|
3561
3567
|
else node.id = this.parseIdentifier();
|
|
3562
3568
|
const bodyNode = this.startNode();
|
|
3563
3569
|
const body = bodyNode.body = [];
|
|
@@ -3566,10 +3572,10 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3566
3572
|
const bodyNode = this.startNode();
|
|
3567
3573
|
if (this.match(79)) {
|
|
3568
3574
|
this.next();
|
|
3569
|
-
if (!this.isContextual(
|
|
3575
|
+
if (!this.isContextual(129) && !this.match(83)) this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
|
|
3570
3576
|
body.push(super.parseImport(bodyNode));
|
|
3571
3577
|
} else {
|
|
3572
|
-
this.expectContextual(
|
|
3578
|
+
this.expectContextual(124, FlowErrors.UnsupportedStatementInDeclareModule);
|
|
3573
3579
|
body.push(this.flowParseDeclare(bodyNode, true));
|
|
3574
3580
|
}
|
|
3575
3581
|
}
|
|
@@ -3603,18 +3609,18 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3603
3609
|
node.default = true;
|
|
3604
3610
|
return this.finishNode(node, "DeclareExportDeclaration");
|
|
3605
3611
|
} else {
|
|
3606
|
-
if (this.match(71) || this.isLet() || (this.isContextual(
|
|
3612
|
+
if (this.match(71) || this.isLet() || (this.isContextual(129) || this.isContextual(128)) && !insideModule) {
|
|
3607
3613
|
const label = this.state.value;
|
|
3608
3614
|
throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, {
|
|
3609
3615
|
unsupportedExportKind: label,
|
|
3610
3616
|
suggestion: exportSuggestions[label]
|
|
3611
3617
|
});
|
|
3612
3618
|
}
|
|
3613
|
-
if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(
|
|
3619
|
+
if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(130)) {
|
|
3614
3620
|
node.declaration = this.flowParseDeclare(this.startNode());
|
|
3615
3621
|
node.default = false;
|
|
3616
3622
|
return this.finishNode(node, "DeclareExportDeclaration");
|
|
3617
|
-
} else if (this.match(51) || this.match(2) || this.isContextual(
|
|
3623
|
+
} else if (this.match(51) || this.match(2) || this.isContextual(128) || this.isContextual(129) || this.isContextual(130)) {
|
|
3618
3624
|
const result = this.parseExport(node, null);
|
|
3619
3625
|
if (result.type === "ExportNamedDeclaration") {
|
|
3620
3626
|
result.default = false;
|
|
@@ -3627,7 +3633,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3627
3633
|
}
|
|
3628
3634
|
flowParseDeclareModuleExports(node) {
|
|
3629
3635
|
this.next();
|
|
3630
|
-
this.expectContextual(
|
|
3636
|
+
this.expectContextual(110);
|
|
3631
3637
|
node.typeAnnotation = this.flowParseTypeAnnotation();
|
|
3632
3638
|
this.semicolon();
|
|
3633
3639
|
return this.finishNode(node, "DeclareModuleExports");
|
|
@@ -3659,10 +3665,10 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3659
3665
|
if (isClass) {
|
|
3660
3666
|
const implemented = [];
|
|
3661
3667
|
const mixins = [];
|
|
3662
|
-
if (this.eatContextual(
|
|
3668
|
+
if (this.eatContextual(116)) do
|
|
3663
3669
|
mixins.push(this.flowParseInterfaceExtends());
|
|
3664
3670
|
while (this.eat(8));
|
|
3665
|
-
if (this.eatContextual(
|
|
3671
|
+
if (this.eatContextual(112)) do
|
|
3666
3672
|
implemented.push(this.flowParseClassImplements());
|
|
3667
3673
|
while (this.eat(8));
|
|
3668
3674
|
node.implements = implemented;
|
|
@@ -3713,7 +3719,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3713
3719
|
return this.finishNode(node, "TypeAlias");
|
|
3714
3720
|
}
|
|
3715
3721
|
flowParseOpaqueType(node, declare) {
|
|
3716
|
-
this.expectContextual(
|
|
3722
|
+
this.expectContextual(129);
|
|
3717
3723
|
node.id = this.flowParseRestrictedIdentifier(true, true);
|
|
3718
3724
|
this.scope.declareName(node.id.name, 8201, node.id.start);
|
|
3719
3725
|
if (this.match(43)) node.typeParameters = this.flowParseTypeParameterDeclaration();
|
|
@@ -3751,7 +3757,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3751
3757
|
const node = this.startNode();
|
|
3752
3758
|
node.params = [];
|
|
3753
3759
|
this.state.inType = true;
|
|
3754
|
-
if (this.match(43) || this.match(
|
|
3760
|
+
if (this.match(43) || this.match(141)) this.next();
|
|
3755
3761
|
else this.unexpected();
|
|
3756
3762
|
let defaultRequired = false;
|
|
3757
3763
|
do {
|
|
@@ -3816,7 +3822,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3816
3822
|
}
|
|
3817
3823
|
flowParseInterfaceType() {
|
|
3818
3824
|
const node = this.startNode();
|
|
3819
|
-
this.expectContextual(
|
|
3825
|
+
this.expectContextual(128);
|
|
3820
3826
|
node.extends = [];
|
|
3821
3827
|
if (this.eat(77)) do
|
|
3822
3828
|
node.extends.push(this.flowParseInterfaceExtends());
|
|
@@ -3831,7 +3837,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3831
3837
|
return this.finishNode(node, "InterfaceTypeAnnotation");
|
|
3832
3838
|
}
|
|
3833
3839
|
flowParseObjectPropertyKey() {
|
|
3834
|
-
return this.match(
|
|
3840
|
+
return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true);
|
|
3835
3841
|
}
|
|
3836
3842
|
flowParseObjectTypeIndexer(node, isStatic, variance) {
|
|
3837
3843
|
node.static = isStatic;
|
|
@@ -3916,7 +3922,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
3916
3922
|
let protoStartLoc = null;
|
|
3917
3923
|
let inexactStartLoc = null;
|
|
3918
3924
|
const node = this.startNode();
|
|
3919
|
-
if (allowProto && this.isContextual(
|
|
3925
|
+
if (allowProto && this.isContextual(117)) {
|
|
3920
3926
|
const lookahead = this.lookahead();
|
|
3921
3927
|
if (lookahead.type !== 10 && lookahead.type !== 13) {
|
|
3922
3928
|
this.next();
|
|
@@ -4180,7 +4186,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4180
4186
|
node.typeParameters = null;
|
|
4181
4187
|
return this.finishNode(node, "FunctionTypeAnnotation");
|
|
4182
4188
|
}
|
|
4183
|
-
case
|
|
4189
|
+
case 133: return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
|
|
4184
4190
|
case 81:
|
|
4185
4191
|
case 82:
|
|
4186
4192
|
node.value = this.match(81);
|
|
@@ -4189,13 +4195,13 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4189
4195
|
case 49:
|
|
4190
4196
|
if (this.state.value === "-") {
|
|
4191
4197
|
this.next();
|
|
4192
|
-
if (this.match(
|
|
4193
|
-
if (this.match(
|
|
4198
|
+
if (this.match(134)) return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
|
|
4199
|
+
if (this.match(135)) return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
|
|
4194
4200
|
throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
|
|
4195
4201
|
}
|
|
4196
4202
|
throw this.unexpected();
|
|
4197
|
-
case
|
|
4198
|
-
case
|
|
4203
|
+
case 134: return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
|
|
4204
|
+
case 135: return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
|
|
4199
4205
|
case 84:
|
|
4200
4206
|
this.next();
|
|
4201
4207
|
return this.finishNode(node, "VoidTypeAnnotation");
|
|
@@ -4214,7 +4220,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4214
4220
|
this.next();
|
|
4215
4221
|
return super.createIdentifier(node, label);
|
|
4216
4222
|
} else if (tokenIsIdentifier(this.state.type)) {
|
|
4217
|
-
if (this.isContextual(
|
|
4223
|
+
if (this.isContextual(128)) return this.flowParseInterfaceType();
|
|
4218
4224
|
return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
|
|
4219
4225
|
}
|
|
4220
4226
|
}
|
|
@@ -4289,7 +4295,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4289
4295
|
return type;
|
|
4290
4296
|
}
|
|
4291
4297
|
flowParseTypeOrImplicitInstantiation() {
|
|
4292
|
-
if (this.state.type ===
|
|
4298
|
+
if (this.state.type === 131 && this.state.value === "_") {
|
|
4293
4299
|
const startLoc = this.state.startLoc;
|
|
4294
4300
|
const node = this.parseIdentifier();
|
|
4295
4301
|
return this.flowParseGenericType(startLoc, node);
|
|
@@ -4339,13 +4345,13 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4339
4345
|
return super.parseFunctionBodyAndFinish(node, type, isMethod);
|
|
4340
4346
|
}
|
|
4341
4347
|
parseStatementLike(flags) {
|
|
4342
|
-
if (this.state.strict && this.isContextual(
|
|
4348
|
+
if (this.state.strict && this.isContextual(128)) {
|
|
4343
4349
|
if (tokenIsKeywordOrIdentifier(this.lookahead().type)) {
|
|
4344
4350
|
const node = this.startNode();
|
|
4345
4351
|
this.next();
|
|
4346
4352
|
return this.flowParseInterface(node);
|
|
4347
4353
|
}
|
|
4348
|
-
} else if (this.isContextual(
|
|
4354
|
+
} else if (this.isContextual(125)) {
|
|
4349
4355
|
const node = this.startNode();
|
|
4350
4356
|
this.next();
|
|
4351
4357
|
return this.flowParseEnumDeclaration(node);
|
|
@@ -4368,16 +4374,16 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4368
4374
|
}
|
|
4369
4375
|
shouldParseExportDeclaration() {
|
|
4370
4376
|
const { type } = this.state;
|
|
4371
|
-
if (type ===
|
|
4377
|
+
if (type === 125 || tokenIsFlowInterfaceOrTypeOrOpaque(type)) return !this.state.containsEsc;
|
|
4372
4378
|
return super.shouldParseExportDeclaration();
|
|
4373
4379
|
}
|
|
4374
4380
|
isExportDefaultSpecifier() {
|
|
4375
4381
|
const { type } = this.state;
|
|
4376
|
-
if (type ===
|
|
4382
|
+
if (type === 125 || tokenIsFlowInterfaceOrTypeOrOpaque(type)) return this.state.containsEsc;
|
|
4377
4383
|
return super.isExportDefaultSpecifier();
|
|
4378
4384
|
}
|
|
4379
4385
|
parseExportDefaultExpression() {
|
|
4380
|
-
if (this.isContextual(
|
|
4386
|
+
if (this.isContextual(125)) {
|
|
4381
4387
|
const node = this.startNode();
|
|
4382
4388
|
this.next();
|
|
4383
4389
|
return this.flowParseEnumDeclaration(node);
|
|
@@ -4490,7 +4496,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4490
4496
|
super.assertModuleNodeAllowed(node);
|
|
4491
4497
|
}
|
|
4492
4498
|
parseExportDeclaration(node) {
|
|
4493
|
-
if (this.isContextual(
|
|
4499
|
+
if (this.isContextual(129)) {
|
|
4494
4500
|
node.exportKind = "type";
|
|
4495
4501
|
const declarationNode = this.startNode();
|
|
4496
4502
|
this.next();
|
|
@@ -4499,17 +4505,17 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4499
4505
|
super.parseExportFrom(node);
|
|
4500
4506
|
return null;
|
|
4501
4507
|
} else return this.flowParseTypeAlias(declarationNode);
|
|
4502
|
-
} else if (this.isContextual(
|
|
4508
|
+
} else if (this.isContextual(130)) {
|
|
4503
4509
|
node.exportKind = "type";
|
|
4504
4510
|
const declarationNode = this.startNode();
|
|
4505
4511
|
this.next();
|
|
4506
4512
|
return this.flowParseOpaqueType(declarationNode, false);
|
|
4507
|
-
} else if (this.isContextual(
|
|
4513
|
+
} else if (this.isContextual(128)) {
|
|
4508
4514
|
node.exportKind = "type";
|
|
4509
4515
|
const declarationNode = this.startNode();
|
|
4510
4516
|
this.next();
|
|
4511
4517
|
return this.flowParseInterface(declarationNode);
|
|
4512
|
-
} else if (this.isContextual(
|
|
4518
|
+
} else if (this.isContextual(125)) {
|
|
4513
4519
|
node.exportKind = "value";
|
|
4514
4520
|
const declarationNode = this.startNode();
|
|
4515
4521
|
this.next();
|
|
@@ -4518,7 +4524,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4518
4524
|
}
|
|
4519
4525
|
eatExportStar(node) {
|
|
4520
4526
|
if (super.eatExportStar(node)) return true;
|
|
4521
|
-
if (this.isContextual(
|
|
4527
|
+
if (this.isContextual(129) && this.lookahead().type === 51) {
|
|
4522
4528
|
node.exportKind = "type";
|
|
4523
4529
|
this.next();
|
|
4524
4530
|
this.next();
|
|
@@ -4532,8 +4538,14 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4532
4538
|
if (hasNamespace && node.exportKind === "type") this.unexpected(startLoc);
|
|
4533
4539
|
return hasNamespace;
|
|
4534
4540
|
}
|
|
4541
|
+
maybeParseExportNamedSpecifiers(node) {
|
|
4542
|
+
if (!super.maybeParseExportNamedSpecifiers(node)) return false;
|
|
4543
|
+
const specifier = node.specifiers[node.specifiers.length - 1];
|
|
4544
|
+
if (node.exportKind === "type" && specifier?.type === "ExportNamespaceSpecifier") this.unexpected(specifier.start);
|
|
4545
|
+
return true;
|
|
4546
|
+
}
|
|
4535
4547
|
parseClassId(node, isStatement, optionalId) {
|
|
4536
|
-
if ((!isStatement || optionalId) && this.isContextual(
|
|
4548
|
+
if ((!isStatement || optionalId) && this.isContextual(112)) {
|
|
4537
4549
|
node.id = null;
|
|
4538
4550
|
return;
|
|
4539
4551
|
}
|
|
@@ -4542,7 +4554,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4542
4554
|
}
|
|
4543
4555
|
parseClassMember(classBody, member, state) {
|
|
4544
4556
|
const { startLoc } = this.state;
|
|
4545
|
-
if (this.isContextual(
|
|
4557
|
+
if (this.isContextual(124)) {
|
|
4546
4558
|
if (super.parseClassMemberFromModifier(classBody, member)) return;
|
|
4547
4559
|
member.declare = true;
|
|
4548
4560
|
}
|
|
@@ -4559,7 +4571,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4559
4571
|
const word = super.readWord1();
|
|
4560
4572
|
const fullWord = "@@" + word;
|
|
4561
4573
|
if (!this.isIterator(word) || !this.state.inType) this.raise(Errors.InvalidIdentifier, this.state.curPosition(), { identifierName: fullWord });
|
|
4562
|
-
this.finishToken(
|
|
4574
|
+
this.finishToken(131, fullWord);
|
|
4563
4575
|
}
|
|
4564
4576
|
getTokenFromCode(code) {
|
|
4565
4577
|
const next = this.input.charCodeAt(this.state.pos + 1);
|
|
@@ -4647,7 +4659,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4647
4659
|
parseClassSuper(node) {
|
|
4648
4660
|
super.parseClassSuper(node);
|
|
4649
4661
|
if (node.superClass && (this.match(43) || this.match(47))) node.superTypeArguments = this.flowParseTypeParameterInstantiationInExpression();
|
|
4650
|
-
if (this.eatContextual(
|
|
4662
|
+
if (this.eatContextual(112)) {
|
|
4651
4663
|
const implemented = node.implements = [];
|
|
4652
4664
|
do
|
|
4653
4665
|
implemented.push(this.flowParseClassImplements());
|
|
@@ -4701,7 +4713,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4701
4713
|
}
|
|
4702
4714
|
isPotentialImportPhase(isExport) {
|
|
4703
4715
|
if (super.isPotentialImportPhase(isExport)) return true;
|
|
4704
|
-
if (this.isContextual(
|
|
4716
|
+
if (this.isContextual(129)) {
|
|
4705
4717
|
if (!isExport) return true;
|
|
4706
4718
|
const ch = this.lookaheadCharCode();
|
|
4707
4719
|
return ch === 123 || ch === 42;
|
|
@@ -4718,14 +4730,18 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4718
4730
|
node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
|
|
4719
4731
|
}
|
|
4720
4732
|
}
|
|
4721
|
-
|
|
4733
|
+
parseNamedOrFilteredImportSpecifiers(node) {
|
|
4734
|
+
super.parseNamedOrFilteredImportSpecifiers(node);
|
|
4735
|
+
const specifier = node.specifiers[node.specifiers.length - 1];
|
|
4736
|
+
if (hasTypeImportKind(node) && specifier?.type === "ImportNamespaceSpecifier") this.unexpected(specifier.start);
|
|
4737
|
+
}
|
|
4738
|
+
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly) {
|
|
4722
4739
|
const firstIdent = specifier.imported;
|
|
4723
4740
|
let specifierTypeKind = null;
|
|
4724
4741
|
if (firstIdent.type === "Identifier") {
|
|
4725
4742
|
if (firstIdent.name === "type") specifierTypeKind = "type";
|
|
4726
4743
|
else if (firstIdent.name === "typeof") specifierTypeKind = "typeof";
|
|
4727
4744
|
}
|
|
4728
|
-
let isBinding = false;
|
|
4729
4745
|
if (this.isContextual(90) && !this.isLookaheadContextual("as")) {
|
|
4730
4746
|
const as_ident = this.parseIdentifier(true);
|
|
4731
4747
|
if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) {
|
|
@@ -4742,21 +4758,23 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4742
4758
|
specifier.imported = this.parseIdentifier(true);
|
|
4743
4759
|
specifier.importKind = specifierTypeKind;
|
|
4744
4760
|
} else {
|
|
4745
|
-
if (importedIsString) throw this.raise(Errors.ImportBindingIsString, specifier, { importName: firstIdent.value });
|
|
4746
4761
|
specifier.imported = firstIdent;
|
|
4747
4762
|
specifier.importKind = null;
|
|
4748
4763
|
}
|
|
4749
4764
|
if (this.eatContextual(90)) specifier.local = this.parseIdentifier();
|
|
4750
|
-
else
|
|
4751
|
-
isBinding = true;
|
|
4752
|
-
specifier.local = this.cloneIdentifier(specifier.imported);
|
|
4753
|
-
}
|
|
4765
|
+
else specifier.local = this.cloneIdentifier(specifier.imported);
|
|
4754
4766
|
}
|
|
4767
|
+
return this.finishNode(specifier, "ImportSpecifier");
|
|
4768
|
+
}
|
|
4769
|
+
checkImportSpecifier(specifier, isInTypeOnlyImport) {
|
|
4755
4770
|
const specifierIsTypeImport = hasTypeImportKind(specifier);
|
|
4756
|
-
|
|
4757
|
-
if (
|
|
4758
|
-
|
|
4759
|
-
|
|
4771
|
+
const isTypeImport = isInTypeOnlyImport || specifierIsTypeImport;
|
|
4772
|
+
if (isTypeImport) {
|
|
4773
|
+
if (isInTypeOnlyImport && specifierIsTypeImport) this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier);
|
|
4774
|
+
const { local } = specifier;
|
|
4775
|
+
this.checkReservedType(local.name, local.start, true);
|
|
4776
|
+
}
|
|
4777
|
+
super.checkImportSpecifier(specifier, isInTypeOnlyImport, 8201, !isTypeImport);
|
|
4760
4778
|
}
|
|
4761
4779
|
parseBindingAtom() {
|
|
4762
4780
|
switch (this.state.type) {
|
|
@@ -4791,7 +4809,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4791
4809
|
parseMaybeAssign(refExpressionErrors, isParenItem) {
|
|
4792
4810
|
let state = null;
|
|
4793
4811
|
let jsx;
|
|
4794
|
-
if (this.hasPlugin("jsx") && (this.match(
|
|
4812
|
+
if (this.hasPlugin("jsx") && (this.match(141) || this.match(43))) {
|
|
4795
4813
|
state = this.state.clone();
|
|
4796
4814
|
jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, isParenItem), state);
|
|
4797
4815
|
if (!jsx.error) return jsx.node;
|
|
@@ -5006,7 +5024,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
5006
5024
|
const startLoc = this.state.startLoc;
|
|
5007
5025
|
const endOfInit = () => this.match(8) || this.match(4);
|
|
5008
5026
|
switch (this.state.type) {
|
|
5009
|
-
case
|
|
5027
|
+
case 134: {
|
|
5010
5028
|
const literal = this.parseNumericLiteral(this.state.value);
|
|
5011
5029
|
if (endOfInit()) return {
|
|
5012
5030
|
type: "number",
|
|
@@ -5015,7 +5033,7 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
5015
5033
|
};
|
|
5016
5034
|
break;
|
|
5017
5035
|
}
|
|
5018
|
-
case
|
|
5036
|
+
case 133: {
|
|
5019
5037
|
const literal = this.parseStringLiteral(this.state.value);
|
|
5020
5038
|
if (endOfInit()) return {
|
|
5021
5039
|
type: "string",
|
|
@@ -5587,12 +5605,12 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5587
5605
|
if (this.state.pos === this.state.start) {
|
|
5588
5606
|
if (ch === 60 && this.state.canStartJSXElement) {
|
|
5589
5607
|
++this.state.pos;
|
|
5590
|
-
this.finishToken(
|
|
5608
|
+
this.finishToken(141);
|
|
5591
5609
|
} else super.getTokenFromCode(ch);
|
|
5592
5610
|
return;
|
|
5593
5611
|
}
|
|
5594
5612
|
out += this.input.slice(chunkStart, this.state.pos);
|
|
5595
|
-
this.finishToken(
|
|
5613
|
+
this.finishToken(140, out);
|
|
5596
5614
|
return;
|
|
5597
5615
|
case 38:
|
|
5598
5616
|
out += this.input.slice(chunkStart, this.state.pos);
|
|
@@ -5642,7 +5660,7 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5642
5660
|
} else ++this.state.pos;
|
|
5643
5661
|
}
|
|
5644
5662
|
out += this.input.slice(chunkStart, this.state.pos++);
|
|
5645
|
-
this.finishToken(
|
|
5663
|
+
this.finishToken(133, out);
|
|
5646
5664
|
}
|
|
5647
5665
|
jsxReadEntity() {
|
|
5648
5666
|
const startPos = ++this.state.pos;
|
|
@@ -5678,11 +5696,11 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5678
5696
|
do
|
|
5679
5697
|
ch = this.input.charCodeAt(++this.state.pos);
|
|
5680
5698
|
while (isIdentifierChar(ch) || ch === 45);
|
|
5681
|
-
this.finishToken(
|
|
5699
|
+
this.finishToken(139, this.input.slice(start, this.state.pos));
|
|
5682
5700
|
}
|
|
5683
5701
|
jsxParseIdentifier() {
|
|
5684
5702
|
const node = this.startNode();
|
|
5685
|
-
if (this.match(
|
|
5703
|
+
if (this.match(139)) node.name = this.state.value;
|
|
5686
5704
|
else if (tokenIsKeyword(this.state.type)) node.name = tokenLabelName(this.state.type);
|
|
5687
5705
|
else this.unexpected();
|
|
5688
5706
|
this.next();
|
|
@@ -5719,8 +5737,8 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5719
5737
|
node = this.jsxParseExpressionContainer(node, types.j_oTag);
|
|
5720
5738
|
if (node.expression.type === "JSXEmptyExpression") this.raise(JsxErrors.AttributeIsEmpty, node);
|
|
5721
5739
|
return node;
|
|
5722
|
-
case
|
|
5723
|
-
case
|
|
5740
|
+
case 141:
|
|
5741
|
+
case 133: return this.parseExprAtom();
|
|
5724
5742
|
default: throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
|
|
5725
5743
|
}
|
|
5726
5744
|
}
|
|
@@ -5766,7 +5784,7 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5766
5784
|
return this.finishNode(node, "JSXAttribute");
|
|
5767
5785
|
}
|
|
5768
5786
|
jsxParseOpeningElementAt(startLoc) {
|
|
5769
|
-
if (this.eat(
|
|
5787
|
+
if (this.eat(142)) {
|
|
5770
5788
|
const node = this.startNodeAt(startLoc);
|
|
5771
5789
|
return this.finishNode(node, "JSXOpeningFragment");
|
|
5772
5790
|
}
|
|
@@ -5776,20 +5794,20 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5776
5794
|
}
|
|
5777
5795
|
jsxParseOpeningElementAfterName(node) {
|
|
5778
5796
|
const attributes = [];
|
|
5779
|
-
while (!this.match(52) && !this.match(
|
|
5797
|
+
while (!this.match(52) && !this.match(142)) attributes.push(this.jsxParseAttribute());
|
|
5780
5798
|
node.attributes = attributes;
|
|
5781
5799
|
node.selfClosing = this.eat(52);
|
|
5782
|
-
this.expect(
|
|
5800
|
+
this.expect(142);
|
|
5783
5801
|
return this.finishNode(node, "JSXOpeningElement");
|
|
5784
5802
|
}
|
|
5785
5803
|
jsxParseClosingElementAt(startLoc) {
|
|
5786
|
-
if (this.eat(
|
|
5804
|
+
if (this.eat(142)) {
|
|
5787
5805
|
const node = this.startNodeAt(startLoc);
|
|
5788
5806
|
return this.finishNode(node, "JSXClosingFragment");
|
|
5789
5807
|
}
|
|
5790
5808
|
const node = this.startNodeAt(startLoc);
|
|
5791
5809
|
node.name = this.jsxParseElementName();
|
|
5792
|
-
this.expect(
|
|
5810
|
+
this.expect(142);
|
|
5793
5811
|
return this.finishNode(node, "JSXClosingElement");
|
|
5794
5812
|
}
|
|
5795
5813
|
jsxParseElementAt(startLoc) {
|
|
@@ -5799,7 +5817,7 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5799
5817
|
let closingElement = null;
|
|
5800
5818
|
if (!openingElement.selfClosing) {
|
|
5801
5819
|
contents: for (;;) switch (this.state.type) {
|
|
5802
|
-
case
|
|
5820
|
+
case 141:
|
|
5803
5821
|
startLoc = this.state.startLoc;
|
|
5804
5822
|
this.next();
|
|
5805
5823
|
if (this.eat(52)) {
|
|
@@ -5808,7 +5826,7 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5808
5826
|
}
|
|
5809
5827
|
children.push(this.jsxParseElementAt(startLoc));
|
|
5810
5828
|
break;
|
|
5811
|
-
case
|
|
5829
|
+
case 140:
|
|
5812
5830
|
children.push(this.parseLiteral(this.state.value, "JSXText"));
|
|
5813
5831
|
break;
|
|
5814
5832
|
case 2: {
|
|
@@ -5848,9 +5866,9 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5848
5866
|
context[context.length - 1] = newContext;
|
|
5849
5867
|
}
|
|
5850
5868
|
parseExprAtom(refExpressionErrors) {
|
|
5851
|
-
if (this.match(
|
|
5869
|
+
if (this.match(141)) return this.jsxParseElement();
|
|
5852
5870
|
else if (this.match(43) && this.input.charCodeAt(this.state.pos) !== 33) {
|
|
5853
|
-
this.replaceToken(
|
|
5871
|
+
this.replaceToken(141);
|
|
5854
5872
|
return this.jsxParseElement();
|
|
5855
5873
|
} else return super.parseExprAtom(refExpressionErrors);
|
|
5856
5874
|
}
|
|
@@ -5870,7 +5888,7 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5870
5888
|
}
|
|
5871
5889
|
if (code === 62) {
|
|
5872
5890
|
++this.state.pos;
|
|
5873
|
-
this.finishToken(
|
|
5891
|
+
this.finishToken(142);
|
|
5874
5892
|
return;
|
|
5875
5893
|
}
|
|
5876
5894
|
if ((code === 34 || code === 39) && context === types.j_oTag) {
|
|
@@ -5880,18 +5898,18 @@ const jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
5880
5898
|
}
|
|
5881
5899
|
if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
|
|
5882
5900
|
++this.state.pos;
|
|
5883
|
-
this.finishToken(
|
|
5901
|
+
this.finishToken(141);
|
|
5884
5902
|
return;
|
|
5885
5903
|
}
|
|
5886
5904
|
super.getTokenFromCode(code);
|
|
5887
5905
|
}
|
|
5888
5906
|
updateContext(prevType) {
|
|
5889
5907
|
const { context, type } = this.state;
|
|
5890
|
-
if (type === 52 && prevType ===
|
|
5908
|
+
if (type === 52 && prevType === 141) {
|
|
5891
5909
|
context.splice(-2, 2, types.j_cTag);
|
|
5892
5910
|
this.state.canStartJSXElement = false;
|
|
5893
|
-
} else if (type ===
|
|
5894
|
-
else if (type ===
|
|
5911
|
+
} else if (type === 141) context.push(types.j_oTag);
|
|
5912
|
+
else if (type === 142) {
|
|
5895
5913
|
const out = context[context.length - 1];
|
|
5896
5914
|
if (out === types.j_oTag && prevType === 52 || out === types.j_cTag) {
|
|
5897
5915
|
context.pop();
|
|
@@ -6095,6 +6113,10 @@ var CommentsParser = class extends BaseParser {
|
|
|
6095
6113
|
case "ImportDeclaration":
|
|
6096
6114
|
adjustInnerComments(node, node.specifiers, commentWS);
|
|
6097
6115
|
break;
|
|
6116
|
+
case "ImportNamespaceSpecifier":
|
|
6117
|
+
case "ExportNamespaceSpecifier":
|
|
6118
|
+
adjustInnerComments(node, node.exportsFilter ?? [], commentWS);
|
|
6119
|
+
break;
|
|
6098
6120
|
case "TSEnumBody":
|
|
6099
6121
|
adjustInnerComments(node, node.members, commentWS);
|
|
6100
6122
|
break;
|
|
@@ -6118,6 +6140,12 @@ var CommentsParser = class extends BaseParser {
|
|
|
6118
6140
|
const commentWS = commentStack[length - 1];
|
|
6119
6141
|
if (commentWS.leadingNode === node) commentWS.leadingNode = null;
|
|
6120
6142
|
}
|
|
6143
|
+
replaceNodeInPendingComments(oldNode, newNode) {
|
|
6144
|
+
for (const commentWS of this.state.commentStack) {
|
|
6145
|
+
if (commentWS.leadingNode === oldNode) commentWS.leadingNode = newNode;
|
|
6146
|
+
if (commentWS.trailingNode === oldNode) commentWS.trailingNode = newNode;
|
|
6147
|
+
}
|
|
6148
|
+
}
|
|
6121
6149
|
takeSurroundingComments(node, start, end) {
|
|
6122
6150
|
const { commentStack } = this.state;
|
|
6123
6151
|
const commentStackLength = commentStack.length;
|
|
@@ -6231,7 +6259,7 @@ var State$1 = class State$1 {
|
|
|
6231
6259
|
commentsLen = 0;
|
|
6232
6260
|
commentStack = [];
|
|
6233
6261
|
pos = 0;
|
|
6234
|
-
type =
|
|
6262
|
+
type = 138;
|
|
6235
6263
|
value = null;
|
|
6236
6264
|
start = 0;
|
|
6237
6265
|
end = 0;
|
|
@@ -6667,7 +6695,7 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
6667
6695
|
this.state.start = this.state.pos;
|
|
6668
6696
|
if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
|
|
6669
6697
|
if (this.state.pos >= this.length) {
|
|
6670
|
-
this.finishToken(
|
|
6698
|
+
this.finishToken(138);
|
|
6671
6699
|
return;
|
|
6672
6700
|
}
|
|
6673
6701
|
this.getTokenFromCode(this.codePointAtPos(this.state.pos));
|
|
@@ -6808,10 +6836,10 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
6808
6836
|
if (next >= 48 && next <= 57) throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition());
|
|
6809
6837
|
if (isIdentifierStart(next)) {
|
|
6810
6838
|
++this.state.pos;
|
|
6811
|
-
this.finishToken(
|
|
6839
|
+
this.finishToken(137, this.readWord1(next));
|
|
6812
6840
|
} else if (next === 92) {
|
|
6813
6841
|
++this.state.pos;
|
|
6814
|
-
this.finishToken(
|
|
6842
|
+
this.finishToken(137, this.readWord1());
|
|
6815
6843
|
} else this.finishOp(23, 1);
|
|
6816
6844
|
}
|
|
6817
6845
|
readToken_dot() {
|
|
@@ -7135,7 +7163,7 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
7135
7163
|
mods += char;
|
|
7136
7164
|
}
|
|
7137
7165
|
this.state.pos = pos;
|
|
7138
|
-
this.finishToken(
|
|
7166
|
+
this.finishToken(136, {
|
|
7139
7167
|
pattern: content,
|
|
7140
7168
|
flags: mods
|
|
7141
7169
|
});
|
|
@@ -7180,12 +7208,12 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
7180
7208
|
if (isBigInt || val !== null && val > Number.MAX_SAFE_INTEGER) {
|
|
7181
7209
|
const str = this.input.slice(start, end).replaceAll("_", "");
|
|
7182
7210
|
if (isBigInt) {
|
|
7183
|
-
this.finishToken(
|
|
7211
|
+
this.finishToken(135, str);
|
|
7184
7212
|
return;
|
|
7185
7213
|
}
|
|
7186
7214
|
val = Number(radix !== 16 && this.optionFlags & 4096 ? str.replace(radix === 2 ? /[2-9]/g : /[89]/g, "0") : str);
|
|
7187
7215
|
}
|
|
7188
|
-
this.finishToken(
|
|
7216
|
+
this.finishToken(134, val);
|
|
7189
7217
|
}
|
|
7190
7218
|
readNumber(startsWithDot) {
|
|
7191
7219
|
const start = this.state.pos;
|
|
@@ -7225,16 +7253,16 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
7225
7253
|
}
|
|
7226
7254
|
if (isIdentifierStart(this.codePointAtPos(this.state.pos))) throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
|
|
7227
7255
|
if (!isFloat && !isBigInt && !hasLeadingZero && integerValue <= Number.MAX_SAFE_INTEGER) {
|
|
7228
|
-
this.finishToken(
|
|
7256
|
+
this.finishToken(134, integerValue);
|
|
7229
7257
|
return;
|
|
7230
7258
|
}
|
|
7231
7259
|
const str = this.input.slice(start, end).replaceAll("_", "");
|
|
7232
7260
|
if (isBigInt) {
|
|
7233
|
-
this.finishToken(
|
|
7261
|
+
this.finishToken(135, str);
|
|
7234
7262
|
return;
|
|
7235
7263
|
}
|
|
7236
7264
|
const val = isOctal ? parseInt(str, 8) : parseFloat(str);
|
|
7237
|
-
this.finishToken(
|
|
7265
|
+
this.finishToken(134, val);
|
|
7238
7266
|
}
|
|
7239
7267
|
readCodePoint(throwOnInvalid) {
|
|
7240
7268
|
const { code, pos } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint);
|
|
@@ -7246,7 +7274,7 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
7246
7274
|
this.state.pos = pos + 1;
|
|
7247
7275
|
this.state.lineStart = lineStart;
|
|
7248
7276
|
this.state.curLine = curLine;
|
|
7249
|
-
this.finishToken(
|
|
7277
|
+
this.finishToken(133, str);
|
|
7250
7278
|
}
|
|
7251
7279
|
readTemplateContinuation() {
|
|
7252
7280
|
if (!this.match(4)) this.unexpected(null, 4);
|
|
@@ -7306,7 +7334,7 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
7306
7334
|
const word = this.readWord1(firstCode);
|
|
7307
7335
|
const type = keywords$1.get(word);
|
|
7308
7336
|
if (type !== void 0) this.finishToken(type, tokenLabelName(type));
|
|
7309
|
-
else this.finishToken(
|
|
7337
|
+
else this.finishToken(131, word);
|
|
7310
7338
|
}
|
|
7311
7339
|
checkKeywordEscapes() {
|
|
7312
7340
|
const { type } = this.state;
|
|
@@ -7568,7 +7596,7 @@ var UtilParser = class extends Tokenizer$1 {
|
|
|
7568
7596
|
isUnparsedContextual(nameStart, name) {
|
|
7569
7597
|
if (this.input.startsWith(name, nameStart)) {
|
|
7570
7598
|
const nextCh = this.input.charCodeAt(nameStart + name.length);
|
|
7571
|
-
return !(isIdentifierChar(nextCh) || (nextCh & 64512) === 55296);
|
|
7599
|
+
return !(isIdentifierChar(nextCh) || nextCh === 92 || (nextCh & 64512) === 55296);
|
|
7572
7600
|
}
|
|
7573
7601
|
return false;
|
|
7574
7602
|
}
|
|
@@ -7590,7 +7618,7 @@ var UtilParser = class extends Tokenizer$1 {
|
|
|
7590
7618
|
}
|
|
7591
7619
|
}
|
|
7592
7620
|
canInsertSemicolon() {
|
|
7593
|
-
return this.match(
|
|
7621
|
+
return this.match(138) || this.match(4) || this.hasPrecedingLineBreak();
|
|
7594
7622
|
}
|
|
7595
7623
|
hasPrecedingLineBreak() {
|
|
7596
7624
|
return hasNewLine(this.input, this.offsetToSourcePos(this.state.lastTokEndLoc.index), this.state.start);
|
|
@@ -8039,7 +8067,7 @@ var LValParser = class extends NodeUtils {
|
|
|
8039
8067
|
const { type, startLoc } = this.state;
|
|
8040
8068
|
if (type === 17) return this.parseBindingRestProperty(this.startNode());
|
|
8041
8069
|
const prop = this.startNode();
|
|
8042
|
-
if (type ===
|
|
8070
|
+
if (type === 137) {
|
|
8043
8071
|
this.expectPlugin("destructuringPrivate", startLoc);
|
|
8044
8072
|
this.classScope.usePrivateName(this.state.value, startLoc);
|
|
8045
8073
|
prop.key = this.parsePrivateName();
|
|
@@ -8179,9 +8207,9 @@ var ExpressionParser = class extends LValParser {
|
|
|
8179
8207
|
getExpression() {
|
|
8180
8208
|
this.enterInitialScopes();
|
|
8181
8209
|
this.nextToken();
|
|
8182
|
-
if (this.match(
|
|
8210
|
+
if (this.match(138)) throw this.raise(Errors.ParseExpressionEmptyInput, this.state.startLoc);
|
|
8183
8211
|
const expr = this.parseExpression();
|
|
8184
|
-
if (!this.match(
|
|
8212
|
+
if (!this.match(138)) throw this.raise(Errors.ParseExpressionExpectsEOF, this.state.startLoc, { unexpected: this.input.codePointAt(this.state.start) });
|
|
8185
8213
|
this.finalizeRemainingComments();
|
|
8186
8214
|
expr.comments = this.comments;
|
|
8187
8215
|
expr.errors = this.state.errors;
|
|
@@ -8215,7 +8243,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8215
8243
|
}
|
|
8216
8244
|
parseMaybeAssign(refExpressionErrors, isParenItem) {
|
|
8217
8245
|
const startLoc = this.state.startLoc;
|
|
8218
|
-
const isYield = this.isContextual(
|
|
8246
|
+
const isYield = this.isContextual(107);
|
|
8219
8247
|
if (isYield) {
|
|
8220
8248
|
if (this.prodParam.hasYield) {
|
|
8221
8249
|
this.next();
|
|
@@ -8290,7 +8318,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8290
8318
|
return expr;
|
|
8291
8319
|
}
|
|
8292
8320
|
parseMaybeUnaryOrPrivate(refExpressionErrors) {
|
|
8293
|
-
return this.match(
|
|
8321
|
+
return this.match(137) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
|
|
8294
8322
|
}
|
|
8295
8323
|
parseExprOps(refExpressionErrors) {
|
|
8296
8324
|
const startLoc = this.state.startLoc;
|
|
@@ -8483,7 +8511,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8483
8511
|
if (computed) {
|
|
8484
8512
|
node.property = this.parseExpression();
|
|
8485
8513
|
this.expect(1);
|
|
8486
|
-
} else if (this.match(
|
|
8514
|
+
} else if (this.match(137)) {
|
|
8487
8515
|
if (base.type === "Super") this.raise(Errors.SuperPrivateField, startLoc);
|
|
8488
8516
|
this.classScope.usePrivateName(this.state.value, this.state.startLoc);
|
|
8489
8517
|
node.property = this.parsePrivateName();
|
|
@@ -8596,7 +8624,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8596
8624
|
case 79:
|
|
8597
8625
|
node = this.startNode();
|
|
8598
8626
|
this.next();
|
|
8599
|
-
if (this.match(12)) return this.
|
|
8627
|
+
if (this.match(12)) return this.parseImportMetaPropertyOrPhaseCallOrSyncCall(node);
|
|
8600
8628
|
if (this.match(6)) {
|
|
8601
8629
|
if (this.optionFlags & 1024) return this.parseImportCall(node);
|
|
8602
8630
|
else return this.finishNode(node, "Import");
|
|
@@ -8613,9 +8641,9 @@ var ExpressionParser = class extends LValParser {
|
|
|
8613
8641
|
case 27:
|
|
8614
8642
|
this.readRegexp();
|
|
8615
8643
|
return this.parseRegExpLiteral(this.state.value);
|
|
8616
|
-
case
|
|
8617
|
-
case
|
|
8618
|
-
case
|
|
8644
|
+
case 134: return this.parseNumericLiteral(this.state.value);
|
|
8645
|
+
case 135: return this.parseBigIntLiteral(this.state.value);
|
|
8646
|
+
case 133: return this.parseStringLiteral(this.state.value);
|
|
8619
8647
|
case 80: return this.parseNullLiteral();
|
|
8620
8648
|
case 81: return this.parseBooleanLiteral(true);
|
|
8621
8649
|
case 82: return this.parseBooleanLiteral(false);
|
|
@@ -8638,7 +8666,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8638
8666
|
if (callee.type === "MemberExpression") return this.finishNode(node, "BindExpression");
|
|
8639
8667
|
else throw this.raise(Errors.UnsupportedBind, callee);
|
|
8640
8668
|
}
|
|
8641
|
-
case
|
|
8669
|
+
case 137:
|
|
8642
8670
|
this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, { identifierName: this.state.value });
|
|
8643
8671
|
return this.parsePrivateName();
|
|
8644
8672
|
case 29: return this.parseTopicReferenceThenEqualsSign(50, "%");
|
|
@@ -8662,7 +8690,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8662
8690
|
throw this.unexpected();
|
|
8663
8691
|
}
|
|
8664
8692
|
default: if (tokenIsIdentifier(type)) {
|
|
8665
|
-
if (this.isContextual(
|
|
8693
|
+
if (this.isContextual(126) && this.lookaheadInLineCharCode() === 123) return this.parseModuleExpression();
|
|
8666
8694
|
const { canStartArrow, containsEsc } = this.state;
|
|
8667
8695
|
const id = this.parseIdentifier();
|
|
8668
8696
|
if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
|
|
@@ -8780,7 +8808,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8780
8808
|
});
|
|
8781
8809
|
return this.finishNode(node, "MetaProperty");
|
|
8782
8810
|
}
|
|
8783
|
-
|
|
8811
|
+
parseImportMetaPropertyOrPhaseCallOrSyncCall(node) {
|
|
8784
8812
|
this.next();
|
|
8785
8813
|
if (this.isContextual(102) || this.isContextual(94)) {
|
|
8786
8814
|
const isSource = this.isContextual(102);
|
|
@@ -8788,6 +8816,11 @@ var ExpressionParser = class extends LValParser {
|
|
|
8788
8816
|
this.next();
|
|
8789
8817
|
node.phase = isSource ? "source" : "defer";
|
|
8790
8818
|
return this.parseImportCall(node);
|
|
8819
|
+
} else if (this.isContextual(105)) {
|
|
8820
|
+
this.expectPlugin("importSync");
|
|
8821
|
+
this.next();
|
|
8822
|
+
node.sync = true;
|
|
8823
|
+
return this.parseImportCall(node);
|
|
8791
8824
|
} else {
|
|
8792
8825
|
const id = this.createIdentifierAt(this.startNodeAtNode(node), "import", this.state.lastTokStartLoc);
|
|
8793
8826
|
if (this.isContextual(98)) {
|
|
@@ -9120,16 +9153,16 @@ var ExpressionParser = class extends LValParser {
|
|
|
9120
9153
|
let key;
|
|
9121
9154
|
if (tokenIsKeywordOrIdentifier(type)) key = this.parseIdentifier(true);
|
|
9122
9155
|
else switch (type) {
|
|
9123
|
-
case
|
|
9156
|
+
case 134:
|
|
9124
9157
|
key = this.parseNumericLiteral(value);
|
|
9125
9158
|
break;
|
|
9126
|
-
case
|
|
9159
|
+
case 133:
|
|
9127
9160
|
key = this.parseStringLiteral(value);
|
|
9128
9161
|
break;
|
|
9129
|
-
case
|
|
9162
|
+
case 135:
|
|
9130
9163
|
key = this.parseBigIntLiteral(value);
|
|
9131
9164
|
break;
|
|
9132
|
-
case
|
|
9165
|
+
case 137: {
|
|
9133
9166
|
const privateKeyLoc = this.state.startLoc;
|
|
9134
9167
|
if (refExpressionErrors != null) {
|
|
9135
9168
|
if (refExpressionErrors.privateKeyLoc === null) refExpressionErrors.privateKeyLoc = privateKeyLoc;
|
|
@@ -9140,7 +9173,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
9140
9173
|
default: throw this.unexpected();
|
|
9141
9174
|
}
|
|
9142
9175
|
prop.key = key;
|
|
9143
|
-
if (type !==
|
|
9176
|
+
if (type !== 137) prop.computed = false;
|
|
9144
9177
|
}
|
|
9145
9178
|
}
|
|
9146
9179
|
initFunction(node, isAsync) {
|
|
@@ -9278,7 +9311,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
9278
9311
|
else this.unexpected();
|
|
9279
9312
|
const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
|
|
9280
9313
|
if (liberal) {
|
|
9281
|
-
if (tokenIsKeyword) this.replaceToken(
|
|
9314
|
+
if (tokenIsKeyword) this.replaceToken(131);
|
|
9282
9315
|
} else this.checkReservedWord(name, this.sourceToOffsetPos(start), tokenIsKeyword, false);
|
|
9283
9316
|
this.next();
|
|
9284
9317
|
return name;
|
|
@@ -9338,7 +9371,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
9338
9371
|
isAmbiguousPrefixOrIdentifier() {
|
|
9339
9372
|
if (this.hasPrecedingLineBreak()) return true;
|
|
9340
9373
|
const { type } = this.state;
|
|
9341
|
-
return type === 49 || type === 6 || type === 0 || tokenIsTemplate(type) || type === 99 && !this.state.containsEsc || type ===
|
|
9374
|
+
return type === 49 || type === 6 || type === 0 || tokenIsTemplate(type) || type === 99 && !this.state.containsEsc || type === 136 || type === 52 || this.hasPlugin("v8intrinsic") && type === 50;
|
|
9342
9375
|
}
|
|
9343
9376
|
parseYield(startLoc) {
|
|
9344
9377
|
const node = this.startNodeAt(startLoc);
|
|
@@ -9349,13 +9382,14 @@ var ExpressionParser = class extends LValParser {
|
|
|
9349
9382
|
delegating = this.eat(51);
|
|
9350
9383
|
switch (this.state.type) {
|
|
9351
9384
|
case 9:
|
|
9352
|
-
case
|
|
9385
|
+
case 138:
|
|
9353
9386
|
case 4:
|
|
9354
9387
|
case 7:
|
|
9355
9388
|
case 1:
|
|
9356
9389
|
case 5:
|
|
9357
9390
|
case 10:
|
|
9358
9391
|
case 8: if (!delegating) break;
|
|
9392
|
+
case 54: if (this.options.annexB && !delegating) break;
|
|
9359
9393
|
default: argument = this.parseMaybeAssign();
|
|
9360
9394
|
}
|
|
9361
9395
|
}
|
|
@@ -9483,7 +9517,7 @@ function createExportedTokens(tokens) {
|
|
|
9483
9517
|
}
|
|
9484
9518
|
var StatementParser = class extends ExpressionParser {
|
|
9485
9519
|
parseTopLevel(file, program) {
|
|
9486
|
-
file.program = this.parseProgram(program,
|
|
9520
|
+
file.program = this.parseProgram(program, 138, this.options.sourceType === "module" ? "module" : "script");
|
|
9487
9521
|
file.comments = this.comments;
|
|
9488
9522
|
if (this.optionFlags & 512) file.tokens = createExportedTokens(this.tokens);
|
|
9489
9523
|
return this.finishNode(file, "File");
|
|
@@ -9497,7 +9531,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
9497
9531
|
this.addExtra(program, "topLevelAwait", this.state.hasTopLevelAwait);
|
|
9498
9532
|
}
|
|
9499
9533
|
let finishedProgram;
|
|
9500
|
-
if (end ===
|
|
9534
|
+
if (end === 138) finishedProgram = this.finishNode(program, "Program");
|
|
9501
9535
|
else finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
|
|
9502
9536
|
return finishedProgram;
|
|
9503
9537
|
}
|
|
@@ -9526,11 +9560,11 @@ var StatementParser = class extends ExpressionParser {
|
|
|
9526
9560
|
return this.hasFollowingBindingAtom();
|
|
9527
9561
|
}
|
|
9528
9562
|
isUsing() {
|
|
9529
|
-
if (!this.isContextual(
|
|
9563
|
+
if (!this.isContextual(106)) return false;
|
|
9530
9564
|
return this.nextTokenIsIdentifierOnSameLine();
|
|
9531
9565
|
}
|
|
9532
9566
|
isForUsing() {
|
|
9533
|
-
if (!this.isContextual(
|
|
9567
|
+
if (!this.isContextual(106)) return false;
|
|
9534
9568
|
const next = this.nextTokenInLineStart();
|
|
9535
9569
|
const nextCh = this.codePointAtPos(next);
|
|
9536
9570
|
if (this.isUnparsedContextual(next, "of")) {
|
|
@@ -9633,6 +9667,13 @@ var StatementParser = class extends ExpressionParser {
|
|
|
9633
9667
|
case 76:
|
|
9634
9668
|
if (!allowDeclaration) this.unexpected();
|
|
9635
9669
|
return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
|
|
9670
|
+
case 104:
|
|
9671
|
+
if (!this.state.containsEsc && this.nextTokenIsIdentifierOnSameLine()) {
|
|
9672
|
+
this.expectPlugin("structs");
|
|
9673
|
+
if (!allowDeclaration) this.unexpected();
|
|
9674
|
+
return this.parseStructDeclaration(node, false);
|
|
9675
|
+
}
|
|
9676
|
+
break;
|
|
9636
9677
|
case 65: return this.parseIfStatement(node);
|
|
9637
9678
|
case 66: return this.parseReturnStatement(node);
|
|
9638
9679
|
case 67: return this.parseSwitchStatement(node);
|
|
@@ -9647,7 +9688,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
9647
9688
|
return this.parseVarStatement(node, "await using");
|
|
9648
9689
|
}
|
|
9649
9690
|
break;
|
|
9650
|
-
case
|
|
9691
|
+
case 106:
|
|
9651
9692
|
if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifierOrBrace()) break;
|
|
9652
9693
|
if (!this.allowsUsing()) this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc);
|
|
9653
9694
|
else if (!allowDeclaration) this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
|
|
@@ -9748,7 +9789,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
9748
9789
|
while (this.eat(12)) {
|
|
9749
9790
|
const node = this.startNodeAt(startLoc);
|
|
9750
9791
|
node.object = expr;
|
|
9751
|
-
if (this.match(
|
|
9792
|
+
if (this.match(137)) {
|
|
9752
9793
|
this.classScope.usePrivateName(this.state.value, this.state.startLoc);
|
|
9753
9794
|
node.property = this.parsePrivateName();
|
|
9754
9795
|
} else node.property = this.parseIdentifier(true);
|
|
@@ -10247,7 +10288,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10247
10288
|
this.parsePropertyNamePrefixOperator(member);
|
|
10248
10289
|
if (this.eat(51)) {
|
|
10249
10290
|
method.kind = "method";
|
|
10250
|
-
const isPrivateName = this.match(
|
|
10291
|
+
const isPrivateName = this.match(137);
|
|
10251
10292
|
this.parseClassElementName(method);
|
|
10252
10293
|
this.parsePostMemberNameModifiers(method);
|
|
10253
10294
|
if (isPrivateName) {
|
|
@@ -10289,7 +10330,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10289
10330
|
const isGenerator = this.eat(51);
|
|
10290
10331
|
if (publicMember.optional) this.unexpected(maybeQuestionTokenStartLoc);
|
|
10291
10332
|
method.kind = "method";
|
|
10292
|
-
const isPrivate = this.match(
|
|
10333
|
+
const isPrivate = this.match(137);
|
|
10293
10334
|
this.parseClassElementName(method);
|
|
10294
10335
|
this.parsePostMemberNameModifiers(publicMember);
|
|
10295
10336
|
if (isPrivate) this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
|
|
@@ -10300,7 +10341,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10300
10341
|
} else if ((maybeContextualKw === "get" || maybeContextualKw === "set") && !(this.match(51) && this.isLineTerminator())) {
|
|
10301
10342
|
this.resetPreviousNodeTrailingComments(key);
|
|
10302
10343
|
method.kind = maybeContextualKw;
|
|
10303
|
-
const isPrivate = this.match(
|
|
10344
|
+
const isPrivate = this.match(137);
|
|
10304
10345
|
this.parseClassElementName(publicMethod);
|
|
10305
10346
|
if (isPrivate) this.pushClassPrivateMethod(classBody, privateMethod, false, false);
|
|
10306
10347
|
else {
|
|
@@ -10311,7 +10352,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10311
10352
|
} else if (maybeContextualKw === "accessor" && !this.isLineTerminator()) {
|
|
10312
10353
|
this.expectPlugin("decoratorAutoAccessors");
|
|
10313
10354
|
this.resetPreviousNodeTrailingComments(key);
|
|
10314
|
-
const isPrivate = this.match(
|
|
10355
|
+
const isPrivate = this.match(137);
|
|
10315
10356
|
this.parseClassElementName(publicProp);
|
|
10316
10357
|
this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
|
|
10317
10358
|
} else if (this.isLineTerminator()) {
|
|
@@ -10321,8 +10362,8 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10321
10362
|
}
|
|
10322
10363
|
parseClassElementName(member) {
|
|
10323
10364
|
const { type, value } = this.state;
|
|
10324
|
-
if ((type ===
|
|
10325
|
-
if (type ===
|
|
10365
|
+
if ((type === 131 || type === 133) && member.static && value === "prototype") this.raise(Errors.StaticPrototype, this.state.startLoc);
|
|
10366
|
+
if (type === 137) {
|
|
10326
10367
|
if (value === "constructor") this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
|
|
10327
10368
|
const key = this.parsePrivateName();
|
|
10328
10369
|
member.key = key;
|
|
@@ -10410,6 +10451,34 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10410
10451
|
node.superClass = this.parseExprSubscripts();
|
|
10411
10452
|
} else node.superClass = null;
|
|
10412
10453
|
}
|
|
10454
|
+
parseStructDeclaration(node, optionalId) {
|
|
10455
|
+
this.next();
|
|
10456
|
+
const oldStrict = this.state.strict;
|
|
10457
|
+
this.state.strict = true;
|
|
10458
|
+
this.parseClassId(node, true, optionalId);
|
|
10459
|
+
this.parseClassSuper(node);
|
|
10460
|
+
node.body = this.parseStructBody(!!node.superClass, oldStrict);
|
|
10461
|
+
return this.finishNode(node, "StructDeclaration");
|
|
10462
|
+
}
|
|
10463
|
+
parseStructBody(hadSuperClass, oldStrict) {
|
|
10464
|
+
this.classScope.enter();
|
|
10465
|
+
const state = {
|
|
10466
|
+
hadConstructor: false,
|
|
10467
|
+
hadSuperClass
|
|
10468
|
+
};
|
|
10469
|
+
const structBody = this.startNode();
|
|
10470
|
+
structBody.body = [];
|
|
10471
|
+
this.expect(2);
|
|
10472
|
+
while (!this.match(4)) {
|
|
10473
|
+
if (this.eat(9)) continue;
|
|
10474
|
+
const member = this.startNode();
|
|
10475
|
+
this.parseClassMember(structBody, member, state);
|
|
10476
|
+
}
|
|
10477
|
+
this.state.strict = oldStrict;
|
|
10478
|
+
this.next();
|
|
10479
|
+
this.classScope.exit();
|
|
10480
|
+
return this.finishNode(structBody, "StructBody");
|
|
10481
|
+
}
|
|
10413
10482
|
parseExport(node, decorators) {
|
|
10414
10483
|
const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
|
|
10415
10484
|
const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
|
|
@@ -10417,15 +10486,16 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10417
10486
|
const hasStar = parseAfterDefault && this.eatExportStar(node);
|
|
10418
10487
|
const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
|
|
10419
10488
|
const parseAfterNamespace = parseAfterDefault && !hasNamespace;
|
|
10420
|
-
const isFromRequired = hasDefault || hasStar;
|
|
10421
10489
|
if (hasStar && !hasNamespace) {
|
|
10422
10490
|
if (hasDefault) this.unexpected();
|
|
10423
10491
|
if (decorators) throw this.raise(Errors.UnsupportedDecoratorExport, node);
|
|
10492
|
+
if (node.phase === "defer") this.raise(Errors.DeferExportInvalidAll, node);
|
|
10424
10493
|
this.parseExportFrom(node, true);
|
|
10425
10494
|
this.sawUnambiguousESM = true;
|
|
10426
10495
|
return this.finishNode(node, "ExportAllDeclaration");
|
|
10427
10496
|
}
|
|
10428
10497
|
const hasSpecifiers = parseAfterNamespace && this.maybeParseExportNamedSpecifiers(node);
|
|
10498
|
+
const isFromRequired = hasDefault || hasStar || node.phase === "defer" || hasSpecifiers && node.specifiers[0]?.type === "ExportNamespaceSpecifier";
|
|
10429
10499
|
if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) this.unexpected(null, 2);
|
|
10430
10500
|
let hasDeclaration;
|
|
10431
10501
|
if (isFromRequired || hasSpecifiers) {
|
|
@@ -10438,6 +10508,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10438
10508
|
this.checkNamedExport(node2, !!node2.source);
|
|
10439
10509
|
if (node2.declaration?.type === "ClassDeclaration") this.maybeTakeDecorators(decorators, node2.declaration, node2);
|
|
10440
10510
|
else if (decorators) throw this.raise(Errors.UnsupportedDecoratorExport, node);
|
|
10511
|
+
if (this.hasPlugin("deferredReexports")) node2.phase ??= null;
|
|
10441
10512
|
this.sawUnambiguousESM = true;
|
|
10442
10513
|
return this.finishNode(node2, "ExportNamedDeclaration");
|
|
10443
10514
|
}
|
|
@@ -10486,7 +10557,17 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10486
10557
|
const node2 = node;
|
|
10487
10558
|
if (!node2.specifiers) node2.specifiers = [];
|
|
10488
10559
|
const isTypeExport = node2.exportKind === "type";
|
|
10489
|
-
|
|
10560
|
+
const startLoc = this.state.startLoc;
|
|
10561
|
+
this.setLoc(startLoc);
|
|
10562
|
+
const specifiers = this.parseExportSpecifiers(isTypeExport);
|
|
10563
|
+
if (this.isContextual(90) && !this.hasPrecedingLineBreak()) {
|
|
10564
|
+
this.expectPlugin("namespaceImportFilter");
|
|
10565
|
+
const specifier = this.startNodeAt(startLoc);
|
|
10566
|
+
specifier.exportsFilter = this.toNamespaceExportsFilter(specifiers);
|
|
10567
|
+
this.next();
|
|
10568
|
+
specifier.exported = this.parseModuleExportName();
|
|
10569
|
+
node2.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
|
|
10570
|
+
} else node2.specifiers.push(...specifiers);
|
|
10490
10571
|
node2.source = null;
|
|
10491
10572
|
node2.attributes = [];
|
|
10492
10573
|
node2.declaration = null;
|
|
@@ -10520,6 +10601,14 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10520
10601
|
return this.parseFunction(expr, 13);
|
|
10521
10602
|
}
|
|
10522
10603
|
if (this.match(76)) return this.parseClass(expr, true, true);
|
|
10604
|
+
if (this.isContextual(104)) {
|
|
10605
|
+
const next = this.nextTokenInLineStart();
|
|
10606
|
+
const nextCh = this.codePointAtPos(next);
|
|
10607
|
+
if (nextCh === 123 || this.chStartsBindingIdentifier(nextCh, next)) {
|
|
10608
|
+
this.expectPlugin("structs");
|
|
10609
|
+
return this.parseStructDeclaration(expr, true);
|
|
10610
|
+
}
|
|
10611
|
+
}
|
|
10523
10612
|
if (this.match(22)) return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
|
|
10524
10613
|
if (this.match(71) || this.match(70) || this.isLet() && !this.isReservedWordOnNewLineAfterLet(this.nextTokenStart()) || this.isUsing() || this.isAwaitUsing()) throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
|
|
10525
10614
|
const res = this.parseMaybeAssignAllowIn();
|
|
@@ -10528,6 +10617,10 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10528
10617
|
}
|
|
10529
10618
|
parseExportDeclaration(node) {
|
|
10530
10619
|
if (this.match(76)) return this.parseClass(this.startNode(), true, false);
|
|
10620
|
+
if (this.isContextual(104) && this.nextTokenIsIdentifierOnSameLine()) {
|
|
10621
|
+
this.expectPlugin("structs");
|
|
10622
|
+
return this.parseStructDeclaration(this.startNode(), false);
|
|
10623
|
+
}
|
|
10531
10624
|
if (this.isContextual(97)) return this.parseVarStatement(this.startNode(), "let");
|
|
10532
10625
|
return this.parseStatementListItem();
|
|
10533
10626
|
}
|
|
@@ -10535,11 +10628,11 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10535
10628
|
const { type } = this.state;
|
|
10536
10629
|
if (tokenIsIdentifier(type)) {
|
|
10537
10630
|
if (type === 92 && !this.state.containsEsc || type === 97) return false;
|
|
10538
|
-
if ((type ===
|
|
10631
|
+
if ((type === 129 || type === 128 || type === 104) && !this.state.containsEsc) {
|
|
10539
10632
|
const next = this.nextTokenStart();
|
|
10540
10633
|
const nextChar = this.input.charCodeAt(next);
|
|
10541
|
-
if (nextChar === 123 || this.chStartsBindingIdentifier(nextChar, next) && !this.
|
|
10542
|
-
this.expectOnePlugin(["flow", "typescript"]);
|
|
10634
|
+
if (nextChar === 123 || this.chStartsBindingIdentifier(nextChar, next) && !this.isUnparsedContextual(next, "from")) {
|
|
10635
|
+
if (type !== 104) this.expectOnePlugin(["flow", "typescript"]);
|
|
10543
10636
|
return false;
|
|
10544
10637
|
}
|
|
10545
10638
|
}
|
|
@@ -10574,7 +10667,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10574
10667
|
this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
|
|
10575
10668
|
return true;
|
|
10576
10669
|
}
|
|
10577
|
-
return type === 70 || type === 71 || type === 64 || type === 76 || this.isLet() || this.isAsyncFunction();
|
|
10670
|
+
return type === 70 || type === 71 || type === 64 || type === 76 || this.isLet() || this.isAsyncFunction() || this.isContextual(104) && this.nextTokenIsIdentifierOnSameLine();
|
|
10578
10671
|
}
|
|
10579
10672
|
checkNamedExport(node, isFrom) {
|
|
10580
10673
|
if (node.specifiers?.length) for (const specifier of node.specifiers) {
|
|
@@ -10595,7 +10688,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10595
10688
|
}
|
|
10596
10689
|
else if (node.declaration) {
|
|
10597
10690
|
const decl = node.declaration;
|
|
10598
|
-
if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration") {
|
|
10691
|
+
if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration" || decl.type === "StructDeclaration") {
|
|
10599
10692
|
const { id } = decl;
|
|
10600
10693
|
if (!id) throw new Error("Assertion failure");
|
|
10601
10694
|
this.checkDuplicateExports(node, id.name);
|
|
@@ -10628,8 +10721,8 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10628
10721
|
this.expect(8);
|
|
10629
10722
|
if (this.eat(4)) break;
|
|
10630
10723
|
}
|
|
10631
|
-
const isMaybeTypeOnly = this.isContextual(
|
|
10632
|
-
const isString = this.match(
|
|
10724
|
+
const isMaybeTypeOnly = this.isContextual(129);
|
|
10725
|
+
const isString = this.match(133);
|
|
10633
10726
|
const node = this.startNode();
|
|
10634
10727
|
node.local = this.parseModuleExportName();
|
|
10635
10728
|
nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
|
|
@@ -10643,7 +10736,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10643
10736
|
return this.finishNode(node, "ExportSpecifier");
|
|
10644
10737
|
}
|
|
10645
10738
|
parseModuleExportName() {
|
|
10646
|
-
if (this.match(
|
|
10739
|
+
if (this.match(133)) {
|
|
10647
10740
|
const result = this.parseStringLiteral(this.state.value);
|
|
10648
10741
|
const surrogate = loneSurrogate.exec(result.value);
|
|
10649
10742
|
if (surrogate) this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, { surrogateCharCode: surrogate[0].charCodeAt(0) });
|
|
@@ -10651,6 +10744,31 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10651
10744
|
}
|
|
10652
10745
|
return this.parseIdentifier(true);
|
|
10653
10746
|
}
|
|
10747
|
+
toNamespaceExportsFilter(specifiers) {
|
|
10748
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10749
|
+
return specifiers.map((specifier) => {
|
|
10750
|
+
let name, alias, kind;
|
|
10751
|
+
if (specifier.type === "ImportSpecifier") ({imported: name, local: alias, importKind: kind} = specifier);
|
|
10752
|
+
else ({local: name, exported: alias, exportKind: kind} = specifier);
|
|
10753
|
+
const nameString = name.type === "Identifier" ? name.name : this.isStringModuleExportName(name) ? name.value : null;
|
|
10754
|
+
if (nameString !== null) {
|
|
10755
|
+
if (seen.has(nameString)) this.raise(Errors.FilteredNamespaceDuplicateName, name, { name: nameString });
|
|
10756
|
+
seen.add(nameString);
|
|
10757
|
+
}
|
|
10758
|
+
let invalid = false;
|
|
10759
|
+
if (alias.start !== name.start) {
|
|
10760
|
+
this.raise(Errors.FilteredNamespaceRename, alias);
|
|
10761
|
+
invalid = true;
|
|
10762
|
+
}
|
|
10763
|
+
if (kind === "type" || kind === "typeof") {
|
|
10764
|
+
this.raise(Errors.FilteredNamespaceTypeModifier, specifier);
|
|
10765
|
+
invalid = true;
|
|
10766
|
+
}
|
|
10767
|
+
if (invalid) return specifier;
|
|
10768
|
+
this.replaceNodeInPendingComments(specifier, name);
|
|
10769
|
+
return name;
|
|
10770
|
+
});
|
|
10771
|
+
}
|
|
10654
10772
|
checkImportPhase(node) {
|
|
10655
10773
|
if (node.phase == null) return;
|
|
10656
10774
|
const { specifiers } = node;
|
|
@@ -10662,11 +10780,21 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10662
10780
|
}
|
|
10663
10781
|
}
|
|
10664
10782
|
isPotentialImportPhase(isExport) {
|
|
10665
|
-
if (isExport)
|
|
10783
|
+
if (isExport) {
|
|
10784
|
+
if (!this.isContextual(94)) return false;
|
|
10785
|
+
const ch = this.lookaheadCharCode();
|
|
10786
|
+
return ch === 123 || ch === 42;
|
|
10787
|
+
}
|
|
10666
10788
|
return this.isContextual(102) || this.isContextual(94);
|
|
10667
10789
|
}
|
|
10668
10790
|
applyImportPhase(node, isExport, phase, loc) {
|
|
10669
|
-
if (isExport)
|
|
10791
|
+
if (isExport) {
|
|
10792
|
+
if (phase === "defer") {
|
|
10793
|
+
this.expectPlugin("deferredReexports", loc);
|
|
10794
|
+
node.phase = "defer";
|
|
10795
|
+
}
|
|
10796
|
+
return;
|
|
10797
|
+
}
|
|
10670
10798
|
if (phase === "source") {
|
|
10671
10799
|
this.expectPlugin("sourcePhaseImports", loc);
|
|
10672
10800
|
node.phase = "source";
|
|
@@ -10696,14 +10824,14 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10696
10824
|
return tokenIsIdentifier(type) ? type !== 95 || this.lookaheadCharCode() === 102 : type !== 8;
|
|
10697
10825
|
}
|
|
10698
10826
|
parseImport(node) {
|
|
10699
|
-
if (this.match(
|
|
10827
|
+
if (this.match(133)) return this.parseImportSourceAndAttributes(node);
|
|
10700
10828
|
return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
|
|
10701
10829
|
}
|
|
10702
10830
|
parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier) {
|
|
10703
10831
|
node.specifiers = [];
|
|
10704
10832
|
const parseNext = !this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier) || this.eat(8);
|
|
10705
10833
|
const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
|
|
10706
|
-
if (parseNext && !hasStar) this.
|
|
10834
|
+
if (parseNext && !hasStar) this.parseNamedOrFilteredImportSpecifiers(node);
|
|
10707
10835
|
this.expectContextual(95);
|
|
10708
10836
|
return this.parseImportSourceAndAttributes(node);
|
|
10709
10837
|
}
|
|
@@ -10717,15 +10845,15 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10717
10845
|
return this.finishNode(node, "ImportDeclaration");
|
|
10718
10846
|
}
|
|
10719
10847
|
parseImportSource() {
|
|
10720
|
-
if (!this.match(
|
|
10848
|
+
if (!this.match(133)) this.unexpected();
|
|
10721
10849
|
return this.parseExprAtom();
|
|
10722
10850
|
}
|
|
10723
10851
|
parseImportSpecifierLocal(node, specifier, type) {
|
|
10724
10852
|
specifier.local = this.parseIdentifier();
|
|
10725
10853
|
node.specifiers.push(this.finishImportSpecifier(specifier, type));
|
|
10726
10854
|
}
|
|
10727
|
-
finishImportSpecifier(specifier, type
|
|
10728
|
-
this.checkLVal(specifier.local, { type },
|
|
10855
|
+
finishImportSpecifier(specifier, type) {
|
|
10856
|
+
this.checkLVal(specifier.local, { type }, 8201);
|
|
10729
10857
|
return this.finishNode(specifier, type);
|
|
10730
10858
|
}
|
|
10731
10859
|
parseImportAttributes() {
|
|
@@ -10738,10 +10866,10 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10738
10866
|
const keyName = this.state.value;
|
|
10739
10867
|
if (attrNames.has(keyName)) this.raise(Errors.ModuleAttributesWithDuplicateKeys, this.state.startLoc, { key: keyName });
|
|
10740
10868
|
attrNames.add(keyName);
|
|
10741
|
-
if (this.match(
|
|
10869
|
+
if (this.match(133)) node.key = this.parseStringLiteral(keyName);
|
|
10742
10870
|
else node.key = this.parseIdentifier(true);
|
|
10743
10871
|
this.expect(10);
|
|
10744
|
-
if (!this.match(
|
|
10872
|
+
if (!this.match(133)) throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
|
|
10745
10873
|
node.value = this.parseStringLiteral(this.state.value);
|
|
10746
10874
|
attrs.push(this.finishNode(node, "ImportAttribute"));
|
|
10747
10875
|
} while (this.eat(8));
|
|
@@ -10779,6 +10907,22 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10779
10907
|
}
|
|
10780
10908
|
return false;
|
|
10781
10909
|
}
|
|
10910
|
+
parseNamedOrFilteredImportSpecifiers(node) {
|
|
10911
|
+
const startLoc = this.state.startLoc;
|
|
10912
|
+
this.setLoc(startLoc);
|
|
10913
|
+
const specifiersStart = node.specifiers.length;
|
|
10914
|
+
this.parseNamedImportSpecifiers(node);
|
|
10915
|
+
if (this.isContextual(90)) {
|
|
10916
|
+
this.expectPlugin("namespaceImportFilter");
|
|
10917
|
+
const specifier = this.startNodeAt(startLoc);
|
|
10918
|
+
specifier.exportsFilter = this.toNamespaceExportsFilter(node.specifiers.splice(specifiersStart));
|
|
10919
|
+
this.next();
|
|
10920
|
+
this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier");
|
|
10921
|
+
return;
|
|
10922
|
+
}
|
|
10923
|
+
const isInTypeOnlyImport = node.importKind === "type" || node.importKind === "typeof";
|
|
10924
|
+
for (let i = specifiersStart; i < node.specifiers.length; i++) this.checkImportSpecifier(node.specifiers[i], isInTypeOnlyImport);
|
|
10925
|
+
}
|
|
10782
10926
|
parseNamedImportSpecifiers(node) {
|
|
10783
10927
|
let first = true;
|
|
10784
10928
|
this.expect(2);
|
|
@@ -10790,22 +10934,26 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10790
10934
|
if (this.eat(4)) break;
|
|
10791
10935
|
}
|
|
10792
10936
|
const specifier = this.startNode();
|
|
10793
|
-
const importedIsString = this.match(
|
|
10794
|
-
const isMaybeTypeOnly = this.isContextual(
|
|
10937
|
+
const importedIsString = this.match(133);
|
|
10938
|
+
const isMaybeTypeOnly = this.isContextual(129);
|
|
10795
10939
|
specifier.imported = this.parseModuleExportName();
|
|
10796
|
-
const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly
|
|
10940
|
+
const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly);
|
|
10797
10941
|
node.specifiers.push(importSpecifier);
|
|
10798
10942
|
}
|
|
10799
10943
|
}
|
|
10800
|
-
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly
|
|
10944
|
+
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly) {
|
|
10801
10945
|
if (this.eatContextual(90)) specifier.local = this.parseIdentifier();
|
|
10802
|
-
else
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
}
|
|
10808
|
-
|
|
10946
|
+
else specifier.local ??= this.cloneIdentifier(specifier.imported);
|
|
10947
|
+
return this.finishNode(specifier, "ImportSpecifier");
|
|
10948
|
+
}
|
|
10949
|
+
checkImportSpecifier(specifier, isInTypeOnlyImport, bindingType = 8201, checkReservedWord = true) {
|
|
10950
|
+
const { imported, local } = specifier;
|
|
10951
|
+
if (this.isStringModuleExportName(local)) throw this.raise(Errors.ImportBindingIsString, specifier, { importName: imported.value });
|
|
10952
|
+
if (checkReservedWord && local.start === imported.start) this.checkReservedWord(local.name, local.start, true, true);
|
|
10953
|
+
this.checkLVal(local, { type: "ImportSpecifier" }, bindingType);
|
|
10954
|
+
}
|
|
10955
|
+
isStringModuleExportName(node) {
|
|
10956
|
+
return node.type === "StringLiteral" || node.type === "Literal";
|
|
10809
10957
|
}
|
|
10810
10958
|
isThisParam(param) {
|
|
10811
10959
|
return param.type === "Identifier" && param.name === "this";
|
|
@@ -10975,7 +11123,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
10975
11123
|
return tokenIsIdentifier(this.state.type);
|
|
10976
11124
|
}
|
|
10977
11125
|
tsTokenCanFollowModifier() {
|
|
10978
|
-
return this.match(0) || this.match(2) || this.match(51) || this.match(17) || this.match(
|
|
11126
|
+
return this.match(0) || this.match(2) || this.match(51) || this.match(17) || this.match(137) || this.isLiteralPropertyName();
|
|
10979
11127
|
}
|
|
10980
11128
|
tsNextTokenOnSameLineAndCanFollowModifier() {
|
|
10981
11129
|
this.next();
|
|
@@ -11093,7 +11241,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11093
11241
|
const node = this.startNode();
|
|
11094
11242
|
this.expect(79);
|
|
11095
11243
|
this.expect(6);
|
|
11096
|
-
if (!this.match(
|
|
11244
|
+
if (!this.match(133)) {
|
|
11097
11245
|
this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
|
|
11098
11246
|
node.source = this.tsParseNonConditionalType();
|
|
11099
11247
|
} else node.source = this.parseStringLiteral(this.state.value);
|
|
@@ -11127,7 +11275,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11127
11275
|
this.expect(2);
|
|
11128
11276
|
while (!this.match(4)) {
|
|
11129
11277
|
const type = this.state.type;
|
|
11130
|
-
if (tokenIsIdentifier(type) || type ===
|
|
11278
|
+
if (tokenIsIdentifier(type) || type === 133) properties.push(super.parsePropertyDefinition(null));
|
|
11131
11279
|
else this.unexpected();
|
|
11132
11280
|
this.eat(8);
|
|
11133
11281
|
}
|
|
@@ -11217,7 +11365,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11217
11365
|
}
|
|
11218
11366
|
tsParseTypeParameters(parseModifiers) {
|
|
11219
11367
|
const node = this.startNode();
|
|
11220
|
-
if (this.match(43) || this.match(
|
|
11368
|
+
if (this.match(43) || this.match(141)) this.next();
|
|
11221
11369
|
else this.unexpected();
|
|
11222
11370
|
const refTrailingCommaPos = { value: -1 };
|
|
11223
11371
|
node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
|
|
@@ -11341,8 +11489,8 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11341
11489
|
}
|
|
11342
11490
|
tsIsStartOfMappedType() {
|
|
11343
11491
|
this.next();
|
|
11344
|
-
if (this.eat(49)) return this.isContextual(
|
|
11345
|
-
if (this.isContextual(
|
|
11492
|
+
if (this.eat(49)) return this.isContextual(121);
|
|
11493
|
+
if (this.isContextual(121)) this.next();
|
|
11346
11494
|
if (!this.match(0)) return false;
|
|
11347
11495
|
this.next();
|
|
11348
11496
|
if (!this.tsIsIdentifier()) return false;
|
|
@@ -11355,8 +11503,8 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11355
11503
|
if (this.match(49)) {
|
|
11356
11504
|
node.readonly = this.state.value;
|
|
11357
11505
|
this.next();
|
|
11358
|
-
this.expectContextual(
|
|
11359
|
-
} else if (this.eatContextual(
|
|
11506
|
+
this.expectContextual(121);
|
|
11507
|
+
} else if (this.eatContextual(121)) node.readonly = true;
|
|
11360
11508
|
this.expect(0);
|
|
11361
11509
|
node.key = this.tsParseTypeParameterName();
|
|
11362
11510
|
node.constraint = this.tsExpectThenParseType(54);
|
|
@@ -11469,9 +11617,9 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11469
11617
|
tsParseLiteralTypeNode() {
|
|
11470
11618
|
const node = this.startNode();
|
|
11471
11619
|
switch (this.state.type) {
|
|
11472
|
-
case
|
|
11620
|
+
case 134:
|
|
11621
|
+
case 135:
|
|
11473
11622
|
case 133:
|
|
11474
|
-
case 131:
|
|
11475
11623
|
case 81:
|
|
11476
11624
|
case 82:
|
|
11477
11625
|
node.literal = super.parseExprAtom();
|
|
@@ -11510,21 +11658,21 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11510
11658
|
}
|
|
11511
11659
|
tsParseThisTypeOrThisTypePredicate() {
|
|
11512
11660
|
const thisKeyword = this.tsParseThisTypeNode();
|
|
11513
|
-
if (this.isContextual(
|
|
11661
|
+
if (this.isContextual(115) && !this.hasPrecedingLineBreak()) return this.tsParseThisTypePredicate(thisKeyword);
|
|
11514
11662
|
else return thisKeyword;
|
|
11515
11663
|
}
|
|
11516
11664
|
tsParseNonArrayType() {
|
|
11517
11665
|
switch (this.state.type) {
|
|
11518
|
-
case 131:
|
|
11519
|
-
case 132:
|
|
11520
11666
|
case 133:
|
|
11667
|
+
case 134:
|
|
11668
|
+
case 135:
|
|
11521
11669
|
case 81:
|
|
11522
11670
|
case 82: return this.tsParseLiteralTypeNode();
|
|
11523
11671
|
case 49:
|
|
11524
11672
|
if (this.state.value === "-") {
|
|
11525
11673
|
const node = this.startNode();
|
|
11526
11674
|
const nextToken = this.lookahead();
|
|
11527
|
-
if (nextToken.type !==
|
|
11675
|
+
if (nextToken.type !== 134 && nextToken.type !== 135) this.unexpected();
|
|
11528
11676
|
node.literal = this.parseMaybeUnary();
|
|
11529
11677
|
return this.finishNode(node, "TSLiteralType");
|
|
11530
11678
|
}
|
|
@@ -11597,7 +11745,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11597
11745
|
}
|
|
11598
11746
|
tsParseInferType() {
|
|
11599
11747
|
const node = this.startNode();
|
|
11600
|
-
this.expectContextual(
|
|
11748
|
+
this.expectContextual(114);
|
|
11601
11749
|
const typeParameter = this.startNode();
|
|
11602
11750
|
typeParameter.name = this.tsParseTypeParameterName();
|
|
11603
11751
|
typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
|
|
@@ -11611,7 +11759,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11611
11759
|
}
|
|
11612
11760
|
}
|
|
11613
11761
|
tsParseTypeOperatorOrHigher() {
|
|
11614
|
-
return tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc ? this.tsParseTypeOperator() : this.isContextual(
|
|
11762
|
+
return tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc ? this.tsParseTypeOperator() : this.isContextual(114) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
|
|
11615
11763
|
}
|
|
11616
11764
|
tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
|
|
11617
11765
|
const node = this.startNode();
|
|
@@ -11716,13 +11864,13 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11716
11864
|
}
|
|
11717
11865
|
tsParseTypePredicatePrefix() {
|
|
11718
11866
|
const id = this.parseIdentifier();
|
|
11719
|
-
if (this.isContextual(
|
|
11867
|
+
if (this.isContextual(115) && !this.hasPrecedingLineBreak()) {
|
|
11720
11868
|
this.next();
|
|
11721
11869
|
return id;
|
|
11722
11870
|
}
|
|
11723
11871
|
}
|
|
11724
11872
|
tsParseTypePredicateAsserts() {
|
|
11725
|
-
if (this.state.type !==
|
|
11873
|
+
if (this.state.type !== 108) return false;
|
|
11726
11874
|
const containsEsc = this.state.containsEsc;
|
|
11727
11875
|
this.next();
|
|
11728
11876
|
if (!tokenIsIdentifier(this.state.type) && !this.match(74)) return false;
|
|
@@ -11750,7 +11898,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11750
11898
|
return this.finishNode(node, "TSConditionalType");
|
|
11751
11899
|
}
|
|
11752
11900
|
isAbstractConstructorSignature() {
|
|
11753
|
-
return this.isContextual(
|
|
11901
|
+
return this.isContextual(123) && this.isLookaheadContextual("new");
|
|
11754
11902
|
}
|
|
11755
11903
|
tsParseNonConditionalType() {
|
|
11756
11904
|
if (this.tsIsStartOfFunctionType()) return this.tsParseFunctionOrConstructorType("TSFunctionType");
|
|
@@ -11790,7 +11938,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11790
11938
|
}
|
|
11791
11939
|
tsParseInterfaceDeclaration(node, properties = {}) {
|
|
11792
11940
|
if (this.hasFollowingLineBreak()) return null;
|
|
11793
|
-
this.expectContextual(
|
|
11941
|
+
this.expectContextual(128);
|
|
11794
11942
|
if (properties.declare) node.declare = true;
|
|
11795
11943
|
if (tokenIsIdentifier(this.state.type)) {
|
|
11796
11944
|
node.id = this.parseIdentifier();
|
|
@@ -11812,7 +11960,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11812
11960
|
node.typeAnnotation = this.tsInType(() => {
|
|
11813
11961
|
node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
|
|
11814
11962
|
this.expect(25);
|
|
11815
|
-
if (this.isContextual(
|
|
11963
|
+
if (this.isContextual(113) && this.lookaheadCharCode() !== 46) {
|
|
11816
11964
|
const node = this.startNode();
|
|
11817
11965
|
this.next();
|
|
11818
11966
|
return this.finishNode(node, "TSIntrinsicKeyword");
|
|
@@ -11877,14 +12025,14 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11877
12025
|
}
|
|
11878
12026
|
tsParseEnumMember() {
|
|
11879
12027
|
const node = this.startNode();
|
|
11880
|
-
node.id = this.match(
|
|
12028
|
+
node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
|
|
11881
12029
|
if (this.eat(25)) node.initializer = super.parseMaybeAssignAllowIn();
|
|
11882
12030
|
return this.finishNode(node, "TSEnumMember");
|
|
11883
12031
|
}
|
|
11884
12032
|
tsParseEnumDeclaration(node, properties = {}) {
|
|
11885
12033
|
if (properties.const) node.const = true;
|
|
11886
12034
|
if (properties.declare) node.declare = true;
|
|
11887
|
-
this.expectContextual(
|
|
12035
|
+
this.expectContextual(125);
|
|
11888
12036
|
node.id = this.parseIdentifier();
|
|
11889
12037
|
this.checkIdentifier(node.id, node.const ? 8971 : 8459);
|
|
11890
12038
|
node.body = this.tsParseEnumBody();
|
|
@@ -11916,14 +12064,14 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11916
12064
|
return this.finishNode(node, "TSModuleDeclaration");
|
|
11917
12065
|
}
|
|
11918
12066
|
tsParseAmbientExternalModuleDeclaration(node) {
|
|
11919
|
-
const isGlobal = this.isContextual(
|
|
12067
|
+
const isGlobal = this.isContextual(111);
|
|
11920
12068
|
if (isGlobal) {
|
|
11921
12069
|
node.kind = "global";
|
|
11922
12070
|
node.id = this.parseIdentifier();
|
|
11923
12071
|
} else {
|
|
11924
12072
|
node.kind = "module";
|
|
11925
12073
|
const { type, value } = this.state;
|
|
11926
|
-
if (type ===
|
|
12074
|
+
if (type === 133) node.id = super.parseStringLiteral(value);
|
|
11927
12075
|
else if (tokenIsIdentifier(type)) {
|
|
11928
12076
|
this.raise(TSErrors.InlineModuleDeclarationMustUseString, this.state.startLoc);
|
|
11929
12077
|
node.id = this.tsParseEntityName(0);
|
|
@@ -11953,16 +12101,16 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11953
12101
|
return this.finishNode(node, "TSImportEqualsDeclaration");
|
|
11954
12102
|
}
|
|
11955
12103
|
tsIsExternalModuleReference() {
|
|
11956
|
-
return this.isContextual(
|
|
12104
|
+
return this.isContextual(118) && this.lookaheadCharCode() === 40;
|
|
11957
12105
|
}
|
|
11958
12106
|
tsParseModuleReference() {
|
|
11959
12107
|
return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(0);
|
|
11960
12108
|
}
|
|
11961
12109
|
tsParseExternalModuleReference() {
|
|
11962
12110
|
const node = this.startNode();
|
|
11963
|
-
this.expectContextual(
|
|
12111
|
+
this.expectContextual(118);
|
|
11964
12112
|
this.expect(6);
|
|
11965
|
-
if (!this.match(
|
|
12113
|
+
if (!this.match(133)) this.unexpected();
|
|
11966
12114
|
node.expression = super.parseExprAtom();
|
|
11967
12115
|
this.expect(7);
|
|
11968
12116
|
this.sawUnambiguousESM = true;
|
|
@@ -11997,8 +12145,8 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11997
12145
|
case 76:
|
|
11998
12146
|
node.declare = true;
|
|
11999
12147
|
return this.parseClass(node, true, false);
|
|
12000
|
-
case
|
|
12001
|
-
case
|
|
12148
|
+
case 125: return this.tsParseEnumDeclaration(node, { declare: true });
|
|
12149
|
+
case 111: return this.tsParseAmbientExternalModuleDeclaration(node);
|
|
12002
12150
|
case 97: if (this.state.containsEsc) return;
|
|
12003
12151
|
case 71:
|
|
12004
12152
|
case 70:
|
|
@@ -12011,7 +12159,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12011
12159
|
const: true,
|
|
12012
12160
|
declare: true
|
|
12013
12161
|
});
|
|
12014
|
-
case
|
|
12162
|
+
case 106:
|
|
12015
12163
|
if (this.isUsing()) {
|
|
12016
12164
|
this.raise(TSErrors.InvalidModifierOnUsingDeclaration, this.state.startLoc, "declare");
|
|
12017
12165
|
node.declare = true;
|
|
@@ -12026,7 +12174,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12026
12174
|
return this.parseVarStatement(node, "await using", true);
|
|
12027
12175
|
}
|
|
12028
12176
|
break;
|
|
12029
|
-
case
|
|
12177
|
+
case 128: {
|
|
12030
12178
|
const result = this.tsParseInterfaceDeclaration(node, { declare: true });
|
|
12031
12179
|
if (result) return result;
|
|
12032
12180
|
}
|
|
@@ -12039,19 +12187,19 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12039
12187
|
}
|
|
12040
12188
|
tsParseDeclaration(node, type, next, decorators) {
|
|
12041
12189
|
switch (type) {
|
|
12042
|
-
case
|
|
12190
|
+
case 123:
|
|
12043
12191
|
if (this.tsCheckLineTerminator(next) && (this.match(76) || tokenIsIdentifier(this.state.type))) return this.tsParseAbstractDeclaration(node, decorators);
|
|
12044
12192
|
break;
|
|
12045
|
-
case
|
|
12193
|
+
case 126:
|
|
12046
12194
|
if (this.tsCheckLineTerminator(next)) return this.tsParseAmbientExternalModuleDeclaration(node);
|
|
12047
12195
|
break;
|
|
12048
|
-
case
|
|
12196
|
+
case 127:
|
|
12049
12197
|
if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
|
|
12050
12198
|
node.kind = "namespace";
|
|
12051
12199
|
return this.tsParseNamespaceDeclaration(node);
|
|
12052
12200
|
}
|
|
12053
12201
|
break;
|
|
12054
|
-
case
|
|
12202
|
+
case 129: if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) return this.tsParseTypeAliasDeclaration(node);
|
|
12055
12203
|
}
|
|
12056
12204
|
}
|
|
12057
12205
|
tsCheckLineTerminator(next) {
|
|
@@ -12215,7 +12363,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12215
12363
|
return this.finishCallExpression(node, state.optionalChainMember);
|
|
12216
12364
|
}
|
|
12217
12365
|
const tokenType = this.state.type;
|
|
12218
|
-
if (tokenType === 44 || tokenType === 48 || tokenType !== 6 && tokenType !== 90 && tokenType !==
|
|
12366
|
+
if (tokenType === 44 || tokenType === 48 || tokenType !== 6 && tokenType !== 90 && tokenType !== 119 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) return;
|
|
12219
12367
|
const node = this.startNodeAt(startLoc);
|
|
12220
12368
|
node.expression = base;
|
|
12221
12369
|
node.typeArguments = typeArguments;
|
|
@@ -12242,7 +12390,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12242
12390
|
}
|
|
12243
12391
|
parseExprOp(left, leftStartLoc, minPrec) {
|
|
12244
12392
|
let isSatisfies;
|
|
12245
|
-
if (tokenOperatorPrecedence(54) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(90) || (isSatisfies = this.isContextual(
|
|
12393
|
+
if (tokenOperatorPrecedence(54) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(90) || (isSatisfies = this.isContextual(119)))) {
|
|
12246
12394
|
const node = this.startNodeAt(leftStartLoc);
|
|
12247
12395
|
node.expression = left;
|
|
12248
12396
|
node.typeAnnotation = this.tsInType(() => {
|
|
@@ -12265,7 +12413,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12265
12413
|
checkDuplicateExports() {}
|
|
12266
12414
|
isPotentialImportPhase(isExport) {
|
|
12267
12415
|
if (super.isPotentialImportPhase(isExport)) return true;
|
|
12268
|
-
if (this.isContextual(
|
|
12416
|
+
if (this.isContextual(129)) {
|
|
12269
12417
|
const ch = this.lookaheadCharCode();
|
|
12270
12418
|
return isExport ? ch === 123 || ch === 42 : ch !== 61;
|
|
12271
12419
|
}
|
|
@@ -12277,7 +12425,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12277
12425
|
else node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
|
|
12278
12426
|
}
|
|
12279
12427
|
parseImport(node) {
|
|
12280
|
-
if (this.match(
|
|
12428
|
+
if (this.match(133)) {
|
|
12281
12429
|
node.importKind = "value";
|
|
12282
12430
|
if (this.scope.inTSNamespace) this.raise(TSErrors.ImportInTSNamespace, node);
|
|
12283
12431
|
return super.parseImport(node);
|
|
@@ -12288,7 +12436,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12288
12436
|
const result = this.tsParseImportEqualsDeclaration(node);
|
|
12289
12437
|
if (this.scope.inTSNamespace && result.moduleReference.type === "TSExternalModuleReference") this.raise(TSErrors.ImportInTSNamespace, node);
|
|
12290
12438
|
return result;
|
|
12291
|
-
} else if (this.isContextual(
|
|
12439
|
+
} else if (this.isContextual(129)) {
|
|
12292
12440
|
const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
|
|
12293
12441
|
if (this.lookaheadCharCode() === 61) {
|
|
12294
12442
|
if (this.scope.inTSNamespace) this.raise(TSErrors.ImportInTSNamespace, node);
|
|
@@ -12304,7 +12452,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12304
12452
|
const nodeImportEquals = this.startNode();
|
|
12305
12453
|
this.next();
|
|
12306
12454
|
let maybeDefaultIdentifier = null;
|
|
12307
|
-
if (this.isContextual(
|
|
12455
|
+
if (this.isContextual(129) && this.isPotentialImportPhase(false)) maybeDefaultIdentifier = this.parseMaybeImportPhase(nodeImportEquals, false);
|
|
12308
12456
|
else nodeImportEquals.importKind = "value";
|
|
12309
12457
|
const declaration = this.tsParseImportEqualsDeclaration(nodeImportEquals, maybeDefaultIdentifier);
|
|
12310
12458
|
node.attributes = [];
|
|
@@ -12322,7 +12470,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12322
12470
|
return this.finishNode(assign, "TSExportAssignment");
|
|
12323
12471
|
} else if (this.eatContextual(90)) {
|
|
12324
12472
|
const decl = node;
|
|
12325
|
-
this.expectContextual(
|
|
12473
|
+
this.expectContextual(127);
|
|
12326
12474
|
decl.id = this.parseIdentifier();
|
|
12327
12475
|
this.checkIdentifier(decl.id, 8201);
|
|
12328
12476
|
this.semicolon();
|
|
@@ -12335,7 +12483,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12335
12483
|
}
|
|
12336
12484
|
}
|
|
12337
12485
|
isAbstractClass() {
|
|
12338
|
-
return this.isContextual(
|
|
12486
|
+
return this.isContextual(123) && this.isLookaheadContextual("class");
|
|
12339
12487
|
}
|
|
12340
12488
|
parseExportDefaultExpression() {
|
|
12341
12489
|
if (this.isAbstractClass()) {
|
|
@@ -12344,7 +12492,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12344
12492
|
cls.abstract = true;
|
|
12345
12493
|
return this.parseClass(cls, true, true);
|
|
12346
12494
|
}
|
|
12347
|
-
if (this.match(
|
|
12495
|
+
if (this.match(128)) {
|
|
12348
12496
|
const result = this.tsParseInterfaceDeclaration(this.startNode());
|
|
12349
12497
|
if (result) return result;
|
|
12350
12498
|
}
|
|
@@ -12380,31 +12528,31 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12380
12528
|
return this.tsParseEnumDeclaration(node, { const: true });
|
|
12381
12529
|
}
|
|
12382
12530
|
break;
|
|
12383
|
-
case
|
|
12384
|
-
case
|
|
12531
|
+
case 123:
|
|
12532
|
+
case 124:
|
|
12385
12533
|
if (this.nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine()) {
|
|
12386
12534
|
const token = this.state.type;
|
|
12387
12535
|
const node = this.startNode();
|
|
12388
12536
|
this.next();
|
|
12389
|
-
const declaration = token ===
|
|
12537
|
+
const declaration = token === 124 ? this.tsTryParseDeclare(node) : this.tsParseAbstractDeclaration(node, decorators);
|
|
12390
12538
|
if (declaration) {
|
|
12391
|
-
if (token ===
|
|
12539
|
+
if (token === 124) declaration.declare = true;
|
|
12392
12540
|
return declaration;
|
|
12393
12541
|
} else {
|
|
12394
|
-
node.expression = this.createIdentifier(this.startNodeAtNode(node), token ===
|
|
12542
|
+
node.expression = this.createIdentifier(this.startNodeAtNode(node), token === 124 ? "declare" : "abstract");
|
|
12395
12543
|
this.semicolon(false);
|
|
12396
12544
|
return this.finishNode(node, "ExpressionStatement");
|
|
12397
12545
|
}
|
|
12398
12546
|
}
|
|
12399
12547
|
break;
|
|
12400
|
-
case
|
|
12401
|
-
case
|
|
12548
|
+
case 125: return this.tsParseEnumDeclaration(this.startNode());
|
|
12549
|
+
case 111:
|
|
12402
12550
|
if (this.lookaheadCharCode() === 123) {
|
|
12403
12551
|
const node = this.startNode();
|
|
12404
12552
|
return this.tsParseAmbientExternalModuleDeclaration(node);
|
|
12405
12553
|
}
|
|
12406
12554
|
break;
|
|
12407
|
-
case
|
|
12555
|
+
case 128: {
|
|
12408
12556
|
const result = this.tsParseInterfaceDeclaration(this.startNode());
|
|
12409
12557
|
if (result) {
|
|
12410
12558
|
if (!allowDeclaration) this.raise(TSErrors.UnexpectedTypeDeclaration, result, "interface");
|
|
@@ -12412,26 +12560,26 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12412
12560
|
}
|
|
12413
12561
|
break;
|
|
12414
12562
|
}
|
|
12415
|
-
case
|
|
12563
|
+
case 126:
|
|
12416
12564
|
if (this.nextTokenIsStringLiteralOnSameLine()) {
|
|
12417
12565
|
const node = this.startNode();
|
|
12418
12566
|
this.next();
|
|
12419
|
-
return this.tsParseDeclaration(node,
|
|
12567
|
+
return this.tsParseDeclaration(node, 126, false, decorators);
|
|
12420
12568
|
} else if (this.nextTokenIsIdentifierOnSameLine()) {
|
|
12421
12569
|
this.raise(TSErrors.InlineModuleDeclarationMustUseString, this.state.startLoc);
|
|
12422
12570
|
const node = this.startNode();
|
|
12423
12571
|
this.next();
|
|
12424
|
-
return this.tsParseDeclaration(node,
|
|
12572
|
+
return this.tsParseDeclaration(node, 127, false, decorators);
|
|
12425
12573
|
}
|
|
12426
12574
|
break;
|
|
12427
|
-
case
|
|
12575
|
+
case 127:
|
|
12428
12576
|
if (this.nextTokenIsIdentifierOnSameLine()) {
|
|
12429
12577
|
const node = this.startNode();
|
|
12430
12578
|
this.next();
|
|
12431
|
-
return this.tsParseDeclaration(node,
|
|
12579
|
+
return this.tsParseDeclaration(node, 127, false, decorators);
|
|
12432
12580
|
}
|
|
12433
12581
|
break;
|
|
12434
|
-
case
|
|
12582
|
+
case 129: if (this.nextTokenIsIdentifierOnSameLine()) {
|
|
12435
12583
|
const node = this.startNode();
|
|
12436
12584
|
if (!allowDeclaration) this.raise(TSErrors.UnexpectedTypeDeclaration, node, "type");
|
|
12437
12585
|
this.next();
|
|
@@ -12538,10 +12686,10 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12538
12686
|
return node;
|
|
12539
12687
|
}
|
|
12540
12688
|
parseExportDeclaration(node) {
|
|
12541
|
-
if (!this.state.isAmbientContext && this.isContextual(
|
|
12689
|
+
if (!this.state.isAmbientContext && this.isContextual(124)) return this.tsInAmbientContext(() => this.parseExportDeclaration(node));
|
|
12542
12690
|
const startLoc = this.state.startLoc;
|
|
12543
|
-
const isDeclare = this.eatContextual(
|
|
12544
|
-
if (isDeclare && (this.isContextual(
|
|
12691
|
+
const isDeclare = this.eatContextual(124);
|
|
12692
|
+
if (isDeclare && (this.isContextual(124) || !this.shouldParseExportDeclaration())) throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc);
|
|
12545
12693
|
const declaration = tokenIsIdentifier(this.state.type) && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(node);
|
|
12546
12694
|
if (!declaration) return null;
|
|
12547
12695
|
if (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare) node.exportKind = "type";
|
|
@@ -12552,7 +12700,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12552
12700
|
return declaration;
|
|
12553
12701
|
}
|
|
12554
12702
|
parseClassId(node, isStatement, optionalId, bindingType) {
|
|
12555
|
-
if ((!isStatement || optionalId) && this.isContextual(
|
|
12703
|
+
if ((!isStatement || optionalId) && this.isContextual(112)) {
|
|
12556
12704
|
node.id = null;
|
|
12557
12705
|
return;
|
|
12558
12706
|
}
|
|
@@ -12623,7 +12771,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12623
12771
|
node.superTypeArguments = superTypeArguments;
|
|
12624
12772
|
} else if (this.match(43) || this.match(47)) node.superTypeArguments = this.tsParseTypeArgumentsInExpression();
|
|
12625
12773
|
}
|
|
12626
|
-
if (this.eatContextual(
|
|
12774
|
+
if (this.eatContextual(112)) node.implements = this.tsParseHeritageClause("implements");
|
|
12627
12775
|
}
|
|
12628
12776
|
parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
|
|
12629
12777
|
const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
|
|
@@ -12652,7 +12800,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12652
12800
|
let state;
|
|
12653
12801
|
let jsx;
|
|
12654
12802
|
let typeCast;
|
|
12655
|
-
if (this.hasPlugin("jsx") && (this.match(
|
|
12803
|
+
if (this.hasPlugin("jsx") && (this.match(141) || this.match(43))) {
|
|
12656
12804
|
state = this.state.clone();
|
|
12657
12805
|
jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, isParenItem), state);
|
|
12658
12806
|
if (!jsx.error) return jsx.node;
|
|
@@ -12911,7 +13059,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12911
13059
|
if (this.match(76)) {
|
|
12912
13060
|
node.abstract = true;
|
|
12913
13061
|
return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false));
|
|
12914
|
-
} else if (this.isContextual(
|
|
13062
|
+
} else if (this.isContextual(128)) {
|
|
12915
13063
|
if (!this.hasFollowingLineBreak()) {
|
|
12916
13064
|
node.abstract = true;
|
|
12917
13065
|
this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifier, node);
|
|
@@ -12952,15 +13100,20 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12952
13100
|
node.exportKind = "value";
|
|
12953
13101
|
return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly);
|
|
12954
13102
|
}
|
|
12955
|
-
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly
|
|
13103
|
+
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly) {
|
|
12956
13104
|
if (!importedIsString && isMaybeTypeOnly) {
|
|
12957
|
-
this.parseTypeOnlyImportSpecifier(specifier
|
|
13105
|
+
this.parseTypeOnlyImportSpecifier(specifier);
|
|
12958
13106
|
return this.finishNode(specifier, "ImportSpecifier");
|
|
12959
13107
|
}
|
|
12960
13108
|
specifier.importKind = "value";
|
|
12961
|
-
return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly
|
|
13109
|
+
return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly);
|
|
12962
13110
|
}
|
|
12963
|
-
|
|
13111
|
+
checkImportSpecifier(specifier, isInTypeOnlyImport) {
|
|
13112
|
+
const hasTypeSpecifier = specifier.importKind === "type";
|
|
13113
|
+
if (hasTypeSpecifier && isInTypeOnlyImport) this.raise(TSErrors.TypeModifierIsUsedInTypeImports, specifier);
|
|
13114
|
+
super.checkImportSpecifier(specifier, isInTypeOnlyImport, hasTypeSpecifier || isInTypeOnlyImport ? 4098 : 4096);
|
|
13115
|
+
}
|
|
13116
|
+
parseTypeOnlyImportSpecifier(node) {
|
|
12964
13117
|
let leftOfAs = node.imported;
|
|
12965
13118
|
let hasTypeSpecifier = false;
|
|
12966
13119
|
if (this.isContextual(90)) {
|
|
@@ -12980,12 +13133,10 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12980
13133
|
} else if (tokenIsKeywordOrIdentifier(this.state.type)) {
|
|
12981
13134
|
hasTypeSpecifier = true;
|
|
12982
13135
|
leftOfAs = this.parseIdentifier(true);
|
|
12983
|
-
if (!this.isContextual(90)) this.checkReservedWord(leftOfAs.name, leftOfAs.start, true, true);
|
|
12984
13136
|
}
|
|
12985
|
-
if (hasTypeSpecifier && isInTypeOnly) this.raise(TSErrors.TypeModifierIsUsedInTypeImports, node.imported);
|
|
12986
13137
|
node.imported = leftOfAs;
|
|
12987
13138
|
node.importKind = hasTypeSpecifier ? "type" : "value";
|
|
12988
|
-
|
|
13139
|
+
node.local ??= this.eatContextual(90) ? this.parseIdentifier() : this.cloneIdentifier(node.imported);
|
|
12989
13140
|
}
|
|
12990
13141
|
parseTypeOnlyExportSpecifier(node, isInTypeOnly) {
|
|
12991
13142
|
const local = node.local;
|
|
@@ -13188,13 +13339,13 @@ const PlaceholderErrors = ParseErrorEnum`placeholders`({
|
|
|
13188
13339
|
});
|
|
13189
13340
|
const placeholders = (superClass) => class PlaceholdersParserMixin extends superClass {
|
|
13190
13341
|
parsePlaceholder(expectedNode) {
|
|
13191
|
-
if (this.match(
|
|
13342
|
+
if (this.match(132)) {
|
|
13192
13343
|
const node = this.startNode();
|
|
13193
13344
|
this.next();
|
|
13194
13345
|
this.assertNoSpace();
|
|
13195
13346
|
node.name = super.parseIdentifier(true);
|
|
13196
13347
|
this.assertNoSpace();
|
|
13197
|
-
this.expect(
|
|
13348
|
+
this.expect(132);
|
|
13198
13349
|
return this.finishPlaceholder(node, expectedNode);
|
|
13199
13350
|
}
|
|
13200
13351
|
}
|
|
@@ -13205,7 +13356,7 @@ const placeholders = (superClass) => class PlaceholdersParserMixin extends super
|
|
|
13205
13356
|
return placeholder;
|
|
13206
13357
|
}
|
|
13207
13358
|
getTokenFromCode(code) {
|
|
13208
|
-
if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) this.finishOp(
|
|
13359
|
+
if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) this.finishOp(132, 2);
|
|
13209
13360
|
else super.getTokenFromCode(code);
|
|
13210
13361
|
}
|
|
13211
13362
|
parseExprAtom(refExpressionErrors) {
|
|
@@ -13272,7 +13423,7 @@ const placeholders = (superClass) => class PlaceholdersParserMixin extends super
|
|
|
13272
13423
|
const oldStrict = this.state.strict;
|
|
13273
13424
|
const placeholder = this.parsePlaceholder("Identifier");
|
|
13274
13425
|
if (placeholder) {
|
|
13275
|
-
if (this.match(77) || this.match(
|
|
13426
|
+
if (this.match(77) || this.match(132) || this.match(2)) node.id = placeholder;
|
|
13276
13427
|
else if (optionalId || !isStatement) {
|
|
13277
13428
|
node.id = null;
|
|
13278
13429
|
node.body = this.finishPlaceholder(placeholder, "ClassBody");
|
|
@@ -13303,7 +13454,7 @@ const placeholders = (superClass) => class PlaceholdersParserMixin extends super
|
|
|
13303
13454
|
if (this.match(61)) {
|
|
13304
13455
|
const next = this.nextTokenStart();
|
|
13305
13456
|
if (this.isUnparsedContextual(next, "from")) {
|
|
13306
|
-
if (this.input.startsWith(tokenLabelName(
|
|
13457
|
+
if (this.input.startsWith(tokenLabelName(132), this.hasPlugin("exportDefaultFrom") ? this.nextTokenStartSince(next + 4) : this.nextTokenInLineStartSince(next + 4))) return true;
|
|
13307
13458
|
}
|
|
13308
13459
|
}
|
|
13309
13460
|
return super.isExportDefaultSpecifier();
|
|
@@ -13326,7 +13477,7 @@ const placeholders = (superClass) => class PlaceholdersParserMixin extends super
|
|
|
13326
13477
|
specifier.local = placeholder;
|
|
13327
13478
|
node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier"));
|
|
13328
13479
|
if (this.eat(8)) {
|
|
13329
|
-
if (!this.maybeParseStarImportSpecifier(node)) this.
|
|
13480
|
+
if (!this.maybeParseStarImportSpecifier(node)) this.parseNamedOrFilteredImportSpecifiers(node);
|
|
13330
13481
|
}
|
|
13331
13482
|
this.expectContextual(95);
|
|
13332
13483
|
node.source = this.parseImportSource();
|
|
@@ -13404,6 +13555,7 @@ function validatePlugins(pluginsMap) {
|
|
|
13404
13555
|
if (pluginsMap.has("discardBinding") && pluginsMap.get("discardBinding").syntaxType !== "void") throw new Error("The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.");
|
|
13405
13556
|
if (pluginsMap.has("decimal")) throw new Error("The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.");
|
|
13406
13557
|
if (pluginsMap.has("importReflection")) throw new Error("The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.");
|
|
13558
|
+
if (pluginsMap.has("deferredReexports") && !pluginsMap.has("deferredImportEvaluation")) throw new Error("The 'deferredReexports' plugin requires 'deferredImportEvaluation'.");
|
|
13407
13559
|
}
|
|
13408
13560
|
const mixinPlugins = {
|
|
13409
13561
|
estree,
|
|
@@ -13489,7 +13641,7 @@ function generateExportedTokenTypes(internalTokenTypes) {
|
|
|
13489
13641
|
for (const typeName of Object.keys(internalTokenTypes)) tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]);
|
|
13490
13642
|
return tokenTypes;
|
|
13491
13643
|
}
|
|
13492
|
-
generateExportedTokenTypes(tt);
|
|
13644
|
+
generateExportedTokenTypes(tt$1);
|
|
13493
13645
|
function getParser(options, input) {
|
|
13494
13646
|
let cls = Parser$1;
|
|
13495
13647
|
const pluginsMap = /* @__PURE__ */ new Map();
|
|
@@ -13518,39 +13670,1258 @@ function getParserClass(pluginsMap) {
|
|
|
13518
13670
|
}
|
|
13519
13671
|
return cls;
|
|
13520
13672
|
}
|
|
13673
|
+
// ../../mpcore/packages/simulator/src/view/templateExpression/stringLiteral.ts
|
|
13674
|
+
const literalValues = /* @__PURE__ */ new WeakMap();
|
|
13675
|
+
function decodeObservedLiteral(raw) {
|
|
13676
|
+
const quote = raw[0];
|
|
13677
|
+
if (quote !== "'" && quote !== "\"" || raw.at(-1) !== quote) return;
|
|
13678
|
+
let value = "";
|
|
13679
|
+
for (let index = 1; index < raw.length - 1; index++) {
|
|
13680
|
+
const character = raw[index];
|
|
13681
|
+
if (character !== "\\") {
|
|
13682
|
+
value += character;
|
|
13683
|
+
continue;
|
|
13684
|
+
}
|
|
13685
|
+
const escaped = raw[++index];
|
|
13686
|
+
if (escaped === "\\") value += "\\";
|
|
13687
|
+
else if (escaped === quote) value += quote === "'" ? "\\x27" : "\\x22";
|
|
13688
|
+
else return;
|
|
13689
|
+
}
|
|
13690
|
+
return value;
|
|
13691
|
+
}
|
|
13692
|
+
/** 仅消费真实 WXML 已确认的引号与反斜杠规则;其他转义整段沿用 Babel 值,尚不声明宿主兼容。 */
|
|
13693
|
+
function resolveWxmlStringLiteral(node) {
|
|
13694
|
+
if (typeof node.value !== "string") return node.value;
|
|
13695
|
+
const cached = literalValues.get(node);
|
|
13696
|
+
if (cached !== void 0) return cached;
|
|
13697
|
+
const raw = node.extra?.raw;
|
|
13698
|
+
const value = typeof raw === "string" ? decodeObservedLiteral(raw) ?? node.value : node.value;
|
|
13699
|
+
literalValues.set(node, value);
|
|
13700
|
+
return value;
|
|
13701
|
+
}
|
|
13702
|
+
// ../../node_modules/.pnpm/entities@9.0.0/node_modules/entities/dist/decode-codepoint.js
|
|
13703
|
+
/**
|
|
13704
|
+
* True for NUL, UTF-16 surrogates, and values past U+10FFFF.
|
|
13705
|
+
* @param codePoint Unicode code point to check.
|
|
13706
|
+
*/
|
|
13707
|
+
function isInvalidCodePoint$1(codePoint) {
|
|
13708
|
+
return codePoint === 0 || codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111;
|
|
13709
|
+
}
|
|
13710
|
+
/**
|
|
13711
|
+
* XML numeric character references are the referenced Unicode code point.
|
|
13712
|
+
* Invalid values still become U+FFFD; the HTML Windows-1252 C1 remap is not
|
|
13713
|
+
* applied.
|
|
13714
|
+
* @see https://www.w3.org/TR/xml/#NT-CharRef
|
|
13715
|
+
* @param codePoint Unicode code point to convert.
|
|
13716
|
+
*/
|
|
13717
|
+
function replaceCodePointXML$1(codePoint) {
|
|
13718
|
+
return isInvalidCodePoint$1(codePoint) ? 65533 : codePoint;
|
|
13719
|
+
}
|
|
13720
|
+
// ../../node_modules/.pnpm/entities@9.0.0/node_modules/entities/dist/decode.js
|
|
13721
|
+
const CHAR_AMP = 38;
|
|
13722
|
+
const CHAR_NUM = 35;
|
|
13723
|
+
const CHAR_SEMI = 59;
|
|
13724
|
+
const CHAR_ZERO = 48;
|
|
13725
|
+
const CHAR_LOWER_A = 97;
|
|
13726
|
+
const CHAR_LOWER_X = 120;
|
|
13727
|
+
const CHAR_UPPER_A = 65;
|
|
13728
|
+
/** Bit that needs to be set to convert an upper case ASCII character to lower case */
|
|
13729
|
+
const TO_LOWER_BIT$1 = 32;
|
|
13730
|
+
/**
|
|
13731
|
+
* Decoding mode for named entities.
|
|
13732
|
+
*/
|
|
13733
|
+
var DecodingMode$1;
|
|
13734
|
+
(function(DecodingMode) {
|
|
13735
|
+
/** Entities in text nodes that can end with any character. */
|
|
13736
|
+
DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
|
|
13737
|
+
/** Only allow entities terminated with a semicolon. */
|
|
13738
|
+
DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
|
|
13739
|
+
/** Entities in attributes have limitations on ending characters. */
|
|
13740
|
+
DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
|
|
13741
|
+
})(DecodingMode$1 || (DecodingMode$1 = {}));
|
|
13742
|
+
/**
|
|
13743
|
+
* `parseNumericEntity` packs its two results into one integer:
|
|
13744
|
+
* `(consumed << CONSUMED_SHIFT) | codePoint`. The code point occupies the low
|
|
13745
|
+
* 21 bits (max 0x110000, clamped before packing); `consumed` takes the upper
|
|
13746
|
+
* 11 bits and is read back with `>>> CONSUMED_SHIFT`, so the sign bit set by a
|
|
13747
|
+
* large `consumed` is harmless. The maximum consumed field is reserved for
|
|
13748
|
+
* long references, whose full length is stored in `longNumericConsumed`.
|
|
13749
|
+
* A zero return means "no numeric entity".
|
|
13750
|
+
*/
|
|
13751
|
+
const NUMERIC_CONSUMED_SHIFT = 21;
|
|
13752
|
+
const NUMERIC_CODE_POINT_MASK = 2097151;
|
|
13753
|
+
const NUMERIC_CONSUMED_OVERFLOW = 2047;
|
|
13754
|
+
/** Full length, including `&`, when the packed consumed field overflows. */
|
|
13755
|
+
let longNumericConsumed = 0;
|
|
13756
|
+
/**
|
|
13757
|
+
* Recover the consumed count before the next numeric parse can overwrite
|
|
13758
|
+
* `longNumericConsumed`. This avoids allocating a tuple for each reference.
|
|
13759
|
+
* @param packed Packed result of `parseNumericEntity`.
|
|
13760
|
+
*/
|
|
13761
|
+
function unpackConsumed(packed) {
|
|
13762
|
+
const consumed = packed >>> NUMERIC_CONSUMED_SHIFT;
|
|
13763
|
+
return consumed === NUMERIC_CONSUMED_OVERFLOW ? longNumericConsumed : consumed;
|
|
13764
|
+
}
|
|
13765
|
+
/** ASCII digit values; 0xff marks characters outside the hexadecimal range. */
|
|
13766
|
+
const numericDigits = /* #__PURE__ */ (() => {
|
|
13767
|
+
const digits = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
|
|
13768
|
+
for (let digit = 0; digit < 10; digit++) digits[CHAR_ZERO + digit] = digit;
|
|
13769
|
+
for (let digit = 0; digit < 6; digit++) {
|
|
13770
|
+
digits[CHAR_UPPER_A + digit] = digit + 10;
|
|
13771
|
+
digits[CHAR_LOWER_A + digit] = digit + 10;
|
|
13772
|
+
}
|
|
13773
|
+
return digits;
|
|
13774
|
+
})();
|
|
13775
|
+
/**
|
|
13776
|
+
* Parse a numeric entity starting right after the `#`. In legacy mode the
|
|
13777
|
+
* terminating semicolon is optional. Returns the number of characters
|
|
13778
|
+
* consumed (counting the `&` and `#`) packed with the code point (see
|
|
13779
|
+
* the packing constants above), or 0 if there is no valid numeric entity at this
|
|
13780
|
+
* position.
|
|
13781
|
+
* @param input Input string.
|
|
13782
|
+
* @param offset Index right after the `#`.
|
|
13783
|
+
* @param isStrict Whether a terminating semicolon is required.
|
|
13784
|
+
*/
|
|
13785
|
+
function parseNumericEntity(input, offset, isStrict) {
|
|
13786
|
+
const inputLength = input.length;
|
|
13787
|
+
let index = offset;
|
|
13788
|
+
let codePoint = 0;
|
|
13789
|
+
let digitsStart;
|
|
13790
|
+
if ((input.charCodeAt(index) | TO_LOWER_BIT$1) === CHAR_LOWER_X) {
|
|
13791
|
+
index += 1;
|
|
13792
|
+
digitsStart = index;
|
|
13793
|
+
while (index < inputLength) {
|
|
13794
|
+
const char = input.charCodeAt(index);
|
|
13795
|
+
if (char >= 128) break;
|
|
13796
|
+
const digit = numericDigits[char];
|
|
13797
|
+
if (digit <= 15) {
|
|
13798
|
+
codePoint = codePoint * 16 + digit;
|
|
13799
|
+
index++;
|
|
13800
|
+
} else break;
|
|
13801
|
+
}
|
|
13802
|
+
} else {
|
|
13803
|
+
digitsStart = index;
|
|
13804
|
+
while (index < inputLength) {
|
|
13805
|
+
const char = input.charCodeAt(index);
|
|
13806
|
+
if (char >= 128) break;
|
|
13807
|
+
const digit = numericDigits[char];
|
|
13808
|
+
if (digit <= 9) {
|
|
13809
|
+
codePoint = codePoint * 10 + digit;
|
|
13810
|
+
index++;
|
|
13811
|
+
} else break;
|
|
13812
|
+
}
|
|
13813
|
+
}
|
|
13814
|
+
if (index === digitsStart) return 0;
|
|
13815
|
+
if (codePoint > 1114111) codePoint = 1114112;
|
|
13816
|
+
let consumed = index - offset + 2;
|
|
13817
|
+
if (index < inputLength && input.charCodeAt(index) === CHAR_SEMI) consumed += 1;
|
|
13818
|
+
else if (isStrict) return 0;
|
|
13819
|
+
if (consumed >= NUMERIC_CONSUMED_OVERFLOW) {
|
|
13820
|
+
longNumericConsumed = consumed;
|
|
13821
|
+
consumed = NUMERIC_CONSUMED_OVERFLOW;
|
|
13822
|
+
}
|
|
13823
|
+
return consumed << NUMERIC_CONSUMED_SHIFT | codePoint;
|
|
13824
|
+
}
|
|
13825
|
+
/**
|
|
13826
|
+
* Decodes an XML string, requiring all entities to be terminated by a
|
|
13827
|
+
* semicolon.
|
|
13828
|
+
* @param xmlString The string to decode.
|
|
13829
|
+
* @returns The decoded string.
|
|
13830
|
+
*/
|
|
13831
|
+
function decodeXML(xmlString) {
|
|
13832
|
+
let offset = xmlString.indexOf("&");
|
|
13833
|
+
if (offset < 0) return xmlString;
|
|
13834
|
+
let lastIndex = 0;
|
|
13835
|
+
let result = "";
|
|
13836
|
+
do {
|
|
13837
|
+
const start = offset + 1;
|
|
13838
|
+
if (start + 1 >= xmlString.length) break;
|
|
13839
|
+
let consumed = 0;
|
|
13840
|
+
let value = "";
|
|
13841
|
+
const c1 = xmlString.charCodeAt(start);
|
|
13842
|
+
if (c1 === CHAR_NUM) {
|
|
13843
|
+
const packed = parseNumericEntity(xmlString, start + 1, true);
|
|
13844
|
+
consumed = unpackConsumed(packed);
|
|
13845
|
+
if (consumed !== 0) {
|
|
13846
|
+
const codePoint = packed & NUMERIC_CODE_POINT_MASK;
|
|
13847
|
+
value = codePoint - 1 >>> 0 < 55295 ? String.fromCharCode(codePoint) : String.fromCodePoint(replaceCodePointXML$1(codePoint));
|
|
13848
|
+
}
|
|
13849
|
+
} else switch (c1) {
|
|
13850
|
+
case 108:
|
|
13851
|
+
case 103:
|
|
13852
|
+
if (start + 2 < xmlString.length && xmlString.charCodeAt(start + 1) === 116 && xmlString.charCodeAt(start + 2) === CHAR_SEMI) {
|
|
13853
|
+
consumed = 4;
|
|
13854
|
+
value = c1 === 108 ? "<" : ">";
|
|
13855
|
+
}
|
|
13856
|
+
break;
|
|
13857
|
+
case 97: {
|
|
13858
|
+
const c2 = xmlString.charCodeAt(start + 1);
|
|
13859
|
+
if (start + 3 < xmlString.length && c2 === 109 && xmlString.charCodeAt(start + 2) === 112 && xmlString.charCodeAt(start + 3) === CHAR_SEMI) {
|
|
13860
|
+
consumed = 5;
|
|
13861
|
+
value = "&";
|
|
13862
|
+
} else if (start + 4 < xmlString.length && c2 === 112 && xmlString.charCodeAt(start + 2) === 111 && xmlString.charCodeAt(start + 3) === 115 && xmlString.charCodeAt(start + 4) === CHAR_SEMI) {
|
|
13863
|
+
consumed = 6;
|
|
13864
|
+
value = "'";
|
|
13865
|
+
}
|
|
13866
|
+
break;
|
|
13867
|
+
}
|
|
13868
|
+
case 113: if (start + 4 < xmlString.length && xmlString.charCodeAt(start + 1) === 117 && xmlString.charCodeAt(start + 2) === 111 && xmlString.charCodeAt(start + 3) === 116 && xmlString.charCodeAt(start + 4) === CHAR_SEMI) {
|
|
13869
|
+
consumed = 6;
|
|
13870
|
+
value = "\"";
|
|
13871
|
+
}
|
|
13872
|
+
}
|
|
13873
|
+
if (consumed > 0) {
|
|
13874
|
+
if (lastIndex < offset) result += xmlString.slice(lastIndex, offset);
|
|
13875
|
+
result += value;
|
|
13876
|
+
offset = lastIndex = offset + consumed;
|
|
13877
|
+
} else offset = start;
|
|
13878
|
+
offset = offset < xmlString.length && xmlString.charCodeAt(offset) === CHAR_AMP ? offset : xmlString.indexOf("&", offset);
|
|
13879
|
+
} while (offset >= 0);
|
|
13880
|
+
return result + xmlString.slice(lastIndex);
|
|
13881
|
+
}
|
|
13882
|
+
// ../wxml/dist/core-BEEC2yjm.mjs
|
|
13883
|
+
const lineEndPattern = /[\n\r\u2028\u2029]/g;
|
|
13884
|
+
/** JS 行注释在任意行终止符处结束;正则只定位下一处,不逐字符分配结果。 */
|
|
13885
|
+
function findLineEnd(source, start) {
|
|
13886
|
+
lineEndPattern.lastIndex = start;
|
|
13887
|
+
return lineEndPattern.exec(source)?.index ?? -1;
|
|
13888
|
+
}
|
|
13889
|
+
/** 词法错误携带原文偏移,由调用方选择报告或抛出。 */
|
|
13890
|
+
var TemplateLexicalError = class extends Error {
|
|
13891
|
+
offset;
|
|
13892
|
+
recovery;
|
|
13893
|
+
constructor(offset, message, recovery) {
|
|
13894
|
+
super(message);
|
|
13895
|
+
this.offset = offset;
|
|
13896
|
+
this.recovery = recovery;
|
|
13897
|
+
}
|
|
13898
|
+
};
|
|
13899
|
+
function isSpaceCode(code) {
|
|
13900
|
+
if (code <= 32) return code === 32 || code >= 9 && code <= 13;
|
|
13901
|
+
return code >= 160 && (code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279);
|
|
13902
|
+
}
|
|
13903
|
+
function isWordCode(code) {
|
|
13904
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 95 || code === 36 || code >= 128;
|
|
13905
|
+
}
|
|
13906
|
+
function isNameCode(code) {
|
|
13907
|
+
return isWordCode(code) || code === 58 || code === 46 || code === 45;
|
|
13908
|
+
}
|
|
13909
|
+
function isTagStartCode(code) {
|
|
13910
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95;
|
|
13911
|
+
}
|
|
13912
|
+
function skipSpace(source, start) {
|
|
13913
|
+
while (isSpaceCode(source.charCodeAt(start))) start++;
|
|
13914
|
+
return start;
|
|
13915
|
+
}
|
|
13916
|
+
/** 宿主属性层只移除每对反斜杠与后续字符中的第一字符,不解释 JS 转义。 */
|
|
13917
|
+
function decodeLegacyAttributeLayer(value) {
|
|
13918
|
+
return value.replace(/\\([\s\S])/g, "$1");
|
|
13919
|
+
}
|
|
13920
|
+
/** 外层引号是否结束属性只由宿主层的连续反斜杠奇偶决定。 */
|
|
13921
|
+
function legacyAttributeEnd(source, start, quote) {
|
|
13922
|
+
let end = source.indexOf(quote, start);
|
|
13923
|
+
while (end >= 0) {
|
|
13924
|
+
let previous = end - 1;
|
|
13925
|
+
while (previous >= start && source.charCodeAt(previous) === 92) previous--;
|
|
13926
|
+
if ((end - previous) % 2 !== 0) return end;
|
|
13927
|
+
end = source.indexOf(quote, end + 1);
|
|
13928
|
+
}
|
|
13929
|
+
return -1;
|
|
13930
|
+
}
|
|
13931
|
+
/** 无转义不建立偏移表;有转义时只记录被移除字符的逻辑偏移。 */
|
|
13932
|
+
function legacyAttributeSource(source, start, end) {
|
|
13933
|
+
const content = source.slice(start, end);
|
|
13934
|
+
if (!content.includes("\\")) return {
|
|
13935
|
+
source: content,
|
|
13936
|
+
start: 0,
|
|
13937
|
+
end: content.length,
|
|
13938
|
+
origin: start
|
|
13939
|
+
};
|
|
13940
|
+
const escapes = [];
|
|
13941
|
+
const value = content.replace(/\\([\s\S])/g, (_match, character, offset) => {
|
|
13942
|
+
escapes.push(offset - escapes.length);
|
|
13943
|
+
return character;
|
|
13944
|
+
});
|
|
13945
|
+
return {
|
|
13946
|
+
source: value,
|
|
13947
|
+
start: 0,
|
|
13948
|
+
end: value.length,
|
|
13949
|
+
origin: start,
|
|
13950
|
+
escapes
|
|
13951
|
+
};
|
|
13952
|
+
}
|
|
13953
|
+
/** 逻辑字符仍映射到包含宿主层反斜杠的原始 UTF-16 位置。 */
|
|
13954
|
+
function attributeSourcePosition(view, offset) {
|
|
13955
|
+
const escapes = view.escapes;
|
|
13956
|
+
let lower = 0;
|
|
13957
|
+
let upper = escapes?.length ?? 0;
|
|
13958
|
+
while (lower < upper) {
|
|
13959
|
+
const middle = lower + upper >>> 1;
|
|
13960
|
+
if (escapes[middle] < offset) lower = middle + 1;
|
|
13961
|
+
else upper = middle;
|
|
13962
|
+
}
|
|
13963
|
+
return view.origin + offset + lower;
|
|
13964
|
+
}
|
|
13965
|
+
/** 诊断和可恢复插值范围始终引用原始源码,而非解码后的临时视图。 */
|
|
13966
|
+
function attributeSourceError(view, error) {
|
|
13967
|
+
if (error instanceof TemplateLexicalError) {
|
|
13968
|
+
const recovery = error.recovery;
|
|
13969
|
+
throw new TemplateLexicalError(attributeSourcePosition(view, error.offset), error.message, recovery && {
|
|
13970
|
+
kind: recovery.kind,
|
|
13971
|
+
start: attributeSourcePosition(view, recovery.start),
|
|
13972
|
+
end: attributeSourcePosition(view, recovery.end)
|
|
13973
|
+
});
|
|
13974
|
+
}
|
|
13975
|
+
throw error;
|
|
13976
|
+
}
|
|
13977
|
+
const expressionWord = 1;
|
|
13978
|
+
const controlWord = 2;
|
|
13979
|
+
const blockWord = 4;
|
|
13980
|
+
const declarationPrefix = 8;
|
|
13981
|
+
const lineBreakWord = 16;
|
|
13982
|
+
const exportWord = 32;
|
|
13983
|
+
const typeObjectWord = 64;
|
|
13984
|
+
const functionWord = 128;
|
|
13985
|
+
const classWord = 256;
|
|
13986
|
+
const caseWord = 512;
|
|
13987
|
+
const defaultWord = 1024;
|
|
13988
|
+
const wordRoles = /* @__PURE__ */ new Map([
|
|
13989
|
+
["return", 17],
|
|
13990
|
+
["throw", expressionWord],
|
|
13991
|
+
["case", 513],
|
|
13992
|
+
["delete", expressionWord],
|
|
13993
|
+
["void", expressionWord],
|
|
13994
|
+
["typeof", expressionWord],
|
|
13995
|
+
["new", expressionWord],
|
|
13996
|
+
["in", expressionWord],
|
|
13997
|
+
["instanceof", expressionWord],
|
|
13998
|
+
["yield", 17],
|
|
13999
|
+
["await", expressionWord],
|
|
14000
|
+
["else", 5],
|
|
14001
|
+
["do", 5],
|
|
14002
|
+
["if", controlWord],
|
|
14003
|
+
["while", controlWord],
|
|
14004
|
+
["for", controlWord],
|
|
14005
|
+
["with", controlWord],
|
|
14006
|
+
["switch", controlWord],
|
|
14007
|
+
["catch", controlWord],
|
|
14008
|
+
["try", blockWord],
|
|
14009
|
+
["finally", blockWord],
|
|
14010
|
+
["async", declarationPrefix],
|
|
14011
|
+
["export", 40],
|
|
14012
|
+
["default", 1032],
|
|
14013
|
+
["extends", typeObjectWord],
|
|
14014
|
+
["keyof", typeObjectWord],
|
|
14015
|
+
["readonly", typeObjectWord],
|
|
14016
|
+
["is", typeObjectWord],
|
|
14017
|
+
["function", functionWord],
|
|
14018
|
+
["class", classWord]
|
|
14019
|
+
]);
|
|
14020
|
+
const lineBreakPattern = /[\n\r\u2028\u2029]/;
|
|
14021
|
+
const expressionAfter = 256;
|
|
14022
|
+
const statementBody = 512;
|
|
14023
|
+
const functionParameters = 1024;
|
|
14024
|
+
const bracketMask = 255;
|
|
14025
|
+
/** 保存有效 token 的词法目标,构造体正文按声明或表达式归属恢复斜杠判界。 */
|
|
14026
|
+
var TokenContext = class {
|
|
14027
|
+
operand = true;
|
|
14028
|
+
previousRoles = 0;
|
|
14029
|
+
previousCode;
|
|
14030
|
+
brackets;
|
|
14031
|
+
rootStatement;
|
|
14032
|
+
statement;
|
|
14033
|
+
label = false;
|
|
14034
|
+
arrowBody = false;
|
|
14035
|
+
headers;
|
|
14036
|
+
questions;
|
|
14037
|
+
cases;
|
|
14038
|
+
constructor(expression = false) {
|
|
14039
|
+
this.previousCode = expression ? -1 : 0;
|
|
14040
|
+
this.rootStatement = this.statement = !expression;
|
|
14041
|
+
}
|
|
14042
|
+
get depth() {
|
|
14043
|
+
return this.brackets?.length ?? 0;
|
|
14044
|
+
}
|
|
14045
|
+
get bracket() {
|
|
14046
|
+
const frame = this.brackets?.[this.brackets.length - 1];
|
|
14047
|
+
return frame === void 0 ? void 0 : frame & bracketMask;
|
|
14048
|
+
}
|
|
14049
|
+
word(source, start, end) {
|
|
14050
|
+
if (this.previousCode === 46) {
|
|
14051
|
+
this.value();
|
|
14052
|
+
return;
|
|
14053
|
+
}
|
|
14054
|
+
const length = end - start;
|
|
14055
|
+
const roles = length >= 2 && length <= 10 ? wordRoles.get(source.slice(start, end)) ?? 0 : 0;
|
|
14056
|
+
if (roles) {
|
|
14057
|
+
this.keyword(roles);
|
|
14058
|
+
return;
|
|
14059
|
+
}
|
|
14060
|
+
this.label = this.statement;
|
|
14061
|
+
this.operand = this.statement = this.arrowBody = false;
|
|
14062
|
+
this.previousRoles = 0;
|
|
14063
|
+
this.previousCode = 1;
|
|
14064
|
+
}
|
|
14065
|
+
keyword(roles) {
|
|
14066
|
+
const startsStatement = this.statement;
|
|
14067
|
+
const caseLabel = startsStatement && Boolean(roles & caseWord || roles & defaultWord && !(this.previousRoles & exportWord));
|
|
14068
|
+
if (roles & 384) (this.headers ??= []).push({
|
|
14069
|
+
kind: roles & functionWord ? "function" : "class",
|
|
14070
|
+
phase: "head",
|
|
14071
|
+
depth: this.depth,
|
|
14072
|
+
declaration: startsStatement,
|
|
14073
|
+
angles: 0,
|
|
14074
|
+
typed: false
|
|
14075
|
+
});
|
|
14076
|
+
if (caseLabel) (this.cases ??= []).push(this.depth);
|
|
14077
|
+
this.label = startsStatement && !caseLabel && !(roles & 1447);
|
|
14078
|
+
this.statement = Boolean(roles & blockWord || startsStatement && !caseLabel && roles & declarationPrefix);
|
|
14079
|
+
this.previousRoles = roles;
|
|
14080
|
+
this.previousCode = 1;
|
|
14081
|
+
this.arrowBody = false;
|
|
14082
|
+
this.operand = Boolean(roles & expressionWord);
|
|
14083
|
+
}
|
|
14084
|
+
value(code = 1) {
|
|
14085
|
+
this.operand = false;
|
|
14086
|
+
this.statement = this.label = this.arrowBody = false;
|
|
14087
|
+
this.previousRoles = 0;
|
|
14088
|
+
this.previousCode = code;
|
|
14089
|
+
}
|
|
14090
|
+
increment(code) {
|
|
14091
|
+
this.statement = this.label = this.arrowBody = false;
|
|
14092
|
+
this.previousRoles = 0;
|
|
14093
|
+
this.previousCode = code;
|
|
14094
|
+
}
|
|
14095
|
+
/** 换行只恢复可开始声明的位置,不改变跨行除法的表达式目标。 */
|
|
14096
|
+
lineBreak(source, start, end) {
|
|
14097
|
+
if (this.operand && !(this.previousRoles & lineBreakWord)) return;
|
|
14098
|
+
const frame = this.brackets?.[this.brackets.length - 1];
|
|
14099
|
+
const header = this.headers?.[this.headers.length - 1];
|
|
14100
|
+
if ((frame === void 0 ? this.rootStatement : Boolean(frame & statementBody)) && header?.depth !== this.depth && (source === void 0 || lineBreakPattern.test(source.slice(start, end)))) this.statement = true;
|
|
14101
|
+
}
|
|
14102
|
+
/** 普通括号仍用数字帧;只有函数或类的头部需要保存跨 token 的正文归属。 */
|
|
14103
|
+
punctuation(code, next = 0) {
|
|
14104
|
+
let matched = true;
|
|
14105
|
+
if (code === 46) this.operand = this.statement = false;
|
|
14106
|
+
else if (code === 91) {
|
|
14107
|
+
(this.brackets ??= []).push(code);
|
|
14108
|
+
this.operand = true;
|
|
14109
|
+
this.statement = false;
|
|
14110
|
+
} else matched = this.punctuationContext(code, next);
|
|
14111
|
+
this.arrowBody = code === 62 && this.previousCode === 61;
|
|
14112
|
+
this.label = false;
|
|
14113
|
+
this.previousRoles = 0;
|
|
14114
|
+
this.previousCode = code;
|
|
14115
|
+
return matched;
|
|
14116
|
+
}
|
|
14117
|
+
punctuationContext(code, next) {
|
|
14118
|
+
let matched = true;
|
|
14119
|
+
const header = this.headers?.[this.headers.length - 1];
|
|
14120
|
+
const currentHeader = header && header.depth === this.depth ? header : void 0;
|
|
14121
|
+
if (code === 40) {
|
|
14122
|
+
if (currentHeader?.kind === "function" && currentHeader.phase === "head" && !currentHeader.angles) {
|
|
14123
|
+
currentHeader.phase = "parameters";
|
|
14124
|
+
(this.brackets ??= []).push(code | functionParameters);
|
|
14125
|
+
} else (this.brackets ??= []).push(code | (this.previousRoles & controlWord ? expressionAfter : 0));
|
|
14126
|
+
this.operand = true;
|
|
14127
|
+
this.statement = false;
|
|
14128
|
+
} else if (code === 123) {
|
|
14129
|
+
const typeObject = currentHeader && (currentHeader.angles > 0 || currentHeader.phase === "body" && currentHeader.typed && ([
|
|
14130
|
+
58,
|
|
14131
|
+
38,
|
|
14132
|
+
124,
|
|
14133
|
+
63,
|
|
14134
|
+
61,
|
|
14135
|
+
62
|
|
14136
|
+
].includes(this.previousCode) || this.previousRoles & typeObjectWord));
|
|
14137
|
+
if (currentHeader && !typeObject && !currentHeader.angles && (currentHeader.kind === "class" || currentHeader.phase === "body")) {
|
|
14138
|
+
this.headers.pop();
|
|
14139
|
+
(this.brackets ??= []).push(code | statementBody | (currentHeader.declaration ? expressionAfter : 0));
|
|
14140
|
+
this.statement = true;
|
|
14141
|
+
} else if (this.arrowBody && !typeObject) {
|
|
14142
|
+
(this.brackets ??= []).push(code | statementBody);
|
|
14143
|
+
this.statement = true;
|
|
14144
|
+
} else {
|
|
14145
|
+
const object = typeObject || this.operand && !this.statement;
|
|
14146
|
+
(this.brackets ??= []).push(code | (object ? 0 : 768));
|
|
14147
|
+
this.statement = !object;
|
|
14148
|
+
}
|
|
14149
|
+
this.operand = true;
|
|
14150
|
+
} else if (code === 41 || code === 93 || code === 125) {
|
|
14151
|
+
const expected = code === 41 ? 40 : code === 93 ? 91 : 123;
|
|
14152
|
+
const frame = this.brackets?.pop();
|
|
14153
|
+
matched = frame !== void 0 && (frame & bracketMask) === expected;
|
|
14154
|
+
if (frame !== void 0 && frame & functionParameters) {
|
|
14155
|
+
const parameters = this.headers?.[this.headers.length - 1];
|
|
14156
|
+
if (parameters?.kind === "function" && parameters.phase === "parameters" && parameters.depth === this.depth) parameters.phase = "body";
|
|
14157
|
+
this.operand = this.statement = false;
|
|
14158
|
+
} else {
|
|
14159
|
+
this.operand = frame === void 0 ? code === 125 : Boolean(frame & expressionAfter);
|
|
14160
|
+
this.statement = this.operand;
|
|
14161
|
+
}
|
|
14162
|
+
} else {
|
|
14163
|
+
if (currentHeader && currentHeader.phase !== "parameters") {
|
|
14164
|
+
if (code === 60) currentHeader.angles++;
|
|
14165
|
+
else if (code === 62 && this.previousCode !== 61 && currentHeader.angles) currentHeader.angles--;
|
|
14166
|
+
else if (code === 58 && currentHeader.phase === "body") currentHeader.typed = true;
|
|
14167
|
+
else if (!currentHeader.angles && currentHeader.phase === "head" && (code === 58 || code === 61 || code === 44 || code === 59)) this.headers.pop();
|
|
14168
|
+
}
|
|
14169
|
+
this.operand = code !== 46;
|
|
14170
|
+
if (code === 59) {
|
|
14171
|
+
const frame = this.brackets?.[this.brackets.length - 1];
|
|
14172
|
+
this.statement = frame === void 0 ? this.rootStatement : Boolean(frame & statementBody);
|
|
14173
|
+
} else if (code === 58) {
|
|
14174
|
+
if (this.questions?.[this.questions.length - 1] === this.depth) {
|
|
14175
|
+
this.questions.pop();
|
|
14176
|
+
this.statement = false;
|
|
14177
|
+
} else if (this.cases?.[this.cases.length - 1] === this.depth) {
|
|
14178
|
+
this.cases.pop();
|
|
14179
|
+
this.statement = true;
|
|
14180
|
+
} else this.statement = this.label;
|
|
14181
|
+
} else {
|
|
14182
|
+
this.statement = false;
|
|
14183
|
+
if (code === 63 && next !== 46 && next !== 63 && this.previousCode !== 63) (this.questions ??= []).push(this.depth);
|
|
14184
|
+
}
|
|
14185
|
+
}
|
|
14186
|
+
return matched;
|
|
14187
|
+
}
|
|
14188
|
+
};
|
|
14189
|
+
const fastInterpolation = /\{\{[^{}[\]()"'`\x2F&]*\}\}/y;
|
|
14190
|
+
function encodedQuoteAt(source, start) {
|
|
14191
|
+
if (source.charCodeAt(start) !== 38) return;
|
|
14192
|
+
const initial = source.charCodeAt(start + 1) | 32;
|
|
14193
|
+
if (initial !== 35 && initial !== 97 && initial !== 113) return;
|
|
14194
|
+
const limit = Math.min(source.length, start + 16);
|
|
14195
|
+
let end = start + 1;
|
|
14196
|
+
while (end < limit && source.charCodeAt(end) !== 59) end++;
|
|
14197
|
+
if (end === limit) return;
|
|
14198
|
+
const name = source.slice(start + 1, end).toLowerCase();
|
|
14199
|
+
let code = name === "quot" ? 34 : name === "apos" ? 39 : 0;
|
|
14200
|
+
if (!code && name.charCodeAt(0) === 35) {
|
|
14201
|
+
const hexadecimal = name.charCodeAt(1) === 120;
|
|
14202
|
+
const begin = hexadecimal ? 2 : 1;
|
|
14203
|
+
if (begin === name.length) return;
|
|
14204
|
+
for (let index = begin; index < name.length; index++) {
|
|
14205
|
+
const digit = name.charCodeAt(index);
|
|
14206
|
+
if (!(digit >= 48 && digit <= 57 || hexadecimal && digit >= 97 && digit <= 102)) return;
|
|
14207
|
+
}
|
|
14208
|
+
code = Number.parseInt(name.slice(begin), hexadecimal ? 16 : 10);
|
|
14209
|
+
}
|
|
14210
|
+
return code === 34 || code === 39 ? {
|
|
14211
|
+
code,
|
|
14212
|
+
end: end + 1
|
|
14213
|
+
} : void 0;
|
|
14214
|
+
}
|
|
14215
|
+
function quotedEnd$1(source, start, syntax, limit, entityQuotes) {
|
|
14216
|
+
const opening = encodedQuoteAt(source, start);
|
|
14217
|
+
const quote = opening?.code ?? source.charCodeAt(start);
|
|
14218
|
+
const entityLayer = syntax === "xml" || Boolean(opening);
|
|
14219
|
+
for (let index = opening?.end ?? start + 1; index < limit;) {
|
|
14220
|
+
const entity = entityLayer ? encodedQuoteAt(source, index) : void 0;
|
|
14221
|
+
const code = entity?.code ?? source.charCodeAt(index);
|
|
14222
|
+
if (code === 92) {
|
|
14223
|
+
const slashStart = index;
|
|
14224
|
+
while (source.charCodeAt(index) === 92) index++;
|
|
14225
|
+
const delimiter = entityLayer ? encodedQuoteAt(source, index) : void 0;
|
|
14226
|
+
if ((index - slashStart) % 2 !== 0) index = delimiter?.end ?? index + 1;
|
|
14227
|
+
continue;
|
|
14228
|
+
}
|
|
14229
|
+
if (quote === 96 && code === 36 && source.charCodeAt(index + 1) === 123) index = scanExpression(source, index + 1, false, syntax, limit, entityQuotes);
|
|
14230
|
+
else if (code === quote) return entity?.end ?? index + 1;
|
|
14231
|
+
else index = entity?.end ?? index + 1;
|
|
14232
|
+
}
|
|
14233
|
+
throw new TemplateLexicalError(start, "未闭合的表达式字符串");
|
|
14234
|
+
}
|
|
14235
|
+
function regexpEnd$1(source, start, limit) {
|
|
14236
|
+
let characterClass = false;
|
|
14237
|
+
for (let index = start + 1; index < limit; index++) {
|
|
14238
|
+
const code = source.charCodeAt(index);
|
|
14239
|
+
if (code === 92) index++;
|
|
14240
|
+
else if (code === 91) characterClass = true;
|
|
14241
|
+
else if (code === 93) characterClass = false;
|
|
14242
|
+
else if (code === 47 && !characterClass) {
|
|
14243
|
+
index++;
|
|
14244
|
+
while (isWordCode(source.charCodeAt(index))) index++;
|
|
14245
|
+
return index;
|
|
14246
|
+
} else if (code === 10 || code === 13) break;
|
|
14247
|
+
}
|
|
14248
|
+
throw new TemplateLexicalError(start, "未闭合的表达式正则");
|
|
14249
|
+
}
|
|
14250
|
+
function scanExpression(source, start, mustache, syntax, limit = source.length, entityQuotes = true) {
|
|
14251
|
+
if (mustache) {
|
|
14252
|
+
fastInterpolation.lastIndex = start;
|
|
14253
|
+
const fast = fastInterpolation.exec(source);
|
|
14254
|
+
if (fast && fast.index + fast[0].length <= limit) return fast.index + fast[0].length;
|
|
14255
|
+
}
|
|
14256
|
+
const context = new TokenContext(true);
|
|
14257
|
+
let mismatch;
|
|
14258
|
+
for (let index = start + (mustache ? 2 : 1); index < limit;) {
|
|
14259
|
+
const code = source.charCodeAt(index);
|
|
14260
|
+
const next = source.charCodeAt(index + 1);
|
|
14261
|
+
if (code === 125 && (!mustache ? context.depth === 0 : next === 125 && context.bracket !== 123)) {
|
|
14262
|
+
const end = index + (mustache ? 2 : 1);
|
|
14263
|
+
if (mismatch !== void 0 || context.depth > 0) throw new TemplateLexicalError(mismatch ?? index, "不匹配的表达式括号", {
|
|
14264
|
+
kind: "interpolation",
|
|
14265
|
+
start,
|
|
14266
|
+
end
|
|
14267
|
+
});
|
|
14268
|
+
return end;
|
|
14269
|
+
}
|
|
14270
|
+
if (isSpaceCode(code)) {
|
|
14271
|
+
if (code === 10 || code === 13 || code === 8232 || code === 8233) context.lineBreak();
|
|
14272
|
+
index++;
|
|
14273
|
+
continue;
|
|
14274
|
+
}
|
|
14275
|
+
if (entityQuotes && code === 38 && encodedQuoteAt(source, index)) {
|
|
14276
|
+
index = quotedEnd$1(source, index, syntax, limit, entityQuotes);
|
|
14277
|
+
context.value();
|
|
14278
|
+
continue;
|
|
14279
|
+
}
|
|
14280
|
+
if (code === 34 || code === 39 || code === 96) {
|
|
14281
|
+
index = quotedEnd$1(source, index, syntax, limit, entityQuotes);
|
|
14282
|
+
context.value();
|
|
14283
|
+
continue;
|
|
14284
|
+
}
|
|
14285
|
+
if (code === 47 && next === 42) {
|
|
14286
|
+
const end = source.indexOf("*/", index + 2);
|
|
14287
|
+
if (end < 0 || end >= limit) throw new TemplateLexicalError(index, "未闭合的表达式注释");
|
|
14288
|
+
context.lineBreak(source, index + 2, end);
|
|
14289
|
+
index = end + 2;
|
|
14290
|
+
continue;
|
|
14291
|
+
}
|
|
14292
|
+
if (code === 47 && next === 47) {
|
|
14293
|
+
const end = findLineEnd(source, index + 2);
|
|
14294
|
+
if (end < 0 || end >= limit) throw new TemplateLexicalError(index, "未闭合的插值表达式");
|
|
14295
|
+
context.lineBreak();
|
|
14296
|
+
index = end + 1;
|
|
14297
|
+
continue;
|
|
14298
|
+
}
|
|
14299
|
+
if (code === 47 && context.operand) {
|
|
14300
|
+
index = regexpEnd$1(source, index, limit);
|
|
14301
|
+
context.value();
|
|
14302
|
+
continue;
|
|
14303
|
+
}
|
|
14304
|
+
if (isWordCode(code)) {
|
|
14305
|
+
const begin = index++;
|
|
14306
|
+
while (isWordCode(source.charCodeAt(index))) index++;
|
|
14307
|
+
context.word(source, begin, index);
|
|
14308
|
+
continue;
|
|
14309
|
+
}
|
|
14310
|
+
if ((code === 43 || code === 45) && code === next) {
|
|
14311
|
+
context.increment(code);
|
|
14312
|
+
index += 2;
|
|
14313
|
+
continue;
|
|
14314
|
+
}
|
|
14315
|
+
if (!context.punctuation(code, next)) {
|
|
14316
|
+
if (!mustache) throw new TemplateLexicalError(index, "不匹配的表达式括号");
|
|
14317
|
+
mismatch ??= index;
|
|
14318
|
+
}
|
|
14319
|
+
index++;
|
|
14320
|
+
}
|
|
14321
|
+
if (mismatch !== void 0) throw new TemplateLexicalError(mismatch, "不匹配的表达式括号");
|
|
14322
|
+
throw new TemplateLexicalError(start, "未闭合的插值表达式");
|
|
14323
|
+
}
|
|
14324
|
+
/** 定位插值末尾;跳过字符串、注释、正则和嵌套括号,保留原文编码。 */
|
|
14325
|
+
function expressionEnd(source, start, mustache = true, syntax = "xml", outerQuote) {
|
|
14326
|
+
if (syntax === "legacy" && outerQuote) {
|
|
14327
|
+
const boundary = legacyAttributeEnd(source, start, outerQuote);
|
|
14328
|
+
const view = legacyAttributeSource(source, start, boundary < 0 ? source.length : boundary);
|
|
14329
|
+
try {
|
|
14330
|
+
return attributeSourcePosition(view, scanExpression(view.source, view.start, mustache, syntax, view.end, false));
|
|
14331
|
+
} catch (error) {
|
|
14332
|
+
attributeSourceError(view, error);
|
|
14333
|
+
}
|
|
14334
|
+
}
|
|
14335
|
+
return scanExpression(source, start, mustache, syntax);
|
|
14336
|
+
}
|
|
14337
|
+
function collectInterpolations(source, syntax, entityQuotes = true, begin = 0, limit = source.length) {
|
|
14338
|
+
const result = [];
|
|
14339
|
+
let start = source.indexOf("{{", begin);
|
|
14340
|
+
while (start >= 0 && start < limit) {
|
|
14341
|
+
const end = scanExpression(source, start, true, syntax, limit, entityQuotes);
|
|
14342
|
+
result.push({
|
|
14343
|
+
start,
|
|
14344
|
+
end
|
|
14345
|
+
});
|
|
14346
|
+
start = source.indexOf("{{", end);
|
|
14347
|
+
}
|
|
14348
|
+
return result;
|
|
14349
|
+
}
|
|
14350
|
+
/** 已解开宿主层的绑定不将实体样文本解释为 JavaScript 引号。 */
|
|
14351
|
+
function legacyAttributeInterpolations(source) {
|
|
14352
|
+
return collectInterpolations(source, "legacy", false);
|
|
14353
|
+
}
|
|
14354
|
+
/** 宿主先确定属性边界,绑定词法只读取解开一层后的逻辑字符。 */
|
|
14355
|
+
function validateLegacyAttribute(source, start, end) {
|
|
14356
|
+
const view = legacyAttributeSource(source, start, end);
|
|
14357
|
+
let begin = view.source.indexOf("{{", view.start);
|
|
14358
|
+
try {
|
|
14359
|
+
while (begin >= 0 && begin < view.end) {
|
|
14360
|
+
const boundary = scanExpression(view.source, begin, true, "legacy", view.end, false);
|
|
14361
|
+
begin = view.source.indexOf("{{", boundary);
|
|
14362
|
+
}
|
|
14363
|
+
} catch (error) {
|
|
14364
|
+
attributeSourceError(view, error);
|
|
14365
|
+
}
|
|
14366
|
+
}
|
|
14367
|
+
function quotedEnd(source, start, quote) {
|
|
14368
|
+
const end = legacyAttributeEnd(source, start + 1, quote === 34 ? "\"" : "'");
|
|
14369
|
+
return end < 0 ? source.length : end + 1;
|
|
14370
|
+
}
|
|
14371
|
+
function regexpEnd(source, start) {
|
|
14372
|
+
let characterClass = false;
|
|
14373
|
+
for (let index = start + 1; index < source.length; index++) {
|
|
14374
|
+
const code = source.charCodeAt(index);
|
|
14375
|
+
if (code === 92) index++;
|
|
14376
|
+
else if (code === 91) characterClass = true;
|
|
14377
|
+
else if (code === 93) characterClass = false;
|
|
14378
|
+
else if (code === 47 && !characterClass) {
|
|
14379
|
+
index++;
|
|
14380
|
+
while (isWordCode(source.charCodeAt(index))) index++;
|
|
14381
|
+
return index;
|
|
14382
|
+
} else if (code === 10 || code === 13) return index;
|
|
14383
|
+
}
|
|
14384
|
+
return source.length;
|
|
14385
|
+
}
|
|
14386
|
+
function closingTagAt(source, start, tagName) {
|
|
14387
|
+
if (!tagName || source.charCodeAt(start) !== 60 || source.charCodeAt(start + 1) !== 47) return;
|
|
14388
|
+
const begin = start + 2;
|
|
14389
|
+
let cursor = begin;
|
|
14390
|
+
while (isNameCode(source.charCodeAt(cursor))) cursor++;
|
|
14391
|
+
if (source.slice(begin, cursor).toLowerCase() !== tagName) return;
|
|
14392
|
+
while (isSpaceCode(source.charCodeAt(cursor))) cursor++;
|
|
14393
|
+
return source.charCodeAt(cursor) === 62 ? {
|
|
14394
|
+
start,
|
|
14395
|
+
end: cursor + 1
|
|
14396
|
+
} : void 0;
|
|
14397
|
+
}
|
|
14398
|
+
function templateEnd(source, start) {
|
|
14399
|
+
let index = start + 1;
|
|
14400
|
+
while (index < source.length) {
|
|
14401
|
+
const code = source.charCodeAt(index);
|
|
14402
|
+
if (code === 92) index += 2;
|
|
14403
|
+
else if (code === 96) return index + 1;
|
|
14404
|
+
else if (code === 36 && source.charCodeAt(index + 1) === 123) index = scanCode(source, index + 2, void 0, true).end;
|
|
14405
|
+
else index++;
|
|
14406
|
+
}
|
|
14407
|
+
return index;
|
|
14408
|
+
}
|
|
14409
|
+
function scanCode(source, start, tagName, interpolation = false) {
|
|
14410
|
+
const commentClosings = [];
|
|
14411
|
+
const context = new TokenContext(interpolation);
|
|
14412
|
+
let index = start;
|
|
14413
|
+
while (index < source.length) {
|
|
14414
|
+
const code = source.charCodeAt(index);
|
|
14415
|
+
const next = source.charCodeAt(index + 1);
|
|
14416
|
+
if (code === 60 && next === 47) {
|
|
14417
|
+
const closingTag = closingTagAt(source, index, tagName);
|
|
14418
|
+
if (closingTag) return {
|
|
14419
|
+
closingTag,
|
|
14420
|
+
commentClosings,
|
|
14421
|
+
end: closingTag.end
|
|
14422
|
+
};
|
|
14423
|
+
}
|
|
14424
|
+
if (isSpaceCode(code)) {
|
|
14425
|
+
if (code === 10 || code === 13 || code === 8232 || code === 8233) context.lineBreak();
|
|
14426
|
+
index++;
|
|
14427
|
+
continue;
|
|
14428
|
+
}
|
|
14429
|
+
if (code === 34 || code === 39) {
|
|
14430
|
+
index = quotedEnd(source, index, code);
|
|
14431
|
+
context.value(code);
|
|
14432
|
+
} else if (code === 96) {
|
|
14433
|
+
index = templateEnd(source, index);
|
|
14434
|
+
context.value(code);
|
|
14435
|
+
} else if (code === 47 && (next === 47 || next === 42)) {
|
|
14436
|
+
const block = next === 42;
|
|
14437
|
+
const end = block ? source.indexOf("*/", index + 2) : findLineEnd(source, index + 2);
|
|
14438
|
+
const limit = end < 0 ? source.length : end;
|
|
14439
|
+
if (tagName) {
|
|
14440
|
+
let candidate = source.indexOf("</", index + 2);
|
|
14441
|
+
while (candidate >= 0 && candidate < limit) {
|
|
14442
|
+
const closing = closingTagAt(source, candidate, tagName);
|
|
14443
|
+
if (closing) commentClosings.push({
|
|
14444
|
+
...closing,
|
|
14445
|
+
block
|
|
14446
|
+
});
|
|
14447
|
+
candidate = source.indexOf("</", candidate + 2);
|
|
14448
|
+
}
|
|
14449
|
+
}
|
|
14450
|
+
if (end < 0 && block) return {
|
|
14451
|
+
trailingComment: index,
|
|
14452
|
+
commentClosings,
|
|
14453
|
+
end: source.length
|
|
14454
|
+
};
|
|
14455
|
+
if (block) context.lineBreak(source, index + 2, limit);
|
|
14456
|
+
else if (end >= 0) context.lineBreak();
|
|
14457
|
+
index = limit + (end < 0 ? 0 : block ? 2 : 1);
|
|
14458
|
+
continue;
|
|
14459
|
+
} else if (code === 47 && context.operand) {
|
|
14460
|
+
index = regexpEnd(source, index);
|
|
14461
|
+
context.value(code);
|
|
14462
|
+
} else if (isWordCode(code)) {
|
|
14463
|
+
const begin = index++;
|
|
14464
|
+
while (isWordCode(source.charCodeAt(index))) index++;
|
|
14465
|
+
context.word(source, begin, index);
|
|
14466
|
+
continue;
|
|
14467
|
+
} else {
|
|
14468
|
+
if (interpolation && code === 125 && context.depth === 0) return { end: index + 1 };
|
|
14469
|
+
if ((code === 43 || code === 45) && next === code) {
|
|
14470
|
+
context.increment(code);
|
|
14471
|
+
index++;
|
|
14472
|
+
} else context.punctuation(code, next);
|
|
14473
|
+
index++;
|
|
14474
|
+
}
|
|
14475
|
+
}
|
|
14476
|
+
return {
|
|
14477
|
+
end: index,
|
|
14478
|
+
commentClosings
|
|
14479
|
+
};
|
|
14480
|
+
}
|
|
14481
|
+
/** 只收集词法候选,不加载 JS AST;歧义由调用方注入的 resolver 处理。 */
|
|
14482
|
+
function scanScriptBoundaryCandidates(source, start, tagName) {
|
|
14483
|
+
return scanCode(source, start, tagName.toLowerCase());
|
|
14484
|
+
}
|
|
14485
|
+
const emptyAttributes = Object.freeze([]);
|
|
14486
|
+
const doubleQuotedBoundary = /"|\{\{/g;
|
|
14487
|
+
const singleQuotedBoundary = /'|\{\{/g;
|
|
14488
|
+
/** 文档扫描共享单调的绑定候选,避免逐属性搜索相同后缀。 */
|
|
14489
|
+
function scanTag(source, start, syntax, collectAttributes, bindings) {
|
|
14490
|
+
let cursor = start + 1;
|
|
14491
|
+
const closing = source.charCodeAt(cursor) === 47;
|
|
14492
|
+
if (closing) cursor++;
|
|
14493
|
+
const nameStart = cursor;
|
|
14494
|
+
while (isNameCode(source.charCodeAt(cursor))) cursor++;
|
|
14495
|
+
const nameEnd = cursor;
|
|
14496
|
+
if (nameStart === nameEnd) throw new TemplateLexicalError(start, "标签缺少名称");
|
|
14497
|
+
let attributes;
|
|
14498
|
+
let quotedAttribute = false;
|
|
14499
|
+
while (cursor < source.length) {
|
|
14500
|
+
const whitespaceStart = cursor;
|
|
14501
|
+
cursor = skipSpace(source, cursor);
|
|
14502
|
+
const code = source.charCodeAt(cursor);
|
|
14503
|
+
const selfClosing = code === 47 && source.charCodeAt(cursor + 1) === 62;
|
|
14504
|
+
if (code === 62 || selfClosing) {
|
|
14505
|
+
if (closing && selfClosing) throw new TemplateLexicalError(cursor, "结束标签不能自闭合");
|
|
14506
|
+
return {
|
|
14507
|
+
kind: "tag",
|
|
14508
|
+
start,
|
|
14509
|
+
end: cursor + (selfClosing ? 2 : 1),
|
|
14510
|
+
name: source.slice(nameStart, nameEnd),
|
|
14511
|
+
nameStart,
|
|
14512
|
+
nameEnd,
|
|
14513
|
+
closing,
|
|
14514
|
+
selfClosing,
|
|
14515
|
+
attributes: attributes ?? emptyAttributes,
|
|
14516
|
+
parent: void 0,
|
|
14517
|
+
matching: void 0
|
|
14518
|
+
};
|
|
14519
|
+
}
|
|
14520
|
+
if (closing) throw new TemplateLexicalError(cursor, "结束标签不能包含属性");
|
|
14521
|
+
if (whitespaceStart === cursor && !quotedAttribute) throw new TemplateLexicalError(cursor, "属性前缺少空白分隔符");
|
|
14522
|
+
quotedAttribute = false;
|
|
14523
|
+
const attributeStart = cursor;
|
|
14524
|
+
if (source.charCodeAt(cursor) === 123 && source.charCodeAt(cursor + 1) === 123) cursor = expressionEnd(source, cursor, true, syntax);
|
|
14525
|
+
else while (cursor < source.length) {
|
|
14526
|
+
const attributeCode = source.charCodeAt(cursor);
|
|
14527
|
+
if (isSpaceCode(attributeCode) || attributeCode === 61 || attributeCode === 47 || attributeCode === 62) break;
|
|
14528
|
+
if (attributeCode === 60 || attributeCode === 34 || attributeCode === 39) throw new TemplateLexicalError(cursor, "无效的属性名称");
|
|
14529
|
+
cursor++;
|
|
14530
|
+
}
|
|
14531
|
+
const attributeNameEnd = cursor;
|
|
14532
|
+
if (cursor === attributeStart) throw new TemplateLexicalError(cursor, "属性缺少名称");
|
|
14533
|
+
const name = collectAttributes ? source.slice(attributeStart, attributeNameEnd) : "";
|
|
14534
|
+
cursor = skipSpace(source, cursor);
|
|
14535
|
+
if (source.charCodeAt(cursor) !== 61) {
|
|
14536
|
+
if (collectAttributes) (attributes ??= []).push({
|
|
14537
|
+
name,
|
|
14538
|
+
nameStart: attributeStart,
|
|
14539
|
+
nameEnd: attributeNameEnd,
|
|
14540
|
+
start: attributeStart,
|
|
14541
|
+
end: attributeNameEnd
|
|
14542
|
+
});
|
|
14543
|
+
cursor = attributeNameEnd;
|
|
14544
|
+
continue;
|
|
14545
|
+
}
|
|
14546
|
+
cursor = skipSpace(source, cursor + 1);
|
|
14547
|
+
const rawStart = cursor;
|
|
14548
|
+
const quoteCode = source.charCodeAt(cursor);
|
|
14549
|
+
const quote = quoteCode === 34 ? "\"" : quoteCode === 39 ? "'" : void 0;
|
|
14550
|
+
if (quote) cursor++;
|
|
14551
|
+
const valueStart = cursor;
|
|
14552
|
+
let closed = !quote;
|
|
14553
|
+
if (quote && syntax === "legacy") {
|
|
14554
|
+
const end = legacyAttributeEnd(source, valueStart, quote);
|
|
14555
|
+
if (end >= 0) {
|
|
14556
|
+
validateLegacyAttribute(source, valueStart, end);
|
|
14557
|
+
cursor = end;
|
|
14558
|
+
closed = true;
|
|
14559
|
+
}
|
|
14560
|
+
} else if (quote && bindings) {
|
|
14561
|
+
let end = source.indexOf(quote, cursor);
|
|
14562
|
+
while (true) {
|
|
14563
|
+
if (bindings.next < cursor) {
|
|
14564
|
+
const found = source.indexOf("{{", cursor);
|
|
14565
|
+
bindings.next = found < 0 ? Number.POSITIVE_INFINITY : found;
|
|
14566
|
+
}
|
|
14567
|
+
if (end >= 0 && end < bindings.next) {
|
|
14568
|
+
cursor = end;
|
|
14569
|
+
closed = true;
|
|
14570
|
+
break;
|
|
14571
|
+
}
|
|
14572
|
+
if (bindings.next === Number.POSITIVE_INFINITY) break;
|
|
14573
|
+
cursor = expressionEnd(source, bindings.next, true, syntax, quote);
|
|
14574
|
+
if (end >= 0 && end < cursor) end = source.indexOf(quote, cursor);
|
|
14575
|
+
}
|
|
14576
|
+
} else if (quote) {
|
|
14577
|
+
const boundary = quoteCode === 34 ? doubleQuotedBoundary : singleQuotedBoundary;
|
|
14578
|
+
boundary.lastIndex = cursor;
|
|
14579
|
+
while (boundary.test(source)) {
|
|
14580
|
+
if (source.charCodeAt(boundary.lastIndex - 1) === quoteCode) {
|
|
14581
|
+
cursor = boundary.lastIndex - 1;
|
|
14582
|
+
closed = true;
|
|
14583
|
+
break;
|
|
14584
|
+
}
|
|
14585
|
+
cursor = expressionEnd(source, boundary.lastIndex - 2, true, syntax, quote);
|
|
14586
|
+
boundary.lastIndex = cursor;
|
|
14587
|
+
}
|
|
14588
|
+
} else while (cursor < source.length) {
|
|
14589
|
+
const valueCode = source.charCodeAt(cursor);
|
|
14590
|
+
if (valueCode === 123 && source.charCodeAt(cursor + 1) === 123) cursor = expressionEnd(source, cursor, true, syntax, quote);
|
|
14591
|
+
else if (quote ? valueCode === quoteCode : isSpaceCode(valueCode) || valueCode === 62 || valueCode === 47 && source.charCodeAt(cursor + 1) === 62) {
|
|
14592
|
+
closed = true;
|
|
14593
|
+
break;
|
|
14594
|
+
} else cursor++;
|
|
14595
|
+
}
|
|
14596
|
+
if (!closed || !quote && cursor === valueStart) throw new TemplateLexicalError(attributeStart, "未闭合或为空的属性值");
|
|
14597
|
+
const valueEnd = cursor;
|
|
14598
|
+
if (quote) {
|
|
14599
|
+
cursor++;
|
|
14600
|
+
quotedAttribute = true;
|
|
14601
|
+
}
|
|
14602
|
+
if (collectAttributes) {
|
|
14603
|
+
const value = source.slice(valueStart, valueEnd);
|
|
14604
|
+
(attributes ??= []).push({
|
|
14605
|
+
name,
|
|
14606
|
+
nameStart: attributeStart,
|
|
14607
|
+
nameEnd: attributeNameEnd,
|
|
14608
|
+
start: attributeStart,
|
|
14609
|
+
end: cursor,
|
|
14610
|
+
valueStart,
|
|
14611
|
+
valueEnd,
|
|
14612
|
+
value,
|
|
14613
|
+
rawValue: quote ? source.slice(rawStart, cursor) : value,
|
|
14614
|
+
quote
|
|
14615
|
+
});
|
|
14616
|
+
}
|
|
14617
|
+
}
|
|
14618
|
+
throw new TemplateLexicalError(start, "未闭合的标签");
|
|
14619
|
+
}
|
|
14620
|
+
function opaqueEnd(source, start) {
|
|
14621
|
+
const delimiter = source.startsWith("<!--", start) ? "-->" : source.startsWith("<![CDATA[", start) ? "]]>" : source.startsWith("<?", start) ? "?>" : void 0;
|
|
14622
|
+
if (delimiter) {
|
|
14623
|
+
const end = source.indexOf(delimiter, start + 2);
|
|
14624
|
+
if (end < 0) throw new TemplateLexicalError(start, "未闭合的注释、CDATA 或处理指令");
|
|
14625
|
+
return end + delimiter.length;
|
|
14626
|
+
}
|
|
14627
|
+
let quote = 0;
|
|
14628
|
+
let depth = 0;
|
|
14629
|
+
for (let index = start + 2; index < source.length; index++) {
|
|
14630
|
+
const code = source.charCodeAt(index);
|
|
14631
|
+
if (quote) {
|
|
14632
|
+
if (code === quote) quote = 0;
|
|
14633
|
+
} else if (code === 34 || code === 39) quote = code;
|
|
14634
|
+
else if (code === 91) depth++;
|
|
14635
|
+
else if (code === 93) depth--;
|
|
14636
|
+
else if (code === 62 && depth === 0) return index + 1;
|
|
14637
|
+
}
|
|
14638
|
+
throw new TemplateLexicalError(start, "未闭合的模板声明");
|
|
14639
|
+
}
|
|
14640
|
+
function scanCompiledDocument(source, state, resolveScriptBoundary, buildTree, commentsOnly = false) {
|
|
14641
|
+
if (typeof source !== "string") throw new TypeError("Expected template source.");
|
|
14642
|
+
const { syntax, rawTagPattern, rawTagInitials } = state;
|
|
14643
|
+
const tokens = [];
|
|
14644
|
+
const diagnostics = [];
|
|
14645
|
+
const stack = [];
|
|
14646
|
+
const children = buildTree ? [] : void 0;
|
|
14647
|
+
const elements = buildTree ? [] : void 0;
|
|
14648
|
+
const scanEnd = commentsOnly ? source.lastIndexOf("<!--") + 1 : source.length;
|
|
14649
|
+
let cursor = 0;
|
|
14650
|
+
let textStart = 0;
|
|
14651
|
+
let nextTag = -1;
|
|
14652
|
+
const bindings = { next: -1 };
|
|
14653
|
+
function appendTag(token) {
|
|
14654
|
+
if (commentsOnly) return;
|
|
14655
|
+
const mutable = token;
|
|
14656
|
+
if (token.closing) {
|
|
14657
|
+
const openIndex = stack[stack.length - 1];
|
|
14658
|
+
const open = openIndex === void 0 ? void 0 : tokens[openIndex];
|
|
14659
|
+
if (!open || open.name !== token.name) diagnostics.push({
|
|
14660
|
+
code: "template/mismatched-tag",
|
|
14661
|
+
message: `结束标签 </${token.name}> 与开始标签不匹配`,
|
|
14662
|
+
severity: "error",
|
|
14663
|
+
start: token.start,
|
|
14664
|
+
end: token.end
|
|
14665
|
+
});
|
|
14666
|
+
else {
|
|
14667
|
+
stack.pop();
|
|
14668
|
+
mutable.matching = openIndex;
|
|
14669
|
+
mutable.parent = open.parent;
|
|
14670
|
+
open.matching = tokens.length;
|
|
14671
|
+
if (elements) {
|
|
14672
|
+
const element = elements.pop();
|
|
14673
|
+
element.closing = token;
|
|
14674
|
+
element.end = token.end;
|
|
14675
|
+
}
|
|
14676
|
+
}
|
|
14677
|
+
} else {
|
|
14678
|
+
mutable.parent = stack[stack.length - 1];
|
|
14679
|
+
if (elements) {
|
|
14680
|
+
const element = {
|
|
14681
|
+
kind: "element",
|
|
14682
|
+
name: token.name,
|
|
14683
|
+
attributes: token.attributes,
|
|
14684
|
+
children: [],
|
|
14685
|
+
opening: token,
|
|
14686
|
+
closing: void 0,
|
|
14687
|
+
selfClosing: token.selfClosing,
|
|
14688
|
+
start: token.start,
|
|
14689
|
+
end: token.end
|
|
14690
|
+
};
|
|
14691
|
+
(elements.length ? elements[elements.length - 1].children : children).push(element);
|
|
14692
|
+
if (!token.selfClosing) elements.push(element);
|
|
14693
|
+
}
|
|
14694
|
+
if (!token.selfClosing) stack.push(tokens.length);
|
|
14695
|
+
}
|
|
14696
|
+
tokens.push(token);
|
|
14697
|
+
}
|
|
14698
|
+
function appendRaw(token) {
|
|
14699
|
+
if (commentsOnly) {
|
|
14700
|
+
if (token.kind === "comment") tokens.push(token);
|
|
14701
|
+
return;
|
|
14702
|
+
}
|
|
14703
|
+
if (elements) (elements.length ? elements[elements.length - 1].children : children).push({
|
|
14704
|
+
kind: token.kind,
|
|
14705
|
+
start: token.start,
|
|
14706
|
+
end: token.end,
|
|
14707
|
+
tagName: token.tagName,
|
|
14708
|
+
data: source.slice(token.start, token.end)
|
|
14709
|
+
});
|
|
14710
|
+
tokens.push(token);
|
|
14711
|
+
}
|
|
14712
|
+
try {
|
|
14713
|
+
while (cursor < scanEnd) {
|
|
14714
|
+
if (!commentsOnly) {
|
|
14715
|
+
if (nextTag < cursor) {
|
|
14716
|
+
const found = source.indexOf("<", cursor);
|
|
14717
|
+
nextTag = found < 0 ? Number.POSITIVE_INFINITY : found;
|
|
14718
|
+
}
|
|
14719
|
+
if (bindings.next < cursor) {
|
|
14720
|
+
const found = source.indexOf("{{", cursor);
|
|
14721
|
+
bindings.next = found < 0 ? Number.POSITIVE_INFINITY : found;
|
|
14722
|
+
}
|
|
14723
|
+
if (bindings.next < nextTag) {
|
|
14724
|
+
cursor = expressionEnd(source, bindings.next, true, syntax);
|
|
14725
|
+
continue;
|
|
14726
|
+
}
|
|
14727
|
+
if (nextTag >= scanEnd) {
|
|
14728
|
+
cursor = scanEnd;
|
|
14729
|
+
break;
|
|
14730
|
+
}
|
|
14731
|
+
cursor = nextTag;
|
|
14732
|
+
}
|
|
14733
|
+
const code = source.charCodeAt(cursor);
|
|
14734
|
+
if (code === 123 && source.charCodeAt(cursor + 1) === 123) {
|
|
14735
|
+
cursor = expressionEnd(source, cursor, true, syntax);
|
|
14736
|
+
continue;
|
|
14737
|
+
}
|
|
14738
|
+
const next = source.charCodeAt(cursor + 1);
|
|
14739
|
+
if (code !== 60 || !isTagStartCode(next) && next !== 33 && next !== 47 && next !== 63) {
|
|
14740
|
+
cursor++;
|
|
14741
|
+
continue;
|
|
14742
|
+
}
|
|
14743
|
+
if (cursor > textStart) appendRaw({
|
|
14744
|
+
kind: "text",
|
|
14745
|
+
start: textStart,
|
|
14746
|
+
end: cursor
|
|
14747
|
+
});
|
|
14748
|
+
if (next === 33 || next === 63) {
|
|
14749
|
+
const end = opaqueEnd(source, cursor);
|
|
14750
|
+
appendRaw({
|
|
14751
|
+
kind: source.startsWith("<!--", cursor) ? "comment" : source.startsWith("<![CDATA[", cursor) ? "cdata" : "declaration",
|
|
14752
|
+
start: cursor,
|
|
14753
|
+
end
|
|
14754
|
+
});
|
|
14755
|
+
cursor = end;
|
|
14756
|
+
} else {
|
|
14757
|
+
const tag = scanTag(source, cursor, syntax, !commentsOnly, bindings);
|
|
14758
|
+
appendTag(tag);
|
|
14759
|
+
cursor = tag.end;
|
|
14760
|
+
if (!tag.closing && !tag.selfClosing && (rawTagInitials & 1 << tag.name.charCodeAt(0)) !== 0 && rawTagPattern.test(tag.name)) {
|
|
14761
|
+
const candidates = scanScriptBoundaryCandidates(source, cursor, tag.name);
|
|
14762
|
+
const close = resolveScriptBoundary ? resolveScriptBoundary(source, cursor, tag.name, candidates) : candidates.closingTag;
|
|
14763
|
+
if (!close) {
|
|
14764
|
+
if (candidates.commentClosings?.length) throw new TemplateLexicalError(tag.start, `脚本标签 <${tag.name}> 的结束边界存在歧义,需要 resolveScriptBoundary`);
|
|
14765
|
+
throw new TemplateLexicalError(tag.start, `未闭合的脚本标签 <${tag.name}>`);
|
|
14766
|
+
}
|
|
14767
|
+
if (!Number.isInteger(close.start) || !Number.isInteger(close.end) || close.start < cursor || close.end > source.length || close.end <= close.start) throw new TemplateLexicalError(tag.start, "脚本边界 resolver 返回了无效范围");
|
|
14768
|
+
appendRaw({
|
|
14769
|
+
kind: "script",
|
|
14770
|
+
tagName: tag.name,
|
|
14771
|
+
start: cursor,
|
|
14772
|
+
end: close.start
|
|
14773
|
+
});
|
|
14774
|
+
const closing = scanTag(source, close.start, syntax, !commentsOnly, bindings);
|
|
14775
|
+
if (!closing.closing || closing.end !== close.end || closing.name.toLowerCase() !== tag.name.toLowerCase()) throw new TemplateLexicalError(close.start, "脚本边界 resolver 返回的范围不是对应结束标签");
|
|
14776
|
+
appendTag(closing);
|
|
14777
|
+
cursor = closing.end;
|
|
14778
|
+
}
|
|
14779
|
+
}
|
|
14780
|
+
textStart = cursor;
|
|
14781
|
+
}
|
|
14782
|
+
if (!commentsOnly && textStart < source.length) appendRaw({
|
|
14783
|
+
kind: "text",
|
|
14784
|
+
start: textStart,
|
|
14785
|
+
end: source.length
|
|
14786
|
+
});
|
|
14787
|
+
for (const index of stack) {
|
|
14788
|
+
const token = tokens[index];
|
|
14789
|
+
diagnostics.push({
|
|
14790
|
+
code: "template/unclosed-tag",
|
|
14791
|
+
message: `标签 <${token.name}> 缺少结束标签`,
|
|
14792
|
+
severity: "error",
|
|
14793
|
+
start: token.start,
|
|
14794
|
+
end: token.end
|
|
14795
|
+
});
|
|
14796
|
+
}
|
|
14797
|
+
} catch (error) {
|
|
14798
|
+
if (!(error instanceof TemplateLexicalError)) throw error;
|
|
14799
|
+
diagnostics.push({
|
|
14800
|
+
code: error.recovery ? "template/invalid-interpolation" : "template/invalid-syntax",
|
|
14801
|
+
message: error.message,
|
|
14802
|
+
severity: "error",
|
|
14803
|
+
start: error.offset,
|
|
14804
|
+
end: Math.min(source.length, error.offset + 1),
|
|
14805
|
+
...error.recovery ? { recovery: error.recovery } : {}
|
|
14806
|
+
});
|
|
14807
|
+
}
|
|
14808
|
+
return buildTree ? {
|
|
14809
|
+
tokens,
|
|
14810
|
+
diagnostics,
|
|
14811
|
+
children,
|
|
14812
|
+
syntax
|
|
14813
|
+
} : {
|
|
14814
|
+
tokens,
|
|
14815
|
+
diagnostics
|
|
14816
|
+
};
|
|
14817
|
+
}
|
|
14818
|
+
const contexts = /* @__PURE__ */ new WeakMap();
|
|
14819
|
+
/** 配置属于解析器,文档仅保存弱关联;编辑延续同一个不可变上下文。 */
|
|
14820
|
+
function bindDocument(document, context) {
|
|
14821
|
+
contexts.set(document, context);
|
|
14822
|
+
return document;
|
|
14823
|
+
}
|
|
14824
|
+
/** 文档构造由所属上下文负责,核心仅创建通用字段并绑定完整结果。 */
|
|
14825
|
+
function createDocument(source, fields, context) {
|
|
14826
|
+
return bindDocument(context.createDocument ? context.createDocument(source, fields) : {
|
|
14827
|
+
source,
|
|
14828
|
+
syntax: fields.syntax,
|
|
14829
|
+
tokens: fields.tokens,
|
|
14830
|
+
diagnostics: fields.diagnostics,
|
|
14831
|
+
children: fields.children
|
|
14832
|
+
}, context);
|
|
14833
|
+
}
|
|
14834
|
+
function parseContext(source, context) {
|
|
14835
|
+
return createDocument(source, scanCompiledDocument(source, context.state, context.resolveScriptBoundary, true), context);
|
|
14836
|
+
}
|
|
14837
|
+
/** 解码不含外层引号的词法属性值;表达式内部保留 JS 字符串的转义层。 */
|
|
14838
|
+
function decodeAttribute(value, syntax = "legacy", decodeEntities = true, quote) {
|
|
14839
|
+
if (syntax !== "legacy") return decodeEntities && value.includes("&") ? decodeXML(value) : value;
|
|
14840
|
+
const decoded = quote && value.includes("\\") ? decodeLegacyAttributeLayer(value) : value;
|
|
14841
|
+
if (!decodeEntities || !decoded.includes("&")) return decoded;
|
|
14842
|
+
if (!decoded.includes("{{")) return decodeXML(decoded);
|
|
14843
|
+
let result = "";
|
|
14844
|
+
let offset = 0;
|
|
14845
|
+
for (const range of legacyAttributeInterpolations(decoded)) {
|
|
14846
|
+
result += decodeXML(decoded.slice(offset, range.start));
|
|
14847
|
+
result += decoded.slice(range.start, range.end);
|
|
14848
|
+
offset = range.end;
|
|
14849
|
+
}
|
|
14850
|
+
return result + decodeXML(decoded.slice(offset));
|
|
14851
|
+
}
|
|
14852
|
+
const states = /* @__PURE__ */ new WeakMap();
|
|
14853
|
+
/** 校验并冻结方言声明,匹配结构不通过公开对象暴露。 */
|
|
14854
|
+
function compileDialect(definition) {
|
|
14855
|
+
if (!definition || typeof definition !== "object" || Array.isArray(definition)) throw new TypeError("Expected a dialect definition.");
|
|
14856
|
+
const { id, syntax, rawTags } = definition;
|
|
14857
|
+
if (typeof id !== "string" || !id) throw new TypeError("Expected a nonempty dialect id.");
|
|
14858
|
+
if (syntax !== "legacy" && syntax !== "xml") throw new TypeError(`Unsupported template syntax: ${String(syntax)}.`);
|
|
14859
|
+
if (!Array.isArray(rawTags)) throw new TypeError("Expected rawTags to be an array of nonempty names.");
|
|
14860
|
+
const names = Object.freeze(rawTags.slice());
|
|
14861
|
+
let rawTagInitials = 0;
|
|
14862
|
+
for (const name of names) {
|
|
14863
|
+
if (typeof name !== "string" || !name) throw new TypeError("Expected rawTags to be an array of nonempty names.");
|
|
14864
|
+
rawTagInitials |= 1 << name.charCodeAt(0);
|
|
14865
|
+
}
|
|
14866
|
+
const matcher = new RegExp(`^(?:${names.map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`, "i");
|
|
14867
|
+
const compiled = Object.freeze({
|
|
14868
|
+
id,
|
|
14869
|
+
syntax,
|
|
14870
|
+
rawTags: names
|
|
14871
|
+
});
|
|
14872
|
+
states.set(compiled, Object.freeze({
|
|
14873
|
+
syntax,
|
|
14874
|
+
rawTagPattern: matcher,
|
|
14875
|
+
rawTagInitials
|
|
14876
|
+
}));
|
|
14877
|
+
return compiled;
|
|
14878
|
+
}
|
|
14879
|
+
/** 绑定解析器或兼容上下文时校验一次,后续扫描直接使用私有状态。 */
|
|
14880
|
+
function compiledState(dialect) {
|
|
14881
|
+
const state = states.get(dialect);
|
|
14882
|
+
if (!state) throw new TypeError("Expected a compiled dialect.");
|
|
14883
|
+
return state;
|
|
14884
|
+
}
|
|
14885
|
+
/** 将编译方言绑定一次,同一解析器复用不可变配置和 matcher。 */
|
|
14886
|
+
function createParser(dialect, options = {}) {
|
|
14887
|
+
const state = compiledState(dialect);
|
|
14888
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) throw new TypeError("Expected parser options.");
|
|
14889
|
+
const resolver = options.resolveScriptBoundary;
|
|
14890
|
+
if (resolver !== void 0 && typeof resolver !== "function") throw new TypeError("Expected resolveScriptBoundary to be a function.");
|
|
14891
|
+
const context = Object.freeze({
|
|
14892
|
+
dialect,
|
|
14893
|
+
state,
|
|
14894
|
+
resolveScriptBoundary: resolver
|
|
14895
|
+
});
|
|
14896
|
+
return Object.freeze({
|
|
14897
|
+
dialect,
|
|
14898
|
+
scan: (source) => scanCompiledDocument(source, state, context.resolveScriptBoundary, false),
|
|
14899
|
+
scanComments: (source) => scanCompiledDocument(source, state, context.resolveScriptBoundary, false, true),
|
|
14900
|
+
parse: (source) => parseContext(source, context)
|
|
14901
|
+
});
|
|
14902
|
+
}
|
|
13521
14903
|
// ../../mpcore/packages/simulator/src/view/templateInterpolation.ts
|
|
13522
|
-
/**
|
|
14904
|
+
/** 共享词法边界,保留历史上不完整绑定按字面量显示、闭合但无效表达式交给求值层的行为。 */
|
|
13523
14905
|
function templateInterpolations(source) {
|
|
13524
14906
|
const ranges = [];
|
|
13525
14907
|
let offset = 0;
|
|
13526
14908
|
while (offset < source.length) {
|
|
13527
14909
|
const start = source.indexOf("{{", offset);
|
|
13528
14910
|
if (start < 0) break;
|
|
13529
|
-
let
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
if (
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
end: i + 2,
|
|
13544
|
-
expression: source.slice(start + 2, i)
|
|
13545
|
-
});
|
|
13546
|
-
offset = i + 2;
|
|
13547
|
-
closed = true;
|
|
13548
|
-
break;
|
|
13549
|
-
}
|
|
13550
|
-
depth--;
|
|
13551
|
-
}
|
|
13552
|
-
}
|
|
13553
|
-
if (!closed) break;
|
|
14911
|
+
let end;
|
|
14912
|
+
try {
|
|
14913
|
+
end = expressionEnd(source, start);
|
|
14914
|
+
} catch (error) {
|
|
14915
|
+
if (!(error instanceof TemplateLexicalError)) throw error;
|
|
14916
|
+
if (!error.recovery) break;
|
|
14917
|
+
end = error.recovery.end;
|
|
14918
|
+
}
|
|
14919
|
+
ranges.push({
|
|
14920
|
+
start,
|
|
14921
|
+
end,
|
|
14922
|
+
expression: source.slice(start + 2, end - 2)
|
|
14923
|
+
});
|
|
14924
|
+
offset = end;
|
|
13554
14925
|
}
|
|
13555
14926
|
return ranges;
|
|
13556
14927
|
}
|
|
@@ -13657,7 +15028,7 @@ function evaluateObjectExpression(node, source) {
|
|
|
13657
15028
|
continue;
|
|
13658
15029
|
}
|
|
13659
15030
|
if (property.type !== "ObjectProperty") continue;
|
|
13660
|
-
const keyRead = captureTemplateValueReads(source, () => property.computed ? evaluateExpressionNode(property.key, source) : property.key?.name ?? property.key?.value);
|
|
15031
|
+
const keyRead = captureTemplateValueReads(source, () => property.computed ? evaluateExpressionNode(property.key, source) : property.key?.type === "StringLiteral" ? resolveWxmlStringLiteral(property.key) : property.key?.name ?? property.key?.value);
|
|
13661
15032
|
const key = keyRead.value;
|
|
13662
15033
|
if (typeof key !== "string" && typeof key !== "number" || BLOCKED_MEMBER_KEYS.has(String(key))) continue;
|
|
13663
15034
|
const value = captureTemplateValueReads(source, () => evaluateExpressionNode(property.value, source));
|
|
@@ -13688,7 +15059,7 @@ function evaluateExpressionNode(node, source) {
|
|
|
13688
15059
|
if (!node) return;
|
|
13689
15060
|
switch (node.type) {
|
|
13690
15061
|
case "Identifier": return resolveIdentifier(source, node.name);
|
|
13691
|
-
case "StringLiteral":
|
|
15062
|
+
case "StringLiteral": return resolveWxmlStringLiteral(node);
|
|
13692
15063
|
case "NumericLiteral":
|
|
13693
15064
|
case "BooleanLiteral": return node.value;
|
|
13694
15065
|
case "NullLiteral": return null;
|
|
@@ -14077,6 +15448,532 @@ function resolveSelectorQueryScopeSnapshot(scope, snapshots) {
|
|
|
14077
15448
|
}
|
|
14078
15449
|
return null;
|
|
14079
15450
|
}
|
|
15451
|
+
// ../wxml/dist/presets-Ez_Kg5w3.mjs
|
|
15452
|
+
const compatibilityRawTags = Object.freeze([
|
|
15453
|
+
"wxs",
|
|
15454
|
+
"sjs",
|
|
15455
|
+
"ks",
|
|
15456
|
+
"filter",
|
|
15457
|
+
"script",
|
|
15458
|
+
"import-sjs"
|
|
15459
|
+
]);
|
|
15460
|
+
const filterScriptReference = Object.freeze({
|
|
15461
|
+
tag: "filter",
|
|
15462
|
+
sourceAttribute: "src"
|
|
15463
|
+
});
|
|
15464
|
+
function dialect(id, syntax, rawTags) {
|
|
15465
|
+
return Object.freeze({
|
|
15466
|
+
id,
|
|
15467
|
+
syntax,
|
|
15468
|
+
rawTags: Object.freeze([...rawTags])
|
|
15469
|
+
});
|
|
15470
|
+
}
|
|
15471
|
+
function module$1(extension, tag, format = "commonjs", sourceAttribute = "src", moduleAttribute = "module") {
|
|
15472
|
+
return Object.freeze({
|
|
15473
|
+
extension,
|
|
15474
|
+
tag,
|
|
15475
|
+
format,
|
|
15476
|
+
sourceAttribute,
|
|
15477
|
+
moduleAttribute
|
|
15478
|
+
});
|
|
15479
|
+
}
|
|
15480
|
+
function directives(prefix, separator = ":") {
|
|
15481
|
+
const name = (suffix) => `${prefix}${separator}${suffix}`;
|
|
15482
|
+
return Object.freeze({
|
|
15483
|
+
if: name("if"),
|
|
15484
|
+
elif: name("elif"),
|
|
15485
|
+
else: name("else"),
|
|
15486
|
+
for: name("for"),
|
|
15487
|
+
forItem: name("for-item"),
|
|
15488
|
+
forIndex: name("for-index"),
|
|
15489
|
+
key: name("key")
|
|
15490
|
+
});
|
|
15491
|
+
}
|
|
15492
|
+
function createPreset(input) {
|
|
15493
|
+
const nativeModules = Object.freeze([...input.nativeScriptModules ?? []]);
|
|
15494
|
+
const nativeRawTags = [
|
|
15495
|
+
input.portableScriptModule.tag,
|
|
15496
|
+
...nativeModules.map((module) => module.tag),
|
|
15497
|
+
...input.extraRawTags ?? []
|
|
15498
|
+
];
|
|
15499
|
+
const compatibilityDialect = dialect(`${input.id}-compatibility`, input.id === "weapp" ? "legacy" : "xml", [.../* @__PURE__ */ new Set([...compatibilityRawTags, ...nativeModules.map((module) => module.tag)])]);
|
|
15500
|
+
const nativeDialect = dialect(`${input.id}-native`, compatibilityDialect.syntax, [...new Set(nativeRawTags)]);
|
|
15501
|
+
return Object.freeze({
|
|
15502
|
+
id: input.id,
|
|
15503
|
+
templateExtension: input.templateExtension,
|
|
15504
|
+
styleExtension: input.styleExtension,
|
|
15505
|
+
dialect: nativeDialect,
|
|
15506
|
+
nativeDialect,
|
|
15507
|
+
compatibilityDialect,
|
|
15508
|
+
portableScriptModule: input.portableScriptModule,
|
|
15509
|
+
nativeScriptModules: nativeModules,
|
|
15510
|
+
directives: directives(input.directivePrefix, input.directiveSeparator),
|
|
15511
|
+
directivePrefix: input.directivePrefix,
|
|
15512
|
+
directiveSeparator: input.directiveSeparator ?? ":",
|
|
15513
|
+
eventStyle: input.eventStyle ?? "default"
|
|
15514
|
+
});
|
|
15515
|
+
}
|
|
15516
|
+
/** 纯模板语言预设;不会暗示对应平台具备构建或宿主 runtime 支持。 */
|
|
15517
|
+
const weapp = createPreset({
|
|
15518
|
+
id: "weapp",
|
|
15519
|
+
templateExtension: ".wxml",
|
|
15520
|
+
styleExtension: ".wxss",
|
|
15521
|
+
directivePrefix: "wx",
|
|
15522
|
+
portableScriptModule: module$1("wxs", "wxs")
|
|
15523
|
+
});
|
|
15524
|
+
const alipay = createPreset({
|
|
15525
|
+
id: "alipay",
|
|
15526
|
+
templateExtension: ".axml",
|
|
15527
|
+
styleExtension: ".acss",
|
|
15528
|
+
directivePrefix: "a",
|
|
15529
|
+
eventStyle: "alipay",
|
|
15530
|
+
portableScriptModule: module$1("sjs", "import-sjs", "esm", "from", "name")
|
|
15531
|
+
});
|
|
15532
|
+
const tt = createPreset({
|
|
15533
|
+
id: "tt",
|
|
15534
|
+
templateExtension: ".ttml",
|
|
15535
|
+
styleExtension: ".ttss",
|
|
15536
|
+
directivePrefix: "tt",
|
|
15537
|
+
portableScriptModule: module$1("sjs", "sjs")
|
|
15538
|
+
});
|
|
15539
|
+
const swan = createPreset({
|
|
15540
|
+
id: "swan",
|
|
15541
|
+
templateExtension: ".swan",
|
|
15542
|
+
styleExtension: ".css",
|
|
15543
|
+
directivePrefix: "s",
|
|
15544
|
+
directiveSeparator: "-",
|
|
15545
|
+
extraRawTags: [filterScriptReference.tag],
|
|
15546
|
+
portableScriptModule: module$1("sjs", "import-sjs", "esm")
|
|
15547
|
+
});
|
|
15548
|
+
const jd = createPreset({
|
|
15549
|
+
id: "jd",
|
|
15550
|
+
templateExtension: ".jxml",
|
|
15551
|
+
styleExtension: ".jxss",
|
|
15552
|
+
directivePrefix: "wx",
|
|
15553
|
+
portableScriptModule: module$1("wxs", "wxs"),
|
|
15554
|
+
nativeScriptModules: [module$1("jds", "jds")]
|
|
15555
|
+
});
|
|
15556
|
+
const xhs = createPreset({
|
|
15557
|
+
id: "xhs",
|
|
15558
|
+
templateExtension: ".xhsml",
|
|
15559
|
+
styleExtension: ".css",
|
|
15560
|
+
directivePrefix: "wx",
|
|
15561
|
+
portableScriptModule: module$1("wxs", "wxs")
|
|
15562
|
+
});
|
|
15563
|
+
const qq = createPreset({
|
|
15564
|
+
id: "qq",
|
|
15565
|
+
templateExtension: ".qml",
|
|
15566
|
+
styleExtension: ".qss",
|
|
15567
|
+
directivePrefix: "qq",
|
|
15568
|
+
portableScriptModule: module$1("wxs", "wxs"),
|
|
15569
|
+
nativeScriptModules: [module$1("qs", "qs")]
|
|
15570
|
+
});
|
|
15571
|
+
const ks = createPreset({
|
|
15572
|
+
id: "ks",
|
|
15573
|
+
templateExtension: ".ksml",
|
|
15574
|
+
styleExtension: ".css",
|
|
15575
|
+
directivePrefix: "ks",
|
|
15576
|
+
portableScriptModule: module$1("ks", "ks")
|
|
15577
|
+
});
|
|
15578
|
+
const ty = createPreset({
|
|
15579
|
+
id: "ty",
|
|
15580
|
+
templateExtension: ".tyml",
|
|
15581
|
+
styleExtension: ".tyss",
|
|
15582
|
+
directivePrefix: "ty",
|
|
15583
|
+
portableScriptModule: module$1("sjs", "sjs")
|
|
15584
|
+
});
|
|
15585
|
+
function referenceRecipe(script) {
|
|
15586
|
+
return Object.freeze({
|
|
15587
|
+
tag: script.tag,
|
|
15588
|
+
sourceAttributes: Object.freeze([script.sourceAttribute])
|
|
15589
|
+
});
|
|
15590
|
+
}
|
|
15591
|
+
/** 兼容构建输入保留原有标签次序;平台原生别名由各自预设追加。 */
|
|
15592
|
+
const portableCompatibilityScriptRecipes = Object.freeze([
|
|
15593
|
+
referenceRecipe(weapp.portableScriptModule),
|
|
15594
|
+
referenceRecipe(tt.portableScriptModule),
|
|
15595
|
+
referenceRecipe(filterScriptReference),
|
|
15596
|
+
referenceRecipe(alipay.portableScriptModule)
|
|
15597
|
+
]);
|
|
15598
|
+
/** 无平台构建入口的历史默认,不暗示微信或其他宿主能力。 */
|
|
15599
|
+
const defaultTemplateInputRecipe = Object.freeze({
|
|
15600
|
+
defaultScriptModule: weapp.portableScriptModule,
|
|
15601
|
+
scriptModules: Object.freeze([weapp.portableScriptModule, tt.portableScriptModule]),
|
|
15602
|
+
scriptReferences: portableCompatibilityScriptRecipes,
|
|
15603
|
+
rawTags: Object.freeze(portableCompatibilityScriptRecipes.map((recipe) => recipe.tag))
|
|
15604
|
+
});
|
|
15605
|
+
Object.freeze({
|
|
15606
|
+
unprofiled: Object.freeze({
|
|
15607
|
+
defaultScriptModule: weapp.portableScriptModule,
|
|
15608
|
+
scriptModules: Object.freeze([weapp.portableScriptModule, module$1(tt.portableScriptModule.extension, tt.portableScriptModule.tag, "esm")])
|
|
15609
|
+
}),
|
|
15610
|
+
platform: defaultTemplateInputRecipe
|
|
15611
|
+
});
|
|
15612
|
+
const presets = Object.freeze([
|
|
15613
|
+
weapp,
|
|
15614
|
+
alipay,
|
|
15615
|
+
tt,
|
|
15616
|
+
swan,
|
|
15617
|
+
jd,
|
|
15618
|
+
xhs,
|
|
15619
|
+
qq,
|
|
15620
|
+
ks,
|
|
15621
|
+
ty
|
|
15622
|
+
]);
|
|
15623
|
+
new Map(presets.map((preset) => [preset.id, preset]));
|
|
15624
|
+
// ../../mpcore/packages/simulator/src/view/sharedDocument.ts
|
|
15625
|
+
const parser = createParser(compileDialect(weapp.dialect), { resolveScriptBoundary: (_source, _start, _tag, candidates) => candidates.closingTag ?? candidates.commentClosings?.at(-1) });
|
|
15626
|
+
/** 元数据属于模板节点,普通 clone/spread 自动保留,不依赖外部 WeakMap。 */
|
|
15627
|
+
function sourceAttributeForms(node) {
|
|
15628
|
+
return node.attributeForms;
|
|
15629
|
+
}
|
|
15630
|
+
/** 将共享源码树适配为 simulator 的逻辑模板树,不执行脚本或解析依赖。 */
|
|
15631
|
+
function parseSharedDocument(source, stripWhitespace = false) {
|
|
15632
|
+
const document = parser.parse(source);
|
|
15633
|
+
const fatal = document.diagnostics.find((item) => item.severity === "error");
|
|
15634
|
+
if (fatal) throw new Error(`[simulator] ${fatal.start}: ${fatal.message}`);
|
|
15635
|
+
const root = {
|
|
15636
|
+
type: "root",
|
|
15637
|
+
children: [],
|
|
15638
|
+
parent: null,
|
|
15639
|
+
prev: null,
|
|
15640
|
+
next: null
|
|
15641
|
+
};
|
|
15642
|
+
const stack = [{
|
|
15643
|
+
input: document.children,
|
|
15644
|
+
output: root
|
|
15645
|
+
}];
|
|
15646
|
+
while (stack.length) {
|
|
15647
|
+
const { input, output } = stack.pop();
|
|
15648
|
+
for (const item of input) {
|
|
15649
|
+
if (stripWhitespace && item.kind === "text" && /^[\t\r\n ]+$/.test(item.data)) continue;
|
|
15650
|
+
const node = {
|
|
15651
|
+
type: item.kind === "element" ? "tag" : item.kind === "script" ? "text" : item.kind,
|
|
15652
|
+
parent: output,
|
|
15653
|
+
prev: output.children.at(-1) ?? null,
|
|
15654
|
+
next: null
|
|
15655
|
+
};
|
|
15656
|
+
if (node.prev) node.prev.next = node;
|
|
15657
|
+
output.children.push(node);
|
|
15658
|
+
if (item.kind === "element") {
|
|
15659
|
+
node.name = item.name;
|
|
15660
|
+
node.attribs = {};
|
|
15661
|
+
node.children = [];
|
|
15662
|
+
const forms = /* @__PURE__ */ new Set();
|
|
15663
|
+
for (const attribute of item.attributes) if (!Object.hasOwn(node.attribs, attribute.name)) {
|
|
15664
|
+
node.attribs[attribute.name] = decodeAttribute(attribute.value ?? "", "legacy", false, attribute.quote);
|
|
15665
|
+
if (attribute.value === void 0 && Object.hasOwn(node.attribs, attribute.name)) forms.add(attribute.name);
|
|
15666
|
+
}
|
|
15667
|
+
if (forms.size) node.attributeForms = forms;
|
|
15668
|
+
stack.push({
|
|
15669
|
+
input: item.children,
|
|
15670
|
+
output: node
|
|
15671
|
+
});
|
|
15672
|
+
} else if (item.kind === "cdata") {
|
|
15673
|
+
node.type = "cdata";
|
|
15674
|
+
node.children = [{
|
|
15675
|
+
type: "text",
|
|
15676
|
+
data: item.data.slice(9, -3),
|
|
15677
|
+
parent: node,
|
|
15678
|
+
prev: null,
|
|
15679
|
+
next: null
|
|
15680
|
+
}];
|
|
15681
|
+
} else {
|
|
15682
|
+
node.data = item.kind === "comment" ? item.data.slice(4, -3) : item.data;
|
|
15683
|
+
if (item.kind === "declaration") {
|
|
15684
|
+
node.type = "directive";
|
|
15685
|
+
node.data = item.data.slice(1, item.data.endsWith("?>") ? -2 : -1);
|
|
15686
|
+
node.name = node.data.split(/\s/, 1)[0];
|
|
15687
|
+
}
|
|
15688
|
+
}
|
|
15689
|
+
}
|
|
15690
|
+
}
|
|
15691
|
+
return root;
|
|
15692
|
+
}
|
|
15693
|
+
/** synthetic page 与静态纯空白过滤是 simulator 的渲染约定。 */
|
|
15694
|
+
function parseSharedWxsDocument(source) {
|
|
15695
|
+
return parseSharedDocument(`<page>${source}</page>`, true);
|
|
15696
|
+
}
|
|
15697
|
+
// ../../mpcore/packages/simulator/src/view/templateAttributes.ts
|
|
15698
|
+
/** 裸属性词法信息属于节点,普通展开和渲染克隆保留同一份只读元数据。 */
|
|
15699
|
+
function isValuelessTemplateAttribute(node, name) {
|
|
15700
|
+
return sourceAttributeForms(node)?.has(name) ?? false;
|
|
15701
|
+
}
|
|
15702
|
+
function copyTemplateAttributeMetadata(source, target) {
|
|
15703
|
+
const attributes = sourceAttributeForms(source);
|
|
15704
|
+
const destination = target;
|
|
15705
|
+
if (attributes) destination.attributeForms = attributes;
|
|
15706
|
+
else delete destination.attributeForms;
|
|
15707
|
+
}
|
|
15708
|
+
// ../../mpcore/packages/simulator/src/runtime/componentInstance/selection.ts
|
|
15709
|
+
function hasExportBehavior(definition, visited = /* @__PURE__ */ new Set()) {
|
|
15710
|
+
if (visited.has(definition)) return false;
|
|
15711
|
+
visited.add(definition);
|
|
15712
|
+
return (Array.isArray(definition.behaviors) ? definition.behaviors : []).some((behavior) => behavior === "wx://component-export" || behavior !== null && typeof behavior === "object" && hasExportBehavior(behavior, visited));
|
|
15713
|
+
}
|
|
15714
|
+
/** 原生选择器尊重组件导出行为;测试桥接继续保留完整组件实例。 */
|
|
15715
|
+
function resolveNativeComponentSelection(instance) {
|
|
15716
|
+
if (!instance) return null;
|
|
15717
|
+
const definition = instance.__definition__;
|
|
15718
|
+
if (!definition || !hasExportBehavior(definition) || typeof instance.export !== "function") return instance;
|
|
15719
|
+
return instance.export();
|
|
15720
|
+
}
|
|
15721
|
+
// ../../mpcore/packages/simulator/src/project/plugins.ts
|
|
15722
|
+
const HEADLESS_PLUGIN_VIRTUAL_ROOT = "__plugins__";
|
|
15723
|
+
const PLUGIN_URL_RE = /^plugin:\/\/([^/]+)\/(.+)$/;
|
|
15724
|
+
function createPluginVirtualRoot(alias) {
|
|
15725
|
+
return `${HEADLESS_PLUGIN_VIRTUAL_ROOT}/${alias}`;
|
|
15726
|
+
}
|
|
15727
|
+
function resolvePluginRequest(plugins, request, kind) {
|
|
15728
|
+
const match = PLUGIN_URL_RE.exec(request);
|
|
15729
|
+
if (!match) return;
|
|
15730
|
+
const [, alias, publicName] = match;
|
|
15731
|
+
const plugin = plugins.find((item) => item.alias === alias);
|
|
15732
|
+
const registry = kind === "page" ? plugin?.config.pages : plugin?.config.publicComponents;
|
|
15733
|
+
const resourcePath = registry && typeof registry === "object" && !Array.isArray(registry) ? registry[publicName] : void 0;
|
|
15734
|
+
if (!plugin || typeof resourcePath !== "string" || !resourcePath) return;
|
|
15735
|
+
return {
|
|
15736
|
+
plugin,
|
|
15737
|
+
publicName,
|
|
15738
|
+
resourcePath: `${plugin.virtualRoot}/${resourcePath}`
|
|
15739
|
+
};
|
|
15740
|
+
}
|
|
15741
|
+
function createPluginArtifactSource(fallback, miniprogramRootPath, plugins) {
|
|
15742
|
+
function resolvePhysicalPath(filePath) {
|
|
15743
|
+
const normalizedPath = path.resolve(filePath);
|
|
15744
|
+
for (const plugin of plugins) {
|
|
15745
|
+
const virtualRootPath = path.resolve(miniprogramRootPath, plugin.virtualRoot);
|
|
15746
|
+
const relativePath = path.relative(virtualRootPath, normalizedPath);
|
|
15747
|
+
if (!relativePath.startsWith("..") && !path.isAbsolute(relativePath)) return path.resolve(plugin.rootPath, relativePath);
|
|
15748
|
+
}
|
|
15749
|
+
return normalizedPath;
|
|
15750
|
+
}
|
|
15751
|
+
return {
|
|
15752
|
+
has: (filePath) => fallback.has(resolvePhysicalPath(filePath)),
|
|
15753
|
+
readText: (filePath) => fallback.readText(resolvePhysicalPath(filePath)),
|
|
15754
|
+
readBinary: (filePath) => fallback.readBinary?.(resolvePhysicalPath(filePath))
|
|
15755
|
+
};
|
|
15756
|
+
}
|
|
15757
|
+
// ../../mpcore/packages/simulator/src/runtime/moduleResolution.ts
|
|
15758
|
+
function resolveMiniProgramModule(importer, request, miniprogramRootPath, hasFile) {
|
|
15759
|
+
function resolveFile(basePath) {
|
|
15760
|
+
return [
|
|
15761
|
+
basePath,
|
|
15762
|
+
`${basePath}.js`,
|
|
15763
|
+
`${basePath}.json`,
|
|
15764
|
+
join(basePath, "index.js")
|
|
15765
|
+
].find(hasFile);
|
|
15766
|
+
}
|
|
15767
|
+
if (request.startsWith(".")) return resolveFile(join(dirname(importer), request));
|
|
15768
|
+
if (request.includes("\\") || request.includes(":") || request.split("/").some((part) => !part || part === "." || part === "..")) return;
|
|
15769
|
+
const root = normalize(miniprogramRootPath);
|
|
15770
|
+
let directory = dirname(importer);
|
|
15771
|
+
while (true) {
|
|
15772
|
+
const relativeDirectory = relative(root, directory);
|
|
15773
|
+
if (relativeDirectory === ".." || relativeDirectory.startsWith("../")) return;
|
|
15774
|
+
const resolved = resolveFile(join(directory, "miniprogram_npm", request));
|
|
15775
|
+
if (resolved) return resolved;
|
|
15776
|
+
if (normalize(directory) === root) return;
|
|
15777
|
+
const parent = dirname(directory);
|
|
15778
|
+
if (parent === directory) return;
|
|
15779
|
+
directory = parent;
|
|
15780
|
+
}
|
|
15781
|
+
}
|
|
15782
|
+
// ../../mpcore/packages/simulator/src/runtime/componentResolution.ts
|
|
15783
|
+
function resolveMiniProgramComponent(ownerFilePath, request, miniprogramRootPath, hasFile) {
|
|
15784
|
+
const localPath = request.startsWith("/") ? request.replace(/^\/+/, "") : join(dirname(ownerFilePath), request);
|
|
15785
|
+
if (request.startsWith("/") || request.startsWith(".")) {
|
|
15786
|
+
const hasComponentArtifact = (basePath) => [
|
|
15787
|
+
"js",
|
|
15788
|
+
"json",
|
|
15789
|
+
"wxml",
|
|
15790
|
+
"wxss"
|
|
15791
|
+
].some((extension) => hasFile(join(miniprogramRootPath, `${basePath}.${extension}`)));
|
|
15792
|
+
if (hasComponentArtifact(localPath)) return localPath;
|
|
15793
|
+
const directoryPath = join(localPath, "index");
|
|
15794
|
+
return hasComponentArtifact(directoryPath) ? directoryPath : localPath;
|
|
15795
|
+
}
|
|
15796
|
+
if (hasFile(join(miniprogramRootPath, `${localPath}.js`))) return localPath;
|
|
15797
|
+
const npmPath = resolveMiniProgramModule(join(miniprogramRootPath, ownerFilePath), request, miniprogramRootPath, (candidate) => candidate.endsWith(".js") && hasFile(candidate));
|
|
15798
|
+
return npmPath ? relative(miniprogramRootPath, npmPath).slice(0, -3) : localPath;
|
|
15799
|
+
}
|
|
15800
|
+
// ../../mpcore/packages/simulator/src/view/nativeBindings/index.ts
|
|
15801
|
+
const bindings = /* @__PURE__ */ new WeakMap();
|
|
15802
|
+
/** 原生受控属性保留实例归属与求值依赖,序列化值仍由现有 renderer 负责。 */
|
|
15803
|
+
function resolveNativeAttributeValue(node, name, scope, read) {
|
|
15804
|
+
const source = wxsScopeData(scope);
|
|
15805
|
+
if (node.name !== "scroll-view" || name !== "refresher-triggered" || !scope.dataOwner) return read(source);
|
|
15806
|
+
const result = captureTemplateReads(source, scope.dataOwner.data, () => read(source));
|
|
15807
|
+
bindings.set(node, {
|
|
15808
|
+
owner: scope.dataOwner,
|
|
15809
|
+
revision: getNativeDataRevision(scope.dataOwner),
|
|
15810
|
+
paths: result.paths
|
|
15811
|
+
});
|
|
15812
|
+
return result.value;
|
|
15813
|
+
}
|
|
15814
|
+
function getNativeBindingCommit(node, previous) {
|
|
15815
|
+
const binding = bindings.get(node);
|
|
15816
|
+
if (!binding) return {
|
|
15817
|
+
explicit: false,
|
|
15818
|
+
consumed: previous
|
|
15819
|
+
};
|
|
15820
|
+
const after = previous?.owner === binding.owner ? previous.revision : binding.revision;
|
|
15821
|
+
return {
|
|
15822
|
+
explicit: hasNativeDataCommit(binding.owner, binding.paths, after, binding.revision),
|
|
15823
|
+
consumed: {
|
|
15824
|
+
owner: binding.owner,
|
|
15825
|
+
revision: binding.revision
|
|
15826
|
+
}
|
|
15827
|
+
};
|
|
15828
|
+
}
|
|
15829
|
+
// ../../mpcore/packages/simulator/src/view/nodeEvents.ts
|
|
15830
|
+
/** 正确字段优先;复制触点,避免处理器修改调用者持有的数据。 */
|
|
15831
|
+
function readTouchEventPayload(event) {
|
|
15832
|
+
const changedTouches = event.changedTouches ?? event.changeTouches;
|
|
15833
|
+
return {
|
|
15834
|
+
...event.touches === void 0 ? {} : { touches: event.touches.map((touch) => ({ ...touch })) },
|
|
15835
|
+
...changedTouches === void 0 ? {} : { changedTouches: changedTouches.map((touch) => ({ ...touch })) }
|
|
15836
|
+
};
|
|
15837
|
+
}
|
|
15838
|
+
// ../../mpcore/packages/simulator/src/view/eventBinding.ts
|
|
15839
|
+
function resolveMiniProgramEventBinding(attributes, eventName) {
|
|
15840
|
+
return resolveEventBindingPhases(attributes, eventName, false)?.bubble ?? null;
|
|
15841
|
+
}
|
|
15842
|
+
/** 冒泡时保留原始 target,currentTarget 则属于当前执行绑定的节点。 */
|
|
15843
|
+
function createMiniProgramEventPayload(node, eventName, event, origin = node) {
|
|
15844
|
+
const dataset = collectNodeDataset(node);
|
|
15845
|
+
const nodeId = node.attribs?.id ?? "";
|
|
15846
|
+
const isOrigin = node === origin;
|
|
15847
|
+
return {
|
|
15848
|
+
...readTouchEventPayload(event),
|
|
15849
|
+
bubbles: false,
|
|
15850
|
+
capturePhase: false,
|
|
15851
|
+
composed: false,
|
|
15852
|
+
currentTarget: {
|
|
15853
|
+
dataset: isOrigin ? event.currentTarget?.dataset ?? event.dataset ?? dataset : dataset,
|
|
15854
|
+
id: isOrigin ? event.currentTarget?.id ?? event.id ?? nodeId : nodeId
|
|
15855
|
+
},
|
|
15856
|
+
detail: event.detail,
|
|
15857
|
+
mark: event.mark,
|
|
15858
|
+
target: {
|
|
15859
|
+
dataset: event.target?.dataset ?? event.dataset ?? (isOrigin ? dataset : collectNodeDataset(origin)),
|
|
15860
|
+
id: event.target?.id ?? event.id ?? origin.attribs?.id ?? ""
|
|
15861
|
+
},
|
|
15862
|
+
timeStamp: Date.now(),
|
|
15863
|
+
type: eventName
|
|
15864
|
+
};
|
|
15865
|
+
}
|
|
15866
|
+
// ../../mpcore/packages/simulator/src/view/nativeForm.ts
|
|
15867
|
+
const pickerValues = /* @__PURE__ */ new WeakMap();
|
|
15868
|
+
/** 保存 picker 的原始数组属性,不能从渲染后的逗号字符串反推选项值。 */
|
|
15869
|
+
function setNativePickerValue(node, value) {
|
|
15870
|
+
if (node.name === "picker") pickerValues.set(node, value);
|
|
15871
|
+
}
|
|
15872
|
+
function includesBehavior(definition, name, visited = /* @__PURE__ */ new Set()) {
|
|
15873
|
+
if (visited.has(definition)) return false;
|
|
15874
|
+
visited.add(definition);
|
|
15875
|
+
return Array.isArray(definition.behaviors) && definition.behaviors.some((behavior) => behavior === name || behavior !== null && typeof behavior === "object" && includesBehavior(behavior, name, visited));
|
|
15876
|
+
}
|
|
15877
|
+
function nativeOwner(node) {
|
|
15878
|
+
return getNativeNodeOwner(node) ?? {
|
|
15879
|
+
scopeId: node.attribs?.["data-sim-scope"] ?? null,
|
|
15880
|
+
target: node
|
|
15881
|
+
};
|
|
15882
|
+
}
|
|
15883
|
+
function participatingScopes(formScope, pageScope, resolveComponent) {
|
|
15884
|
+
const scopes = /* @__PURE__ */ new Set([null, pageScope]);
|
|
15885
|
+
let current = formScope;
|
|
15886
|
+
while (current && !scopes.has(current)) {
|
|
15887
|
+
scopes.add(current);
|
|
15888
|
+
current = resolveComponent?.(current)?.ownerScopeId ?? null;
|
|
15889
|
+
}
|
|
15890
|
+
return scopes;
|
|
15891
|
+
}
|
|
15892
|
+
function participates(scopeId, formScopes, behavior, resolveComponent) {
|
|
15893
|
+
const visited = /* @__PURE__ */ new Set();
|
|
15894
|
+
while (!formScopes.has(scopeId)) {
|
|
15895
|
+
if (!scopeId || visited.has(scopeId)) return false;
|
|
15896
|
+
visited.add(scopeId);
|
|
15897
|
+
const component = resolveComponent?.(scopeId);
|
|
15898
|
+
if (!component || !includesBehavior(component.definition, behavior)) return false;
|
|
15899
|
+
scopeId = component.ownerScopeId;
|
|
15900
|
+
}
|
|
15901
|
+
return true;
|
|
15902
|
+
}
|
|
15903
|
+
function checked(attributes, name) {
|
|
15904
|
+
const value = attributes?.[name];
|
|
15905
|
+
return value !== void 0 && value !== "false" && value !== "0";
|
|
15906
|
+
}
|
|
15907
|
+
function choiceValues(group, pageScope, resolveComponent) {
|
|
15908
|
+
const values = [];
|
|
15909
|
+
const scopes = participatingScopes(nativeOwner(group).scopeId, pageScope, resolveComponent);
|
|
15910
|
+
const choice = group.name === "radio-group" ? "radio" : "checkbox";
|
|
15911
|
+
const visit = (node) => {
|
|
15912
|
+
if (node.name === "form" || node.name === "radio-group" || node.name === "checkbox-group") return;
|
|
15913
|
+
if (node.name === choice) {
|
|
15914
|
+
const owner = nativeOwner(node);
|
|
15915
|
+
if (checked(owner.target.attribs, "checked") && participates(owner.scopeId, scopes, "wx://form-field-group", resolveComponent)) values.push(owner.target.attribs?.value ?? "");
|
|
15916
|
+
}
|
|
15917
|
+
for (const child of node.children ?? []) visit(child);
|
|
15918
|
+
};
|
|
15919
|
+
for (const child of group.children ?? []) visit(child);
|
|
15920
|
+
return values;
|
|
15921
|
+
}
|
|
15922
|
+
function collectFormValues(form, scopes, pageScope, resolveComponent) {
|
|
15923
|
+
const values = Object.create(null);
|
|
15924
|
+
const visit = (node) => {
|
|
15925
|
+
if (node.name === "form") return;
|
|
15926
|
+
const owner = nativeOwner(node);
|
|
15927
|
+
const attributes = owner.target.attribs;
|
|
15928
|
+
const name = attributes?.name;
|
|
15929
|
+
if (attributes && name && participates(owner.scopeId, scopes, "wx://form-field-group", resolveComponent)) switch (node.name) {
|
|
15930
|
+
case "input":
|
|
15931
|
+
case "textarea":
|
|
15932
|
+
values[name] = attributes.value ?? "";
|
|
15933
|
+
break;
|
|
15934
|
+
case "switch":
|
|
15935
|
+
values[name] = checked(attributes, "checked");
|
|
15936
|
+
break;
|
|
15937
|
+
case "slider":
|
|
15938
|
+
values[name] = Number(attributes.value ?? 0);
|
|
15939
|
+
break;
|
|
15940
|
+
case "picker": {
|
|
15941
|
+
const mode = attributes.mode ?? "selector";
|
|
15942
|
+
if (mode === "multiSelector" || mode === "region") {
|
|
15943
|
+
const value = pickerValues.get(node);
|
|
15944
|
+
values[name] = Array.isArray(value) ? value.slice() : [];
|
|
15945
|
+
} else values[name] = mode === "selector" ? Number(attributes.value ?? 0) : attributes.value ?? "";
|
|
15946
|
+
break;
|
|
15947
|
+
}
|
|
15948
|
+
case "radio-group":
|
|
15949
|
+
values[name] = choiceValues(node, pageScope, resolveComponent)[0] ?? "";
|
|
15950
|
+
break;
|
|
15951
|
+
case "checkbox-group": values[name] = choiceValues(node, pageScope, resolveComponent);
|
|
15952
|
+
}
|
|
15953
|
+
for (const child of node.children ?? []) visit(child);
|
|
15954
|
+
};
|
|
15955
|
+
for (const child of form.children ?? []) visit(child);
|
|
15956
|
+
return values;
|
|
15957
|
+
}
|
|
15958
|
+
/** 先固定提交目标、字段值和方法所有者,再允许 tap 回调改变组件树。 */
|
|
15959
|
+
function prepareNativeFormSubmit(button, pageScope, event, resolveMethod, resolveComponent) {
|
|
15960
|
+
const owner = nativeOwner(button);
|
|
15961
|
+
if (owner.target.attribs?.["form-type"] !== "submit" || checked(owner.target.attribs, "disabled")) return;
|
|
15962
|
+
let form = button.parent;
|
|
15963
|
+
while (form && form.name !== "form") form = form.parent;
|
|
15964
|
+
if (!form) return;
|
|
15965
|
+
const formOwner = nativeOwner(form);
|
|
15966
|
+
const scopes = participatingScopes(formOwner.scopeId, pageScope, resolveComponent);
|
|
15967
|
+
if (!participates(owner.scopeId, scopes, "wx://form-field-button", resolveComponent)) return;
|
|
15968
|
+
const binding = resolveMiniProgramEventBinding(formOwner.target.attribs, "submit");
|
|
15969
|
+
return {
|
|
15970
|
+
call: binding?.method ? resolveMethod(formOwner.scopeId, binding.method) : void 0,
|
|
15971
|
+
event: createMiniProgramEventPayload(formOwner.target, "submit", {
|
|
15972
|
+
detail: { value: collectFormValues(form, scopes, pageScope, resolveComponent) },
|
|
15973
|
+
mark: event.mark
|
|
15974
|
+
})
|
|
15975
|
+
};
|
|
15976
|
+
}
|
|
14080
15977
|
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode-codepoint.js
|
|
14081
15978
|
/**
|
|
14082
15979
|
* C1 Unicode control character reference replacements (code points 128–159).
|
|
@@ -17827,347 +19724,6 @@ function parseDocument(data, options) {
|
|
|
17827
19724
|
new Parser(handler, options).end(data);
|
|
17828
19725
|
return handler.root;
|
|
17829
19726
|
}
|
|
17830
|
-
// ../../mpcore/packages/simulator/src/view/templateAttributes.ts
|
|
17831
|
-
const valuelessAttributes = /* @__PURE__ */ new WeakMap();
|
|
17832
|
-
var TemplateAttributeHandler = class extends DomHandler {
|
|
17833
|
-
attributeForms = /* @__PURE__ */ new Map();
|
|
17834
|
-
onopentagname() {
|
|
17835
|
-
this.attributeForms.clear();
|
|
17836
|
-
}
|
|
17837
|
-
onattribute(name, _value, quote) {
|
|
17838
|
-
if (!this.attributeForms.has(name)) this.attributeForms.set(name, quote === void 0);
|
|
17839
|
-
}
|
|
17840
|
-
onopentag(name, attributes) {
|
|
17841
|
-
super.onopentag(name, attributes);
|
|
17842
|
-
const names = new Set([...this.attributeForms].filter(([key, valueless]) => valueless && Object.hasOwn(attributes, key)).map(([key]) => key));
|
|
17843
|
-
if (names.size > 0) valuelessAttributes.set(this.tagStack[this.tagStack.length - 1], names);
|
|
17844
|
-
}
|
|
17845
|
-
};
|
|
17846
|
-
/** 保留 parser 的无值属性信息,不把裸属性与显式空字符串混为一谈。 */
|
|
17847
|
-
function parseTemplateAttributeDocument(source) {
|
|
17848
|
-
const handler = new TemplateAttributeHandler(void 0, { xmlMode: true });
|
|
17849
|
-
new Parser(handler, {
|
|
17850
|
-
xmlMode: true,
|
|
17851
|
-
decodeEntities: false,
|
|
17852
|
-
lowerCaseAttributeNames: false,
|
|
17853
|
-
lowerCaseTags: false,
|
|
17854
|
-
recognizeSelfClosing: true
|
|
17855
|
-
}).end(source);
|
|
17856
|
-
return handler.root;
|
|
17857
|
-
}
|
|
17858
|
-
function isValuelessTemplateAttribute(node, name) {
|
|
17859
|
-
return valuelessAttributes.get(node)?.has(name) ?? false;
|
|
17860
|
-
}
|
|
17861
|
-
function copyTemplateAttributeMetadata(source, target) {
|
|
17862
|
-
const attributes = valuelessAttributes.get(source);
|
|
17863
|
-
if (attributes) valuelessAttributes.set(target, attributes);
|
|
17864
|
-
else valuelessAttributes.delete(target);
|
|
17865
|
-
}
|
|
17866
|
-
function decodeAttribute(raw, quote) {
|
|
17867
|
-
const source = raw.replaceAll(`\\${quote}`, quote);
|
|
17868
|
-
let value = "";
|
|
17869
|
-
let offset = 0;
|
|
17870
|
-
for (const range of templateInterpolations(source)) {
|
|
17871
|
-
value += source.slice(offset, range.start).replace(/\\([\s\S])/g, "$1");
|
|
17872
|
-
value += source.slice(range.start, range.end);
|
|
17873
|
-
offset = range.end;
|
|
17874
|
-
}
|
|
17875
|
-
return value + source.slice(offset).replace(/\\([\s\S])/g, "$1");
|
|
17876
|
-
}
|
|
17877
|
-
/** 先保存 WXML 属性词法值,再交给 HTML parser 构建标签树,避免反斜杠引号提前截断属性。 */
|
|
17878
|
-
function maskTemplateAttributes(source) {
|
|
17879
|
-
const attributes = /* @__PURE__ */ new Map();
|
|
17880
|
-
if (!source.includes("\\")) return {
|
|
17881
|
-
source,
|
|
17882
|
-
attributes
|
|
17883
|
-
};
|
|
17884
|
-
let prefix = "__mpcore_quoted_attribute_";
|
|
17885
|
-
while (source.includes(prefix)) prefix += "_";
|
|
17886
|
-
let output = "";
|
|
17887
|
-
let offset = 0;
|
|
17888
|
-
for (let i = 0; i < source.length; i++) {
|
|
17889
|
-
if (source.startsWith("<!--", i)) {
|
|
17890
|
-
const end = source.indexOf("-->", i + 4);
|
|
17891
|
-
i = end < 0 ? source.length : end + 2;
|
|
17892
|
-
continue;
|
|
17893
|
-
}
|
|
17894
|
-
if (source[i] !== "<" || !/[a-z_]/i.test(source[i + 1] ?? "")) continue;
|
|
17895
|
-
for (i++; i < source.length && source[i] !== ">"; i++) {
|
|
17896
|
-
if (source[i] !== "\"" && source[i] !== "'") continue;
|
|
17897
|
-
const quote = source[i];
|
|
17898
|
-
const start = i + 1;
|
|
17899
|
-
for (i++; i < source.length && source[i] !== quote; i++) if (source[i] === "\\") i++;
|
|
17900
|
-
if (i >= source.length) break;
|
|
17901
|
-
const raw = source.slice(start, i);
|
|
17902
|
-
if (!raw.includes("\\")) continue;
|
|
17903
|
-
const token = `${prefix}${attributes.size}`;
|
|
17904
|
-
attributes.set(token, decodeAttribute(raw, quote));
|
|
17905
|
-
output += source.slice(offset, start) + token;
|
|
17906
|
-
offset = i;
|
|
17907
|
-
}
|
|
17908
|
-
}
|
|
17909
|
-
return {
|
|
17910
|
-
source: output + source.slice(offset),
|
|
17911
|
-
attributes
|
|
17912
|
-
};
|
|
17913
|
-
}
|
|
17914
|
-
// ../../mpcore/packages/simulator/src/runtime/componentInstance/selection.ts
|
|
17915
|
-
function hasExportBehavior(definition, visited = /* @__PURE__ */ new Set()) {
|
|
17916
|
-
if (visited.has(definition)) return false;
|
|
17917
|
-
visited.add(definition);
|
|
17918
|
-
return (Array.isArray(definition.behaviors) ? definition.behaviors : []).some((behavior) => behavior === "wx://component-export" || behavior !== null && typeof behavior === "object" && hasExportBehavior(behavior, visited));
|
|
17919
|
-
}
|
|
17920
|
-
/** 原生选择器尊重组件导出行为;测试桥接继续保留完整组件实例。 */
|
|
17921
|
-
function resolveNativeComponentSelection(instance) {
|
|
17922
|
-
if (!instance) return null;
|
|
17923
|
-
const definition = instance.__definition__;
|
|
17924
|
-
if (!definition || !hasExportBehavior(definition) || typeof instance.export !== "function") return instance;
|
|
17925
|
-
return instance.export();
|
|
17926
|
-
}
|
|
17927
|
-
// ../../mpcore/packages/simulator/src/project/plugins.ts
|
|
17928
|
-
const HEADLESS_PLUGIN_VIRTUAL_ROOT = "__plugins__";
|
|
17929
|
-
const PLUGIN_URL_RE = /^plugin:\/\/([^/]+)\/(.+)$/;
|
|
17930
|
-
function createPluginVirtualRoot(alias) {
|
|
17931
|
-
return `${HEADLESS_PLUGIN_VIRTUAL_ROOT}/${alias}`;
|
|
17932
|
-
}
|
|
17933
|
-
function resolvePluginRequest(plugins, request, kind) {
|
|
17934
|
-
const match = PLUGIN_URL_RE.exec(request);
|
|
17935
|
-
if (!match) return;
|
|
17936
|
-
const [, alias, publicName] = match;
|
|
17937
|
-
const plugin = plugins.find((item) => item.alias === alias);
|
|
17938
|
-
const registry = kind === "page" ? plugin?.config.pages : plugin?.config.publicComponents;
|
|
17939
|
-
const resourcePath = registry && typeof registry === "object" && !Array.isArray(registry) ? registry[publicName] : void 0;
|
|
17940
|
-
if (!plugin || typeof resourcePath !== "string" || !resourcePath) return;
|
|
17941
|
-
return {
|
|
17942
|
-
plugin,
|
|
17943
|
-
publicName,
|
|
17944
|
-
resourcePath: `${plugin.virtualRoot}/${resourcePath}`
|
|
17945
|
-
};
|
|
17946
|
-
}
|
|
17947
|
-
function createPluginArtifactSource(fallback, miniprogramRootPath, plugins) {
|
|
17948
|
-
function resolvePhysicalPath(filePath) {
|
|
17949
|
-
const normalizedPath = path.resolve(filePath);
|
|
17950
|
-
for (const plugin of plugins) {
|
|
17951
|
-
const virtualRootPath = path.resolve(miniprogramRootPath, plugin.virtualRoot);
|
|
17952
|
-
const relativePath = path.relative(virtualRootPath, normalizedPath);
|
|
17953
|
-
if (!relativePath.startsWith("..") && !path.isAbsolute(relativePath)) return path.resolve(plugin.rootPath, relativePath);
|
|
17954
|
-
}
|
|
17955
|
-
return normalizedPath;
|
|
17956
|
-
}
|
|
17957
|
-
return {
|
|
17958
|
-
has: (filePath) => fallback.has(resolvePhysicalPath(filePath)),
|
|
17959
|
-
readText: (filePath) => fallback.readText(resolvePhysicalPath(filePath))
|
|
17960
|
-
};
|
|
17961
|
-
}
|
|
17962
|
-
// ../../mpcore/packages/simulator/src/runtime/moduleResolution.ts
|
|
17963
|
-
function resolveMiniProgramModule(importer, request, miniprogramRootPath, hasFile) {
|
|
17964
|
-
function resolveFile(basePath) {
|
|
17965
|
-
return [
|
|
17966
|
-
basePath,
|
|
17967
|
-
`${basePath}.js`,
|
|
17968
|
-
`${basePath}.json`,
|
|
17969
|
-
join(basePath, "index.js")
|
|
17970
|
-
].find(hasFile);
|
|
17971
|
-
}
|
|
17972
|
-
if (request.startsWith(".")) return resolveFile(join(dirname(importer), request));
|
|
17973
|
-
if (request.includes("\\") || request.includes(":") || request.split("/").some((part) => !part || part === "." || part === "..")) return;
|
|
17974
|
-
const root = normalize(miniprogramRootPath);
|
|
17975
|
-
let directory = dirname(importer);
|
|
17976
|
-
while (true) {
|
|
17977
|
-
const relativeDirectory = relative(root, directory);
|
|
17978
|
-
if (relativeDirectory === ".." || relativeDirectory.startsWith("../")) return;
|
|
17979
|
-
const resolved = resolveFile(join(directory, "miniprogram_npm", request));
|
|
17980
|
-
if (resolved) return resolved;
|
|
17981
|
-
if (normalize(directory) === root) return;
|
|
17982
|
-
const parent = dirname(directory);
|
|
17983
|
-
if (parent === directory) return;
|
|
17984
|
-
directory = parent;
|
|
17985
|
-
}
|
|
17986
|
-
}
|
|
17987
|
-
// ../../mpcore/packages/simulator/src/runtime/componentResolution.ts
|
|
17988
|
-
function resolveMiniProgramComponent(ownerFilePath, request, miniprogramRootPath, hasFile) {
|
|
17989
|
-
const localPath = request.startsWith("/") ? request.replace(/^\/+/, "") : join(dirname(ownerFilePath), request);
|
|
17990
|
-
if (request.startsWith("/") || request.startsWith(".") || hasFile(join(miniprogramRootPath, `${localPath}.js`))) return localPath;
|
|
17991
|
-
const npmPath = resolveMiniProgramModule(join(miniprogramRootPath, ownerFilePath), request, miniprogramRootPath, (candidate) => candidate.endsWith(".js") && hasFile(candidate));
|
|
17992
|
-
return npmPath ? relative(miniprogramRootPath, npmPath).slice(0, -3) : localPath;
|
|
17993
|
-
}
|
|
17994
|
-
// ../../mpcore/packages/simulator/src/view/nativeBindings/index.ts
|
|
17995
|
-
const bindings = /* @__PURE__ */ new WeakMap();
|
|
17996
|
-
/** 原生受控属性保留实例归属与求值依赖,序列化值仍由现有 renderer 负责。 */
|
|
17997
|
-
function resolveNativeAttributeValue(node, name, scope, read) {
|
|
17998
|
-
const source = wxsScopeData(scope);
|
|
17999
|
-
if (node.name !== "scroll-view" || name !== "refresher-triggered" || !scope.dataOwner) return read(source);
|
|
18000
|
-
const result = captureTemplateReads(source, scope.dataOwner.data, () => read(source));
|
|
18001
|
-
bindings.set(node, {
|
|
18002
|
-
owner: scope.dataOwner,
|
|
18003
|
-
revision: getNativeDataRevision(scope.dataOwner),
|
|
18004
|
-
paths: result.paths
|
|
18005
|
-
});
|
|
18006
|
-
return result.value;
|
|
18007
|
-
}
|
|
18008
|
-
function getNativeBindingCommit(node, previous) {
|
|
18009
|
-
const binding = bindings.get(node);
|
|
18010
|
-
if (!binding) return {
|
|
18011
|
-
explicit: false,
|
|
18012
|
-
consumed: previous
|
|
18013
|
-
};
|
|
18014
|
-
const after = previous?.owner === binding.owner ? previous.revision : binding.revision;
|
|
18015
|
-
return {
|
|
18016
|
-
explicit: hasNativeDataCommit(binding.owner, binding.paths, after, binding.revision),
|
|
18017
|
-
consumed: {
|
|
18018
|
-
owner: binding.owner,
|
|
18019
|
-
revision: binding.revision
|
|
18020
|
-
}
|
|
18021
|
-
};
|
|
18022
|
-
}
|
|
18023
|
-
// ../../mpcore/packages/simulator/src/view/nodeEvents.ts
|
|
18024
|
-
/** 正确字段优先;复制触点,避免处理器修改调用者持有的数据。 */
|
|
18025
|
-
function readTouchEventPayload(event) {
|
|
18026
|
-
const changedTouches = event.changedTouches ?? event.changeTouches;
|
|
18027
|
-
return {
|
|
18028
|
-
...event.touches === void 0 ? {} : { touches: event.touches.map((touch) => ({ ...touch })) },
|
|
18029
|
-
...changedTouches === void 0 ? {} : { changedTouches: changedTouches.map((touch) => ({ ...touch })) }
|
|
18030
|
-
};
|
|
18031
|
-
}
|
|
18032
|
-
// ../../mpcore/packages/simulator/src/view/eventBinding.ts
|
|
18033
|
-
function resolveMiniProgramEventBinding(attributes, eventName) {
|
|
18034
|
-
return resolveEventBindingPhases(attributes, eventName, false)?.bubble ?? null;
|
|
18035
|
-
}
|
|
18036
|
-
/** 冒泡时保留原始 target,currentTarget 则属于当前执行绑定的节点。 */
|
|
18037
|
-
function createMiniProgramEventPayload(node, eventName, event, origin = node) {
|
|
18038
|
-
const dataset = collectNodeDataset(node);
|
|
18039
|
-
const nodeId = node.attribs?.id ?? "";
|
|
18040
|
-
const isOrigin = node === origin;
|
|
18041
|
-
return {
|
|
18042
|
-
...readTouchEventPayload(event),
|
|
18043
|
-
bubbles: false,
|
|
18044
|
-
capturePhase: false,
|
|
18045
|
-
composed: false,
|
|
18046
|
-
currentTarget: {
|
|
18047
|
-
dataset: isOrigin ? event.currentTarget?.dataset ?? event.dataset ?? dataset : dataset,
|
|
18048
|
-
id: isOrigin ? event.currentTarget?.id ?? event.id ?? nodeId : nodeId
|
|
18049
|
-
},
|
|
18050
|
-
detail: event.detail,
|
|
18051
|
-
mark: event.mark,
|
|
18052
|
-
target: {
|
|
18053
|
-
dataset: event.target?.dataset ?? event.dataset ?? (isOrigin ? dataset : collectNodeDataset(origin)),
|
|
18054
|
-
id: event.target?.id ?? event.id ?? origin.attribs?.id ?? ""
|
|
18055
|
-
},
|
|
18056
|
-
timeStamp: Date.now(),
|
|
18057
|
-
type: eventName
|
|
18058
|
-
};
|
|
18059
|
-
}
|
|
18060
|
-
// ../../mpcore/packages/simulator/src/view/nativeForm.ts
|
|
18061
|
-
const pickerValues = /* @__PURE__ */ new WeakMap();
|
|
18062
|
-
/** 保存 picker 的原始数组属性,不能从渲染后的逗号字符串反推选项值。 */
|
|
18063
|
-
function setNativePickerValue(node, value) {
|
|
18064
|
-
if (node.name === "picker") pickerValues.set(node, value);
|
|
18065
|
-
}
|
|
18066
|
-
function includesBehavior(definition, name, visited = /* @__PURE__ */ new Set()) {
|
|
18067
|
-
if (visited.has(definition)) return false;
|
|
18068
|
-
visited.add(definition);
|
|
18069
|
-
return Array.isArray(definition.behaviors) && definition.behaviors.some((behavior) => behavior === name || behavior !== null && typeof behavior === "object" && includesBehavior(behavior, name, visited));
|
|
18070
|
-
}
|
|
18071
|
-
function nativeOwner(node) {
|
|
18072
|
-
return getNativeNodeOwner(node) ?? {
|
|
18073
|
-
scopeId: node.attribs?.["data-sim-scope"] ?? null,
|
|
18074
|
-
target: node
|
|
18075
|
-
};
|
|
18076
|
-
}
|
|
18077
|
-
function participatingScopes(formScope, pageScope, resolveComponent) {
|
|
18078
|
-
const scopes = /* @__PURE__ */ new Set([null, pageScope]);
|
|
18079
|
-
let current = formScope;
|
|
18080
|
-
while (current && !scopes.has(current)) {
|
|
18081
|
-
scopes.add(current);
|
|
18082
|
-
current = resolveComponent?.(current)?.ownerScopeId ?? null;
|
|
18083
|
-
}
|
|
18084
|
-
return scopes;
|
|
18085
|
-
}
|
|
18086
|
-
function participates(scopeId, formScopes, behavior, resolveComponent) {
|
|
18087
|
-
const visited = /* @__PURE__ */ new Set();
|
|
18088
|
-
while (!formScopes.has(scopeId)) {
|
|
18089
|
-
if (!scopeId || visited.has(scopeId)) return false;
|
|
18090
|
-
visited.add(scopeId);
|
|
18091
|
-
const component = resolveComponent?.(scopeId);
|
|
18092
|
-
if (!component || !includesBehavior(component.definition, behavior)) return false;
|
|
18093
|
-
scopeId = component.ownerScopeId;
|
|
18094
|
-
}
|
|
18095
|
-
return true;
|
|
18096
|
-
}
|
|
18097
|
-
function checked(attributes, name) {
|
|
18098
|
-
const value = attributes?.[name];
|
|
18099
|
-
return value !== void 0 && value !== "false" && value !== "0";
|
|
18100
|
-
}
|
|
18101
|
-
function choiceValues(group, pageScope, resolveComponent) {
|
|
18102
|
-
const values = [];
|
|
18103
|
-
const scopes = participatingScopes(nativeOwner(group).scopeId, pageScope, resolveComponent);
|
|
18104
|
-
const choice = group.name === "radio-group" ? "radio" : "checkbox";
|
|
18105
|
-
const visit = (node) => {
|
|
18106
|
-
if (node.name === "form" || node.name === "radio-group" || node.name === "checkbox-group") return;
|
|
18107
|
-
if (node.name === choice) {
|
|
18108
|
-
const owner = nativeOwner(node);
|
|
18109
|
-
if (checked(owner.target.attribs, "checked") && participates(owner.scopeId, scopes, "wx://form-field-group", resolveComponent)) values.push(owner.target.attribs?.value ?? "");
|
|
18110
|
-
}
|
|
18111
|
-
for (const child of node.children ?? []) visit(child);
|
|
18112
|
-
};
|
|
18113
|
-
for (const child of group.children ?? []) visit(child);
|
|
18114
|
-
return values;
|
|
18115
|
-
}
|
|
18116
|
-
function collectFormValues(form, scopes, pageScope, resolveComponent) {
|
|
18117
|
-
const values = Object.create(null);
|
|
18118
|
-
const visit = (node) => {
|
|
18119
|
-
if (node.name === "form") return;
|
|
18120
|
-
const owner = nativeOwner(node);
|
|
18121
|
-
const attributes = owner.target.attribs;
|
|
18122
|
-
const name = attributes?.name;
|
|
18123
|
-
if (attributes && name && participates(owner.scopeId, scopes, "wx://form-field-group", resolveComponent)) switch (node.name) {
|
|
18124
|
-
case "input":
|
|
18125
|
-
case "textarea":
|
|
18126
|
-
values[name] = attributes.value ?? "";
|
|
18127
|
-
break;
|
|
18128
|
-
case "switch":
|
|
18129
|
-
values[name] = checked(attributes, "checked");
|
|
18130
|
-
break;
|
|
18131
|
-
case "slider":
|
|
18132
|
-
values[name] = Number(attributes.value ?? 0);
|
|
18133
|
-
break;
|
|
18134
|
-
case "picker": {
|
|
18135
|
-
const mode = attributes.mode ?? "selector";
|
|
18136
|
-
if (mode === "multiSelector" || mode === "region") {
|
|
18137
|
-
const value = pickerValues.get(node);
|
|
18138
|
-
values[name] = Array.isArray(value) ? value.slice() : [];
|
|
18139
|
-
} else values[name] = mode === "selector" ? Number(attributes.value ?? 0) : attributes.value ?? "";
|
|
18140
|
-
break;
|
|
18141
|
-
}
|
|
18142
|
-
case "radio-group":
|
|
18143
|
-
values[name] = choiceValues(node, pageScope, resolveComponent)[0] ?? "";
|
|
18144
|
-
break;
|
|
18145
|
-
case "checkbox-group": values[name] = choiceValues(node, pageScope, resolveComponent);
|
|
18146
|
-
}
|
|
18147
|
-
for (const child of node.children ?? []) visit(child);
|
|
18148
|
-
};
|
|
18149
|
-
for (const child of form.children ?? []) visit(child);
|
|
18150
|
-
return values;
|
|
18151
|
-
}
|
|
18152
|
-
/** 先固定提交目标、字段值和方法所有者,再允许 tap 回调改变组件树。 */
|
|
18153
|
-
function prepareNativeFormSubmit(button, pageScope, event, resolveMethod, resolveComponent) {
|
|
18154
|
-
const owner = nativeOwner(button);
|
|
18155
|
-
if (owner.target.attribs?.["form-type"] !== "submit" || checked(owner.target.attribs, "disabled")) return;
|
|
18156
|
-
let form = button.parent;
|
|
18157
|
-
while (form && form.name !== "form") form = form.parent;
|
|
18158
|
-
if (!form) return;
|
|
18159
|
-
const formOwner = nativeOwner(form);
|
|
18160
|
-
const scopes = participatingScopes(formOwner.scopeId, pageScope, resolveComponent);
|
|
18161
|
-
if (!participates(owner.scopeId, scopes, "wx://form-field-button", resolveComponent)) return;
|
|
18162
|
-
const binding = resolveMiniProgramEventBinding(formOwner.target.attribs, "submit");
|
|
18163
|
-
return {
|
|
18164
|
-
call: binding?.method ? resolveMethod(formOwner.scopeId, binding.method) : void 0,
|
|
18165
|
-
event: createMiniProgramEventPayload(formOwner.target, "submit", {
|
|
18166
|
-
detail: { value: collectFormValues(form, scopes, pageScope, resolveComponent) },
|
|
18167
|
-
mark: event.mark
|
|
18168
|
-
})
|
|
18169
|
-
};
|
|
18170
|
-
}
|
|
18171
19727
|
// ../../@weapp-core/shared/dist/rich-text.js
|
|
18172
19728
|
const ALLOWED_TAGS = /* @__PURE__ */ new Set([
|
|
18173
19729
|
"a",
|
|
@@ -18502,30 +20058,8 @@ function interpolateTemplateText(input, data, emptyNull = false) {
|
|
|
18502
20058
|
return output + input.slice(offset);
|
|
18503
20059
|
}
|
|
18504
20060
|
// ../../mpcore/packages/simulator/src/view/wxsDocument.ts
|
|
18505
|
-
const INLINE_WXS_RE = /<wxs\b([^>]*)(?<!\/)>([\s\S]*?)<\/wxs\s*>/g;
|
|
18506
20061
|
function parseWxsTemplateDocument(templateSource) {
|
|
18507
|
-
|
|
18508
|
-
const source = templateSource.replace(INLINE_WXS_RE, (_match, attributes, script) => {
|
|
18509
|
-
return `<wxs data-sim-wxs="${scripts.push(script) - 1}"${attributes}>wxs-source</wxs>`;
|
|
18510
|
-
});
|
|
18511
|
-
const masked = maskTemplateAttributes(source);
|
|
18512
|
-
const document = parseTemplateAttributeDocument(`<page>${masked.source}</page>`);
|
|
18513
|
-
if (!scripts.length && !masked.attributes.size && !/(?:^|>)[\t\r\n ]+(?:<|$)/.test(source)) return document;
|
|
18514
|
-
const hasAttributes = masked.attributes.size > 0;
|
|
18515
|
-
const restore = (node) => {
|
|
18516
|
-
if (hasAttributes && node.attribs) {
|
|
18517
|
-
for (const [name, token] of Object.entries(node.attribs)) if (masked.attributes.has(token)) node.attribs[name] = masked.attributes.get(token);
|
|
18518
|
-
}
|
|
18519
|
-
if (node.name === "wxs" && Object.hasOwn(node.attribs ?? {}, "data-sim-wxs")) {
|
|
18520
|
-
node.children[0].data = scripts[Number(node.attribs["data-sim-wxs"])];
|
|
18521
|
-
delete node.attribs["data-sim-wxs"];
|
|
18522
|
-
return;
|
|
18523
|
-
}
|
|
18524
|
-
if (node.children) node.children = node.children.filter((child) => child.type !== "text" || !/^[\t\r\n ]+$/.test(child.data ?? ""));
|
|
18525
|
-
for (const child of node.children ?? []) restore(child);
|
|
18526
|
-
};
|
|
18527
|
-
restore(document);
|
|
18528
|
-
return document;
|
|
20062
|
+
return parseSharedWxsDocument(templateSource);
|
|
18529
20063
|
}
|
|
18530
20064
|
// ../../mpcore/packages/simulator/src/runtime/render/shared.ts
|
|
18531
20065
|
const LEADING_SLASH_RE$4 = /^\/+/;
|
|
@@ -19671,6 +21205,7 @@ function createHeadlessWx(driver, runtimeConsole = console, workers) {
|
|
|
19671
21205
|
};
|
|
19672
21206
|
return {
|
|
19673
21207
|
...eventBus,
|
|
21208
|
+
env: { USER_DATA_PATH: "headless://wxfile/user" },
|
|
19674
21209
|
[WEVU_ROUTE_EVENT_CONTRACT_KEY]: 1,
|
|
19675
21210
|
[WEVU_PAGE_SCROLL_EVENT_CONTRACT_KEY]: 1,
|
|
19676
21211
|
arrayBufferToBase64,
|
|
@@ -19917,6 +21452,14 @@ function invokePreparedNavigationApi(prepare, option) {
|
|
|
19917
21452
|
option?.complete?.();
|
|
19918
21453
|
}
|
|
19919
21454
|
}
|
|
21455
|
+
// ../../mpcore/packages/simulator/src/kernel/artifactContent.ts
|
|
21456
|
+
/** 二进制产物与虚拟文件共享字节转换,读写边界均复制以隔离调用方修改。 */
|
|
21457
|
+
function copyArtifactBinary(content) {
|
|
21458
|
+
return typeof content === "string" ? new TextEncoder().encode(content).buffer : new Uint8Array(content).slice().buffer;
|
|
21459
|
+
}
|
|
21460
|
+
function readArtifactText(content) {
|
|
21461
|
+
return typeof content === "string" ? content : new TextDecoder().decode(content);
|
|
21462
|
+
}
|
|
19920
21463
|
// ../../mpcore/packages/simulator/src/kernel/artifactSource.ts
|
|
19921
21464
|
function createFileSystemArtifactSource() {
|
|
19922
21465
|
return {
|
|
@@ -19933,6 +21476,13 @@ function createFileSystemArtifactSource() {
|
|
|
19933
21476
|
} catch {
|
|
19934
21477
|
return;
|
|
19935
21478
|
}
|
|
21479
|
+
},
|
|
21480
|
+
readBinary(filePath) {
|
|
21481
|
+
try {
|
|
21482
|
+
return new Uint8Array(fs.readFileSync(filePath)).buffer;
|
|
21483
|
+
} catch {
|
|
21484
|
+
return;
|
|
21485
|
+
}
|
|
19936
21486
|
}
|
|
19937
21487
|
};
|
|
19938
21488
|
}
|
|
@@ -41703,6 +43253,41 @@ function transformMiniProgramModule(source) {
|
|
|
41703
43253
|
}
|
|
41704
43254
|
return `(function(${moduleName}, ${requireName}, ${objectName}) {\n"use strict";\n${declarations.join("\n")}\n${applySourceEdits(source, edits)}\n${objectName}.preventExtensions(${moduleName}.exports);\n}).call(undefined, module, require, Object);`;
|
|
41705
43255
|
}
|
|
43256
|
+
// ../../mpcore/packages/simulator/src/runtime/packageAsset.ts
|
|
43257
|
+
const assetExtension = /\.(?:png|jpe?g|gif|svg|cer|mp3|aac|m4a|mp4|wav|ogg|silk|wasm|br|cur|ico|skel|crt|cert|gltf|glb|bin|ktx|hdr|exr|xnet|pem)$/i;
|
|
43258
|
+
/** 包内静态资源只读且每次访问宿主当前产物,不缓存为用户文件,也不允许越过包根目录。 */
|
|
43259
|
+
function createPackageAssetReader(read) {
|
|
43260
|
+
return (filePath) => {
|
|
43261
|
+
if (filePath.includes("\\") || filePath.includes(":") || filePath.includes("\0")) return;
|
|
43262
|
+
const relative = posix.normalize(filePath.replace(/^\/+/, ""));
|
|
43263
|
+
if (relative === ".." || relative.startsWith("../") || !assetExtension.test(relative)) return;
|
|
43264
|
+
return read(relative);
|
|
43265
|
+
};
|
|
43266
|
+
}
|
|
43267
|
+
// ../../mpcore/packages/simulator/src/runtime/packageWebAssembly.ts
|
|
43268
|
+
/** 使用宿主真实 WASM 引擎执行代码包路径,不向小程序暴露宿主文件系统。 */
|
|
43269
|
+
function createPackageWebAssembly(readBinary) {
|
|
43270
|
+
const native = globalThis.WebAssembly;
|
|
43271
|
+
const read = createPackageAssetReader(readBinary);
|
|
43272
|
+
return {
|
|
43273
|
+
Module: native.Module,
|
|
43274
|
+
Instance: native.Instance,
|
|
43275
|
+
Memory: native.Memory,
|
|
43276
|
+
Table: native.Table,
|
|
43277
|
+
Global: native.Global,
|
|
43278
|
+
CompileError: native.CompileError,
|
|
43279
|
+
LinkError: native.LinkError,
|
|
43280
|
+
RuntimeError: native.RuntimeError,
|
|
43281
|
+
compile: native.compile.bind(native),
|
|
43282
|
+
validate: native.validate.bind(native),
|
|
43283
|
+
async instantiate(source, imports) {
|
|
43284
|
+
if (typeof source !== "string") return native.instantiate(source, imports);
|
|
43285
|
+
const binary = read(source);
|
|
43286
|
+
if (!binary) throw new Error(`WXWebAssembly.instantiate:fail package file not found: ${source}`);
|
|
43287
|
+
return native.instantiate(binary, imports);
|
|
43288
|
+
}
|
|
43289
|
+
};
|
|
43290
|
+
}
|
|
41706
43291
|
// ../../mpcore/packages/simulator/src/runtime/pageDefinitionReload.ts
|
|
41707
43292
|
/** 定义更新只解析已有路由,不触发普通导航的启动或 page-not-found 生命周期。 */
|
|
41708
43293
|
function resolvePageDefinitionReloadRoute(project, route) {
|
|
@@ -41758,6 +43343,7 @@ const MINI_PROGRAM_UNAVAILABLE_GLOBAL_NAMES = [
|
|
|
41758
43343
|
"AbortSignal",
|
|
41759
43344
|
"XMLHttpRequest",
|
|
41760
43345
|
"WebSocket",
|
|
43346
|
+
"WebAssembly",
|
|
41761
43347
|
"URLSearchParams",
|
|
41762
43348
|
"Blob",
|
|
41763
43349
|
"File",
|
|
@@ -41832,7 +43418,10 @@ function createModuleLoader(registries, getCurrentPages, getApp, wxDriver, optio
|
|
|
41832
43418
|
}
|
|
41833
43419
|
});
|
|
41834
43420
|
const moduleCache = /* @__PURE__ */ new Map();
|
|
41835
|
-
const executionContext = createExecutionContext(registries, getCurrentPages, getApp, wxDriver, options.kernel,
|
|
43421
|
+
const executionContext = createExecutionContext(registries, getCurrentPages, getApp, wxDriver, options.kernel, {
|
|
43422
|
+
WXWebAssembly: createPackageWebAssembly((file) => options.artifactSource.readBinary?.(path.join(options.miniprogramRootPath, file))),
|
|
43423
|
+
...options.globals
|
|
43424
|
+
}, options.onConsole, workers.apis);
|
|
41836
43425
|
executionContext.globalThis = executionContext;
|
|
41837
43426
|
function executeModule(filePath, loadContext) {
|
|
41838
43427
|
const resolvedPath = path.resolve(filePath);
|
|
@@ -41935,17 +43524,6 @@ function createModuleLoader(registries, getCurrentPages, getApp, wxDriver, optio
|
|
|
41935
43524
|
};
|
|
41936
43525
|
return loader;
|
|
41937
43526
|
}
|
|
41938
|
-
// ../../mpcore/packages/simulator/src/runtime/packageAsset.ts
|
|
41939
|
-
const assetExtension = /\.(?:png|jpe?g|gif|svg|cer|mp3|aac|m4a|mp4|wav|ogg|silk|wasm|br|cur|ico|skel|crt|cert|gltf|glb|bin|ktx|hdr|exr|xnet|pem)$/i;
|
|
41940
|
-
/** 包内静态资源只读且每次访问宿主当前产物,不缓存为用户文件,也不允许越过包根目录。 */
|
|
41941
|
-
function createPackageAssetReader(read) {
|
|
41942
|
-
return (filePath) => {
|
|
41943
|
-
if (filePath.includes("\\") || filePath.includes(":") || filePath.includes("\0")) return;
|
|
41944
|
-
const relative = posix.normalize(filePath.replace(/^\/+/, ""));
|
|
41945
|
-
if (relative === ".." || relative.startsWith("../") || !assetExtension.test(relative)) return;
|
|
41946
|
-
return read(relative);
|
|
41947
|
-
};
|
|
41948
|
-
}
|
|
41949
43527
|
// ../../mpcore/packages/simulator/src/runtime/routeEvents.ts
|
|
41950
43528
|
/** 两种模拟器共用路由身份与监听状态,完成事件由页面就绪和宿主提交驱动。 */
|
|
41951
43529
|
var HeadlessRouteEvents = class {
|
|
@@ -42253,6 +43831,23 @@ function createHeadlessAccountState(scheduler, options) {
|
|
|
42253
43831
|
}
|
|
42254
43832
|
};
|
|
42255
43833
|
}
|
|
43834
|
+
// ../../mpcore/packages/simulator/src/runtime/fileSystemCallbacks.ts
|
|
43835
|
+
/** 文件系统失败保留 Error 兼容性,并向 fail/complete 提供微信 errMsg 契约。 */
|
|
43836
|
+
function runFileSystemOperation(operation, option) {
|
|
43837
|
+
let result;
|
|
43838
|
+
try {
|
|
43839
|
+
result = operation();
|
|
43840
|
+
} catch (cause) {
|
|
43841
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
43842
|
+
const failure = Object.assign(error, { errMsg: error.message });
|
|
43843
|
+
option.fail?.(failure);
|
|
43844
|
+
option.complete?.(failure);
|
|
43845
|
+
return;
|
|
43846
|
+
}
|
|
43847
|
+
option.success?.(result);
|
|
43848
|
+
option.complete?.(result);
|
|
43849
|
+
return result;
|
|
43850
|
+
}
|
|
42256
43851
|
// ../../mpcore/packages/simulator/src/runtime/request/task.ts
|
|
42257
43852
|
/** mock 与显式网络桥接共用终止状态;终止后不再分发 headers/chunk。 */
|
|
42258
43853
|
function createRequestTask(option, onAbort = () => {}) {
|
|
@@ -42384,8 +43979,11 @@ const VIDEO_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
42384
43979
|
"mpg",
|
|
42385
43980
|
"webm"
|
|
42386
43981
|
]);
|
|
43982
|
+
function fileBytes(input) {
|
|
43983
|
+
return typeof input === "string" ? textEncoder.encode(input) : new Uint8Array(input);
|
|
43984
|
+
}
|
|
42387
43985
|
function byteLength(input) {
|
|
42388
|
-
return
|
|
43986
|
+
return fileBytes(input).byteLength;
|
|
42389
43987
|
}
|
|
42390
43988
|
function rotateLeft(value, bits) {
|
|
42391
43989
|
return (value << bits | value >>> 32 - bits) >>> 0;
|
|
@@ -42399,7 +43997,7 @@ function toHexWordBigEndian(value) {
|
|
|
42399
43997
|
return value.toString(16).padStart(8, "0");
|
|
42400
43998
|
}
|
|
42401
43999
|
function computeMd5Digest(input) {
|
|
42402
|
-
const bytes = Array.from(
|
|
44000
|
+
const bytes = Array.from(fileBytes(input));
|
|
42403
44001
|
const bitLength = bytes.length * 8;
|
|
42404
44002
|
const lowBits = bitLength >>> 0;
|
|
42405
44003
|
const highBits = Math.floor(bitLength / 4294967296) >>> 0;
|
|
@@ -42522,7 +44120,7 @@ function computeMd5Digest(input) {
|
|
|
42522
44120
|
].join("");
|
|
42523
44121
|
}
|
|
42524
44122
|
function computeSha1Digest(input) {
|
|
42525
|
-
const bytes = Array.from(
|
|
44123
|
+
const bytes = Array.from(fileBytes(input));
|
|
42526
44124
|
const bitLength = bytes.length * 8;
|
|
42527
44125
|
const lowBits = bitLength >>> 0;
|
|
42528
44126
|
const highBits = Math.floor(bitLength / 4294967296) >>> 0;
|
|
@@ -42907,14 +44505,14 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
42907
44505
|
if (!savedFile) return;
|
|
42908
44506
|
savedFiles.set(normalizedPath, {
|
|
42909
44507
|
...savedFile,
|
|
42910
|
-
size: fileContent
|
|
44508
|
+
size: byteLength(fileContent)
|
|
42911
44509
|
});
|
|
42912
44510
|
};
|
|
42913
44511
|
const setSavedFileMetadata = (normalizedPath, fileContent, createTime = Date.now()) => {
|
|
42914
44512
|
savedFiles.set(normalizedPath, {
|
|
42915
44513
|
createTime,
|
|
42916
44514
|
filePath: normalizedPath,
|
|
42917
|
-
size: fileContent
|
|
44515
|
+
size: byteLength(fileContent)
|
|
42918
44516
|
});
|
|
42919
44517
|
};
|
|
42920
44518
|
const accessFile = (filePath) => {
|
|
@@ -42928,7 +44526,7 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
42928
44526
|
const fileContent = files.get(normalizedPath) ?? options.readPackageFile?.(normalizedPath);
|
|
42929
44527
|
if (fileContent == null) throw new Error(`readFile:fail no such file or directory, open '${normalizedPath}'`);
|
|
42930
44528
|
return {
|
|
42931
|
-
data: fileContent,
|
|
44529
|
+
data: encoding ? readArtifactText(fileContent) : copyArtifactBinary(fileContent),
|
|
42932
44530
|
errMsg: "readFile:ok"
|
|
42933
44531
|
};
|
|
42934
44532
|
};
|
|
@@ -42936,7 +44534,7 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
42936
44534
|
const normalizedPath = normalizeFsPath(filePath);
|
|
42937
44535
|
normalizeEncoding(encoding);
|
|
42938
44536
|
ensureDirectoryTree(normalizedPath);
|
|
42939
|
-
const fileContent =
|
|
44537
|
+
const fileContent = typeof data === "string" ? data : copyArtifactBinary(data);
|
|
42940
44538
|
files.set(normalizedPath, fileContent);
|
|
42941
44539
|
updateSavedFileMetadata(normalizedPath, fileContent);
|
|
42942
44540
|
return { errMsg: "writeFile:ok" };
|
|
@@ -42945,7 +44543,12 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
42945
44543
|
const normalizedPath = normalizeFsPath(filePath);
|
|
42946
44544
|
normalizeEncoding(encoding);
|
|
42947
44545
|
ensureDirectoryTree(normalizedPath);
|
|
42948
|
-
const
|
|
44546
|
+
const currentBytes = fileBytes(files.get(normalizedPath) ?? "");
|
|
44547
|
+
const appendedBytes = fileBytes(data);
|
|
44548
|
+
const nextBytes = new Uint8Array(currentBytes.length + appendedBytes.length);
|
|
44549
|
+
nextBytes.set(currentBytes);
|
|
44550
|
+
nextBytes.set(appendedBytes, currentBytes.length);
|
|
44551
|
+
const nextFileContent = nextBytes.buffer;
|
|
42949
44552
|
files.set(normalizedPath, nextFileContent);
|
|
42950
44553
|
updateSavedFileMetadata(normalizedPath, nextFileContent);
|
|
42951
44554
|
return { errMsg: "appendFile:ok" };
|
|
@@ -42973,12 +44576,12 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
42973
44576
|
files.set(normalizedNewPath, fileContent);
|
|
42974
44577
|
if (targetSavedFile) savedFiles.set(normalizedNewPath, {
|
|
42975
44578
|
...targetSavedFile,
|
|
42976
|
-
size: fileContent
|
|
44579
|
+
size: byteLength(fileContent)
|
|
42977
44580
|
});
|
|
42978
44581
|
else if (savedFile && isSavedFilePath(normalizedNewPath)) savedFiles.set(normalizedNewPath, {
|
|
42979
44582
|
...savedFile,
|
|
42980
44583
|
filePath: normalizedNewPath,
|
|
42981
|
-
size: fileContent
|
|
44584
|
+
size: byteLength(fileContent)
|
|
42982
44585
|
});
|
|
42983
44586
|
return { errMsg: "rename:ok" };
|
|
42984
44587
|
};
|
|
@@ -43041,7 +44644,7 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
43041
44644
|
const normalizedPath = normalizeFsPath(inputPath);
|
|
43042
44645
|
if (files.has(normalizedPath)) return {
|
|
43043
44646
|
errMsg: "stat:ok",
|
|
43044
|
-
stats: createStats(false, files.get(normalizedPath)
|
|
44647
|
+
stats: createStats(false, byteLength(files.get(normalizedPath)))
|
|
43045
44648
|
};
|
|
43046
44649
|
if (directories.has(normalizedPath)) return {
|
|
43047
44650
|
errMsg: "stat:ok",
|
|
@@ -43082,168 +44685,70 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
43082
44685
|
files.delete(normalizedPath);
|
|
43083
44686
|
return { errMsg: "removeSavedFile:ok" };
|
|
43084
44687
|
};
|
|
44688
|
+
function readFileSync(filePath, encoding) {
|
|
44689
|
+
return readFile(filePath, encoding).data;
|
|
44690
|
+
}
|
|
43085
44691
|
const fileSystemManager = {
|
|
43086
44692
|
access(option) {
|
|
43087
|
-
|
|
43088
|
-
const result = accessFile(option.path);
|
|
43089
|
-
option.success?.(result);
|
|
43090
|
-
option.complete?.(result);
|
|
43091
|
-
return result;
|
|
43092
|
-
} catch (error) {
|
|
43093
|
-
option.fail?.(error);
|
|
43094
|
-
option.complete?.();
|
|
43095
|
-
return;
|
|
43096
|
-
}
|
|
44693
|
+
return runFileSystemOperation(() => accessFile(option.path), option);
|
|
43097
44694
|
},
|
|
43098
44695
|
accessSync(path) {
|
|
43099
44696
|
accessFile(path);
|
|
43100
44697
|
},
|
|
43101
44698
|
appendFile(option) {
|
|
43102
|
-
|
|
43103
|
-
const result = appendFile(option.filePath, option.data, option.encoding);
|
|
43104
|
-
option.success?.(result);
|
|
43105
|
-
option.complete?.(result);
|
|
43106
|
-
return result;
|
|
43107
|
-
} catch (error) {
|
|
43108
|
-
option.fail?.(error);
|
|
43109
|
-
option.complete?.();
|
|
43110
|
-
return;
|
|
43111
|
-
}
|
|
44699
|
+
return runFileSystemOperation(() => appendFile(option.filePath, option.data, option.encoding), option);
|
|
43112
44700
|
},
|
|
43113
44701
|
appendFileSync(filePath, data, encoding) {
|
|
43114
44702
|
appendFile(filePath, data, encoding);
|
|
43115
44703
|
},
|
|
43116
44704
|
copyFile(option) {
|
|
43117
|
-
|
|
43118
|
-
const result = copyFile(option.srcPath, option.destPath);
|
|
43119
|
-
option.success?.(result);
|
|
43120
|
-
option.complete?.(result);
|
|
43121
|
-
return result;
|
|
43122
|
-
} catch (error) {
|
|
43123
|
-
option.fail?.(error);
|
|
43124
|
-
option.complete?.();
|
|
43125
|
-
return;
|
|
43126
|
-
}
|
|
44705
|
+
return runFileSystemOperation(() => copyFile(option.srcPath, option.destPath), option);
|
|
43127
44706
|
},
|
|
43128
44707
|
copyFileSync(srcPath, destPath) {
|
|
43129
44708
|
copyFile(srcPath, destPath);
|
|
43130
44709
|
},
|
|
43131
44710
|
mkdir(option) {
|
|
43132
|
-
|
|
43133
|
-
const result = mkdir(option.dirPath, option.recursive);
|
|
43134
|
-
option.success?.(result);
|
|
43135
|
-
option.complete?.(result);
|
|
43136
|
-
return result;
|
|
43137
|
-
} catch (error) {
|
|
43138
|
-
option.fail?.(error);
|
|
43139
|
-
option.complete?.();
|
|
43140
|
-
return;
|
|
43141
|
-
}
|
|
44711
|
+
return runFileSystemOperation(() => mkdir(option.dirPath, option.recursive), option);
|
|
43142
44712
|
},
|
|
43143
44713
|
mkdirSync(dirPath, recursive) {
|
|
43144
44714
|
mkdir(dirPath, recursive);
|
|
43145
44715
|
},
|
|
43146
44716
|
readFile(option) {
|
|
43147
|
-
|
|
43148
|
-
const result = readFile(option.filePath, option.encoding);
|
|
43149
|
-
option.success?.(result);
|
|
43150
|
-
option.complete?.(result);
|
|
43151
|
-
return result;
|
|
43152
|
-
} catch (error) {
|
|
43153
|
-
option.fail?.(error);
|
|
43154
|
-
option.complete?.();
|
|
43155
|
-
return;
|
|
43156
|
-
}
|
|
43157
|
-
},
|
|
43158
|
-
readFileSync(filePath, encoding) {
|
|
43159
|
-
return readFile(filePath, encoding).data;
|
|
44717
|
+
return runFileSystemOperation(() => readFile(option.filePath, option.encoding), option);
|
|
43160
44718
|
},
|
|
44719
|
+
readFileSync,
|
|
43161
44720
|
readdir(option) {
|
|
43162
|
-
|
|
43163
|
-
const result = readdir(option.dirPath);
|
|
43164
|
-
option.success?.(result);
|
|
43165
|
-
option.complete?.(result);
|
|
43166
|
-
return result;
|
|
43167
|
-
} catch (error) {
|
|
43168
|
-
option.fail?.(error);
|
|
43169
|
-
option.complete?.();
|
|
43170
|
-
return;
|
|
43171
|
-
}
|
|
44721
|
+
return runFileSystemOperation(() => readdir(option.dirPath), option);
|
|
43172
44722
|
},
|
|
43173
44723
|
readdirSync(dirPath) {
|
|
43174
44724
|
return readdir(dirPath).files;
|
|
43175
44725
|
},
|
|
43176
44726
|
rmdir(option) {
|
|
43177
|
-
|
|
43178
|
-
const result = rmdir(option.dirPath, option.recursive);
|
|
43179
|
-
option.success?.(result);
|
|
43180
|
-
option.complete?.(result);
|
|
43181
|
-
return result;
|
|
43182
|
-
} catch (error) {
|
|
43183
|
-
option.fail?.(error);
|
|
43184
|
-
option.complete?.();
|
|
43185
|
-
return;
|
|
43186
|
-
}
|
|
44727
|
+
return runFileSystemOperation(() => rmdir(option.dirPath, option.recursive), option);
|
|
43187
44728
|
},
|
|
43188
44729
|
rmdirSync(dirPath, recursive) {
|
|
43189
44730
|
rmdir(dirPath, recursive);
|
|
43190
44731
|
},
|
|
43191
44732
|
rename(option) {
|
|
43192
|
-
|
|
43193
|
-
const result = renameFile(option.oldPath, option.newPath);
|
|
43194
|
-
option.success?.(result);
|
|
43195
|
-
option.complete?.(result);
|
|
43196
|
-
return result;
|
|
43197
|
-
} catch (error) {
|
|
43198
|
-
option.fail?.(error);
|
|
43199
|
-
option.complete?.();
|
|
43200
|
-
return;
|
|
43201
|
-
}
|
|
44733
|
+
return runFileSystemOperation(() => renameFile(option.oldPath, option.newPath), option);
|
|
43202
44734
|
},
|
|
43203
44735
|
renameSync(oldPath, newPath) {
|
|
43204
44736
|
renameFile(oldPath, newPath);
|
|
43205
44737
|
},
|
|
43206
44738
|
stat(option) {
|
|
43207
|
-
|
|
43208
|
-
const result = stat(option.path);
|
|
43209
|
-
option.success?.(result);
|
|
43210
|
-
option.complete?.(result);
|
|
43211
|
-
return result;
|
|
43212
|
-
} catch (error) {
|
|
43213
|
-
option.fail?.(error);
|
|
43214
|
-
option.complete?.();
|
|
43215
|
-
return;
|
|
43216
|
-
}
|
|
44739
|
+
return runFileSystemOperation(() => stat(option.path), option);
|
|
43217
44740
|
},
|
|
43218
44741
|
statSync(path) {
|
|
43219
44742
|
return stat(path).stats;
|
|
43220
44743
|
},
|
|
43221
44744
|
unlink(option) {
|
|
43222
|
-
|
|
43223
|
-
const result = unlinkFile(option.filePath);
|
|
43224
|
-
option.success?.(result);
|
|
43225
|
-
option.complete?.(result);
|
|
43226
|
-
return result;
|
|
43227
|
-
} catch (error) {
|
|
43228
|
-
option.fail?.(error);
|
|
43229
|
-
option.complete?.();
|
|
43230
|
-
return;
|
|
43231
|
-
}
|
|
44745
|
+
return runFileSystemOperation(() => unlinkFile(option.filePath), option);
|
|
43232
44746
|
},
|
|
43233
44747
|
unlinkSync(filePath) {
|
|
43234
44748
|
unlinkFile(filePath);
|
|
43235
44749
|
},
|
|
43236
44750
|
writeFile(option) {
|
|
43237
|
-
|
|
43238
|
-
const result = writeFile(option.filePath, option.data, option.encoding);
|
|
43239
|
-
option.success?.(result);
|
|
43240
|
-
option.complete?.(result);
|
|
43241
|
-
return result;
|
|
43242
|
-
} catch (error) {
|
|
43243
|
-
option.fail?.(error);
|
|
43244
|
-
option.complete?.();
|
|
43245
|
-
return;
|
|
43246
|
-
}
|
|
44751
|
+
return runFileSystemOperation(() => writeFile(option.filePath, option.data, option.encoding), option);
|
|
43247
44752
|
},
|
|
43248
44753
|
writeFileSync(filePath, data, encoding) {
|
|
43249
44754
|
writeFile(filePath, data, encoding);
|
|
@@ -43323,7 +44828,7 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
43323
44828
|
}));
|
|
43324
44829
|
},
|
|
43325
44830
|
getFileSnapshot() {
|
|
43326
|
-
return Object.fromEntries(files.
|
|
44831
|
+
return Object.fromEntries([...files].map(([file, content]) => [file, typeof content === "string" ? content : copyArtifactBinary(content)]));
|
|
43327
44832
|
},
|
|
43328
44833
|
getDirectorySnapshot() {
|
|
43329
44834
|
return Array.from(directories.values()).sort((a, b) => a.localeCompare(b));
|
|
@@ -43341,7 +44846,8 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
43341
44846
|
return getSavedFileList();
|
|
43342
44847
|
},
|
|
43343
44848
|
getFileText(filePath) {
|
|
43344
|
-
|
|
44849
|
+
const content = files.get(filePath);
|
|
44850
|
+
return content === void 0 ? null : readArtifactText(content);
|
|
43345
44851
|
},
|
|
43346
44852
|
createTempFile(fileContent, preferredPath) {
|
|
43347
44853
|
const tempFilePath = allocateFilePath("temp", preferredPath);
|
|
@@ -43472,8 +44978,8 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
43472
44978
|
compressImage(option) {
|
|
43473
44979
|
const fileContent = files.get(option.src);
|
|
43474
44980
|
if (fileContent == null) throw new Error(`compressImage:fail file not found: ${option.src}`);
|
|
43475
|
-
const sourceSize = inferImageSize(fileContent);
|
|
43476
|
-
const sourceType = inferImageType(option.src, fileContent);
|
|
44981
|
+
const sourceSize = inferImageSize(readArtifactText(fileContent));
|
|
44982
|
+
const sourceType = inferImageType(option.src, readArtifactText(fileContent));
|
|
43477
44983
|
const width = Number.isFinite(option.compressedWidth) ? Math.max(1, Math.trunc(option.compressedWidth ?? sourceSize.width)) : Math.max(1, sourceSize.width);
|
|
43478
44984
|
const height = Number.isFinite(option.compressedHeight) ? Math.max(1, Math.trunc(option.compressedHeight ?? sourceSize.height)) : Math.max(1, sourceSize.height);
|
|
43479
44985
|
const normalizedType = sourceType === "unknown" ? "jpg" : sourceType;
|
|
@@ -43493,20 +44999,20 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
43493
44999
|
getImageInfo(option) {
|
|
43494
45000
|
const fileContent = files.get(option.src);
|
|
43495
45001
|
if (fileContent == null) throw new Error(`getImageInfo:fail file not found: ${option.src}`);
|
|
43496
|
-
const size = inferImageSize(fileContent);
|
|
45002
|
+
const size = inferImageSize(readArtifactText(fileContent));
|
|
43497
45003
|
return {
|
|
43498
45004
|
errMsg: "getImageInfo:ok",
|
|
43499
45005
|
height: size.height,
|
|
43500
45006
|
orientation: "up",
|
|
43501
45007
|
path: option.src,
|
|
43502
|
-
type: inferImageType(option.src, fileContent),
|
|
45008
|
+
type: inferImageType(option.src, readArtifactText(fileContent)),
|
|
43503
45009
|
width: size.width
|
|
43504
45010
|
};
|
|
43505
45011
|
},
|
|
43506
45012
|
getVideoInfo(option) {
|
|
43507
45013
|
const fileContent = files.get(option.src);
|
|
43508
45014
|
if (fileContent == null) throw new Error(`getVideoInfo:fail file not found: ${option.src}`);
|
|
43509
|
-
const info = inferVideoInfo(option.src, fileContent);
|
|
45015
|
+
const info = inferVideoInfo(option.src, readArtifactText(fileContent));
|
|
43510
45016
|
return {
|
|
43511
45017
|
bitrate: info.bitrate,
|
|
43512
45018
|
duration: info.duration,
|
|
@@ -43860,7 +45366,7 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
43860
45366
|
}
|
|
43861
45367
|
const matchedMock = uploadFileMocks.find((mock) => matchesSimpleUrlMock(mock, option.url));
|
|
43862
45368
|
const logEntry = {
|
|
43863
|
-
fileContent,
|
|
45369
|
+
fileContent: readArtifactText(fileContent),
|
|
43864
45370
|
fileName: option.fileName,
|
|
43865
45371
|
filePath: option.filePath,
|
|
43866
45372
|
formData: cloneValue(option.formData ?? {}),
|
|
@@ -43877,7 +45383,7 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
43877
45383
|
option.complete?.();
|
|
43878
45384
|
return createNoopTask();
|
|
43879
45385
|
}
|
|
43880
|
-
const response = resolveUploadFileResponse(matchedMock, option, fileContent);
|
|
45386
|
+
const response = resolveUploadFileResponse(matchedMock, option, readArtifactText(fileContent));
|
|
43881
45387
|
const delay = normalizeDelay(matchedMock.delay);
|
|
43882
45388
|
const commit = () => {
|
|
43883
45389
|
logEntry.response = { ...response };
|
|
@@ -44015,7 +45521,7 @@ var HeadlessSession = class {
|
|
|
44015
45521
|
this.wxState = createHeadlessWxState(this.kernel.scheduler, {
|
|
44016
45522
|
accountInfo: createDefaultAccountInfo(this.project),
|
|
44017
45523
|
strictMocks: options.strictHostMocks,
|
|
44018
|
-
readPackageFile: createPackageAssetReader((relative) => this.project.artifactSource.readText(path.join(this.project.miniprogramRootPath, relative)))
|
|
45524
|
+
readPackageFile: createPackageAssetReader((relative) => this.project.artifactSource.readBinary?.(path.join(this.project.miniprogramRootPath, relative)) ?? this.project.artifactSource.readText(path.join(this.project.miniprogramRootPath, relative)))
|
|
44019
45525
|
});
|
|
44020
45526
|
this.registries = createHostRegistries();
|
|
44021
45527
|
const rawTabBarList = Array.isArray(this.project.appConfig.tabBar?.list) ? this.project.appConfig.tabBar.list : [];
|