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.
@@ -5606,8 +5606,672 @@ Parser.acorn = {
5606
5606
  lineBreakG,
5607
5607
  nonASCIIwhitespace
5608
5608
  };
5609
- function parse3(input, options) {
5610
- return Parser.parse(input, options);
5609
+ var XHTMLEntities = {
5610
+ quot: '"',
5611
+ amp: "&",
5612
+ apos: "'",
5613
+ lt: "<",
5614
+ gt: ">",
5615
+ nbsp: "\xA0",
5616
+ iexcl: "\xA1",
5617
+ cent: "\xA2",
5618
+ pound: "\xA3",
5619
+ curren: "\xA4",
5620
+ yen: "\xA5",
5621
+ brvbar: "\xA6",
5622
+ sect: "\xA7",
5623
+ uml: "\xA8",
5624
+ copy: "\xA9",
5625
+ ordf: "\xAA",
5626
+ laquo: "\xAB",
5627
+ not: "\xAC",
5628
+ shy: "\xAD",
5629
+ reg: "\xAE",
5630
+ macr: "\xAF",
5631
+ deg: "\xB0",
5632
+ plusmn: "\xB1",
5633
+ sup2: "\xB2",
5634
+ sup3: "\xB3",
5635
+ acute: "\xB4",
5636
+ micro: "\xB5",
5637
+ para: "\xB6",
5638
+ middot: "\xB7",
5639
+ cedil: "\xB8",
5640
+ sup1: "\xB9",
5641
+ ordm: "\xBA",
5642
+ raquo: "\xBB",
5643
+ frac14: "\xBC",
5644
+ frac12: "\xBD",
5645
+ frac34: "\xBE",
5646
+ iquest: "\xBF",
5647
+ Agrave: "\xC0",
5648
+ Aacute: "\xC1",
5649
+ Acirc: "\xC2",
5650
+ Atilde: "\xC3",
5651
+ Auml: "\xC4",
5652
+ Aring: "\xC5",
5653
+ AElig: "\xC6",
5654
+ Ccedil: "\xC7",
5655
+ Egrave: "\xC8",
5656
+ Eacute: "\xC9",
5657
+ Ecirc: "\xCA",
5658
+ Euml: "\xCB",
5659
+ Igrave: "\xCC",
5660
+ Iacute: "\xCD",
5661
+ Icirc: "\xCE",
5662
+ Iuml: "\xCF",
5663
+ ETH: "\xD0",
5664
+ Ntilde: "\xD1",
5665
+ Ograve: "\xD2",
5666
+ Oacute: "\xD3",
5667
+ Ocirc: "\xD4",
5668
+ Otilde: "\xD5",
5669
+ Ouml: "\xD6",
5670
+ times: "\xD7",
5671
+ Oslash: "\xD8",
5672
+ Ugrave: "\xD9",
5673
+ Uacute: "\xDA",
5674
+ Ucirc: "\xDB",
5675
+ Uuml: "\xDC",
5676
+ Yacute: "\xDD",
5677
+ THORN: "\xDE",
5678
+ szlig: "\xDF",
5679
+ agrave: "\xE0",
5680
+ aacute: "\xE1",
5681
+ acirc: "\xE2",
5682
+ atilde: "\xE3",
5683
+ auml: "\xE4",
5684
+ aring: "\xE5",
5685
+ aelig: "\xE6",
5686
+ ccedil: "\xE7",
5687
+ egrave: "\xE8",
5688
+ eacute: "\xE9",
5689
+ ecirc: "\xEA",
5690
+ euml: "\xEB",
5691
+ igrave: "\xEC",
5692
+ iacute: "\xED",
5693
+ icirc: "\xEE",
5694
+ iuml: "\xEF",
5695
+ eth: "\xF0",
5696
+ ntilde: "\xF1",
5697
+ ograve: "\xF2",
5698
+ oacute: "\xF3",
5699
+ ocirc: "\xF4",
5700
+ otilde: "\xF5",
5701
+ ouml: "\xF6",
5702
+ divide: "\xF7",
5703
+ oslash: "\xF8",
5704
+ ugrave: "\xF9",
5705
+ uacute: "\xFA",
5706
+ ucirc: "\xFB",
5707
+ uuml: "\xFC",
5708
+ yacute: "\xFD",
5709
+ thorn: "\xFE",
5710
+ yuml: "\xFF",
5711
+ OElig: "\u0152",
5712
+ oelig: "\u0153",
5713
+ Scaron: "\u0160",
5714
+ scaron: "\u0161",
5715
+ Yuml: "\u0178",
5716
+ fnof: "\u0192",
5717
+ circ: "\u02C6",
5718
+ tilde: "\u02DC",
5719
+ Alpha: "\u0391",
5720
+ Beta: "\u0392",
5721
+ Gamma: "\u0393",
5722
+ Delta: "\u0394",
5723
+ Epsilon: "\u0395",
5724
+ Zeta: "\u0396",
5725
+ Eta: "\u0397",
5726
+ Theta: "\u0398",
5727
+ Iota: "\u0399",
5728
+ Kappa: "\u039A",
5729
+ Lambda: "\u039B",
5730
+ Mu: "\u039C",
5731
+ Nu: "\u039D",
5732
+ Xi: "\u039E",
5733
+ Omicron: "\u039F",
5734
+ Pi: "\u03A0",
5735
+ Rho: "\u03A1",
5736
+ Sigma: "\u03A3",
5737
+ Tau: "\u03A4",
5738
+ Upsilon: "\u03A5",
5739
+ Phi: "\u03A6",
5740
+ Chi: "\u03A7",
5741
+ Psi: "\u03A8",
5742
+ Omega: "\u03A9",
5743
+ alpha: "\u03B1",
5744
+ beta: "\u03B2",
5745
+ gamma: "\u03B3",
5746
+ delta: "\u03B4",
5747
+ epsilon: "\u03B5",
5748
+ zeta: "\u03B6",
5749
+ eta: "\u03B7",
5750
+ theta: "\u03B8",
5751
+ iota: "\u03B9",
5752
+ kappa: "\u03BA",
5753
+ lambda: "\u03BB",
5754
+ mu: "\u03BC",
5755
+ nu: "\u03BD",
5756
+ xi: "\u03BE",
5757
+ omicron: "\u03BF",
5758
+ pi: "\u03C0",
5759
+ rho: "\u03C1",
5760
+ sigmaf: "\u03C2",
5761
+ sigma: "\u03C3",
5762
+ tau: "\u03C4",
5763
+ upsilon: "\u03C5",
5764
+ phi: "\u03C6",
5765
+ chi: "\u03C7",
5766
+ psi: "\u03C8",
5767
+ omega: "\u03C9",
5768
+ thetasym: "\u03D1",
5769
+ upsih: "\u03D2",
5770
+ piv: "\u03D6",
5771
+ ensp: "\u2002",
5772
+ emsp: "\u2003",
5773
+ thinsp: "\u2009",
5774
+ zwnj: "\u200C",
5775
+ zwj: "\u200D",
5776
+ lrm: "\u200E",
5777
+ rlm: "\u200F",
5778
+ ndash: "\u2013",
5779
+ mdash: "\u2014",
5780
+ lsquo: "\u2018",
5781
+ rsquo: "\u2019",
5782
+ sbquo: "\u201A",
5783
+ ldquo: "\u201C",
5784
+ rdquo: "\u201D",
5785
+ bdquo: "\u201E",
5786
+ dagger: "\u2020",
5787
+ Dagger: "\u2021",
5788
+ bull: "\u2022",
5789
+ hellip: "\u2026",
5790
+ permil: "\u2030",
5791
+ prime: "\u2032",
5792
+ Prime: "\u2033",
5793
+ lsaquo: "\u2039",
5794
+ rsaquo: "\u203A",
5795
+ oline: "\u203E",
5796
+ frasl: "\u2044",
5797
+ euro: "\u20AC",
5798
+ image: "\u2111",
5799
+ weierp: "\u2118",
5800
+ real: "\u211C",
5801
+ trade: "\u2122",
5802
+ alefsym: "\u2135",
5803
+ larr: "\u2190",
5804
+ uarr: "\u2191",
5805
+ rarr: "\u2192",
5806
+ darr: "\u2193",
5807
+ harr: "\u2194",
5808
+ crarr: "\u21B5",
5809
+ lArr: "\u21D0",
5810
+ uArr: "\u21D1",
5811
+ rArr: "\u21D2",
5812
+ dArr: "\u21D3",
5813
+ hArr: "\u21D4",
5814
+ forall: "\u2200",
5815
+ part: "\u2202",
5816
+ exist: "\u2203",
5817
+ empty: "\u2205",
5818
+ nabla: "\u2207",
5819
+ isin: "\u2208",
5820
+ notin: "\u2209",
5821
+ ni: "\u220B",
5822
+ prod: "\u220F",
5823
+ sum: "\u2211",
5824
+ minus: "\u2212",
5825
+ lowast: "\u2217",
5826
+ radic: "\u221A",
5827
+ prop: "\u221D",
5828
+ infin: "\u221E",
5829
+ ang: "\u2220",
5830
+ and: "\u2227",
5831
+ or: "\u2228",
5832
+ cap: "\u2229",
5833
+ cup: "\u222A",
5834
+ "int": "\u222B",
5835
+ there4: "\u2234",
5836
+ sim: "\u223C",
5837
+ cong: "\u2245",
5838
+ asymp: "\u2248",
5839
+ ne: "\u2260",
5840
+ equiv: "\u2261",
5841
+ le: "\u2264",
5842
+ ge: "\u2265",
5843
+ sub: "\u2282",
5844
+ sup: "\u2283",
5845
+ nsub: "\u2284",
5846
+ sube: "\u2286",
5847
+ supe: "\u2287",
5848
+ oplus: "\u2295",
5849
+ otimes: "\u2297",
5850
+ perp: "\u22A5",
5851
+ sdot: "\u22C5",
5852
+ lceil: "\u2308",
5853
+ rceil: "\u2309",
5854
+ lfloor: "\u230A",
5855
+ rfloor: "\u230B",
5856
+ lang: "\u2329",
5857
+ rang: "\u232A",
5858
+ loz: "\u25CA",
5859
+ spades: "\u2660",
5860
+ clubs: "\u2663",
5861
+ hearts: "\u2665",
5862
+ diams: "\u2666"
5863
+ };
5864
+ var hexNumber = /^[\da-fA-F]+$/;
5865
+ var decimalNumber = /^\d+$/;
5866
+ var acornJsxMap = /* @__PURE__ */ new WeakMap();
5867
+ function getJsxTokens(acorn) {
5868
+ acorn = acorn.Parser.acorn || acorn;
5869
+ let acornJsx2 = acornJsxMap.get(acorn);
5870
+ if (!acornJsx2) {
5871
+ const tt = acorn.tokTypes;
5872
+ const TokContext3 = acorn.TokContext;
5873
+ const TokenType3 = acorn.TokenType;
5874
+ const tc_oTag = new TokContext3("<tag", false);
5875
+ const tc_cTag = new TokContext3("</tag", false);
5876
+ const tc_expr = new TokContext3("<tag>...</tag>", true, true);
5877
+ const tokContexts = {
5878
+ tc_oTag,
5879
+ tc_cTag,
5880
+ tc_expr
5881
+ };
5882
+ const tokTypes = {
5883
+ jsxName: new TokenType3("jsxName"),
5884
+ jsxText: new TokenType3("jsxText", { beforeExpr: true }),
5885
+ jsxTagStart: new TokenType3("jsxTagStart", { startsExpr: true }),
5886
+ jsxTagEnd: new TokenType3("jsxTagEnd")
5887
+ };
5888
+ tokTypes.jsxTagStart.updateContext = function() {
5889
+ this.context.push(tc_expr);
5890
+ this.context.push(tc_oTag);
5891
+ this.exprAllowed = false;
5892
+ };
5893
+ tokTypes.jsxTagEnd.updateContext = function(prevType) {
5894
+ let out = this.context.pop();
5895
+ if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) {
5896
+ this.context.pop();
5897
+ this.exprAllowed = this.curContext() === tc_expr;
5898
+ } else {
5899
+ this.exprAllowed = true;
5900
+ }
5901
+ };
5902
+ acornJsx2 = { tokContexts, tokTypes };
5903
+ acornJsxMap.set(acorn, acornJsx2);
5904
+ }
5905
+ return acornJsx2;
5906
+ }
5907
+ function getQualifiedJSXName(object) {
5908
+ if (!object)
5909
+ return object;
5910
+ if (object.type === "JSXIdentifier")
5911
+ return object.name;
5912
+ if (object.type === "JSXNamespacedName")
5913
+ return object.namespace.name + ":" + object.name.name;
5914
+ if (object.type === "JSXMemberExpression")
5915
+ return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
5916
+ }
5917
+ function acornJsx(options) {
5918
+ options = options || {};
5919
+ return function(Parser3) {
5920
+ return plugin({
5921
+ allowNamespaces: options.allowNamespaces !== false,
5922
+ allowNamespacedObjects: !!options.allowNamespacedObjects
5923
+ }, Parser3);
5924
+ };
5925
+ }
5926
+ function plugin(options, Parser3) {
5927
+ const acorn = Parser3.acorn || { tokTypes: tt, TokContext, TokenType, isNewLine: isNewLine2, isIdentifierStart: isIdentifierStart2, isIdentifierChar: isIdentifierChar2, tokContexts };
5928
+ const acornJsx2 = getJsxTokens(acorn);
5929
+ const tt = acorn.tokTypes;
5930
+ const tok = acornJsx2.tokTypes;
5931
+ const tokContexts = acorn.tokContexts;
5932
+ const tc_oTag = acornJsx2.tokContexts.tc_oTag;
5933
+ const tc_cTag = acornJsx2.tokContexts.tc_cTag;
5934
+ const tc_expr = acornJsx2.tokContexts.tc_expr;
5935
+ const isNewLine2 = acorn.isNewLine;
5936
+ const isIdentifierStart2 = acorn.isIdentifierStart;
5937
+ const isIdentifierChar2 = acorn.isIdentifierChar;
5938
+ return class extends Parser3 {
5939
+ // Expose actual `tokTypes` and `tokContexts` to other plugins.
5940
+ static get acornJsx() {
5941
+ return acornJsx2;
5942
+ }
5943
+ // Reads inline JSX contents token.
5944
+ jsx_readToken() {
5945
+ let out = "", chunkStart = this.pos;
5946
+ for (; ; ) {
5947
+ if (this.pos >= this.input.length)
5948
+ this.raise(this.start, "Unterminated JSX contents");
5949
+ let ch = this.input.charCodeAt(this.pos);
5950
+ switch (ch) {
5951
+ case 60:
5952
+ // '<'
5953
+ case 123:
5954
+ if (this.pos === this.start) {
5955
+ if (ch === 60 && this.exprAllowed) {
5956
+ ++this.pos;
5957
+ return this.finishToken(tok.jsxTagStart);
5958
+ }
5959
+ return this.getTokenFromCode(ch);
5960
+ }
5961
+ out += this.input.slice(chunkStart, this.pos);
5962
+ return this.finishToken(tok.jsxText, out);
5963
+ case 38:
5964
+ out += this.input.slice(chunkStart, this.pos);
5965
+ out += this.jsx_readEntity();
5966
+ chunkStart = this.pos;
5967
+ break;
5968
+ case 62:
5969
+ // '>'
5970
+ case 125:
5971
+ this.raise(
5972
+ this.pos,
5973
+ "Unexpected token `" + this.input[this.pos] + "`. Did you mean `" + (ch === 62 ? "&gt;" : "&rbrace;") + '` or `{"' + this.input[this.pos] + '"}`?'
5974
+ );
5975
+ default:
5976
+ if (isNewLine2(ch)) {
5977
+ out += this.input.slice(chunkStart, this.pos);
5978
+ out += this.jsx_readNewLine(true);
5979
+ chunkStart = this.pos;
5980
+ } else {
5981
+ ++this.pos;
5982
+ }
5983
+ }
5984
+ }
5985
+ }
5986
+ jsx_readNewLine(normalizeCRLF) {
5987
+ let ch = this.input.charCodeAt(this.pos);
5988
+ let out;
5989
+ ++this.pos;
5990
+ if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
5991
+ ++this.pos;
5992
+ out = normalizeCRLF ? "\n" : "\r\n";
5993
+ } else {
5994
+ out = String.fromCharCode(ch);
5995
+ }
5996
+ if (this.options.locations) {
5997
+ ++this.curLine;
5998
+ this.lineStart = this.pos;
5999
+ }
6000
+ return out;
6001
+ }
6002
+ jsx_readString(quote) {
6003
+ let out = "", chunkStart = ++this.pos;
6004
+ for (; ; ) {
6005
+ if (this.pos >= this.input.length)
6006
+ this.raise(this.start, "Unterminated string constant");
6007
+ let ch = this.input.charCodeAt(this.pos);
6008
+ if (ch === quote) break;
6009
+ if (ch === 38) {
6010
+ out += this.input.slice(chunkStart, this.pos);
6011
+ out += this.jsx_readEntity();
6012
+ chunkStart = this.pos;
6013
+ } else if (isNewLine2(ch)) {
6014
+ out += this.input.slice(chunkStart, this.pos);
6015
+ out += this.jsx_readNewLine(false);
6016
+ chunkStart = this.pos;
6017
+ } else {
6018
+ ++this.pos;
6019
+ }
6020
+ }
6021
+ out += this.input.slice(chunkStart, this.pos++);
6022
+ return this.finishToken(tt.string, out);
6023
+ }
6024
+ jsx_readEntity() {
6025
+ let str = "", count = 0, entity;
6026
+ let ch = this.input[this.pos];
6027
+ if (ch !== "&")
6028
+ this.raise(this.pos, "Entity must start with an ampersand");
6029
+ let startPos = ++this.pos;
6030
+ while (this.pos < this.input.length && count++ < 10) {
6031
+ ch = this.input[this.pos++];
6032
+ if (ch === ";") {
6033
+ if (str[0] === "#") {
6034
+ if (str[1] === "x") {
6035
+ str = str.substr(2);
6036
+ if (hexNumber.test(str))
6037
+ entity = String.fromCharCode(parseInt(str, 16));
6038
+ } else {
6039
+ str = str.substr(1);
6040
+ if (decimalNumber.test(str))
6041
+ entity = String.fromCharCode(parseInt(str, 10));
6042
+ }
6043
+ } else {
6044
+ entity = XHTMLEntities[str];
6045
+ }
6046
+ break;
6047
+ }
6048
+ str += ch;
6049
+ }
6050
+ if (!entity) {
6051
+ this.pos = startPos;
6052
+ return "&";
6053
+ }
6054
+ return entity;
6055
+ }
6056
+ // Read a JSX identifier (valid tag or attribute name).
6057
+ //
6058
+ // Optimized version since JSX identifiers can't contain
6059
+ // escape characters and so can be read as single slice.
6060
+ // Also assumes that first character was already checked
6061
+ // by isIdentifierStart in readToken.
6062
+ jsx_readWord() {
6063
+ let ch, start = this.pos;
6064
+ do {
6065
+ ch = this.input.charCodeAt(++this.pos);
6066
+ } while (isIdentifierChar2(ch) || ch === 45);
6067
+ return this.finishToken(tok.jsxName, this.input.slice(start, this.pos));
6068
+ }
6069
+ // Parse next token as JSX identifier
6070
+ jsx_parseIdentifier() {
6071
+ let node = this.startNode();
6072
+ if (this.type === tok.jsxName)
6073
+ node.name = this.value;
6074
+ else if (this.type.keyword)
6075
+ node.name = this.type.keyword;
6076
+ else
6077
+ this.unexpected();
6078
+ this.next();
6079
+ return this.finishNode(node, "JSXIdentifier");
6080
+ }
6081
+ // Parse namespaced identifier.
6082
+ jsx_parseNamespacedName() {
6083
+ let startPos = this.start, startLoc = this.startLoc;
6084
+ let name = this.jsx_parseIdentifier();
6085
+ if (!options.allowNamespaces || !this.eat(tt.colon)) return name;
6086
+ var node = this.startNodeAt(startPos, startLoc);
6087
+ node.namespace = name;
6088
+ node.name = this.jsx_parseIdentifier();
6089
+ return this.finishNode(node, "JSXNamespacedName");
6090
+ }
6091
+ // Parses element name in any form - namespaced, member
6092
+ // or single identifier.
6093
+ jsx_parseElementName() {
6094
+ if (this.type === tok.jsxTagEnd) return "";
6095
+ let startPos = this.start, startLoc = this.startLoc;
6096
+ let node = this.jsx_parseNamespacedName();
6097
+ if (this.type === tt.dot && node.type === "JSXNamespacedName" && !options.allowNamespacedObjects) {
6098
+ this.unexpected();
6099
+ }
6100
+ while (this.eat(tt.dot)) {
6101
+ let newNode = this.startNodeAt(startPos, startLoc);
6102
+ newNode.object = node;
6103
+ newNode.property = this.jsx_parseIdentifier();
6104
+ node = this.finishNode(newNode, "JSXMemberExpression");
6105
+ }
6106
+ return node;
6107
+ }
6108
+ // Parses any type of JSX attribute value.
6109
+ jsx_parseAttributeValue() {
6110
+ switch (this.type) {
6111
+ case tt.braceL:
6112
+ let node = this.jsx_parseExpressionContainer();
6113
+ if (node.expression.type === "JSXEmptyExpression")
6114
+ this.raise(node.start, "JSX attributes must only be assigned a non-empty expression");
6115
+ return node;
6116
+ case tok.jsxTagStart:
6117
+ case tt.string:
6118
+ return this.parseExprAtom();
6119
+ default:
6120
+ this.raise(this.start, "JSX value should be either an expression or a quoted JSX text");
6121
+ }
6122
+ }
6123
+ // JSXEmptyExpression is unique type since it doesn't actually parse anything,
6124
+ // and so it should start at the end of last read token (left brace) and finish
6125
+ // at the beginning of the next one (right brace).
6126
+ jsx_parseEmptyExpression() {
6127
+ let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
6128
+ return this.finishNodeAt(node, "JSXEmptyExpression", this.start, this.startLoc);
6129
+ }
6130
+ // Parses JSX expression enclosed into curly brackets.
6131
+ jsx_parseExpressionContainer() {
6132
+ let node = this.startNode();
6133
+ this.next();
6134
+ node.expression = this.type === tt.braceR ? this.jsx_parseEmptyExpression() : this.parseExpression();
6135
+ this.expect(tt.braceR);
6136
+ return this.finishNode(node, "JSXExpressionContainer");
6137
+ }
6138
+ // Parses following JSX attribute name-value pair.
6139
+ jsx_parseAttribute() {
6140
+ let node = this.startNode();
6141
+ if (this.eat(tt.braceL)) {
6142
+ this.expect(tt.ellipsis);
6143
+ node.argument = this.parseMaybeAssign();
6144
+ this.expect(tt.braceR);
6145
+ return this.finishNode(node, "JSXSpreadAttribute");
6146
+ }
6147
+ node.name = this.jsx_parseNamespacedName();
6148
+ node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
6149
+ return this.finishNode(node, "JSXAttribute");
6150
+ }
6151
+ // Parses JSX opening tag starting after '<'.
6152
+ jsx_parseOpeningElementAt(startPos, startLoc) {
6153
+ let node = this.startNodeAt(startPos, startLoc);
6154
+ node.attributes = [];
6155
+ let nodeName = this.jsx_parseElementName();
6156
+ if (nodeName) node.name = nodeName;
6157
+ while (this.type !== tt.slash && this.type !== tok.jsxTagEnd)
6158
+ node.attributes.push(this.jsx_parseAttribute());
6159
+ node.selfClosing = this.eat(tt.slash);
6160
+ this.expect(tok.jsxTagEnd);
6161
+ return this.finishNode(node, nodeName ? "JSXOpeningElement" : "JSXOpeningFragment");
6162
+ }
6163
+ // Parses JSX closing tag starting after '</'.
6164
+ jsx_parseClosingElementAt(startPos, startLoc) {
6165
+ let node = this.startNodeAt(startPos, startLoc);
6166
+ let nodeName = this.jsx_parseElementName();
6167
+ if (nodeName) node.name = nodeName;
6168
+ this.expect(tok.jsxTagEnd);
6169
+ return this.finishNode(node, nodeName ? "JSXClosingElement" : "JSXClosingFragment");
6170
+ }
6171
+ // Parses entire JSX element, including it's opening tag
6172
+ // (starting after '<'), attributes, contents and closing tag.
6173
+ jsx_parseElementAt(startPos, startLoc) {
6174
+ let node = this.startNodeAt(startPos, startLoc);
6175
+ let children = [];
6176
+ let openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
6177
+ let closingElement = null;
6178
+ if (!openingElement.selfClosing) {
6179
+ contents: for (; ; ) {
6180
+ switch (this.type) {
6181
+ case tok.jsxTagStart:
6182
+ startPos = this.start;
6183
+ startLoc = this.startLoc;
6184
+ this.next();
6185
+ if (this.eat(tt.slash)) {
6186
+ closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
6187
+ break contents;
6188
+ }
6189
+ children.push(this.jsx_parseElementAt(startPos, startLoc));
6190
+ break;
6191
+ case tok.jsxText:
6192
+ children.push(this.parseExprAtom());
6193
+ break;
6194
+ case tt.braceL:
6195
+ children.push(this.jsx_parseExpressionContainer());
6196
+ break;
6197
+ default:
6198
+ this.unexpected();
6199
+ }
6200
+ }
6201
+ if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
6202
+ this.raise(
6203
+ closingElement.start,
6204
+ "Expected corresponding JSX closing tag for <" + getQualifiedJSXName(openingElement.name) + ">"
6205
+ );
6206
+ }
6207
+ }
6208
+ let fragmentOrElement = openingElement.name ? "Element" : "Fragment";
6209
+ node["opening" + fragmentOrElement] = openingElement;
6210
+ node["closing" + fragmentOrElement] = closingElement;
6211
+ node.children = children;
6212
+ if (this.type === tt.relational && this.value === "<") {
6213
+ this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
6214
+ }
6215
+ return this.finishNode(node, "JSX" + fragmentOrElement);
6216
+ }
6217
+ // Parse JSX text
6218
+ jsx_parseText() {
6219
+ let node = this.parseLiteral(this.value);
6220
+ node.type = "JSXText";
6221
+ return node;
6222
+ }
6223
+ // Parses entire JSX element from current position.
6224
+ jsx_parseElement() {
6225
+ let startPos = this.start, startLoc = this.startLoc;
6226
+ this.next();
6227
+ return this.jsx_parseElementAt(startPos, startLoc);
6228
+ }
6229
+ parseExprAtom(refShortHandDefaultPos) {
6230
+ if (this.type === tok.jsxText)
6231
+ return this.jsx_parseText();
6232
+ else if (this.type === tok.jsxTagStart)
6233
+ return this.jsx_parseElement();
6234
+ else
6235
+ return super.parseExprAtom(refShortHandDefaultPos);
6236
+ }
6237
+ readToken(code) {
6238
+ let context = this.curContext();
6239
+ if (context === tc_expr) return this.jsx_readToken();
6240
+ if (context === tc_oTag || context === tc_cTag) {
6241
+ if (isIdentifierStart2(code)) return this.jsx_readWord();
6242
+ if (code == 62) {
6243
+ ++this.pos;
6244
+ return this.finishToken(tok.jsxTagEnd);
6245
+ }
6246
+ if ((code === 34 || code === 39) && context == tc_oTag)
6247
+ return this.jsx_readString(code);
6248
+ }
6249
+ if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
6250
+ ++this.pos;
6251
+ return this.finishToken(tok.jsxTagStart);
6252
+ }
6253
+ return super.readToken(code);
6254
+ }
6255
+ updateContext(prevType) {
6256
+ if (this.type == tt.braceL) {
6257
+ var curContext = this.curContext();
6258
+ if (curContext == tc_oTag) this.context.push(tokContexts.b_expr);
6259
+ else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl);
6260
+ else super.updateContext(prevType);
6261
+ this.exprAllowed = true;
6262
+ } else if (this.type === tt.slash && prevType === tok.jsxTagStart) {
6263
+ this.context.length -= 2;
6264
+ this.context.push(tc_cTag);
6265
+ this.exprAllowed = false;
6266
+ } else {
6267
+ return super.updateContext(prevType);
6268
+ }
6269
+ }
6270
+ };
6271
+ }
6272
+ var JSXParser = Parser.extend(acornJsx());
6273
+ function jsxParse(input, options) {
6274
+ return JSXParser.parse(input, options);
5611
6275
  }
5612
6276
 
5613
6277
  // src/index.js
@@ -5620,14 +6284,14 @@ function containsModuleSyntax(code) {
5620
6284
  }
5621
6285
  return false;
5622
6286
  }
5623
- function parse4(code, options = {}) {
6287
+ function parse3(code, options = {}) {
5624
6288
  var _a;
5625
6289
  let sourceType = options.sourceType || "script";
5626
6290
  if (!options.sourceType && containsModuleSyntax(code)) {
5627
6291
  sourceType = "module";
5628
6292
  }
5629
6293
  try {
5630
- return parse3(code, {
6294
+ return jsxParse(code, {
5631
6295
  ecmaVersion: 2022,
5632
6296
  // Support ES2022 features (including top-level await)
5633
6297
  sourceType,
@@ -5657,7 +6321,7 @@ var WangValidator = class {
5657
6321
  validate(code, options = {}) {
5658
6322
  var _a, _b;
5659
6323
  try {
5660
- const ast = parse4(code);
6324
+ const ast = parse3(code);
5661
6325
  return {
5662
6326
  valid: true,
5663
6327
  ast: options.includeAST ? ast : void 0