@next-core/cook 2.4.0 → 2.4.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/cjs/cook.js +18 -5
- package/dist/cjs/cook.js.map +1 -1
- package/dist/cjs/precook.js +8 -0
- package/dist/cjs/precook.js.map +1 -1
- package/dist/esm/cook.js +16 -5
- package/dist/esm/cook.js.map +1 -1
- package/dist/esm/precook.js +8 -0
- package/dist/esm/precook.js.map +1 -1
- package/dist/types/cook.d.ts +3 -0
- package/dist/types/precook.d.ts +2 -1
- package/package.json +2 -2
package/dist/cjs/cook.js
CHANGED
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.__dev_only_clearGlobalExecutionContextStack = __dev_only_clearGlobalExecutionContextStack;
|
|
7
|
+
exports.__dev_only_getGlobalExecutionContextStack = __dev_only_getGlobalExecutionContextStack;
|
|
6
8
|
exports.cook = cook;
|
|
7
9
|
var _contextFree = require("./context-free.js");
|
|
8
10
|
var _ExecutionContext = require("./ExecutionContext.js");
|
|
9
11
|
var _sanitize = require("./sanitize.js");
|
|
10
12
|
var _traverse = require("./traverse.js");
|
|
13
|
+
const globalExecutionContextStack = [];
|
|
14
|
+
function __dev_only_clearGlobalExecutionContextStack() {
|
|
15
|
+
globalExecutionContextStack.length = 0;
|
|
16
|
+
}
|
|
17
|
+
function __dev_only_getGlobalExecutionContextStack() {
|
|
18
|
+
return globalExecutionContextStack;
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
/** For next-core internal usage only. */
|
|
12
22
|
function cook(rootAst, codeSource, {
|
|
13
23
|
rules,
|
|
@@ -60,7 +70,7 @@ function cook(rootAst, codeSource, {
|
|
|
60
70
|
var _hooks$beforeEvaluate, _hooks$beforeBranch2;
|
|
61
71
|
(_hooks$beforeEvaluate = hooks.beforeEvaluate) === null || _hooks$beforeEvaluate === void 0 || _hooks$beforeEvaluate.call(hooks, node);
|
|
62
72
|
currentNode = node;
|
|
63
|
-
if (debug && (forceYield || node.type.endsWith("Statement") && node.type !== "TryStatement" && node.type !== "BlockStatement" && node.type !== "ForStatement" && node.type !== "ForInStatement" && node.type !== "ForOfStatement")) {
|
|
73
|
+
if (debug && (forceYield || node.type.endsWith("Statement") && !(node.type === "ExpressionStatement" && (node.expression.type === "CallExpression" || node.expression.type === "TaggedTemplateExpression")) && node.type !== "TryStatement" && node.type !== "BlockStatement" && node.type !== "DoWhileStatement" && node.type !== "WhileStatement" && node.type !== "ForStatement" && node.type !== "ForInStatement" && node.type !== "ForOfStatement")) {
|
|
64
74
|
yield;
|
|
65
75
|
}
|
|
66
76
|
// Expressions:
|
|
@@ -442,7 +452,7 @@ function cook(rootAst, codeSource, {
|
|
|
442
452
|
}
|
|
443
453
|
} else if (declarator.id.type === "Identifier") {
|
|
444
454
|
currentNode = declarator.init;
|
|
445
|
-
if (debug) yield;
|
|
455
|
+
if (debug && currentNode.type !== "CallExpression" && currentNode.type !== "TaggedTemplateExpression") yield;
|
|
446
456
|
const bindingId = declarator.id.name;
|
|
447
457
|
const lhs = ResolveBinding(bindingId);
|
|
448
458
|
let value;
|
|
@@ -455,7 +465,7 @@ function cook(rootAst, codeSource, {
|
|
|
455
465
|
result = node.kind === "var" ? (0, _contextFree.PutValue)(lhs, value) : (0, _contextFree.InitializeReferencedBinding)(lhs, value);
|
|
456
466
|
} else {
|
|
457
467
|
currentNode = declarator.init;
|
|
458
|
-
if (debug) yield;
|
|
468
|
+
if (debug && currentNode.type !== "CallExpression" && currentNode.type !== "TaggedTemplateExpression") yield;
|
|
459
469
|
const rhs = yield* Evaluate(declarator.init);
|
|
460
470
|
const rval = (0, _contextFree.GetValue)(rhs);
|
|
461
471
|
result = yield* BindingInitialization(declarator.id, rval, node.kind === "var" ? undefined : getRunningContext().LexicalEnvironment);
|
|
@@ -588,7 +598,7 @@ function cook(rootAst, codeSource, {
|
|
|
588
598
|
let V;
|
|
589
599
|
// eslint-disable-next-line no-constant-condition
|
|
590
600
|
while (true) {
|
|
591
|
-
const exprValue = (0, _contextFree.GetValue)(yield* Evaluate(node.test));
|
|
601
|
+
const exprValue = (0, _contextFree.GetValue)(yield* Evaluate(node.test, undefined, true));
|
|
592
602
|
if (!exprValue) {
|
|
593
603
|
return (0, _ExecutionContext.NormalCompletion)(V);
|
|
594
604
|
}
|
|
@@ -615,7 +625,7 @@ function cook(rootAst, codeSource, {
|
|
|
615
625
|
if (stmtResult.Value !== _ExecutionContext.Empty) {
|
|
616
626
|
V = stmtResult.Value;
|
|
617
627
|
}
|
|
618
|
-
const exprValue = (0, _contextFree.GetValue)(yield* Evaluate(node.test));
|
|
628
|
+
const exprValue = (0, _contextFree.GetValue)(yield* Evaluate(node.test, undefined, true));
|
|
619
629
|
if (!exprValue) {
|
|
620
630
|
return (0, _ExecutionContext.NormalCompletion)(V);
|
|
621
631
|
}
|
|
@@ -952,6 +962,7 @@ function cook(rootAst, codeSource, {
|
|
|
952
962
|
|
|
953
963
|
// https://tc39.es/ecma262/#sec-evaluate-property-access-with-identifier-key
|
|
954
964
|
function EvaluatePropertyAccessWithIdentifierKey(baseValue, identifier, strict) {
|
|
965
|
+
currentNode = identifier;
|
|
955
966
|
const propertyNameString = identifier.name;
|
|
956
967
|
return new _ExecutionContext.ReferenceRecord(baseValue, propertyNameString, strict);
|
|
957
968
|
}
|
|
@@ -1062,6 +1073,7 @@ function cook(rootAst, codeSource, {
|
|
|
1062
1073
|
};
|
|
1063
1074
|
}
|
|
1064
1075
|
executionContextStack.pop();
|
|
1076
|
+
globalExecutionContextStack.pop();
|
|
1065
1077
|
if (result.Type === "return") {
|
|
1066
1078
|
return result.Value;
|
|
1067
1079
|
}
|
|
@@ -1076,6 +1088,7 @@ function cook(rootAst, codeSource, {
|
|
|
1076
1088
|
calleeContext.VariableEnvironment = localEnv;
|
|
1077
1089
|
calleeContext.LexicalEnvironment = localEnv;
|
|
1078
1090
|
executionContextStack.push(calleeContext);
|
|
1091
|
+
globalExecutionContextStack.push(calleeContext);
|
|
1079
1092
|
return calleeContext;
|
|
1080
1093
|
}
|
|
1081
1094
|
function OrdinaryCallBindThis(F, calleeContext, thisArgument) {
|