@weapp-vite/miniprogram-automator 1.5.3 → 1.5.4-dev.20261114.1
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.mjs +2 -2
- package/dist/{launch-B07RJf-D.mjs → launch-B9tPcu70.mjs} +426 -156
- package/package.json +13 -5
package/dist/index.mjs
CHANGED
|
@@ -1402,7 +1402,7 @@ var Connection = class Connection extends EventEmitter {
|
|
|
1402
1402
|
};
|
|
1403
1403
|
// src/headless.ts
|
|
1404
1404
|
async function launchHeadlessAutomator(options) {
|
|
1405
|
-
return await (await import("./launch-
|
|
1405
|
+
return await (await import("./launch-B9tPcu70.mjs")).launch({ projectPath: options.projectPath });
|
|
1406
1406
|
}
|
|
1407
1407
|
// src/launcher/diagnostics.ts
|
|
1408
1408
|
/** 将本次 CLI 的有界输出附到原始错误,避免泄露登录票据及账号参数。 */
|
|
@@ -1658,7 +1658,7 @@ function spawnWechatCli(cliPath, args, cwd, scope) {
|
|
|
1658
1658
|
return Object.assign(state, { release });
|
|
1659
1659
|
}
|
|
1660
1660
|
// package.json
|
|
1661
|
-
var version = "1.5.
|
|
1661
|
+
var version = "1.5.4-dev.20261114.1";
|
|
1662
1662
|
// src/appServiceHeap.ts
|
|
1663
1663
|
function isRecord$1(value) {
|
|
1664
1664
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -126,6 +126,16 @@ function hasNativeDataCommit(owner, dependencies, after, through) {
|
|
|
126
126
|
for (const entry of commits.get(owner)?.paths.values() ?? []) if (entry.revision > after && entry.revision <= through && dependencies.some((path) => pathsIntersect(path, entry.path))) return true;
|
|
127
127
|
return false;
|
|
128
128
|
}
|
|
129
|
+
// ../../mpcore/packages/simulator/src/runtime/componentInstance/pureData.ts
|
|
130
|
+
/** 原生纯数据保留在逻辑层,不能参与组件自身的模板求值。 */
|
|
131
|
+
function isPureDataField(definition, key) {
|
|
132
|
+
const pattern = definition?.options?.pureDataPattern;
|
|
133
|
+
return typeof pattern?.source === "string" && typeof pattern?.flags === "string" && new RegExp(pattern.source, pattern.flags).test(key);
|
|
134
|
+
}
|
|
135
|
+
/** Node 与浏览器渲染共享同一纯数据边界。 */
|
|
136
|
+
function resolveComponentViewData(instance) {
|
|
137
|
+
return Object.fromEntries(Object.entries(instance.data).filter(([key]) => !isPureDataField(instance.__definition__, key)));
|
|
138
|
+
}
|
|
129
139
|
// ../../mpcore/packages/simulator/src/runtime/componentInstance/shared.ts
|
|
130
140
|
const ARRAY_INDEX_PATH_RE$1 = /\[(\d+)\]/g;
|
|
131
141
|
const ARRAY_INDEX_SEGMENT_RE$1 = /^\d+$/;
|
|
@@ -194,7 +204,7 @@ function runPropertyObservers(definition, instance, changedKeys, previousPropert
|
|
|
194
204
|
if (!propOptions || typeof propOptions !== "object" || Array.isArray(propOptions)) return;
|
|
195
205
|
const changedRoots = new Set(changedKeys.map((key) => parseDataPath$1(key)[0]));
|
|
196
206
|
for (const changedKey of Object.keys(propOptions)) {
|
|
197
|
-
if (!changedRoots.has(changedKey)) continue;
|
|
207
|
+
if (!changedRoots.has(changedKey) || isPureDataField(definition, changedKey)) continue;
|
|
198
208
|
const value = instance.properties[changedKey];
|
|
199
209
|
if ((value === null || typeof value !== "object") && Object.hasOwn(previousProperties, changedKey) && Object.is(value, previousProperties[changedKey])) continue;
|
|
200
210
|
const option = propOptions[changedKey];
|
|
@@ -416,6 +426,11 @@ function resolveInitialProperties(definition, properties) {
|
|
|
416
426
|
}
|
|
417
427
|
return resolved;
|
|
418
428
|
}
|
|
429
|
+
/** 与真实宿主对齐:显式传入空值与未声明属性不同,String 空值会产生类型警告。 */
|
|
430
|
+
function isInvalidStringPropertyNull(definition, key, value) {
|
|
431
|
+
const candidates = resolvePropertyTypeCandidates(definition.properties?.[key]);
|
|
432
|
+
return value == null && candidates[0] === String && !candidates.includes(null);
|
|
433
|
+
}
|
|
419
434
|
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
420
435
|
let _lazyMatch = () => {
|
|
421
436
|
var __lib__ = (() => {
|
|
@@ -1932,7 +1947,7 @@ function registerSlotDeclarations(pass, slots, parent, scopeId) {
|
|
|
1932
1947
|
scopeId
|
|
1933
1948
|
});
|
|
1934
1949
|
}
|
|
1935
|
-
// ../../node_modules/.pnpm/@babel+parser@8.1.
|
|
1950
|
+
// ../../node_modules/.pnpm/@babel+parser@8.1.2/node_modules/@babel/parser/lib/index.js
|
|
1936
1951
|
var Position = class {
|
|
1937
1952
|
constructor(line, col, index) {
|
|
1938
1953
|
this.line = void 0;
|
|
@@ -2028,7 +2043,7 @@ const StandardErrors = {
|
|
|
2028
2043
|
DuplicateRegExpFlags: "Duplicate regular expression flag.",
|
|
2029
2044
|
ElementAfterRest: "Rest element must be last element.",
|
|
2030
2045
|
EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
|
|
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'\`?`,
|
|
2046
|
+
ExportBindingIsString: ({ localName, exportName, typeModifierIn }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export ${typeModifierIn === "declaration" ? "type " : ""}{ ${typeModifierIn === "specifier" ? "type " : ""}'${localName}' as '${exportName}' } from 'some-module'\`?`,
|
|
2032
2047
|
ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
|
|
2033
2048
|
FilteredNamespaceDuplicateName: ({ name }) => `Duplicate name '${name}' in filtered namespace.`,
|
|
2034
2049
|
FilteredNamespaceRename: "Names in a filtered namespace cannot be renamed using `as`.",
|
|
@@ -4401,31 +4416,26 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4401
4416
|
}
|
|
4402
4417
|
this.expect(13);
|
|
4403
4418
|
const state = this.state.clone();
|
|
4404
|
-
const originalNoArrowAt = this.state.noArrowAt;
|
|
4405
4419
|
const node = this.startNodeAt(startLoc);
|
|
4406
4420
|
let { consequent, failed } = this.tryParseConditionalConsequent();
|
|
4407
4421
|
const result = this.getArrowLikeExpressions(consequent);
|
|
4408
4422
|
let valid = result[0];
|
|
4409
4423
|
const invalid = result[1];
|
|
4410
4424
|
if (failed || invalid.length > 0) {
|
|
4411
|
-
const noArrowAt = [...originalNoArrowAt];
|
|
4412
4425
|
if (invalid.length > 0) {
|
|
4413
4426
|
this.state = state;
|
|
4414
|
-
|
|
4415
|
-
for (let i = 0; i < invalid.length; i++) noArrowAt.push(invalid[i].start);
|
|
4427
|
+
for (let i = 0; i < invalid.length; i++) this.noArrowAt.add(this.offsetToSourcePos(invalid[i].start));
|
|
4416
4428
|
({consequent, failed} = this.tryParseConditionalConsequent());
|
|
4417
4429
|
[valid] = this.getArrowLikeExpressions(consequent);
|
|
4418
4430
|
}
|
|
4419
4431
|
if (failed && valid.length > 1) this.raise(FlowErrors.AmbiguousConditionalArrow, state.startLoc);
|
|
4420
4432
|
if (failed && valid.length === 1) {
|
|
4421
4433
|
this.state = state;
|
|
4422
|
-
noArrowAt.
|
|
4423
|
-
this.state.noArrowAt = noArrowAt;
|
|
4434
|
+
this.noArrowAt.add(this.offsetToSourcePos(valid[0].start));
|
|
4424
4435
|
({consequent} = this.tryParseConditionalConsequent());
|
|
4425
4436
|
}
|
|
4426
4437
|
}
|
|
4427
4438
|
this.getArrowLikeExpressions(consequent, true);
|
|
4428
|
-
this.state.noArrowAt = originalNoArrowAt;
|
|
4429
4439
|
this.expect(10);
|
|
4430
4440
|
node.test = expr;
|
|
4431
4441
|
node.consequent = consequent;
|
|
@@ -4803,8 +4813,8 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4803
4813
|
}
|
|
4804
4814
|
return super.parseAsyncArrowFromCallExpression(node, call);
|
|
4805
4815
|
}
|
|
4806
|
-
|
|
4807
|
-
return this.match(10)
|
|
4816
|
+
parseAsyncArrowHead(startLoc) {
|
|
4817
|
+
return this.match(10) ? this.startNodeAt(startLoc) : super.parseAsyncArrowHead(startLoc);
|
|
4808
4818
|
}
|
|
4809
4819
|
parseMaybeAssign(refExpressionErrors, isParenItem) {
|
|
4810
4820
|
let state = null;
|
|
@@ -4887,10 +4897,10 @@ const flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
4887
4897
|
super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
|
|
4888
4898
|
}
|
|
4889
4899
|
parseParenAndDistinguishExpression(canStartArrow) {
|
|
4890
|
-
return super.parseParenAndDistinguishExpression(canStartArrow && !this.
|
|
4900
|
+
return super.parseParenAndDistinguishExpression(canStartArrow && !this.noArrowAt.has(this.state.start));
|
|
4891
4901
|
}
|
|
4892
4902
|
parseSubscripts(base, startLoc, noCalls) {
|
|
4893
|
-
if (base.type === "Identifier" && base.name === "async" && this.
|
|
4903
|
+
if (base.type === "Identifier" && base.name === "async" && this.noArrowAt.has(this.offsetToSourcePos(startLoc.index))) {
|
|
4894
4904
|
this.next();
|
|
4895
4905
|
const node = this.startNodeAt(startLoc);
|
|
4896
4906
|
node.callee = base;
|
|
@@ -5952,12 +5962,13 @@ var TypeScriptScopeHandler = class extends ScopeHandler {
|
|
|
5952
5962
|
return false;
|
|
5953
5963
|
}
|
|
5954
5964
|
declareName(name, bindingType, loc) {
|
|
5965
|
+
const scope = this.currentScope();
|
|
5955
5966
|
if (bindingType & 4096) {
|
|
5956
5967
|
if (this.hasImport(name, true)) this.parser.raise(Errors.VarRedeclaration, loc, { identifierName: name });
|
|
5957
5968
|
this.importsStack[this.importsStack.length - 1].add(name);
|
|
5969
|
+
this.maybeExportDefined(scope, name);
|
|
5958
5970
|
return;
|
|
5959
5971
|
}
|
|
5960
|
-
const scope = this.currentScope();
|
|
5961
5972
|
let type = scope.tsNames.get(name) || 0;
|
|
5962
5973
|
if (bindingType & 1024) {
|
|
5963
5974
|
this.maybeExportDefined(scope, name);
|
|
@@ -6004,6 +6015,7 @@ var TypeScriptScopeHandler = class extends ScopeHandler {
|
|
|
6004
6015
|
var BaseParser = class {
|
|
6005
6016
|
sawUnambiguousESM = false;
|
|
6006
6017
|
ambiguousScriptDifferentAst = false;
|
|
6018
|
+
noArrowAt = /* @__PURE__ */ new Set();
|
|
6007
6019
|
sourceToOffsetPos(sourcePos) {
|
|
6008
6020
|
return sourcePos + this.startIndex;
|
|
6009
6021
|
}
|
|
@@ -6161,7 +6173,7 @@ var CommentsParser = class extends BaseParser {
|
|
|
6161
6173
|
}
|
|
6162
6174
|
};
|
|
6163
6175
|
var State$1 = class State$1 {
|
|
6164
|
-
flags =
|
|
6176
|
+
flags = 1024;
|
|
6165
6177
|
get strict() {
|
|
6166
6178
|
return (this.flags & 1) > 0;
|
|
6167
6179
|
}
|
|
@@ -6182,8 +6194,8 @@ var State$1 = class State$1 {
|
|
|
6182
6194
|
this.startLoc = this.endLoc = new Position(startLine, startColumn, startIndex);
|
|
6183
6195
|
}
|
|
6184
6196
|
errors = [];
|
|
6185
|
-
noArrowAt = [];
|
|
6186
6197
|
noArrowParamsConversionAt = [];
|
|
6198
|
+
tsArrowReturnTypeRestrictionAt = -1;
|
|
6187
6199
|
regExpAllowedAt = -1;
|
|
6188
6200
|
get canStartArrow() {
|
|
6189
6201
|
return (this.flags & 2) > 0;
|
|
@@ -6234,27 +6246,20 @@ var State$1 = class State$1 {
|
|
|
6234
6246
|
if (v) this.flags |= 128;
|
|
6235
6247
|
else this.flags &= -129;
|
|
6236
6248
|
}
|
|
6237
|
-
get
|
|
6249
|
+
get inHackPipelineBody() {
|
|
6238
6250
|
return (this.flags & 256) > 0;
|
|
6239
6251
|
}
|
|
6240
|
-
set
|
|
6252
|
+
set inHackPipelineBody(v) {
|
|
6241
6253
|
if (v) this.flags |= 256;
|
|
6242
6254
|
else this.flags &= -257;
|
|
6243
6255
|
}
|
|
6244
|
-
get
|
|
6256
|
+
get seenTopicReference() {
|
|
6245
6257
|
return (this.flags & 512) > 0;
|
|
6246
6258
|
}
|
|
6247
|
-
set
|
|
6259
|
+
set seenTopicReference(v) {
|
|
6248
6260
|
if (v) this.flags |= 512;
|
|
6249
6261
|
else this.flags &= -513;
|
|
6250
6262
|
}
|
|
6251
|
-
get seenTopicReference() {
|
|
6252
|
-
return (this.flags & 1024) > 0;
|
|
6253
|
-
}
|
|
6254
|
-
set seenTopicReference(v) {
|
|
6255
|
-
if (v) this.flags |= 1024;
|
|
6256
|
-
else this.flags &= -1025;
|
|
6257
|
-
}
|
|
6258
6263
|
labels = [];
|
|
6259
6264
|
commentsLen = 0;
|
|
6260
6265
|
commentStack = [];
|
|
@@ -6267,27 +6272,41 @@ var State$1 = class State$1 {
|
|
|
6267
6272
|
lastTokStartLoc = null;
|
|
6268
6273
|
context = [types.brace];
|
|
6269
6274
|
get canStartJSXElement() {
|
|
6270
|
-
return (this.flags &
|
|
6275
|
+
return (this.flags & 1024) > 0;
|
|
6271
6276
|
}
|
|
6272
6277
|
set canStartJSXElement(v) {
|
|
6278
|
+
if (v) this.flags |= 1024;
|
|
6279
|
+
else this.flags &= -1025;
|
|
6280
|
+
}
|
|
6281
|
+
get containsEsc() {
|
|
6282
|
+
return (this.flags & 2048) > 0;
|
|
6283
|
+
}
|
|
6284
|
+
set containsEsc(v) {
|
|
6273
6285
|
if (v) this.flags |= 2048;
|
|
6274
6286
|
else this.flags &= -2049;
|
|
6275
6287
|
}
|
|
6276
|
-
|
|
6288
|
+
firstInvalidTemplateEscapePos = null;
|
|
6289
|
+
get hasTopLevelAwait() {
|
|
6277
6290
|
return (this.flags & 4096) > 0;
|
|
6278
6291
|
}
|
|
6279
|
-
set
|
|
6292
|
+
set hasTopLevelAwait(v) {
|
|
6280
6293
|
if (v) this.flags |= 4096;
|
|
6281
6294
|
else this.flags &= -4097;
|
|
6282
6295
|
}
|
|
6283
|
-
|
|
6284
|
-
get hasTopLevelAwait() {
|
|
6296
|
+
get tsArrowReturnTypeAllowed() {
|
|
6285
6297
|
return (this.flags & 8192) > 0;
|
|
6286
6298
|
}
|
|
6287
|
-
set
|
|
6299
|
+
set tsArrowReturnTypeAllowed(v) {
|
|
6288
6300
|
if (v) this.flags |= 8192;
|
|
6289
6301
|
else this.flags &= -8193;
|
|
6290
6302
|
}
|
|
6303
|
+
get tsGenericArrowParams() {
|
|
6304
|
+
return (this.flags & 16384) > 0;
|
|
6305
|
+
}
|
|
6306
|
+
set tsGenericArrowParams(v) {
|
|
6307
|
+
if (v) this.flags |= 16384;
|
|
6308
|
+
else this.flags &= -16385;
|
|
6309
|
+
}
|
|
6291
6310
|
strictErrors = /* @__PURE__ */ new Map();
|
|
6292
6311
|
tokensLength = 0;
|
|
6293
6312
|
curPosition() {
|
|
@@ -6302,8 +6321,8 @@ var State$1 = class State$1 {
|
|
|
6302
6321
|
state.startLoc = this.startLoc;
|
|
6303
6322
|
state.endLoc = this.endLoc;
|
|
6304
6323
|
state.errors = this.errors.slice();
|
|
6305
|
-
state.noArrowAt = this.noArrowAt.slice();
|
|
6306
6324
|
state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
|
|
6325
|
+
state.tsArrowReturnTypeRestrictionAt = this.tsArrowReturnTypeRestrictionAt;
|
|
6307
6326
|
state.regExpAllowedAt = this.regExpAllowedAt;
|
|
6308
6327
|
state.labels = this.labels.slice();
|
|
6309
6328
|
state.commentsLen = this.commentsLen;
|
|
@@ -6542,7 +6561,7 @@ function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
|
|
|
6542
6561
|
++pos;
|
|
6543
6562
|
if (code !== null && code > 1114111) {
|
|
6544
6563
|
if (throwOnInvalid) errors.invalidCodePoint(pos, lineStart, curLine);
|
|
6545
|
-
|
|
6564
|
+
return {
|
|
6546
6565
|
code: null,
|
|
6547
6566
|
pos
|
|
6548
6567
|
};
|
|
@@ -6577,6 +6596,23 @@ var Token = class {
|
|
|
6577
6596
|
}
|
|
6578
6597
|
};
|
|
6579
6598
|
let locDataCache;
|
|
6599
|
+
const asciiIdentifierChar = /* @__PURE__ */ new Uint8Array(128);
|
|
6600
|
+
for (let i = 0; i < 128; i++) asciiIdentifierChar[i] = isIdentifierChar(i) ? 1 : 0;
|
|
6601
|
+
const keywordBuckets = [];
|
|
6602
|
+
let maxKeywordLength = 0;
|
|
6603
|
+
keywords$1.forEach((type, word) => {
|
|
6604
|
+
const index = word.length << 7 | word.charCodeAt(0);
|
|
6605
|
+
(keywordBuckets[index] ??= []).push(word, type);
|
|
6606
|
+
if (word.length > maxKeywordLength) maxKeywordLength = word.length;
|
|
6607
|
+
});
|
|
6608
|
+
function lookupKeyword(word, firstCode) {
|
|
6609
|
+
const { length } = word;
|
|
6610
|
+
if (length > maxKeywordLength || firstCode >= 128) return void 0;
|
|
6611
|
+
const bucket = keywordBuckets[length << 7 | firstCode];
|
|
6612
|
+
if (bucket !== void 0) {
|
|
6613
|
+
for (let i = 0; i < bucket.length; i += 2) if (bucket[i] === word) return bucket[i + 1];
|
|
6614
|
+
}
|
|
6615
|
+
}
|
|
6580
6616
|
var Tokenizer$1 = class extends CommentsParser {
|
|
6581
6617
|
isLookahead;
|
|
6582
6618
|
tokens = [];
|
|
@@ -6745,26 +6781,30 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
6745
6781
|
const spaceStart = this.state.pos;
|
|
6746
6782
|
const attachComment = (this.optionFlags & 8192) > 0;
|
|
6747
6783
|
let comments;
|
|
6748
|
-
|
|
6749
|
-
|
|
6784
|
+
const { input, length } = this;
|
|
6785
|
+
let pos = spaceStart;
|
|
6786
|
+
loop: while (pos < length) {
|
|
6787
|
+
const ch = input.charCodeAt(pos);
|
|
6750
6788
|
switch (ch) {
|
|
6751
6789
|
case 32:
|
|
6752
6790
|
case 160:
|
|
6753
6791
|
case 9:
|
|
6754
|
-
++
|
|
6792
|
+
++pos;
|
|
6755
6793
|
break;
|
|
6756
|
-
case 13: if (
|
|
6794
|
+
case 13: if (input.charCodeAt(pos + 1) === 10) ++pos;
|
|
6757
6795
|
case 10:
|
|
6758
6796
|
case 8232:
|
|
6759
6797
|
case 8233:
|
|
6760
|
-
++
|
|
6798
|
+
++pos;
|
|
6761
6799
|
++this.state.curLine;
|
|
6762
|
-
this.state.lineStart =
|
|
6800
|
+
this.state.lineStart = pos;
|
|
6763
6801
|
break;
|
|
6764
6802
|
case 47:
|
|
6765
|
-
switch (
|
|
6803
|
+
switch (input.charCodeAt(pos + 1)) {
|
|
6766
6804
|
case 42: {
|
|
6805
|
+
this.state.pos = pos;
|
|
6767
6806
|
const comment = this.skipBlockComment("*/");
|
|
6807
|
+
pos = this.state.pos;
|
|
6768
6808
|
if (comment !== void 0) {
|
|
6769
6809
|
this.addComment(comment);
|
|
6770
6810
|
if (attachComment) (comments ??= []).push(comment);
|
|
@@ -6772,7 +6812,9 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
6772
6812
|
break;
|
|
6773
6813
|
}
|
|
6774
6814
|
case 47: {
|
|
6815
|
+
this.state.pos = pos;
|
|
6775
6816
|
const comment = this.skipLineComment(2);
|
|
6817
|
+
pos = this.state.pos;
|
|
6776
6818
|
if (comment !== void 0) {
|
|
6777
6819
|
this.addComment(comment);
|
|
6778
6820
|
if (attachComment) (comments ??= []).push(comment);
|
|
@@ -6782,20 +6824,22 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
6782
6824
|
default: break loop;
|
|
6783
6825
|
}
|
|
6784
6826
|
break;
|
|
6785
|
-
default: if (isWhitespace$2(ch)) ++
|
|
6827
|
+
default: if (isWhitespace$2(ch)) ++pos;
|
|
6786
6828
|
else if (ch === 45 && !this.inModule && this.optionFlags & 16384) {
|
|
6787
|
-
|
|
6788
|
-
|
|
6829
|
+
if (input.charCodeAt(pos + 1) === 45 && input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
|
|
6830
|
+
this.state.pos = pos;
|
|
6789
6831
|
const comment = this.skipLineComment(3);
|
|
6832
|
+
pos = this.state.pos;
|
|
6790
6833
|
if (comment !== void 0) {
|
|
6791
6834
|
this.addComment(comment);
|
|
6792
6835
|
if (attachComment) (comments ??= []).push(comment);
|
|
6793
6836
|
}
|
|
6794
6837
|
} else break loop;
|
|
6795
6838
|
} else if (ch === 60 && !this.inModule && this.optionFlags & 16384) {
|
|
6796
|
-
|
|
6797
|
-
|
|
6839
|
+
if (input.charCodeAt(pos + 1) === 33 && input.charCodeAt(pos + 2) === 45 && input.charCodeAt(pos + 3) === 45) {
|
|
6840
|
+
this.state.pos = pos;
|
|
6798
6841
|
const comment = this.skipLineComment(4);
|
|
6842
|
+
pos = this.state.pos;
|
|
6799
6843
|
if (comment !== void 0) {
|
|
6800
6844
|
this.addComment(comment);
|
|
6801
6845
|
if (attachComment) (comments ??= []).push(comment);
|
|
@@ -6804,6 +6848,7 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
6804
6848
|
} else break loop;
|
|
6805
6849
|
}
|
|
6806
6850
|
}
|
|
6851
|
+
this.state.pos = pos;
|
|
6807
6852
|
if (comments?.length) {
|
|
6808
6853
|
const end = this.state.pos;
|
|
6809
6854
|
const commentWhitespace = {
|
|
@@ -7304,19 +7349,27 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
7304
7349
|
this.state.containsEsc = false;
|
|
7305
7350
|
let word = "";
|
|
7306
7351
|
const start = this.state.pos;
|
|
7307
|
-
let chunkStart =
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7352
|
+
let chunkStart = start;
|
|
7353
|
+
const { input, length } = this;
|
|
7354
|
+
let pos = start;
|
|
7355
|
+
if (firstCode !== void 0) pos += firstCode <= 65535 ? 1 : 2;
|
|
7356
|
+
while (pos < length) {
|
|
7357
|
+
let ch = input.charCodeAt(pos);
|
|
7358
|
+
if (ch < 128) {
|
|
7359
|
+
if (asciiIdentifierChar[ch] === 1) {
|
|
7360
|
+
++pos;
|
|
7361
|
+
continue;
|
|
7362
|
+
}
|
|
7363
|
+
if (ch !== 92) break;
|
|
7313
7364
|
this.state.containsEsc = true;
|
|
7314
|
-
word +=
|
|
7365
|
+
word += input.slice(chunkStart, pos);
|
|
7366
|
+
this.state.pos = pos;
|
|
7315
7367
|
const escStart = this.state.curPosition();
|
|
7316
|
-
const identifierCheck =
|
|
7317
|
-
if (
|
|
7368
|
+
const identifierCheck = pos === start ? isIdentifierStart : isIdentifierChar;
|
|
7369
|
+
if (input.charCodeAt(++this.state.pos) !== 117) {
|
|
7318
7370
|
this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
|
|
7319
7371
|
chunkStart = this.state.pos - 1;
|
|
7372
|
+
pos = this.state.pos;
|
|
7320
7373
|
continue;
|
|
7321
7374
|
}
|
|
7322
7375
|
++this.state.pos;
|
|
@@ -7325,14 +7378,22 @@ var Tokenizer$1 = class extends CommentsParser {
|
|
|
7325
7378
|
if (!identifierCheck(esc)) this.raise(Errors.EscapedCharNotAnIdentifier, escStart);
|
|
7326
7379
|
word += String.fromCodePoint(esc);
|
|
7327
7380
|
}
|
|
7328
|
-
chunkStart = this.state.pos;
|
|
7329
|
-
} else
|
|
7381
|
+
chunkStart = pos = this.state.pos;
|
|
7382
|
+
} else {
|
|
7383
|
+
if ((ch & 64512) === 55296 && pos + 1 < length) {
|
|
7384
|
+
const trail = input.charCodeAt(pos + 1);
|
|
7385
|
+
if ((trail & 64512) === 56320) ch = 65536 + ((ch & 1023) << 10) + (trail & 1023);
|
|
7386
|
+
}
|
|
7387
|
+
if (isIdentifierChar(ch)) pos += ch <= 65535 ? 1 : 2;
|
|
7388
|
+
else break;
|
|
7389
|
+
}
|
|
7330
7390
|
}
|
|
7331
|
-
|
|
7391
|
+
this.state.pos = pos;
|
|
7392
|
+
return word + input.slice(chunkStart, pos);
|
|
7332
7393
|
}
|
|
7333
7394
|
readWord(firstCode) {
|
|
7334
7395
|
const word = this.readWord1(firstCode);
|
|
7335
|
-
const type =
|
|
7396
|
+
const type = lookupKeyword(word, firstCode === void 0 ? word.charCodeAt(0) : firstCode);
|
|
7336
7397
|
if (type !== void 0) this.finishToken(type, tokenLabelName(type));
|
|
7337
7398
|
else this.finishToken(131, word);
|
|
7338
7399
|
}
|
|
@@ -8217,8 +8278,12 @@ var ExpressionParser = class extends LValParser {
|
|
|
8217
8278
|
return expr;
|
|
8218
8279
|
}
|
|
8219
8280
|
parseExpression(disallowIn, refExpressionErrors) {
|
|
8220
|
-
if (disallowIn
|
|
8221
|
-
|
|
8281
|
+
if (disallowIn ? this.enterDisallowIn() : this.enterAllowIn()) try {
|
|
8282
|
+
return this.parseExpressionBase(refExpressionErrors);
|
|
8283
|
+
} finally {
|
|
8284
|
+
this.prodParam.exit();
|
|
8285
|
+
}
|
|
8286
|
+
return this.parseExpressionBase(refExpressionErrors);
|
|
8222
8287
|
}
|
|
8223
8288
|
parseExpressionBase(refExpressionErrors) {
|
|
8224
8289
|
const startLoc = this.state.startLoc;
|
|
@@ -8233,10 +8298,20 @@ var ExpressionParser = class extends LValParser {
|
|
|
8233
8298
|
return expr;
|
|
8234
8299
|
}
|
|
8235
8300
|
parseMaybeAssignDisallowIn(refExpressionErrors) {
|
|
8236
|
-
|
|
8301
|
+
if (this.enterDisallowIn()) try {
|
|
8302
|
+
return this.parseMaybeAssign(refExpressionErrors);
|
|
8303
|
+
} finally {
|
|
8304
|
+
this.prodParam.exit();
|
|
8305
|
+
}
|
|
8306
|
+
return this.parseMaybeAssign(refExpressionErrors);
|
|
8237
8307
|
}
|
|
8238
8308
|
parseMaybeAssignAllowIn(refExpressionErrors, isParenItem) {
|
|
8239
|
-
|
|
8309
|
+
if (this.enterAllowIn()) try {
|
|
8310
|
+
return this.parseMaybeAssign(refExpressionErrors, isParenItem);
|
|
8311
|
+
} finally {
|
|
8312
|
+
this.prodParam.exit();
|
|
8313
|
+
}
|
|
8314
|
+
return this.parseMaybeAssign(refExpressionErrors, isParenItem);
|
|
8240
8315
|
}
|
|
8241
8316
|
setOptionalParametersError(refExpressionErrors) {
|
|
8242
8317
|
refExpressionErrors.optionalParametersLoc = this.state.startLoc;
|
|
@@ -8324,7 +8399,6 @@ var ExpressionParser = class extends LValParser {
|
|
|
8324
8399
|
const startLoc = this.state.startLoc;
|
|
8325
8400
|
const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors);
|
|
8326
8401
|
if (this.shouldExitDescending(expr)) return expr;
|
|
8327
|
-
this.state.canStartArrow = false;
|
|
8328
8402
|
return this.parseExprOp(expr, startLoc, -1);
|
|
8329
8403
|
}
|
|
8330
8404
|
isEscapedKeywordOperatorAfterLineBreak() {
|
|
@@ -8377,6 +8451,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8377
8451
|
}
|
|
8378
8452
|
parseExprOpBaseRightExpr(op, prec) {
|
|
8379
8453
|
const startLoc = this.state.startLoc;
|
|
8454
|
+
this.state.canStartArrow = false;
|
|
8380
8455
|
return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
|
|
8381
8456
|
}
|
|
8382
8457
|
parseHackPipeBody() {
|
|
@@ -8398,9 +8473,9 @@ var ExpressionParser = class extends LValParser {
|
|
|
8398
8473
|
if (!sawUnary) this.checkExponentialAfterUnary(expr);
|
|
8399
8474
|
return expr;
|
|
8400
8475
|
}
|
|
8401
|
-
const update = this.match(30);
|
|
8402
|
-
const node = this.startNode();
|
|
8403
8476
|
if (tokenIsPrefix(this.state.type)) {
|
|
8477
|
+
const update = this.match(30);
|
|
8478
|
+
const node = this.startNode();
|
|
8404
8479
|
node.operator = this.state.value;
|
|
8405
8480
|
node.prefix = true;
|
|
8406
8481
|
this.state.canStartArrow = false;
|
|
@@ -8418,8 +8493,11 @@ var ExpressionParser = class extends LValParser {
|
|
|
8418
8493
|
if (!sawUnary) this.checkExponentialAfterUnary(node);
|
|
8419
8494
|
return this.finishNode(node, "UnaryExpression");
|
|
8420
8495
|
}
|
|
8496
|
+
const result = this.finishNode(node, "UpdateExpression");
|
|
8497
|
+
this.checkLVal(result.argument, result);
|
|
8498
|
+
return result;
|
|
8421
8499
|
}
|
|
8422
|
-
const expr = this.parseUpdate(
|
|
8500
|
+
const expr = this.parseUpdate(refExpressionErrors);
|
|
8423
8501
|
if (isAwait) {
|
|
8424
8502
|
const { type } = this.state;
|
|
8425
8503
|
if ((this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(50)) && !this.isAmbiguousPrefixOrIdentifier()) {
|
|
@@ -8429,12 +8507,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8429
8507
|
}
|
|
8430
8508
|
return expr;
|
|
8431
8509
|
}
|
|
8432
|
-
parseUpdate(
|
|
8433
|
-
if (update) {
|
|
8434
|
-
const result = this.finishNode(node, "UpdateExpression");
|
|
8435
|
-
this.checkLVal(result.argument, result);
|
|
8436
|
-
return result;
|
|
8437
|
-
}
|
|
8510
|
+
parseUpdate(refExpressionErrors) {
|
|
8438
8511
|
const startLoc = this.state.startLoc;
|
|
8439
8512
|
let expr = this.parseExprSubscripts(refExpressionErrors);
|
|
8440
8513
|
if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
|
|
@@ -8546,20 +8619,25 @@ var ExpressionParser = class extends LValParser {
|
|
|
8546
8619
|
if (optionalChainMember) node.optional = optional;
|
|
8547
8620
|
if (optional) node.arguments = this.parseCallExpressionArguments();
|
|
8548
8621
|
else node.arguments = this.parseCallExpressionArguments(base.type !== "Super", node, refExpressionErrors);
|
|
8549
|
-
|
|
8550
|
-
if (maybeAsyncArrow &&
|
|
8551
|
-
|
|
8552
|
-
this.
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
this.checkExpressionErrors(refExpressionErrors, true);
|
|
8622
|
+
const finishedNode = this.finishCallExpression(node, optionalChainMember);
|
|
8623
|
+
if (maybeAsyncArrow && !optional) {
|
|
8624
|
+
const errorsLength = this.state.errors.length;
|
|
8625
|
+
const asyncArrowHead = this.parseAsyncArrowHead(startLoc);
|
|
8626
|
+
if (asyncArrowHead) {
|
|
8627
|
+
const returnTypeErrors = this.state.errors.length > errorsLength ? this.state.errors.splice(errorsLength) : void 0;
|
|
8628
|
+
state.stop = true;
|
|
8629
|
+
this.checkDestructuringPrivate(refExpressionErrors);
|
|
8630
|
+
this.expressionScope.validateAsPattern();
|
|
8559
8631
|
this.expressionScope.exit();
|
|
8632
|
+
if (returnTypeErrors) this.state.errors.push(...returnTypeErrors);
|
|
8633
|
+
return this.parseAsyncArrowFromCallExpression(asyncArrowHead, finishedNode);
|
|
8560
8634
|
}
|
|
8561
|
-
this.toReferencedList(node.arguments);
|
|
8562
8635
|
}
|
|
8636
|
+
if (maybeAsyncArrow) {
|
|
8637
|
+
this.checkExpressionErrors(refExpressionErrors, true);
|
|
8638
|
+
this.expressionScope.exit();
|
|
8639
|
+
}
|
|
8640
|
+
this.toReferencedList(node.arguments);
|
|
8563
8641
|
return finishedNode;
|
|
8564
8642
|
}
|
|
8565
8643
|
parseTaggedTemplateExpression(base, startLoc, state) {
|
|
@@ -8596,8 +8674,8 @@ var ExpressionParser = class extends LValParser {
|
|
|
8596
8674
|
}
|
|
8597
8675
|
return elts;
|
|
8598
8676
|
}
|
|
8599
|
-
|
|
8600
|
-
return this.match(15) && !this.canInsertSemicolon();
|
|
8677
|
+
parseAsyncArrowHead(startLoc) {
|
|
8678
|
+
return this.match(15) && !this.canInsertSemicolon() ? this.startNodeAt(startLoc) : void 0;
|
|
8601
8679
|
}
|
|
8602
8680
|
parseAsyncArrowFromCallExpression(node, call) {
|
|
8603
8681
|
this.resetPreviousNodeTrailingComments(call);
|
|
@@ -8763,9 +8841,11 @@ var ExpressionParser = class extends LValParser {
|
|
|
8763
8841
|
const oldLabels = this.state.labels;
|
|
8764
8842
|
this.state.labels = [];
|
|
8765
8843
|
if (isAsync) {
|
|
8844
|
+
this.expressionScope.enter(sharedExpressionScope);
|
|
8766
8845
|
this.prodParam.enter(2);
|
|
8767
8846
|
node.body = this.parseBlock();
|
|
8768
8847
|
this.prodParam.exit();
|
|
8848
|
+
this.expressionScope.exit();
|
|
8769
8849
|
} else node.body = this.parseBlock();
|
|
8770
8850
|
this.state.labels = oldLabels;
|
|
8771
8851
|
return this.finishNode(node, "DoExpression");
|
|
@@ -8811,7 +8891,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
8811
8891
|
parseImportMetaPropertyOrPhaseCallOrSyncCall(node) {
|
|
8812
8892
|
this.next();
|
|
8813
8893
|
if (this.isContextual(102) || this.isContextual(94)) {
|
|
8814
|
-
const isSource = this.
|
|
8894
|
+
const isSource = this.match(102);
|
|
8815
8895
|
this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
|
|
8816
8896
|
this.next();
|
|
8817
8897
|
node.phase = isSource ? "source" : "defer";
|
|
@@ -8904,8 +8984,8 @@ var ExpressionParser = class extends LValParser {
|
|
|
8904
8984
|
}
|
|
8905
8985
|
const innerEndLoc = this.state.lastTokEndLoc;
|
|
8906
8986
|
this.expect(7);
|
|
8907
|
-
let arrowNode
|
|
8908
|
-
if (canStartArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(
|
|
8987
|
+
let arrowNode;
|
|
8988
|
+
if (canStartArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(this.startNodeAt(startLoc)))) {
|
|
8909
8989
|
this.checkDestructuringPrivate(refExpressionErrors);
|
|
8910
8990
|
this.expressionScope.validateAsPattern();
|
|
8911
8991
|
this.expressionScope.exit();
|
|
@@ -9048,18 +9128,19 @@ var ExpressionParser = class extends LValParser {
|
|
|
9048
9128
|
}
|
|
9049
9129
|
parsePropertyDefinition(refExpressionErrors) {
|
|
9050
9130
|
const decorators = [];
|
|
9131
|
+
const decoratorsStartLoc = this.state.startLoc;
|
|
9051
9132
|
if (this.match(22)) {
|
|
9052
|
-
if (this.hasPlugin("decorators")) this.raise(Errors.UnsupportedPropertyDecorator,
|
|
9133
|
+
if (this.hasPlugin("decorators")) this.raise(Errors.UnsupportedPropertyDecorator, decoratorsStartLoc);
|
|
9053
9134
|
while (this.match(22)) decorators.push(this.parseDecorator());
|
|
9054
9135
|
}
|
|
9055
|
-
const prop = this.startNode();
|
|
9056
|
-
let isAsync = false;
|
|
9057
|
-
let isAccessor = false;
|
|
9058
|
-
let startLoc;
|
|
9059
9136
|
if (this.match(17)) {
|
|
9060
9137
|
if (decorators.length) this.unexpected();
|
|
9061
9138
|
return this.parseSpread();
|
|
9062
9139
|
}
|
|
9140
|
+
const prop = this.startNodeAt(decoratorsStartLoc);
|
|
9141
|
+
let isAsync = false;
|
|
9142
|
+
let isAccessor = false;
|
|
9143
|
+
let startLoc;
|
|
9063
9144
|
if (decorators.length) prop.decorators = decorators;
|
|
9064
9145
|
prop.method = false;
|
|
9065
9146
|
if (refExpressionErrors) startLoc = this.state.startLoc;
|
|
@@ -9312,7 +9393,10 @@ var ExpressionParser = class extends LValParser {
|
|
|
9312
9393
|
const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
|
|
9313
9394
|
if (liberal) {
|
|
9314
9395
|
if (tokenIsKeyword) this.replaceToken(131);
|
|
9315
|
-
} else
|
|
9396
|
+
} else {
|
|
9397
|
+
this.setLoc(this.state.startLoc);
|
|
9398
|
+
this.checkReservedWord(name, this.sourceToOffsetPos(start), tokenIsKeyword, false);
|
|
9399
|
+
}
|
|
9316
9400
|
this.next();
|
|
9317
9401
|
return name;
|
|
9318
9402
|
}
|
|
@@ -9399,7 +9483,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
9399
9483
|
return this.finishNode(node, "YieldExpression");
|
|
9400
9484
|
}
|
|
9401
9485
|
parseImportCall(node) {
|
|
9402
|
-
this.
|
|
9486
|
+
this.expect(6);
|
|
9403
9487
|
const args = this.parseCallExpressionArguments();
|
|
9404
9488
|
if (args.length === 0 || args.length > 2) this.raise(Errors.ImportCallArity, node, node);
|
|
9405
9489
|
else for (const arg of args) if (arg.type === "SpreadElement") this.raise(Errors.ImportCallSpreadArgument, arg, node);
|
|
@@ -9419,31 +9503,23 @@ var ExpressionParser = class extends LValParser {
|
|
|
9419
9503
|
this.state.seenTopicReference = oldSeenTopicReference;
|
|
9420
9504
|
}
|
|
9421
9505
|
}
|
|
9422
|
-
|
|
9506
|
+
enterAllowIn() {
|
|
9423
9507
|
const flags = this.prodParam.currentFlags();
|
|
9424
9508
|
if (24 & ~flags) {
|
|
9425
9509
|
this.prodParam.enter(flags | 24);
|
|
9426
|
-
|
|
9427
|
-
return callback();
|
|
9428
|
-
} finally {
|
|
9429
|
-
this.prodParam.exit();
|
|
9430
|
-
}
|
|
9510
|
+
return true;
|
|
9431
9511
|
}
|
|
9432
|
-
return
|
|
9512
|
+
return false;
|
|
9433
9513
|
}
|
|
9434
|
-
|
|
9514
|
+
enterDisallowIn() {
|
|
9435
9515
|
const flags = this.prodParam.currentFlags();
|
|
9436
9516
|
const prodParamToClear = 8 & flags;
|
|
9437
9517
|
const prodParamToSet = 16 & ~flags;
|
|
9438
9518
|
if (prodParamToClear || prodParamToSet) {
|
|
9439
9519
|
this.prodParam.enter(flags & -9 | 16);
|
|
9440
|
-
|
|
9441
|
-
return callback();
|
|
9442
|
-
} finally {
|
|
9443
|
-
this.prodParam.exit();
|
|
9444
|
-
}
|
|
9520
|
+
return true;
|
|
9445
9521
|
}
|
|
9446
|
-
return
|
|
9522
|
+
return false;
|
|
9447
9523
|
}
|
|
9448
9524
|
registerTopicReference() {
|
|
9449
9525
|
this.state.seenTopicReference = true;
|
|
@@ -10200,7 +10276,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10200
10276
|
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
|
|
10201
10277
|
}
|
|
10202
10278
|
isClassProperty() {
|
|
10203
|
-
return this.match(25) || this.match(9) || this.match(4);
|
|
10279
|
+
return this.match(25) || this.match(9) || this.match(4) || this.match(22) && this.hasPrecedingLineBreak();
|
|
10204
10280
|
}
|
|
10205
10281
|
isClassMethod() {
|
|
10206
10282
|
return this.match(6);
|
|
@@ -10678,7 +10754,8 @@ var StatementParser = class extends ExpressionParser {
|
|
|
10678
10754
|
const { local } = specifier;
|
|
10679
10755
|
if (local.type !== "Identifier") this.raise(Errors.ExportBindingIsString, specifier, {
|
|
10680
10756
|
localName: local.value,
|
|
10681
|
-
exportName
|
|
10757
|
+
exportName,
|
|
10758
|
+
typeModifierIn: node.exportKind === "type" ? "declaration" : specifier.exportKind === "type" ? "specifier" : void 0
|
|
10682
10759
|
});
|
|
10683
10760
|
else {
|
|
10684
10761
|
this.checkReservedWord(local.name, local.start, true, false);
|
|
@@ -11084,6 +11161,31 @@ function tsIsTypeCast(node) {
|
|
|
11084
11161
|
default: return false;
|
|
11085
11162
|
}
|
|
11086
11163
|
}
|
|
11164
|
+
function tsIsInvalidArrowParamsError(error, returnTypeStart) {
|
|
11165
|
+
if (error.pos >= returnTypeStart) return false;
|
|
11166
|
+
switch (error.reasonCode) {
|
|
11167
|
+
case "AwaitBindingIdentifier":
|
|
11168
|
+
case "AwaitExpressionFormalParameter":
|
|
11169
|
+
case "IllegalLanguageModeDirective":
|
|
11170
|
+
case "ParamDupe":
|
|
11171
|
+
case "StrictEvalArgumentsBinding":
|
|
11172
|
+
case "VarRedeclaration":
|
|
11173
|
+
case "YieldInParameter": return false;
|
|
11174
|
+
default: return true;
|
|
11175
|
+
}
|
|
11176
|
+
}
|
|
11177
|
+
function tsHasUnambiguousArrowParams(params) {
|
|
11178
|
+
if (!params?.length) return true;
|
|
11179
|
+
let first = params[0];
|
|
11180
|
+
if (first?.type === "AssignmentPattern" || first?.type === "AssignmentExpression") first = first.left;
|
|
11181
|
+
switch (first?.type) {
|
|
11182
|
+
case "RestElement":
|
|
11183
|
+
case "SpreadElement": return true;
|
|
11184
|
+
case "TSTypeCastExpression": return first.expression.type === "Identifier" || first.expression.type === "ThisExpression";
|
|
11185
|
+
case "Identifier": return !!first.typeAnnotation || !!first.optional;
|
|
11186
|
+
default: return false;
|
|
11187
|
+
}
|
|
11188
|
+
}
|
|
11087
11189
|
const ClassMemberModifiers = buildModifiersMap([
|
|
11088
11190
|
"declare",
|
|
11089
11191
|
"private",
|
|
@@ -11762,13 +11864,13 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11762
11864
|
return tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc ? this.tsParseTypeOperator() : this.isContextual(114) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
|
|
11763
11865
|
}
|
|
11764
11866
|
tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
|
|
11765
|
-
const
|
|
11867
|
+
const startLoc = this.state.startLoc;
|
|
11766
11868
|
const hasLeadingOperator = this.eat(operator);
|
|
11767
|
-
const
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11869
|
+
const first = parseConstituentType();
|
|
11870
|
+
if (!hasLeadingOperator && !this.match(operator)) return first;
|
|
11871
|
+
const node = this.startNodeAt(startLoc);
|
|
11872
|
+
const types = [first];
|
|
11873
|
+
while (this.eat(operator)) types.push(parseConstituentType());
|
|
11772
11874
|
node.types = types;
|
|
11773
11875
|
return this.finishNode(node, kind);
|
|
11774
11876
|
}
|
|
@@ -11820,9 +11922,10 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11820
11922
|
return this.tsInType(() => {
|
|
11821
11923
|
const t = this.startNode();
|
|
11822
11924
|
this.expect(returnToken);
|
|
11823
|
-
const
|
|
11824
|
-
const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
|
|
11925
|
+
const startLoc = this.state.startLoc;
|
|
11926
|
+
const asserts = this.match(108) && !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
|
|
11825
11927
|
if (asserts && this.match(74)) {
|
|
11928
|
+
const node = this.startNodeAt(startLoc);
|
|
11826
11929
|
let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
|
|
11827
11930
|
if (thisTypePredicate.type === "TSThisType") {
|
|
11828
11931
|
node.parameterName = thisTypePredicate;
|
|
@@ -11839,12 +11942,14 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
11839
11942
|
const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
|
|
11840
11943
|
if (!typePredicateVariable) {
|
|
11841
11944
|
if (!asserts) return this.tsParseTypeAnnotation(false, t);
|
|
11945
|
+
const node = this.startNodeAt(startLoc);
|
|
11842
11946
|
node.parameterName = this.parseIdentifier();
|
|
11843
11947
|
node.asserts = asserts;
|
|
11844
11948
|
node.typeAnnotation = null;
|
|
11845
11949
|
t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
|
|
11846
11950
|
return this.finishNode(t, "TSTypeAnnotation");
|
|
11847
11951
|
}
|
|
11952
|
+
const node = this.startNodeAt(startLoc);
|
|
11848
11953
|
const type = this.tsParseTypeAnnotation(false);
|
|
11849
11954
|
node.parameterName = typePredicateVariable;
|
|
11850
11955
|
node.typeAnnotation = type;
|
|
@@ -12217,11 +12322,15 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12217
12322
|
node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
|
|
12218
12323
|
super.parseFunctionParams(node);
|
|
12219
12324
|
node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
|
|
12325
|
+
const arrowStartPos = this.offsetToSourcePos(startLoc.index);
|
|
12326
|
+
if (node.returnType && this.match(15) && this.tsIsArrowReturnTypeRestrictedAt(arrowStartPos)) this.tsArrowReturnTypeAt.set(arrowStartPos, node.returnType.start);
|
|
12220
12327
|
this.expect(15);
|
|
12221
12328
|
return node;
|
|
12222
12329
|
});
|
|
12223
12330
|
if (!res) return;
|
|
12224
|
-
|
|
12331
|
+
const startPos = this.offsetToSourcePos(startLoc.index);
|
|
12332
|
+
const parse = () => res.returnType && this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithDeferredArrowErrors(() => super.parseArrowExpression(res, null, true)) : super.parseArrowExpression(res, null, true);
|
|
12333
|
+
return this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithRestrictedArrowReturnType(parse, this.hasPlugin("jsx") || this.state.tsArrowReturnTypeAllowed) : parse();
|
|
12225
12334
|
}
|
|
12226
12335
|
tsParseTypeArgumentsInExpression() {
|
|
12227
12336
|
if (this.reScan_lt() !== 43) return;
|
|
@@ -12334,7 +12443,8 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12334
12443
|
}
|
|
12335
12444
|
if (this.match(43) || this.match(47)) {
|
|
12336
12445
|
let missingParenErrorLoc;
|
|
12337
|
-
|
|
12446
|
+
let parsingAsyncArrow = true;
|
|
12447
|
+
const parseAttempt = () => {
|
|
12338
12448
|
if (!noCalls && this.atPossibleAsyncArrow(base)) {
|
|
12339
12449
|
const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
|
|
12340
12450
|
if (asyncArrowFn) {
|
|
@@ -12342,6 +12452,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12342
12452
|
return asyncArrowFn;
|
|
12343
12453
|
}
|
|
12344
12454
|
}
|
|
12455
|
+
parsingAsyncArrow = false;
|
|
12345
12456
|
const typeArguments = this.tsParseTypeArgumentsInExpression();
|
|
12346
12457
|
if (!typeArguments) return;
|
|
12347
12458
|
if (isOptionalCall && !this.match(6)) {
|
|
@@ -12368,7 +12479,11 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12368
12479
|
node.expression = base;
|
|
12369
12480
|
node.typeArguments = typeArguments;
|
|
12370
12481
|
return this.finishNode(node, "TSInstantiationExpression");
|
|
12371
|
-
}
|
|
12482
|
+
};
|
|
12483
|
+
const attempt = this.tryParse((abort) => parseAttempt() || abort());
|
|
12484
|
+
if (attempt.thrown && parsingAsyncArrow && this.tsShouldKeepArrowErrorAt(attempt.error, this.offsetToSourcePos(startLoc.index))) throw attempt.error;
|
|
12485
|
+
const result = attempt.node;
|
|
12486
|
+
if (result && attempt.error) this.state = attempt.failState;
|
|
12372
12487
|
if (missingParenErrorLoc) this.unexpected(missingParenErrorLoc, 6);
|
|
12373
12488
|
if (result) {
|
|
12374
12489
|
if (result.type === "TSInstantiationExpression") {
|
|
@@ -12660,17 +12775,36 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12660
12775
|
return expr;
|
|
12661
12776
|
}
|
|
12662
12777
|
}
|
|
12778
|
+
const startPos = this.offsetToSourcePos(startLoc.index);
|
|
12779
|
+
const isRestricted = this.tsIsArrowReturnTypeRestrictedAt(startPos);
|
|
12780
|
+
const allowsReturnType = isRestricted && this.state.tsArrowReturnTypeAllowed;
|
|
12663
12781
|
this.next();
|
|
12664
12782
|
const node = this.startNodeAt(startLoc);
|
|
12665
12783
|
node.test = expr;
|
|
12666
|
-
|
|
12667
|
-
this.state.inConditionalConsequent = true;
|
|
12668
|
-
node.consequent = this.parseMaybeAssignAllowIn();
|
|
12669
|
-
this.state.inConditionalConsequent = oldInConditionalConsequent;
|
|
12784
|
+
node.consequent = this.tsParseWithRestrictedArrowReturnType(() => this.parseMaybeAssignAllowIn());
|
|
12670
12785
|
this.expect(10);
|
|
12671
|
-
node.alternate = this.parseMaybeAssign();
|
|
12786
|
+
node.alternate = isRestricted ? this.tsParseWithRestrictedArrowReturnType(() => this.parseMaybeAssign(), allowsReturnType) : this.parseMaybeAssign();
|
|
12672
12787
|
return this.finishNode(node, "ConditionalExpression");
|
|
12673
12788
|
}
|
|
12789
|
+
tsIsArrowReturnTypeRestrictedAt(sourcePos) {
|
|
12790
|
+
return this.state.tsArrowReturnTypeRestrictionAt === sourcePos;
|
|
12791
|
+
}
|
|
12792
|
+
tsRestrictArrowReturnTypeAt(sourcePos, allowsReturnType, genericParams = false) {
|
|
12793
|
+
this.state.tsArrowReturnTypeRestrictionAt = sourcePos;
|
|
12794
|
+
this.state.tsArrowReturnTypeAllowed = allowsReturnType;
|
|
12795
|
+
this.state.tsGenericArrowParams = genericParams;
|
|
12796
|
+
}
|
|
12797
|
+
tsParseWithRestrictedArrowReturnType(parse, allowsReturnType = false, genericParams = false) {
|
|
12798
|
+
const oldAllowed = this.state.tsArrowReturnTypeAllowed;
|
|
12799
|
+
const oldGeneric = this.state.tsGenericArrowParams;
|
|
12800
|
+
const oldStart = this.state.tsArrowReturnTypeRestrictionAt;
|
|
12801
|
+
this.tsRestrictArrowReturnTypeAt(this.state.start, allowsReturnType, genericParams);
|
|
12802
|
+
const result = parse();
|
|
12803
|
+
this.state.tsArrowReturnTypeRestrictionAt = oldStart;
|
|
12804
|
+
this.state.tsArrowReturnTypeAllowed = oldAllowed;
|
|
12805
|
+
this.state.tsGenericArrowParams = oldGeneric;
|
|
12806
|
+
return result;
|
|
12807
|
+
}
|
|
12674
12808
|
parseParenItem(node, startLoc) {
|
|
12675
12809
|
const newNode = super.parseParenItem(node, startLoc);
|
|
12676
12810
|
if (this.eat(13)) {
|
|
@@ -12792,11 +12926,72 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12792
12926
|
this.resetEndLocation(decl.id);
|
|
12793
12927
|
}
|
|
12794
12928
|
}
|
|
12795
|
-
parseAsyncArrowFromCallExpression(node, call) {
|
|
12796
|
-
if (this.match(10)) node.returnType = this.tsParseTypeAnnotation();
|
|
12797
|
-
return super.parseAsyncArrowFromCallExpression(node, call);
|
|
12798
|
-
}
|
|
12799
12929
|
parseMaybeAssign(refExpressionErrors, isParenItem) {
|
|
12930
|
+
const startPos = this.state.start;
|
|
12931
|
+
if (!this.tsIsArrowReturnTypeRestrictedAt(startPos)) return this.tsParseMaybeAssign(refExpressionErrors, isParenItem);
|
|
12932
|
+
const oldStart = this.state.tsArrowReturnTypeRestrictionAt;
|
|
12933
|
+
const oldAllowed = this.state.tsArrowReturnTypeAllowed;
|
|
12934
|
+
const oldGeneric = this.state.tsGenericArrowParams;
|
|
12935
|
+
const node = this.match(6) || this.match(43) || this.isContextual(92) ? this.tsParseMaybeArrowWithRestrictedReturnType(startPos, refExpressionErrors, isParenItem) : this.tsParseMaybeAssign(refExpressionErrors, isParenItem);
|
|
12936
|
+
this.state.tsArrowReturnTypeRestrictionAt = oldStart;
|
|
12937
|
+
this.state.tsArrowReturnTypeAllowed = oldAllowed;
|
|
12938
|
+
this.state.tsGenericArrowParams = oldGeneric;
|
|
12939
|
+
return node;
|
|
12940
|
+
}
|
|
12941
|
+
tsParseWithDeferredArrowErrors(parse) {
|
|
12942
|
+
if (this.optionFlags & 4096) return parse();
|
|
12943
|
+
this.optionFlags |= 4096;
|
|
12944
|
+
try {
|
|
12945
|
+
return parse();
|
|
12946
|
+
} finally {
|
|
12947
|
+
this.optionFlags &= -4097;
|
|
12948
|
+
}
|
|
12949
|
+
}
|
|
12950
|
+
tsShouldKeepArrowErrorAt(error, startPos) {
|
|
12951
|
+
if (!this.tsIsArrowReturnTypeRestrictedAt(startPos)) return false;
|
|
12952
|
+
const returnTypeStart = this.tsArrowReturnTypeAt.get(startPos);
|
|
12953
|
+
return returnTypeStart !== void 0 && !tsIsInvalidArrowParamsError(error, returnTypeStart);
|
|
12954
|
+
}
|
|
12955
|
+
tsArrowReturnTypeAt = /* @__PURE__ */ new Map();
|
|
12956
|
+
tsParseMaybeArrowWithRestrictedReturnType(startPos, refExpressionErrors, isParenItem) {
|
|
12957
|
+
if (!this.noArrowAt.has(startPos)) {
|
|
12958
|
+
const allowsReturnType = this.state.tsArrowReturnTypeAllowed;
|
|
12959
|
+
const parse = () => this.tsParseMaybeAssign(refExpressionErrors, isParenItem);
|
|
12960
|
+
let state = this.state.clone();
|
|
12961
|
+
const { tokensLength } = state;
|
|
12962
|
+
this.tsArrowReturnTypeAt.delete(startPos);
|
|
12963
|
+
let result = this.tryParse(parse, state);
|
|
12964
|
+
const returnTypeStart = this.tsArrowReturnTypeAt.get(startPos);
|
|
12965
|
+
if (result.thrown && returnTypeStart !== void 0 && !tsIsInvalidArrowParamsError(result.error, returnTypeStart) && !(this.optionFlags & 4096)) {
|
|
12966
|
+
state = this.state.clone();
|
|
12967
|
+
this.optionFlags |= 4096;
|
|
12968
|
+
try {
|
|
12969
|
+
result = this.tryParse(parse, state);
|
|
12970
|
+
} finally {
|
|
12971
|
+
this.optionFlags &= -4097;
|
|
12972
|
+
}
|
|
12973
|
+
}
|
|
12974
|
+
if (result.thrown) {
|
|
12975
|
+
if (!this.tsArrowReturnTypeAt.has(startPos)) throw result.error;
|
|
12976
|
+
} else {
|
|
12977
|
+
if (result.error) this.state = result.failState;
|
|
12978
|
+
const node = result.node;
|
|
12979
|
+
if (node.type !== "ArrowFunctionExpression" || !node.returnType || node.extra?.parenthesized) return node;
|
|
12980
|
+
const { start } = node.returnType;
|
|
12981
|
+
const hasInvalidParams = result.error != null && this.state.errors.slice(state.errors.length).some((error) => tsIsInvalidArrowParamsError(error, start));
|
|
12982
|
+
const isUnambiguous = node.typeParameters ? this.hasPlugin("jsx") : tsHasUnambiguousArrowParams(node.params);
|
|
12983
|
+
if (!hasInvalidParams && (allowsReturnType || this.match(10)) || isUnambiguous && !(hasInvalidParams && node.async)) {
|
|
12984
|
+
if (result.error && !(this.optionFlags & 4096)) throw result.error;
|
|
12985
|
+
return node;
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
this.noArrowAt.add(startPos);
|
|
12989
|
+
this.state = state;
|
|
12990
|
+
this.state.tokensLength = tokensLength;
|
|
12991
|
+
}
|
|
12992
|
+
return this.tsParseMaybeAssign(refExpressionErrors, isParenItem);
|
|
12993
|
+
}
|
|
12994
|
+
tsParseMaybeAssign(refExpressionErrors, isParenItem) {
|
|
12800
12995
|
let state;
|
|
12801
12996
|
let jsx;
|
|
12802
12997
|
let typeCast;
|
|
@@ -12812,8 +13007,22 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12812
13007
|
if (!state || state === this.state) state = this.state.clone();
|
|
12813
13008
|
let typeParameters;
|
|
12814
13009
|
const arrow = this.tryParse((abort) => {
|
|
13010
|
+
const startPos = this.state.start;
|
|
13011
|
+
if (this.noArrowAt.has(startPos)) abort();
|
|
13012
|
+
const allowsReturnType = !this.match(43) || this.state.tsArrowReturnTypeAllowed;
|
|
13013
|
+
const isRestricted = this.tsIsArrowReturnTypeRestrictedAt(startPos);
|
|
12815
13014
|
typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
|
|
12816
|
-
|
|
13015
|
+
let expr;
|
|
13016
|
+
if (isRestricted) {
|
|
13017
|
+
const paramsStartPos = this.state.start;
|
|
13018
|
+
this.tsArrowReturnTypeAt.delete(paramsStartPos);
|
|
13019
|
+
try {
|
|
13020
|
+
expr = this.tsParseWithRestrictedArrowReturnType(() => super.parseMaybeAssign(refExpressionErrors, isParenItem), allowsReturnType, true);
|
|
13021
|
+
} finally {
|
|
13022
|
+
const returnTypeStart = this.tsArrowReturnTypeAt.get(paramsStartPos);
|
|
13023
|
+
if (returnTypeStart !== void 0) this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
|
|
13024
|
+
}
|
|
13025
|
+
} else expr = super.parseMaybeAssign(refExpressionErrors, isParenItem);
|
|
12817
13026
|
if (expr.type !== "ArrowFunctionExpression" || expr.extra?.parenthesized) abort();
|
|
12818
13027
|
if (typeParameters?.params.length !== 0) this.resetStartLocationFromNode(expr, typeParameters);
|
|
12819
13028
|
expr.typeParameters = typeParameters;
|
|
@@ -12823,6 +13032,13 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12823
13032
|
}
|
|
12824
13033
|
return expr;
|
|
12825
13034
|
}, state);
|
|
13035
|
+
if (jsx && arrow.node && arrow.error && !(this.optionFlags & 4096)) throw arrow.error;
|
|
13036
|
+
if (arrow.error && this.tsShouldKeepArrowErrorAt(arrow.error, state.start)) {
|
|
13037
|
+
if (!arrow.node) throw arrow.error;
|
|
13038
|
+
this.state = arrow.failState;
|
|
13039
|
+
if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
|
|
13040
|
+
return arrow.node;
|
|
13041
|
+
}
|
|
12826
13042
|
if (!arrow.error && !arrow.aborted) {
|
|
12827
13043
|
if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
|
|
12828
13044
|
return arrow.node;
|
|
@@ -12856,6 +13072,9 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12856
13072
|
}
|
|
12857
13073
|
parseArrow(node) {
|
|
12858
13074
|
if (this.match(10)) {
|
|
13075
|
+
const startPos = this.offsetToSourcePos(node.start);
|
|
13076
|
+
if (this.noArrowAt.has(startPos)) return;
|
|
13077
|
+
const returnTypeStart = this.sourceToOffsetPos(this.state.start);
|
|
12859
13078
|
const result = this.tryParse((abort) => {
|
|
12860
13079
|
const returnType = this.tsParseTypeOrTypePredicateAnnotation(10);
|
|
12861
13080
|
if (this.canInsertSemicolon() || !this.match(15)) abort();
|
|
@@ -12865,6 +13084,7 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12865
13084
|
if (!result.thrown) {
|
|
12866
13085
|
if (result.error) this.state = result.failState;
|
|
12867
13086
|
node.returnType = result.node;
|
|
13087
|
+
if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
|
|
12868
13088
|
}
|
|
12869
13089
|
}
|
|
12870
13090
|
return super.parseArrow(node);
|
|
@@ -12997,19 +13217,40 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
12997
13217
|
if (this.match(10)) return params.every((expr) => this.isAssignable(expr, true));
|
|
12998
13218
|
return super.shouldParseArrow(params);
|
|
12999
13219
|
}
|
|
13000
|
-
|
|
13001
|
-
if (this.match(10))
|
|
13002
|
-
|
|
13003
|
-
|
|
13004
|
-
|
|
13005
|
-
|
|
13220
|
+
parseAsyncArrowHead(startLoc) {
|
|
13221
|
+
if (!this.match(10)) return super.parseAsyncArrowHead(startLoc);
|
|
13222
|
+
const returnTypeStart = this.sourceToOffsetPos(this.state.start);
|
|
13223
|
+
const result = this.tryParse((abort) => {
|
|
13224
|
+
const returnType = this.tsParseTypeAnnotation();
|
|
13225
|
+
if (!this.match(15)) abort();
|
|
13226
|
+
return returnType;
|
|
13227
|
+
});
|
|
13228
|
+
if (result.aborted || result.thrown) return void 0;
|
|
13229
|
+
if (result.error) this.state = result.failState;
|
|
13230
|
+
const startPos = this.offsetToSourcePos(startLoc.index);
|
|
13231
|
+
if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
|
|
13232
|
+
const node = this.startNodeAt(startLoc);
|
|
13233
|
+
node.returnType = result.node;
|
|
13234
|
+
return node;
|
|
13006
13235
|
}
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
this.state.
|
|
13012
|
-
|
|
13236
|
+
atPossibleAsyncArrow(base) {
|
|
13237
|
+
return super.atPossibleAsyncArrow(base) && !this.noArrowAt.has(this.offsetToSourcePos(base.start));
|
|
13238
|
+
}
|
|
13239
|
+
parseMaybeConditional(refExpressionErrors) {
|
|
13240
|
+
if (!this.tsIsArrowReturnTypeRestrictedAt(this.state.start)) return super.parseMaybeConditional(refExpressionErrors);
|
|
13241
|
+
const allowsReturnType = this.state.tsArrowReturnTypeAllowed;
|
|
13242
|
+
const expr = super.parseMaybeConditional(refExpressionErrors);
|
|
13243
|
+
if (tokenIsAssignment(this.state.type)) this.tsRestrictArrowReturnTypeAt(this.nextTokenStart(), allowsReturnType);
|
|
13244
|
+
return expr;
|
|
13245
|
+
}
|
|
13246
|
+
parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
|
|
13247
|
+
const startPos = this.offsetToSourcePos(node.start);
|
|
13248
|
+
if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
|
|
13249
|
+
const genericParams = this.state.tsGenericArrowParams;
|
|
13250
|
+
const parse = () => super.parseArrowExpression(node, params, isAsync, trailingCommaLoc);
|
|
13251
|
+
return this.tsParseWithRestrictedArrowReturnType(genericParams && node.returnType ? () => this.tsParseWithDeferredArrowErrors(parse) : parse, this.state.tsArrowReturnTypeAllowed || !genericParams && tsHasUnambiguousArrowParams(params));
|
|
13252
|
+
}
|
|
13253
|
+
return super.parseArrowExpression(node, params, isAsync, trailingCommaLoc);
|
|
13013
13254
|
}
|
|
13014
13255
|
canHaveLeadingDecorator() {
|
|
13015
13256
|
return super.canHaveLeadingDecorator() || this.isAbstractClass();
|
|
@@ -13130,9 +13371,9 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
13130
13371
|
hasTypeSpecifier = true;
|
|
13131
13372
|
leftOfAs = firstAs;
|
|
13132
13373
|
}
|
|
13133
|
-
} else if (
|
|
13374
|
+
} else if (this.tsIsStartOfModuleExportName()) {
|
|
13134
13375
|
hasTypeSpecifier = true;
|
|
13135
|
-
leftOfAs = this.
|
|
13376
|
+
leftOfAs = this.parseModuleExportName();
|
|
13136
13377
|
}
|
|
13137
13378
|
node.imported = leftOfAs;
|
|
13138
13379
|
node.importKind = hasTypeSpecifier ? "type" : "value";
|
|
@@ -13145,23 +13386,26 @@ const typescript = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
13145
13386
|
const firstAs = this.parseIdentifier();
|
|
13146
13387
|
if (this.isContextual(90)) {
|
|
13147
13388
|
const secondAs = this.parseIdentifier();
|
|
13148
|
-
if (
|
|
13389
|
+
if (this.tsIsStartOfModuleExportName()) {
|
|
13149
13390
|
hasTypeSpecifier = true;
|
|
13150
13391
|
node.local = firstAs;
|
|
13151
13392
|
node.exported = this.parseModuleExportName();
|
|
13152
13393
|
} else node.exported = secondAs;
|
|
13153
|
-
} else if (
|
|
13394
|
+
} else if (this.tsIsStartOfModuleExportName()) node.exported = this.parseModuleExportName();
|
|
13154
13395
|
else {
|
|
13155
13396
|
hasTypeSpecifier = true;
|
|
13156
13397
|
node.local = firstAs;
|
|
13157
13398
|
}
|
|
13158
|
-
} else if (
|
|
13399
|
+
} else if (this.tsIsStartOfModuleExportName()) {
|
|
13159
13400
|
hasTypeSpecifier = true;
|
|
13160
13401
|
node.local = this.parseModuleExportName();
|
|
13161
13402
|
}
|
|
13162
13403
|
if (hasTypeSpecifier && isInTypeOnly) this.raise(TSErrors.TypeModifierIsUsedInTypeExports, local);
|
|
13163
13404
|
node.exportKind = hasTypeSpecifier ? "type" : "value";
|
|
13164
|
-
node.exported ??= this.eatContextual(90) ? this.parseModuleExportName() : this.cloneIdentifier(node.local);
|
|
13405
|
+
node.exported ??= this.eatContextual(90) ? this.parseModuleExportName() : this.isStringModuleExportName(node.local) ? this.cloneStringLiteral(node.local) : this.cloneIdentifier(node.local);
|
|
13406
|
+
}
|
|
13407
|
+
tsIsStartOfModuleExportName() {
|
|
13408
|
+
return tokenIsKeywordOrIdentifier(this.state.type) || this.match(133);
|
|
13165
13409
|
}
|
|
13166
13410
|
fillOptionalPropertiesForTSESLint(node) {
|
|
13167
13411
|
switch (node.type) {
|
|
@@ -15277,6 +15521,29 @@ function syncNativePropertyCommits(instance, properties) {
|
|
|
15277
15521
|
if (last?.owner === binding.owner && hasNativeDataCommit(binding.owner, binding.paths, last.revision, binding.revision)) recordNativeDataCommit(instance, [key]);
|
|
15278
15522
|
}
|
|
15279
15523
|
}
|
|
15524
|
+
// ../../mpcore/packages/simulator/src/runtime/componentInstance/propertyDiagnostics.ts
|
|
15525
|
+
const diagnostics = /* @__PURE__ */ new WeakMap();
|
|
15526
|
+
/** 使用会话所属的 console,避免将属性警告写入另一运行时。 */
|
|
15527
|
+
function attachComponentPropertyDiagnostics(instance, label, warn) {
|
|
15528
|
+
diagnostics.set(instance, {
|
|
15529
|
+
label,
|
|
15530
|
+
warn,
|
|
15531
|
+
invalidKeys: /* @__PURE__ */ new Set()
|
|
15532
|
+
});
|
|
15533
|
+
}
|
|
15534
|
+
/** 重复渲染不重复交付同一空属性;值恢复有效后允许下一次空值发出警告。 */
|
|
15535
|
+
function reportComponentPropertyValue(instance, definition, key, value) {
|
|
15536
|
+
const state = diagnostics.get(instance);
|
|
15537
|
+
if (!state) return;
|
|
15538
|
+
if (!isInvalidStringPropertyNull(definition, key, value)) {
|
|
15539
|
+
state.invalidKeys.delete(key);
|
|
15540
|
+
return;
|
|
15541
|
+
}
|
|
15542
|
+
if (!state.invalidKeys.has(key)) {
|
|
15543
|
+
state.invalidKeys.add(key);
|
|
15544
|
+
state.warn(`[Component] property "${key}" of "${state.label}" received type-uncompatible value: expected <String> but get null value. Use empty string instead.`);
|
|
15545
|
+
}
|
|
15546
|
+
}
|
|
15280
15547
|
// ../../mpcore/packages/simulator/src/runtime/componentInstance/propertyBindings.ts
|
|
15281
15548
|
const consumedPageChanges = /* @__PURE__ */ new WeakMap();
|
|
15282
15549
|
function syncComponentProperties(instance, definition, nextProperties, bindingExpressions, changedPageKeys, beforeObservers) {
|
|
@@ -15287,6 +15554,7 @@ function syncComponentProperties(instance, definition, nextProperties, bindingEx
|
|
|
15287
15554
|
const previousProperties = {};
|
|
15288
15555
|
for (const [key, value] of Object.entries(nextProperties)) {
|
|
15289
15556
|
if (!Object.hasOwn(definition.properties ?? {}, key)) continue;
|
|
15557
|
+
reportComponentPropertyValue(instance, definition, key, value);
|
|
15290
15558
|
const nextValue = normalizeComponentPropertyValue(definition, key, value);
|
|
15291
15559
|
const bindingExpression = bindingExpressions[key];
|
|
15292
15560
|
const bindingAffected = freshPageChanges && !!bindingExpression && changedPageKeys.some((changedKey) => {
|
|
@@ -20284,7 +20552,7 @@ function createComponentScope(clonedNode, scope, componentScopeId, componentInst
|
|
|
20284
20552
|
return {
|
|
20285
20553
|
alias: clonedNode.name,
|
|
20286
20554
|
classList: String(clonedNode.attribs?.class ?? "").split(CLASS_SPLIT_RE).map((item) => item.trim()).filter(Boolean),
|
|
20287
|
-
data:
|
|
20555
|
+
data: resolveComponentViewData(componentInstance),
|
|
20288
20556
|
dataOwner: componentInstance,
|
|
20289
20557
|
dataset: collectDataset(clonedNode, wxsScopeData(scope)),
|
|
20290
20558
|
...bindComponentEventHost(clonedNode),
|
|
@@ -20324,6 +20592,7 @@ function createRuntimeComponentInstance(componentScopeId, context, componentEntr
|
|
|
20324
20592
|
requestRender: (callback) => context.session.requestRender(callback)
|
|
20325
20593
|
};
|
|
20326
20594
|
const componentInstance = createComponentInstance(instanceOptions);
|
|
20595
|
+
attachComponentPropertyDiagnostics(componentInstance, componentEntry.filePath.replaceAll("\\", "/").replace(/^\/+/, "").replace(JS_FILE_RE, ""), context.moduleLoader.warn);
|
|
20327
20596
|
bindAttachmentBindingScope(componentInstance, context);
|
|
20328
20597
|
setSelectorQueryScopeId(componentInstance, componentScopeId);
|
|
20329
20598
|
componentInstance.is = componentEntry.filePath.replace(JS_FILE_RE, "");
|
|
@@ -43522,7 +43791,8 @@ function createModuleLoader(registries, getCurrentPages, getApp, wxDriver, optio
|
|
|
43522
43791
|
if (!definition) throw new Error(`Component() was not registered for id "${id}" while executing ${normalize(filePath)}.`);
|
|
43523
43792
|
return definition;
|
|
43524
43793
|
},
|
|
43525
|
-
wx: executionContext.wx
|
|
43794
|
+
wx: executionContext.wx,
|
|
43795
|
+
warn: (message) => executionContext.console.warn(message)
|
|
43526
43796
|
};
|
|
43527
43797
|
return loader;
|
|
43528
43798
|
}
|
|
@@ -44999,7 +45269,7 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
44999
45269
|
};
|
|
45000
45270
|
},
|
|
45001
45271
|
getImageInfo(option) {
|
|
45002
|
-
const fileContent = files.get(option.src);
|
|
45272
|
+
const fileContent = files.get(normalizeFsPath(option.src)) ?? options.readPackageFile?.(option.src);
|
|
45003
45273
|
if (fileContent == null) throw new Error(`getImageInfo:fail file not found: ${option.src}`);
|
|
45004
45274
|
const size = inferImageSize(readArtifactText(fileContent));
|
|
45005
45275
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/miniprogram-automator",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.4-dev.20261114.1",
|
|
5
5
|
"description": "完全兼容微信 miniprogram-automator 的现代化替代实现",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -49,13 +49,14 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@types/ws": "^8.18.2",
|
|
52
|
-
"@weapp-vite/qr": "1.2.
|
|
52
|
+
"@weapp-vite/qr": "1.2.4-dev.20261114.1",
|
|
53
53
|
"obug": "^3.0.0",
|
|
54
|
-
"ws": "^8.
|
|
54
|
+
"ws": "^8.23.0"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public",
|
|
58
|
-
"registry": "https://registry.npmjs.org"
|
|
58
|
+
"registry": "https://registry.npmjs.org/",
|
|
59
|
+
"tag": "snapshot-nightly"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"sharp": "^0.35.5"
|
|
@@ -66,6 +67,13 @@
|
|
|
66
67
|
"moduleResolution": "NodeNext"
|
|
67
68
|
}
|
|
68
69
|
},
|
|
70
|
+
"repoctlSnapshot": {
|
|
71
|
+
"kind": "nightly",
|
|
72
|
+
"commit": "b098ea06ce1752679ffdec07228f9284afa14e5f",
|
|
73
|
+
"buildId": "43546123322-1",
|
|
74
|
+
"identityKey": "c32ae1660ff7f54fdbceae9a78aca56a1df42331ce90b77e87135036cf7e8a1a",
|
|
75
|
+
"tag": "snapshot-nightly"
|
|
76
|
+
},
|
|
69
77
|
"scripts": {
|
|
70
78
|
"dev": "tsdown -w --sourcemap",
|
|
71
79
|
"build": "tsdown",
|
|
@@ -77,4 +85,4 @@
|
|
|
77
85
|
"lint": "eslint .",
|
|
78
86
|
"lint:fix": "eslint . --fix"
|
|
79
87
|
}
|
|
80
|
-
}
|
|
88
|
+
}
|