sveast 0.9.2 → 0.9.4
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 +437 -7
- 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 +1792 -0
- package/scope.js +1 -0
- package/shared-2by923ar.js +3 -0
- package/shared-3371ehgf.js +2 -0
- package/shared-4wqe6a27.js +5 -0
- package/shared-4zk9ntab.js +2 -0
- package/shared-artd3d80.js +2 -0
- package/shared-c9gzmr05.js +2 -0
- package/shared-h6c4cer7.js +2 -0
- package/shared-hjcsmz9f.js +2 -0
- package/shared-jxkrk6hx.js +10 -0
- package/{shared-k5pfyxpa.js → shared-n0fpkmn8.js} +2 -2
- package/shared-n1wnwhk8.js +3 -0
- package/shared-nbaaegmc.js +2 -0
- package/shared-rh41v5ez.js +3 -0
- package/shared-shxvsq2a.js +2 -0
- package/shared-stdj6se1.js +2 -0
- package/{shared-3yc3kmnb.js → shared-v0nj05q2.js} +2 -2
- package/shared-vjpq32kx.js +2 -0
- package/shared-xyqvjc3m.js +10 -0
- package/shared-znzncsf2.js +2 -0
- package/typescript.d.ts +3 -2
- package/typescript.js +1 -1
- package/walk.d.ts +248 -7
- package/walk.js +1 -1
- package/shared-00hyas4z.js +0 -2
- package/shared-40v3xx3k.js +0 -2
- package/shared-4y1phpr0.js +0 -3
- package/shared-5kdpxrm3.js +0 -5
- package/shared-a454y0yc.js +0 -2
- package/shared-fcgh2ks8.js +0 -2
- package/shared-ff56bedk.js +0 -2
- package/shared-np5jnnrw.js +0 -2
- package/shared-r6mb2ytj.js +0 -2
- package/shared-t30czg6b.js +0 -2
- package/shared-tgpdmrqm.js +0 -3
- package/shared-wkbh341y.js +0 -2
- package/shared-x7fez4k2.js +0 -3
- package/shared-yxr92tk5.js +0 -10
- package/shared-zd01zsyh.js +0 -10
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{s}from"./shared-nbaaegmc.js";import{a,G,Ne,oe,b,q}from"./shared-2by923ar.js";import"./shared-stdj6se1.js";import{se}from"./shared-n1wnwhk8.js";function g(e){let t=new f(e),u=[];return G(e,!1,(i,n)=>{let r=t.statement(n);return u.push(r),r.end}),u}function k(e){let t=new f(e),u=[];return Ne(e,(i,n,r)=>{let o=r?0:1;u.push({kind:r?"template":"string",value:t.cooked(i+o,n-o,r),start:i,end:n})}),u}class f{source;pos=0;end=0;escapeEnd=0;constructor(e){this.source=e}statement(e){this.pos=this.end=e+6;let t={kind:this.source.charCodeAt(e)===105?"import":"export",start:e,end:0,source:null,typeOnly:!1,specifiers:[]};if(!(t.kind==="import"?this.import(t):this.export(t)))t.source=null,t.specifiers=[];return t.end=this.end,t}import(e){let t=this.string();if(t!==null)return e.source=t,this.finish();if(this.isWord("type")){let r=this.peekAfter(4);if(r===123||r===42||d(r)&&!this.isWordAfter(4,"from"))e.typeOnly=!0,this.advance(4)}let{specifiers:u,typeOnly:i}=e,n=this.at();if(n!==123&&n!==42){let r=this.pos,o=this.name();if(o===null)return!1;if(this.at()===61)return this.importEquals();if(u.push({kind:"default",imported:"default",local:o,typeOnly:i,start:r,end:this.end}),!this.eat(44))return this.from(e);n=this.at()}if(n===42){let r=this.pos;if(this.advance(1),!this.eatWord("as"))return!1;let o=this.name();if(o===null)return!1;return u.push({kind:"namespace",imported:"*",local:o,typeOnly:i,start:r,end:this.end}),this.from(e)}if(!this.eat(123))return!1;while(!this.eat(125)){let r=this.skip(),o=this.typeModifier()||i,l=this.name(),h=l??this.string()?.value;if(h===void 0)return!1;let c=l;if(this.eatWord("as"))c=this.name();if(c===null)return!1;if(u.push({kind:"named",imported:h,local:c,typeOnly:o,start:r,end:this.end}),!this.eat(44)&&this.at()!==125)return!1}return this.from(e)}export(e){if(this.eatWord("import")){if(this.isWord("type")&&d(this.peekAfter(4))&&!this.isWordAfter(4,"from"))e.typeOnly=!0,this.advance(4);return this.name()!==null&&this.at()===61&&this.importEquals()}if(this.isWord("type")){let i=this.peekAfter(4);if(i===123||i===42)e.typeOnly=!0,this.advance(4)}let{specifiers:t,typeOnly:u}=e;if(this.at()===42){let i=this.pos;this.advance(1);let n=null;if(this.eatWord("as")){if(n=this.moduleExportName(),n===null)return!1}return t.push({kind:n===null?"all":"namespace",local:"*",exported:n,typeOnly:u,start:i,end:this.end}),this.from(e)}if(!this.eat(123))return!1;while(!this.eat(125)){let i=this.skip(),n=this.typeModifier()||u,r=this.moduleExportName();if(r===null)return!1;let o=r;if(this.eatWord("as"))o=this.moduleExportName();if(o===null)return!1;if(t.push({kind:"named",local:r,exported:o,typeOnly:n,start:i,end:this.end}),!this.eat(44)&&this.at()!==125)return!1}return this.from(e)}typeModifier(){if(!this.isWord("type"))return!1;let e=this.peekAfter(4);if(e===34||e===39||d(e)&&!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(e){if(!this.eatWord("from"))return!1;return e.source=this.string(),e.source!==null&&this.finish()}finish(){let e=this.isWord("with")?4:0;if(this.isWord("assert")&&oe(this.source,this.end)>=this.pos)e=6;if(e!==0&&this.peekAfter(e)===123){this.advance(e),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=b(this.source,this.pos),this.pos}at(){return this.source.charCodeAt(this.skip())}advance(e){this.pos+=e,this.end=this.pos}peekAfter(e){return this.source.charCodeAt(b(this.source,this.pos+e))}isWordAfter(e,t){return q(this.source,b(this.source,this.pos+e),t)}eat(e){if(this.at()!==e)return!1;return this.advance(1),!0}isWord(e){return q(this.source,this.skip(),e)}eatWord(e){if(!this.isWord(e))return!1;return this.advance(e.length),!0}moduleExportName(){return this.name()??this.string()?.value??null}name(){let e=this.source,t=this.skip();if(!a(e.charCodeAt(t))||s(e.charCodeAt(t)))return null;let u="",i=t,n=t;while(n<e.length){let r=e.charCodeAt(n);if(r===92){if(e.charCodeAt(n+1)!==117)return null;let o=this.unicodeEscape(n+2);if(o===null)return null;u+=e.slice(i,n)+o,n=i=this.escapeEnd}else if(a(r))n++;else break}return this.advance(n-t),u+e.slice(i,n)}string(){let e=this.source,t=this.skip(),u=e.charCodeAt(t);if(u!==34&&u!==39)return null;let i="",n=t+1;for(let r=n;r<e.length;){let o=e.charCodeAt(r);if(o===u)return this.advance(r+1-t),{value:i+e.slice(n,r),start:t,end:r+1};if(o===10||o===13)return null;if(o===92){let l=this.escape(r+1);if(l===null)return null;i+=e.slice(n,r)+l,r=n=this.escapeEnd}else r++}return null}cooked(e,t,u){let i=this.source,n="",r=e;for(let o=e;o<t;){let l=i.charCodeAt(o);if(l===92){let h=this.escape(o+1);if(h===null)return null;n+=i.slice(r,o)+h,o=r=this.escapeEnd}else if(l===13&&u)n+=`${i.slice(r,o)}
|
|
2
|
+
`,o+=i.charCodeAt(o+1)===10?2:1,r=o;else o++}return n+i.slice(r,t)}escape(e){let t=this.source.charCodeAt(e);switch(this.escapeEnd=e+1,t){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 s(this.source.charCodeAt(e+1))?null:"\x00";case 120:return this.hexEscape(e+1,2);case 117:return this.unicodeEscape(e+1);case 13:if(this.source.charCodeAt(e+1)===10)this.escapeEnd++;return"";case 10:case 8232:case 8233:return"";default:return s(t)||e>=this.source.length?null:String.fromCharCode(t)}}unicodeEscape(e){if(this.source.charCodeAt(e)!==123)return this.hexEscape(e,4);let t=0,u=e+1;for(;this.source.charCodeAt(u)!==125;u++){let i=p(this.source.charCodeAt(u));if(i===-1)return null;if(t=t*16+i,t>1114111)return null}if(u===e+1)return null;return this.escapeEnd=u+1,String.fromCodePoint(t)}hexEscape(e,t){let u=0;for(let i=e;i<e+t;i++){let n=p(this.source.charCodeAt(i));if(n===-1)return null;u=u*16+n}return this.escapeEnd=e+t,String.fromCharCode(u)}}function d(e){return e!==92&&a(e)&&!s(e)}function p(e){if(s(e))return e-48;let t=e|32;return t>=97&&t<=102?t-87:-1}export{se as lexComponent,g as lexImportsExports,k as lexStrings};
|
package/module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-xyqvjc3m.js";import"./shared-4wqe6a27.js";import{e}from"./shared-jxkrk6hx.js";import"./shared-nbaaegmc.js";import"./shared-2by923ar.js";import{T}from"./shared-artd3d80.js";import{k}from"./shared-hjcsmz9f.js";import{ee}from"./shared-h6c4cer7.js";function m(t={}){let p=ee(t.typescript);return{parseModule:(r,o={})=>T(r,o,p),parseImportsExports:(r,o={})=>k(r,o,p)}}export{e as ParseError,m as createModuleParser};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sveast",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
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-xyqvjc3m.js";import"./shared-4wqe6a27.js";import"./shared-jxkrk6hx.js";import"./shared-nbaaegmc.js";import"./shared-2by923ar.js";import"./shared-c9gzmr05.js";import{c}from"./shared-vjpq32kx.js";import{k}from"./shared-hjcsmz9f.js";function s(r,t={}){return k(r,t,c)}export{s as parseImportsExports};
|
package/parse-module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-xyqvjc3m.js";import"./shared-4wqe6a27.js";import{e}from"./shared-jxkrk6hx.js";import"./shared-c9gzmr05.js";import{c}from"./shared-vjpq32kx.js";import{T}from"./shared-artd3d80.js";function s(r,o={}){return T(r,o,c)}export{e as ParseError,s as parseModule};
|
package/parse-sections.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ue}from"./shared-3371ehgf.js";import"./shared-n1wnwhk8.js";import"./shared-v0nj05q2.js";import"./shared-vjpq32kx.js";import"./shared-c9gzmr05.js";import"./shared-rh41v5ez.js";import"./shared-n0fpkmn8.js";import"./shared-stdj6se1.js";import"./shared-2by923ar.js";import"./shared-nbaaegmc.js";import"./shared-jxkrk6hx.js";import"./shared-4wqe6a27.js";import"./shared-xyqvjc3m.js";export{ue as parseSections};
|
package/parse.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{pe}from"./shared-shxvsq2a.js";import"./shared-v0nj05q2.js";import"./shared-vjpq32kx.js";import"./shared-c9gzmr05.js";import"./shared-rh41v5ez.js";import"./shared-n0fpkmn8.js";import"./shared-stdj6se1.js";import"./shared-nbaaegmc.js";import"./shared-jxkrk6hx.js";import"./shared-4wqe6a27.js";import"./shared-xyqvjc3m.js";export{pe as parse};
|
package/runes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import"./shared-stdj6se1.js";import{w,i,t}from"./shared-nbaaegmc.js";import{a,R,O}from"./shared-2by923ar.js";import"./shared-4wqe6a27.js";import"./shared-xyqvjc3m.js";import"./shared-jxkrk6hx.js";import"./shared-n0fpkmn8.js";import"./shared-rh41v5ez.js";import"./shared-c9gzmr05.js";import{pe}from"./shared-shxvsq2a.js";import{ue}from"./shared-3371ehgf.js";import{p,I,j,y,L}from"./shared-4zk9ntab.js";import{W,P}from"./shared-znzncsf2.js";import{se}from"./shared-n1wnwhk8.js";import"./shared-v0nj05q2.js";import"./shared-vjpq32kx.js";var S=/(?<![\w$])(?:\$(?:state|derived|props|bindable|effect|inspect|host)(?![\w$])|await(?![\w$]))|\\u/g,N=/^\{\s*(true|false)\s*\}$/;function ee(e){let c=se(e),l=c.options?.attributes.find((h)=>h.name==="runes"),r=l&&M(l);if(r!==void 0)return r;let n=w(e),s=[c.instance,c.module].flatMap((h)=>h?[h.content]:[]),u=!1,f=!1,o=!0;S.lastIndex=0;for(let h=S.exec(n);h!==null&&!(f&&!o);h=S.exec(n)){let b=h.index;u=!0,o&&=h[0]==="await",f||=!s.some(({start:C,end:D})=>b>=C&&b<D)}if(!u)return!1;if(!o&&l===void 0&&!n.includes("\\u")&&k(n,s))return!0;let m={css:!1,comments:!1},d=f?pe(e,m):ue(e,m);if(d.options?.runes!==void 0)return d.options.runes;if(o)return d.instance!==void 0&&g(d.instance.content)||g(d.fragment);return U(d)}function g(e){let c=!1;return L(e,{enter(l){if(x(l))return y;if(l.type!=="AwaitExpression")return;return c=!0,j}}),c}function M(e){if(e.value===!0)return!0;let c=N.exec(e.value);return c?c[1]==="true":void 0}var F=new Map([...P].map((e)=>[e,new RegExp(`(?<![\\w$.])${e.slice(1)}(?![\\w$])`)])),T=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 k(e,c){let l=new Map;for(let{start:r,end:n}of c){let s=e.slice(0,n);if(R(s,r,(f,o)=>{if(s.charCodeAt(f)!==36)return!1;let m=s.slice(f,o);if(P.has(m)&&l.get(m)!==!1)l.set(m,_(s,f,o));return!1})!==s.length)return!1}for(let[r,n]of l)if(n&&!F.get(r)?.test(e))return!0;return!1}function _(e,c,l){let r=c-1;while(r>=0&&i(e.charCodeAt(r)))r--;let n=e.charCodeAt(r);if(n===35||n===42||n===46||n===58||n===60||n===64)return!1;if(a(n)){let o=r;while(o>0&&a(e.charCodeAt(o-1)))o--;if(T.has(e.slice(o,r+1)))return!1}let s=t(e,l);while(e.charCodeAt(s)===46){let o=t(e,s+1),m=O(e,o);if(m===o)return!1;s=t(e,m)}if(e.charCodeAt(s)===60){if(s=B(e,s),s===-1)return!1;s=t(e,s)}if(e.charCodeAt(s)!==40)return!1;let u=R(e,s+1);if(e.charCodeAt(u)!==41)return!1;let f=e.charCodeAt(t(e,u+1));return f!==123&&f!==58}function B(e,c){let l=0,r=Math.min(e.length,c+2000);for(let n=c;n<r;n++){let s=e.charCodeAt(n);if(s===34||s===39||s===96||s===47)return-1;if(s===60)l++;else if(s===62&&e.charCodeAt(n-1)!==61){if(l--,l===0)return n+1}}return-1}function U(e){let c=e.module?.content,l=e.instance?.content,r=new Map;if(l)v(l,r,!0);let n=new Map;if(c)v(c,n,!1);for(let[f,o]of n)if(!r.has(f))r.set(f,o);let s=[],u=(f)=>{if(!s.includes(f))s.push(f)};if(c)A(c,n,u);if(l&&A(l,r,u))return!0;if(A(e.fragment,r,u))return!0;for(let f of s){let o=f.slice(1);if(!r.has(o))return!0;let m=r.get(o)??null,d=G(m,r);if(!((d===null||o!=="props"&&d==="$props")&&!(f==="$derived"&&m?.type==="ImportDeclaration"&&m.source.value==="svelte/store")))return!0;r.set(f,null)}return!1}function A(e,c,l){let r=[],n=new Map,s=(o)=>P.has(o)&&!c.has(o)&&!r.some((m)=>V(m,n).has(o)),u=0,f=!1;return L(e,{enter(o,m){if(x(o))u++;else if(o.type==="AwaitExpression")f||=u===0;let d;if(o.type==="Identifier"&&m&&!m.type.startsWith("TS")&&I(o,m))d=o.name;else if(o.type==="TransitionDirective"||o.type==="AnimateDirective"||o.type==="UseDirective")d=o.name.split(".")[0];else if(o.type==="StyleDirective"&&o.value===!0)d=o.name;if(d!==void 0&&s(d))l(d);r.push(o)},leave(o){if(r.pop(),x(o))u--}}),f}var E=new Set;function V(e,c){let l=c.get(e);if(l)return l;let r=[];if(x(e)){if(r.push(...e.params),e.type==="FunctionExpression"&&e.id)r.push(e.id)}else if(e.type==="CatchClause"&&e.param)r.push(e.param);else if(e.type==="SnippetBlock")r.push(...e.parameters??[]);else if(e.type==="EachBlock"&&e.context)r.push(e.context);if(r.length===0&&!x(e))return c.set(e,E),E;let n=new Set(r.flatMap((s)=>p(s)).map((s)=>s.name));if(x(e)){let{body:s}=e;L(s,{enter(u){if(u===s)return;if(u.type==="VariableDeclaration")for(let f of u.declarations)for(let o of p(f.id))n.add(o.name);else if((u.type==="FunctionDeclaration"||u.type==="ClassDeclaration")&&u.id)n.add(u.id.name);return x(u)?y:void 0}})}return c.set(e,n),n}function x(e){return e.type==="ArrowFunctionExpression"||e.type==="FunctionExpression"||e.type==="FunctionDeclaration"}function v(e,c,l){let r=[];L(e,{enter(n,s){if(x(n)&&n.type!=="FunctionDeclaration")return y;let u=s===e||s?.type==="ExportNamedDeclaration"||s?.type==="ExportDefaultDeclaration";if(n.type==="ImportDeclaration"){for(let f of n.specifiers)c.set(f.local.name,n);return y}if(n.type==="FunctionDeclaration"||n.type==="ClassDeclaration"){if(u&&n.id)c.set(n.id.name,n);return y}if(n.type==="VariableDeclaration"){if(n.kind!=="var"&&!u)return y;for(let f of n.declarations)for(let o of p(f.id))c.set(o.name,u?f.init??null:null);return y}if(l&&s===e&&n.type==="LabeledStatement"&&n.label.name==="$"&&n.body.type==="ExpressionStatement"&&n.body.expression.type==="AssignmentExpression"){for(let f of p(n.body.expression.left))if(!f.name.startsWith("$"))r.push(f)}return}});for(let n of r)if(!c.has(n.name))c.set(n.name,null)}function G(e,c){if(e?.type!=="CallExpression")return null;let l=e.callee,r="";while(l.type==="MemberExpression"){if(l.computed||l.property.type!=="Identifier")return null;r=`.${l.property.name}${r}`,l=l.object}if(l.type==="CallExpression"&&l.callee.type==="Identifier")r=`()${r}`,l=l.callee;if(l.type!=="Identifier"||c.has(l.name))return null;return r=l.name+r,W.has(r)?r:null}export{ee as isRunesMode};
|