jslike 1.4.5 → 1.6.0

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.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
22
  Environment: () => Environment,
23
+ ExecutionController: () => ExecutionController,
23
24
  InMemoryModuleResolver: () => InMemoryModuleResolver,
24
25
  Interpreter: () => Interpreter,
25
26
  ModuleResolver: () => ModuleResolver,
@@ -27,7 +28,7 @@ __export(src_exports, {
27
28
  createEnvironment: () => createEnvironment,
28
29
  execute: () => execute,
29
30
  isTopLevelAwait: () => isTopLevelAwait,
30
- parse: () => parse4
31
+ parse: () => parse3
31
32
  });
32
33
  module.exports = __toCommonJS(src_exports);
33
34
 
@@ -5639,8 +5640,672 @@ Parser.acorn = {
5639
5640
  lineBreakG,
5640
5641
  nonASCIIwhitespace
5641
5642
  };
5642
- function parse3(input, options) {
5643
- return Parser.parse(input, options);
5643
+ var XHTMLEntities = {
5644
+ quot: '"',
5645
+ amp: "&",
5646
+ apos: "'",
5647
+ lt: "<",
5648
+ gt: ">",
5649
+ nbsp: "\xA0",
5650
+ iexcl: "\xA1",
5651
+ cent: "\xA2",
5652
+ pound: "\xA3",
5653
+ curren: "\xA4",
5654
+ yen: "\xA5",
5655
+ brvbar: "\xA6",
5656
+ sect: "\xA7",
5657
+ uml: "\xA8",
5658
+ copy: "\xA9",
5659
+ ordf: "\xAA",
5660
+ laquo: "\xAB",
5661
+ not: "\xAC",
5662
+ shy: "\xAD",
5663
+ reg: "\xAE",
5664
+ macr: "\xAF",
5665
+ deg: "\xB0",
5666
+ plusmn: "\xB1",
5667
+ sup2: "\xB2",
5668
+ sup3: "\xB3",
5669
+ acute: "\xB4",
5670
+ micro: "\xB5",
5671
+ para: "\xB6",
5672
+ middot: "\xB7",
5673
+ cedil: "\xB8",
5674
+ sup1: "\xB9",
5675
+ ordm: "\xBA",
5676
+ raquo: "\xBB",
5677
+ frac14: "\xBC",
5678
+ frac12: "\xBD",
5679
+ frac34: "\xBE",
5680
+ iquest: "\xBF",
5681
+ Agrave: "\xC0",
5682
+ Aacute: "\xC1",
5683
+ Acirc: "\xC2",
5684
+ Atilde: "\xC3",
5685
+ Auml: "\xC4",
5686
+ Aring: "\xC5",
5687
+ AElig: "\xC6",
5688
+ Ccedil: "\xC7",
5689
+ Egrave: "\xC8",
5690
+ Eacute: "\xC9",
5691
+ Ecirc: "\xCA",
5692
+ Euml: "\xCB",
5693
+ Igrave: "\xCC",
5694
+ Iacute: "\xCD",
5695
+ Icirc: "\xCE",
5696
+ Iuml: "\xCF",
5697
+ ETH: "\xD0",
5698
+ Ntilde: "\xD1",
5699
+ Ograve: "\xD2",
5700
+ Oacute: "\xD3",
5701
+ Ocirc: "\xD4",
5702
+ Otilde: "\xD5",
5703
+ Ouml: "\xD6",
5704
+ times: "\xD7",
5705
+ Oslash: "\xD8",
5706
+ Ugrave: "\xD9",
5707
+ Uacute: "\xDA",
5708
+ Ucirc: "\xDB",
5709
+ Uuml: "\xDC",
5710
+ Yacute: "\xDD",
5711
+ THORN: "\xDE",
5712
+ szlig: "\xDF",
5713
+ agrave: "\xE0",
5714
+ aacute: "\xE1",
5715
+ acirc: "\xE2",
5716
+ atilde: "\xE3",
5717
+ auml: "\xE4",
5718
+ aring: "\xE5",
5719
+ aelig: "\xE6",
5720
+ ccedil: "\xE7",
5721
+ egrave: "\xE8",
5722
+ eacute: "\xE9",
5723
+ ecirc: "\xEA",
5724
+ euml: "\xEB",
5725
+ igrave: "\xEC",
5726
+ iacute: "\xED",
5727
+ icirc: "\xEE",
5728
+ iuml: "\xEF",
5729
+ eth: "\xF0",
5730
+ ntilde: "\xF1",
5731
+ ograve: "\xF2",
5732
+ oacute: "\xF3",
5733
+ ocirc: "\xF4",
5734
+ otilde: "\xF5",
5735
+ ouml: "\xF6",
5736
+ divide: "\xF7",
5737
+ oslash: "\xF8",
5738
+ ugrave: "\xF9",
5739
+ uacute: "\xFA",
5740
+ ucirc: "\xFB",
5741
+ uuml: "\xFC",
5742
+ yacute: "\xFD",
5743
+ thorn: "\xFE",
5744
+ yuml: "\xFF",
5745
+ OElig: "\u0152",
5746
+ oelig: "\u0153",
5747
+ Scaron: "\u0160",
5748
+ scaron: "\u0161",
5749
+ Yuml: "\u0178",
5750
+ fnof: "\u0192",
5751
+ circ: "\u02C6",
5752
+ tilde: "\u02DC",
5753
+ Alpha: "\u0391",
5754
+ Beta: "\u0392",
5755
+ Gamma: "\u0393",
5756
+ Delta: "\u0394",
5757
+ Epsilon: "\u0395",
5758
+ Zeta: "\u0396",
5759
+ Eta: "\u0397",
5760
+ Theta: "\u0398",
5761
+ Iota: "\u0399",
5762
+ Kappa: "\u039A",
5763
+ Lambda: "\u039B",
5764
+ Mu: "\u039C",
5765
+ Nu: "\u039D",
5766
+ Xi: "\u039E",
5767
+ Omicron: "\u039F",
5768
+ Pi: "\u03A0",
5769
+ Rho: "\u03A1",
5770
+ Sigma: "\u03A3",
5771
+ Tau: "\u03A4",
5772
+ Upsilon: "\u03A5",
5773
+ Phi: "\u03A6",
5774
+ Chi: "\u03A7",
5775
+ Psi: "\u03A8",
5776
+ Omega: "\u03A9",
5777
+ alpha: "\u03B1",
5778
+ beta: "\u03B2",
5779
+ gamma: "\u03B3",
5780
+ delta: "\u03B4",
5781
+ epsilon: "\u03B5",
5782
+ zeta: "\u03B6",
5783
+ eta: "\u03B7",
5784
+ theta: "\u03B8",
5785
+ iota: "\u03B9",
5786
+ kappa: "\u03BA",
5787
+ lambda: "\u03BB",
5788
+ mu: "\u03BC",
5789
+ nu: "\u03BD",
5790
+ xi: "\u03BE",
5791
+ omicron: "\u03BF",
5792
+ pi: "\u03C0",
5793
+ rho: "\u03C1",
5794
+ sigmaf: "\u03C2",
5795
+ sigma: "\u03C3",
5796
+ tau: "\u03C4",
5797
+ upsilon: "\u03C5",
5798
+ phi: "\u03C6",
5799
+ chi: "\u03C7",
5800
+ psi: "\u03C8",
5801
+ omega: "\u03C9",
5802
+ thetasym: "\u03D1",
5803
+ upsih: "\u03D2",
5804
+ piv: "\u03D6",
5805
+ ensp: "\u2002",
5806
+ emsp: "\u2003",
5807
+ thinsp: "\u2009",
5808
+ zwnj: "\u200C",
5809
+ zwj: "\u200D",
5810
+ lrm: "\u200E",
5811
+ rlm: "\u200F",
5812
+ ndash: "\u2013",
5813
+ mdash: "\u2014",
5814
+ lsquo: "\u2018",
5815
+ rsquo: "\u2019",
5816
+ sbquo: "\u201A",
5817
+ ldquo: "\u201C",
5818
+ rdquo: "\u201D",
5819
+ bdquo: "\u201E",
5820
+ dagger: "\u2020",
5821
+ Dagger: "\u2021",
5822
+ bull: "\u2022",
5823
+ hellip: "\u2026",
5824
+ permil: "\u2030",
5825
+ prime: "\u2032",
5826
+ Prime: "\u2033",
5827
+ lsaquo: "\u2039",
5828
+ rsaquo: "\u203A",
5829
+ oline: "\u203E",
5830
+ frasl: "\u2044",
5831
+ euro: "\u20AC",
5832
+ image: "\u2111",
5833
+ weierp: "\u2118",
5834
+ real: "\u211C",
5835
+ trade: "\u2122",
5836
+ alefsym: "\u2135",
5837
+ larr: "\u2190",
5838
+ uarr: "\u2191",
5839
+ rarr: "\u2192",
5840
+ darr: "\u2193",
5841
+ harr: "\u2194",
5842
+ crarr: "\u21B5",
5843
+ lArr: "\u21D0",
5844
+ uArr: "\u21D1",
5845
+ rArr: "\u21D2",
5846
+ dArr: "\u21D3",
5847
+ hArr: "\u21D4",
5848
+ forall: "\u2200",
5849
+ part: "\u2202",
5850
+ exist: "\u2203",
5851
+ empty: "\u2205",
5852
+ nabla: "\u2207",
5853
+ isin: "\u2208",
5854
+ notin: "\u2209",
5855
+ ni: "\u220B",
5856
+ prod: "\u220F",
5857
+ sum: "\u2211",
5858
+ minus: "\u2212",
5859
+ lowast: "\u2217",
5860
+ radic: "\u221A",
5861
+ prop: "\u221D",
5862
+ infin: "\u221E",
5863
+ ang: "\u2220",
5864
+ and: "\u2227",
5865
+ or: "\u2228",
5866
+ cap: "\u2229",
5867
+ cup: "\u222A",
5868
+ "int": "\u222B",
5869
+ there4: "\u2234",
5870
+ sim: "\u223C",
5871
+ cong: "\u2245",
5872
+ asymp: "\u2248",
5873
+ ne: "\u2260",
5874
+ equiv: "\u2261",
5875
+ le: "\u2264",
5876
+ ge: "\u2265",
5877
+ sub: "\u2282",
5878
+ sup: "\u2283",
5879
+ nsub: "\u2284",
5880
+ sube: "\u2286",
5881
+ supe: "\u2287",
5882
+ oplus: "\u2295",
5883
+ otimes: "\u2297",
5884
+ perp: "\u22A5",
5885
+ sdot: "\u22C5",
5886
+ lceil: "\u2308",
5887
+ rceil: "\u2309",
5888
+ lfloor: "\u230A",
5889
+ rfloor: "\u230B",
5890
+ lang: "\u2329",
5891
+ rang: "\u232A",
5892
+ loz: "\u25CA",
5893
+ spades: "\u2660",
5894
+ clubs: "\u2663",
5895
+ hearts: "\u2665",
5896
+ diams: "\u2666"
5897
+ };
5898
+ var hexNumber = /^[\da-fA-F]+$/;
5899
+ var decimalNumber = /^\d+$/;
5900
+ var acornJsxMap = /* @__PURE__ */ new WeakMap();
5901
+ function getJsxTokens(acorn) {
5902
+ acorn = acorn.Parser.acorn || acorn;
5903
+ let acornJsx2 = acornJsxMap.get(acorn);
5904
+ if (!acornJsx2) {
5905
+ const tt = acorn.tokTypes;
5906
+ const TokContext3 = acorn.TokContext;
5907
+ const TokenType3 = acorn.TokenType;
5908
+ const tc_oTag = new TokContext3("<tag", false);
5909
+ const tc_cTag = new TokContext3("</tag", false);
5910
+ const tc_expr = new TokContext3("<tag>...</tag>", true, true);
5911
+ const tokContexts = {
5912
+ tc_oTag,
5913
+ tc_cTag,
5914
+ tc_expr
5915
+ };
5916
+ const tokTypes = {
5917
+ jsxName: new TokenType3("jsxName"),
5918
+ jsxText: new TokenType3("jsxText", { beforeExpr: true }),
5919
+ jsxTagStart: new TokenType3("jsxTagStart", { startsExpr: true }),
5920
+ jsxTagEnd: new TokenType3("jsxTagEnd")
5921
+ };
5922
+ tokTypes.jsxTagStart.updateContext = function() {
5923
+ this.context.push(tc_expr);
5924
+ this.context.push(tc_oTag);
5925
+ this.exprAllowed = false;
5926
+ };
5927
+ tokTypes.jsxTagEnd.updateContext = function(prevType) {
5928
+ let out = this.context.pop();
5929
+ if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) {
5930
+ this.context.pop();
5931
+ this.exprAllowed = this.curContext() === tc_expr;
5932
+ } else {
5933
+ this.exprAllowed = true;
5934
+ }
5935
+ };
5936
+ acornJsx2 = { tokContexts, tokTypes };
5937
+ acornJsxMap.set(acorn, acornJsx2);
5938
+ }
5939
+ return acornJsx2;
5940
+ }
5941
+ function getQualifiedJSXName(object) {
5942
+ if (!object)
5943
+ return object;
5944
+ if (object.type === "JSXIdentifier")
5945
+ return object.name;
5946
+ if (object.type === "JSXNamespacedName")
5947
+ return object.namespace.name + ":" + object.name.name;
5948
+ if (object.type === "JSXMemberExpression")
5949
+ return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
5950
+ }
5951
+ function acornJsx(options) {
5952
+ options = options || {};
5953
+ return function(Parser3) {
5954
+ return plugin({
5955
+ allowNamespaces: options.allowNamespaces !== false,
5956
+ allowNamespacedObjects: !!options.allowNamespacedObjects
5957
+ }, Parser3);
5958
+ };
5959
+ }
5960
+ function plugin(options, Parser3) {
5961
+ const acorn = Parser3.acorn || { tokTypes: tt, TokContext, TokenType, isNewLine: isNewLine2, isIdentifierStart: isIdentifierStart2, isIdentifierChar: isIdentifierChar2, tokContexts };
5962
+ const acornJsx2 = getJsxTokens(acorn);
5963
+ const tt = acorn.tokTypes;
5964
+ const tok = acornJsx2.tokTypes;
5965
+ const tokContexts = acorn.tokContexts;
5966
+ const tc_oTag = acornJsx2.tokContexts.tc_oTag;
5967
+ const tc_cTag = acornJsx2.tokContexts.tc_cTag;
5968
+ const tc_expr = acornJsx2.tokContexts.tc_expr;
5969
+ const isNewLine2 = acorn.isNewLine;
5970
+ const isIdentifierStart2 = acorn.isIdentifierStart;
5971
+ const isIdentifierChar2 = acorn.isIdentifierChar;
5972
+ return class extends Parser3 {
5973
+ // Expose actual `tokTypes` and `tokContexts` to other plugins.
5974
+ static get acornJsx() {
5975
+ return acornJsx2;
5976
+ }
5977
+ // Reads inline JSX contents token.
5978
+ jsx_readToken() {
5979
+ let out = "", chunkStart = this.pos;
5980
+ for (; ; ) {
5981
+ if (this.pos >= this.input.length)
5982
+ this.raise(this.start, "Unterminated JSX contents");
5983
+ let ch = this.input.charCodeAt(this.pos);
5984
+ switch (ch) {
5985
+ case 60:
5986
+ // '<'
5987
+ case 123:
5988
+ if (this.pos === this.start) {
5989
+ if (ch === 60 && this.exprAllowed) {
5990
+ ++this.pos;
5991
+ return this.finishToken(tok.jsxTagStart);
5992
+ }
5993
+ return this.getTokenFromCode(ch);
5994
+ }
5995
+ out += this.input.slice(chunkStart, this.pos);
5996
+ return this.finishToken(tok.jsxText, out);
5997
+ case 38:
5998
+ out += this.input.slice(chunkStart, this.pos);
5999
+ out += this.jsx_readEntity();
6000
+ chunkStart = this.pos;
6001
+ break;
6002
+ case 62:
6003
+ // '>'
6004
+ case 125:
6005
+ this.raise(
6006
+ this.pos,
6007
+ "Unexpected token `" + this.input[this.pos] + "`. Did you mean `" + (ch === 62 ? "&gt;" : "&rbrace;") + '` or `{"' + this.input[this.pos] + '"}`?'
6008
+ );
6009
+ default:
6010
+ if (isNewLine2(ch)) {
6011
+ out += this.input.slice(chunkStart, this.pos);
6012
+ out += this.jsx_readNewLine(true);
6013
+ chunkStart = this.pos;
6014
+ } else {
6015
+ ++this.pos;
6016
+ }
6017
+ }
6018
+ }
6019
+ }
6020
+ jsx_readNewLine(normalizeCRLF) {
6021
+ let ch = this.input.charCodeAt(this.pos);
6022
+ let out;
6023
+ ++this.pos;
6024
+ if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
6025
+ ++this.pos;
6026
+ out = normalizeCRLF ? "\n" : "\r\n";
6027
+ } else {
6028
+ out = String.fromCharCode(ch);
6029
+ }
6030
+ if (this.options.locations) {
6031
+ ++this.curLine;
6032
+ this.lineStart = this.pos;
6033
+ }
6034
+ return out;
6035
+ }
6036
+ jsx_readString(quote) {
6037
+ let out = "", chunkStart = ++this.pos;
6038
+ for (; ; ) {
6039
+ if (this.pos >= this.input.length)
6040
+ this.raise(this.start, "Unterminated string constant");
6041
+ let ch = this.input.charCodeAt(this.pos);
6042
+ if (ch === quote) break;
6043
+ if (ch === 38) {
6044
+ out += this.input.slice(chunkStart, this.pos);
6045
+ out += this.jsx_readEntity();
6046
+ chunkStart = this.pos;
6047
+ } else if (isNewLine2(ch)) {
6048
+ out += this.input.slice(chunkStart, this.pos);
6049
+ out += this.jsx_readNewLine(false);
6050
+ chunkStart = this.pos;
6051
+ } else {
6052
+ ++this.pos;
6053
+ }
6054
+ }
6055
+ out += this.input.slice(chunkStart, this.pos++);
6056
+ return this.finishToken(tt.string, out);
6057
+ }
6058
+ jsx_readEntity() {
6059
+ let str = "", count = 0, entity;
6060
+ let ch = this.input[this.pos];
6061
+ if (ch !== "&")
6062
+ this.raise(this.pos, "Entity must start with an ampersand");
6063
+ let startPos = ++this.pos;
6064
+ while (this.pos < this.input.length && count++ < 10) {
6065
+ ch = this.input[this.pos++];
6066
+ if (ch === ";") {
6067
+ if (str[0] === "#") {
6068
+ if (str[1] === "x") {
6069
+ str = str.substr(2);
6070
+ if (hexNumber.test(str))
6071
+ entity = String.fromCharCode(parseInt(str, 16));
6072
+ } else {
6073
+ str = str.substr(1);
6074
+ if (decimalNumber.test(str))
6075
+ entity = String.fromCharCode(parseInt(str, 10));
6076
+ }
6077
+ } else {
6078
+ entity = XHTMLEntities[str];
6079
+ }
6080
+ break;
6081
+ }
6082
+ str += ch;
6083
+ }
6084
+ if (!entity) {
6085
+ this.pos = startPos;
6086
+ return "&";
6087
+ }
6088
+ return entity;
6089
+ }
6090
+ // Read a JSX identifier (valid tag or attribute name).
6091
+ //
6092
+ // Optimized version since JSX identifiers can't contain
6093
+ // escape characters and so can be read as single slice.
6094
+ // Also assumes that first character was already checked
6095
+ // by isIdentifierStart in readToken.
6096
+ jsx_readWord() {
6097
+ let ch, start = this.pos;
6098
+ do {
6099
+ ch = this.input.charCodeAt(++this.pos);
6100
+ } while (isIdentifierChar2(ch) || ch === 45);
6101
+ return this.finishToken(tok.jsxName, this.input.slice(start, this.pos));
6102
+ }
6103
+ // Parse next token as JSX identifier
6104
+ jsx_parseIdentifier() {
6105
+ let node = this.startNode();
6106
+ if (this.type === tok.jsxName)
6107
+ node.name = this.value;
6108
+ else if (this.type.keyword)
6109
+ node.name = this.type.keyword;
6110
+ else
6111
+ this.unexpected();
6112
+ this.next();
6113
+ return this.finishNode(node, "JSXIdentifier");
6114
+ }
6115
+ // Parse namespaced identifier.
6116
+ jsx_parseNamespacedName() {
6117
+ let startPos = this.start, startLoc = this.startLoc;
6118
+ let name = this.jsx_parseIdentifier();
6119
+ if (!options.allowNamespaces || !this.eat(tt.colon)) return name;
6120
+ var node = this.startNodeAt(startPos, startLoc);
6121
+ node.namespace = name;
6122
+ node.name = this.jsx_parseIdentifier();
6123
+ return this.finishNode(node, "JSXNamespacedName");
6124
+ }
6125
+ // Parses element name in any form - namespaced, member
6126
+ // or single identifier.
6127
+ jsx_parseElementName() {
6128
+ if (this.type === tok.jsxTagEnd) return "";
6129
+ let startPos = this.start, startLoc = this.startLoc;
6130
+ let node = this.jsx_parseNamespacedName();
6131
+ if (this.type === tt.dot && node.type === "JSXNamespacedName" && !options.allowNamespacedObjects) {
6132
+ this.unexpected();
6133
+ }
6134
+ while (this.eat(tt.dot)) {
6135
+ let newNode = this.startNodeAt(startPos, startLoc);
6136
+ newNode.object = node;
6137
+ newNode.property = this.jsx_parseIdentifier();
6138
+ node = this.finishNode(newNode, "JSXMemberExpression");
6139
+ }
6140
+ return node;
6141
+ }
6142
+ // Parses any type of JSX attribute value.
6143
+ jsx_parseAttributeValue() {
6144
+ switch (this.type) {
6145
+ case tt.braceL:
6146
+ let node = this.jsx_parseExpressionContainer();
6147
+ if (node.expression.type === "JSXEmptyExpression")
6148
+ this.raise(node.start, "JSX attributes must only be assigned a non-empty expression");
6149
+ return node;
6150
+ case tok.jsxTagStart:
6151
+ case tt.string:
6152
+ return this.parseExprAtom();
6153
+ default:
6154
+ this.raise(this.start, "JSX value should be either an expression or a quoted JSX text");
6155
+ }
6156
+ }
6157
+ // JSXEmptyExpression is unique type since it doesn't actually parse anything,
6158
+ // and so it should start at the end of last read token (left brace) and finish
6159
+ // at the beginning of the next one (right brace).
6160
+ jsx_parseEmptyExpression() {
6161
+ let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
6162
+ return this.finishNodeAt(node, "JSXEmptyExpression", this.start, this.startLoc);
6163
+ }
6164
+ // Parses JSX expression enclosed into curly brackets.
6165
+ jsx_parseExpressionContainer() {
6166
+ let node = this.startNode();
6167
+ this.next();
6168
+ node.expression = this.type === tt.braceR ? this.jsx_parseEmptyExpression() : this.parseExpression();
6169
+ this.expect(tt.braceR);
6170
+ return this.finishNode(node, "JSXExpressionContainer");
6171
+ }
6172
+ // Parses following JSX attribute name-value pair.
6173
+ jsx_parseAttribute() {
6174
+ let node = this.startNode();
6175
+ if (this.eat(tt.braceL)) {
6176
+ this.expect(tt.ellipsis);
6177
+ node.argument = this.parseMaybeAssign();
6178
+ this.expect(tt.braceR);
6179
+ return this.finishNode(node, "JSXSpreadAttribute");
6180
+ }
6181
+ node.name = this.jsx_parseNamespacedName();
6182
+ node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
6183
+ return this.finishNode(node, "JSXAttribute");
6184
+ }
6185
+ // Parses JSX opening tag starting after '<'.
6186
+ jsx_parseOpeningElementAt(startPos, startLoc) {
6187
+ let node = this.startNodeAt(startPos, startLoc);
6188
+ node.attributes = [];
6189
+ let nodeName = this.jsx_parseElementName();
6190
+ if (nodeName) node.name = nodeName;
6191
+ while (this.type !== tt.slash && this.type !== tok.jsxTagEnd)
6192
+ node.attributes.push(this.jsx_parseAttribute());
6193
+ node.selfClosing = this.eat(tt.slash);
6194
+ this.expect(tok.jsxTagEnd);
6195
+ return this.finishNode(node, nodeName ? "JSXOpeningElement" : "JSXOpeningFragment");
6196
+ }
6197
+ // Parses JSX closing tag starting after '</'.
6198
+ jsx_parseClosingElementAt(startPos, startLoc) {
6199
+ let node = this.startNodeAt(startPos, startLoc);
6200
+ let nodeName = this.jsx_parseElementName();
6201
+ if (nodeName) node.name = nodeName;
6202
+ this.expect(tok.jsxTagEnd);
6203
+ return this.finishNode(node, nodeName ? "JSXClosingElement" : "JSXClosingFragment");
6204
+ }
6205
+ // Parses entire JSX element, including it's opening tag
6206
+ // (starting after '<'), attributes, contents and closing tag.
6207
+ jsx_parseElementAt(startPos, startLoc) {
6208
+ let node = this.startNodeAt(startPos, startLoc);
6209
+ let children = [];
6210
+ let openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
6211
+ let closingElement = null;
6212
+ if (!openingElement.selfClosing) {
6213
+ contents: for (; ; ) {
6214
+ switch (this.type) {
6215
+ case tok.jsxTagStart:
6216
+ startPos = this.start;
6217
+ startLoc = this.startLoc;
6218
+ this.next();
6219
+ if (this.eat(tt.slash)) {
6220
+ closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
6221
+ break contents;
6222
+ }
6223
+ children.push(this.jsx_parseElementAt(startPos, startLoc));
6224
+ break;
6225
+ case tok.jsxText:
6226
+ children.push(this.parseExprAtom());
6227
+ break;
6228
+ case tt.braceL:
6229
+ children.push(this.jsx_parseExpressionContainer());
6230
+ break;
6231
+ default:
6232
+ this.unexpected();
6233
+ }
6234
+ }
6235
+ if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
6236
+ this.raise(
6237
+ closingElement.start,
6238
+ "Expected corresponding JSX closing tag for <" + getQualifiedJSXName(openingElement.name) + ">"
6239
+ );
6240
+ }
6241
+ }
6242
+ let fragmentOrElement = openingElement.name ? "Element" : "Fragment";
6243
+ node["opening" + fragmentOrElement] = openingElement;
6244
+ node["closing" + fragmentOrElement] = closingElement;
6245
+ node.children = children;
6246
+ if (this.type === tt.relational && this.value === "<") {
6247
+ this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
6248
+ }
6249
+ return this.finishNode(node, "JSX" + fragmentOrElement);
6250
+ }
6251
+ // Parse JSX text
6252
+ jsx_parseText() {
6253
+ let node = this.parseLiteral(this.value);
6254
+ node.type = "JSXText";
6255
+ return node;
6256
+ }
6257
+ // Parses entire JSX element from current position.
6258
+ jsx_parseElement() {
6259
+ let startPos = this.start, startLoc = this.startLoc;
6260
+ this.next();
6261
+ return this.jsx_parseElementAt(startPos, startLoc);
6262
+ }
6263
+ parseExprAtom(refShortHandDefaultPos) {
6264
+ if (this.type === tok.jsxText)
6265
+ return this.jsx_parseText();
6266
+ else if (this.type === tok.jsxTagStart)
6267
+ return this.jsx_parseElement();
6268
+ else
6269
+ return super.parseExprAtom(refShortHandDefaultPos);
6270
+ }
6271
+ readToken(code) {
6272
+ let context = this.curContext();
6273
+ if (context === tc_expr) return this.jsx_readToken();
6274
+ if (context === tc_oTag || context === tc_cTag) {
6275
+ if (isIdentifierStart2(code)) return this.jsx_readWord();
6276
+ if (code == 62) {
6277
+ ++this.pos;
6278
+ return this.finishToken(tok.jsxTagEnd);
6279
+ }
6280
+ if ((code === 34 || code === 39) && context == tc_oTag)
6281
+ return this.jsx_readString(code);
6282
+ }
6283
+ if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
6284
+ ++this.pos;
6285
+ return this.finishToken(tok.jsxTagStart);
6286
+ }
6287
+ return super.readToken(code);
6288
+ }
6289
+ updateContext(prevType) {
6290
+ if (this.type == tt.braceL) {
6291
+ var curContext = this.curContext();
6292
+ if (curContext == tc_oTag) this.context.push(tokContexts.b_expr);
6293
+ else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl);
6294
+ else super.updateContext(prevType);
6295
+ this.exprAllowed = true;
6296
+ } else if (this.type === tt.slash && prevType === tok.jsxTagStart) {
6297
+ this.context.length -= 2;
6298
+ this.context.push(tc_cTag);
6299
+ this.exprAllowed = false;
6300
+ } else {
6301
+ return super.updateContext(prevType);
6302
+ }
6303
+ }
6304
+ };
6305
+ }
6306
+ var JSXParser = Parser.extend(acornJsx());
6307
+ function jsxParse(input, options) {
6308
+ return JSXParser.parse(input, options);
5644
6309
  }
5645
6310
 
5646
6311
  // src/runtime/environment.js
@@ -5817,19 +6482,36 @@ var Interpreter = class _Interpreter {
5817
6482
  this.moduleCache = /* @__PURE__ */ new Map();
5818
6483
  this.moduleExports = {};
5819
6484
  this.abortSignal = options.abortSignal;
6485
+ this.executionController = options.executionController;
5820
6486
  }
5821
- // Check if execution should be aborted
6487
+ // Check if execution should be aborted (sync version)
5822
6488
  checkAbortSignal() {
6489
+ if (this.executionController) {
6490
+ this.executionController._checkAbortSync();
6491
+ return;
6492
+ }
5823
6493
  if (this.abortSignal && this.abortSignal.aborted) {
5824
6494
  const error = new Error("The operation was aborted");
5825
6495
  error.name = "AbortError";
5826
6496
  throw error;
5827
6497
  }
5828
6498
  }
6499
+ // Checkpoint that returns a promise only when controller is present
6500
+ // When no controller, returns null to signal no await needed
6501
+ _getCheckpointPromise(node, env) {
6502
+ if (this.executionController) {
6503
+ this.executionController._setEnv(env);
6504
+ return this.executionController._checkpoint(node);
6505
+ } else {
6506
+ this.checkAbortSignal();
6507
+ return null;
6508
+ }
6509
+ }
5829
6510
  // Async evaluation for async functions - handles await expressions
5830
6511
  async evaluateAsync(node, env) {
5831
6512
  if (!node) return void 0;
5832
- this.checkAbortSignal();
6513
+ const checkpointPromise = this._getCheckpointPromise(node, env);
6514
+ if (checkpointPromise) await checkpointPromise;
5833
6515
  if (node.type === "AwaitExpression") {
5834
6516
  const promise = await this.evaluateAsync(node.argument, env);
5835
6517
  return await promise;
@@ -6000,6 +6682,8 @@ var Interpreter = class _Interpreter {
6000
6682
  await this.evaluateAsync(node.init, forEnv);
6001
6683
  }
6002
6684
  while (!node.test || await this.evaluateAsync(node.test, forEnv)) {
6685
+ const cp1 = this._getCheckpointPromise(node, forEnv);
6686
+ if (cp1) await cp1;
6003
6687
  const result = await this.evaluateAsync(node.body, forEnv);
6004
6688
  if (result instanceof BreakSignal) {
6005
6689
  break;
@@ -6025,6 +6709,8 @@ var Interpreter = class _Interpreter {
6025
6709
  const declarator = node.left.declarations[0];
6026
6710
  const isConst = node.left.kind === "const";
6027
6711
  for (const value of iterable) {
6712
+ const cp2 = this._getCheckpointPromise(node, forEnv);
6713
+ if (cp2) await cp2;
6028
6714
  const iterEnv = forEnv.extend();
6029
6715
  if (declarator.id.type === "Identifier") {
6030
6716
  iterEnv.define(declarator.id.name, value, isConst);
@@ -6055,6 +6741,8 @@ var Interpreter = class _Interpreter {
6055
6741
  const varName = node.left.declarations[0].id.name;
6056
6742
  forEnv.define(varName, void 0);
6057
6743
  for (const key in obj) {
6744
+ const cp3 = this._getCheckpointPromise(node, forEnv);
6745
+ if (cp3) await cp3;
6058
6746
  forEnv.set(varName, key);
6059
6747
  const result = await this.evaluateAsync(node.body, forEnv);
6060
6748
  if (result instanceof BreakSignal) {
@@ -6071,6 +6759,8 @@ var Interpreter = class _Interpreter {
6071
6759
  }
6072
6760
  if (node.type === "WhileStatement") {
6073
6761
  while (await this.evaluateAsync(node.test, env)) {
6762
+ const cp4 = this._getCheckpointPromise(node, env);
6763
+ if (cp4) await cp4;
6074
6764
  const result = await this.evaluateAsync(node.body, env);
6075
6765
  if (result instanceof BreakSignal) {
6076
6766
  break;
@@ -6086,6 +6776,8 @@ var Interpreter = class _Interpreter {
6086
6776
  }
6087
6777
  if (node.type === "DoWhileStatement") {
6088
6778
  do {
6779
+ const cp5 = this._getCheckpointPromise(node, env);
6780
+ if (cp5) await cp5;
6089
6781
  const result = await this.evaluateAsync(node.body, env);
6090
6782
  if (result instanceof BreakSignal) {
6091
6783
  break;
@@ -6287,6 +6979,21 @@ var Interpreter = class _Interpreter {
6287
6979
  if (node.type === "ClassExpression") {
6288
6980
  return this.evaluateClassExpression(node, env);
6289
6981
  }
6982
+ if (node.type === "JSXElement") {
6983
+ return await this.evaluateJSXElementAsync(node, env);
6984
+ }
6985
+ if (node.type === "JSXFragment") {
6986
+ return await this.evaluateJSXFragmentAsync(node, env);
6987
+ }
6988
+ if (node.type === "JSXExpressionContainer") {
6989
+ if (node.expression.type === "JSXEmptyExpression") {
6990
+ return void 0;
6991
+ }
6992
+ return await this.evaluateAsync(node.expression, env);
6993
+ }
6994
+ if (node.type === "JSXText") {
6995
+ return this.normalizeJSXText(node.value);
6996
+ }
6290
6997
  if ([
6291
6998
  "Literal",
6292
6999
  "Identifier",
@@ -6409,6 +7116,18 @@ var Interpreter = class _Interpreter {
6409
7116
  return this.evaluateAssignmentPattern(node, env);
6410
7117
  case "Property":
6411
7118
  return this.evaluateProperty(node, env);
7119
+ // JSX Support
7120
+ case "JSXElement":
7121
+ return this.evaluateJSXElement(node, env);
7122
+ case "JSXFragment":
7123
+ return this.evaluateJSXFragment(node, env);
7124
+ case "JSXExpressionContainer":
7125
+ if (node.expression.type === "JSXEmptyExpression") {
7126
+ return void 0;
7127
+ }
7128
+ return this.evaluate(node.expression, env);
7129
+ case "JSXText":
7130
+ return this.normalizeJSXText(node.value);
6412
7131
  default:
6413
7132
  throw new Error(`Unknown node type: ${node.type}`);
6414
7133
  }
@@ -6728,6 +7447,7 @@ var Interpreter = class _Interpreter {
6728
7447
  callUserFunction(func, args, callingEnv, thisContext = void 0) {
6729
7448
  const metadata = func.__metadata || func;
6730
7449
  const funcEnv = new Environment(metadata.closure);
7450
+ const funcName = metadata.name || func.name || "anonymous";
6731
7451
  if (thisContext !== void 0) {
6732
7452
  funcEnv.define("this", thisContext);
6733
7453
  }
@@ -6750,15 +7470,46 @@ var Interpreter = class _Interpreter {
6750
7470
  }
6751
7471
  }
6752
7472
  if (metadata.async) {
7473
+ if (this.executionController) {
7474
+ this.executionController._pushCall(funcName);
7475
+ }
6753
7476
  return (async () => {
7477
+ try {
7478
+ if (metadata.expression) {
7479
+ const result = await this.evaluateAsync(metadata.body, funcEnv);
7480
+ if (result instanceof ThrowSignal) {
7481
+ throw result.value;
7482
+ }
7483
+ return result;
7484
+ } else {
7485
+ const result = await this.evaluateAsync(metadata.body, funcEnv);
7486
+ if (result instanceof ReturnValue) {
7487
+ return result.value;
7488
+ }
7489
+ if (result instanceof ThrowSignal) {
7490
+ throw result.value;
7491
+ }
7492
+ return void 0;
7493
+ }
7494
+ } finally {
7495
+ if (this.executionController) {
7496
+ this.executionController._popCall();
7497
+ }
7498
+ }
7499
+ })();
7500
+ } else {
7501
+ if (this.executionController) {
7502
+ this.executionController._pushCall(funcName);
7503
+ }
7504
+ try {
6754
7505
  if (metadata.expression) {
6755
- const result = await this.evaluateAsync(metadata.body, funcEnv);
7506
+ const result = this.evaluate(metadata.body, funcEnv);
6756
7507
  if (result instanceof ThrowSignal) {
6757
7508
  throw result.value;
6758
7509
  }
6759
7510
  return result;
6760
7511
  } else {
6761
- const result = await this.evaluateAsync(metadata.body, funcEnv);
7512
+ const result = this.evaluate(metadata.body, funcEnv);
6762
7513
  if (result instanceof ReturnValue) {
6763
7514
  return result.value;
6764
7515
  }
@@ -6767,23 +7518,10 @@ var Interpreter = class _Interpreter {
6767
7518
  }
6768
7519
  return void 0;
6769
7520
  }
6770
- })();
6771
- } else {
6772
- if (metadata.expression) {
6773
- const result = this.evaluate(metadata.body, funcEnv);
6774
- if (result instanceof ThrowSignal) {
6775
- throw result.value;
6776
- }
6777
- return result;
6778
- } else {
6779
- const result = this.evaluate(metadata.body, funcEnv);
6780
- if (result instanceof ReturnValue) {
6781
- return result.value;
6782
- }
6783
- if (result instanceof ThrowSignal) {
6784
- throw result.value;
7521
+ } finally {
7522
+ if (this.executionController) {
7523
+ this.executionController._popCall();
6785
7524
  }
6786
- return void 0;
6787
7525
  }
6788
7526
  }
6789
7527
  }
@@ -7028,7 +7766,7 @@ var Interpreter = class _Interpreter {
7028
7766
  throw new Error(`Cannot find module '${modulePath}'`);
7029
7767
  }
7030
7768
  const moduleCode = typeof resolution === "string" ? resolution : resolution.code;
7031
- const moduleAst = parse3(moduleCode, {
7769
+ const moduleAst = jsxParse(moduleCode, {
7032
7770
  ecmaVersion: 2020,
7033
7771
  sourceType: "module",
7034
7772
  locations: false
@@ -7457,6 +8195,210 @@ var Interpreter = class _Interpreter {
7457
8195
  evaluateProperty(node, env) {
7458
8196
  return void 0;
7459
8197
  }
8198
+ // ===== JSX Support =====
8199
+ evaluateJSXElement(node, env) {
8200
+ const createElement = this.getCreateElement(env);
8201
+ const { type, props } = this.evaluateJSXOpeningElement(node.openingElement, env);
8202
+ const children = this.evaluateJSXChildren(node.children, env);
8203
+ if (children.length === 0) {
8204
+ return createElement(type, props);
8205
+ } else if (children.length === 1) {
8206
+ return createElement(type, props, children[0]);
8207
+ }
8208
+ return createElement(type, props, ...children);
8209
+ }
8210
+ evaluateJSXFragment(node, env) {
8211
+ const createElement = this.getCreateElement(env);
8212
+ const Fragment = this.getFragment(env);
8213
+ const children = this.evaluateJSXChildren(node.children, env);
8214
+ if (children.length === 0) {
8215
+ return createElement(Fragment, null);
8216
+ } else if (children.length === 1) {
8217
+ return createElement(Fragment, null, children[0]);
8218
+ }
8219
+ return createElement(Fragment, null, ...children);
8220
+ }
8221
+ evaluateJSXOpeningElement(node, env) {
8222
+ const type = this.evaluateJSXElementName(node.name, env);
8223
+ const props = {};
8224
+ for (const attr of node.attributes) {
8225
+ if (attr.type === "JSXAttribute") {
8226
+ const name = attr.name.type === "JSXIdentifier" ? attr.name.name : `${attr.name.namespace.name}:${attr.name.name.name}`;
8227
+ const value = attr.value ? this.evaluateJSXAttributeValue(attr.value, env) : true;
8228
+ props[name] = value;
8229
+ } else if (attr.type === "JSXSpreadAttribute") {
8230
+ Object.assign(props, this.evaluate(attr.argument, env));
8231
+ }
8232
+ }
8233
+ return { type, props: Object.keys(props).length > 0 ? props : null };
8234
+ }
8235
+ evaluateJSXElementName(node, env) {
8236
+ if (node.type === "JSXIdentifier") {
8237
+ const name = node.name;
8238
+ if (name[0] === name[0].toLowerCase()) {
8239
+ return name;
8240
+ }
8241
+ return env.get(name);
8242
+ } else if (node.type === "JSXMemberExpression") {
8243
+ const object = this.evaluateJSXElementName(node.object, env);
8244
+ return object[node.property.name];
8245
+ } else if (node.type === "JSXNamespacedName") {
8246
+ return `${node.namespace.name}:${node.name.name}`;
8247
+ }
8248
+ throw new Error(`Unknown JSX element name type: ${node.type}`);
8249
+ }
8250
+ evaluateJSXAttributeValue(node, env) {
8251
+ if (node.type === "Literal") return node.value;
8252
+ if (node.type === "JSXExpressionContainer") {
8253
+ return this.evaluate(node.expression, env);
8254
+ }
8255
+ if (node.type === "JSXElement") return this.evaluateJSXElement(node, env);
8256
+ if (node.type === "JSXFragment") return this.evaluateJSXFragment(node, env);
8257
+ throw new Error(`Unknown JSX attribute value type: ${node.type}`);
8258
+ }
8259
+ evaluateJSXChildren(children, env) {
8260
+ const result = [];
8261
+ for (const child of children) {
8262
+ if (child.type === "JSXText") {
8263
+ const text = this.normalizeJSXText(child.value);
8264
+ if (text) result.push(text);
8265
+ } else if (child.type === "JSXExpressionContainer") {
8266
+ if (child.expression.type !== "JSXEmptyExpression") {
8267
+ const value = this.evaluate(child.expression, env);
8268
+ if (Array.isArray(value)) {
8269
+ result.push(...value);
8270
+ } else if (value !== null && value !== void 0 && value !== false) {
8271
+ result.push(value);
8272
+ }
8273
+ }
8274
+ } else if (child.type === "JSXElement") {
8275
+ result.push(this.evaluateJSXElement(child, env));
8276
+ } else if (child.type === "JSXFragment") {
8277
+ result.push(this.evaluateJSXFragment(child, env));
8278
+ }
8279
+ }
8280
+ return result;
8281
+ }
8282
+ normalizeJSXText(text) {
8283
+ const lines = text.split("\n");
8284
+ const normalized = lines.map((line, i) => {
8285
+ let result = line;
8286
+ if (i === 0) result = result.trimStart();
8287
+ if (i === lines.length - 1) result = result.trimEnd();
8288
+ return result;
8289
+ }).filter((line) => line.length > 0).join(" ");
8290
+ return normalized || null;
8291
+ }
8292
+ getCreateElement(env) {
8293
+ try {
8294
+ const React = env.get("React");
8295
+ if (React && React.createElement) {
8296
+ return React.createElement.bind(React);
8297
+ }
8298
+ } catch (e) {
8299
+ }
8300
+ try {
8301
+ return env.get("createElement");
8302
+ } catch (e) {
8303
+ }
8304
+ return (type, props, ...children) => ({
8305
+ $$typeof: Symbol.for("react.element"),
8306
+ type,
8307
+ props: {
8308
+ ...props,
8309
+ children: children.length === 0 ? void 0 : children.length === 1 ? children[0] : children
8310
+ },
8311
+ key: (props == null ? void 0 : props.key) ?? null,
8312
+ ref: (props == null ? void 0 : props.ref) ?? null
8313
+ });
8314
+ }
8315
+ getFragment(env) {
8316
+ try {
8317
+ const React = env.get("React");
8318
+ if (React && React.Fragment) {
8319
+ return React.Fragment;
8320
+ }
8321
+ } catch (e) {
8322
+ }
8323
+ try {
8324
+ return env.get("Fragment");
8325
+ } catch (e) {
8326
+ }
8327
+ return Symbol.for("react.fragment");
8328
+ }
8329
+ // ===== Async JSX Support =====
8330
+ async evaluateJSXElementAsync(node, env) {
8331
+ const checkpointPromise = this._getCheckpointPromise(node, env);
8332
+ if (checkpointPromise) await checkpointPromise;
8333
+ const createElement = this.getCreateElement(env);
8334
+ const { type, props } = await this.evaluateJSXOpeningElementAsync(node.openingElement, env);
8335
+ const children = await this.evaluateJSXChildrenAsync(node.children, env);
8336
+ if (children.length === 0) {
8337
+ return createElement(type, props);
8338
+ } else if (children.length === 1) {
8339
+ return createElement(type, props, children[0]);
8340
+ }
8341
+ return createElement(type, props, ...children);
8342
+ }
8343
+ async evaluateJSXFragmentAsync(node, env) {
8344
+ const checkpointPromise = this._getCheckpointPromise(node, env);
8345
+ if (checkpointPromise) await checkpointPromise;
8346
+ const createElement = this.getCreateElement(env);
8347
+ const Fragment = this.getFragment(env);
8348
+ const children = await this.evaluateJSXChildrenAsync(node.children, env);
8349
+ if (children.length === 0) {
8350
+ return createElement(Fragment, null);
8351
+ } else if (children.length === 1) {
8352
+ return createElement(Fragment, null, children[0]);
8353
+ }
8354
+ return createElement(Fragment, null, ...children);
8355
+ }
8356
+ async evaluateJSXOpeningElementAsync(node, env) {
8357
+ const type = this.evaluateJSXElementName(node.name, env);
8358
+ const props = {};
8359
+ for (const attr of node.attributes) {
8360
+ if (attr.type === "JSXAttribute") {
8361
+ const name = attr.name.type === "JSXIdentifier" ? attr.name.name : `${attr.name.namespace.name}:${attr.name.name.name}`;
8362
+ const value = attr.value ? await this.evaluateJSXAttributeValueAsync(attr.value, env) : true;
8363
+ props[name] = value;
8364
+ } else if (attr.type === "JSXSpreadAttribute") {
8365
+ Object.assign(props, await this.evaluateAsync(attr.argument, env));
8366
+ }
8367
+ }
8368
+ return { type, props: Object.keys(props).length > 0 ? props : null };
8369
+ }
8370
+ async evaluateJSXAttributeValueAsync(node, env) {
8371
+ if (node.type === "Literal") return node.value;
8372
+ if (node.type === "JSXExpressionContainer") {
8373
+ return await this.evaluateAsync(node.expression, env);
8374
+ }
8375
+ if (node.type === "JSXElement") return await this.evaluateJSXElementAsync(node, env);
8376
+ if (node.type === "JSXFragment") return await this.evaluateJSXFragmentAsync(node, env);
8377
+ throw new Error(`Unknown JSX attribute value type: ${node.type}`);
8378
+ }
8379
+ async evaluateJSXChildrenAsync(children, env) {
8380
+ const result = [];
8381
+ for (const child of children) {
8382
+ if (child.type === "JSXText") {
8383
+ const text = this.normalizeJSXText(child.value);
8384
+ if (text) result.push(text);
8385
+ } else if (child.type === "JSXExpressionContainer") {
8386
+ if (child.expression.type !== "JSXEmptyExpression") {
8387
+ const value = await this.evaluateAsync(child.expression, env);
8388
+ if (Array.isArray(value)) {
8389
+ result.push(...value);
8390
+ } else if (value !== null && value !== void 0 && value !== false) {
8391
+ result.push(value);
8392
+ }
8393
+ }
8394
+ } else if (child.type === "JSXElement") {
8395
+ result.push(await this.evaluateJSXElementAsync(child, env));
8396
+ } else if (child.type === "JSXFragment") {
8397
+ result.push(await this.evaluateJSXFragmentAsync(child, env));
8398
+ }
8399
+ }
8400
+ return result;
8401
+ }
7460
8402
  };
7461
8403
 
7462
8404
  // src/runtime/builtins.js
@@ -7538,6 +8480,17 @@ function createGlobalEnvironment(env) {
7538
8480
  env.define("ReferenceError", ReferenceError);
7539
8481
  env.define("SyntaxError", SyntaxError);
7540
8482
  env.define("RangeError", RangeError);
8483
+ env.define("createElement", (type, props, ...children) => ({
8484
+ $$typeof: Symbol.for("react.element"),
8485
+ type,
8486
+ props: {
8487
+ ...props,
8488
+ children: children.length === 0 ? void 0 : children.length === 1 ? children[0] : children
8489
+ },
8490
+ key: (props == null ? void 0 : props.key) ?? null,
8491
+ ref: (props == null ? void 0 : props.ref) ?? null
8492
+ }));
8493
+ env.define("Fragment", Symbol.for("react.fragment"));
7541
8494
  env.define("log", (...args) => {
7542
8495
  console.log(...args);
7543
8496
  return void 0;
@@ -7926,7 +8879,8 @@ var WangInterpreter = class {
7926
8879
  }
7927
8880
  const hasTopLevelReturn = this.hasTopLevelReturn(code);
7928
8881
  const options = {
7929
- moduleResolver: this.moduleResolver
8882
+ moduleResolver: this.moduleResolver,
8883
+ executionController: userOptions.executionController
7930
8884
  // sourceType will be auto-detected from code
7931
8885
  };
7932
8886
  let result;
@@ -8005,6 +8959,191 @@ var InMemoryModuleResolver = class {
8005
8959
  }
8006
8960
  };
8007
8961
 
8962
+ // src/runtime/execution-controller.js
8963
+ var ExecutionController = class {
8964
+ constructor() {
8965
+ this.state = "idle";
8966
+ this.pauseRequested = false;
8967
+ this.abortRequested = false;
8968
+ this.stepCount = 0;
8969
+ this.currentNode = null;
8970
+ this.callStack = [];
8971
+ this.currentEnv = null;
8972
+ this._resolveResume = null;
8973
+ }
8974
+ // --- Control methods (called by user) ---
8975
+ /**
8976
+ * Request pause at next checkpoint. Only works during async evaluation.
8977
+ */
8978
+ pause() {
8979
+ if (this.state === "running") {
8980
+ this.pauseRequested = true;
8981
+ }
8982
+ }
8983
+ /**
8984
+ * Resume execution after pause.
8985
+ */
8986
+ resume() {
8987
+ if (this.state === "paused" && this._resolveResume) {
8988
+ this.pauseRequested = false;
8989
+ this._resolveResume();
8990
+ this._resolveResume = null;
8991
+ }
8992
+ }
8993
+ /**
8994
+ * Abort execution. Works for both sync and async evaluation.
8995
+ * If paused, will resume and then abort.
8996
+ */
8997
+ abort() {
8998
+ this.abortRequested = true;
8999
+ if (this._resolveResume) {
9000
+ this._resolveResume();
9001
+ this._resolveResume = null;
9002
+ }
9003
+ }
9004
+ // --- Status (called by user) ---
9005
+ /**
9006
+ * Get current execution status with full debug information.
9007
+ * @returns {Object} Status object with state, stepCount, currentNode, callStack, and variables
9008
+ */
9009
+ getStatus() {
9010
+ var _a;
9011
+ return {
9012
+ state: this.state,
9013
+ stepCount: this.stepCount,
9014
+ currentNode: ((_a = this.currentNode) == null ? void 0 : _a.type) || null,
9015
+ callStack: [...this.callStack],
9016
+ variables: this._getEnvironmentVariables()
9017
+ };
9018
+ }
9019
+ /**
9020
+ * Check if abort has been requested.
9021
+ * Compatible with AbortSignal interface.
9022
+ */
9023
+ get aborted() {
9024
+ return this.abortRequested;
9025
+ }
9026
+ // --- Internal methods (called by interpreter) ---
9027
+ /**
9028
+ * Mark execution as started. Called by execute().
9029
+ * @internal
9030
+ */
9031
+ _start() {
9032
+ this.state = "running";
9033
+ this.stepCount = 0;
9034
+ this.currentNode = null;
9035
+ this.callStack = [];
9036
+ this.pauseRequested = false;
9037
+ }
9038
+ /**
9039
+ * Mark execution as completed. Called by execute().
9040
+ * @internal
9041
+ */
9042
+ _complete() {
9043
+ this.state = "completed";
9044
+ }
9045
+ /**
9046
+ * Push a function call onto the call stack.
9047
+ * @internal
9048
+ */
9049
+ _pushCall(name) {
9050
+ this.callStack.push(name);
9051
+ }
9052
+ /**
9053
+ * Pop a function call from the call stack.
9054
+ * @internal
9055
+ */
9056
+ _popCall() {
9057
+ this.callStack.pop();
9058
+ }
9059
+ /**
9060
+ * Set the current environment for variable introspection.
9061
+ * @internal
9062
+ */
9063
+ _setEnv(env) {
9064
+ this.currentEnv = env;
9065
+ }
9066
+ /**
9067
+ * Async checkpoint - yields if paused, throws if aborted.
9068
+ * Called at coarse granularity points (loops, function calls).
9069
+ * @internal
9070
+ */
9071
+ async _checkpoint(node) {
9072
+ this.stepCount++;
9073
+ this.currentNode = node;
9074
+ if (this.abortRequested) {
9075
+ this.state = "aborted";
9076
+ const error = new Error("The operation was aborted");
9077
+ error.name = "AbortError";
9078
+ throw error;
9079
+ }
9080
+ if (this.pauseRequested && this.state === "running") {
9081
+ this.state = "paused";
9082
+ await new Promise((resolve) => {
9083
+ this._resolveResume = resolve;
9084
+ });
9085
+ this.state = "running";
9086
+ if (this.abortRequested) {
9087
+ this.state = "aborted";
9088
+ const error = new Error("The operation was aborted");
9089
+ error.name = "AbortError";
9090
+ throw error;
9091
+ }
9092
+ }
9093
+ }
9094
+ /**
9095
+ * Sync abort check - only throws if aborted, cannot pause.
9096
+ * Used in sync evaluate() path.
9097
+ * @internal
9098
+ */
9099
+ _checkAbortSync() {
9100
+ if (this.abortRequested) {
9101
+ this.state = "aborted";
9102
+ const error = new Error("The operation was aborted");
9103
+ error.name = "AbortError";
9104
+ throw error;
9105
+ }
9106
+ }
9107
+ /**
9108
+ * Get all variables from current environment chain.
9109
+ * @internal
9110
+ */
9111
+ _getEnvironmentVariables() {
9112
+ if (!this.currentEnv) return {};
9113
+ const vars = {};
9114
+ let env = this.currentEnv;
9115
+ while (env) {
9116
+ if (env.vars) {
9117
+ for (const [key, value] of env.vars) {
9118
+ if (!(key in vars)) {
9119
+ vars[key] = this._serializeValue(value);
9120
+ }
9121
+ }
9122
+ }
9123
+ env = env.parent;
9124
+ }
9125
+ return vars;
9126
+ }
9127
+ /**
9128
+ * Serialize a value for status reporting.
9129
+ * @internal
9130
+ */
9131
+ _serializeValue(value) {
9132
+ if (value === void 0) return { type: "undefined" };
9133
+ if (value === null) return { type: "null" };
9134
+ if (typeof value === "function" || value && value.__isFunction) {
9135
+ return { type: "function", name: value.name || "anonymous" };
9136
+ }
9137
+ if (Array.isArray(value)) {
9138
+ return { type: "array", length: value.length };
9139
+ }
9140
+ if (typeof value === "object") {
9141
+ return { type: "object", preview: Object.keys(value).slice(0, 5) };
9142
+ }
9143
+ return { type: typeof value, value };
9144
+ }
9145
+ };
9146
+
8008
9147
  // src/index.js
8009
9148
  function containsModuleSyntax(code) {
8010
9149
  if (/^\s*(import|export)\s+/m.test(code)) {
@@ -8015,14 +9154,14 @@ function containsModuleSyntax(code) {
8015
9154
  }
8016
9155
  return false;
8017
9156
  }
8018
- function parse4(code, options = {}) {
9157
+ function parse3(code, options = {}) {
8019
9158
  var _a;
8020
9159
  let sourceType = options.sourceType || "script";
8021
9160
  if (!options.sourceType && containsModuleSyntax(code)) {
8022
9161
  sourceType = "module";
8023
9162
  }
8024
9163
  try {
8025
- return parse3(code, {
9164
+ return jsxParse(code, {
8026
9165
  ecmaVersion: 2022,
8027
9166
  // Support ES2022 features (including top-level await)
8028
9167
  sourceType,
@@ -8071,21 +9210,39 @@ function containsTopLevelAwait(node) {
8071
9210
  return false;
8072
9211
  }
8073
9212
  async function execute(code, env = null, options = {}) {
8074
- const ast = parse4(code, options);
8075
- if (!env) {
8076
- env = createGlobalEnvironment(new Environment());
9213
+ const controller = options.executionController;
9214
+ if (controller) {
9215
+ controller._start();
8077
9216
  }
8078
- const interpreter = new Interpreter(env, {
8079
- moduleResolver: options.moduleResolver,
8080
- abortSignal: options.abortSignal
8081
- });
8082
- const needsAsync = options.sourceType === "module" || containsModuleDeclarations(ast) || containsTopLevelAwait(ast);
8083
- if (needsAsync) {
8084
- const result = await interpreter.evaluateAsync(ast, env);
8085
- return result instanceof ReturnValue ? result.value : result;
8086
- } else {
8087
- const result = interpreter.evaluate(ast, env);
8088
- return result instanceof ReturnValue ? result.value : result;
9217
+ try {
9218
+ const ast = parse3(code, options);
9219
+ if (!env) {
9220
+ env = createGlobalEnvironment(new Environment());
9221
+ }
9222
+ const interpreter = new Interpreter(env, {
9223
+ moduleResolver: options.moduleResolver,
9224
+ abortSignal: options.abortSignal,
9225
+ executionController: controller
9226
+ });
9227
+ const needsAsync = options.sourceType === "module" || containsModuleDeclarations(ast) || containsTopLevelAwait(ast) || controller != null;
9228
+ if (needsAsync) {
9229
+ const result = await interpreter.evaluateAsync(ast, env);
9230
+ if (controller) {
9231
+ controller._complete();
9232
+ }
9233
+ return result instanceof ReturnValue ? result.value : result;
9234
+ } else {
9235
+ const result = interpreter.evaluate(ast, env);
9236
+ if (controller) {
9237
+ controller._complete();
9238
+ }
9239
+ return result instanceof ReturnValue ? result.value : result;
9240
+ }
9241
+ } catch (e) {
9242
+ if (controller && e.name === "AbortError") {
9243
+ controller.state = "aborted";
9244
+ }
9245
+ throw e;
8089
9246
  }
8090
9247
  }
8091
9248
  function createEnvironment() {
@@ -8123,6 +9280,7 @@ var ModuleResolver = class {
8123
9280
  // Annotate the CommonJS export names for ESM import in node:
8124
9281
  0 && (module.exports = {
8125
9282
  Environment,
9283
+ ExecutionController,
8126
9284
  InMemoryModuleResolver,
8127
9285
  Interpreter,
8128
9286
  ModuleResolver,