jslike 1.6.2 → 1.6.3
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/esm/interpreter/index.js +2 -1
- package/dist/esm/interpreter/interpreter.js +21 -2
- package/dist/index.cjs +22 -3
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +22 -3
- package/package.json +1 -1
|
@@ -102,7 +102,8 @@ export class WangInterpreter {
|
|
|
102
102
|
// Prepare execution options
|
|
103
103
|
const options = {
|
|
104
104
|
moduleResolver: this.moduleResolver,
|
|
105
|
-
executionController: userOptions.executionController
|
|
105
|
+
executionController: userOptions.executionController,
|
|
106
|
+
abortSignal: userOptions.abortSignal // Pass abort signal to interpreter for cancellation support
|
|
106
107
|
// sourceType will be auto-detected from code
|
|
107
108
|
};
|
|
108
109
|
|
|
@@ -158,10 +158,11 @@ export class Interpreter {
|
|
|
158
158
|
return undefined;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
const
|
|
161
|
+
const rawArgs = [];
|
|
162
162
|
for (const arg of node.arguments) {
|
|
163
|
-
|
|
163
|
+
rawArgs.push(await this.evaluateAsync(arg, env));
|
|
164
164
|
}
|
|
165
|
+
const args = this.flattenSpreadArgs(rawArgs);
|
|
165
166
|
|
|
166
167
|
if (typeof callee === 'function') {
|
|
167
168
|
if (thisContext !== undefined) {
|
|
@@ -656,6 +657,24 @@ export class Interpreter {
|
|
|
656
657
|
return this.normalizeJSXText(node.value);
|
|
657
658
|
}
|
|
658
659
|
|
|
660
|
+
// For SpreadElement - return spread marker for flattenSpreadArgs
|
|
661
|
+
if (node.type === 'SpreadElement') {
|
|
662
|
+
const arg = await this.evaluateAsync(node.argument, env);
|
|
663
|
+
if (Array.isArray(arg)) {
|
|
664
|
+
return { __spread: true, __values: arg };
|
|
665
|
+
}
|
|
666
|
+
if (typeof arg === 'string') {
|
|
667
|
+
return { __spread: true, __values: [...arg] };
|
|
668
|
+
}
|
|
669
|
+
if (arg !== null && arg !== undefined && typeof arg[Symbol.iterator] === 'function') {
|
|
670
|
+
return { __spread: true, __values: [...arg] };
|
|
671
|
+
}
|
|
672
|
+
if (typeof arg === 'object' && arg !== null) {
|
|
673
|
+
return { __spread: true, __values: Object.entries(arg) };
|
|
674
|
+
}
|
|
675
|
+
throw new TypeError('Spread syntax requires an iterable');
|
|
676
|
+
}
|
|
677
|
+
|
|
659
678
|
// Only leaf nodes should fall through to sync evaluate
|
|
660
679
|
// These have no sub-expressions that could contain await
|
|
661
680
|
if (['Literal', 'Identifier', 'BreakStatement', 'ContinueStatement',
|
package/dist/index.cjs
CHANGED
|
@@ -6589,10 +6589,11 @@ var Interpreter = class _Interpreter {
|
|
|
6589
6589
|
if (node.optional && (callee === null || callee === void 0)) {
|
|
6590
6590
|
return void 0;
|
|
6591
6591
|
}
|
|
6592
|
-
const
|
|
6592
|
+
const rawArgs = [];
|
|
6593
6593
|
for (const arg of node.arguments) {
|
|
6594
|
-
|
|
6594
|
+
rawArgs.push(await this.evaluateAsync(arg, env));
|
|
6595
6595
|
}
|
|
6596
|
+
const args = this.flattenSpreadArgs(rawArgs);
|
|
6596
6597
|
if (typeof callee === "function") {
|
|
6597
6598
|
if (thisContext !== void 0) {
|
|
6598
6599
|
return await callee.call(thisContext, ...args);
|
|
@@ -6994,6 +6995,22 @@ var Interpreter = class _Interpreter {
|
|
|
6994
6995
|
if (node.type === "JSXText") {
|
|
6995
6996
|
return this.normalizeJSXText(node.value);
|
|
6996
6997
|
}
|
|
6998
|
+
if (node.type === "SpreadElement") {
|
|
6999
|
+
const arg = await this.evaluateAsync(node.argument, env);
|
|
7000
|
+
if (Array.isArray(arg)) {
|
|
7001
|
+
return { __spread: true, __values: arg };
|
|
7002
|
+
}
|
|
7003
|
+
if (typeof arg === "string") {
|
|
7004
|
+
return { __spread: true, __values: [...arg] };
|
|
7005
|
+
}
|
|
7006
|
+
if (arg !== null && arg !== void 0 && typeof arg[Symbol.iterator] === "function") {
|
|
7007
|
+
return { __spread: true, __values: [...arg] };
|
|
7008
|
+
}
|
|
7009
|
+
if (typeof arg === "object" && arg !== null) {
|
|
7010
|
+
return { __spread: true, __values: Object.entries(arg) };
|
|
7011
|
+
}
|
|
7012
|
+
throw new TypeError("Spread syntax requires an iterable");
|
|
7013
|
+
}
|
|
6997
7014
|
if ([
|
|
6998
7015
|
"Literal",
|
|
6999
7016
|
"Identifier",
|
|
@@ -8885,7 +8902,9 @@ var WangInterpreter = class {
|
|
|
8885
8902
|
const hasTopLevelReturn = this.hasTopLevelReturn(code);
|
|
8886
8903
|
const options = {
|
|
8887
8904
|
moduleResolver: this.moduleResolver,
|
|
8888
|
-
executionController: userOptions.executionController
|
|
8905
|
+
executionController: userOptions.executionController,
|
|
8906
|
+
abortSignal: userOptions.abortSignal
|
|
8907
|
+
// Pass abort signal to interpreter for cancellation support
|
|
8889
8908
|
// sourceType will be auto-detected from code
|
|
8890
8909
|
};
|
|
8891
8910
|
let result;
|
package/dist/index.d.cts
CHANGED
|
@@ -7323,10 +7323,11 @@ class Interpreter {
|
|
|
7323
7323
|
return undefined;
|
|
7324
7324
|
}
|
|
7325
7325
|
|
|
7326
|
-
const
|
|
7326
|
+
const rawArgs = [];
|
|
7327
7327
|
for (const arg of node.arguments) {
|
|
7328
|
-
|
|
7328
|
+
rawArgs.push(await this.evaluateAsync(arg, env));
|
|
7329
7329
|
}
|
|
7330
|
+
const args = this.flattenSpreadArgs(rawArgs);
|
|
7330
7331
|
|
|
7331
7332
|
if (typeof callee === 'function') {
|
|
7332
7333
|
if (thisContext !== undefined) {
|
|
@@ -7821,6 +7822,24 @@ class Interpreter {
|
|
|
7821
7822
|
return this.normalizeJSXText(node.value);
|
|
7822
7823
|
}
|
|
7823
7824
|
|
|
7825
|
+
// For SpreadElement - return spread marker for flattenSpreadArgs
|
|
7826
|
+
if (node.type === 'SpreadElement') {
|
|
7827
|
+
const arg = await this.evaluateAsync(node.argument, env);
|
|
7828
|
+
if (Array.isArray(arg)) {
|
|
7829
|
+
return { __spread: true, __values: arg };
|
|
7830
|
+
}
|
|
7831
|
+
if (typeof arg === 'string') {
|
|
7832
|
+
return { __spread: true, __values: [...arg] };
|
|
7833
|
+
}
|
|
7834
|
+
if (arg !== null && arg !== undefined && typeof arg[Symbol.iterator] === 'function') {
|
|
7835
|
+
return { __spread: true, __values: [...arg] };
|
|
7836
|
+
}
|
|
7837
|
+
if (typeof arg === 'object' && arg !== null) {
|
|
7838
|
+
return { __spread: true, __values: Object.entries(arg) };
|
|
7839
|
+
}
|
|
7840
|
+
throw new TypeError('Spread syntax requires an iterable');
|
|
7841
|
+
}
|
|
7842
|
+
|
|
7824
7843
|
// Only leaf nodes should fall through to sync evaluate
|
|
7825
7844
|
// These have no sub-expressions that could contain await
|
|
7826
7845
|
if (['Literal', 'Identifier', 'BreakStatement', 'ContinueStatement',
|
|
@@ -10328,7 +10347,8 @@ class WangInterpreter {
|
|
|
10328
10347
|
// Prepare execution options
|
|
10329
10348
|
const options = {
|
|
10330
10349
|
moduleResolver: this.moduleResolver,
|
|
10331
|
-
executionController: userOptions.executionController
|
|
10350
|
+
executionController: userOptions.executionController,
|
|
10351
|
+
abortSignal: userOptions.abortSignal // Pass abort signal to interpreter for cancellation support
|
|
10332
10352
|
// sourceType will be auto-detected from code
|
|
10333
10353
|
};
|
|
10334
10354
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7323,10 +7323,11 @@ class Interpreter {
|
|
|
7323
7323
|
return undefined;
|
|
7324
7324
|
}
|
|
7325
7325
|
|
|
7326
|
-
const
|
|
7326
|
+
const rawArgs = [];
|
|
7327
7327
|
for (const arg of node.arguments) {
|
|
7328
|
-
|
|
7328
|
+
rawArgs.push(await this.evaluateAsync(arg, env));
|
|
7329
7329
|
}
|
|
7330
|
+
const args = this.flattenSpreadArgs(rawArgs);
|
|
7330
7331
|
|
|
7331
7332
|
if (typeof callee === 'function') {
|
|
7332
7333
|
if (thisContext !== undefined) {
|
|
@@ -7821,6 +7822,24 @@ class Interpreter {
|
|
|
7821
7822
|
return this.normalizeJSXText(node.value);
|
|
7822
7823
|
}
|
|
7823
7824
|
|
|
7825
|
+
// For SpreadElement - return spread marker for flattenSpreadArgs
|
|
7826
|
+
if (node.type === 'SpreadElement') {
|
|
7827
|
+
const arg = await this.evaluateAsync(node.argument, env);
|
|
7828
|
+
if (Array.isArray(arg)) {
|
|
7829
|
+
return { __spread: true, __values: arg };
|
|
7830
|
+
}
|
|
7831
|
+
if (typeof arg === 'string') {
|
|
7832
|
+
return { __spread: true, __values: [...arg] };
|
|
7833
|
+
}
|
|
7834
|
+
if (arg !== null && arg !== undefined && typeof arg[Symbol.iterator] === 'function') {
|
|
7835
|
+
return { __spread: true, __values: [...arg] };
|
|
7836
|
+
}
|
|
7837
|
+
if (typeof arg === 'object' && arg !== null) {
|
|
7838
|
+
return { __spread: true, __values: Object.entries(arg) };
|
|
7839
|
+
}
|
|
7840
|
+
throw new TypeError('Spread syntax requires an iterable');
|
|
7841
|
+
}
|
|
7842
|
+
|
|
7824
7843
|
// Only leaf nodes should fall through to sync evaluate
|
|
7825
7844
|
// These have no sub-expressions that could contain await
|
|
7826
7845
|
if (['Literal', 'Identifier', 'BreakStatement', 'ContinueStatement',
|
|
@@ -10328,7 +10347,8 @@ class WangInterpreter {
|
|
|
10328
10347
|
// Prepare execution options
|
|
10329
10348
|
const options = {
|
|
10330
10349
|
moduleResolver: this.moduleResolver,
|
|
10331
|
-
executionController: userOptions.executionController
|
|
10350
|
+
executionController: userOptions.executionController,
|
|
10351
|
+
abortSignal: userOptions.abortSignal // Pass abort signal to interpreter for cancellation support
|
|
10332
10352
|
// sourceType will be auto-detected from code
|
|
10333
10353
|
};
|
|
10334
10354
|
|
package/dist/index.js
CHANGED
|
@@ -6555,10 +6555,11 @@ var Interpreter = class _Interpreter {
|
|
|
6555
6555
|
if (node.optional && (callee === null || callee === void 0)) {
|
|
6556
6556
|
return void 0;
|
|
6557
6557
|
}
|
|
6558
|
-
const
|
|
6558
|
+
const rawArgs = [];
|
|
6559
6559
|
for (const arg of node.arguments) {
|
|
6560
|
-
|
|
6560
|
+
rawArgs.push(await this.evaluateAsync(arg, env));
|
|
6561
6561
|
}
|
|
6562
|
+
const args = this.flattenSpreadArgs(rawArgs);
|
|
6562
6563
|
if (typeof callee === "function") {
|
|
6563
6564
|
if (thisContext !== void 0) {
|
|
6564
6565
|
return await callee.call(thisContext, ...args);
|
|
@@ -6960,6 +6961,22 @@ var Interpreter = class _Interpreter {
|
|
|
6960
6961
|
if (node.type === "JSXText") {
|
|
6961
6962
|
return this.normalizeJSXText(node.value);
|
|
6962
6963
|
}
|
|
6964
|
+
if (node.type === "SpreadElement") {
|
|
6965
|
+
const arg = await this.evaluateAsync(node.argument, env);
|
|
6966
|
+
if (Array.isArray(arg)) {
|
|
6967
|
+
return { __spread: true, __values: arg };
|
|
6968
|
+
}
|
|
6969
|
+
if (typeof arg === "string") {
|
|
6970
|
+
return { __spread: true, __values: [...arg] };
|
|
6971
|
+
}
|
|
6972
|
+
if (arg !== null && arg !== void 0 && typeof arg[Symbol.iterator] === "function") {
|
|
6973
|
+
return { __spread: true, __values: [...arg] };
|
|
6974
|
+
}
|
|
6975
|
+
if (typeof arg === "object" && arg !== null) {
|
|
6976
|
+
return { __spread: true, __values: Object.entries(arg) };
|
|
6977
|
+
}
|
|
6978
|
+
throw new TypeError("Spread syntax requires an iterable");
|
|
6979
|
+
}
|
|
6963
6980
|
if ([
|
|
6964
6981
|
"Literal",
|
|
6965
6982
|
"Identifier",
|
|
@@ -8851,7 +8868,9 @@ var WangInterpreter = class {
|
|
|
8851
8868
|
const hasTopLevelReturn = this.hasTopLevelReturn(code);
|
|
8852
8869
|
const options = {
|
|
8853
8870
|
moduleResolver: this.moduleResolver,
|
|
8854
|
-
executionController: userOptions.executionController
|
|
8871
|
+
executionController: userOptions.executionController,
|
|
8872
|
+
abortSignal: userOptions.abortSignal
|
|
8873
|
+
// Pass abort signal to interpreter for cancellation support
|
|
8855
8874
|
// sourceType will be auto-detected from code
|
|
8856
8875
|
};
|
|
8857
8876
|
let result;
|