sveast 0.9.5 → 0.9.7
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/README.md +49 -4
- package/a11y.d.ts +1636 -0
- package/a11y.js +36 -0
- package/core.js +1 -1
- package/index.d.ts +39 -7
- package/index.js +1 -1
- package/is-valid-type.js +1 -1
- package/lexer.d.ts +39 -7
- package/lexer.js +2 -2
- package/module.js +1 -1
- package/package.json +6 -1
- package/parse-imports-exports.js +1 -1
- package/parse-module.js +1 -1
- package/parse-sections.js +1 -1
- package/parse.js +1 -1
- package/runes.js +1 -1
- package/{shared-rce4ty8a.js → shared-a23q4q40.js} +1 -1
- package/shared-dscc5xg8.js +2 -0
- package/shared-e4gbs4rb.js +3 -0
- package/{shared-cs1ezg1f.js → shared-f45stvzk.js} +1 -1
- package/{shared-rvkvagj5.js → shared-k0xcpcmz.js} +1 -1
- package/{shared-qkp49nav.js → shared-nb0h4j83.js} +1 -1
- package/{shared-xwzsb4m8.js → shared-qqrqzz29.js} +1 -1
- package/shared-s46wfvhw.js +10 -0
- package/{shared-nan648gn.js → shared-w3mxqtgj.js} +1 -1
- package/{shared-z9y4mrek.js → shared-x2vs5571.js} +1 -1
- package/{shared-y41kz9tv.js → shared-xmc2pnaf.js} +1 -1
- package/typescript.js +1 -1
- package/shared-2pngd0mg.js +0 -10
- package/shared-ke0fgd3r.js +0 -2
- package/shared-y3nf00py.js +0 -3
package/lexer.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{isDigit}from"./shared-5tpb3h6x.js";import{isWordCode,scan,scanLiterals,lineEnd,skipTrivia,isWordAt}from"./shared-
|
|
1
|
+
import{isDigit}from"./shared-5tpb3h6x.js";import{isWordCode,scan,scanLiterals,scanCalls,closingBracket,lineEnd,skipTrivia,isWordAt}from"./shared-e4gbs4rb.js";import"./shared-dgdrqgdn.js";import{lexComponent2}from"./shared-a23q4q40.js";function lexImportsExports(source,options={}){let lexer=new Lexer(source);lexer.exportLists=options.exportLists??!1;let statements=[];return scan(source,!1,(_start,keyword)=>{let statement=lexer.statement(keyword);return statements.push(statement),statement.end},lexer.exportLists),statements}function lexDynamicImports(source){let lexer=new Lexer(source),imports=[];return scanCalls(source,(start,member)=>{let call=lexer.dynamicImport(start,member);if(call!==null)imports.push(call)}),imports}function lexStrings(source){let lexer=new Lexer(source),strings=[];return scanLiterals(source,(start,end,template)=>{let quote=template?0:1;strings.push({kind:template?"template":"string",value:lexer.cooked(start+quote,end-quote,template),start,end})}),strings}class Lexer{source;pos=0;end=0;escapeEnd=0;exportLists=!1;constructor(source){this.source=source}statement(keyword){this.pos=this.end=keyword+6;let statement={kind:this.source.charCodeAt(keyword)===105?"import":"export",start:keyword,end:0,source:null,typeOnly:!1,specifiers:[]};if(!(statement.kind==="import"?this.import(statement):this.export(statement)))statement.source=null,statement.specifiers=[];return statement.end=this.end,statement}import(statement){let module=this.string();if(module!==null)return statement.source=module,this.finish();if(this.isWord("type")){let next=this.peekAfter(4);if(next===123||next===42||isIdentifierStart(next)&&!this.isWordAfter(4,"from"))statement.typeOnly=!0,this.advance(4)}let{specifiers,typeOnly}=statement,next=this.at();if(next!==123&&next!==42){let start=this.pos,local=this.name();if(local===null)return!1;if(this.at()===61)return this.importEquals();if(specifiers.push({kind:"default",imported:"default",local,typeOnly,start,end:this.end}),!this.eat(44))return this.from(statement);next=this.at()}if(next===42){let start=this.pos;if(this.advance(1),!this.eatWord("as"))return!1;let local=this.name();if(local===null)return!1;return specifiers.push({kind:"namespace",imported:"*",local,typeOnly,start,end:this.end}),this.from(statement)}if(!this.eat(123))return!1;while(!this.eat(125)){let start=this.skip(),named=this.typeModifier()||typeOnly,name=this.name(),imported=name??this.string()?.value;if(imported===void 0)return!1;let local=name;if(this.eatWord("as"))local=this.name();if(local===null)return!1;if(specifiers.push({kind:"named",imported,local,typeOnly:named,start,end:this.end}),!this.eat(44)&&this.at()!==125)return!1}return this.from(statement)}export(statement){if(this.eatWord("import")){if(this.isWord("type")&&isIdentifierStart(this.peekAfter(4))&&!this.isWordAfter(4,"from"))statement.typeOnly=!0,this.advance(4);return this.name()!==null&&this.at()===61&&this.importEquals()}if(this.isWord("type")){let next=this.peekAfter(4);if(next===123||next===42)statement.typeOnly=!0,this.advance(4)}let{specifiers,typeOnly}=statement;if(this.at()===42){let start=this.pos;this.advance(1);let exported=null;if(this.eatWord("as")){if(exported=this.moduleExportName(),exported===null)return!1}return specifiers.push({kind:exported===null?"all":"namespace",local:"*",exported,typeOnly,start,end:this.end}),this.from(statement)}if(!this.eat(123))return!1;while(!this.eat(125)){let start=this.skip(),named=this.typeModifier()||typeOnly,local=this.moduleExportName();if(local===null)return!1;let exported=local;if(this.eatWord("as"))exported=this.moduleExportName();if(exported===null)return!1;if(specifiers.push({kind:"named",local,exported,typeOnly:named,start,end:this.end}),!this.eat(44)&&this.at()!==125)return!1}if(this.exportLists&&!this.isWord("from")){for(let specifier of specifiers)specifier.kind="local";return this.eat(59),!0}return this.from(statement)}dynamicImport(start,member){let isImport=this.source.charCodeAt(start)===105;this.pos=this.end=start+(isImport?6:7);let kind=isImport?"import":"require";if(isImport&&this.eat(46)){if(!this.eatWord("meta")||!this.eat(46)||!this.eatWord("glob")||!this.typeArguments())return null;kind="glob"}if(!this.eat(40))return null;let argument=this.skip(),source=this.string()??this.template(),close=this.at()===41?this.pos:-1;if(close===-1){if(this.at()!==44)source=null;close=closingBracket(this.source,argument)}if(member&&kind!=="glob"){let after=this.source.charCodeAt(skipTrivia(this.source,close+1));if(after===123||after===58)return null}return{kind,source,start,end:Math.min(close+1,this.source.length)}}typeArguments(){if(this.at()!==60)return!0;let source=this.source,depth=0;for(let i=this.pos;i<source.length;i=skipTrivia(source,i+1)){let code=source.charCodeAt(i);if(code===34||code===39||code===96){let end=source.indexOf(source[i],i+1);if(end===-1)return!1;i=end}else if(code===60)depth++;else if(code===62&&source.charCodeAt(i-1)!==61){if(--depth===0)return this.advance(i+1-this.pos),!0}}return!1}template(){let source=this.source,start=this.skip();if(source.charCodeAt(start)!==96)return null;for(let i=start+1;i<source.length;i++){let code=source.charCodeAt(i);if(code===96){let value=this.cooked(start+1,i,!0);if(value===null)return null;return this.advance(i+1-start),{value,start,end:i+1}}if(code===92)i++;else if(code===36&&source.charCodeAt(i+1)===123)return null}return null}typeModifier(){if(!this.isWord("type"))return!1;let next=this.peekAfter(4);if(next===34||next===39||isIdentifierStart(next)&&!this.isWordAfter(4,"as"))return this.advance(4),!0;return!1}importEquals(){if(this.advance(1),this.isWord("require")&&this.peekAfter(7)===40){if(this.advance(7),this.eat(40),this.string()===null||!this.eat(41))return!1}else do if(this.name()===null)return!1;while(this.eat(46));return this.eat(59),!0}from(statement){if(!this.eatWord("from"))return!1;return statement.source=this.string(),statement.source!==null&&this.finish()}finish(){let keyword=this.isWord("with")?4:0;if(this.isWord("assert")&&lineEnd(this.source,this.end)>=this.pos)keyword=6;if(keyword!==0&&this.peekAfter(keyword)===123){this.advance(keyword),this.eat(123);while(!this.eat(125))if(this.string()===null&&this.name()===null&&!this.eat(58)&&!this.eat(44))return!1}return this.eat(59),!0}skip(){return this.pos=skipTrivia(this.source,this.pos),this.pos}at(){return this.source.charCodeAt(this.skip())}advance(length){this.pos+=length,this.end=this.pos}peekAfter(length){return this.source.charCodeAt(skipTrivia(this.source,this.pos+length))}isWordAfter(length,word){return isWordAt(this.source,skipTrivia(this.source,this.pos+length),word)}eat(code){if(this.at()!==code)return!1;return this.advance(1),!0}isWord(word){return isWordAt(this.source,this.skip(),word)}eatWord(word){if(!this.isWord(word))return!1;return this.advance(word.length),!0}moduleExportName(){return this.name()??this.string()?.value??null}name(){let source=this.source,start=this.skip();if(!isWordCode(source.charCodeAt(start))||isDigit(source.charCodeAt(start)))return null;let value="",chunk=start,i=start;while(i<source.length){let code=source.charCodeAt(i);if(code===92){if(source.charCodeAt(i+1)!==117)return null;let escaped=this.unicodeEscape(i+2);if(escaped===null)return null;value+=source.slice(chunk,i)+escaped,i=chunk=this.escapeEnd}else if(isWordCode(code))i++;else break}return this.advance(i-start),value+source.slice(chunk,i)}string(){let source=this.source,start=this.skip(),quote=source.charCodeAt(start);if(quote!==34&"e!==39)return null;let value="",chunk=start+1;for(let i=chunk;i<source.length;){let code=source.charCodeAt(i);if(code===quote)return this.advance(i+1-start),{value:value+source.slice(chunk,i),start,end:i+1};if(code===10||code===13)return null;if(code===92){let escaped=this.escape(i+1);if(escaped===null)return null;value+=source.slice(chunk,i)+escaped,i=chunk=this.escapeEnd}else i++}return null}cooked(from,to,template){let source=this.source,value="",chunk=from;for(let i=from;i<to;){let code=source.charCodeAt(i);if(code===92){let escaped=this.escape(i+1);if(escaped===null)return null;value+=source.slice(chunk,i)+escaped,i=chunk=this.escapeEnd}else if(code===13&&template)value+=`${source.slice(chunk,i)}
|
|
2
2
|
`,i+=source.charCodeAt(i+1)===10?2:1,chunk=i;else i++}return value+source.slice(chunk,to)}escape(pos){let code=this.source.charCodeAt(pos);switch(this.escapeEnd=pos+1,code){case 110:return`
|
|
3
|
-
`;case 114:return"\r";case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 48:return isDigit(this.source.charCodeAt(pos+1))?null:"\x00";case 120:return this.hexEscape(pos+1,2);case 117:return this.unicodeEscape(pos+1);case 13:if(this.source.charCodeAt(pos+1)===10)this.escapeEnd++;return"";case 10:case 8232:case 8233:return"";default:return isDigit(code)||pos>=this.source.length?null:String.fromCharCode(code)}}unicodeEscape(pos){if(this.source.charCodeAt(pos)!==123)return this.hexEscape(pos,4);let value=0,i=pos+1;for(;this.source.charCodeAt(i)!==125;i++){let digit=hexValue(this.source.charCodeAt(i));if(digit===-1)return null;if(value=value*16+digit,value>1114111)return null}if(i===pos+1)return null;return this.escapeEnd=i+1,String.fromCodePoint(value)}hexEscape(pos,length){let value=0;for(let i=pos;i<pos+length;i++){let digit=hexValue(this.source.charCodeAt(i));if(digit===-1)return null;value=value*16+digit}return this.escapeEnd=pos+length,String.fromCharCode(value)}}function isIdentifierStart(code){return code!==92&&isWordCode(code)&&!isDigit(code)}function hexValue(code){if(isDigit(code))return code-48;let lower=code|32;return lower>=97&&lower<=102?lower-87:-1}export{lexComponent2 as lexComponent,lexImportsExports,lexStrings};
|
|
3
|
+
`;case 114:return"\r";case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 48:return isDigit(this.source.charCodeAt(pos+1))?null:"\x00";case 120:return this.hexEscape(pos+1,2);case 117:return this.unicodeEscape(pos+1);case 13:if(this.source.charCodeAt(pos+1)===10)this.escapeEnd++;return"";case 10:case 8232:case 8233:return"";default:return isDigit(code)||pos>=this.source.length?null:String.fromCharCode(code)}}unicodeEscape(pos){if(this.source.charCodeAt(pos)!==123)return this.hexEscape(pos,4);let value=0,i=pos+1;for(;this.source.charCodeAt(i)!==125;i++){let digit=hexValue(this.source.charCodeAt(i));if(digit===-1)return null;if(value=value*16+digit,value>1114111)return null}if(i===pos+1)return null;return this.escapeEnd=i+1,String.fromCodePoint(value)}hexEscape(pos,length){let value=0;for(let i=pos;i<pos+length;i++){let digit=hexValue(this.source.charCodeAt(i));if(digit===-1)return null;value=value*16+digit}return this.escapeEnd=pos+length,String.fromCharCode(value)}}function isIdentifierStart(code){return code!==92&&isWordCode(code)&&!isDigit(code)}function hexValue(code){if(isDigit(code))return code-48;let lower=code|32;return lower>=97&&lower<=102?lower-87:-1}export{lexComponent2 as lexComponent,lexDynamicImports,lexImportsExports,lexStrings};
|
package/module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-s46wfvhw.js";import"./shared-m0dcdh24.js";import{ParseError2}from"./shared-w3mxqtgj.js";import"./shared-5tpb3h6x.js";import"./shared-e4gbs4rb.js";import{parseModuleWith}from"./shared-x2vs5571.js";import{parseImportsExportsWith}from"./shared-k0xcpcmz.js";import{typeScriptParser}from"./shared-h6z1kjbb.js";function createModuleParser(support={}){let typescript=typeScriptParser(support.typescript);return{parseModule:(source,options={})=>parseModuleWith(source,options,typescript),parseImportsExports:(source,options={})=>parseImportsExportsWith(source,options,typescript)}}export{ParseError2 as ParseError,createModuleParser};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sveast",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Fast, zero-dependency Svelte 5 parser with svelte/compiler's AST.",
|
|
6
6
|
"author": "Eric Liu (https://github.com/metonym)",
|
|
@@ -47,6 +47,11 @@
|
|
|
47
47
|
"types": "./lexer.d.ts",
|
|
48
48
|
"import": "./lexer.js",
|
|
49
49
|
"default": "./lexer.js"
|
|
50
|
+
},
|
|
51
|
+
"./a11y": {
|
|
52
|
+
"types": "./a11y.d.ts",
|
|
53
|
+
"import": "./a11y.js",
|
|
54
|
+
"default": "./a11y.js"
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
"sideEffects": false,
|
package/parse-imports-exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-s46wfvhw.js";import"./shared-m0dcdh24.js";import"./shared-w3mxqtgj.js";import"./shared-5tpb3h6x.js";import"./shared-e4gbs4rb.js";import"./shared-f45stvzk.js";import{TypeScriptParser}from"./shared-dscc5xg8.js";import{parseImportsExportsWith}from"./shared-k0xcpcmz.js";function parseImportsExports(source,options={}){return parseImportsExportsWith(source,options,TypeScriptParser)}export{parseImportsExports};
|
package/parse-module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-s46wfvhw.js";import"./shared-m0dcdh24.js";import{ParseError2}from"./shared-w3mxqtgj.js";import"./shared-f45stvzk.js";import{TypeScriptParser}from"./shared-dscc5xg8.js";import{parseModuleWith}from"./shared-x2vs5571.js";function parseModule(source,options={}){return parseModuleWith(source,options,TypeScriptParser)}export{ParseError2 as ParseError,parseModule};
|
package/parse-sections.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseSections2}from"./shared-
|
|
1
|
+
import{parseSections2}from"./shared-xmc2pnaf.js";import"./shared-a23q4q40.js";import"./shared-drb44hb9.js";import"./shared-dscc5xg8.js";import"./shared-f45stvzk.js";import"./shared-qqrqzz29.js";import"./shared-bzqbnvee.js";import"./shared-dgdrqgdn.js";import"./shared-e4gbs4rb.js";import"./shared-5tpb3h6x.js";import"./shared-w3mxqtgj.js";import"./shared-m0dcdh24.js";import"./shared-s46wfvhw.js";export{parseSections2 as parseSections};
|
package/parse.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parse2}from"./shared-
|
|
1
|
+
import{parse2}from"./shared-nb0h4j83.js";import"./shared-drb44hb9.js";import"./shared-dscc5xg8.js";import"./shared-f45stvzk.js";import"./shared-qqrqzz29.js";import"./shared-bzqbnvee.js";import"./shared-dgdrqgdn.js";import"./shared-5tpb3h6x.js";import"./shared-w3mxqtgj.js";import"./shared-m0dcdh24.js";import"./shared-s46wfvhw.js";export{parse2 as parse};
|
package/runes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-dgdrqgdn.js";import{withoutByteOrderMark,isWhitespace,skipWhitespace}from"./shared-5tpb3h6x.js";import{isWordCode,closingBracket,wordCodesEnd}from"./shared-
|
|
1
|
+
import"./shared-dgdrqgdn.js";import{withoutByteOrderMark,isWhitespace,skipWhitespace}from"./shared-5tpb3h6x.js";import{isWordCode,closingBracket,wordCodesEnd}from"./shared-e4gbs4rb.js";import"./shared-m0dcdh24.js";import"./shared-s46wfvhw.js";import"./shared-w3mxqtgj.js";import"./shared-bzqbnvee.js";import"./shared-qqrqzz29.js";import"./shared-f45stvzk.js";import{parse2}from"./shared-nb0h4j83.js";import{parseSections2}from"./shared-xmc2pnaf.js";import{extractIdentifiers2,isReference2,STOP2,SKIP2,walk2}from"./shared-jpvd0875.js";import{RUNES,RUNE_NAMES}from"./shared-m3dr31c3.js";import{lexComponent2}from"./shared-a23q4q40.js";import"./shared-drb44hb9.js";import"./shared-dscc5xg8.js";var REGEX_CANDIDATE=/(?<![\w$])(?:\$(?:state|derived|props|bindable|effect|inspect|host)(?![\w$])|await(?![\w$]))|\\u/g,BOOLEAN_EXPRESSION=/^\{\s*(true|false)\s*\}$/;function isRunesMode(source){let lexed=lexComponent2(source),option=lexed.options?.attributes.find((attribute)=>attribute.name==="runes"),fromOption=option&&booleanValue(option);if(fromOption!==void 0)return fromOption;let text=withoutByteOrderMark(source),scripts=[lexed.instance,lexed.module].flatMap((script)=>script?[script.content]:[]),candidates=!1,inMarkup=!1,onlyAwait=!0;REGEX_CANDIDATE.lastIndex=0;for(let match=REGEX_CANDIDATE.exec(text);match!==null&&!(inMarkup&&!onlyAwait);match=REGEX_CANDIDATE.exec(text)){let at=match.index;candidates=!0,onlyAwait&&=match[0]==="await",inMarkup||=!scripts.some(({start,end})=>at>=start&&at<end)}if(!candidates)return!1;if(!onlyAwait&&option===void 0&&!text.includes("\\u")&&callsRune(text,scripts))return!0;let options={css:!1,comments:!1},ast=inMarkup?parse2(source,options):parseSections2(source,options);if(ast.options?.runes!==void 0)return ast.options.runes;if(onlyAwait)return ast.instance!==void 0&&awaitsOutsideFunctions(ast.instance.content)||awaitsOutsideFunctions(ast.fragment);return usesRunes(ast)}function awaitsOutsideFunctions(root){let awaits=!1;return walk2(root,{enter(node){if(isFunction(node))return SKIP2;if(node.type!=="AwaitExpression")return;return awaits=!0,STOP2}}),awaits}function booleanValue(attribute){if(attribute.value===!0)return!0;let match=BOOLEAN_EXPRESSION.exec(attribute.value);return match?match[1]==="true":void 0}var STORE_NAMES=new Map([...RUNE_NAMES].map((name)=>[name,new RegExp(`(?<![\\w$.])${name.slice(1)}(?![\\w$])`)])),DECLARING_WORDS=new Set("abstract accessor as async class const declare enum export extends function get implements import infer interface is keyof let module namespace new override private protected public readonly satisfies set static type typeof unique var".split(" "));function callsRune(source,scripts){let calls=new Map;for(let{start,end}of scripts){let script=source.slice(0,end);if(closingBracket(script,start,(wordStart,wordEnd)=>{if(script.charCodeAt(wordStart)!==36)return!1;let name=script.slice(wordStart,wordEnd);if(RUNE_NAMES.has(name)&&calls.get(name)!==!1)calls.set(name,isRuneCall(script,wordStart,wordEnd));return!1})!==script.length)return!1}for(let[name,call]of calls)if(call&&!STORE_NAMES.get(name)?.test(source))return!0;return!1}function isRuneCall(source,start,end){let before=start-1;while(before>=0&&isWhitespace(source.charCodeAt(before)))before--;let previous=source.charCodeAt(before);if(previous===35||previous===42||previous===46||previous===58||previous===60||previous===64)return!1;if(isWordCode(previous)){let wordStart=before;while(wordStart>0&&isWordCode(source.charCodeAt(wordStart-1)))wordStart--;if(DECLARING_WORDS.has(source.slice(wordStart,before+1)))return!1}let i=skipWhitespace(source,end);while(source.charCodeAt(i)===46){let wordStart=skipWhitespace(source,i+1),wordEnd=wordCodesEnd(source,wordStart);if(wordEnd===wordStart)return!1;i=skipWhitespace(source,wordEnd)}if(source.charCodeAt(i)===60){if(i=typeArgumentsEnd(source,i),i===-1)return!1;i=skipWhitespace(source,i)}if(source.charCodeAt(i)!==40)return!1;let close=closingBracket(source,i+1);if(source.charCodeAt(close)!==41)return!1;let next=source.charCodeAt(skipWhitespace(source,close+1));return next!==123&&next!==58}function typeArgumentsEnd(source,from){let depth=0,limit=Math.min(source.length,from+2000);for(let i=from;i<limit;i++){let code=source.charCodeAt(i);if(code===34||code===39||code===96||code===47)return-1;if(code===60)depth++;else if(code===62&&source.charCodeAt(i-1)!==61){if(depth--,depth===0)return i+1}}return-1}function usesRunes(ast){let module=ast.module?.content,instance=ast.instance?.content,declared=new Map;if(instance)declare(instance,declared,!0);let moduleDeclared=new Map;if(module)declare(module,moduleDeclared,!1);for(let[name,initial]of moduleDeclared)if(!declared.has(name))declared.set(name,initial);let referenced=[],reference=(name)=>{if(!referenced.includes(name))referenced.push(name)};if(module)collectReferences(module,moduleDeclared,reference);if(instance&&collectReferences(instance,declared,reference))return!0;if(collectReferences(ast.fragment,declared,reference))return!0;for(let name of referenced){let store=name.slice(1);if(!declared.has(store))return!0;let initial=declared.get(store)??null,rune=runeOf(initial,declared);if(!((rune===null||store!=="props"&&rune==="$props")&&!(name==="$derived"&&initial?.type==="ImportDeclaration"&&initial.source.value==="svelte/store")))return!0;declared.set(name,null)}return!1}function collectReferences(root,outer,reference){let ancestors=[],scopes=new Map,unresolved=(name)=>RUNE_NAMES.has(name)&&!outer.has(name)&&!ancestors.some((ancestor)=>declaredIn(ancestor,scopes).has(name)),functions=0,awaits=!1;return walk2(root,{enter(node,parent){if(isFunction(node))functions++;else if(node.type==="AwaitExpression")awaits||=functions===0;let name;if(node.type==="Identifier"&&parent&&!parent.type.startsWith("TS")&&isReference2(node,parent))name=node.name;else if(node.type==="TransitionDirective"||node.type==="AnimateDirective"||node.type==="UseDirective")name=node.name.split(".")[0];else if(node.type==="StyleDirective"&&node.value===!0)name=node.name;if(name!==void 0&&unresolved(name))reference(name);ancestors.push(node)},leave(node){if(ancestors.pop(),isFunction(node))functions--}}),awaits}var NO_NAMES=new Set;function declaredIn(node,scopes){let cached=scopes.get(node);if(cached)return cached;let patterns=[];if(isFunction(node)){if(patterns.push(...node.params),node.type==="FunctionExpression"&&node.id)patterns.push(node.id)}else if(node.type==="CatchClause"&&node.param)patterns.push(node.param);else if(node.type==="SnippetBlock")patterns.push(...node.parameters??[]);else if(node.type==="EachBlock"&&node.context)patterns.push(node.context);if(patterns.length===0&&!isFunction(node))return scopes.set(node,NO_NAMES),NO_NAMES;let names=new Set(patterns.flatMap((pattern)=>extractIdentifiers2(pattern)).map((id)=>id.name));if(isFunction(node)){let{body}=node;walk2(body,{enter(inner){if(inner===body)return;if(inner.type==="VariableDeclaration")for(let declarator of inner.declarations)for(let id of extractIdentifiers2(declarator.id))names.add(id.name);else if((inner.type==="FunctionDeclaration"||inner.type==="ClassDeclaration")&&inner.id)names.add(inner.id.name);return isFunction(inner)?SKIP2:void 0}})}return scopes.set(node,names),names}function isFunction(node){return node.type==="ArrowFunctionExpression"||node.type==="FunctionExpression"||node.type==="FunctionDeclaration"}function declare(program,into,instance){let implicit=[];walk2(program,{enter(node,parent){if(isFunction(node)&&node.type!=="FunctionDeclaration")return SKIP2;let topLevel=parent===program||parent?.type==="ExportNamedDeclaration"||parent?.type==="ExportDefaultDeclaration";if(node.type==="ImportDeclaration"){for(let specifier of node.specifiers)into.set(specifier.local.name,node);return SKIP2}if(node.type==="FunctionDeclaration"||node.type==="ClassDeclaration"){if(topLevel&&node.id)into.set(node.id.name,node);return SKIP2}if(node.type==="VariableDeclaration"){if(node.kind!=="var"&&!topLevel)return SKIP2;for(let declarator of node.declarations)for(let id of extractIdentifiers2(declarator.id))into.set(id.name,topLevel?declarator.init??null:null);return SKIP2}if(instance&&parent===program&&node.type==="LabeledStatement"&&node.label.name==="$"&&node.body.type==="ExpressionStatement"&&node.body.expression.type==="AssignmentExpression"){for(let id of extractIdentifiers2(node.body.expression.left))if(!id.name.startsWith("$"))implicit.push(id)}return}});for(let id of implicit)if(!into.has(id.name))into.set(id.name,null)}function runeOf(initial,declared){if(initial?.type!=="CallExpression")return null;let node=initial.callee,keypath="";while(node.type==="MemberExpression"){if(node.computed||node.property.type!=="Identifier")return null;keypath=`.${node.property.name}${keypath}`,node=node.object}if(node.type==="CallExpression"&&node.callee.type==="Identifier")keypath=`()${keypath}`,node=node.callee;if(node.type!=="Identifier"||declared.has(node.name))return null;return keypath=node.name+keypath,RUNES.has(keypath)?keypath:null}export{isRunesMode};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{closingTagOmitted}from"./shared-dgdrqgdn.js";import{withoutByteOrderMark,isWhitespace,skipWhitespace,isTypeScript,closingScriptTag,closingScriptTagEnd,isVoid,styleContentEnd,isQuote,nameEnd,endsUnquotedValue}from"./shared-5tpb3h6x.js";import{closingBracket}from"./shared-
|
|
1
|
+
import{closingTagOmitted}from"./shared-dgdrqgdn.js";import{withoutByteOrderMark,isWhitespace,skipWhitespace,isTypeScript,closingScriptTag,closingScriptTagEnd,isVoid,styleContentEnd,isQuote,nameEnd,endsUnquotedValue}from"./shared-5tpb3h6x.js";import{closingBracket}from"./shared-e4gbs4rb.js";var BLOCK="{",LT=60,GT=62,SLASH=47,EQUALS=61,BRACE=123,REGEX_CLOSING_STYLE_TAG_END=/\s*>/y,REGEX_CLOSING_TEXTAREA=/<\/textarea(\s[^>]*)?>/iy,SECTION_TAG_NAMES=["cript","tyle","velte:options"],CLOSING_OPTIONS_TAG="</svelte:options";function lexComponent2(input){let source=withoutByteOrderMark(input).trimEnd();return lex(source,isTypeScript(source),null)}function topLevelTags(source){let found={tags:[],comments:[]};return lex(source,!1,found),found}function lex(source,typescript,found){let component={typescript,instance:null,module:null,css:null,options:null},last=lastSectionTag(source),stack=[],i=0;while(i<=last){let code=source.charCodeAt(i);if(code===LT)i=readTag(source,i,stack,component,found);else if(code===BRACE)i=readMustache(source,i,stack);else i++}return component}function lastSectionTag(source){let last=-1,i=source.indexOf("<s");while(i!==-1){let end=sectionTagNameEnd(source,i+2);if(end!==-1){let code=source.charCodeAt(end);if(end===source.length||isWhitespace(code)||code===SLASH||code===GT)last=i}i=source.indexOf("<s",i+2)}return last}function sectionTagNameEnd(source,from){for(let name of SECTION_TAG_NAMES)if(source.startsWith(name,from))return from+name.length;return-1}function expressionEnd(source,from){return Math.min(closingBracket(source,from)+1,source.length)}function readMustache(source,start,stack){let i=skipWhitespace(source,start+1),code=source.charCodeAt(i),next=source.charCodeAt(i+1);if(code===35||code===58||code===64||code===SLASH&&next!==SLASH&&next!==42){i++;while(i<source.length){let letter=source.charCodeAt(i);if(letter<97||letter>122)break;i++}if(code===35)stack.push(BLOCK);else if(code===SLASH){let open=stack.lastIndexOf(BLOCK);if(open!==-1)stack.length=open}}return expressionEnd(source,i)}function readTag(source,start,stack,component,found){if(source.startsWith("!--",start+1)){let close=source.indexOf("-->",start+4),end=close===-1?source.length:close+3;if(found&&stack.length===0)found.comments.push(start,end);return end}if(source.charCodeAt(start+1)===SLASH){let nameStart=start+2,name=source.slice(nameStart,nameEnd(source,nameStart,!1)),open=stack.lastIndexOf(name);if(open!==-1)stack.length=open;return eatGreaterThan(source,skipWhitespace(source,nameStart+name.length))}let name=source.slice(start+1,nameEnd(source,start+1,!1)),i=skipWhitespace(source,start+1+name.length),parent=stack[stack.length-1];if(parent!==void 0&&closingTagOmitted(parent,name))stack.pop();let topLevel=stack.length===0;if(found&&topLevel&&(name==="script"||name==="style"||name==="svelte:options"))found.tags.push(start);if(topLevel&&(name==="script"||name==="style")){let attributes=[];if(i=eatGreaterThan(source,readStaticAttributes(source,i,attributes)),name==="script"){let script=readScript(source,start,i,attributes);if(script.context==="module")component.module??=script;else component.instance??=script;return script.end}let css=readStyle(source,start,i,attributes);return component.css??=css,css.end}let attributes=topLevel&&name==="svelte:options"?[]:null;if(i=readAttributes(source,i,attributes),source.charCodeAt(i)===SLASH||isVoid(name)){if(source.charCodeAt(i)===SLASH)i++;i=eatGreaterThan(source,i)}else{if(i=eatGreaterThan(source,i),name==="textarea")return textareaEnd(source,i);if(name==="script"||name==="style"){let closer=`</${name}>`,close=source.indexOf(closer,i);return close===-1?source.length:close+closer.length}if(attributes&&source.startsWith(CLOSING_OPTIONS_TAG,i))i=eatGreaterThan(source,skipWhitespace(source,i+CLOSING_OPTIONS_TAG.length));else return stack.push(name),i}if(attributes)component.options??={start,end:i,attributes};return i}function eatGreaterThan(source,i){return source.charCodeAt(i)===GT?i+1:i}function readScript(source,start,contentStart,attributes){let close=closingScriptTag(source,contentStart),contentEnd=close===-1?source.length:close,module=attributes.some((attribute)=>attribute.name==="module"||attribute.name==="context");return{start,end:close===-1?source.length:closingScriptTagEnd(source,close),context:module?"module":"default",attributes,content:{start:contentStart,end:contentEnd}}}function readStyle(source,start,contentStart,attributes){let contentEnd=styleContentEnd(source,contentStart),end=contentEnd;if(source.startsWith("</style",end)){end+=7,REGEX_CLOSING_STYLE_TAG_END.lastIndex=end;let close=REGEX_CLOSING_STYLE_TAG_END.exec(source);if(close)end+=close[0].length}return{start,end,attributes,content:{start:contentStart,end:contentEnd}}}function readStaticAttributes(source,from,into){let i=from;for(;;){let start=i,end=nameEnd(source,i,!0);if(end===start)return i;i=end;let value=!0;if(source.charCodeAt(i)===EQUALS){let at=skipWhitespace(source,i+1),quote=source.charCodeAt(at),valueEnd=-1;if(isQuote(quote)){let close=source.indexOf(source[at],at+1);if(close!==-1)valueEnd=close+1}if(valueEnd===-1){valueEnd=at;while(valueEnd<source.length&&source.charCodeAt(valueEnd)!==GT&&!isWhitespace(source.charCodeAt(valueEnd)))valueEnd++}let quotes=isQuote(quote)?1:0;value=source.slice(at+quotes,valueEnd-quotes),i=valueEnd}into.push({name:source.slice(start,end),value,start,end:i}),i=skipWhitespace(source,i)}}function readAttributes(source,from,into){let i=from;for(;;){for(;;){if(source.startsWith("/*",i)){let end=source.indexOf("*/",i+2);i=end===-1?source.length:end+2}else if(source.startsWith("//",i)){let end=source.indexOf(`
|
|
2
2
|
`,i+2);i=end===-1?source.length:end}else break;i=skipWhitespace(source,i)}let start=i;if(source.charCodeAt(i)===BRACE){i=skipWhitespace(source,expressionEnd(source,i+1));continue}let nameEndAt=nameEnd(source,i,!0);if(nameEndAt===start)return i;let end=nameEndAt,value=!0;if(i=skipWhitespace(source,nameEndAt),source.charCodeAt(i)===EQUALS){let at=skipWhitespace(source,i+1);end=source.startsWith("/>",at)?at+1:attributeValueEnd(source,at),value=isQuote(source.charCodeAt(at))?source.slice(at+1,Math.max(at+1,end-1)):source.slice(at,end),i=skipWhitespace(source,end)}into?.push({name:source.slice(start,nameEndAt),value,start,end})}}function attributeValueEnd(source,from){let quote=source.charCodeAt(from);if(isQuote(quote)){let i=from+1;while(i<source.length){let code=source.charCodeAt(i);if(code===quote)return i+1;i=code===BRACE?expressionEnd(source,i+1):i+1}return source.length}let i=from;while(i<source.length&&!endsUnquotedValue(source,i))i=source.charCodeAt(i)===BRACE?expressionEnd(source,i+1):i+1;return i}function textareaEnd(source,from){let i=from;while(i<source.length){let code=source.charCodeAt(i);if(code===LT){if(REGEX_CLOSING_TEXTAREA.lastIndex=i,REGEX_CLOSING_TEXTAREA.test(source))return REGEX_CLOSING_TEXTAREA.lastIndex}i=code===BRACE?expressionEnd(source,i+1):i+1}return source.length}
|
|
3
3
|
export{lexComponent2,topLevelTags};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{isDigit,isWhitespace}from"./shared-5tpb3h6x.js";var STATEMENT_START=0,OPERATOR=1,BLOCK_OPENER=2,VALUE=3,PAREN=0,HEAD_PAREN=1,BLOCK=2,OBJECT=3,TEMPLATE=4,HEAD=4,IMPORT=5,EXPORT=6,REQUIRE=7,KEYWORDS={await:OPERATOR,case:OPERATOR,default:OPERATOR,delete:OPERATOR,extends:OPERATOR,in:OPERATOR,instanceof:OPERATOR,new:OPERATOR,of:OPERATOR,return:OPERATOR,throw:OPERATOR,typeof:OPERATOR,void:OPERATOR,yield:OPERATOR,do:BLOCK_OPENER,else:BLOCK_OPENER,finally:BLOCK_OPENER,try:BLOCK_OPENER,for:HEAD,if:HEAD,while:HEAD,with:HEAD,import:IMPORT,export:EXPORT,require:REQUIRE},LONGEST_KEYWORD=10,KEYWORDS_BY_KEY=Array(keywordKey(128,0)).fill(null);for(let entry of Object.entries(KEYWORDS)){let key=keywordKey(entry[0].charCodeAt(0),entry[0].length),entries=KEYWORDS_BY_KEY[key]??[];entries.push(entry),KEYWORDS_BY_KEY[key]=entries}function keywordKey(first,length){return first*(LONGEST_KEYWORD+1)+length}function wordKind(source,start,end){let first=source.charCodeAt(start);if(first>=128||end-start>LONGEST_KEYWORD)return VALUE;let key=keywordKey(first,end-start),entries=KEYWORDS_BY_KEY[key];if(entries===null)return VALUE;for(let i=0;i<entries.length;i++)if(source.startsWith(entries[i][0],start))return entries[i][1];return VALUE}var ASCII_WORD=new Uint8Array(128);for(let range of["az","AZ","09","__","$$","\\\\"])for(let code=range.charCodeAt(0);code<=range.charCodeAt(1);code++)ASCII_WORD[code]=1;function isWordCode(code){return code>=128?!isWhitespace(code):ASCII_WORD[code]===1}function scan(source,localExports,parseAt,exportLists=!1){tokenize(source,lastStatementKeyword(source,localExports,exportLists),localExports,exportLists,parseAt,void 0,void 0)}function scanLiterals(source,literal){tokenize(source,source.length-1,!1,!1,void 0,literal,void 0)}function scanCalls(source,call){tokenize(source,source.length-1,!1,!1,void 0,void 0,call)}function tokenize(source,last,localExports,exportLists,parseAt,literal,call){let stack=[],pos=source.startsWith("#!")?lineEnd(source,2):0,prev=STATEMENT_START,afterDot=!1,head=!1,decorators=-1,statementEnd=()=>{if(prev=STATEMENT_START,stack.length===0)decorators=-1};while(pos<=last){let code=source.charCodeAt(pos);if(code===32||code===10||isWhitespace(code)){pos++;continue}if(code===47){let end=commentEnd(source,pos);if(end!==-1){pos=end;continue}}let wasAfterDot=afterDot,wasHead=head;if(afterDot=!1,head=!1,isWordCode(code)||code===35){let start=pos;pos=wordEnd(source,pos+1);let kind=wasAfterDot?VALUE:wordKind(source,start,pos);if(call!==void 0&&(kind===IMPORT||kind===REQUIRE))call(start,prev===STATEMENT_START||prev===VALUE);if(parseAt!==void 0&&stack.length===0&&(kind===EXPORT?localExports||isReexport(source,pos,exportLists):kind===IMPORT&&isImportDeclaration(source,pos)))pos=Math.max(pos,parseAt(decorators!==-1&&kind===EXPORT?decorators:start,start)),statementEnd();else if(kind===EXPORT)prev=BLOCK_OPENER;else if(kind===HEAD)head=!0,prev=VALUE;else prev=kind===OPERATOR||kind===BLOCK_OPENER?kind:VALUE;continue}switch(pos++,code){case 34:case 39:{let start=pos-1;pos=stringEnd(source,pos,code),literal?.(start,pos,!1),prev=VALUE;break}case 96:{let start=pos;pos=templateEnd(source,pos,stack),literal?.(start,quasiEnd(source,pos),!0),prev=source.charCodeAt(pos-1)===123?OPERATOR:VALUE;break}case 47:{let end=prev===VALUE?-1:regexEnd(source,pos);if(end===-1)prev=OPERATOR;else pos=wordCodesEnd(source,end),prev=VALUE;break}case 40:stack.push(wasHead?HEAD_PAREN:PAREN),prev=OPERATOR;break;case 41:prev=stack.pop()===HEAD_PAREN?BLOCK_OPENER:VALUE;break;case 123:stack.push(prev===OPERATOR?OBJECT:BLOCK),prev=STATEMENT_START;break;case 125:{let open=stack.pop();if(open===TEMPLATE){let start=pos;pos=templateEnd(source,pos,stack),literal?.(start,quasiEnd(source,pos),!0),prev=source.charCodeAt(pos-1)===123?OPERATOR:VALUE}else if(open===OBJECT)prev=VALUE;else statementEnd();break}case 59:statementEnd();break;case 44:prev=stack[stack.length-1]===OBJECT?STATEMENT_START:OPERATOR;break;case 93:prev=VALUE;break;case 46:if(isDigit(source.charCodeAt(pos)))pos=wordCodesEnd(source,pos),prev=VALUE;else if(source.startsWith("..",pos))pos+=2,prev=OPERATOR;else afterDot=!0,prev=OPERATOR;break;case 63:if(source.charCodeAt(pos)===46&&!isDigit(source.charCodeAt(pos+1)))pos++,afterDot=!0;prev=OPERATOR;break;case 33:prev=prev===VALUE&&!isWhitespace(source.charCodeAt(pos-2))?VALUE:OPERATOR;break;case 43:case 45:if(source.charCodeAt(pos)===code&&prev===VALUE)pos++;else prev=OPERATOR;break;case 61:if(prev=source.charCodeAt(pos)===62?BLOCK_OPENER:OPERATOR,prev===BLOCK_OPENER)pos++;break;case 64:if(stack.length===0&&decorators===-1)decorators=pos-1;prev=OPERATOR;break;default:prev=OPERATOR}}}function closingBracket(source,from,word){let length=source.length,stack=[],pos=from,prev=OPERATOR,afterDot=!1;while(pos<length){let code=source.charCodeAt(pos);if(code===32||code===10||isWhitespace(code)){pos++;continue}if(code===47){let end=commentEnd(source,pos);if(end!==-1){pos=end;continue}}let wasAfterDot=afterDot;if(afterDot=!1,isWordCode(code)||code===35){let start=pos;if(pos=wordEnd(source,pos+1),!wasAfterDot&&word?.(start,pos))return-1;let kind=wasAfterDot?VALUE:wordKind(source,start,pos);prev=kind===OPERATOR||kind===BLOCK_OPENER||kind===HEAD?OPERATOR:VALUE;continue}switch(pos++,code){case 34:case 39:pos=stringEnd(source,pos,code),prev=VALUE;break;case 96:pos=templateEnd(source,pos,stack),prev=source.charCodeAt(pos-1)===123?OPERATOR:VALUE;break;case 47:{let end=prev===VALUE?-1:regexEnd(source,pos);if(end===-1)prev=OPERATOR;else pos=wordCodesEnd(source,end),prev=VALUE;break}case 40:stack.push(PAREN),prev=OPERATOR;break;case 41:if(stack.length===0)return pos-1;stack.pop(),prev=VALUE;break;case 123:stack.push(prev===OPERATOR?OBJECT:BLOCK),prev=STATEMENT_START;break;case 125:{if(stack.length===0)return pos-1;let open=stack.pop();if(open===TEMPLATE)pos=templateEnd(source,pos,stack),prev=source.charCodeAt(pos-1)===123?OPERATOR:VALUE;else prev=open===OBJECT?VALUE:STATEMENT_START;break}case 93:prev=VALUE;break;case 46:if(isDigit(source.charCodeAt(pos)))pos=wordCodesEnd(source,pos),prev=VALUE;else if(source.startsWith("..",pos))pos+=2,prev=OPERATOR;else afterDot=!0,prev=OPERATOR;break;case 63:if(source.charCodeAt(pos)===46&&!isDigit(source.charCodeAt(pos+1)))pos++,afterDot=!0;prev=OPERATOR;break;case 33:prev=prev===VALUE&&!isWhitespace(source.charCodeAt(pos-2))?VALUE:OPERATOR;break;case 43:case 45:if(source.charCodeAt(pos)===code&&prev===VALUE)pos++;else prev=OPERATOR;break;case 61:if(source.charCodeAt(pos)===62)pos++;prev=OPERATOR;break;default:prev=OPERATOR}}return length}function isLineBreak(code){return code===10||code===13||code===8232||code===8233}function lineEnd(source,pos){for(let i=pos;i<source.length;i++)if(isLineBreak(source.charCodeAt(i)))return i;return source.length}function commentEnd(source,slash){let next=source.charCodeAt(slash+1);if(next===47)return lineEnd(source,slash+2);if(next!==42)return-1;let end=source.indexOf("*/",slash+2);return end===-1?source.length:end+2}function wordEnd(source,pos){let i=pos;while(i<source.length){let code=source.charCodeAt(i);if(code===92)i+=2;else if(isWordCode(code))i++;else break}return i}function wordCodesEnd(source,pos){let i=pos;while(i<source.length&&isWordCode(source.charCodeAt(i)))i++;return i}function stringEnd(source,pos,quote){for(let i=pos;i<source.length;i++){let code=source.charCodeAt(i);if(code===quote)return i+1;if(code===92)i+=source.startsWith(`\r
|
|
2
|
+
`,i+1)?2:1;else if(code===10||code===13)return i}return source.length}function templateEnd(source,pos,stack){for(let i=pos;i<source.length;i++){let code=source.charCodeAt(i);if(code===96)return i+1;if(code===92)i++;else if(code===36&&source.charCodeAt(i+1)===123)return stack.push(TEMPLATE),i+2}return source.length}function quasiEnd(source,pos){let code=source.charCodeAt(pos-1);if(code===96)return pos-1;if(code===123&&source.charCodeAt(pos-2)===36)return pos-2;return pos}function regexEnd(source,pos){let inClass=!1;for(let i=pos;i<source.length;i++){let code=source.charCodeAt(i);if(isLineBreak(code))return-1;if(code===92)i++;else if(code===91)inClass=!0;else if(code===93)inClass=!1;else if(code===47&&!inClass)return i+1}return-1}function skipTrivia(source,pos){let i=pos;while(i<source.length){let code=source.charCodeAt(i);if(isWhitespace(code)){i++;continue}let end=code===47?commentEnd(source,i):-1;if(end===-1)return i;i=end}return source.length}function isWordAt(source,pos,word){return source.charCodeAt(pos)===word.charCodeAt(0)&&source.startsWith(word,pos)&&!isWordCode(source.charCodeAt(pos+word.length))}function isImportDeclaration(source,pos){let code=source.charCodeAt(skipTrivia(source,pos));return code!==40&&code!==46}function isReexport(source,pos,lists){let i=skipTrivia(source,pos);if(isWordAt(source,i,"import"))return!0;if(isWordAt(source,i,"type"))i=skipTrivia(source,i+4);let code=source.charCodeAt(i);if(code===42)return!0;if(code!==123)return!1;if(lists)return!0;for(i++;i<source.length;i++){let inner=source.charCodeAt(i);if(inner===125)break;if(inner===34||inner===39)i=stringEnd(source,i+1,inner)-1;else if(inner===47)i=Math.max(i,skipTrivia(source,i)-1)}return isWordAt(source,skipTrivia(source,i+1),"from")}var STATEMENT_KEYWORD=/import|export/g;function lastStatementKeyword(source,localExports,exportLists){let last=-1;STATEMENT_KEYWORD.lastIndex=0;for(let match=STATEMENT_KEYWORD.exec(source);match!==null;match=STATEMENT_KEYWORD.exec(source)){let start=match.index,end=start+6;if(!isWordCode(source.charCodeAt(start-1))&&!isWordCode(source.charCodeAt(end))&&(source.charCodeAt(start)===105?isImportDeclaration(source,end):localExports||isReexport(source,end,exportLists)))last=start}return last}
|
|
3
|
+
export{isWordCode,scan,scanLiterals,scanCalls,closingBracket,lineEnd,wordCodesEnd,skipTrivia,isWordAt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{definePlugin,hasLineBreak,hasName}from"./shared-2pngd0mg.js";var SKIP_WHITESPACE=/(?:\s|\/\/.*|\/\*[\s\S]*?\*\/)*/g,KEYWORD_TYPES=new Map([["any","TSAnyKeyword"],["bigint","TSBigIntKeyword"],["boolean","TSBooleanKeyword"],["never","TSNeverKeyword"],["null","TSNullKeyword"],["number","TSNumberKeyword"],["object","TSObjectKeyword"],["string","TSStringKeyword"],["symbol","TSSymbolKeyword"],["undefined","TSUndefinedKeyword"],["unknown","TSUnknownKeyword"],["void","TSVoidKeyword"]]),CLASS_MODIFIERS=new Set("public private protected readonly declare abstract override static accessor".split(" ")),PARAMETER_MODIFIERS=new Set("public private protected readonly override".split(" ")),DECLARE_TARGETS=new Set("var let const function class abstract enum interface type namespace module global".split(" ")),DECLARE_FIRST=new Set("var let const function class interface enum".split(" ")),TS_EXPRESSION_WRAPPERS=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion"]),SCOPE_TOP=1,SCOPE_SIMPLE_CATCH=32,SCOPE_CLASS_STATIC_BLOCK=256,BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_TS_TYPE=6,BIND_TS_INTERFACE=7,BIND_FLAGS_TS_ENUM=256,BIND_FLAGS_TS_EXPORT_ONLY=1024,BIND_TS_NAMESPACE=8|BIND_FLAGS_TS_EXPORT_ONLY,BIND_TS_ENUM=BIND_LEXICAL|BIND_FLAGS_TS_ENUM,FUNC_STATEMENT=1,FUNC_HANGING_STATEMENT=2,CHAR_PAREN_L=40,CHAR_PAREN_R=41,CHAR_COMMA=44,CHAR_DOT=46,CHAR_COLON=58,CHAR_EQ=61,CHAR_LT=60,CHAR_BRACE_L=123,CHAR_BRACKET_L=91,CHAR_STAR=42,CHAR_HASH=35,CHAR_DQUOTE=34,CHAR_SQUOTE=39,SPECULATION_FAILED=SyntaxError("speculative parse failed"),tsPlugin=definePlugin((Base)=>{let{tokTypes:tt,keywordTypes,isIdentifierChar,isIdentifierStart}=Base.acorn,atType=new Base.acorn.TokenType("@");class TSParser extends Base{inType=!1;$4=!1;$5=!1;$7=null;$k=null;$l=!1;$m=!1;$f=null;$9=[[]];$n=0;$t=0;$o=-1;constructor(options,input,startPos){super(options,input,startPos);let onComment=this.options.onComment;if(typeof onComment==="function")this.options.onComment=(block,text,start,end,startLoc,endLoc)=>{if(start<this.$t)return;this.$t=end,onComment.call(this,block,text,start,end,startLoc,endLoc)}}reset(){this.inType=!1,this.$4=!1,this.$5=!1,this.$7=null,this.$k=null,this.$l=!1,this.$m=!1,this.$f=null,this.$9=[[]],this.$n=0,this.$t=0,this.$o=-1}getTokenFromCode(code){if(code===64)return++this.pos,this.finishToken(atType);return super.getTokenFromCode(code)}readToken_lt_gt(code){if(this.inType)return this.finishOp(tt.relational,1);return super.readToken_lt_gt(code)}$a(fn){let old=this.inType;this.inType=!0;let result=fn();if(this.inType=old,!old&&this.type===tt.relational)this.pos=this.start,this.nextToken();return result}$1(){return this.type===tt.relational&&this.value==="<"}$p(){if(this.type===tt.bitShift&&this.value==="<<")this.pos=this.start+1,this.finishToken(tt.relational,"<");return this.$1()}$c(){return this.type===tt.relational&&this.value===">"}$u(){return this.type===tt.prefix&&this.value==="!"}hasPrecedingLineBreak(){return hasLineBreak(this.input,this.lastTokEnd,this.start)}$d(from=this.pos){return SKIP_WHITESPACE.lastIndex=from,SKIP_WHITESPACE.exec(this.input),SKIP_WHITESPACE.lastIndex}$2(){return this.input.charCodeAt(this.$d())}$3(){let start=this.$d(),end=start;while(end<this.input.length&&isIdentifierChar(this.input.charCodeAt(end)))end++;return this.input.slice(start,end)}$b(){return!hasLineBreak(this.input,this.pos,this.$d())}$14(){return this.$b()&&isIdentifierStart(this.$2())&&!Object.hasOwn(keywordTypes,this.$3())}$15(){return{pos:this.pos,type:this.type,value:this.value,start:this.start,end:this.end,startLoc:this.startLoc,endLoc:this.endLoc,lastTokStart:this.lastTokStart,lastTokEnd:this.lastTokEnd,lastTokStartLoc:this.lastTokStartLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,context:this.context.slice(),exprAllowed:this.exprAllowed,containsEsc:this.containsEsc,inType:this.inType,$4:this.$4,$5:this.$5,$7:this.$7,scopes:this.scopeStack.length,privateNames:this.privateNameStack.length,labels:this.labels,labelCount:this.labels.length,strict:this.strict,yieldPos:this.yieldPos,awaitPos:this.awaitPos,awaitIdentPos:this.awaitIdentPos,potentialArrowAt:this.potentialArrowAt,potentialArrowInForAwait:this.potentialArrowInForAwait}}$16(state){this.pos=state.pos,this.type=state.type,this.value=state.value,this.start=state.start,this.end=state.end,this.startLoc=state.startLoc,this.endLoc=state.endLoc,this.lastTokStart=state.lastTokStart,this.lastTokEnd=state.lastTokEnd,this.lastTokStartLoc=state.lastTokStartLoc,this.lastTokEndLoc=state.lastTokEndLoc,this.curLine=state.curLine,this.lineStart=state.lineStart,this.context=state.context,this.exprAllowed=state.exprAllowed,this.containsEsc=state.containsEsc,this.inType=state.inType,this.$4=state.$4,this.$5=state.$5,this.$7=state.$7,this.scopeStack.length=state.scopes,this.privateNameStack.length=state.privateNames,this.labels=state.labels,this.labels.length=state.labelCount,this.strict=state.strict,this.yieldPos=state.yieldPos,this.awaitPos=state.awaitPos,this.awaitIdentPos=state.awaitIdentPos,this.potentialArrowAt=state.potentialArrowAt,this.potentialArrowInForAwait=state.potentialArrowInForAwait}raise(pos,message){if(this.$n>0)throw SPECULATION_FAILED;return super.raise(pos,message)}$1y(pos,message){try{super.raise(pos,message)}catch(error){if(error instanceof SyntaxError)error.$1z=!0;throw error}throw Error("unreachable")}$g(fn,lookahead=!1){let state=this.$15();this.$n++;try{let result=fn();if(lookahead||result===void 0)this.$16(state);return result}catch(error){if(!(error instanceof SyntaxError)||!lookahead&&error.$1z)throw error;this.$16(state);return}finally{this.$n--}}$v(fn){return this.$g(fn,!0)===!0}$17(node){if(node.end=this.lastTokEnd,this.options.locations)node.loc.end=this.lastTokEndLoc}$q(node,from){if(node.start=from.start,this.options.locations)node.loc.start=from.loc.start}$6(returnType=!1){let node=this.startNode();return node.typeAnnotation=this.$a(()=>(this.next(),returnType?this.$20():this.$0())),this.finishNode(node,"TSTypeAnnotation")}$h(node,optional){if(optional&&this.eat(tt.question))node.optional=!0,this.$17(node);if(this.type===tt.colon)node.typeAnnotation=this.$6(),this.$17(node);return node}$20(){if(this.type!==tt.name&&this.type!==tt._this)return this.$0();if(this.isContextual("asserts")&&this.$b()&&isIdentifierStart(this.$2())){let node=this.startNode();if(this.next(),node.parameterName=this.type===tt._this?this.$w():this.parseIdent(),this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.$x(node,!0);return node.asserts=!0,node.typeAnnotation=null,this.finishNode(node,"TSTypePredicate")}if(this.$3()==="is"&&this.$b()){let node=this.startNode();return node.parameterName=this.type===tt._this?this.$w():this.parseIdent(!0),this.$x(node,!1)}return this.$0()}$x(node,asserts){this.next();let annotation=this.startNode();return annotation.typeAnnotation=this.$0(),node.typeAnnotation=this.finishNode(annotation,"TSTypeAnnotation"),node.asserts=asserts,this.finishNode(node,"TSTypePredicate")}$w(){let node=this.startNode();return this.next(),this.finishNode(node,"TSThisType")}parseWholeType(){this.inType=!0,this.nextToken();let type=this.$0();if(this.type!==tt.eof)this.unexpected();return type}$0(){let type=this.$18();if(this.$4||this.type!==tt._extends||this.hasPrecedingLineBreak())return type;let node=this.startNodeAt(type.start,type.loc?.start);return this.next(),node.checkType=type,node.extendsType=this.$i(!0,()=>this.$18()),this.expect(tt.question),node.trueType=this.$i(!1,()=>this.$0()),this.expect(tt.colon),node.falseType=this.$i(!1,()=>this.$0()),this.finishNode(node,"TSConditionalType")}$i(disallow,fn){let old=this.$4;this.$4=disallow;let result=fn();return this.$4=old,result}$18(){if(this.$21())return this.$19("TSFunctionType");if(this.type===tt._new||this.isContextual("abstract")&&this.$3()==="new")return this.$19("TSConstructorType");return this.$1a("TSUnionType",tt.bitwiseOR,()=>this.$1a("TSIntersectionType",tt.bitwiseAND,()=>this.$1b()))}$19(type){let node=this.startNode();if(type==="TSConstructorType"){if(node.abstract=this.isContextual("abstract"),node.abstract)this.next();this.next()}return this.$i(!1,()=>this.$r(node,tt.arrow)),this.finishNode(node,type)}$r(node,returnToken){if(this.$1())node.typeParameters=this.$8();if(this.expect(tt.parenL),node.parameters=this.parseBindingList(tt.parenR,!1,!0),this.type===returnToken)node.typeAnnotation=this.$6(!0);else if(returnToken===tt.arrow)this.unexpected()}$21(){if(this.$1())return!0;if(this.type!==tt.parenL)return!1;return this.$v(()=>{if(this.next(),this.type===tt.parenR||this.type===tt.ellipsis)return!0;if(this.type===tt.name||this.type===tt._this)this.next();else if(this.type===tt.braceL||this.type===tt.bracketL)this.parseBindingAtom();else return!1;let type=this.type;if(type===tt.colon||type===tt.comma||type===tt.question||type===tt.eq)return!0;if(type!==tt.parenR)return!1;return this.next(),this.type===tt.arrow})}$1a(type,operator,parseConstituent){let node=this.startNode(),hasLeadingOperator=this.eat(operator),types=[];do types.push(parseConstituent());while(this.eat(operator));if(types.length===1&&!hasLeadingOperator)return types[0];return node.types=types,this.finishNode(node,type)}$1b(){if(this.type===tt.name&&!this.containsEsc){let value=this.value;if(value==="keyof"||value==="unique"||value==="readonly"){let node=this.startNode();return this.next(),node.operator=value,node.typeAnnotation=this.$1b(),this.finishNode(node,"TSTypeOperator")}if(value==="infer"){let node=this.startNode();this.next();let parameter=this.startNode();parameter.name=this.$y();let constraint=this.$g(()=>this.$22());if(constraint)parameter.constraint=constraint;return node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),this.finishNode(node,"TSInferType")}}return this.$i(!1,()=>this.$23())}$22(){if(!this.eat(tt._extends))return;let constraint=this.$i(!0,()=>this.$0());return this.$4||this.type!==tt.question?constraint:void 0}$y(){if(this.type!==tt.name&&!this.type.keyword)this.unexpected();let name=this.type===tt.name?this.value:this.type.keyword;return this.next(),name}$23(){let type=this.$24();while(!this.hasPrecedingLineBreak()&&this.eat(tt.bracketL)){let node=this.startNodeAt(type.start,type.loc?.start);if(this.eat(tt.bracketR))node.elementType=type,type=this.finishNode(node,"TSArrayType");else node.objectType=type,node.indexType=this.$0(),this.expect(tt.bracketR),type=this.finishNode(node,"TSIndexedAccessType")}return type}$24(){switch(this.type){case tt.name:case tt._void:case tt._null:{let keyword=KEYWORD_TYPES.get(this.value);if(keyword&&(this.type!==tt.name||!this.containsEsc&&this.$2()!==CHAR_DOT)){let node=this.startNode();return this.next(),this.finishNode(node,keyword)}return this.$1c()}case tt.string:case tt.num:case tt._true:case tt._false:{let node=this.startNode();return node.literal=this.parseExprAtom(),this.finishNode(node,"TSLiteralType")}case tt.plusMin:{if(this.value!=="-")break;let node=this.startNode(),unary=this.startNode();if(this.next(),this.type!==tt.num)this.unexpected();return unary.operator="-",unary.prefix=!0,unary.argument=this.parseExprAtom(),node.literal=this.finishNode(unary,"UnaryExpression"),this.finishNode(node,"TSLiteralType")}case tt.backQuote:return this.$25();case tt._this:{let thisType=this.$w();if(this.isContextual("is")&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(thisType.start,thisType.loc?.start);return node.parameterName=thisType,this.$x(node,!1)}return thisType}case tt._typeof:return this.$26();case tt._import:return this.$1d();case tt.braceL:return this.$27()?this.$28():this.$29();case tt.bracketL:return this.$2a();case tt.parenL:{let node=this.startNode();return this.next(),node.typeAnnotation=this.$0(),this.expect(tt.parenR),this.finishNode(node,"TSParenthesizedType")}default:if(this.type.keyword)return this.$1c()}return this.unexpected()}$1c(){let node=this.startNode();if(node.typeName=this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeReference")}$j(){let entity=this.parseIdent(!0);while(this.eat(tt.dot)){let node=this.startNodeAt(entity.start,entity.loc?.start);node.left=entity,node.right=this.parseIdent(!0),entity=this.finishNode(node,"TSQualifiedName")}return entity}$26(){let node=this.startNode();if(this.next(),node.exprName=this.type===tt._import?this.$1d():this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeQuery")}$1d(){let node=this.startNode();if(this.next(),node.argument=this.$1e(),this.eat(tt.dot))node.qualifier=this.$j();if(this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSImportType")}$z(){if(this.type!==tt.string)this.unexpected();return this.parseExprAtom()}$1e(){this.expect(tt.parenL);let string=this.$z();return this.expect(tt.parenR),string}$25(){let node=this.startNode(),literal=this.startNode();this.next(),literal.expressions=[];let element=this.parseTemplateElement({isTagged:!1});literal.quasis=[element];while(!element.tail){if(this.type===tt.eof)this.raise(this.pos,"Unterminated template literal");this.expect(tt.dollarBraceL),literal.expressions.push(this.$0()),this.expect(tt.braceR),element=this.parseTemplateElement({isTagged:!1}),literal.quasis.push(element)}return this.next(),node.literal=this.finishNode(literal,"TemplateLiteral"),this.finishNode(node,"TSLiteralType")}$27(){return this.$v(()=>{if(this.next(),this.type===tt.plusMin)return this.next(),this.isContextual("readonly");if(this.isContextual("readonly"))this.next();if(this.type!==tt.bracketL)return!1;if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt._in})}$28(){let node=this.startNode();if(this.expect(tt.braceL),this.type===tt.plusMin)node.readonly=this.value,this.next(),this.expectContextual("readonly");else if(this.eatContextual("readonly"))node.readonly=!0;this.expect(tt.bracketL);let parameter=this.startNode();if(parameter.name=this.$y(),this.expect(tt._in),parameter.constraint=this.$0(),node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),node.nameType=this.eatContextual("as")?this.$0():null,this.expect(tt.bracketR),this.type===tt.plusMin)node.optional=this.value,this.next(),this.expect(tt.question);else if(this.eat(tt.question))node.optional=!0;if(this.eat(tt.colon))node.typeAnnotation=this.$0();return this.semicolon(),this.expect(tt.braceR),this.finishNode(node,"TSMappedType")}$29(){let node=this.startNode();return node.members=this.$1f(),this.finishNode(node,"TSTypeLiteral")}$1f(){this.expect(tt.braceL);let members=[];while(!this.eat(tt.braceR))members.push(this.$2b());return members}$2b(){let node=this.startNode(),type="TSPropertySignature",next=this.type===tt._new?this.$2():-1;if(this.type===tt.parenL||this.$1())type="TSCallSignatureDeclaration",this.$r(node,tt.colon);else if(next===CHAR_PAREN_L||next===CHAR_LT)type="TSConstructSignatureDeclaration",this.next(),this.$r(node,tt.colon);else{let newKey=this.type===tt._new?this.parseIdent(!0):null;if(this.isContextual("readonly")&&this.$s(!0))this.next(),node.readonly=!0;if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);let kind="method";if(newKey)node.key=newKey;else{if((this.isContextual("get")||this.isContextual("set"))&&this.$s(!1))kind=this.value,this.next();this.parsePropertyName(node)}if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()){if(type="TSMethodSignature",kind!=="method")node.kind=kind;this.$r(node,tt.colon),node.kind=kind}else if(this.type===tt.colon)node.typeAnnotation=this.$6()}return this.$1i(),this.finishNode(node,type)}$1i(){if(!this.eat(tt.comma))this.semicolon()}$1g(){return this.$v(()=>{if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt.colon})}$1h(node){if(this.expect(tt.bracketL),node.parameters=[this.$h(this.parseIdent(),!1)],this.expect(tt.bracketR),this.type===tt.colon)node.typeAnnotation=this.$6();return this.$1i(),this.finishNode(node,"TSIndexSignature")}$2a(){let node=this.startNode();this.expect(tt.bracketL),node.elementTypes=[];while(!this.eat(tt.bracketR))if(node.elementTypes.push(this.$2c()),this.type!==tt.bracketR)this.expect(tt.comma);return this.finishNode(node,"TSTupleType")}$2c(){let start=this.start,startLoc=this.startLoc,rest=this.eat(tt.ellipsis),element;if((this.type===tt.name||this.type.keyword)&&this.$2d()){let node=this.startNode();node.label=this.parseIdent(!0),node.optional=this.eat(tt.question),this.expect(tt.colon),node.elementType=this.$0(),element=this.finishNode(node,"TSNamedTupleMember")}else if(element=this.$0(),this.eat(tt.question)){let node=this.startNodeAt(element.start,element.loc?.start);node.typeAnnotation=element,element=this.finishNode(node,"TSOptionalType")}if(rest){let node=this.startNodeAt(start,startLoc);node.typeAnnotation=element,element=this.finishNode(node,"TSRestType")}return element}$2d(){let at=this.$d();if(this.input.charCodeAt(at)===63)at=this.$d(at+1);return this.input.charCodeAt(at)===CHAR_COLON}$8(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c()){let parameter=this.startNode();while((this.type===tt._const||this.type===tt._in||this.isContextual("out"))&&isIdentifierStart(this.$2()))parameter[this.value]=!0,this.next();if(parameter.name=this.$y(),this.eat(tt._extends))parameter.constraint=this.$0();if(this.eat(tt.eq))parameter.default=this.$0();if(node.params.push(this.finishNode(parameter,"TSTypeParameter")),!this.$c()){if(this.expect(tt.comma),this.$c())node.extra={trailingComma:this.lastTokStart}}}if(this.next(),node.params.length===0)this.$1y(this.start,"Type parameter list cannot be empty.");return this.finishNode(node,"TSTypeParameterDeclaration")})}$e(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c())if(node.params.push(this.$0()),!this.$c())this.expect(tt.comma);if(node.params.length===0)this.unexpected();return this.next(),this.finishNode(node,"TSTypeParameterInstantiation")})}$1j(){let list=[];do{let node=this.startNode();if(node.expression=this.$j(),this.$1())node.typeParameters=this.$e();list.push(this.finishNode(node,"TSExpressionWithTypeArguments"))}while(this.eat(tt.comma));return list}$1k(exported=!1){if(this.type!==tt.name||this.containsEsc){if(this.type===tt._const&&this.$3()==="enum")return this.$10(this.startNode());return}if(!this.$2e(this.value))return;if(this.value==="declare")return this.$2f(exported);return this.$1l(this.startNode(),this.value)}$2e(word){switch(word){case"interface":case"type":case"namespace":return this.$14();case"enum":return isIdentifierStart(this.$2());case"abstract":return this.$b()&&this.$3()==="class";case"module":{let next=this.$2();return this.$b()&&(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next))}case"declare":return this.$b()&&DECLARE_TARGETS.has(this.$3());case"global":return this.$b()&&this.$2()===CHAR_BRACE_L}return!1}$1l(node,word){switch(word){case"interface":return this.$1m(node);case"type":return this.$2g(node);case"enum":return this.$10(node);case"abstract":return this.$1n(node,!0);case"global":return node.global=!0,node.id=this.parseIdent(),node.body=this.$11(),this.finishNode(node,"TSModuleDeclaration")}return this.$2h(node)}$2f(exported){let old=this.$5;this.$5=!0;let node=this.startNode();this.next();let word=this.value;if(word==="const"&&this.$3()==="enum")node.const=!0;if(!exported&&DECLARE_FIRST.has(word))node.declare=!0;let declaration;if(node.const)declaration=this.$10(node);else if(word==="var"||word==="let"||word==="const")declaration=this.parseVarStatement(node,word,!0);else if(word==="function")this.next(),declaration=this.parseFunction(node,FUNC_STATEMENT,!1,!1);else if(word==="class")declaration=this.parseClass(node,!0);else declaration=this.$1l(node,word);return declaration.declare=!0,this.$5=old,declaration}$1n(node,isStatement){return this.next(),node.abstract=!0,this.parseClass(node,isStatement)}$1m(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_INTERFACE),this.$1())node.typeParameters=this.$8();return this.$a(()=>{if(this.eat(tt._extends))node.extends=this.$1j();let body=this.startNode();body.body=this.$1f(),node.body=this.finishNode(body,"TSInterfaceBody")}),this.finishNode(node,"TSInterfaceDeclaration")}$2g(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_TYPE),this.$1())node.typeParameters=this.$8();return node.typeAnnotation=this.$a(()=>(this.expect(tt.eq),this.$0())),this.semicolon(),this.finishNode(node,"TSTypeAliasDeclaration")}$10(node){if(this.type===tt._const)node.const=!0,this.next();this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_ENUM),this.expect(tt.braceL),node.members=[];while(!this.eat(tt.braceR)){let member=this.startNode();if(member.id=this.type===tt.string?this.parseExprAtom():this.parseIdent(!0),this.eat(tt.eq))member.initializer=this.parseMaybeAssign();if(node.members.push(this.finishNode(member,"TSEnumMember")),this.type!==tt.braceR)this.expect(tt.comma)}return this.finishNode(node,"TSEnumDeclaration")}$2h(node){if(this.next(),this.type===tt.string){if(node.id=this.parseExprAtom(),this.type===tt.braceL)node.body=this.$11();else this.semicolon();return this.finishNode(node,"TSModuleDeclaration")}return node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_NAMESPACE),this.$1o(node)}$1o(node){if(this.eat(tt.dot)){let inner=this.startNode();inner.id=this.parseIdent(),node.body=this.$1o(inner)}else node.body=this.$11();return this.finishNode(node,"TSModuleDeclaration")}$11(){this.enterScope(SCOPE_CLASS_STATIC_BLOCK);let node=this.startNode();this.enterScope(0),this.expect(tt.braceL),node.body=[];while(!this.eat(tt.braceR))node.body.push(this.parseStatement(null,!0));return this.exitScope(),this.exitScope(),this.finishNode(node,"TSModuleBlock")}$1p(node,isExport){if(node.isExport=isExport,node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_LEXICAL),this.expect(tt.eq),this.isContextual("require")&&this.$2()===CHAR_PAREN_L){let reference=this.startNode();this.next(),reference.expression=this.$1e(),node.moduleReference=this.finishNode(reference,"TSExternalModuleReference")}else node.moduleReference=this.$j();return this.semicolon(),this.finishNode(node,"TSImportEqualsDeclaration")}$2i(){let at=this.$d();if(this.input.charCodeAt(at)!==CHAR_EQ)return!1;let after=this.input.charCodeAt(at+1);return after!==CHAR_EQ&&after!==62}parseStatement(context,topLevel,exports){if(this.type===atType)this.$1q(!0);let declaration=this.$1k();if(declaration)return declaration;return super.parseStatement(context,topLevel,exports)}parseVarStatement(node,kind,allowMissingInitializer){return super.parseVarStatement(node,kind,allowMissingInitializer||this.$5)}parseVarId(decl,kind){if(super.parseVarId(decl,kind),decl.id.type==="Identifier"&&this.$u()&&!this.hasPrecedingLineBreak())this.next(),decl.definite=!0;this.$h(decl.id,!1)}parseCatchClauseParam(){let param=this.$h(this.parseBindingAtom(),!1),simple=param.type==="Identifier";return this.enterScope(simple?SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(param,simple?BIND_SIMPLE_CATCH:BIND_LEXICAL),this.expect(tt.parenR),param}parseImport(node){if(this.next(),node.importKind="value",this.type===tt.string)node.specifiers=[],node.source=this.parseExprAtom();else{if(this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR||isIdentifierStart(next)&&this.$3()!=="from")node.importKind="type",this.next()}if(this.type===tt.name&&this.$2i())return this.$1p(node,!1);node.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),node.source=this.$z()}return this.$1r(node),this.semicolon(),this.finishNode(node,"ImportDeclaration")}parseWithClause(){if(this.isContextual("assert")&&!this.hasPrecedingLineBreak())this.type=tt._with;return this.type===tt._with?super.parseWithClause():void 0}$1r(node){let attributes=this.parseWithClause();if(attributes)node.attributes=attributes}parseImportSpecifier(){return this.$1s("importKind",()=>super.parseImportSpecifier())}parseExportSpecifier(exports){return this.$1s("exportKind",()=>super.parseExportSpecifier(exports))}$1s(kindKey,parse){let next=this.isContextual("type")?this.$2():-1;if(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next)&&this.$3()!=="as"){let modifier=this.startNode();this.next();let node=parse();return this.$q(node,modifier),node[kindKey]="type",node}let node=parse();return node[kindKey]="value",node}parseExport(node,exports){if(this.next(),this.eat(tt._import)){if(node.importKind="value",this.isContextual("type")&&isIdentifierStart(this.$2())&&this.$3()!=="from")node.importKind="type",this.next();return this.$1p(node,!0)}if(this.eat(tt.eq))return node.expression=this.parseExpression(),this.semicolon(),this.finishNode(node,"TSExportAssignment");if(this.eatContextual("as"))return this.expectContextual("namespace"),node.id=this.parseIdent(),this.semicolon(),this.finishNode(node,"TSNamespaceExportDeclaration");if(node.exportKind="value",this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR)node.exportKind="type",this.next()}if(this.eat(tt.star))return this.parseExportAllDeclaration(node,exports);if(this.eat(tt._default)){if(this.isContextual("interface")&&this.$14())node.declaration=this.$1m(this.startNode());else if(this.isContextual("abstract")&&this.$3()==="class")node.declaration=this.$1n(this.startNode(),"nullableID");else node.declaration=this.parseExportDefaultDeclaration();return this.finishNode(node,"ExportDefaultDeclaration")}let isDeclare=this.isContextual("declare"),declaration=this.$1k(!0);if(declaration||this.shouldParseExportStatement()){if(node.declaration=declaration??this.parseStatement(null),isDeclare||node.declaration.type==="TSInterfaceDeclaration"||node.declaration.type==="TSTypeAliasDeclaration")node.exportKind="type";return node.specifiers=[],node.source=null,this.finishNode(node,"ExportNamedDeclaration")}if(node.declaration=null,node.specifiers=this.parseExportSpecifiers(exports),this.eatContextual("from"))node.source=this.$z(),this.$1r(node);else{for(let spec of node.specifiers)if(this.checkUnreserved(spec.local),this.checkLocalExport(spec.local),spec.local.type==="Literal")this.raise(spec.local.start,"A string literal cannot be used as an exported binding without `from`.");node.source=null}return this.semicolon(),this.finishNode(node,"ExportNamedDeclaration")}parseFunction(node,statement,allowExpressionBody,isAsync,forInit){let isDeclaration=statement&FUNC_STATEMENT;if(isDeclaration)this.$f=node,this.$o=node.start;super.parseFunction(node,statement,allowExpressionBody,isAsync,forInit),this.$f=null;let bodiless=!node.body;if(bodiless)node.type="TSDeclareFunction";if(isDeclaration&&node.id){if(bodiless){if(this.$5&&this.currentScope().flags&SCOPE_TOP)this.declareName(node.id.name,BIND_FLAGS_TS_EXPORT_ONLY,node.id.start);this.checkLValSimple(node.id,BIND_NONE)}else if(!(statement&FUNC_HANGING_STATEMENT)){let bindingType=BIND_FUNCTION;if(this.strict||node.generator||node.async)bindingType=this.treatFunctionsAsVar?BIND_VAR:BIND_LEXICAL;this.checkLValSimple(node.id,bindingType)}}return node}parseFunctionParams(node){if(this.$1())node.typeParameters=this.$8();if(super.parseFunctionParams(node),this.type===tt.colon)node.returnType=this.$6(!0)}parseFunctionBody(node,isArrowFunction,isMethod,forInit){if(isMethod&&this.type===tt.colon)node.returnType=this.$6(!0);if(isArrowFunction||this.type===tt.braceL||node.start!==this.$o){super.parseFunctionBody(node,isArrowFunction,isMethod,forInit);return}this.semicolon(),this.exitScope()}parseMethod(isGenerator,isAsync,allowDirectSuper){let typeParameters=this.$k;this.$k=null;let node=super.parseMethod(isGenerator,isAsync,allowDirectSuper);if(!node.body)node.type="TSDeclareMethod";if(typeParameters)node.typeParameters=typeParameters;return node}parseBindingList(close,allowEmpty,allowTrailingComma,allowModifiers){let modifiers=allowModifiers===!0||this.$l;return this.$l=!1,super.parseBindingList(close,allowEmpty,allowTrailingComma,modifiers)}$s(allowLineBreak){if(!allowLineBreak&&!this.$b())return!1;let next=this.$2();return next===CHAR_BRACKET_L||next===CHAR_BRACE_L||next===CHAR_STAR||next===CHAR_DOT||next===CHAR_HASH||next===CHAR_DQUOTE||next===CHAR_SQUOTE||next>=48&&next<=57||isIdentifierStart(next)}parseAssignableListItem(allowModifiers){let decorators=this.$12(),start=this.start,startLoc=this.startLoc,accessibility,readonly=!1,override=!1;if(allowModifiers)while(this.type===tt.name&&PARAMETER_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(!1)){if(this.value==="readonly")readonly=!0;else if(this.value==="override")override=!0;else accessibility=this.value;this.next()}let left;if(this.type===tt._this)left=this.startNode(),left.name="this",this.next(),this.finishNode(left,"Identifier");else left=this.parseBindingAtom();let element=this.type===tt.eq?this.parseMaybeDefault(start,startLoc,left):this.parseMaybeDefault(left.start,left.loc?.start,this.$h(left,!0));if(decorators.length>0)element.decorators=decorators;if(!accessibility&&!readonly&&!override)return element;let node=this.startNodeAt(start,startLoc);if(accessibility)node.accessibility=accessibility;if(readonly)node.readonly=!0;if(override)node.override=!0;return node.parameter=element,this.finishNode(node,"TSParameterProperty")}parseBindingListItem(param){if(param.type==="RestElement")this.$h(param,!0);return param}checkLValSimple(expr,bindingType,checkClashes){if(this.$f&&expr===this.$f.id){this.$f=null;return}if(!bindingType&&TS_EXPRESSION_WRAPPERS.has(expr.type)){this.checkLValSimple(expr.expression,bindingType,checkClashes);return}switch(expr.type){case"TSParameterProperty":this.checkLValInnerPattern(expr.parameter,bindingType,checkClashes);return;case"Identifier":if(expr.name==="this")return}super.checkLValSimple(expr,bindingType,checkClashes)}toAssignable(node,isBinding,refDestructuringErrors){if(node&&!isBinding&&TS_EXPRESSION_WRAPPERS.has(node.type))return node;return super.toAssignable(node,isBinding,refDestructuringErrors)}declareName(name,bindingType,pos){let scope=this.currentScope();if(bindingType&BIND_FLAGS_TS_EXPORT_ONLY){this.$1t(scope,name),scope.$1u??=[],scope.$1u.push(name);return}if(bindingType===BIND_TS_TYPE||bindingType===BIND_TS_INTERFACE){if(scope.$13??=[],bindingType===BIND_TS_TYPE&&hasName(scope.$13,name))this.raise(pos,`type '${name}' has already been declared.`);scope.$13.push(name),this.$1t(scope,name);return}if(bindingType&BIND_FLAGS_TS_ENUM){if(scope.$1v??=[],hasName(scope.$1v,name))return;super.declareName(name,BIND_LEXICAL,pos),scope.$1v.push(name);return}super.declareName(name,bindingType,pos)}$1t(scope,name){if(this.inModule&&scope.flags&SCOPE_TOP)delete this.undefinedExports[name]}checkLocalExport(id){for(let i=this.scopeStack.length-1;i>=0;i--){let scope=this.scopeStack[i];if(hasName(scope.$13,id.name)||hasName(scope.$1u,id.name))return}super.checkLocalExport(id)}checkExport(){}raiseRecoverable(pos,message){if(message==="Duplicate constructor in the same class")return;super.raiseRecoverable(pos,message)}$12(){let decorators=[];while(this.type===atType)decorators.push(this.$1w());return decorators}$1q(allowExport){let pending=this.$9[this.$9.length-1];while(this.type===atType)pending.push(this.$1w());if(this.type===tt._export){if(!allowExport)this.unexpected()}else if(this.type!==tt._class&&!((this.isContextual("abstract")||this.isContextual("declare"))&&this.$3()==="class"))this.raise(this.start,"Leading decorators must be attached to a class declaration.")}$1w(){let node=this.startNode();this.next(),this.$9.push([]);let startPos=this.start,startLoc=this.startLoc,expression;if(this.type===tt.parenL){if(this.next(),expression=this.parseExpression(),this.expect(tt.parenR),this.options.preserveParens){let paren=this.startNodeAt(startPos,startLoc);paren.expression=expression,expression=this.finishNode(paren,"ParenthesizedExpression")}}else{expression=this.parseIdent(!1);while(this.eat(tt.dot)){let member=this.startNodeAt(startPos,startLoc);member.object=expression,member.property=this.parseIdent(!0),member.computed=!1,expression=this.finishNode(member,"MemberExpression")}}let typeArguments=this.$p()?this.$e():void 0;if(this.eat(tt.parenL)){let call=this.startNodeAt(expression.start,expression.loc?.start);if(call.callee=expression,call.arguments=this.parseExprList(tt.parenR,!1,!1),typeArguments)call.typeArguments=typeArguments;expression=this.finishNode(call,"CallExpression")}else if(typeArguments){let instantiation=this.startNodeAt(expression.start,expression.loc?.start);instantiation.expression=expression,instantiation.typeArguments=typeArguments,expression=this.finishNode(instantiation,"TSInstantiationExpression")}return node.expression=expression,this.$9.pop(),this.finishNode(node,"Decorator")}shouldParseExportStatement(){return this.type===atType||super.shouldParseExportStatement()}parseExprAtom(refDestructuringErrors,forInit,forNew){if(this.type===atType)this.$1q(!1);return super.parseExprAtom(refDestructuringErrors,forInit,forNew)}parseProperty(isPattern,refDestructuringErrors){if(isPattern||this.type!==atType)return super.parseProperty(isPattern,refDestructuringErrors);let decorators=this.$12(),property=super.parseProperty(isPattern,refDestructuringErrors);if(property.type==="SpreadElement")this.raise(property.start,"Decorators can't be used with SpreadElement");return property.decorators=decorators,property}parseClassId(node,isStatement){let index=this.$9.length-1,decorators=this.$9[index];if(decorators.length>0)node.decorators=decorators,this.$q(node,decorators[0]),this.$9[index]=[];if(!this.isContextual("implements")||isStatement===!0)super.parseClassId(node,isStatement);if(this.$1())node.typeParameters=this.$8()}parseClassSuper(node){if(super.parseClassSuper(node),node.superClass&&this.$1())node.superTypeParameters=this.$e();if(this.eatContextual("implements"))node.implements=this.$a(()=>this.$1j())}parseClassElement(constructorAllowsSuper){if(this.type===atType){let decorators=this.$12();if(this.type===tt.braceR)this.raise(this.start,"Decorators must be attached to a class element.");let element=this.parseClassElement(constructorAllowsSuper);return element.decorators=decorators,this.$q(element,decorators[0]),element}if(this.eat(tt.semi))return null;let node=this.startNode();while(this.type===tt.name&&CLASS_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(this.value==="static")){let modifier=this.value;if(this.next(),modifier==="static"&&this.type===tt.braceL)return this.next(),this.parseClassStaticBlock(node),node;if(modifier==="public"||modifier==="private"||modifier==="protected")node.accessibility=modifier;else node[modifier]=!0}if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);node.static??=!1;let keyName="",isGenerator=!1,isAsync=!1,kind="method";if(this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===tt.star)&&!this.canInsertSemicolon())isAsync=!0;else keyName="async";if(!keyName&&this.eat(tt.star))isGenerator=!0;if(!keyName&&!isAsync&&!isGenerator){let lastValue=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())kind=lastValue;else keyName=lastValue}if(keyName)node.computed=!1,node.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),node.key.name=keyName,this.finishNode(node.key,"Identifier");else this.parseClassElementName(node);if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()||kind!=="method"||isGenerator||isAsync){let key=node.key,isConstructor=!node.static&&!node.computed&&(key.type==="Identifier"&&key.name==="constructor"||key.type==="Literal"&&key.value==="constructor");if(node.kind=isConstructor?"constructor":kind,this.$1())node.typeParameters=this.$8();this.$l=isConstructor,this.$o=this.start,this.parseClassMethod(node,isGenerator,isAsync,isConstructor&&constructorAllowsSuper)}else{if(!node.optional&&this.$u())this.next(),node.definite=!0;if(this.type===tt.colon)node.typeAnnotation=this.$6();this.parseClassField(node)}return node}parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse){if(this.$p()){let arrow=this.$g(()=>{let typeParameters=this.$8(),expr=super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse);if(expr.type!=="ArrowFunctionExpression")return;return expr.typeParameters=typeParameters,this.$q(expr,typeParameters),expr});if(arrow)return arrow}return super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse)}parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit){if(this.$p()){let node=this.startNode();return node.typeAnnotation=this.$a(()=>{this.next();let type=this.$0();if(!this.$c())this.unexpected();return this.next(),type}),node.expression=this.parseMaybeUnary(null,!1,!1,forInit),this.finishNode(node,"TSTypeAssertion")}return super.parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit)}parseMaybeConditional(forInit,refDestructuringErrors){let startPos=this.start,startLoc=this.startLoc,expr=this.parseExprOps(forInit,refDestructuringErrors);if(this.checkExpressionErrors(refDestructuringErrors))return expr;if(this.type===tt.question&&!(expr.type==="ArrowFunctionExpression"&&expr.start===startPos)&&!this.$2j()){this.next();let node=this.startNodeAt(startPos,startLoc);return node.test=expr,node.consequent=this.parseMaybeAssign(),this.expect(tt.colon),node.alternate=this.parseMaybeAssign(forInit),this.finishNode(node,"ConditionalExpression")}return expr}$2j(){let at=this.$d(),next=this.input.charCodeAt(at);if(next===CHAR_COLON||next===CHAR_COMMA||next===CHAR_PAREN_R)return!0;return next===CHAR_EQ&&this.input.charCodeAt(at+1)!==CHAR_EQ}parseParenItem(item){return this.$h(item,!0)}$1x(){if(this.type!==tt.colon)return!0;let returnType=this.$g(()=>{let type=this.$6(!0);return this.type===tt.arrow&&!this.canInsertSemicolon()?type:void 0});if(!returnType)return!1;return this.$7=returnType,!0}shouldParseArrow(exprList){return this.$1x()&&super.shouldParseArrow(exprList)}shouldParseAsyncArrow(){return this.$1x()&&super.shouldParseAsyncArrow()}parseArrowExpression(node,params,isAsync,forInit){if(this.$7)node.returnType=this.$7,this.$7=null;return super.parseArrowExpression(node,params,isAsync,forInit)}parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors){if(!this.$m)return super.parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors);this.$m=!1;let elements=[],first=!0;while(!this.eat(close)){if(first)first=!1;else if(this.expect(tt.comma),allowTrailingComma&&this.afterTrailingComma(close))break;if(this.type===tt.ellipsis){let spread=this.parseSpread(refDestructuringErrors);if(this.eat(tt.question))spread.optional=!0;if(this.type===tt.colon)spread.typeAnnotation=this.$6();elements.push(spread)}else elements.push(this.parseMaybeAssign(!1,refDestructuringErrors,this.parseParenItem))}return elements}parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit){if(this.$u()&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(startPos,startLoc);return this.exprAllowed=!1,this.next(),node.expression=base,this.finishNode(node,"TSNonNullExpression")}if(maybeAsyncArrow&&this.$1()){let arrow=this.$g(()=>this.$2k(startPos,startLoc,forInit));if(arrow)return arrow}let optional=this.type===tt.questionDot&&this.$2()===CHAR_LT;if(this.$1()||optional||this.type===tt.bitShift&&this.value==="<<"){let typeArguments=this.$g(()=>{if(optional)this.next();this.$p();let args=this.$e();if(this.type===tt.parenL&&!noCalls)return args;if(this.type===tt.backQuote)return optional?void 0:args;if(optional)return;if(this.$c()||this.type===tt.bitShift||this.type.startsExpr&&this.type!==tt.parenL&&!this.hasPrecedingLineBreak())return;return args});if(typeArguments){let node=this.startNodeAt(startPos,startLoc);if(this.type===tt.parenL&&!noCalls){if(this.next(),node.callee=base,node.arguments=this.parseExprList(tt.parenR,!0,!1),node.typeArguments=typeArguments,optional)base.optional=!0;if(optional||optionalChained)node.optional=optional;return this.finishNode(node,"CallExpression")}if(this.type===tt.backQuote)return node.tag=base,node.quasi=this.parseTemplate({isTagged:!0}),node.typeArguments=typeArguments,this.finishNode(node,"TaggedTemplateExpression");return node.expression=base,node.typeArguments=typeArguments,this.finishNode(node,"TSInstantiationExpression")}}if(maybeAsyncArrow&&this.type===tt.parenL)this.$m=!0;return super.parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit)}$2k(startPos,startLoc,forInit){let node=this.startNodeAt(startPos,startLoc);if(node.typeParameters=this.$8(),this.expect(tt.parenL),node.params=this.parseBindingList(tt.parenR,!1,!0),this.type===tt.colon)node.returnType=this.$6(!0);if(this.type!==tt.arrow||this.canInsertSemicolon())return;return this.next(),this.parseArrowExpression(node,node.params,!0,forInit)}parseDynamicImport(node){if(this.next(),node.source=this.parseMaybeAssign(),this.eat(tt.comma)&&this.type!==tt.parenR)node.arguments=[this.parseExpression()];return this.expect(tt.parenR),this.finishNode(node,"ImportExpression")}parseNew(){let node=super.parseNew();if(node.callee?.type!=="TSInstantiationExpression")return node;let result=this.startNodeAt(node.start,node.loc?.start);return result.callee=node.callee.expression,result.typeArguments=node.callee.typeArguments,result.arguments=node.arguments,this.finishNodeAt(result,"NewExpression",node.end,node.loc?.end)}parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit){if(tt._in.binop>minPrec&&this.type===tt.name&&(this.value==="as"||this.value==="satisfies")&&!this.containsEsc&&!this.hasPrecedingLineBreak()){let isSatisfies=this.value==="satisfies",node=this.startNodeAt(leftStartPos,leftStartLoc);return node.expression=left,node.typeAnnotation=this.$a(()=>{if(this.next(),!isSatisfies&&this.type===tt._const){let reference=this.startNode();return reference.typeName=this.parseIdent(!0),this.finishNode(reference,"TSTypeReference")}return this.$0()}),this.finishNode(node,isSatisfies?"TSSatisfiesExpression":"TSAsExpression"),this.parseExprOp(node,leftStartPos,leftStartLoc,minPrec,forInit)}return super.parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit)}parseGetterSetter(prop){prop.kind=prop.key.name,super.parseGetterSetter(prop)}parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc){if(!isPattern&&this.$1()){if(this.$k=this.$8(),this.type!==tt.parenL)this.unexpected();prop.kind="init"}return super.parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc)}}return TSParser});
|
|
1
|
+
import{definePlugin,hasLineBreak,hasName}from"./shared-s46wfvhw.js";var SKIP_WHITESPACE=/(?:\s|\/\/.*|\/\*[\s\S]*?\*\/)*/g,KEYWORD_TYPES=new Map([["any","TSAnyKeyword"],["bigint","TSBigIntKeyword"],["boolean","TSBooleanKeyword"],["never","TSNeverKeyword"],["null","TSNullKeyword"],["number","TSNumberKeyword"],["object","TSObjectKeyword"],["string","TSStringKeyword"],["symbol","TSSymbolKeyword"],["undefined","TSUndefinedKeyword"],["unknown","TSUnknownKeyword"],["void","TSVoidKeyword"]]),CLASS_MODIFIERS=new Set("public private protected readonly declare abstract override static accessor".split(" ")),PARAMETER_MODIFIERS=new Set("public private protected readonly override".split(" ")),DECLARE_TARGETS=new Set("var let const function class abstract enum interface type namespace module global".split(" ")),DECLARE_FIRST=new Set("var let const function class interface enum".split(" ")),TS_EXPRESSION_WRAPPERS=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion"]),SCOPE_TOP=1,SCOPE_SIMPLE_CATCH=32,SCOPE_CLASS_STATIC_BLOCK=256,BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_TS_TYPE=6,BIND_TS_INTERFACE=7,BIND_FLAGS_TS_ENUM=256,BIND_FLAGS_TS_EXPORT_ONLY=1024,BIND_TS_NAMESPACE=8|BIND_FLAGS_TS_EXPORT_ONLY,BIND_TS_ENUM=BIND_LEXICAL|BIND_FLAGS_TS_ENUM,FUNC_STATEMENT=1,FUNC_HANGING_STATEMENT=2,CHAR_PAREN_L=40,CHAR_PAREN_R=41,CHAR_COMMA=44,CHAR_DOT=46,CHAR_COLON=58,CHAR_EQ=61,CHAR_LT=60,CHAR_BRACE_L=123,CHAR_BRACKET_L=91,CHAR_STAR=42,CHAR_HASH=35,CHAR_DQUOTE=34,CHAR_SQUOTE=39,SPECULATION_FAILED=SyntaxError("speculative parse failed"),tsPlugin=definePlugin((Base)=>{let{tokTypes:tt,keywordTypes,isIdentifierChar,isIdentifierStart}=Base.acorn,atType=new Base.acorn.TokenType("@");class TSParser extends Base{inType=!1;$4=!1;$5=!1;$7=null;$k=null;$l=!1;$m=!1;$f=null;$9=[[]];$n=0;$t=0;$o=-1;constructor(options,input,startPos){super(options,input,startPos);let onComment=this.options.onComment;if(typeof onComment==="function")this.options.onComment=(block,text,start,end,startLoc,endLoc)=>{if(start<this.$t)return;this.$t=end,onComment.call(this,block,text,start,end,startLoc,endLoc)}}reset(){this.inType=!1,this.$4=!1,this.$5=!1,this.$7=null,this.$k=null,this.$l=!1,this.$m=!1,this.$f=null,this.$9=[[]],this.$n=0,this.$t=0,this.$o=-1}getTokenFromCode(code){if(code===64)return++this.pos,this.finishToken(atType);return super.getTokenFromCode(code)}readToken_lt_gt(code){if(this.inType)return this.finishOp(tt.relational,1);return super.readToken_lt_gt(code)}$a(fn){let old=this.inType;this.inType=!0;let result=fn();if(this.inType=old,!old&&this.type===tt.relational)this.pos=this.start,this.nextToken();return result}$1(){return this.type===tt.relational&&this.value==="<"}$p(){if(this.type===tt.bitShift&&this.value==="<<")this.pos=this.start+1,this.finishToken(tt.relational,"<");return this.$1()}$c(){return this.type===tt.relational&&this.value===">"}$u(){return this.type===tt.prefix&&this.value==="!"}hasPrecedingLineBreak(){return hasLineBreak(this.input,this.lastTokEnd,this.start)}$d(from=this.pos){return SKIP_WHITESPACE.lastIndex=from,SKIP_WHITESPACE.exec(this.input),SKIP_WHITESPACE.lastIndex}$2(){return this.input.charCodeAt(this.$d())}$3(){let start=this.$d(),end=start;while(end<this.input.length&&isIdentifierChar(this.input.charCodeAt(end)))end++;return this.input.slice(start,end)}$b(){return!hasLineBreak(this.input,this.pos,this.$d())}$14(){return this.$b()&&isIdentifierStart(this.$2())&&!Object.hasOwn(keywordTypes,this.$3())}$15(){return{pos:this.pos,type:this.type,value:this.value,start:this.start,end:this.end,startLoc:this.startLoc,endLoc:this.endLoc,lastTokStart:this.lastTokStart,lastTokEnd:this.lastTokEnd,lastTokStartLoc:this.lastTokStartLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,context:this.context.slice(),exprAllowed:this.exprAllowed,containsEsc:this.containsEsc,inType:this.inType,$4:this.$4,$5:this.$5,$7:this.$7,scopes:this.scopeStack.length,privateNames:this.privateNameStack.length,labels:this.labels,labelCount:this.labels.length,strict:this.strict,yieldPos:this.yieldPos,awaitPos:this.awaitPos,awaitIdentPos:this.awaitIdentPos,potentialArrowAt:this.potentialArrowAt,potentialArrowInForAwait:this.potentialArrowInForAwait}}$16(state){this.pos=state.pos,this.type=state.type,this.value=state.value,this.start=state.start,this.end=state.end,this.startLoc=state.startLoc,this.endLoc=state.endLoc,this.lastTokStart=state.lastTokStart,this.lastTokEnd=state.lastTokEnd,this.lastTokStartLoc=state.lastTokStartLoc,this.lastTokEndLoc=state.lastTokEndLoc,this.curLine=state.curLine,this.lineStart=state.lineStart,this.context=state.context,this.exprAllowed=state.exprAllowed,this.containsEsc=state.containsEsc,this.inType=state.inType,this.$4=state.$4,this.$5=state.$5,this.$7=state.$7,this.scopeStack.length=state.scopes,this.privateNameStack.length=state.privateNames,this.labels=state.labels,this.labels.length=state.labelCount,this.strict=state.strict,this.yieldPos=state.yieldPos,this.awaitPos=state.awaitPos,this.awaitIdentPos=state.awaitIdentPos,this.potentialArrowAt=state.potentialArrowAt,this.potentialArrowInForAwait=state.potentialArrowInForAwait}raise(pos,message){if(this.$n>0)throw SPECULATION_FAILED;return super.raise(pos,message)}$1y(pos,message){try{super.raise(pos,message)}catch(error){if(error instanceof SyntaxError)error.$1z=!0;throw error}throw Error("unreachable")}$g(fn,lookahead=!1){let state=this.$15();this.$n++;try{let result=fn();if(lookahead||result===void 0)this.$16(state);return result}catch(error){if(!(error instanceof SyntaxError)||!lookahead&&error.$1z)throw error;this.$16(state);return}finally{this.$n--}}$v(fn){return this.$g(fn,!0)===!0}$17(node){if(node.end=this.lastTokEnd,this.options.locations)node.loc.end=this.lastTokEndLoc}$q(node,from){if(node.start=from.start,this.options.locations)node.loc.start=from.loc.start}$6(returnType=!1){let node=this.startNode();return node.typeAnnotation=this.$a(()=>(this.next(),returnType?this.$20():this.$0())),this.finishNode(node,"TSTypeAnnotation")}$h(node,optional){if(optional&&this.eat(tt.question))node.optional=!0,this.$17(node);if(this.type===tt.colon)node.typeAnnotation=this.$6(),this.$17(node);return node}$20(){if(this.type!==tt.name&&this.type!==tt._this)return this.$0();if(this.isContextual("asserts")&&this.$b()&&isIdentifierStart(this.$2())){let node=this.startNode();if(this.next(),node.parameterName=this.type===tt._this?this.$w():this.parseIdent(),this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.$x(node,!0);return node.asserts=!0,node.typeAnnotation=null,this.finishNode(node,"TSTypePredicate")}if(this.$3()==="is"&&this.$b()){let node=this.startNode();return node.parameterName=this.type===tt._this?this.$w():this.parseIdent(!0),this.$x(node,!1)}return this.$0()}$x(node,asserts){this.next();let annotation=this.startNode();return annotation.typeAnnotation=this.$0(),node.typeAnnotation=this.finishNode(annotation,"TSTypeAnnotation"),node.asserts=asserts,this.finishNode(node,"TSTypePredicate")}$w(){let node=this.startNode();return this.next(),this.finishNode(node,"TSThisType")}parseWholeType(){this.inType=!0,this.nextToken();let type=this.$0();if(this.type!==tt.eof)this.unexpected();return type}$0(){let type=this.$18();if(this.$4||this.type!==tt._extends||this.hasPrecedingLineBreak())return type;let node=this.startNodeAt(type.start,type.loc?.start);return this.next(),node.checkType=type,node.extendsType=this.$i(!0,()=>this.$18()),this.expect(tt.question),node.trueType=this.$i(!1,()=>this.$0()),this.expect(tt.colon),node.falseType=this.$i(!1,()=>this.$0()),this.finishNode(node,"TSConditionalType")}$i(disallow,fn){let old=this.$4;this.$4=disallow;let result=fn();return this.$4=old,result}$18(){if(this.$21())return this.$19("TSFunctionType");if(this.type===tt._new||this.isContextual("abstract")&&this.$3()==="new")return this.$19("TSConstructorType");return this.$1a("TSUnionType",tt.bitwiseOR,()=>this.$1a("TSIntersectionType",tt.bitwiseAND,()=>this.$1b()))}$19(type){let node=this.startNode();if(type==="TSConstructorType"){if(node.abstract=this.isContextual("abstract"),node.abstract)this.next();this.next()}return this.$i(!1,()=>this.$r(node,tt.arrow)),this.finishNode(node,type)}$r(node,returnToken){if(this.$1())node.typeParameters=this.$8();if(this.expect(tt.parenL),node.parameters=this.parseBindingList(tt.parenR,!1,!0),this.type===returnToken)node.typeAnnotation=this.$6(!0);else if(returnToken===tt.arrow)this.unexpected()}$21(){if(this.$1())return!0;if(this.type!==tt.parenL)return!1;return this.$v(()=>{if(this.next(),this.type===tt.parenR||this.type===tt.ellipsis)return!0;if(this.type===tt.name||this.type===tt._this)this.next();else if(this.type===tt.braceL||this.type===tt.bracketL)this.parseBindingAtom();else return!1;let type=this.type;if(type===tt.colon||type===tt.comma||type===tt.question||type===tt.eq)return!0;if(type!==tt.parenR)return!1;return this.next(),this.type===tt.arrow})}$1a(type,operator,parseConstituent){let node=this.startNode(),hasLeadingOperator=this.eat(operator),types=[];do types.push(parseConstituent());while(this.eat(operator));if(types.length===1&&!hasLeadingOperator)return types[0];return node.types=types,this.finishNode(node,type)}$1b(){if(this.type===tt.name&&!this.containsEsc){let value=this.value;if(value==="keyof"||value==="unique"||value==="readonly"){let node=this.startNode();return this.next(),node.operator=value,node.typeAnnotation=this.$1b(),this.finishNode(node,"TSTypeOperator")}if(value==="infer"){let node=this.startNode();this.next();let parameter=this.startNode();parameter.name=this.$y();let constraint=this.$g(()=>this.$22());if(constraint)parameter.constraint=constraint;return node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),this.finishNode(node,"TSInferType")}}return this.$i(!1,()=>this.$23())}$22(){if(!this.eat(tt._extends))return;let constraint=this.$i(!0,()=>this.$0());return this.$4||this.type!==tt.question?constraint:void 0}$y(){if(this.type!==tt.name&&!this.type.keyword)this.unexpected();let name=this.type===tt.name?this.value:this.type.keyword;return this.next(),name}$23(){let type=this.$24();while(!this.hasPrecedingLineBreak()&&this.eat(tt.bracketL)){let node=this.startNodeAt(type.start,type.loc?.start);if(this.eat(tt.bracketR))node.elementType=type,type=this.finishNode(node,"TSArrayType");else node.objectType=type,node.indexType=this.$0(),this.expect(tt.bracketR),type=this.finishNode(node,"TSIndexedAccessType")}return type}$24(){switch(this.type){case tt.name:case tt._void:case tt._null:{let keyword=KEYWORD_TYPES.get(this.value);if(keyword&&(this.type!==tt.name||!this.containsEsc&&this.$2()!==CHAR_DOT)){let node=this.startNode();return this.next(),this.finishNode(node,keyword)}return this.$1c()}case tt.string:case tt.num:case tt._true:case tt._false:{let node=this.startNode();return node.literal=this.parseExprAtom(),this.finishNode(node,"TSLiteralType")}case tt.plusMin:{if(this.value!=="-")break;let node=this.startNode(),unary=this.startNode();if(this.next(),this.type!==tt.num)this.unexpected();return unary.operator="-",unary.prefix=!0,unary.argument=this.parseExprAtom(),node.literal=this.finishNode(unary,"UnaryExpression"),this.finishNode(node,"TSLiteralType")}case tt.backQuote:return this.$25();case tt._this:{let thisType=this.$w();if(this.isContextual("is")&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(thisType.start,thisType.loc?.start);return node.parameterName=thisType,this.$x(node,!1)}return thisType}case tt._typeof:return this.$26();case tt._import:return this.$1d();case tt.braceL:return this.$27()?this.$28():this.$29();case tt.bracketL:return this.$2a();case tt.parenL:{let node=this.startNode();return this.next(),node.typeAnnotation=this.$0(),this.expect(tt.parenR),this.finishNode(node,"TSParenthesizedType")}default:if(this.type.keyword)return this.$1c()}return this.unexpected()}$1c(){let node=this.startNode();if(node.typeName=this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeReference")}$j(){let entity=this.parseIdent(!0);while(this.eat(tt.dot)){let node=this.startNodeAt(entity.start,entity.loc?.start);node.left=entity,node.right=this.parseIdent(!0),entity=this.finishNode(node,"TSQualifiedName")}return entity}$26(){let node=this.startNode();if(this.next(),node.exprName=this.type===tt._import?this.$1d():this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeQuery")}$1d(){let node=this.startNode();if(this.next(),node.argument=this.$1e(),this.eat(tt.dot))node.qualifier=this.$j();if(this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSImportType")}$z(){if(this.type!==tt.string)this.unexpected();return this.parseExprAtom()}$1e(){this.expect(tt.parenL);let string=this.$z();return this.expect(tt.parenR),string}$25(){let node=this.startNode(),literal=this.startNode();this.next(),literal.expressions=[];let element=this.parseTemplateElement({isTagged:!1});literal.quasis=[element];while(!element.tail){if(this.type===tt.eof)this.raise(this.pos,"Unterminated template literal");this.expect(tt.dollarBraceL),literal.expressions.push(this.$0()),this.expect(tt.braceR),element=this.parseTemplateElement({isTagged:!1}),literal.quasis.push(element)}return this.next(),node.literal=this.finishNode(literal,"TemplateLiteral"),this.finishNode(node,"TSLiteralType")}$27(){return this.$v(()=>{if(this.next(),this.type===tt.plusMin)return this.next(),this.isContextual("readonly");if(this.isContextual("readonly"))this.next();if(this.type!==tt.bracketL)return!1;if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt._in})}$28(){let node=this.startNode();if(this.expect(tt.braceL),this.type===tt.plusMin)node.readonly=this.value,this.next(),this.expectContextual("readonly");else if(this.eatContextual("readonly"))node.readonly=!0;this.expect(tt.bracketL);let parameter=this.startNode();if(parameter.name=this.$y(),this.expect(tt._in),parameter.constraint=this.$0(),node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),node.nameType=this.eatContextual("as")?this.$0():null,this.expect(tt.bracketR),this.type===tt.plusMin)node.optional=this.value,this.next(),this.expect(tt.question);else if(this.eat(tt.question))node.optional=!0;if(this.eat(tt.colon))node.typeAnnotation=this.$0();return this.semicolon(),this.expect(tt.braceR),this.finishNode(node,"TSMappedType")}$29(){let node=this.startNode();return node.members=this.$1f(),this.finishNode(node,"TSTypeLiteral")}$1f(){this.expect(tt.braceL);let members=[];while(!this.eat(tt.braceR))members.push(this.$2b());return members}$2b(){let node=this.startNode(),type="TSPropertySignature",next=this.type===tt._new?this.$2():-1;if(this.type===tt.parenL||this.$1())type="TSCallSignatureDeclaration",this.$r(node,tt.colon);else if(next===CHAR_PAREN_L||next===CHAR_LT)type="TSConstructSignatureDeclaration",this.next(),this.$r(node,tt.colon);else{let newKey=this.type===tt._new?this.parseIdent(!0):null;if(this.isContextual("readonly")&&this.$s(!0))this.next(),node.readonly=!0;if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);let kind="method";if(newKey)node.key=newKey;else{if((this.isContextual("get")||this.isContextual("set"))&&this.$s(!1))kind=this.value,this.next();this.parsePropertyName(node)}if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()){if(type="TSMethodSignature",kind!=="method")node.kind=kind;this.$r(node,tt.colon),node.kind=kind}else if(this.type===tt.colon)node.typeAnnotation=this.$6()}return this.$1i(),this.finishNode(node,type)}$1i(){if(!this.eat(tt.comma))this.semicolon()}$1g(){return this.$v(()=>{if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt.colon})}$1h(node){if(this.expect(tt.bracketL),node.parameters=[this.$h(this.parseIdent(),!1)],this.expect(tt.bracketR),this.type===tt.colon)node.typeAnnotation=this.$6();return this.$1i(),this.finishNode(node,"TSIndexSignature")}$2a(){let node=this.startNode();this.expect(tt.bracketL),node.elementTypes=[];while(!this.eat(tt.bracketR))if(node.elementTypes.push(this.$2c()),this.type!==tt.bracketR)this.expect(tt.comma);return this.finishNode(node,"TSTupleType")}$2c(){let start=this.start,startLoc=this.startLoc,rest=this.eat(tt.ellipsis),element;if((this.type===tt.name||this.type.keyword)&&this.$2d()){let node=this.startNode();node.label=this.parseIdent(!0),node.optional=this.eat(tt.question),this.expect(tt.colon),node.elementType=this.$0(),element=this.finishNode(node,"TSNamedTupleMember")}else if(element=this.$0(),this.eat(tt.question)){let node=this.startNodeAt(element.start,element.loc?.start);node.typeAnnotation=element,element=this.finishNode(node,"TSOptionalType")}if(rest){let node=this.startNodeAt(start,startLoc);node.typeAnnotation=element,element=this.finishNode(node,"TSRestType")}return element}$2d(){let at=this.$d();if(this.input.charCodeAt(at)===63)at=this.$d(at+1);return this.input.charCodeAt(at)===CHAR_COLON}$8(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c()){let parameter=this.startNode();while((this.type===tt._const||this.type===tt._in||this.isContextual("out"))&&isIdentifierStart(this.$2()))parameter[this.value]=!0,this.next();if(parameter.name=this.$y(),this.eat(tt._extends))parameter.constraint=this.$0();if(this.eat(tt.eq))parameter.default=this.$0();if(node.params.push(this.finishNode(parameter,"TSTypeParameter")),!this.$c()){if(this.expect(tt.comma),this.$c())node.extra={trailingComma:this.lastTokStart}}}if(this.next(),node.params.length===0)this.$1y(this.start,"Type parameter list cannot be empty.");return this.finishNode(node,"TSTypeParameterDeclaration")})}$e(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c())if(node.params.push(this.$0()),!this.$c())this.expect(tt.comma);if(node.params.length===0)this.unexpected();return this.next(),this.finishNode(node,"TSTypeParameterInstantiation")})}$1j(){let list=[];do{let node=this.startNode();if(node.expression=this.$j(),this.$1())node.typeParameters=this.$e();list.push(this.finishNode(node,"TSExpressionWithTypeArguments"))}while(this.eat(tt.comma));return list}$1k(exported=!1){if(this.type!==tt.name||this.containsEsc){if(this.type===tt._const&&this.$3()==="enum")return this.$10(this.startNode());return}if(!this.$2e(this.value))return;if(this.value==="declare")return this.$2f(exported);return this.$1l(this.startNode(),this.value)}$2e(word){switch(word){case"interface":case"type":case"namespace":return this.$14();case"enum":return isIdentifierStart(this.$2());case"abstract":return this.$b()&&this.$3()==="class";case"module":{let next=this.$2();return this.$b()&&(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next))}case"declare":return this.$b()&&DECLARE_TARGETS.has(this.$3());case"global":return this.$b()&&this.$2()===CHAR_BRACE_L}return!1}$1l(node,word){switch(word){case"interface":return this.$1m(node);case"type":return this.$2g(node);case"enum":return this.$10(node);case"abstract":return this.$1n(node,!0);case"global":return node.global=!0,node.id=this.parseIdent(),node.body=this.$11(),this.finishNode(node,"TSModuleDeclaration")}return this.$2h(node)}$2f(exported){let old=this.$5;this.$5=!0;let node=this.startNode();this.next();let word=this.value;if(word==="const"&&this.$3()==="enum")node.const=!0;if(!exported&&DECLARE_FIRST.has(word))node.declare=!0;let declaration;if(node.const)declaration=this.$10(node);else if(word==="var"||word==="let"||word==="const")declaration=this.parseVarStatement(node,word,!0);else if(word==="function")this.next(),declaration=this.parseFunction(node,FUNC_STATEMENT,!1,!1);else if(word==="class")declaration=this.parseClass(node,!0);else declaration=this.$1l(node,word);return declaration.declare=!0,this.$5=old,declaration}$1n(node,isStatement){return this.next(),node.abstract=!0,this.parseClass(node,isStatement)}$1m(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_INTERFACE),this.$1())node.typeParameters=this.$8();return this.$a(()=>{if(this.eat(tt._extends))node.extends=this.$1j();let body=this.startNode();body.body=this.$1f(),node.body=this.finishNode(body,"TSInterfaceBody")}),this.finishNode(node,"TSInterfaceDeclaration")}$2g(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_TYPE),this.$1())node.typeParameters=this.$8();return node.typeAnnotation=this.$a(()=>(this.expect(tt.eq),this.$0())),this.semicolon(),this.finishNode(node,"TSTypeAliasDeclaration")}$10(node){if(this.type===tt._const)node.const=!0,this.next();this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_ENUM),this.expect(tt.braceL),node.members=[];while(!this.eat(tt.braceR)){let member=this.startNode();if(member.id=this.type===tt.string?this.parseExprAtom():this.parseIdent(!0),this.eat(tt.eq))member.initializer=this.parseMaybeAssign();if(node.members.push(this.finishNode(member,"TSEnumMember")),this.type!==tt.braceR)this.expect(tt.comma)}return this.finishNode(node,"TSEnumDeclaration")}$2h(node){if(this.next(),this.type===tt.string){if(node.id=this.parseExprAtom(),this.type===tt.braceL)node.body=this.$11();else this.semicolon();return this.finishNode(node,"TSModuleDeclaration")}return node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_NAMESPACE),this.$1o(node)}$1o(node){if(this.eat(tt.dot)){let inner=this.startNode();inner.id=this.parseIdent(),node.body=this.$1o(inner)}else node.body=this.$11();return this.finishNode(node,"TSModuleDeclaration")}$11(){this.enterScope(SCOPE_CLASS_STATIC_BLOCK);let node=this.startNode();this.enterScope(0),this.expect(tt.braceL),node.body=[];while(!this.eat(tt.braceR))node.body.push(this.parseStatement(null,!0));return this.exitScope(),this.exitScope(),this.finishNode(node,"TSModuleBlock")}$1p(node,isExport){if(node.isExport=isExport,node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_LEXICAL),this.expect(tt.eq),this.isContextual("require")&&this.$2()===CHAR_PAREN_L){let reference=this.startNode();this.next(),reference.expression=this.$1e(),node.moduleReference=this.finishNode(reference,"TSExternalModuleReference")}else node.moduleReference=this.$j();return this.semicolon(),this.finishNode(node,"TSImportEqualsDeclaration")}$2i(){let at=this.$d();if(this.input.charCodeAt(at)!==CHAR_EQ)return!1;let after=this.input.charCodeAt(at+1);return after!==CHAR_EQ&&after!==62}parseStatement(context,topLevel,exports){if(this.type===atType)this.$1q(!0);let declaration=this.$1k();if(declaration)return declaration;return super.parseStatement(context,topLevel,exports)}parseVarStatement(node,kind,allowMissingInitializer){return super.parseVarStatement(node,kind,allowMissingInitializer||this.$5)}parseVarId(decl,kind){if(super.parseVarId(decl,kind),decl.id.type==="Identifier"&&this.$u()&&!this.hasPrecedingLineBreak())this.next(),decl.definite=!0;this.$h(decl.id,!1)}parseCatchClauseParam(){let param=this.$h(this.parseBindingAtom(),!1),simple=param.type==="Identifier";return this.enterScope(simple?SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(param,simple?BIND_SIMPLE_CATCH:BIND_LEXICAL),this.expect(tt.parenR),param}parseImport(node){if(this.next(),node.importKind="value",this.type===tt.string)node.specifiers=[],node.source=this.parseExprAtom();else{if(this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR||isIdentifierStart(next)&&this.$3()!=="from")node.importKind="type",this.next()}if(this.type===tt.name&&this.$2i())return this.$1p(node,!1);node.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),node.source=this.$z()}return this.$1r(node),this.semicolon(),this.finishNode(node,"ImportDeclaration")}parseWithClause(){if(this.isContextual("assert")&&!this.hasPrecedingLineBreak())this.type=tt._with;return this.type===tt._with?super.parseWithClause():void 0}$1r(node){let attributes=this.parseWithClause();if(attributes)node.attributes=attributes}parseImportSpecifier(){return this.$1s("importKind",()=>super.parseImportSpecifier())}parseExportSpecifier(exports){return this.$1s("exportKind",()=>super.parseExportSpecifier(exports))}$1s(kindKey,parse){let next=this.isContextual("type")?this.$2():-1;if(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next)&&this.$3()!=="as"){let modifier=this.startNode();this.next();let node=parse();return this.$q(node,modifier),node[kindKey]="type",node}let node=parse();return node[kindKey]="value",node}parseExport(node,exports){if(this.next(),this.eat(tt._import)){if(node.importKind="value",this.isContextual("type")&&isIdentifierStart(this.$2())&&this.$3()!=="from")node.importKind="type",this.next();return this.$1p(node,!0)}if(this.eat(tt.eq))return node.expression=this.parseExpression(),this.semicolon(),this.finishNode(node,"TSExportAssignment");if(this.eatContextual("as"))return this.expectContextual("namespace"),node.id=this.parseIdent(),this.semicolon(),this.finishNode(node,"TSNamespaceExportDeclaration");if(node.exportKind="value",this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR)node.exportKind="type",this.next()}if(this.eat(tt.star))return this.parseExportAllDeclaration(node,exports);if(this.eat(tt._default)){if(this.isContextual("interface")&&this.$14())node.declaration=this.$1m(this.startNode());else if(this.isContextual("abstract")&&this.$3()==="class")node.declaration=this.$1n(this.startNode(),"nullableID");else node.declaration=this.parseExportDefaultDeclaration();return this.finishNode(node,"ExportDefaultDeclaration")}let isDeclare=this.isContextual("declare"),declaration=this.$1k(!0);if(declaration||this.shouldParseExportStatement()){if(node.declaration=declaration??this.parseStatement(null),isDeclare||node.declaration.type==="TSInterfaceDeclaration"||node.declaration.type==="TSTypeAliasDeclaration")node.exportKind="type";return node.specifiers=[],node.source=null,this.finishNode(node,"ExportNamedDeclaration")}if(node.declaration=null,node.specifiers=this.parseExportSpecifiers(exports),this.eatContextual("from"))node.source=this.$z(),this.$1r(node);else{for(let spec of node.specifiers)if(this.checkUnreserved(spec.local),this.checkLocalExport(spec.local),spec.local.type==="Literal")this.raise(spec.local.start,"A string literal cannot be used as an exported binding without `from`.");node.source=null}return this.semicolon(),this.finishNode(node,"ExportNamedDeclaration")}parseFunction(node,statement,allowExpressionBody,isAsync,forInit){let isDeclaration=statement&FUNC_STATEMENT;if(isDeclaration)this.$f=node,this.$o=node.start;super.parseFunction(node,statement,allowExpressionBody,isAsync,forInit),this.$f=null;let bodiless=!node.body;if(bodiless)node.type="TSDeclareFunction";if(isDeclaration&&node.id){if(bodiless){if(this.$5&&this.currentScope().flags&SCOPE_TOP)this.declareName(node.id.name,BIND_FLAGS_TS_EXPORT_ONLY,node.id.start);this.checkLValSimple(node.id,BIND_NONE)}else if(!(statement&FUNC_HANGING_STATEMENT)){let bindingType=BIND_FUNCTION;if(this.strict||node.generator||node.async)bindingType=this.treatFunctionsAsVar?BIND_VAR:BIND_LEXICAL;this.checkLValSimple(node.id,bindingType)}}return node}parseFunctionParams(node){if(this.$1())node.typeParameters=this.$8();if(super.parseFunctionParams(node),this.type===tt.colon)node.returnType=this.$6(!0)}parseFunctionBody(node,isArrowFunction,isMethod,forInit){if(isMethod&&this.type===tt.colon)node.returnType=this.$6(!0);if(isArrowFunction||this.type===tt.braceL||node.start!==this.$o){super.parseFunctionBody(node,isArrowFunction,isMethod,forInit);return}this.semicolon(),this.exitScope()}parseMethod(isGenerator,isAsync,allowDirectSuper){let typeParameters=this.$k;this.$k=null;let node=super.parseMethod(isGenerator,isAsync,allowDirectSuper);if(!node.body)node.type="TSDeclareMethod";if(typeParameters)node.typeParameters=typeParameters;return node}parseBindingList(close,allowEmpty,allowTrailingComma,allowModifiers){let modifiers=allowModifiers===!0||this.$l;return this.$l=!1,super.parseBindingList(close,allowEmpty,allowTrailingComma,modifiers)}$s(allowLineBreak){if(!allowLineBreak&&!this.$b())return!1;let next=this.$2();return next===CHAR_BRACKET_L||next===CHAR_BRACE_L||next===CHAR_STAR||next===CHAR_DOT||next===CHAR_HASH||next===CHAR_DQUOTE||next===CHAR_SQUOTE||next>=48&&next<=57||isIdentifierStart(next)}parseAssignableListItem(allowModifiers){let decorators=this.$12(),start=this.start,startLoc=this.startLoc,accessibility,readonly=!1,override=!1;if(allowModifiers)while(this.type===tt.name&&PARAMETER_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(!1)){if(this.value==="readonly")readonly=!0;else if(this.value==="override")override=!0;else accessibility=this.value;this.next()}let left;if(this.type===tt._this)left=this.startNode(),left.name="this",this.next(),this.finishNode(left,"Identifier");else left=this.parseBindingAtom();let element=this.type===tt.eq?this.parseMaybeDefault(start,startLoc,left):this.parseMaybeDefault(left.start,left.loc?.start,this.$h(left,!0));if(decorators.length>0)element.decorators=decorators;if(!accessibility&&!readonly&&!override)return element;let node=this.startNodeAt(start,startLoc);if(accessibility)node.accessibility=accessibility;if(readonly)node.readonly=!0;if(override)node.override=!0;return node.parameter=element,this.finishNode(node,"TSParameterProperty")}parseBindingListItem(param){if(param.type==="RestElement")this.$h(param,!0);return param}checkLValSimple(expr,bindingType,checkClashes){if(this.$f&&expr===this.$f.id){this.$f=null;return}if(!bindingType&&TS_EXPRESSION_WRAPPERS.has(expr.type)){this.checkLValSimple(expr.expression,bindingType,checkClashes);return}switch(expr.type){case"TSParameterProperty":this.checkLValInnerPattern(expr.parameter,bindingType,checkClashes);return;case"Identifier":if(expr.name==="this")return}super.checkLValSimple(expr,bindingType,checkClashes)}toAssignable(node,isBinding,refDestructuringErrors){if(node&&!isBinding&&TS_EXPRESSION_WRAPPERS.has(node.type))return node;return super.toAssignable(node,isBinding,refDestructuringErrors)}declareName(name,bindingType,pos){let scope=this.currentScope();if(bindingType&BIND_FLAGS_TS_EXPORT_ONLY){this.$1t(scope,name),scope.$1u??=[],scope.$1u.push(name);return}if(bindingType===BIND_TS_TYPE||bindingType===BIND_TS_INTERFACE){if(scope.$13??=[],bindingType===BIND_TS_TYPE&&hasName(scope.$13,name))this.raise(pos,`type '${name}' has already been declared.`);scope.$13.push(name),this.$1t(scope,name);return}if(bindingType&BIND_FLAGS_TS_ENUM){if(scope.$1v??=[],hasName(scope.$1v,name))return;super.declareName(name,BIND_LEXICAL,pos),scope.$1v.push(name);return}super.declareName(name,bindingType,pos)}$1t(scope,name){if(this.inModule&&scope.flags&SCOPE_TOP)delete this.undefinedExports[name]}checkLocalExport(id){for(let i=this.scopeStack.length-1;i>=0;i--){let scope=this.scopeStack[i];if(hasName(scope.$13,id.name)||hasName(scope.$1u,id.name))return}super.checkLocalExport(id)}checkExport(){}raiseRecoverable(pos,message){if(message==="Duplicate constructor in the same class")return;super.raiseRecoverable(pos,message)}$12(){let decorators=[];while(this.type===atType)decorators.push(this.$1w());return decorators}$1q(allowExport){let pending=this.$9[this.$9.length-1];while(this.type===atType)pending.push(this.$1w());if(this.type===tt._export){if(!allowExport)this.unexpected()}else if(this.type!==tt._class&&!((this.isContextual("abstract")||this.isContextual("declare"))&&this.$3()==="class"))this.raise(this.start,"Leading decorators must be attached to a class declaration.")}$1w(){let node=this.startNode();this.next(),this.$9.push([]);let startPos=this.start,startLoc=this.startLoc,expression;if(this.type===tt.parenL){if(this.next(),expression=this.parseExpression(),this.expect(tt.parenR),this.options.preserveParens){let paren=this.startNodeAt(startPos,startLoc);paren.expression=expression,expression=this.finishNode(paren,"ParenthesizedExpression")}}else{expression=this.parseIdent(!1);while(this.eat(tt.dot)){let member=this.startNodeAt(startPos,startLoc);member.object=expression,member.property=this.parseIdent(!0),member.computed=!1,expression=this.finishNode(member,"MemberExpression")}}let typeArguments=this.$p()?this.$e():void 0;if(this.eat(tt.parenL)){let call=this.startNodeAt(expression.start,expression.loc?.start);if(call.callee=expression,call.arguments=this.parseExprList(tt.parenR,!1,!1),typeArguments)call.typeArguments=typeArguments;expression=this.finishNode(call,"CallExpression")}else if(typeArguments){let instantiation=this.startNodeAt(expression.start,expression.loc?.start);instantiation.expression=expression,instantiation.typeArguments=typeArguments,expression=this.finishNode(instantiation,"TSInstantiationExpression")}return node.expression=expression,this.$9.pop(),this.finishNode(node,"Decorator")}shouldParseExportStatement(){return this.type===atType||super.shouldParseExportStatement()}parseExprAtom(refDestructuringErrors,forInit,forNew){if(this.type===atType)this.$1q(!1);return super.parseExprAtom(refDestructuringErrors,forInit,forNew)}parseProperty(isPattern,refDestructuringErrors){if(isPattern||this.type!==atType)return super.parseProperty(isPattern,refDestructuringErrors);let decorators=this.$12(),property=super.parseProperty(isPattern,refDestructuringErrors);if(property.type==="SpreadElement")this.raise(property.start,"Decorators can't be used with SpreadElement");return property.decorators=decorators,property}parseClassId(node,isStatement){let index=this.$9.length-1,decorators=this.$9[index];if(decorators.length>0)node.decorators=decorators,this.$q(node,decorators[0]),this.$9[index]=[];if(!this.isContextual("implements")||isStatement===!0)super.parseClassId(node,isStatement);if(this.$1())node.typeParameters=this.$8()}parseClassSuper(node){if(super.parseClassSuper(node),node.superClass&&this.$1())node.superTypeParameters=this.$e();if(this.eatContextual("implements"))node.implements=this.$a(()=>this.$1j())}parseClassElement(constructorAllowsSuper){if(this.type===atType){let decorators=this.$12();if(this.type===tt.braceR)this.raise(this.start,"Decorators must be attached to a class element.");let element=this.parseClassElement(constructorAllowsSuper);return element.decorators=decorators,this.$q(element,decorators[0]),element}if(this.eat(tt.semi))return null;let node=this.startNode();while(this.type===tt.name&&CLASS_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(this.value==="static")){let modifier=this.value;if(this.next(),modifier==="static"&&this.type===tt.braceL)return this.next(),this.parseClassStaticBlock(node),node;if(modifier==="public"||modifier==="private"||modifier==="protected")node.accessibility=modifier;else node[modifier]=!0}if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);node.static??=!1;let keyName="",isGenerator=!1,isAsync=!1,kind="method";if(this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===tt.star)&&!this.canInsertSemicolon())isAsync=!0;else keyName="async";if(!keyName&&this.eat(tt.star))isGenerator=!0;if(!keyName&&!isAsync&&!isGenerator){let lastValue=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())kind=lastValue;else keyName=lastValue}if(keyName)node.computed=!1,node.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),node.key.name=keyName,this.finishNode(node.key,"Identifier");else this.parseClassElementName(node);if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()||kind!=="method"||isGenerator||isAsync){let key=node.key,isConstructor=!node.static&&!node.computed&&(key.type==="Identifier"&&key.name==="constructor"||key.type==="Literal"&&key.value==="constructor");if(node.kind=isConstructor?"constructor":kind,this.$1())node.typeParameters=this.$8();this.$l=isConstructor,this.$o=this.start,this.parseClassMethod(node,isGenerator,isAsync,isConstructor&&constructorAllowsSuper)}else{if(!node.optional&&this.$u())this.next(),node.definite=!0;if(this.type===tt.colon)node.typeAnnotation=this.$6();this.parseClassField(node)}return node}parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse){if(this.$p()){let arrow=this.$g(()=>{let typeParameters=this.$8(),expr=super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse);if(expr.type!=="ArrowFunctionExpression")return;return expr.typeParameters=typeParameters,this.$q(expr,typeParameters),expr});if(arrow)return arrow}return super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse)}parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit){if(this.$p()){let node=this.startNode();return node.typeAnnotation=this.$a(()=>{this.next();let type=this.$0();if(!this.$c())this.unexpected();return this.next(),type}),node.expression=this.parseMaybeUnary(null,!1,!1,forInit),this.finishNode(node,"TSTypeAssertion")}return super.parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit)}parseMaybeConditional(forInit,refDestructuringErrors){let startPos=this.start,startLoc=this.startLoc,expr=this.parseExprOps(forInit,refDestructuringErrors);if(this.checkExpressionErrors(refDestructuringErrors))return expr;if(this.type===tt.question&&!(expr.type==="ArrowFunctionExpression"&&expr.start===startPos)&&!this.$2j()){this.next();let node=this.startNodeAt(startPos,startLoc);return node.test=expr,node.consequent=this.parseMaybeAssign(),this.expect(tt.colon),node.alternate=this.parseMaybeAssign(forInit),this.finishNode(node,"ConditionalExpression")}return expr}$2j(){let at=this.$d(),next=this.input.charCodeAt(at);if(next===CHAR_COLON||next===CHAR_COMMA||next===CHAR_PAREN_R)return!0;return next===CHAR_EQ&&this.input.charCodeAt(at+1)!==CHAR_EQ}parseParenItem(item){return this.$h(item,!0)}$1x(){if(this.type!==tt.colon)return!0;let returnType=this.$g(()=>{let type=this.$6(!0);return this.type===tt.arrow&&!this.canInsertSemicolon()?type:void 0});if(!returnType)return!1;return this.$7=returnType,!0}shouldParseArrow(exprList){return this.$1x()&&super.shouldParseArrow(exprList)}shouldParseAsyncArrow(){return this.$1x()&&super.shouldParseAsyncArrow()}parseArrowExpression(node,params,isAsync,forInit){if(this.$7)node.returnType=this.$7,this.$7=null;return super.parseArrowExpression(node,params,isAsync,forInit)}parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors){if(!this.$m)return super.parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors);this.$m=!1;let elements=[],first=!0;while(!this.eat(close)){if(first)first=!1;else if(this.expect(tt.comma),allowTrailingComma&&this.afterTrailingComma(close))break;if(this.type===tt.ellipsis){let spread=this.parseSpread(refDestructuringErrors);if(this.eat(tt.question))spread.optional=!0;if(this.type===tt.colon)spread.typeAnnotation=this.$6();elements.push(spread)}else elements.push(this.parseMaybeAssign(!1,refDestructuringErrors,this.parseParenItem))}return elements}parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit){if(this.$u()&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(startPos,startLoc);return this.exprAllowed=!1,this.next(),node.expression=base,this.finishNode(node,"TSNonNullExpression")}if(maybeAsyncArrow&&this.$1()){let arrow=this.$g(()=>this.$2k(startPos,startLoc,forInit));if(arrow)return arrow}let optional=this.type===tt.questionDot&&this.$2()===CHAR_LT;if(this.$1()||optional||this.type===tt.bitShift&&this.value==="<<"){let typeArguments=this.$g(()=>{if(optional)this.next();this.$p();let args=this.$e();if(this.type===tt.parenL&&!noCalls)return args;if(this.type===tt.backQuote)return optional?void 0:args;if(optional)return;if(this.$c()||this.type===tt.bitShift||this.type.startsExpr&&this.type!==tt.parenL&&!this.hasPrecedingLineBreak())return;return args});if(typeArguments){let node=this.startNodeAt(startPos,startLoc);if(this.type===tt.parenL&&!noCalls){if(this.next(),node.callee=base,node.arguments=this.parseExprList(tt.parenR,!0,!1),node.typeArguments=typeArguments,optional)base.optional=!0;if(optional||optionalChained)node.optional=optional;return this.finishNode(node,"CallExpression")}if(this.type===tt.backQuote)return node.tag=base,node.quasi=this.parseTemplate({isTagged:!0}),node.typeArguments=typeArguments,this.finishNode(node,"TaggedTemplateExpression");return node.expression=base,node.typeArguments=typeArguments,this.finishNode(node,"TSInstantiationExpression")}}if(maybeAsyncArrow&&this.type===tt.parenL)this.$m=!0;return super.parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit)}$2k(startPos,startLoc,forInit){let node=this.startNodeAt(startPos,startLoc);if(node.typeParameters=this.$8(),this.expect(tt.parenL),node.params=this.parseBindingList(tt.parenR,!1,!0),this.type===tt.colon)node.returnType=this.$6(!0);if(this.type!==tt.arrow||this.canInsertSemicolon())return;return this.next(),this.parseArrowExpression(node,node.params,!0,forInit)}parseDynamicImport(node){if(this.next(),node.source=this.parseMaybeAssign(),this.eat(tt.comma)&&this.type!==tt.parenR)node.arguments=[this.parseExpression()];return this.expect(tt.parenR),this.finishNode(node,"ImportExpression")}parseNew(){let node=super.parseNew();if(node.callee?.type!=="TSInstantiationExpression")return node;let result=this.startNodeAt(node.start,node.loc?.start);return result.callee=node.callee.expression,result.typeArguments=node.callee.typeArguments,result.arguments=node.arguments,this.finishNodeAt(result,"NewExpression",node.end,node.loc?.end)}parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit){if(tt._in.binop>minPrec&&this.type===tt.name&&(this.value==="as"||this.value==="satisfies")&&!this.containsEsc&&!this.hasPrecedingLineBreak()){let isSatisfies=this.value==="satisfies",node=this.startNodeAt(leftStartPos,leftStartLoc);return node.expression=left,node.typeAnnotation=this.$a(()=>{if(this.next(),!isSatisfies&&this.type===tt._const){let reference=this.startNode();return reference.typeName=this.parseIdent(!0),this.finishNode(reference,"TSTypeReference")}return this.$0()}),this.finishNode(node,isSatisfies?"TSSatisfiesExpression":"TSAsExpression"),this.parseExprOp(node,leftStartPos,leftStartLoc,minPrec,forInit)}return super.parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit)}parseGetterSetter(prop){prop.kind=prop.key.name,super.parseGetterSetter(prop)}parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc){if(!isPattern&&this.$1()){if(this.$k=this.$8(),this.type!==tt.parenL)this.unexpected();prop.kind="init"}return super.parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc)}}return TSParser});
|
|
2
2
|
export{tsPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{setSource}from"./shared-m0dcdh24.js";import{parseStatementsAt}from"./shared-
|
|
1
|
+
import{setSource}from"./shared-m0dcdh24.js";import{parseStatementsAt}from"./shared-w3mxqtgj.js";import{scan}from"./shared-e4gbs4rb.js";function parseImportsExportsWith(source,options,typescript){setSource(source);let context={isTypeScript:options.typescript??!1,typescript,loc:!1,comments:!1,root:{comments:[]}};return parseStatementsAt(context,source,(parseAt)=>scan(source,options.localExports??!0,parseAt))}
|
|
2
2
|
export{parseImportsExportsWith};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{parseComponent}from"./shared-
|
|
1
|
+
import{parseComponent}from"./shared-qqrqzz29.js";import{htmlEntityNames}from"./shared-drb44hb9.js";import{TypeScriptParser}from"./shared-dscc5xg8.js";var support={typescript:TypeScriptParser,entityNames:htmlEntityNames};function parse2(source,options){return parseComponent(source,options,support)}
|
|
2
2
|
export{parse2};
|