poe-code 14.0.59 → 14.0.60
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.js +53 -43
- package/dist/index.js.map +2 -2
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-YZGYOQK3.js → chunk-C7UCTQDN.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-D4YY44EF.js → chunk-MKJBQPBH.js} +54 -44
- package/packages/safe-js/dist/chunks/chunk-MKJBQPBH.js.map +7 -0
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/parse/parser.js +45 -42
- package/packages/safe-js/dist/chunks/chunk-D4YY44EF.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-YZGYOQK3.js.map → chunk-C7UCTQDN.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -122161,9 +122161,6 @@ function parseTokens(tokens, compilation) {
|
|
|
122161
122161
|
function parseModuleTokens(tokens, compilation) {
|
|
122162
122162
|
return new Parser(tokens, compilation).parseModule();
|
|
122163
122163
|
}
|
|
122164
|
-
function parseExpressionTokens(tokens, compilation) {
|
|
122165
|
-
return new Parser(tokens, compilation).parseExpressionOnly();
|
|
122166
|
-
}
|
|
122167
122164
|
function createIdentifier2(token) {
|
|
122168
122165
|
return {
|
|
122169
122166
|
type: "Identifier",
|
|
@@ -122451,7 +122448,7 @@ function createLiteralFromToken(token) {
|
|
|
122451
122448
|
}
|
|
122452
122449
|
return createKeywordLiteral(token);
|
|
122453
122450
|
}
|
|
122454
|
-
function createTemplateLiteral(token, options
|
|
122451
|
+
function createTemplateLiteral(token, options, compilation) {
|
|
122455
122452
|
const raw = token.value;
|
|
122456
122453
|
const expressions = [];
|
|
122457
122454
|
const quasis = [];
|
|
@@ -122471,6 +122468,7 @@ function createTemplateLiteral(token, options = { allowMalformedEscapes: false }
|
|
|
122471
122468
|
parseEmbeddedExpression(
|
|
122472
122469
|
raw.slice(expressionStart, expressionEnd),
|
|
122473
122470
|
positionWithinRaw(token.start, raw, expressionStart),
|
|
122471
|
+
options.functionContext,
|
|
122474
122472
|
compilation
|
|
122475
122473
|
)
|
|
122476
122474
|
);
|
|
@@ -122833,13 +122831,13 @@ function decodeHexEscape(value, start) {
|
|
|
122833
122831
|
end: index + 2
|
|
122834
122832
|
};
|
|
122835
122833
|
}
|
|
122836
|
-
function parseEmbeddedExpression(source, base, compilation) {
|
|
122834
|
+
function parseEmbeddedExpression(source, base, functionContext, compilation) {
|
|
122837
122835
|
const tokens = tokenize3(source, { allowRegexLiterals: true, compilation }).map((token) => ({
|
|
122838
122836
|
...token,
|
|
122839
122837
|
start: rebasePosition(token.start, base),
|
|
122840
122838
|
end: rebasePosition(token.end, base)
|
|
122841
122839
|
}));
|
|
122842
|
-
return
|
|
122840
|
+
return new Parser(tokens, compilation, functionContext).parseExpressionOnly();
|
|
122843
122841
|
}
|
|
122844
122842
|
function findRegexLiteral(node) {
|
|
122845
122843
|
if (node === null || node === void 0) {
|
|
@@ -123024,19 +123022,20 @@ var init_parser3 = __esm({
|
|
|
123024
123022
|
"while"
|
|
123025
123023
|
]);
|
|
123026
123024
|
Parser = class {
|
|
123027
|
-
constructor(tokens, compilation) {
|
|
123025
|
+
constructor(tokens, compilation, functionContext = "normal") {
|
|
123028
123026
|
this.tokens = tokens;
|
|
123029
123027
|
this.compilation = compilation;
|
|
123028
|
+
this.functionContext = functionContext;
|
|
123030
123029
|
this.functionScopes.add(this.scopes[0]);
|
|
123031
123030
|
}
|
|
123032
123031
|
tokens;
|
|
123033
123032
|
compilation;
|
|
123033
|
+
functionContext;
|
|
123034
123034
|
index = 0;
|
|
123035
123035
|
breakableDepth = 0;
|
|
123036
123036
|
conditionalExpressionDepth = 0;
|
|
123037
123037
|
ifStatementDepth = 0;
|
|
123038
123038
|
loopDepth = 0;
|
|
123039
|
-
generatorBody = false;
|
|
123040
123039
|
scopes = [/* @__PURE__ */ new Map()];
|
|
123041
123040
|
functionScopes = /* @__PURE__ */ new WeakSet();
|
|
123042
123041
|
varNames = /* @__PURE__ */ new WeakMap();
|
|
@@ -123222,9 +123221,9 @@ var init_parser3 = __esm({
|
|
|
123222
123221
|
}
|
|
123223
123222
|
parseArrowFunctionBody(params) {
|
|
123224
123223
|
if (this.currentToken().type === "punctuator" && this.currentToken().value === "{") {
|
|
123225
|
-
return this.withFunctionContext(
|
|
123224
|
+
return this.withFunctionContext("normal", () => this.parseBlockStatement(params));
|
|
123226
123225
|
}
|
|
123227
|
-
return this.withFunctionContext(
|
|
123226
|
+
return this.withFunctionContext("normal", () => this.parseExpression().node);
|
|
123228
123227
|
}
|
|
123229
123228
|
parseBlockStatement(params, catchParam) {
|
|
123230
123229
|
const start = this.expectPunctuator("{");
|
|
@@ -123828,7 +123827,7 @@ var init_parser3 = __esm({
|
|
|
123828
123827
|
return parsedParams;
|
|
123829
123828
|
});
|
|
123830
123829
|
const generator = generatorToken !== void 0;
|
|
123831
|
-
const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
|
|
123830
|
+
const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
|
|
123832
123831
|
return {
|
|
123833
123832
|
type: "FunctionDeclaration",
|
|
123834
123833
|
async: asyncToken !== void 0,
|
|
@@ -123863,32 +123862,34 @@ var init_parser3 = __esm({
|
|
|
123863
123862
|
};
|
|
123864
123863
|
}
|
|
123865
123864
|
parseArrowParameters() {
|
|
123866
|
-
this.
|
|
123867
|
-
|
|
123868
|
-
|
|
123869
|
-
|
|
123870
|
-
|
|
123871
|
-
while (true) {
|
|
123872
|
-
const param = this.parseBindingElement();
|
|
123873
|
-
params.push(param);
|
|
123874
|
-
const comma = this.consumePunctuator(",");
|
|
123875
|
-
if (comma === void 0) {
|
|
123876
|
-
break;
|
|
123865
|
+
return this.withFunctionContext("parameters", () => {
|
|
123866
|
+
this.expectPunctuator("(");
|
|
123867
|
+
const params = [];
|
|
123868
|
+
if (this.consumePunctuator(")") !== void 0) {
|
|
123869
|
+
return params;
|
|
123877
123870
|
}
|
|
123878
|
-
|
|
123871
|
+
while (true) {
|
|
123872
|
+
const param = this.parseBindingElement();
|
|
123873
|
+
params.push(param);
|
|
123874
|
+
const comma = this.consumePunctuator(",");
|
|
123875
|
+
if (comma === void 0) {
|
|
123876
|
+
break;
|
|
123877
|
+
}
|
|
123878
|
+
if (param.type === "RestElement") {
|
|
123879
|
+
if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
|
|
123880
|
+
throw unexpectedTokenError(comma);
|
|
123881
|
+
}
|
|
123882
|
+
throw new Error(
|
|
123883
|
+
`Rest element must be the last parameter at line ${comma.start.line}, column ${comma.start.column}.`
|
|
123884
|
+
);
|
|
123885
|
+
}
|
|
123879
123886
|
if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
|
|
123880
|
-
|
|
123887
|
+
break;
|
|
123881
123888
|
}
|
|
123882
|
-
throw new Error(
|
|
123883
|
-
`Rest element must be the last parameter at line ${comma.start.line}, column ${comma.start.column}.`
|
|
123884
|
-
);
|
|
123885
|
-
}
|
|
123886
|
-
if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
|
|
123887
|
-
break;
|
|
123888
123889
|
}
|
|
123889
|
-
|
|
123890
|
-
|
|
123891
|
-
|
|
123890
|
+
this.expectPunctuator(")");
|
|
123891
|
+
return params;
|
|
123892
|
+
});
|
|
123892
123893
|
}
|
|
123893
123894
|
parseBindingElement() {
|
|
123894
123895
|
if (this.consumePunctuator("...") !== void 0) {
|
|
@@ -124442,7 +124443,7 @@ var init_parser3 = __esm({
|
|
|
124442
124443
|
};
|
|
124443
124444
|
}
|
|
124444
124445
|
if (token.type === "keyword" && token.value === "yield") {
|
|
124445
|
-
if (
|
|
124446
|
+
if (this.functionContext !== "generator") {
|
|
124446
124447
|
throw new Error(
|
|
124447
124448
|
`yield is only valid inside a generator body at line ${token.start.line}, column ${token.start.column}.`
|
|
124448
124449
|
);
|
|
@@ -124469,11 +124470,16 @@ var init_parser3 = __esm({
|
|
|
124469
124470
|
};
|
|
124470
124471
|
}
|
|
124471
124472
|
if (token.type === "keyword" && token.value === "await") {
|
|
124472
|
-
if (this.
|
|
124473
|
+
if (this.functionContext === "generator") {
|
|
124473
124474
|
throw new Error(
|
|
124474
124475
|
`generators cannot await; use a regular async function at line ${token.start.line}, column ${token.start.column}.`
|
|
124475
124476
|
);
|
|
124476
124477
|
}
|
|
124478
|
+
if (this.functionContext === "parameters") {
|
|
124479
|
+
throw new Error(
|
|
124480
|
+
`await is not valid in function parameters at line ${token.start.line}, column ${token.start.column}.`
|
|
124481
|
+
);
|
|
124482
|
+
}
|
|
124477
124483
|
this.index += 1;
|
|
124478
124484
|
const argument = this.parseUnaryExpression();
|
|
124479
124485
|
return {
|
|
@@ -124598,7 +124604,7 @@ var init_parser3 = __esm({
|
|
|
124598
124604
|
if (this.currentToken().type === "template") {
|
|
124599
124605
|
const quasi = createTemplateLiteral(
|
|
124600
124606
|
this.currentToken(),
|
|
124601
|
-
{ allowMalformedEscapes: true },
|
|
124607
|
+
{ allowMalformedEscapes: true, functionContext: this.functionContext },
|
|
124602
124608
|
this.compilation
|
|
124603
124609
|
);
|
|
124604
124610
|
this.index += 1;
|
|
@@ -124685,7 +124691,11 @@ var init_parser3 = __esm({
|
|
|
124685
124691
|
if (token.type === "template") {
|
|
124686
124692
|
this.index += 1;
|
|
124687
124693
|
return {
|
|
124688
|
-
node: createTemplateLiteral(
|
|
124694
|
+
node: createTemplateLiteral(
|
|
124695
|
+
token,
|
|
124696
|
+
{ allowMalformedEscapes: false, functionContext: this.functionContext },
|
|
124697
|
+
this.compilation
|
|
124698
|
+
),
|
|
124689
124699
|
parenthesized: false
|
|
124690
124700
|
};
|
|
124691
124701
|
}
|
|
@@ -124801,7 +124811,7 @@ var init_parser3 = __esm({
|
|
|
124801
124811
|
return parsedParams;
|
|
124802
124812
|
});
|
|
124803
124813
|
const generator = generatorToken !== void 0;
|
|
124804
|
-
const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
|
|
124814
|
+
const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
|
|
124805
124815
|
return {
|
|
124806
124816
|
type: "FunctionExpression",
|
|
124807
124817
|
async: asyncToken !== void 0,
|
|
@@ -125045,7 +125055,7 @@ var init_parser3 = __esm({
|
|
|
125045
125055
|
}
|
|
125046
125056
|
return parsedParams;
|
|
125047
125057
|
});
|
|
125048
|
-
const body = this.withFunctionContext(
|
|
125058
|
+
const body = this.withFunctionContext("normal", () => this.parseBlockStatement(params));
|
|
125049
125059
|
return {
|
|
125050
125060
|
type: "FunctionExpression",
|
|
125051
125061
|
async: asyncToken !== void 0,
|
|
@@ -125450,19 +125460,19 @@ var init_parser3 = __esm({
|
|
|
125450
125460
|
hasReturnArgument(returnToken, nextToken) {
|
|
125451
125461
|
return !(hasLineBreakBetween(returnToken, nextToken) || nextToken.type === "punctuator" && (nextToken.value === ";" || nextToken.value === "}") || nextToken.type === "eof");
|
|
125452
125462
|
}
|
|
125453
|
-
withFunctionContext(
|
|
125463
|
+
withFunctionContext(functionContext, callback) {
|
|
125454
125464
|
const previousBreakableDepth = this.breakableDepth;
|
|
125455
125465
|
const previousLoopDepth = this.loopDepth;
|
|
125456
|
-
const
|
|
125466
|
+
const previousFunctionContext = this.functionContext;
|
|
125457
125467
|
this.breakableDepth = 0;
|
|
125458
125468
|
this.loopDepth = 0;
|
|
125459
|
-
this.
|
|
125469
|
+
this.functionContext = functionContext;
|
|
125460
125470
|
try {
|
|
125461
125471
|
return callback();
|
|
125462
125472
|
} finally {
|
|
125463
125473
|
this.breakableDepth = previousBreakableDepth;
|
|
125464
125474
|
this.loopDepth = previousLoopDepth;
|
|
125465
|
-
this.
|
|
125475
|
+
this.functionContext = previousFunctionContext;
|
|
125466
125476
|
}
|
|
125467
125477
|
}
|
|
125468
125478
|
withLoopContext(callback) {
|