sveast 0.9.3 → 0.9.5
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 +76 -3
- package/core.js +1 -1
- package/entities.js +1 -1
- package/index.d.ts +439 -0
- package/index.js +1 -1
- package/is-valid-type.js +1 -1
- package/lexer.js +3 -3
- 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/scope.d.ts +1794 -0
- package/scope.js +1 -0
- package/shared-2pngd0mg.js +10 -0
- package/shared-5tpb3h6x.js +2 -0
- package/shared-bzqbnvee.js +2 -0
- package/shared-cs1ezg1f.js +2 -0
- package/shared-dgdrqgdn.js +2 -0
- package/shared-drb44hb9.js +2 -0
- package/shared-h6z1kjbb.js +2 -0
- package/shared-jpvd0875.js +2 -0
- package/shared-ke0fgd3r.js +2 -0
- package/shared-m0dcdh24.js +5 -0
- package/shared-m3dr31c3.js +2 -0
- package/shared-nan648gn.js +10 -0
- package/shared-qkp49nav.js +2 -0
- package/shared-rce4ty8a.js +3 -0
- package/shared-rvkvagj5.js +2 -0
- package/shared-xwzsb4m8.js +3 -0
- package/shared-y3nf00py.js +3 -0
- package/shared-y41kz9tv.js +2 -0
- package/shared-z9y4mrek.js +2 -0
- package/typescript.js +1 -1
- package/walk.d.ts +247 -0
- package/walk.js +1 -1
- package/shared-1z80250f.js +0 -2
- package/shared-2m9w933n.js +0 -2
- package/shared-3bhr0q10.js +0 -2
- package/shared-3ez2yv7r.js +0 -2
- package/shared-4t495q2a.js +0 -2
- package/shared-7q3geqgt.js +0 -2
- package/shared-bbp47cz4.js +0 -10
- package/shared-bx03zqyq.js +0 -2
- package/shared-cr4ebmgx.js +0 -5
- package/shared-g06vtkxe.js +0 -2
- package/shared-g7qbtk93.js +0 -3
- package/shared-j1r12f45.js +0 -3
- package/shared-njpj8eam.js +0 -2
- package/shared-qbw8n9am.js +0 -2
- package/shared-saxr459v.js +0 -2
- package/shared-wfjkg544.js +0 -10
- package/shared-wr6wdcs6.js +0 -2
- package/shared-xa3xp3kp.js +0 -3
package/lexer.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,
|
|
3
|
-
`;case 114:return"\r";case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 48:return
|
|
1
|
+
import{isDigit}from"./shared-5tpb3h6x.js";import{isWordCode,scan,scanLiterals,lineEnd,skipTrivia,isWordAt}from"./shared-y3nf00py.js";import"./shared-dgdrqgdn.js";import{lexComponent2}from"./shared-rce4ty8a.js";function lexImportsExports(source){let lexer=new Lexer(source),statements=[];return scan(source,!1,(_start,keyword)=>{let statement=lexer.statement(keyword);return statements.push(statement),statement.end}),statements}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;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}return this.from(statement)}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
|
+
`,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};
|
package/module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-2pngd0mg.js";import"./shared-m0dcdh24.js";import{ParseError2}from"./shared-nan648gn.js";import"./shared-5tpb3h6x.js";import"./shared-y3nf00py.js";import{parseModuleWith}from"./shared-z9y4mrek.js";import{parseImportsExportsWith}from"./shared-rvkvagj5.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.5",
|
|
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)",
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"import": "./walk.js",
|
|
39
39
|
"default": "./walk.js"
|
|
40
40
|
},
|
|
41
|
+
"./scope": {
|
|
42
|
+
"types": "./scope.d.ts",
|
|
43
|
+
"import": "./scope.js",
|
|
44
|
+
"default": "./scope.js"
|
|
45
|
+
},
|
|
41
46
|
"./lexer": {
|
|
42
47
|
"types": "./lexer.d.ts",
|
|
43
48
|
"import": "./lexer.js",
|
package/parse-imports-exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-2pngd0mg.js";import"./shared-m0dcdh24.js";import"./shared-nan648gn.js";import"./shared-5tpb3h6x.js";import"./shared-y3nf00py.js";import"./shared-cs1ezg1f.js";import{TypeScriptParser}from"./shared-ke0fgd3r.js";import{parseImportsExportsWith}from"./shared-rvkvagj5.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-2pngd0mg.js";import"./shared-m0dcdh24.js";import{ParseError2}from"./shared-nan648gn.js";import"./shared-cs1ezg1f.js";import{TypeScriptParser}from"./shared-ke0fgd3r.js";import{parseModuleWith}from"./shared-z9y4mrek.js";function parseModule(source,options={}){return parseModuleWith(source,options,TypeScriptParser)}export{ParseError2 as ParseError,parseModule};
|
package/parse-sections.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{parseSections2}from"./shared-y41kz9tv.js";import"./shared-rce4ty8a.js";import"./shared-drb44hb9.js";import"./shared-ke0fgd3r.js";import"./shared-cs1ezg1f.js";import"./shared-xwzsb4m8.js";import"./shared-bzqbnvee.js";import"./shared-dgdrqgdn.js";import"./shared-y3nf00py.js";import"./shared-5tpb3h6x.js";import"./shared-nan648gn.js";import"./shared-m0dcdh24.js";import"./shared-2pngd0mg.js";export{parseSections2 as parseSections};
|
package/parse.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{parse2}from"./shared-qkp49nav.js";import"./shared-drb44hb9.js";import"./shared-ke0fgd3r.js";import"./shared-cs1ezg1f.js";import"./shared-xwzsb4m8.js";import"./shared-bzqbnvee.js";import"./shared-dgdrqgdn.js";import"./shared-5tpb3h6x.js";import"./shared-nan648gn.js";import"./shared-m0dcdh24.js";import"./shared-2pngd0mg.js";export{parse2 as parse};
|
package/runes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-dgdrqgdn.js";import{withoutByteOrderMark,isWhitespace,skipWhitespace}from"./shared-5tpb3h6x.js";import{isWordCode,closingBracket,wordCodesEnd}from"./shared-y3nf00py.js";import"./shared-m0dcdh24.js";import"./shared-2pngd0mg.js";import"./shared-nan648gn.js";import"./shared-bzqbnvee.js";import"./shared-xwzsb4m8.js";import"./shared-cs1ezg1f.js";import{parse2}from"./shared-qkp49nav.js";import{parseSections2}from"./shared-y41kz9tv.js";import{extractIdentifiers2,isReference2,STOP2,SKIP2,walk2}from"./shared-jpvd0875.js";import{RUNES,RUNE_NAMES}from"./shared-m3dr31c3.js";import{lexComponent2}from"./shared-rce4ty8a.js";import"./shared-drb44hb9.js";import"./shared-ke0fgd3r.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};
|