sveld 0.37.2 → 0.37.3
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 +399 -4
- package/lib/browser.d.ts +90 -21
- package/lib/browser.js +134 -130
- package/lib/chunk-ag202nwj.js +317 -0
- package/lib/{chunk-z1dy5a6k.js → chunk-m2bfvdte.js} +9 -9
- package/lib/chunk-n14td14g.js +1 -0
- package/lib/chunk-s4f6b34h.js +6 -0
- package/lib/chunk-te52wx32.js +1 -0
- package/lib/chunk-v4be4g6y.js +6 -0
- package/lib/cli-entry.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/lib/chunk-0mgphvte.js +0 -6
- package/lib/chunk-fc72j0vd.js +0 -1
- package/lib/chunk-fj7dbych.js +0 -1
- package/lib/chunk-szfpvrdq.js +0 -6
- package/lib/chunk-xt4vdey6.js +0 -301
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i}from"./chunk-v4be4g6y.js";export{i as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{e}from"./chunk-ag202nwj.js";import{existsSync as N,readdirSync as O,readFileSync as D,statSync as j}from"node:fs";import{createRequire as M}from"node:module";import f from"node:path";var F="__sveld_resolved_props__",k="__SveldResolvedProps__",L=/ \| undefined$/,G=/[^A-Za-z0-9_-]/g,U=/[^A-Za-z0-9_$]/g,B=/^[0-9]/,q=2,I=7,E=`TypeScript ${I} or later, which provides \`typescript/unstable/async\``;function z(t){if(!t)return!1;let n=Number.parseInt(t,10);return Number.isFinite(n)&&n>=I}async function X(t){let n;try{let i=M(f.join(t,"package.json")).resolve("typescript/package.json");n=JSON.parse(D(i,"utf8")).version}catch{return{installed:!1}}if(!z(n))return{installed:!0,version:n};try{let s=await import("./chunk-m2bfvdte.js");return{installed:!0,version:n,module:s}}catch{return{installed:!0,version:n}}}class A{api;symbolFlags;typeFlags;tsconfigPath;cwd;overlay=new Map;pendingOverlayDeletions=new Set;constructor(t,n,s,i,o){this.api=t,this.symbolFlags=n,this.typeFlags=s,this.tsconfigPath=i,this.cwd=o}static async create(t=process.cwd(),{importTs:n=X}={}){let s=await n(t);if(!s.installed)return{ok:!1,reason:"not-installed",message:`requires the \`typescript\` package to be installed (${E}); none was found`};if(!s.module)return{ok:!1,reason:"unsupported-version",message:`requires ${E}; found \`typescript@${s.version??"unknown"}\` installed, which does not expose that module`};let i=Q(t);if(!i)return{ok:!1,reason:"no-tsconfig",message:`could not locate a tsconfig.json starting from "${t}"`};let o=s.module,r=new A(null,o.SymbolFlags,o.TypeFlags,i,t),a=new o.API({cwd:t,fs:r.createFileSystem()});return r.api=a,{ok:!0,resolver:r}}async expandAll(t){let n=new Map;if(t.length===0)return n;let s=new Map;for(let o of t){if(!o.metadata.canonicalPropsType)continue;if(o.metadata.referencesComponentGenerics)continue;let r=this.virtualFileName(o.filePath,o.moduleName);this.overlay.set(r,V(o.metadata)),s.set(r,o)}if(s.size===0)return n;let i=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:Array.from(s.keys())}});try{let[o]=s.keys(),r=await i.getDefaultProjectForFile(o);if(!r)return n;let a=r.checker,y=await Promise.all(Array.from(s,async([c,u])=>{let p=this.overlay.get(c);if(!p)return null;let d=Z(p),l=await a.getTypeAtPosition(c,d);if(!l)return null;let m=new Map,b=await a.getPropertiesOfType(l);for(let v of b){if(!v.name||v.name.startsWith("__"))continue;m.set(v.name,{name:v.name,symbols:[v],forceOptional:!1})}if((l.flags&this.typeFlags.Union)!==0){let v=await l.getTypes(),C=await Promise.all(v.map((R)=>a.getPropertiesOfType(R)));for(let R of C)for(let T of R){if(!T.name||T.name.startsWith("__")||m.has(T.name))continue;let w=m.get(T.name);if(w)w.symbols.push(T);else m.set(T.name,{name:T.name,symbols:[T],forceOptional:!0})}}return{filePath:u.filePath,groups:Array.from(m.values())}})),g=[],P=[];y.forEach((c,u)=>{if(!c)return;c.groups.forEach((p,d)=>{for(let l of p.symbols)g.push(l),P.push({fileIndex:u,groupIndex:d})})});let S=g.length>0?await a.getTypeOfSymbol(g):[],x=await Promise.all(S.map((c)=>c?a.typeToString(c):Promise.resolve("any"))),h=new Map;g.forEach((c,u)=>{let{fileIndex:p,groupIndex:d}=P[u],l=(c.flags&this.symbolFlags.Optional)!==0,m=x[u];if(l)m=m.replace(L,"");let b=h.get(p)??new Map,_=b.get(d)??[];_.push(m),b.set(d,_),h.set(p,b)}),y.forEach((c,u)=>{if(!c)return;let p=h.get(u),d=c.groups.map((l,m)=>{let b=p?.get(m)??[],_=!(l.forceOptional||l.symbols.some((v)=>(v.flags&this.symbolFlags.Optional)!==0));return{name:l.name,type:Array.from(new Set(b)).join(" | "),isRequired:_}});d.sort((l,m)=>l.name.localeCompare(m.name)),n.set(c.filePath,d)})}finally{await i.dispose?.()}return n}async checkExamples(t){let n=new Map;if(t.length===0)return n;let s=[];for(let o of t)for(let r of o.sources){let a=this.exampleFileName(o.filePath,o.moduleName,r.id);this.overlay.set(a,H(r)),s.push({filePath:o.filePath,source:r,file:a})}if(s.length===0)return n;let i=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:s.map((o)=>o.file)}});try{let[o]=s,r=await i.getDefaultProjectForFile(o.file);if(!r)return n;await Promise.all(s.map(async({filePath:a,source:y,file:g})=>{let[P,S]=await Promise.all([r.program.getSyntacticDiagnostics(g),r.program.getSemanticDiagnostics(g)]),x=[...P,...S];if(x.length===0)return;let h=this.overlay.get(g)??"",c=x.map((p)=>J(p,h)).sort((p,d)=>p.line-d.line).map((p)=>`Line ${p.line}: ${p.text}`).join(`
|
|
2
|
+
`),u=n.get(a)??[];u.push({id:y.id,name:y.name,message:c}),n.set(a,u)}))}finally{await i.dispose?.()}return n}forgetOverlayFiles(t){for(let n of t)if(this.overlay.delete(n))this.pendingOverlayDeletions.add(n)}async openBareTypeSession(t){for(let[r,a]of t)this.overlay.set(r,a);let n=Array.from(this.pendingOverlayDeletions).filter((r)=>!t.has(r));this.pendingOverlayDeletions.clear();let s=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:Array.from(t.keys()),deleted:n}}),i=`${e(f.join(this.cwd,"node_modules"))}/`;return{resolveAt:async(r,a)=>{let y=await s.getDefaultProjectForFile(r);if(!y)return{kind:"unresolved"};let g=y.checker,P=await g.getSymbolAtPosition(r,a);if(!P)return{kind:"unresolved"};let S=await g.getAliasedSymbol(P);if(await g.isUnknownSymbol(S))return{kind:"unresolved"};let x=S.declarations??[];if(x.length===0)return{kind:"unresolved"};let h=await Promise.all(x.map((l)=>l.resolve())),c=h.findIndex((l)=>l&&e(l.getSourceFile().fileName).startsWith(i)),u=c===-1?h.findIndex((l)=>l!==void 0):c,p=u===-1?void 0:h[u];if(!p)return{kind:"unresolved"};let d=p.getSourceFile();if(await y.program.isSourceFileDefaultLibrary(d))return{kind:"default-lib"};return{kind:"resolved",filePath:d.fileName,declaredName:S.name}},dispose:()=>s.dispose?.()??Promise.resolve()}}async dispose(){this.overlay.clear(),await this.api?.close?.()}createFileSystem(){return{readFile:(t)=>this.overlay.get(e(t)),fileExists:(t)=>this.overlay.has(e(t))?!0:void 0,getAccessibleEntries:(t)=>{let n=e(t),s=Array.from(this.overlay.keys()).filter((r)=>e(f.dirname(r))===n);if(s.length===0)return;let i=[],o=[];try{for(let r of O(t)){let a=f.join(t,r);try{(j(a).isDirectory()?o:i).push(r)}catch{}}}catch{}for(let r of s){let a=f.basename(r);if(!i.includes(a))i.push(a)}return{files:i,directories:o}}}}virtualFileName(t,n){let s=f.dirname(f.resolve(t));return e(f.join(s,`__sveld_resolved_${n}.ts`))}exampleFileName(t,n,s){let i=f.dirname(f.resolve(t)),o=s.replace(G,"_");return e(f.join(i,`__sveld_example_${n}_${o}.ts`))}}function V(t){return[...t.typeImportStatements,...t.localTypeDeclarations,`type ${k} = ${t.canonicalPropsType};`,`declare const ${F}: ${k};`].join(`
|
|
3
|
+
`)}function W(t){let n=t.replace(U,"_");if(n===""||B.test(n))return`_${n}`;return n}function H(t){return`const ${W(t.name)} = null as unknown as (${t.type});
|
|
4
|
+
${t.code}
|
|
5
|
+
`}function J(t,n){let s=t.pos??0,i=n.slice(0,s).split(`
|
|
6
|
+
`).length;return{line:Math.max(1,i-q+1),text:String(t.text??"").trim()}}function Z(t){let n=t.lastIndexOf("declare const");return t.indexOf(F,n)+2}function Q(t){let n=f.resolve(t);while(!0){let s=f.join(n,"tsconfig.json");if(N(s))return s;let i=f.dirname(n);if(i===n)return null;n=i}}export{A as TypeResolver};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{T,A}from"./chunk-ag202nwj.js";export{T as TemplateParseNotImplementedError,A as parse};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{se,l,s,ie,p,f,oe,g,B,n,d,U,t,r,u,R,m,ce,ue,pe,z,h,le,X,fe,de,x,me,c,P,he,Q,ye,ge,xe,Y,Te,L,Z,K,O,y,Ee,be,ee,v,A}from"./chunk-ag202nwj.js";var lt={a:"HTMLAnchorElement",abbr:"HTMLElement",address:"HTMLElement",applet:"HTMLUnknownElement",area:"HTMLAreaElement",article:"HTMLElement",aside:"HTMLElement",audio:"HTMLAudioElement",b:"HTMLElement",base:"HTMLBaseElement",basefont:"HTMLElement",bdi:"HTMLElement",bdo:"HTMLElement",blockquote:"HTMLQuoteElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",cite:"HTMLElement",code:"HTMLElement",col:"HTMLTableColElement",colgroup:"HTMLTableColElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",dd:"HTMLElement",del:"HTMLModElement",details:"HTMLDetailsElement",dfn:"HTMLElement",dialog:"HTMLDialogElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",dt:"HTMLElement",em:"HTMLElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",figcaption:"HTMLElement",figure:"HTMLElement",font:"HTMLFontElement",footer:"HTMLElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",h2:"HTMLHeadingElement",h3:"HTMLHeadingElement",h4:"HTMLHeadingElement",h5:"HTMLHeadingElement",h6:"HTMLHeadingElement",head:"HTMLHeadElement",header:"HTMLElement",hgroup:"HTMLElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",i:"HTMLElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",ins:"HTMLModElement",kbd:"HTMLElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",main:"HTMLElement",map:"HTMLMapElement",mark:"HTMLElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",nav:"HTMLElement",noscript:"HTMLElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",picture:"HTMLPictureElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",rp:"HTMLElement",rt:"HTMLElement",ruby:"HTMLElement",s:"HTMLElement",samp:"HTMLElement",script:"HTMLScriptElement",search:"HTMLElement",section:"HTMLElement",select:"HTMLSelectElement",slot:"HTMLSlotElement",small:"HTMLElement",source:"HTMLSourceElement",span:"HTMLSpanElement",strong:"HTMLElement",style:"HTMLStyleElement",sub:"HTMLElement",summary:"HTMLElement",sup:"HTMLElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",td:"HTMLTableCellElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",tfoot:"HTMLTableSectionElement",th:"HTMLTableCellElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",u:"HTMLElement",ul:"HTMLUListElement",var:"HTMLElement",video:"HTMLVideoElement",wbr:"HTMLElement"};function _t(e){return e in lt}function dt(e){if(_t(e))return lt[e];return"HTMLElement"}function nt(){return{syntaxMode:"legacy",scriptLanguage:void 0,source:void 0,parsed:void 0,runesOptionOverride:void 0,sourceLineStartOffsetsCache:void 0,sourceLineHint:void 0,parsedJsDocByText:new Map,jsDocBlocksByStart:new Map,rest_props:void 0,extends:void 0,customElementTag:void 0,customElement:void 0,componentComment:void 0,componentCommentSource:void 0,generics:null,scriptGenericsAttribute:void 0,diagnosticRecords:[],componentFilePath:"",props:new Map,moduleExports:new Map,propLocalToPublicName:new Map,reactive_vars:new Set,funcDecls:new Map,vars:new Set,valueImportBindingsByLocalName:new Map,pendingCallDefaultCandidates:[],pendingContextKeyCandidates:[],runesPropsDeclarationMetadataByDeclaratorStart:new Map,typedRunesPropsDeclarations:[],explicitPropTypesByName:new Map,explicitVariableTypesByName:new Map,typeImportBindingsByLocalName:new Map,localTypeDeclarationsByName:new Map,additionalTypeDependencyNodes:[],wholePropsLocals:new Set,restPropLocals:new Set,componentScope:new Map,scopeDeclarations:new Map,activeScopes:[],slots:new Map,snippetPropLocals:new Set,cssParts:[],cssProperties:[],deferredSlotBlockGenerics:[],events:new Map,eventDescriptions:new Map,forwardedEvents:new Map,jsDocEventNames:new Set,jsDocEventSources:new Map,bindings:new Map,contexts:new Map,typedefs:new Map,variableInfoCache:new Map,variableInfoCacheBuilt:!1,sveldIgnoreDirectives:new Map}}var Ht=new Set(["Component","SvelteComponent","SvelteSelf"]),Ft=new Set(["RegularElement","SvelteElement"]);function Ve(e){return Ht.has(e)}function Oe(e){return Ft.has(e)}function jt({hasTypeScriptType:e,hasJSDocType:o,inferredType:a,finalType:b}){if(e)return"typescript";if(o)return"jsdoc";if(a!==void 0)return"default";if(b!==void 0)return"inferred";return"unknown"}function $e(e){let o=e.explicitType??e.jsdocType??e.resolvedType??e.typeSeed,a=e.jsdocParams??e.resolvedParams,b=e.jsdocReturnType??e.resolvedReturnType;if(e.isFunctionDeclaration&&o==="() => any"&&b)o=a&&a.length>0?`(${a.map((E)=>`${E.name}${E.optional?"?":""}: ${E.type}`).join(", ")}) => ${b}`:`() => ${b}`;let S=e.jsdocDescription??e.resolvedDescription;if(S===void 0&&o!==void 0)S=e.typedefs?.get(o)?.description;let M=jt({hasTypeScriptType:e.explicitType!==void 0,hasJSDocType:e.jsdocType!==void 0||e.jsdocParams!==void 0||e.jsdocReturnType!==void 0||e.resolvedType!==void 0,inferredType:e.inferredTypeForSource,finalType:o}),C=e.initializerIsFunction||e.isFunctionDeclaration||e.inferIsFunctionFromTypeSignature===!0&&(!!e.jsdocParams?.length||e.jsdocReturnType!==void 0||!!e.jsdocType?.includes("=>")||!!e.resolvedType?.includes("=>")||!!e.explicitType?.includes("=>"));return{type:o,typeSource:M,description:S,params:a,returnType:b,isFunction:C}}function Bt(e){if(!e||typeof e!=="object"||!("type"in e))return;let o=String(e.type),a=Ve(o);if(!a&&!Oe(o))return;let b="name"in e&&typeof e.name==="string"?e.name:void 0;if(!b)return;let S=a?{type:"InlineComponent",name:b}:{type:"Element",name:b};if(b==="svelte:element"&&"tag"in e&&e.tag&&typeof e.tag==="object"){let M=e.tag;if(M.type==="Literal"&&typeof M.value==="string")S.thisValue=M.value}return S}function ut(e,o){let a=Bt(o);if(!a)return;if(e.rest_props===void 0){e.rest_props=a;return}if(e.rest_props.type==="InlineComponent"&&a.type==="Element")e.rest_props=a}function De(e,o,a){if(!o||e.has(o))return;e.set(o,a)}function Ge(e,o){for(let a=e.activeScopes.length-1;a>=0;a-=1){let b=e.activeScopes[a]?.get(o);if(!b)continue;return b.kind==="prop"?b.publicPropName:void 0}return}function ve(e,o=new Set){if(!e||typeof e!=="object"||!("type"in e))return o;switch(e.type){case"Identifier":o.add(e.name);break;case"AssignmentPattern":ve(e.left,o);break;case"ArrayPattern":for(let a of e.elements)ve(a??void 0,o);break;case"ObjectPattern":for(let a of e.properties)if(a.type==="Property")ve(a.value,o);else if(a.type==="RestElement")ve(a.argument,o);break;case"RestElement":ve(e.argument,o);break}return o}function ot(e,o){if(!o||typeof o!=="object"||!("type"in o))return;if(o.type==="Identifier"){let b=Ge(e,o.name);if(b)e.reactive_vars.add(b);return}let a=ve(o);for(let b of a){let S=Ge(e,b);if(S)e.reactive_vars.add(S)}}function Je(e){if(!e||typeof e!=="object"||!("type"in e))return!1;switch(String(e.type)){case"BlockStatement":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"EachBlock":case"AwaitBlock":return!0;default:return!1}}function mt(e){if(!e||typeof e!=="object"||!("type"in e))return!1;let o=String(e.type);return o==="FunctionDeclaration"||o==="FunctionExpression"||o==="ArrowFunctionExpression"}function Vt(e,o){let a=e.scopeDeclarations.get(o);if(!a)a=new Map,e.scopeDeclarations.set(o,a);return a}function Ot(e,o,a){let b=[];if(a.id.type==="Identifier")return b.push({kind:"local",name:a.id.name}),b;if(a.id.type!=="ObjectPattern")return b;for(let S of a.id.properties){if(S.type==="RestElement"){if(S.argument.type==="Identifier")b.push({kind:"local",name:S.argument.name});continue}if(S.computed)continue;let M=e.getPropertyName(S.key);if(!M)continue;let C;if(S.value.type==="Identifier")C=S.value.name;else if(S.value.type==="AssignmentPattern"&&S.value.left.type==="Identifier")C=S.value.left.name;if(!C)continue;b.push({kind:"prop",name:C,publicPropName:M})}return b}function rt(e,o,a,b,S){if(!se(o))return;let M=S?.allowRunesProps??!1,C=S?.forceProp??!1,E=o;for(let k of E.declarations){if(M&&p(f(k.init),"$props")){for(let q of Ot(e,E,k))De(q.kind==="prop"?a:b,q.name,q.kind==="prop"?{kind:"prop",publicPropName:q.publicPropName}:{kind:"local"});continue}let G=E.kind==="var"?b:a,j=C?"prop":"local";for(let q of ve(k.id))De(G,q,j==="prop"?{kind:"prop",publicPropName:q}:{kind:"local"})}}function $t(e,o){if("id"in e&&e.id&&typeof e.id==="object"&&"name"in e.id&&typeof e.id.name==="string")De(o,e.id.name,{kind:"local"});for(let a of e.params)for(let b of ve(a))De(o,b,{kind:"local"})}function Gt(e,o,a,b){if(!Array.isArray(o))return;for(let S of o){if(!S||typeof S!=="object"||!("type"in S))continue;switch(S.type){case"VariableDeclaration":rt(e,S,a,b);break;case"FunctionDeclaration":if(S.id?.name)De(a,S.id.name,{kind:"local"});break;case"ClassDeclaration":if(S.id?.name)De(a,S.id.name,{kind:"local"});break}}}function Jt(e,o,a){if(!a||typeof a!=="object")return;let b="content"in a&&a.content&&typeof a.content==="object"&&"body"in a.content&&Array.isArray(a.content.body)?a.content:("body"in a)&&Array.isArray(a.body)?a:void 0;if(!b||!("body"in b)||!Array.isArray(b.body))return;for(let S of b.body){if(!S||typeof S!=="object"||!("type"in S))continue;switch(S.type){case"ImportDeclaration":for(let M of S.specifiers??[])if(M.local?.name)De(o.componentScope,M.local.name,{kind:"local"});break;case"VariableDeclaration":rt(e,S,o.componentScope,o.componentScope,{allowRunesProps:!0});break;case"FunctionDeclaration":if(S.id?.name)De(o.componentScope,S.id.name,{kind:"local"});break;case"ClassDeclaration":if(S.id?.name)De(o.componentScope,S.id.name,{kind:"local"});break;case"ExportNamedDeclaration":if(!S.declaration||typeof S.declaration!=="object"||!("type"in S.declaration))break;if(S.declaration.type==="VariableDeclaration")rt(e,S.declaration,o.componentScope,o.componentScope,{forceProp:!0});else if(S.declaration.type==="FunctionDeclaration"&&S.declaration.id?.name)De(o.componentScope,S.declaration.id.name,{kind:"prop",publicPropName:S.declaration.id.name});break}}}function ft(e,o){o.componentScope.clear(),o.scopeDeclarations=new Map,o.activeScopes.length=0,Jt(e,o,o.parsed?.instance)}function yt(e){return{varScopeStack:[e.componentScope]}}function gt(e,o,a,b){if(!Je(b))return;let S=Vt(o,b),M=a.varScopeStack[a.varScopeStack.length-1]??o.componentScope;switch(String(b.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":$t(b,S);break;case"BlockStatement":Gt(e,b.body,S,M);break;case"CatchClause":if("param"in b)for(let E of ve(b.param))De(S,E,{kind:"local"});break;case"EachBlock":{let E=b;for(let k of ve(E.context))De(S,k,{kind:"local"});if(typeof E.index==="string")De(S,E.index,{kind:"local"});else if(E.index&&"name"in E.index)De(S,E.index.name,{kind:"local"});break}case"AwaitBlock":{let E=b;for(let k of ve(E.value))De(S,k,{kind:"local"});for(let k of ve(E.error))De(S,k,{kind:"local"});break}}if(mt(b))a.varScopeStack.push(S);return S}function bt(e,o){if(mt(o))e.varScopeStack.pop()}var ht=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]);function Kt(e,o){switch(o?.type){case"MemberExpression":return o.computed||e===o.object;case"MethodDefinition":return!!o.computed;case"MetaProperty":return e===o.meta;case"PropertyDefinition":return o.computed||e===o.value;case"Property":return o.computed||e===o.value;case"ExportSpecifier":case"ImportSpecifier":return e===o.local;case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return!1;default:return!0}}var zt=Array.from(ht);function Tt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Wt(e){if(e.includes("\\u"))return!0;for(let o of zt){let a=e.indexOf(o);while(a!==-1){if(!Tt(e.charCodeAt(a-1))&&!Tt(e.charCodeAt(a+o.length)))return!0;a=e.indexOf(o,a+1)}}return!1}function Xt(e,o){for(let a=o.length-1;a>=0;a-=1)if(o[a]?.has(e))return!0;return!1}function Ut(e){let o=new Set;if(!e||typeof e!=="object"||!("type"in e))return o;switch(String(e.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":{let a=e;if(a.id?.name)o.add(a.id.name);for(let b of a.params??[])ve(b,o);break}case"BlockStatement":Ye(e.body,o);break;case"CatchClause":ve(e.param,o);break;case"EachBlock":{let a=e;if(ve(a.context,o),typeof a.index==="string")o.add(a.index);else if(a.index?.name)o.add(a.index.name);break}case"AwaitBlock":{let a=e;ve(a.value,o),ve(a.error,o);break}}return o}function Ye(e,o){if(!Array.isArray(e))return;for(let a of e){if(!a||typeof a!=="object"||!("type"in a))continue;switch(String(a.type)){case"ImportDeclaration":for(let b of a.specifiers??[])if(b.local?.name)o.add(b.local.name);break;case"VariableDeclaration":for(let b of a.declarations??[])ve(b.id,o);break;case"FunctionDeclaration":case"ClassDeclaration":{let b=a.id?.name;if(b)o.add(b);break}case"ExportNamedDeclaration":{let b=a.declaration;if(b&&typeof b==="object"&&"type"in b)Ye([b],o);break}}}}function it(e,o){if(!e||typeof e!=="object")return!1;return at(e,void 0,[...o])}function at(e,o,a){if(ee(e.type))return!1;let b=Je(e);if(b)a.push(Ut(e));let S=!1;if(o&&e.type==="Identifier"&&e.name!==void 0&&ht.has(e.name)&&!o.type.startsWith("TS")&&Kt(e,o)&&!Xt(e.name,a))S=!0;else for(let M in e){if(M==="leadingComments")continue;let C=e[M];if(!C||typeof C!=="object")continue;if(Array.isArray(C)){for(let E=0;E<C.length;E++){let k=C[E];if(k&&typeof k==="object"&&typeof k.type==="string"){if(at(k,e,a)){S=!0;break}}}if(S)break}else if(typeof C.type==="string"){if(at(C,e,a)){S=!0;break}}}if(b)a.pop();return S}function xt(e){if(!e||typeof e!=="object")return;if("content"in e){let o=e.content,a=o&&typeof o==="object"&&"body"in o?o.body:void 0;if(Array.isArray(a))return a}if("body"in e&&Array.isArray(e.body))return e.body;return}function St(e){if(e.runesOptionOverride!==void 0)return e.runesOptionOverride?"runes":"legacy";let o=e.parsed;if(!o)return"legacy";if(e.source!==void 0&&!Wt(e.source))return"legacy";let a=new Set;Ye(xt(o.module),a);let b=new Set;return Ye(xt(o.instance),b),it(o.module,[a])||it(o.instance,[a,b])||it(o.fragment,[a,b])?"runes":"legacy"}var qt=/[A-Za-z_$][\w$]*/g;function Yt(e,o,a){let b=new Map,S=o.typeParameters?.params,M=a.typeArguments?.params;if(!S?.length||!M?.length)return b;for(let C=0;C<S.length;C++){let E=S[C]?.name,k=M[C];if(!E||k?.start===void 0||k?.end===void 0)continue;let G=r(e,k.start,k.end)?.trim();if(G)b.set(E,G)}return b}function Qt(e,o){if(o.size===0)return e;return e.replace(qt,(a)=>o.get(a)??a)}function Ie(e,o,a,b,S=new Set){let M=new Map;if(!a?.type)return M;let C=(E)=>{for(let k of E){if(k?.type!=="TSPropertySignature"||k.computed)continue;if(!k.key)continue;let G=e.getPropertyName(k.key);if(!G)continue;let j=k.typeAnnotation?.start,q=k.typeAnnotation?.end;if(j===void 0||q===void 0)continue;let Pe=r(o,j+1,q)?.trim();if(!Pe)continue;P(o,k.typeAnnotation?.typeAnnotation),M.set(G,{type:Pe,optional:k.optional===!0,source:t(o,k)})}};switch(a.type){case"TSTypeLiteral":C(a.members??[]);break;case"TSInterfaceDeclaration":C(a.body?.body??[]);break;case"TSTypeAliasDeclaration":{let E=Ie(e,o,a.typeAnnotation,b,S);for(let[k,G]of E)M.set(k,G);break}case"TSTypeReference":{let E=de(a.typeName);if(!E||S.has(E))break;let k=b.get(E);if(!k)break;S.add(E);let G=Ie(e,o,k,b,S);S.delete(E);let j=Yt(o,k,a);for(let[q,Pe]of G)M.set(q,j.size===0?Pe:{...Pe,type:Qt(Pe.type,j)});break}case"TSIntersectionType":for(let E of a.types??[]){let k=Ie(e,o,E,b,S);for(let[G,j]of k)M.set(G,j)}break;case"TSParenthesizedType":{let E=Ie(e,o,a.typeAnnotation,b,S);for(let[k,G]of E)M.set(k,G);break}}return M}function Zt(e){let o={};for(let[a,b]of Object.entries(e))o[a]={...b.attribute===void 0?{}:{attribute:b.attribute},...b.reflect===void 0?{}:{reflect:b.reflect},...b.type===void 0?{}:{type:b.type}};return o}function Et(e,o,a){if(o.runesPropsDeclarationMetadataByDeclaratorStart.clear(),o.explicitPropTypesByName.clear(),o.explicitVariableTypesByName.clear(),o.typeImportBindingsByLocalName.clear(),o.localTypeDeclarationsByName.clear(),o.additionalTypeDependencyNodes.length=0,o.typedRunesPropsDeclarations.length=0,!o.source)return;let b=a;o.scriptLanguage=e.resolveScriptLanguage(b);let S=b.options?.customElement;o.customElementTag=S?.tag,o.customElement=S?{...S.tag===void 0?{}:{tag:S.tag},...S.shadow==="open"||S.shadow==="none"?{shadow:S.shadow}:{},...S.props?{props:Zt(S.props)}:{},...S.extend===void 0?{}:{extend:!0}}:void 0,o.runesOptionOverride=b.options?.runes,o.scriptGenericsAttribute=e.resolveScriptGenericsAttribute(b);let M=b.instance?.content?.body??[];for(let C of M){if(!C?.type)continue;if(C.type==="ImportDeclaration"&&C.source?.value)for(let E of C.specifiers??[]){let k=E.local?.name;if(!k)continue;if(!(C.importKind==="type"||E.importKind==="type"))continue;let j,q;if(E.type==="ImportSpecifier")j="named",q=E.imported?.type==="Identifier"?E.imported.name:typeof E.imported?.value==="string"?E.imported.value:void 0;else if(E.type==="ImportDefaultSpecifier")j="default";else if(E.type==="ImportNamespaceSpecifier")j="namespace";if(!j)continue;o.typeImportBindingsByLocalName.set(k,{importedName:q,localName:k,source:String(C.source.value),specifierType:j})}if((C.type==="TSInterfaceDeclaration"||C.type==="TSTypeAliasDeclaration")&&C.id?.name&&C.start!==void 0&&C.end!==void 0)o.localTypeDeclarationsByName.set(C.id.name,{code:r(o,C.start,C.end)?.trim()??"",node:C,start:C.start});if(C.type==="TSEnumDeclaration"&&C.id?.name&&C.start!==void 0&&C.end!==void 0)o.localTypeDeclarationsByName.set(C.id.name,{code:he(o,C)??"",node:C,start:C.start});if(C.type==="ExportNamedDeclaration"&&C.declaration?.type==="VariableDeclaration")for(let E of C.declaration.declarations??[]){if(E.id?.type!=="Identifier"||!E.id.name)continue;let k=x(o,E.id.typeAnnotation);if(k)o.explicitPropTypesByName.set(E.id.name,k),P(o,E.id.typeAnnotation?.typeAnnotation)}else if(C.type==="VariableDeclaration")for(let E of C.declarations??[]){if(E.id?.type!=="Identifier"||!E.id.name)continue;let k=x(o,E.id.typeAnnotation);if(k)o.explicitVariableTypesByName.set(E.id.name,k)}}for(let C of M){if(!C||typeof C!=="object"||!("declarations"in C))continue;for(let E of C.declarations??[]){if(!p(f(E.init),"$props"))continue;let k=E.id?.typeAnnotation?void 0:oe(E.init),G=E.id?.typeAnnotation?.typeAnnotation??k,j=E.id?.typeAnnotation?x(o,E.id.typeAnnotation):me(o,k),q=Ie(e,o,G,new Map(Array.from(o.localTypeDeclarationsByName.entries(),([Ce,_e])=>[Ce,_e.node]))),Pe=new Set,Me=new Set;if(c(o,G,Pe,Me),xe(o,Pe,Me),E.start!==void 0){let Ce={canonicalType:j,props:q,referencedImportedTypes:Pe,referencedLocalTypes:Me};if(o.runesPropsDeclarationMetadataByDeclaratorStart.set(E.start,Ce),j)o.typedRunesPropsDeclarations.push(Ce)}}}}function Pt(e,o,a){for(let b of a.declarations){if(!p(f(b.init),"$props"))continue;if(b.id.type==="Identifier"){o.wholePropsLocals.add(b.id.name),o.restPropLocals.add(b.id.name);let C=X(o,b.start);if(C)for(let[E,k]of C.props)R(e,o,E,{name:E,kind:"let",type:k.type,typeSource:"typescript",isFunction:!1,isFunctionDeclaration:!1,isRequired:!k.optional,constant:!1,reactive:!1,source:k.source});continue}if(b.id.type!=="ObjectPattern")continue;let S=y(o,e,a),M=b.id.properties.filter((C)=>{if(C.type!=="Property"||C.computed)return!1;if(!e.getPropertyName(C.key))return!1;if(C.value.type==="Identifier")return!0;return C.value.type==="AssignmentPattern"&&C.value.left.type==="Identifier"}).length;for(let C of b.id.properties){if(C.type==="RestElement"){if(C.argument.type==="Identifier")o.restPropLocals.add(C.argument.name);continue}let E=e.getPropertyName(C.key);if(!E)continue;let k,G;if(C.value.type==="Identifier")k=C.value.name;else{let T=C.value;k=T.left.name,G=T.right}if(!k)continue;if(e.trackPropLocalName(E,k),E==="children")o.snippetPropLocals.add(k);let j=Ee(o,e,C)??(M===1?S:void 0),q=fe(o,b.start,E),{init:Pe,bindable:Me}=ce(G),Ce=Pe==null?{isFunction:!1}:m(e,o,Pe),{value:_e,type:Re,isFunction:He,defaultValue:Fe}=Ce,Ke=q?.type===void 0&&j?.type===void 0?Ce.resolvedType:void 0;if(Ce.pendingCallDefault)o.pendingCallDefaultCandidates.push({propName:E,location:"props",...Ce.pendingCallDefault});let{type:je,typeSource:ze,description:We,params:Xe,returnType:Ue,isFunction:qe}=$e({explicitType:q?.type,typeSeed:Re,inferredTypeForSource:Re,jsdocType:j?.type,jsdocDescription:j?.description,jsdocParams:j?.params,jsdocReturnType:j?.returnType,resolvedType:Ke,resolvedDescription:Ce.resolvedDescription,resolvedParams:Ce.resolvedParams,resolvedReturnType:Ce.resolvedReturnType,initializerIsFunction:He,isFunctionDeclaration:!1,inferIsFunctionFromTypeSignature:!0});if(Me)o.reactive_vars.add(E);d(o,"prop-unknown-type",E,j?.sveldIgnore),R(e,o,E,{name:E,...k===E?{}:{localName:k},kind:"let",description:We,binding:j?.binding,deprecated:j?.deprecated,tags:j?.tags,...j?.internal?{internal:!0}:{},...Me?{bindable:!0}:{},type:je,typeSource:ze,value:_e,defaultValue:Fe,params:Xe,returnType:Ue,isFunction:qe,isFunctionDeclaration:!1,isRequired:!Me&&Pe==null&&q?.optional!==!0,constant:!1,reactive:Me,source:t(o,C)})}}}function en(e){let a=e.indexOf("EventDispatcher");if(a===-1)return;let b=a+15;while(e[b]===" ")b++;if(e[b]!=="<")return;let S=0,M=b;for(;b<e.length;b++)if(e[b]==="<")S++;else if(e[b]===">"){if(S--,S===0)return e.slice(M+1,b)}return}function tn(e){let o=[],a=0,b=0;for(let S=0;S<e.length;S++){let M=e[S];if(M==="{"||M==="("||M==="["||M==="<")a++;else if(M==="}"||M===")"||M==="]"||M===">")a=Math.max(a-1,0);else if(a===0&&(M===";"||M===","))o.push(e.slice(b,S)),b=S+1}return o.push(e.slice(b)),o.map((S)=>S.trim()).filter((S)=>S.length>0)}var nn=/^["']|["']$/g,rn=/\?$/,on=/^\{/,an=/\}$/;function sn(e){let o=0;for(let a=0;a<e.length;a++){let b=e[a];if(b==="{"||b==="("||b==="["||b==="<")o++;else if(b==="}"||b===")"||b==="]"||b===">")o=Math.max(o-1,0);else if(o===0&&b===":"){let S=e.slice(0,a).trim().replace(rn,"").replace(nn,""),M=e.slice(a+1).trim();if(!S||!M)return;return{name:S,type:M}}}return}function vt(e,o,a,b,S){if(a){let k=new Map(Array.from(o.localTypeDeclarationsByName.entries(),([j,q])=>[j,q.node])),G=Ie(e,o,a,k);for(let[j,q]of G)h(o,{name:j,detail:q.type,has_argument:!0,source:q.source});return}let M=e.resolveLocalVarJSDoc(b)?.type,C=M?en(M):void 0;if(!C)return;let E=C.trim().replace(on,"").replace(an,"");for(let k of tn(E)){let G=sn(k);if(!G)continue;h(o,{name:G.name,detail:G.type,has_argument:!0,source:S})}}function Ct(e,o){if(e.syntaxMode!=="runes")return;for(let[a,b]of Array.from(e.events.entries())){if(b.type!=="dispatched")continue;if(o.has(a)||e.forwardedEvents.has(a))continue;let S=`on${a}`,M=e.props.get(S);if(!M)continue;let C=M.type!==void 0||M.params!==void 0||M.returnType!==void 0,E=b.detail===void 0||b.detail==="undefined"||b.detail==="null"?"() => void":`(detail: ${b.detail}) => void`;e.props.set(S,{...M,description:M.description??b.description,type:C?M.type:E,typeSource:C?M.typeSource:"inferred",isFunction:!0}),e.events.delete(a)}}var Dt=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function st(e){return e!==null&&typeof e==="object"&&typeof e.type==="string"}function Mt(e){if(!Dt.has(e.type))return e;let o=e.expression;while(o&&Dt.has(o.type))o=o.expression;return o??e}function Qe(e){if(!st(e))return;ct(e)}function ct(e){for(let o in e){if(o==="leadingComments")continue;let a=e[o];if(!a||typeof a!=="object")continue;if(Array.isArray(a))for(let b=0;b<a.length;b++){let S=a[b];if(!st(S))continue;let M=Mt(S);if(M!==S)a[b]=M;ct(M)}else if(st(a)){let b=Mt(a);if(b!==a)e[o]=b;ct(b)}}}function Ze(e,o){let a=o.source?.value;if(typeof a!=="string"||o.importKind==="type")return;for(let b of o.specifiers??[]){if(b.type!=="ImportSpecifier"||b.importKind==="type")continue;let S=b.local?.name;if(!S)continue;let M=b.imported?.name??(typeof b.imported?.value==="string"?b.imported.value:S);e.valueImportBindingsByLocalName.set(S,{localName:S,importedName:M,source:a})}}function pt(e,o){if(!o)return;let a=o,b=a.type==="Program"?a.body:a.content?.body??a.body;if(!Array.isArray(b))return;for(let S of b){let M=S;if(M.type==="ImportDeclaration"){Ze(e,M);continue}let C=M.type==="ExportNamedDeclaration"&&M.declaration?M.declaration:M;if(C.type==="FunctionDeclaration"){let E=C;if(E.id?.name)e.funcDecls.set(E.id.name,E)}}}function cn(e,o,a,b,S){for(let M of e){if(M.type!=="Block"||M.start<a||M.end>b)continue;let C=o.slice(M.start,M.end);S.push({end:M.end,isJsDoc:C.startsWith("/**")&&C.length>4,text:C})}}function kt(e,o,a){if(!e||typeof e!=="object"||!("type"in e))return;let b=e;if(b.type==="FunctionDeclaration"){if(b.id?.type==="Identifier"&&b.id.name)a.push({name:b.id.name,start:o});return}if(b.type==="VariableDeclaration"){for(let S of b.declarations??[])if(S?.id?.type==="Identifier"&&S.id.name)a.push({name:S.id.name,start:o})}}function pn(e){let o=[];for(let a of e){if(!a||typeof a!=="object"||!("type"in a))continue;let b=a;if(b.start===void 0)continue;if(b.type==="ExportNamedDeclaration"&&b.declaration)kt(b.declaration,b.start,o);else kt(b,b.start,o)}return o}function ln(e,o,a){let b;for(let S of e){if(S.end>o)break;if(!S.isJsDoc)continue;if(!Z.test(a.slice(S.end,o)))continue;b=S}return b}function Nt(e,o){let a=new Map;if(!e.source)return a;let b=[e.parsed?.module,e.parsed?.instance],S=[],M=[],C=e.parsed?.comments??[];for(let E of b){let k=E?.content;if(!k?.body||k.start===void 0||k.end===void 0)continue;cn(C,e.source,k.start,k.end,S),M.push(...pn(k.body))}S.sort((E,k)=>E.end-k.end);for(let E of M){let k=ln(S,E.start,e.source);if(!k)continue;let G=K(e,k.text),{type:j,description:q,ignore:Pe,internal:Me}=O(G);if(Pe.length>0)d(e,"context-any-type",E.name,Pe);if(!j)continue;a.set(E.name,{type:o.aliasType(j.type),description:q||j.description,internal:Me||void 0})}return a}function Lt(e){if(e==="var")return"let";if(e==="using"||e==="await using")return"const";return e}var dn=null,wt=/^@component/,un=/\r/g,mn=/^\{\s*\}$/,fn=new Set(["AssignmentExpression","UpdateExpression","CallExpression","SpreadAttribute","FunctionDeclaration","ImportDeclaration","VariableDeclaration","ExportNamedDeclaration","Comment","SlotElement","RenderTag","OnDirective","BindDirective"]);class i{ctx=nt();static mapToArray(e){return Array.from(e,([o,a])=>a)}static getStaticAttributeValue(e){if(!Array.isArray(e.value))return;return e.value.map((o)=>o.data??o.raw??"").join("").trim()}resolveScriptLanguage(e){let o=[e.instance,e.module].filter((b)=>b!==void 0),a=!1;for(let b of o){let S=b.attributes?.find((C)=>C.name==="lang");if(!S){a=!0;continue}if(i.getStaticAttributeValue(S)?.toLowerCase()==="ts")return"ts"}return a?"js":void 0}resolveScriptGenericsAttribute(e){let o=e.instance?.attributes?.find((C)=>C.name==="generics");if(!o)return;let a=t(this.ctx,o),b=e.instance?.attributes?.find((C)=>C.name==="lang");if((b?i.getStaticAttributeValue(b)?.toLowerCase():void 0)!=="ts"){n(this.ctx,"syntax-skipped","generics",'<script generics="..."> requires lang="ts"; the generics attribute was ignored because the script is not TypeScript.',a);return}let M=i.getStaticAttributeValue(o);if(!M)return;return{value:M,source:a}}resolvePublicPropName(e){return this.ctx.propLocalToPublicName.get(e)??e}trackPropLocalName(e,o=e){this.ctx.propLocalToPublicName.set(o,e)}getPropByLocalOrPublic(e){return this.ctx.props.get(this.resolvePublicPropName(e))}getPropTypeByLocalOrPublic(e){return this.getPropByLocalOrPublic(e)?.type}getExplicitPropType(e){return this.ctx.explicitPropTypesByName.get(e)}getPropertyName(e){if(!e||typeof e!=="object"||!("type"in e))return;if(s(e))return e.name;if(l(e))return e.value==null?void 0:String(e.value);return}isNumericConstant(e){if(!e||typeof e!=="object"||!("type"in e))return!1;if(e.type!=="MemberExpression")return!1;let o=e,a=o.object&&"name"in o.object?o.object.name:void 0,b=o.property&&"name"in o.property?o.property.name:void 0;if(!a||!b)return!1;if(a==="Number")return["POSITIVE_INFINITY","NEGATIVE_INFINITY","MAX_VALUE","MIN_VALUE","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","EPSILON","NaN"].includes(b);if(a==="Math")return["PI","E","LN2","LN10","LOG2E","LOG10E","SQRT2","SQRT1_2"].includes(b);return!1}resolveLocalVarJSDoc(e){for(let a of this.ctx.vars)if(a.declarations.some((S)=>S.id&&typeof S.id==="object"&&("type"in S.id)&&S.id.type==="Identifier"&&("name"in S.id)&&S.id.name===e))return y(this.ctx,this,a);let o=this.ctx.funcDecls.get(e);if(o)return y(this.ctx,this,o);return}addModuleExport(e,o){if(u(e)===void 0)return;if(this.ctx.moduleExports.has(e)){let a=this.ctx.moduleExports.get(e);this.ctx.moduleExports.set(e,{...a,...o})}else this.ctx.moduleExports.set(e,o)}aliasType(e){if(e==="*")return"any";return e.trim()}findVariableTypeAndDescription(e){let o=this.getPropByLocalOrPublic(e);if(o?.type)return{type:o.type,description:o.description,internal:o.internal};if(!this.ctx.variableInfoCacheBuilt)this.ctx.variableInfoCache=Nt(this.ctx,this),this.ctx.variableInfoCacheBuilt=!0;let a=this.ctx.variableInfoCache.get(e),b=this.ctx.explicitVariableTypesByName.get(e);if(b)return{type:b,description:a?.description,internal:a?.internal};return a??null}accumulateGeneric(e,o){if(this.ctx.generics)this.ctx.generics=[`${this.ctx.generics[0]}, ${e}`,`${this.ctx.generics[1]}, ${o}`];else this.ctx.generics=[e,o]}cleanup(){this.ctx=nt()}static SCRIPT_BLOCK_REGEX=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi;static TS_DIRECTIVE_REGEX=/\/\/\s*@ts-[^\n\r]*/g;static stripTypeScriptDirectivesFromScripts(e){if(!e.includes("@ts-"))return e;return i.SCRIPT_BLOCK_REGEX.lastIndex=0,e.replace(i.SCRIPT_BLOCK_REGEX,(o,a,b,S)=>{i.TS_DIRECTIVE_REGEX.lastIndex=0;let M=b.replace(i.TS_DIRECTIVE_REGEX,"");return a+M+S})}parseSvelteComponent(e,o){this.cleanup(),this.ctx.componentFilePath=o.filePath;let a=i.stripTypeScriptDirectivesFromScripts(e);this.ctx.source=a;let b=A(a);if(Et(this,this.ctx,b),this.ctx.parsed=b,this.ctx.scriptLanguage==="ts")Qe(this.ctx.parsed.module),Qe(this.ctx.parsed.instance),Qe(this.ctx.parsed.fragment);this.ctx.syntaxMode=St(this.ctx);let S=this.ctx.parsed.css,M=S?.start!==void 0&&S?.end!==void 0?a.slice(0,S.start)+" ".repeat(S.end-S.start)+a.slice(S.end):a;pt(this.ctx,this.ctx.parsed?.module),pt(this.ctx,this.ctx.parsed?.instance),be(this.ctx,this,M);let C={type:"ComponentRoot",instance:this.ctx.parsed.instance,fragment:this.ctx.parsed.fragment};if(this.ctx.parsed?.module)v(this.ctx.parsed?.module,(T)=>{if(T.type==="ImportDeclaration")Ze(this.ctx,T);if(T.type==="FunctionDeclaration"){let D=T;if(D.id?.name)this.ctx.funcDecls.set(D.id.name,D)}if(T.type==="VariableDeclaration")this.ctx.vars.add(T);if(T.type==="ExportNamedDeclaration"){if(T.declaration==null&&T.specifiers.length===0)return;let D,w=!1;if(T.declaration==null&&T.specifiers[0]?.type==="ExportSpecifier"){let N=T.specifiers[0],I=N.local&&typeof N.local==="object"&&"name"in N.local?N.local.name:void 0,F=N.exported&&typeof N.exported==="object"&&"name"in N.exported?N.exported.name:void 0;if(!I||!F)return;let W;for(let _ of Array.from(this.ctx.vars))if(_.declarations.some((H)=>H.id&&typeof H.id==="object"&&("type"in H.id)&&H.id.type==="Identifier"&&H.id.name===I)){W=_;break}if(!W){let _="source"in T&&T.source&&typeof T.source==="object"&&"value"in T.source?T.source.value:void 0,H=typeof _==="string"?`it re-exports from "${_}"`:this.ctx.valueImportBindingsByLocalName.has(I)?"it re-exports an imported binding":"no matching local declaration was found";n(this.ctx,"export-unresolved",F,`export "${F}" was skipped because ${H}; sveld only resolves exports of a local declaration.`,t(this.ctx,T));return}T.declaration=W,D=F,w=!0}if(T.declaration==null)return;if(!T.declaration||typeof T.declaration!=="object"||!("type"in T.declaration))return;let V=[];if(T.declaration.type==="FunctionDeclaration"){let N=T.declaration;if(!N.id?.name)return;let I=this.ctx.scriptLanguage==="ts"?Q(this.ctx,N):void 0;V.push({prop_name:N.id.name,kind:"function",isFunctionDeclaration:!0,value:void 0,typeSeed:I?.hasAnnotations?void 0:"() => any",explicitType:I?.hasAnnotations?I.signature:void 0,initializerIsFunction:!0,defaultValue:void 0,inferredTypeForSource:void 0,resolvedJSDoc:void 0})}else if(T.declaration.type==="VariableDeclaration"){let N=T.declaration,I=Lt(N.kind),F=w?N.declarations.slice(0,1):N.declarations;for(let W of F){if(!W||typeof W!=="object"||!("id"in W))continue;let{id:_,init:H}=W;if(!_||typeof _!=="object"||!("name"in _))continue;let te=_.name,re=D??te,ae=H==null?{isFunction:!1}:m(this,this.ctx,H),{value:Se,type:ke,isFunction:ne,defaultValue:we}=ae,Ne=ae;if(Ne.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:te,location:"moduleExports",...Ne.pendingCallDefault});V.push({prop_name:re,kind:I,isFunctionDeclaration:!1,value:Se,typeSeed:ke,explicitType:this.getExplicitPropType(te),initializerIsFunction:ne,defaultValue:we,inferredTypeForSource:ke,resolvedJSDoc:Ne})}if(V.length===0)return}else return;let J=y(this.ctx,this,T);for(let{prop_name:N,kind:I,isFunctionDeclaration:F,value:W,typeSeed:_,explicitType:H,initializerIsFunction:te,defaultValue:re,inferredTypeForSource:ae,resolvedJSDoc:Se}of V){let{type:ke,typeSource:ne,description:we,params:Ne,returnType:Ae,isFunction:Le}=$e({explicitType:H,typeSeed:_,inferredTypeForSource:ae,jsdocType:J?.type,jsdocDescription:J?.description,jsdocParams:J?.params,jsdocReturnType:J?.returnType,resolvedType:Se?.resolvedType,resolvedDescription:Se?.resolvedDescription,resolvedParams:Se?.resolvedParams,resolvedReturnType:Se?.resolvedReturnType,initializerIsFunction:te,isFunctionDeclaration:F,typedefs:this.ctx.typedefs});this.addModuleExport(N,{name:N,kind:I,description:we,deprecated:J?.deprecated,tags:J?.tags,...J?.internal?{internal:!0}:{},type:ke,typeSource:ne,value:W,defaultValue:re,params:Ne,returnType:Ae,isFunction:Le,isFunctionDeclaration:F,isRequired:!1,constant:I==="const",reactive:!1,source:t(this.ctx,T)})}}});let E,k,G,j=new Set,q=new Set,Pe=[];ft(this,this.ctx),this.ctx.activeScopes.push(this.ctx.componentScope);let Me=yt(this.ctx);if(v(C,(T,D,w)=>{let V=gt(this,this.ctx,Me,T);if(V)this.ctx.activeScopes.push(V);let J=T.type;if(!fn.has(J))return;if(T.type==="AssignmentExpression")ot(this.ctx,T.left);if(T.type==="UpdateExpression")ot(this.ctx,T.argument);if(T.type==="CallExpression"){let N=T,I=N.callee&&typeof N.callee==="object"&&"name"in N.callee?N.callee.name:void 0;if(I==="createEventDispatcher"){if(D&&typeof D==="object"&&"id"in D&&D.id&&typeof D.id==="object"&&"name"in D.id)E=D.id.name,k=D;G=N.typeArguments?.params?.[0]}if(I==="$host"){if(D&&typeof D==="object"&&"id"in D&&D.id&&typeof D.id==="object"&&"name"in D.id)j.add(D.id.name)}if(I==="setContext")ue(this.ctx,this,T,D??void 0);if(I)Pe.push({name:I,arguments:N.arguments,node:N});if(ie(N.callee)&&s(N.callee.property)&&N.callee.property.name==="dispatchEvent"&&(p(N.callee.object,"$host")||s(N.callee.object)&&j.has(N.callee.object.name))){let F=le(this.ctx,N);if(F)q.add(F)}}if(J==="SpreadAttribute"){let N=T;if(N.expression?.name==="$$restProps"||this.ctx.restPropLocals.has(N.expression?.name??""))ut(this.ctx,D)}if(T.type==="FunctionDeclaration"){let N=T;if(N.id?.name)this.ctx.funcDecls.set(N.id.name,N)}if(T.type==="ImportDeclaration")Ze(this.ctx,T);if(T.type==="VariableDeclaration"){if(this.ctx.vars.add(T),D&&typeof D==="object"&&"type"in D&&D.type==="Program"&&T.declarations.some((N)=>p(f(N.init),"$props")))Pt(this,this.ctx,T)}if(T.type==="ExportNamedDeclaration"){if(T.declaration==null&&T.specifiers.length===0)return;let N,I=!1;if(T.declaration==null&&T.specifiers[0]?.type==="ExportSpecifier"){let _=T.specifiers[0],H=_.local&&typeof _.local==="object"&&"name"in _.local?_.local.name:void 0,te=_.exported&&typeof _.exported==="object"&&"name"in _.exported?_.exported.name:void 0;if(!H||!te)return;let re;for(let ae of Array.from(this.ctx.vars))if(ae.declarations.some((Se)=>Se.id&&typeof Se.id==="object"&&("type"in Se.id)&&Se.id.type==="Identifier"&&Se.id.name===H)){re=ae;break}if(T.declaration=re,N=te,I=!0,!re){let ae="source"in T&&T.source&&typeof T.source==="object"&&"value"in T.source?T.source.value:void 0,Se=typeof ae==="string"?`it re-exports from "${ae}"`:this.ctx.valueImportBindingsByLocalName.has(H)?"it re-exports an imported binding":"no matching local declaration was found";n(this.ctx,"export-unresolved",te,`export "${te}" was skipped because ${Se}; sveld only resolves exports of a local declaration.`,t(this.ctx,T));return}}if(T.declaration==null)return;if(!T.declaration||typeof T.declaration!=="object"||!("type"in T.declaration))return;let F=[];if(T.declaration.type==="FunctionDeclaration"){let _=T.declaration;if(!_.id?.name)return;N??=_.id.name;let H=this.ctx.scriptLanguage==="ts"?Q(this.ctx,_):void 0;F.push({prop_name:N,kind:"function",isFunctionDeclaration:!0,value:void 0,typeSeed:H?.hasAnnotations?void 0:"() => any",explicitType:H?.hasAnnotations?H.signature:void 0,initializerIsFunction:!0,isRequired:!1,localName:_.id.name,defaultValue:void 0,inferredTypeForSource:void 0,resolvedJSDoc:void 0})}else if(T.declaration.type==="VariableDeclaration"){let _=T.declaration,H=Lt(_.kind),te=I?_.declarations.slice(0,1):_.declarations;for(let re of te){if(!re||typeof re!=="object"||!("id"in re))continue;let{id:ae,init:Se}=re;if(!ae||typeof ae!=="object"||!("name"in ae))continue;let ke=ae.name,ne=N??ke,we=H==="let"&&Se==null,Ne=Se==null?{isFunction:!1}:m(this,this.ctx,Se),{value:Ae,type:Le,isFunction:et,defaultValue:tt}=Ne,Be=Ne;if(Be.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:ne,location:"props",...Be.pendingCallDefault});F.push({prop_name:ne,kind:H,isFunctionDeclaration:!1,value:Ae,typeSeed:Le,explicitType:this.getExplicitPropType(ke),initializerIsFunction:et,isRequired:we,localName:ke,defaultValue:tt,inferredTypeForSource:Le,resolvedJSDoc:Be})}if(F.length===0)return}else return;let W=y(this.ctx,this,T);for(let{prop_name:_,kind:H,isFunctionDeclaration:te,value:re,typeSeed:ae,explicitType:Se,initializerIsFunction:ke,isRequired:ne,localName:we,defaultValue:Ne,inferredTypeForSource:Ae,resolvedJSDoc:Le}of F){let{type:et,typeSource:tt,description:Be,params:At,returnType:Rt,isFunction:It}=$e({explicitType:Se,typeSeed:ae,inferredTypeForSource:Ae,jsdocType:W?.type,jsdocDescription:W?.description,jsdocParams:W?.params,jsdocReturnType:W?.returnType,resolvedType:Le?.resolvedType,resolvedDescription:Le?.resolvedDescription,resolvedParams:Le?.resolvedParams,resolvedReturnType:Le?.resolvedReturnType,initializerIsFunction:ke,isFunctionDeclaration:te,typedefs:this.ctx.typedefs});d(this.ctx,"prop-unknown-type",_,W?.sveldIgnore),R(this,this.ctx,_,{name:_,...we!==void 0&&we!==_?{localName:we}:{},kind:H,description:Be,binding:W?.binding,deprecated:W?.deprecated,tags:W?.tags,...W?.internal?{internal:!0}:{},type:et,typeSource:tt,value:re,defaultValue:Ne,params:At,returnType:Rt,isFunction:It,isFunctionDeclaration:te,isRequired:ne,constant:H==="const",reactive:this.ctx.reactive_vars.has(_),source:t(this.ctx,T)})}}if(J==="Comment"){let I=T?.data?.trim()??"";if(wt.test(I))this.ctx.componentComment=I.replace(wt,"").replace(un,""),this.ctx.componentCommentSource=t(this.ctx,T)}if(J==="SlotElement"){let N=T,I=N.attributes?.find((H)=>H.name==="name")?.value,F=(Array.isArray(I)?I[0]:void 0)?.data,W=(N.attributes||[]).filter((H)=>H.name!=="name").reduce((H,te)=>{let re={value:void 0,replace:!1},ae=te.value;if(ae===void 0||ae===!0)return H;let Se=Array.isArray(ae)?ae[0]:ae;if(Se){let{type:ke,expression:ne,raw:we,start:Ne,end:Ae}=Se;if(ke==="Text"&&we!==void 0)re.value=JSON.stringify(we);else if(!Array.isArray(ae)&&ke==="ExpressionTag"&&ne&&typeof ne==="object"&&"type"in ne&&ne.type==="Identifier"&&"name"in ne&&ne.name===te.name)re.value=ne.name,re.replace=!0;if(ne&&typeof ne==="object"&&"type"in ne){if(ne.type==="Literal"&&"value"in ne){let Le=ne.value;re.value=typeof Le==="string"?JSON.stringify(Le):String(Le)}else if(ne.type==="MemberExpression")re.value=B(this.ctx,this,ne);else if(ne.type!=="Identifier"){if(Ne!==void 0&&Ae!==void 0){if(ne.type==="ObjectExpression"||ne.type==="TemplateLiteral")re.value=r(this.ctx,Ne+1,Ae-1)}}}}if(te.name)H[te.name]=re;return H},{}),_=N.fragment?.nodes?.map(({start:H,end:te})=>{if(H===void 0||te===void 0)return"";return r(this.ctx,H,te)??""}).join("").trim();L(this.ctx,{slot_name:F,slot_props:W,slot_fallback:_,source:t(this.ctx,T)})}if(J==="RenderTag"){let N=T,I=Te(this.ctx,N.expression);if(I){let F,W=!1;if(I.arguments.length===0)F={};else if(I.arguments.length===1&&typeof I.arguments[0]==="object"&&I.arguments[0]&&"type"in I.arguments[0]&&I.arguments[0].type==="ObjectExpression"){let te=Y(this.ctx,this,I.arguments[0]);F=te.slot_props,W=te.hasUnresolvedSpread}else if(I.arguments.length===1)n(this.ctx,"syntax-skipped",I.publicName,`{@render ${I.publicName}(...)} argument is not a plain object literal; the render call was not mapped to slot metadata.`,t(this.ctx,T));let _=I.publicName==="children"?void 0:I.publicName,H=_===void 0?dn:_;if(F!==void 0)L(this.ctx,{slot_name:_,slot_props:F,slot_props_unresolved_spread:W||void 0,source:t(this.ctx,T)});if(F!==void 0||this.ctx.slots.has(H))this.ctx.snippetPropLocals.add(I.trackingName)}}if(J==="OnDirective"){let N=T;if(N.expression==null&&N.name){if(D!=null&&typeof D==="object"&&"name"in D){let I=typeof D.name==="string"?D.name:void 0,F="type"in D?String(D.type):void 0;if(I&&F){let W=Ve(F)?{type:"InlineComponent",name:I}:{type:"Element",name:I};this.ctx.forwardedEvents.set(N.name,W);let _=this.ctx.events.get(N.name),H=this.ctx.eventDescriptions.get(N.name),te=_?.deprecated,re=_?.internal;if(!_)this.ctx.events.set(N.name,{type:"forwarded",name:N.name,element:W,description:H,deprecated:te,...re?{internal:!0}:{},source:t(this.ctx,T)});else if(_.type==="forwarded"&&H&&!_.description)this.ctx.events.set(N.name,{..._,description:H,deprecated:_.deprecated??te,..._.internal||re?{internal:!0}:{},source:_.source||t(this.ctx,T)})}}}}if(J==="BindDirective"&&D&&typeof D==="object"&&"type"in D&&(Oe(String(D.type))||Ve(String(D.type)))){let N=T;if(N.expression?.name){let I=Ge(this.ctx,N.expression.name);if(I)this.ctx.reactive_vars.add(I)}if(Oe(String(D.type))&&N.name==="this"&&N.expression?.name&&"name"in D&&typeof D.name==="string"){let I=Ge(this.ctx,N.expression.name);if(!I)return;let F=D.name;if(this.ctx.bindings.has(I)){let W=this.ctx.bindings.get(I);if(W&&!W.elements.includes(F))this.ctx.bindings.set(I,{...W,elements:[...W.elements,F]})}else this.ctx.bindings.set(I,{elements:[F]})}}},(T)=>{if(Je(T))this.ctx.activeScopes.pop(),bt(Me,T)},{skipTypeOnlySubtrees:!0}),E!==void 0){vt(this,this.ctx,G,E,t(this.ctx,k));for(let T of Pe)if(T.name===E){let D=T.arguments[0],w=D&&typeof D==="object"&&"value"in D?D.value:void 0,V=T.arguments[1],J=pe(this,V),N=J===void 0&&V&&typeof V==="object"&&"value"in V?V.value:void 0;if(w!=null)h(this.ctx,{name:String(w),detail:J??(N==null?"":z(N)),has_argument:Boolean(V),source:t(this.ctx,T.node)})}}let Ce=new Set(q);if(E!==void 0){for(let T of Pe)if(T.name===E){let D=T.arguments[0],w=D&&typeof D==="object"&&"value"in D?D.value:void 0;if(w!=null)Ce.add(String(w))}}this.ctx.forwardedEvents.forEach((T,D)=>{let w=this.ctx.events.get(D);if(w&&w.type==="dispatched"&&!Ce.has(D)){let V=this.ctx.eventDescriptions.get(D),J={type:"forwarded",name:D,element:T,description:V,deprecated:w.deprecated,tags:w.tags,source:w.source};if(w.internal)J.internal=!0;if(w.detail!==void 0&&w.detail!=="undefined")J.detail=w.detail;this.ctx.events.set(D,J)}}),Ct(this.ctx,Ce);let _e=this.ctx.syntaxMode==="runes"?new Set(Array.from(this.ctx.snippetPropLocals,(T)=>this.resolvePublicPropName(T))):new Set,Re=i.mapToArray(this.ctx.props).filter((T)=>!_e.has(T.name)).map((T)=>{if(this.ctx.bindings.has(T.name)){let D=this.ctx.bindings.get(T.name)?.elements.sort().map((w)=>dt(w)).join(" | ");return{...T,type:`null | ${D}`,typeSource:"inferred",reactive:T.reactive||this.ctx.reactive_vars.has(T.name)}}return{...T,reactive:T.reactive||this.ctx.reactive_vars.has(T.name)}});this.ctx.activeScopes.length=0;let He=i.mapToArray(this.ctx.slots).map((T)=>{let{slot_props_unresolved_spread:D,...w}=T;if(!T.slot_props)return w;if(typeof T.slot_props==="string")return mn.test(T.slot_props)?{...w,slot_props:"Record<string, never>"}:w;let V=T.slot_props,J=[];for(let F of Object.keys(V)){if(V[F].replace&&V[F].value!==void 0)V[F].value=this.getPropTypeByLocalOrPublic(V[F].value);if(V[F].value===void 0)V[F].value="any";J.push(`${F}: ${V[F].value}`)}let N=D?" & Record<string, any>":"",I=J.length===0?D?"Record<string, any>":"Record<string, never>":J.length===1?`{ ${J[0]} }${N}`:`{
|
|
2
|
+
${J.join(`;
|
|
3
|
+
`)};
|
|
4
|
+
}${N}`;return{...w,slot_props:I}}).sort((T,D)=>{let w=T.name??"",V=D.name??"";if(w<V)return-1;if(w>V)return 1;return 0});if(this.ctx.deferredSlotBlockGenerics.length>0){let T=[...Re.map((D)=>D.type??""),...He.map((D)=>D.slot_props??"")].join(`
|
|
5
|
+
`);for(let{name:D,constraint:w}of this.ctx.deferredSlotBlockGenerics){let V=D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!new RegExp(`\\b${V}\\b`).test(T))continue;this.accumulateGeneric(D,w)}}if(this.ctx.scriptGenericsAttribute){if(this.ctx.generics)n(this.ctx,"syntax-skipped","generics",'Both the "generics" script attribute and @generics/@template JSDoc tags declare component generics; the script attribute takes precedence and the JSDoc declaration was ignored.',this.ctx.scriptGenericsAttribute.source);this.ctx.generics=ge(this.ctx.scriptGenericsAttribute.value)}let Fe=i.mapToArray(this.ctx.moduleExports),Ke=i.mapToArray(this.ctx.events).map((T)=>{switch(T.type){case"forwarded":return{...T,element:T.element.name};case"dispatched":return T;default:return T}}).sort((T,D)=>{let w=T.name.localeCompare(D.name);if(w!==0)return w;let V=T.type.localeCompare(D.type);if(V!==0)return V;if(T.type==="forwarded"&&D.type==="forwarded"){let J=T.element.localeCompare(D.element);if(J!==0)return J}return(T.detail??"").localeCompare(D.detail??"")}),je=i.mapToArray(this.ctx.typedefs),ze=i.mapToArray(this.ctx.contexts),We={props:new Map(this.ctx.pendingCallDefaultCandidates.filter((T)=>T.location==="props").map((T)=>[T.propName,T])),moduleExports:new Map(this.ctx.pendingCallDefaultCandidates.filter((T)=>T.location==="moduleExports").map((T)=>[T.propName,T]))};for(let T of Re)if(T.typeSource==="unknown"){let D=We.props.get(T.name);if(D)T.type="any";let w=D?D.importSource?`Prop "${T.name}" default calls "${D.calleeName}()" imported from "${D.importSource}"; falling back to "any" pending cross-file resolution.`:`Prop "${T.name}" default calls "${D.calleeName}()", but its return type could not be inferred; falling back to "any".`:`Prop "${T.name}" type could not be inferred; falling back to "${T.type??"any"}".`;n(this.ctx,"prop-unknown-type",T.name,w,T.source)}for(let T of Fe)if(T.typeSource==="unknown"&&We.moduleExports.has(T.name))T.type="any";for(let T of this.ctx.jsDocEventNames){if(Ce.has(T))continue;if(this.ctx.forwardedEvents.has(T))continue;if(this.ctx.props.has(`on${T}`))continue;n(this.ctx,"event-no-source",T,`@event "${T}" has no matching dispatch or callback prop.`,this.ctx.jsDocEventSources.get(T))}if(this.ctx.rest_props?.type==="InlineComponent")n(this.ctx,"rest-props-unresolved","$$restProps",`$$restProps is only spread onto component "${this.ctx.rest_props.name}"; sveld cannot infer its rest-prop type. Spread onto a plain element or add an @restProps tag.`);let Xe=je.filter((T)=>T.internal).map((T)=>T.name.split("<")[0]);if(Xe.length>0){let T=Xe.map((w)=>({name:w,regex:new RegExp(`\\b${w}\\b`)})),D=(w,V,J)=>{if(!V)return;for(let{name:N,regex:I}of T){if(!I.test(V))continue;n(this.ctx,"internal-typedef-referenced",w,`"${w}" references "${N}", which is @internal and excluded from output; the generated .d.ts will contain a dangling reference to it.`,J)}};for(let w of Re){if(w.internal)continue;D(w.name,w.type,w.source)}for(let w of Fe){if(w.internal)continue;D(w.name,w.type,w.source)}for(let w of je){if(w.internal)continue;D(w.name,w.ts)}for(let w of Ke){if(w.internal||w.type!=="dispatched")continue;D(w.name,w.detail,w.source)}for(let w of He){if(w.internal)continue;D(w.name??"default",w.slot_props,w.source)}for(let w of ze){if(w.internal)continue;for(let V of w.properties)D(V.name,V.type)}}let Ue={source:U(this.ctx,0,this.ctx.source?.length),syntaxMode:this.ctx.syntaxMode,...this.ctx.scriptLanguage?{scriptLanguage:this.ctx.scriptLanguage}:{},props:Re,moduleExports:Fe,slots:He,events:Ke,typedefs:je,generics:this.ctx.generics,rest_props:this.ctx.rest_props,extends:this.ctx.extends,componentComment:this.ctx.componentComment,componentCommentSource:this.ctx.componentCommentSource,contexts:ze,customElementTag:this.ctx.customElementTag,customElement:this.ctx.customElement,...this.ctx.cssParts.length>0?{cssParts:this.ctx.cssParts.slice()}:{},...this.ctx.cssProperties.length>0?{cssProperties:this.ctx.cssProperties.slice()}:{},diagnostics:this.ctx.diagnosticRecords.slice()},qe=ye(this.ctx);if(qe)Ue[g]=qe;return Ue}}
|
|
6
|
+
export{i};
|
package/lib/cli-entry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ne}from"./chunk-ag202nwj.js";export{ne as cli};
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{j,F,J,q,ae,V,o,Se,W,M,te,ke,re,D,Pe,_,E,H,N,I,b,S,k,G,ve,we,w,ne}from"./chunk-ag202nwj.js";import{i}from"./chunk-v4be4g6y.js";async function f(s){if(s&&"input"in s)throw Error("sveld: the `input` option was renamed to `entry`.");let{entry:m,...u}=s??{},a=await _(),n=D(m??a.entry);if(n===null)throw Error('sveld: could not resolve a Svelte entry point. Set package.json#svelte, or pass the "entry" option.');let e=H(E(a,u,{entry:n}));N(e),I(e.quiet===!0);let t=await S(n,e.glob===!0,b(e)),p;if(e.check)p=await M(t.components,W(e),{entryExports:t.entryExports});if(await w(t,e,n),!e.dryRun)t.cache?.save();let c=e.reportDiagnostics||e.strict,r=F(t.diagnostics,c);if(c&&r.length>0)if(e.format==="json")process.stderr.write(V(r));else console.error(q(r));let l=0;if(p?.bump==="major")l=3;else if(J(r,e.strict).length>0)l=4;return{diagnostics:r,check:p,errors:t.errors,exitCode:l}}export{ke as CHECK_REPORT_SCHEMA_VERSION,i as ComponentParser,ae as DIAGNOSTICS_SCHEMA_VERSION,j as DIAGNOSTIC_CODES,o as buildComponentApiDocument,ne as cli,we as default,Pe as defineConfig,Se as diffApiDocuments,te as formatCheckReport,re as formatCheckReportJson,G as getWriter,ve as listWriters,k as registerWriter,M as runCheck,f as sveld};
|
package/package.json
CHANGED
package/lib/chunk-0mgphvte.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{e}from"./chunk-xt4vdey6.js";import{existsSync as A,readdirSync as O,readFileSync as M,statSync as j}from"node:fs";import{createRequire as D}from"node:module";import m from"node:path";var C="__sveld_resolved_props__",w="__SveldResolvedProps__",L=/ \| undefined$/,G=/[^A-Za-z0-9_-]/g,U=/[^A-Za-z0-9_$]/g,q=/^[0-9]/,z=2,I=7,F=`TypeScript ${I} or later, which provides \`typescript/unstable/async\``;function X(t){if(!t)return!1;let s=Number.parseInt(t,10);return Number.isFinite(s)&&s>=I}async function V(t){let s;try{let o=D(m.join(t,"package.json")).resolve("typescript/package.json");s=JSON.parse(M(o,"utf8")).version}catch{return{installed:!1}}if(!X(s))return{installed:!0,version:s};try{let n=await import("./chunk-z1dy5a6k.js");return{installed:!0,version:s,module:n}}catch{return{installed:!0,version:s}}}class k{api;symbolFlags;typeFlags;tsconfigPath;overlay=new Map;constructor(t,s,n,o){this.api=t,this.symbolFlags=s,this.typeFlags=n,this.tsconfigPath=o}static async create(t=process.cwd(),{importTs:s=V}={}){let n=await s(t);if(!n.installed)return{ok:!1,reason:"not-installed",message:`requires the \`typescript\` package to be installed (${F}); none was found`};if(!n.module)return{ok:!1,reason:"unsupported-version",message:`requires ${F}; found \`typescript@${n.version??"unknown"}\` installed, which does not expose that module`};let o=Q(t);if(!o)return{ok:!1,reason:"no-tsconfig",message:`could not locate a tsconfig.json starting from "${t}"`};let r=n.module,i=new k(null,r.SymbolFlags,r.TypeFlags,o),a=new r.API({cwd:t,fs:i.createFileSystem()});return i.api=a,{ok:!0,resolver:i}}async expandAll(t){let s=new Map;if(t.length===0)return s;let n=new Map;for(let r of t){if(!r.metadata.canonicalPropsType)continue;if(r.metadata.referencesComponentGenerics)continue;let i=this.virtualFileName(r.filePath,r.moduleName);this.overlay.set(i,B(r.metadata)),n.set(i,r)}if(n.size===0)return s;let o=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:Array.from(n.keys())}});try{let[r]=n.keys(),i=await o.getDefaultProjectForFile(r);if(!i)return s;let a=i.checker,v=await Promise.all(Array.from(n,async([l,f])=>{let c=this.overlay.get(l);if(!c)return null;let g=Z(c),p=await a.getTypeAtPosition(l,g);if(!p)return null;let u=new Map,T=await a.getPropertiesOfType(p);for(let d of T){if(!d.name||d.name.startsWith("__"))continue;u.set(d.name,{name:d.name,symbols:[d],forceOptional:!1})}if((p.flags&this.typeFlags.Union)!==0){let d=await p.getTypes(),N=await Promise.all(d.map((E)=>a.getPropertiesOfType(E)));for(let E of N)for(let h of E){if(!h.name||h.name.startsWith("__")||u.has(h.name))continue;let b=u.get(h.name);if(b)b.symbols.push(h);else u.set(h.name,{name:h.name,symbols:[h],forceOptional:!0})}}return{filePath:f.filePath,groups:Array.from(u.values())}})),y=[],_=[];v.forEach((l,f)=>{if(!l)return;l.groups.forEach((c,g)=>{for(let p of c.symbols)y.push(p),_.push({fileIndex:f,groupIndex:g})})});let R=y.length>0?await a.getTypeOfSymbol(y):[],x=await Promise.all(R.map((l)=>l?a.typeToString(l):Promise.resolve("any"))),P=new Map;y.forEach((l,f)=>{let{fileIndex:c,groupIndex:g}=_[f],p=(l.flags&this.symbolFlags.Optional)!==0,u=x[f];if(p)u=u.replace(L,"");let T=P.get(c)??new Map,S=T.get(g)??[];S.push(u),T.set(g,S),P.set(c,T)}),v.forEach((l,f)=>{if(!l)return;let c=P.get(f),g=l.groups.map((p,u)=>{let T=c?.get(u)??[],S=!(p.forceOptional||p.symbols.some((d)=>(d.flags&this.symbolFlags.Optional)!==0));return{name:p.name,type:Array.from(new Set(T)).join(" | "),isRequired:S}});g.sort((p,u)=>p.name.localeCompare(u.name)),s.set(l.filePath,g)})}finally{await o.dispose?.()}return s}async checkExamples(t){let s=new Map;if(t.length===0)return s;let n=[];for(let r of t)for(let i of r.sources){let a=this.exampleFileName(r.filePath,r.moduleName,i.id);this.overlay.set(a,J(i)),n.push({filePath:r.filePath,source:i,file:a})}if(n.length===0)return s;let o=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:n.map((r)=>r.file)}});try{let[r]=n,i=await o.getDefaultProjectForFile(r.file);if(!i)return s;await Promise.all(n.map(async({filePath:a,source:v,file:y})=>{let[_,R]=await Promise.all([i.program.getSyntacticDiagnostics(y),i.program.getSemanticDiagnostics(y)]),x=[..._,...R];if(x.length===0)return;let P=this.overlay.get(y)??"",l=x.map((c)=>W(c,P)).sort((c,g)=>c.line-g.line).map((c)=>`Line ${c.line}: ${c.text}`).join(`
|
|
2
|
-
`),f=s.get(a)??[];f.push({id:v.id,name:v.name,message:l}),s.set(a,f)}))}finally{await o.dispose?.()}return s}async dispose(){this.overlay.clear(),await this.api?.close?.()}createFileSystem(){return{readFile:(t)=>this.overlay.get(e(t)),fileExists:(t)=>this.overlay.has(e(t))?!0:void 0,getAccessibleEntries:(t)=>{let s=e(t),n=Array.from(this.overlay.keys()).filter((i)=>e(m.dirname(i))===s);if(n.length===0)return;let o=[],r=[];try{for(let i of O(t)){let a=m.join(t,i);try{(j(a).isDirectory()?r:o).push(i)}catch{}}}catch{}for(let i of n){let a=m.basename(i);if(!o.includes(a))o.push(a)}return{files:o,directories:r}}}}virtualFileName(t,s){let n=m.dirname(m.resolve(t));return e(m.join(n,`__sveld_resolved_${s}.ts`))}exampleFileName(t,s,n){let o=m.dirname(m.resolve(t)),r=n.replace(G,"_");return e(m.join(o,`__sveld_example_${s}_${r}.ts`))}}function B(t){return[...t.typeImportStatements,...t.localTypeDeclarations,`type ${w} = ${t.canonicalPropsType};`,`declare const ${C}: ${w};`].join(`
|
|
3
|
-
`)}function H(t){let s=t.replace(U,"_");if(s===""||q.test(s))return`_${s}`;return s}function J(t){return`const ${H(t.name)} = null as unknown as (${t.type});
|
|
4
|
-
${t.code}
|
|
5
|
-
`}function W(t,s){let n=t.pos??0,o=s.slice(0,n).split(`
|
|
6
|
-
`).length;return{line:Math.max(1,o-z+1),text:String(t.text??"").trim()}}function Z(t){let s=t.lastIndexOf("declare const");return t.indexOf(C,s)+2}function Q(t){let s=m.resolve(t);while(!0){let n=m.join(s,"tsconfig.json");if(A(n))return n;let o=m.dirname(s);if(o===s)return null;s=o}}export{k as TypeResolver};
|
package/lib/chunk-fc72j0vd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T,P}from"./chunk-xt4vdey6.js";export{T as TemplateParseNotImplementedError,P as parse};
|
package/lib/chunk-fj7dbych.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i}from"./chunk-szfpvrdq.js";export{i as default};
|
package/lib/chunk-szfpvrdq.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{re,l,a,ne,p,f,ie,y,M,n,d,V,t,r,u,I,m,oe,ae,ce,G,h,ue,z,pe,le,x,fe,c,C,de,X,me,he,ge,Q,ye,R,Y,Z,L,g,xe,Te,P}from"./chunk-xt4vdey6.js";var dt={a:"HTMLAnchorElement",abbr:"HTMLElement",address:"HTMLElement",applet:"HTMLUnknownElement",area:"HTMLAreaElement",article:"HTMLElement",aside:"HTMLElement",audio:"HTMLAudioElement",b:"HTMLElement",base:"HTMLBaseElement",basefont:"HTMLElement",bdi:"HTMLElement",bdo:"HTMLElement",blockquote:"HTMLQuoteElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",cite:"HTMLElement",code:"HTMLElement",col:"HTMLTableColElement",colgroup:"HTMLTableColElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",dd:"HTMLElement",del:"HTMLModElement",details:"HTMLDetailsElement",dfn:"HTMLElement",dialog:"HTMLDialogElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",dt:"HTMLElement",em:"HTMLElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",figcaption:"HTMLElement",figure:"HTMLElement",font:"HTMLFontElement",footer:"HTMLElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",h2:"HTMLHeadingElement",h3:"HTMLHeadingElement",h4:"HTMLHeadingElement",h5:"HTMLHeadingElement",h6:"HTMLHeadingElement",head:"HTMLHeadElement",header:"HTMLElement",hgroup:"HTMLElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",i:"HTMLElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",ins:"HTMLModElement",kbd:"HTMLElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",main:"HTMLElement",map:"HTMLMapElement",mark:"HTMLElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",nav:"HTMLElement",noscript:"HTMLElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",picture:"HTMLPictureElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",rp:"HTMLElement",rt:"HTMLElement",ruby:"HTMLElement",s:"HTMLElement",samp:"HTMLElement",script:"HTMLScriptElement",search:"HTMLElement",section:"HTMLElement",select:"HTMLSelectElement",slot:"HTMLSlotElement",small:"HTMLElement",source:"HTMLSourceElement",span:"HTMLSpanElement",strong:"HTMLElement",style:"HTMLStyleElement",sub:"HTMLElement",summary:"HTMLElement",sup:"HTMLElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",td:"HTMLTableCellElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",tfoot:"HTMLTableSectionElement",th:"HTMLTableCellElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",u:"HTMLElement",ul:"HTMLUListElement",var:"HTMLElement",video:"HTMLVideoElement",wbr:"HTMLElement"};function Ht(e){return e in dt}function ut(e){if(Ht(e))return dt[e];return"HTMLElement"}function et(){return{syntaxMode:"legacy",scriptLanguage:void 0,source:void 0,parsed:void 0,runesOptionOverride:void 0,sourceLineStartOffsetsCache:void 0,sourceLineHint:void 0,parsedJsDocByText:new Map,jsDocBlocksByStart:new Map,rest_props:void 0,extends:void 0,customElementTag:void 0,customElement:void 0,componentComment:void 0,componentCommentSource:void 0,generics:null,scriptGenericsAttribute:void 0,diagnosticRecords:[],componentFilePath:"",props:new Map,moduleExports:new Map,propLocalToPublicName:new Map,reactive_vars:new Set,funcDecls:new Map,vars:new Set,valueImportBindingsByLocalName:new Map,pendingCallDefaultCandidates:[],pendingContextKeyCandidates:[],runesPropsDeclarationMetadataByDeclaratorStart:new Map,typedRunesPropsDeclarations:[],explicitPropTypesByName:new Map,explicitVariableTypesByName:new Map,typeImportBindingsByLocalName:new Map,localTypeDeclarationsByName:new Map,additionalTypeDependencyNodes:[],wholePropsLocals:new Set,restPropLocals:new Set,componentScope:new Map,scopeDeclarations:new Map,activeScopes:[],slots:new Map,snippetPropLocals:new Set,cssParts:[],cssProperties:[],deferredSlotBlockGenerics:[],events:new Map,eventDescriptions:new Map,forwardedEvents:new Map,jsDocEventNames:new Set,jsDocEventSources:new Map,bindings:new Map,contexts:new Map,typedefs:new Map,variableInfoCache:new Map,variableInfoCacheBuilt:!1,sveldIgnoreDirectives:new Map}}var Ft=new Set(["Component","SvelteComponent","SvelteSelf"]),jt=new Set(["RegularElement","SvelteElement"]);function je(e){return Ft.has(e)}function Be(e){return jt.has(e)}function Bt({hasTypeScriptType:e,hasJSDocType:o,inferredType:s,finalType:b}){if(e)return"typescript";if(o)return"jsdoc";if(s!==void 0)return"default";if(b!==void 0)return"inferred";return"unknown"}function Ve(e){let o=e.explicitType??e.jsdocType??e.resolvedType??e.typeSeed,s=e.jsdocParams??e.resolvedParams,b=e.jsdocReturnType??e.resolvedReturnType;if(e.isFunctionDeclaration&&o==="() => any"&&b)o=s&&s.length>0?`(${s.map((E)=>`${E.name}${E.optional?"?":""}: ${E.type}`).join(", ")}) => ${b}`:`() => ${b}`;let T=e.jsdocDescription??e.resolvedDescription;if(T===void 0&&o!==void 0)T=e.typedefs?.get(o)?.description;let D=Bt({hasTypeScriptType:e.explicitType!==void 0,hasJSDocType:e.jsdocType!==void 0||e.jsdocParams!==void 0||e.jsdocReturnType!==void 0||e.resolvedType!==void 0,inferredType:e.inferredTypeForSource,finalType:o}),v=e.initializerIsFunction||e.isFunctionDeclaration||e.inferIsFunctionFromTypeSignature===!0&&(!!e.jsdocParams?.length||e.jsdocReturnType!==void 0||!!e.jsdocType?.includes("=>")||!!e.resolvedType?.includes("=>")||!!e.explicitType?.includes("=>"));return{type:o,typeSource:D,description:T,params:s,returnType:b,isFunction:v}}function Vt(e){if(!e||typeof e!=="object"||!("type"in e))return;let o=String(e.type),s=je(o);if(!s&&!Be(o))return;let b="name"in e&&typeof e.name==="string"?e.name:void 0;if(!b)return;let T=s?{type:"InlineComponent",name:b}:{type:"Element",name:b};if(b==="svelte:element"&&"tag"in e&&e.tag&&typeof e.tag==="object"){let D=e.tag;if(D.type==="Literal"&&typeof D.value==="string")T.thisValue=D.value}return T}function mt(e,o){let s=Vt(o);if(!s)return;if(e.rest_props===void 0){e.rest_props=s;return}if(e.rest_props.type==="InlineComponent"&&s.type==="Element")e.rest_props=s}function ve(e,o,s){if(!o||e.has(o))return;e.set(o,s)}function Oe(e,o){for(let s=e.activeScopes.length-1;s>=0;s-=1){let b=e.activeScopes[s]?.get(o);if(!b)continue;return b.kind==="prop"?b.publicPropName:void 0}return}function Ee(e,o=new Set){if(!e||typeof e!=="object"||!("type"in e))return o;switch(e.type){case"Identifier":o.add(e.name);break;case"AssignmentPattern":Ee(e.left,o);break;case"ArrayPattern":for(let s of e.elements)Ee(s??void 0,o);break;case"ObjectPattern":for(let s of e.properties)if(s.type==="Property")Ee(s.value,o);else if(s.type==="RestElement")Ee(s.argument,o);break;case"RestElement":Ee(e.argument,o);break}return o}function nt(e,o){if(!o||typeof o!=="object"||!("type"in o))return;if(o.type==="Identifier"){let b=Oe(e,o.name);if(b)e.reactive_vars.add(b);return}let s=Ee(o);for(let b of s){let T=Oe(e,b);if(T)e.reactive_vars.add(T)}}function $e(e){if(!e||typeof e!=="object"||!("type"in e))return!1;switch(String(e.type)){case"BlockStatement":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"EachBlock":case"AwaitBlock":return!0;default:return!1}}function ft(e){if(!e||typeof e!=="object"||!("type"in e))return!1;let o=String(e.type);return o==="FunctionDeclaration"||o==="FunctionExpression"||o==="ArrowFunctionExpression"}function Ot(e,o){let s=e.scopeDeclarations.get(o);if(!s)s=new Map,e.scopeDeclarations.set(o,s);return s}function $t(e,o,s){let b=[];if(s.id.type==="Identifier")return b.push({kind:"local",name:s.id.name}),b;if(s.id.type!=="ObjectPattern")return b;for(let T of s.id.properties){if(T.type==="RestElement"){if(T.argument.type==="Identifier")b.push({kind:"local",name:T.argument.name});continue}if(T.computed)continue;let D=e.getPropertyName(T.key);if(!D)continue;let v;if(T.value.type==="Identifier")v=T.value.name;else if(T.value.type==="AssignmentPattern"&&T.value.left.type==="Identifier")v=T.value.left.name;if(!v)continue;b.push({kind:"prop",name:v,publicPropName:D})}return b}function tt(e,o,s,b,T){if(!re(o))return;let D=T?.allowRunesProps??!1,v=T?.forceProp??!1,E=o;for(let N of E.declarations){if(D&&p(f(N.init),"$props")){for(let U of $t(e,E,N))ve(U.kind==="prop"?s:b,U.name,U.kind==="prop"?{kind:"prop",publicPropName:U.publicPropName}:{kind:"local"});continue}let W=E.kind==="var"?b:s,F=v?"prop":"local";for(let U of Ee(N.id))ve(W,U,F==="prop"?{kind:"prop",publicPropName:U}:{kind:"local"})}}function Gt(e,o){if("id"in e&&e.id&&typeof e.id==="object"&&"name"in e.id&&typeof e.id.name==="string")ve(o,e.id.name,{kind:"local"});for(let s of e.params)for(let b of Ee(s))ve(o,b,{kind:"local"})}function Wt(e,o,s,b){if(!Array.isArray(o))return;for(let T of o){if(!T||typeof T!=="object"||!("type"in T))continue;switch(T.type){case"VariableDeclaration":tt(e,T,s,b);break;case"FunctionDeclaration":if(T.id?.name)ve(s,T.id.name,{kind:"local"});break;case"ClassDeclaration":if(T.id?.name)ve(s,T.id.name,{kind:"local"});break}}}function Jt(e,o,s){if(!s||typeof s!=="object")return;let b="content"in s&&s.content&&typeof s.content==="object"&&"body"in s.content&&Array.isArray(s.content.body)?s.content:("body"in s)&&Array.isArray(s.body)?s:void 0;if(!b||!("body"in b)||!Array.isArray(b.body))return;for(let T of b.body){if(!T||typeof T!=="object"||!("type"in T))continue;switch(T.type){case"ImportDeclaration":for(let D of T.specifiers??[])if(D.local?.name)ve(o.componentScope,D.local.name,{kind:"local"});break;case"VariableDeclaration":tt(e,T,o.componentScope,o.componentScope,{allowRunesProps:!0});break;case"FunctionDeclaration":if(T.id?.name)ve(o.componentScope,T.id.name,{kind:"local"});break;case"ClassDeclaration":if(T.id?.name)ve(o.componentScope,T.id.name,{kind:"local"});break;case"ExportNamedDeclaration":if(!T.declaration||typeof T.declaration!=="object"||!("type"in T.declaration))break;if(T.declaration.type==="VariableDeclaration")tt(e,T.declaration,o.componentScope,o.componentScope,{forceProp:!0});else if(T.declaration.type==="FunctionDeclaration"&&T.declaration.id?.name)ve(o.componentScope,T.declaration.id.name,{kind:"prop",publicPropName:T.declaration.id.name});break}}}function yt(e,o){o.componentScope.clear(),o.scopeDeclarations=new Map,o.activeScopes.length=0,Jt(e,o,o.parsed?.instance)}function gt(e){return{varScopeStack:[e.componentScope]}}function bt(e,o,s,b){if(!$e(b))return;let T=Ot(o,b),D=s.varScopeStack[s.varScopeStack.length-1]??o.componentScope;switch(String(b.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":Gt(b,T);break;case"BlockStatement":Wt(e,b.body,T,D);break;case"CatchClause":if("param"in b)for(let E of Ee(b.param))ve(T,E,{kind:"local"});break;case"EachBlock":{let E=b;for(let N of Ee(E.context))ve(T,N,{kind:"local"});if(typeof E.index==="string")ve(T,E.index,{kind:"local"});else if(E.index&&"name"in E.index)ve(T,E.index.name,{kind:"local"});break}case"AwaitBlock":{let E=b;for(let N of Ee(E.value))ve(T,N,{kind:"local"});for(let N of Ee(E.error))ve(T,N,{kind:"local"});break}}if(ft(b))s.varScopeStack.push(T);return T}function Tt(e,o){if(ft(o))e.varScopeStack.pop()}function ot(e){return e==="TSTypeAnnotation"||e==="TSTypeAliasDeclaration"||e==="TSInterfaceDeclaration"||e==="TSTypeParameterDeclaration"||e==="TSTypeParameterInstantiation"}function it(e,o,s,b){rt(e,null,null,o,s,b?.skipTypeOnlySubtrees===!0)}function rt(e,o,s,b,T,D){b(e,o,s);let v=e.type;if((v==="Identifier"||v==="Literal"||v==="Text")&&e.typeAnnotation===void 0){if(T)T(e);return}if(D&&v.charCodeAt(0)===84&&ot(v)){if(T)T(e);return}for(let E in e){if(E==="leadingComments")continue;let N=e[E];if(!N||typeof N!=="object")continue;if(Array.isArray(N))for(let W=0;W<N.length;W++){let F=N[W];if(F&&typeof F==="object"&&typeof F.type==="string")rt(F,e,E,b,T,D)}else if(typeof N.type==="string")rt(N,e,E,b,T,D)}if(T)T(e)}var St=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]);function Kt(e,o){switch(o?.type){case"MemberExpression":return o.computed||e===o.object;case"MethodDefinition":return!!o.computed;case"MetaProperty":return e===o.meta;case"PropertyDefinition":return o.computed||e===o.value;case"Property":return o.computed||e===o.value;case"ExportSpecifier":case"ImportSpecifier":return e===o.local;case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return!1;default:return!0}}var zt=Array.from(St);function xt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Xt(e){if(e.includes("\\u"))return!0;for(let o of zt){let s=e.indexOf(o);while(s!==-1){if(!xt(e.charCodeAt(s-1))&&!xt(e.charCodeAt(s+o.length)))return!0;s=e.indexOf(o,s+1)}}return!1}function Ut(e,o){for(let s=o.length-1;s>=0;s-=1)if(o[s]?.has(e))return!0;return!1}function qt(e){let o=new Set;if(!e||typeof e!=="object"||!("type"in e))return o;switch(String(e.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":{let s=e;if(s.id?.name)o.add(s.id.name);for(let b of s.params??[])Ee(b,o);break}case"BlockStatement":Ue(e.body,o);break;case"CatchClause":Ee(e.param,o);break;case"EachBlock":{let s=e;if(Ee(s.context,o),typeof s.index==="string")o.add(s.index);else if(s.index?.name)o.add(s.index.name);break}case"AwaitBlock":{let s=e;Ee(s.value,o),Ee(s.error,o);break}}return o}function Ue(e,o){if(!Array.isArray(e))return;for(let s of e){if(!s||typeof s!=="object"||!("type"in s))continue;switch(String(s.type)){case"ImportDeclaration":for(let b of s.specifiers??[])if(b.local?.name)o.add(b.local.name);break;case"VariableDeclaration":for(let b of s.declarations??[])Ee(b.id,o);break;case"FunctionDeclaration":case"ClassDeclaration":{let b=s.id?.name;if(b)o.add(b);break}case"ExportNamedDeclaration":{let b=s.declaration;if(b&&typeof b==="object"&&"type"in b)Ue([b],o);break}}}}function at(e,o){if(!e||typeof e!=="object")return!1;return st(e,void 0,[...o])}function st(e,o,s){if(ot(e.type))return!1;let b=$e(e);if(b)s.push(qt(e));let T=!1;if(o&&e.type==="Identifier"&&e.name!==void 0&&St.has(e.name)&&!o.type.startsWith("TS")&&Kt(e,o)&&!Ut(e.name,s))T=!0;else for(let D in e){if(D==="leadingComments")continue;let v=e[D];if(!v||typeof v!=="object")continue;if(Array.isArray(v)){for(let E=0;E<v.length;E++){let N=v[E];if(N&&typeof N==="object"&&typeof N.type==="string"){if(st(N,e,s)){T=!0;break}}}if(T)break}else if(typeof v.type==="string"){if(st(v,e,s)){T=!0;break}}}if(b)s.pop();return T}function ht(e){if(!e||typeof e!=="object")return;if("content"in e){let o=e.content,s=o&&typeof o==="object"&&"body"in o?o.body:void 0;if(Array.isArray(s))return s}if("body"in e&&Array.isArray(e.body))return e.body;return}function Et(e){if(e.runesOptionOverride!==void 0)return e.runesOptionOverride?"runes":"legacy";let o=e.parsed;if(!o)return"legacy";if(e.source!==void 0&&!Xt(e.source))return"legacy";let s=new Set;Ue(ht(o.module),s);let b=new Set;return Ue(ht(o.instance),b),at(o.module,[s])||at(o.instance,[s,b])||at(o.fragment,[s,b])?"runes":"legacy"}var Yt=/[A-Za-z_$][\w$]*/g;function Qt(e,o,s){let b=new Map,T=o.typeParameters?.params,D=s.typeArguments?.params;if(!T?.length||!D?.length)return b;for(let v=0;v<T.length;v++){let E=T[v]?.name,N=D[v];if(!E||N?.start===void 0||N?.end===void 0)continue;let W=r(e,N.start,N.end)?.trim();if(W)b.set(E,W)}return b}function Zt(e,o){if(o.size===0)return e;return e.replace(Yt,(s)=>o.get(s)??s)}function Ae(e,o,s,b,T=new Set){let D=new Map;if(!s?.type)return D;let v=(E)=>{for(let N of E){if(N?.type!=="TSPropertySignature"||N.computed)continue;if(!N.key)continue;let W=e.getPropertyName(N.key);if(!W)continue;let F=N.typeAnnotation?.start,U=N.typeAnnotation?.end;if(F===void 0||U===void 0)continue;let Se=r(o,F+1,U)?.trim();if(!Se)continue;C(o,N.typeAnnotation?.typeAnnotation),D.set(W,{type:Se,optional:N.optional===!0,source:t(o,N)})}};switch(s.type){case"TSTypeLiteral":v(s.members??[]);break;case"TSInterfaceDeclaration":v(s.body?.body??[]);break;case"TSTypeAliasDeclaration":{let E=Ae(e,o,s.typeAnnotation,b,T);for(let[N,W]of E)D.set(N,W);break}case"TSTypeReference":{let E=le(s.typeName);if(!E||T.has(E))break;let N=b.get(E);if(!N)break;T.add(E);let W=Ae(e,o,N,b,T);T.delete(E);let F=Qt(o,N,s);for(let[U,Se]of W)D.set(U,F.size===0?Se:{...Se,type:Zt(Se.type,F)});break}case"TSIntersectionType":for(let E of s.types??[]){let N=Ae(e,o,E,b,T);for(let[W,F]of N)D.set(W,F)}break;case"TSParenthesizedType":{let E=Ae(e,o,s.typeAnnotation,b,T);for(let[N,W]of E)D.set(N,W);break}}return D}function en(e){let o={};for(let[s,b]of Object.entries(e))o[s]={...b.attribute===void 0?{}:{attribute:b.attribute},...b.reflect===void 0?{}:{reflect:b.reflect},...b.type===void 0?{}:{type:b.type}};return o}function Pt(e,o,s){if(o.runesPropsDeclarationMetadataByDeclaratorStart.clear(),o.explicitPropTypesByName.clear(),o.explicitVariableTypesByName.clear(),o.typeImportBindingsByLocalName.clear(),o.localTypeDeclarationsByName.clear(),o.additionalTypeDependencyNodes.length=0,o.typedRunesPropsDeclarations.length=0,!o.source)return;let b=s;o.scriptLanguage=e.resolveScriptLanguage(b);let T=b.options?.customElement;o.customElementTag=T?.tag,o.customElement=T?{...T.tag===void 0?{}:{tag:T.tag},...T.shadow==="open"||T.shadow==="none"?{shadow:T.shadow}:{},...T.props?{props:en(T.props)}:{},...T.extend===void 0?{}:{extend:!0}}:void 0,o.runesOptionOverride=b.options?.runes,o.scriptGenericsAttribute=e.resolveScriptGenericsAttribute(b);let D=b.instance?.content?.body??[];for(let v of D){if(!v?.type)continue;if(v.type==="ImportDeclaration"&&v.source?.value)for(let E of v.specifiers??[]){let N=E.local?.name;if(!N)continue;if(!(v.importKind==="type"||E.importKind==="type"))continue;let F,U;if(E.type==="ImportSpecifier")F="named",U=E.imported?.type==="Identifier"?E.imported.name:typeof E.imported?.value==="string"?E.imported.value:void 0;else if(E.type==="ImportDefaultSpecifier")F="default";else if(E.type==="ImportNamespaceSpecifier")F="namespace";if(!F)continue;o.typeImportBindingsByLocalName.set(N,{importedName:U,localName:N,source:String(v.source.value),specifierType:F})}if((v.type==="TSInterfaceDeclaration"||v.type==="TSTypeAliasDeclaration")&&v.id?.name&&v.start!==void 0&&v.end!==void 0)o.localTypeDeclarationsByName.set(v.id.name,{code:r(o,v.start,v.end)?.trim()??"",node:v,start:v.start});if(v.type==="TSEnumDeclaration"&&v.id?.name&&v.start!==void 0&&v.end!==void 0)o.localTypeDeclarationsByName.set(v.id.name,{code:de(o,v)??"",node:v,start:v.start});if(v.type==="ExportNamedDeclaration"&&v.declaration?.type==="VariableDeclaration")for(let E of v.declaration.declarations??[]){if(E.id?.type!=="Identifier"||!E.id.name)continue;let N=x(o,E.id.typeAnnotation);if(N)o.explicitPropTypesByName.set(E.id.name,N),C(o,E.id.typeAnnotation?.typeAnnotation)}else if(v.type==="VariableDeclaration")for(let E of v.declarations??[]){if(E.id?.type!=="Identifier"||!E.id.name)continue;let N=x(o,E.id.typeAnnotation);if(N)o.explicitVariableTypesByName.set(E.id.name,N)}}for(let v of D){if(!v||typeof v!=="object"||!("declarations"in v))continue;for(let E of v.declarations??[]){if(!p(f(E.init),"$props"))continue;let N=E.id?.typeAnnotation?void 0:ie(E.init),W=E.id?.typeAnnotation?.typeAnnotation??N,F=E.id?.typeAnnotation?x(o,E.id.typeAnnotation):fe(o,N),U=Ae(e,o,W,new Map(Array.from(o.localTypeDeclarationsByName.entries(),([Pe,Re])=>[Pe,Re.node]))),Se=new Set,Ce=new Set;if(c(o,W,Se,Ce),ge(o,Se,Ce),E.start!==void 0){let Pe={canonicalType:F,props:U,referencedImportedTypes:Se,referencedLocalTypes:Ce};if(o.runesPropsDeclarationMetadataByDeclaratorStart.set(E.start,Pe),F)o.typedRunesPropsDeclarations.push(Pe)}}}}function vt(e,o,s){for(let b of s.declarations){if(!p(f(b.init),"$props"))continue;if(b.id.type==="Identifier"){o.wholePropsLocals.add(b.id.name),o.restPropLocals.add(b.id.name);let v=z(o,b.start);if(v)for(let[E,N]of v.props)I(e,o,E,{name:E,kind:"let",type:N.type,typeSource:"typescript",isFunction:!1,isFunctionDeclaration:!1,isRequired:!N.optional,constant:!1,reactive:!1,source:N.source});continue}if(b.id.type!=="ObjectPattern")continue;let T=g(o,e,s),D=b.id.properties.filter((v)=>{if(v.type!=="Property"||v.computed)return!1;if(!e.getPropertyName(v.key))return!1;if(v.value.type==="Identifier")return!0;return v.value.type==="AssignmentPattern"&&v.value.left.type==="Identifier"}).length;for(let v of b.id.properties){if(v.type==="RestElement"){if(v.argument.type==="Identifier")o.restPropLocals.add(v.argument.name);continue}let E=e.getPropertyName(v.key);if(!E)continue;let N,W;if(v.value.type==="Identifier")N=v.value.name;else{let S=v.value;N=S.left.name,W=S.right}if(!N)continue;if(e.trackPropLocalName(E,N),E==="children")o.snippetPropLocals.add(N);let F=xe(o,e,v)??(D===1?T:void 0),U=pe(o,b.start,E),{init:Se,bindable:Ce}=oe(W),Pe=Se==null?{isFunction:!1}:m(e,o,Se),{value:Re,type:we,isFunction:Ie,defaultValue:_e}=Pe,Ge=U?.type===void 0&&F?.type===void 0?Pe.resolvedType:void 0;if(Pe.pendingCallDefault)o.pendingCallDefaultCandidates.push({propName:E,location:"props",...Pe.pendingCallDefault});let{type:He,typeSource:We,description:Je,params:Ke,returnType:ze,isFunction:Xe}=Ve({explicitType:U?.type,typeSeed:we,inferredTypeForSource:we,jsdocType:F?.type,jsdocDescription:F?.description,jsdocParams:F?.params,jsdocReturnType:F?.returnType,resolvedType:Ge,resolvedDescription:Pe.resolvedDescription,resolvedParams:Pe.resolvedParams,resolvedReturnType:Pe.resolvedReturnType,initializerIsFunction:Ie,isFunctionDeclaration:!1,inferIsFunctionFromTypeSignature:!0});if(Ce)o.reactive_vars.add(E);d(o,"prop-unknown-type",E,F?.sveldIgnore),I(e,o,E,{name:E,...N===E?{}:{localName:N},kind:"let",description:Je,binding:F?.binding,deprecated:F?.deprecated,tags:F?.tags,...F?.internal?{internal:!0}:{},...Ce?{bindable:!0}:{},type:He,typeSource:We,value:Re,defaultValue:_e,params:Ke,returnType:ze,isFunction:Xe,isFunctionDeclaration:!1,isRequired:!Ce&&Se==null&&U?.optional!==!0,constant:!1,reactive:Ce,source:t(o,v)})}}}function tn(e){let s=e.indexOf("EventDispatcher");if(s===-1)return;let b=s+15;while(e[b]===" ")b++;if(e[b]!=="<")return;let T=0,D=b;for(;b<e.length;b++)if(e[b]==="<")T++;else if(e[b]===">"){if(T--,T===0)return e.slice(D+1,b)}return}function nn(e){let o=[],s=0,b=0;for(let T=0;T<e.length;T++){let D=e[T];if(D==="{"||D==="("||D==="["||D==="<")s++;else if(D==="}"||D===")"||D==="]"||D===">")s=Math.max(s-1,0);else if(s===0&&(D===";"||D===","))o.push(e.slice(b,T)),b=T+1}return o.push(e.slice(b)),o.map((T)=>T.trim()).filter((T)=>T.length>0)}var rn=/^["']|["']$/g,on=/\?$/,an=/^\{/,sn=/\}$/;function cn(e){let o=0;for(let s=0;s<e.length;s++){let b=e[s];if(b==="{"||b==="("||b==="["||b==="<")o++;else if(b==="}"||b===")"||b==="]"||b===">")o=Math.max(o-1,0);else if(o===0&&b===":"){let T=e.slice(0,s).trim().replace(on,"").replace(rn,""),D=e.slice(s+1).trim();if(!T||!D)return;return{name:T,type:D}}}return}function Ct(e,o,s,b,T){if(s){let N=new Map(Array.from(o.localTypeDeclarationsByName.entries(),([F,U])=>[F,U.node])),W=Ae(e,o,s,N);for(let[F,U]of W)h(o,{name:F,detail:U.type,has_argument:!0,source:U.source});return}let D=e.resolveLocalVarJSDoc(b)?.type,v=D?tn(D):void 0;if(!v)return;let E=v.trim().replace(an,"").replace(sn,"");for(let N of nn(E)){let W=cn(N);if(!W)continue;h(o,{name:W.name,detail:W.type,has_argument:!0,source:T})}}function Dt(e,o){if(e.syntaxMode!=="runes")return;for(let[s,b]of Array.from(e.events.entries())){if(b.type!=="dispatched")continue;if(o.has(s)||e.forwardedEvents.has(s))continue;let T=`on${s}`,D=e.props.get(T);if(!D)continue;let v=D.type!==void 0||D.params!==void 0||D.returnType!==void 0,E=b.detail===void 0||b.detail==="undefined"||b.detail==="null"?"() => void":`(detail: ${b.detail}) => void`;e.props.set(T,{...D,description:D.description??b.description,type:v?D.type:E,typeSource:v?D.typeSource:"inferred",isFunction:!0}),e.events.delete(s)}}var Mt=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function ct(e){return e!==null&&typeof e==="object"&&typeof e.type==="string"}function kt(e){if(!Mt.has(e.type))return e;let o=e.expression;while(o&&Mt.has(o.type))o=o.expression;return o??e}function qe(e){if(!ct(e))return;pt(e)}function pt(e){for(let o in e){if(o==="leadingComments")continue;let s=e[o];if(!s||typeof s!=="object")continue;if(Array.isArray(s))for(let b=0;b<s.length;b++){let T=s[b];if(!ct(T))continue;let D=kt(T);if(D!==T)s[b]=D;pt(D)}else if(ct(s)){let b=kt(s);if(b!==s)e[o]=b;pt(b)}}}function Ye(e,o){let s=o.source?.value;if(typeof s!=="string"||o.importKind==="type")return;for(let b of o.specifiers??[]){if(b.type!=="ImportSpecifier"||b.importKind==="type")continue;let T=b.local?.name;if(!T)continue;let D=b.imported?.name??(typeof b.imported?.value==="string"?b.imported.value:T);e.valueImportBindingsByLocalName.set(T,{localName:T,importedName:D,source:s})}}function lt(e,o){if(!o)return;let s=o,b=s.type==="Program"?s.body:s.content?.body??s.body;if(!Array.isArray(b))return;for(let T of b){let D=T;if(D.type==="ImportDeclaration"){Ye(e,D);continue}let v=D.type==="ExportNamedDeclaration"&&D.declaration?D.declaration:D;if(v.type==="FunctionDeclaration"){let E=v;if(E.id?.name)e.funcDecls.set(E.id.name,E)}}}function pn(e,o,s,b,T){for(let D of e){if(D.type!=="Block"||D.start<s||D.end>b)continue;let v=o.slice(D.start,D.end);T.push({end:D.end,isJsDoc:v.startsWith("/**")&&v.length>4,text:v})}}function Nt(e,o,s){if(!e||typeof e!=="object"||!("type"in e))return;let b=e;if(b.type==="FunctionDeclaration"){if(b.id?.type==="Identifier"&&b.id.name)s.push({name:b.id.name,start:o});return}if(b.type==="VariableDeclaration"){for(let T of b.declarations??[])if(T?.id?.type==="Identifier"&&T.id.name)s.push({name:T.id.name,start:o})}}function ln(e){let o=[];for(let s of e){if(!s||typeof s!=="object"||!("type"in s))continue;let b=s;if(b.start===void 0)continue;if(b.type==="ExportNamedDeclaration"&&b.declaration)Nt(b.declaration,b.start,o);else Nt(b,b.start,o)}return o}function dn(e,o,s){let b;for(let T of e){if(T.end>o)break;if(!T.isJsDoc)continue;if(!Y.test(s.slice(T.end,o)))continue;b=T}return b}function Lt(e,o){let s=new Map;if(!e.source)return s;let b=[e.parsed?.module,e.parsed?.instance],T=[],D=[],v=e.parsed?.comments??[];for(let E of b){let N=E?.content;if(!N?.body||N.start===void 0||N.end===void 0)continue;pn(v,e.source,N.start,N.end,T),D.push(...ln(N.body))}T.sort((E,N)=>E.end-N.end);for(let E of D){let N=dn(T,E.start,e.source);if(!N)continue;let W=Z(e,N.text),{type:F,description:U,ignore:Se,internal:Ce}=L(W);if(Se.length>0)d(e,"context-any-type",E.name,Se);if(!F)continue;s.set(E.name,{type:o.aliasType(F.type),description:U||F.description,internal:Ce||void 0})}return s}function wt(e){if(e==="var")return"let";if(e==="using"||e==="await using")return"const";return e}var un=null,At=/^@component/,mn=/\r/g,fn=/^\{\s*\}$/,yn=new Set(["AssignmentExpression","UpdateExpression","CallExpression","SpreadAttribute","FunctionDeclaration","ImportDeclaration","VariableDeclaration","ExportNamedDeclaration","Comment","SlotElement","RenderTag","OnDirective","BindDirective"]);class i{ctx=et();static mapToArray(e){return Array.from(e,([o,s])=>s)}static getStaticAttributeValue(e){if(!Array.isArray(e.value))return;return e.value.map((o)=>o.data??o.raw??"").join("").trim()}resolveScriptLanguage(e){let o=[e.instance,e.module].filter((b)=>b!==void 0),s=!1;for(let b of o){let T=b.attributes?.find((v)=>v.name==="lang");if(!T){s=!0;continue}if(i.getStaticAttributeValue(T)?.toLowerCase()==="ts")return"ts"}return s?"js":void 0}resolveScriptGenericsAttribute(e){let o=e.instance?.attributes?.find((v)=>v.name==="generics");if(!o)return;let s=t(this.ctx,o),b=e.instance?.attributes?.find((v)=>v.name==="lang");if((b?i.getStaticAttributeValue(b)?.toLowerCase():void 0)!=="ts"){n(this.ctx,"syntax-skipped","generics",'<script generics="..."> requires lang="ts"; the generics attribute was ignored because the script is not TypeScript.',s);return}let D=i.getStaticAttributeValue(o);if(!D)return;return{value:D,source:s}}resolvePublicPropName(e){return this.ctx.propLocalToPublicName.get(e)??e}trackPropLocalName(e,o=e){this.ctx.propLocalToPublicName.set(o,e)}getPropByLocalOrPublic(e){return this.ctx.props.get(this.resolvePublicPropName(e))}getPropTypeByLocalOrPublic(e){return this.getPropByLocalOrPublic(e)?.type}getExplicitPropType(e){return this.ctx.explicitPropTypesByName.get(e)}getPropertyName(e){if(!e||typeof e!=="object"||!("type"in e))return;if(a(e))return e.name;if(l(e))return e.value==null?void 0:String(e.value);return}isNumericConstant(e){if(!e||typeof e!=="object"||!("type"in e))return!1;if(e.type!=="MemberExpression")return!1;let o=e,s=o.object&&"name"in o.object?o.object.name:void 0,b=o.property&&"name"in o.property?o.property.name:void 0;if(!s||!b)return!1;if(s==="Number")return["POSITIVE_INFINITY","NEGATIVE_INFINITY","MAX_VALUE","MIN_VALUE","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","EPSILON","NaN"].includes(b);if(s==="Math")return["PI","E","LN2","LN10","LOG2E","LOG10E","SQRT2","SQRT1_2"].includes(b);return!1}resolveLocalVarJSDoc(e){for(let s of this.ctx.vars)if(s.declarations.some((T)=>T.id&&typeof T.id==="object"&&("type"in T.id)&&T.id.type==="Identifier"&&("name"in T.id)&&T.id.name===e))return g(this.ctx,this,s);let o=this.ctx.funcDecls.get(e);if(o)return g(this.ctx,this,o);return}addModuleExport(e,o){if(u(e)===void 0)return;if(this.ctx.moduleExports.has(e)){let s=this.ctx.moduleExports.get(e);this.ctx.moduleExports.set(e,{...s,...o})}else this.ctx.moduleExports.set(e,o)}aliasType(e){if(e==="*")return"any";return e.trim()}findVariableTypeAndDescription(e){let o=this.getPropByLocalOrPublic(e);if(o?.type)return{type:o.type,description:o.description,internal:o.internal};if(!this.ctx.variableInfoCacheBuilt)this.ctx.variableInfoCache=Lt(this.ctx,this),this.ctx.variableInfoCacheBuilt=!0;let s=this.ctx.variableInfoCache.get(e),b=this.ctx.explicitVariableTypesByName.get(e);if(b)return{type:b,description:s?.description,internal:s?.internal};return s??null}accumulateGeneric(e,o){if(this.ctx.generics)this.ctx.generics=[`${this.ctx.generics[0]}, ${e}`,`${this.ctx.generics[1]}, ${o}`];else this.ctx.generics=[e,o]}cleanup(){this.ctx=et()}static SCRIPT_BLOCK_REGEX=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi;static TS_DIRECTIVE_REGEX=/\/\/\s*@ts-[^\n\r]*/g;static stripTypeScriptDirectivesFromScripts(e){if(!e.includes("@ts-"))return e;return i.SCRIPT_BLOCK_REGEX.lastIndex=0,e.replace(i.SCRIPT_BLOCK_REGEX,(o,s,b,T)=>{i.TS_DIRECTIVE_REGEX.lastIndex=0;let D=b.replace(i.TS_DIRECTIVE_REGEX,"");return s+D+T})}parseSvelteComponent(e,o){this.cleanup(),this.ctx.componentFilePath=o.filePath;let s=i.stripTypeScriptDirectivesFromScripts(e);this.ctx.source=s;let b=P(s);if(Pt(this,this.ctx,b),this.ctx.parsed=b,this.ctx.scriptLanguage==="ts")qe(this.ctx.parsed.module),qe(this.ctx.parsed.instance),qe(this.ctx.parsed.fragment);this.ctx.syntaxMode=Et(this.ctx);let T=this.ctx.parsed.css,D=T?.start!==void 0&&T?.end!==void 0?s.slice(0,T.start)+" ".repeat(T.end-T.start)+s.slice(T.end):s;lt(this.ctx,this.ctx.parsed?.module),lt(this.ctx,this.ctx.parsed?.instance),Te(this.ctx,this,D);let v={type:"ComponentRoot",instance:this.ctx.parsed.instance,fragment:this.ctx.parsed.fragment};if(this.ctx.parsed?.module)it(this.ctx.parsed?.module,(S)=>{if(S.type==="ImportDeclaration")Ye(this.ctx,S);if(S.type==="FunctionDeclaration"){let k=S;if(k.id?.name)this.ctx.funcDecls.set(k.id.name,k)}if(S.type==="VariableDeclaration")this.ctx.vars.add(S);if(S.type==="ExportNamedDeclaration"){if(S.declaration==null&&S.specifiers.length===0)return;let k,A=!1;if(S.declaration==null&&S.specifiers[0]?.type==="ExportSpecifier"){let w=S.specifiers[0],_=w.local&&typeof w.local==="object"&&"name"in w.local?w.local.name:void 0,B=w.exported&&typeof w.exported==="object"&&"name"in w.exported?w.exported.name:void 0;if(!_||!B)return;let K;for(let H of Array.from(this.ctx.vars))if(H.declarations.some((j)=>j.id&&typeof j.id==="object"&&("type"in j.id)&&j.id.type==="Identifier"&&j.id.name===_)){K=H;break}if(!K){let H="source"in S&&S.source&&typeof S.source==="object"&&"value"in S.source?S.source.value:void 0,j=typeof H==="string"?`it re-exports from "${H}"`:this.ctx.valueImportBindingsByLocalName.has(_)?"it re-exports an imported binding":"no matching local declaration was found";n(this.ctx,"export-unresolved",B,`export "${B}" was skipped because ${j}; sveld only resolves exports of a local declaration.`,t(this.ctx,S));return}S.declaration=K,k=B,A=!0}if(S.declaration==null)return;if(!S.declaration||typeof S.declaration!=="object"||!("type"in S.declaration))return;let O=[];if(S.declaration.type==="FunctionDeclaration"){let w=S.declaration;if(!w.id?.name)return;let _=this.ctx.scriptLanguage==="ts"?X(this.ctx,w):void 0;O.push({prop_name:w.id.name,kind:"function",isFunctionDeclaration:!0,value:void 0,typeSeed:_?.hasAnnotations?void 0:"() => any",explicitType:_?.hasAnnotations?_.signature:void 0,initializerIsFunction:!0,defaultValue:void 0,inferredTypeForSource:void 0,resolvedJSDoc:void 0})}else if(S.declaration.type==="VariableDeclaration"){let w=S.declaration,_=wt(w.kind),B=A?w.declarations.slice(0,1):w.declarations;for(let K of B){if(!K||typeof K!=="object"||!("id"in K))continue;let{id:H,init:j}=K;if(!H||typeof H!=="object"||!("name"in H))continue;let q=H.name,te=k??q,se=j==null?{isFunction:!1}:m(this,this.ctx,j),{value:be,type:De,isFunction:ee,defaultValue:Ne}=se,Me=se;if(Me.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:q,location:"moduleExports",...Me.pendingCallDefault});O.push({prop_name:te,kind:_,isFunctionDeclaration:!1,value:be,typeSeed:De,explicitType:this.getExplicitPropType(q),initializerIsFunction:ee,defaultValue:Ne,inferredTypeForSource:De,resolvedJSDoc:Me})}if(O.length===0)return}else return;let J=g(this.ctx,this,S);for(let{prop_name:w,kind:_,isFunctionDeclaration:B,value:K,typeSeed:H,explicitType:j,initializerIsFunction:q,defaultValue:te,inferredTypeForSource:se,resolvedJSDoc:be}of O){let{type:De,typeSource:ee,description:Ne,params:Me,returnType:Le,isFunction:ke}=Ve({explicitType:j,typeSeed:H,inferredTypeForSource:se,jsdocType:J?.type,jsdocDescription:J?.description,jsdocParams:J?.params,jsdocReturnType:J?.returnType,resolvedType:be?.resolvedType,resolvedDescription:be?.resolvedDescription,resolvedParams:be?.resolvedParams,resolvedReturnType:be?.resolvedReturnType,initializerIsFunction:q,isFunctionDeclaration:B,typedefs:this.ctx.typedefs});this.addModuleExport(w,{name:w,kind:_,description:Ne,deprecated:J?.deprecated,tags:J?.tags,...J?.internal?{internal:!0}:{},type:De,typeSource:ee,value:K,defaultValue:te,params:Me,returnType:Le,isFunction:ke,isFunctionDeclaration:B,isRequired:!1,constant:_==="const",reactive:!1,source:t(this.ctx,S)})}}});let E,N,W,F=new Set,U=new Set,Se=[];yt(this,this.ctx),this.ctx.activeScopes.push(this.ctx.componentScope);let Ce=gt(this.ctx);if(it(v,(S,k,A)=>{let O=bt(this,this.ctx,Ce,S);if(O)this.ctx.activeScopes.push(O);let J=S.type;if(!yn.has(J))return;if(S.type==="AssignmentExpression")nt(this.ctx,S.left);if(S.type==="UpdateExpression")nt(this.ctx,S.argument);if(S.type==="CallExpression"){let w=S,_=w.callee&&typeof w.callee==="object"&&"name"in w.callee?w.callee.name:void 0;if(_==="createEventDispatcher"){if(k&&typeof k==="object"&&"id"in k&&k.id&&typeof k.id==="object"&&"name"in k.id)E=k.id.name,N=k;W=w.typeArguments?.params?.[0]}if(_==="$host"){if(k&&typeof k==="object"&&"id"in k&&k.id&&typeof k.id==="object"&&"name"in k.id)F.add(k.id.name)}if(_==="setContext")ae(this.ctx,this,S,k??void 0);if(_)Se.push({name:_,arguments:w.arguments,node:w});if(ne(w.callee)&&a(w.callee.property)&&w.callee.property.name==="dispatchEvent"&&(p(w.callee.object,"$host")||a(w.callee.object)&&F.has(w.callee.object.name))){let B=ue(this.ctx,w);if(B)U.add(B)}}if(J==="SpreadAttribute"){let w=S;if(w.expression?.name==="$$restProps"||this.ctx.restPropLocals.has(w.expression?.name??""))mt(this.ctx,k)}if(S.type==="FunctionDeclaration"){let w=S;if(w.id?.name)this.ctx.funcDecls.set(w.id.name,w)}if(S.type==="ImportDeclaration")Ye(this.ctx,S);if(S.type==="VariableDeclaration"){if(this.ctx.vars.add(S),k&&typeof k==="object"&&"type"in k&&k.type==="Program"&&S.declarations.some((w)=>p(f(w.init),"$props")))vt(this,this.ctx,S)}if(S.type==="ExportNamedDeclaration"){if(S.declaration==null&&S.specifiers.length===0)return;let w,_=!1;if(S.declaration==null&&S.specifiers[0]?.type==="ExportSpecifier"){let H=S.specifiers[0],j=H.local&&typeof H.local==="object"&&"name"in H.local?H.local.name:void 0,q=H.exported&&typeof H.exported==="object"&&"name"in H.exported?H.exported.name:void 0;if(!j||!q)return;let te;for(let se of Array.from(this.ctx.vars))if(se.declarations.some((be)=>be.id&&typeof be.id==="object"&&("type"in be.id)&&be.id.type==="Identifier"&&be.id.name===j)){te=se;break}if(S.declaration=te,w=q,_=!0,!te){let se="source"in S&&S.source&&typeof S.source==="object"&&"value"in S.source?S.source.value:void 0,be=typeof se==="string"?`it re-exports from "${se}"`:this.ctx.valueImportBindingsByLocalName.has(j)?"it re-exports an imported binding":"no matching local declaration was found";n(this.ctx,"export-unresolved",q,`export "${q}" was skipped because ${be}; sveld only resolves exports of a local declaration.`,t(this.ctx,S));return}}if(S.declaration==null)return;if(!S.declaration||typeof S.declaration!=="object"||!("type"in S.declaration))return;let B=[];if(S.declaration.type==="FunctionDeclaration"){let H=S.declaration;if(!H.id?.name)return;w??=H.id.name;let j=this.ctx.scriptLanguage==="ts"?X(this.ctx,H):void 0;B.push({prop_name:w,kind:"function",isFunctionDeclaration:!0,value:void 0,typeSeed:j?.hasAnnotations?void 0:"() => any",explicitType:j?.hasAnnotations?j.signature:void 0,initializerIsFunction:!0,isRequired:!1,localName:H.id.name,defaultValue:void 0,inferredTypeForSource:void 0,resolvedJSDoc:void 0})}else if(S.declaration.type==="VariableDeclaration"){let H=S.declaration,j=wt(H.kind),q=_?H.declarations.slice(0,1):H.declarations;for(let te of q){if(!te||typeof te!=="object"||!("id"in te))continue;let{id:se,init:be}=te;if(!se||typeof se!=="object"||!("name"in se))continue;let De=se.name,ee=w??De,Ne=j==="let"&&be==null,Me=be==null?{isFunction:!1}:m(this,this.ctx,be),{value:Le,type:ke,isFunction:Qe,defaultValue:Ze}=Me,Fe=Me;if(Fe.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:ee,location:"props",...Fe.pendingCallDefault});B.push({prop_name:ee,kind:j,isFunctionDeclaration:!1,value:Le,typeSeed:ke,explicitType:this.getExplicitPropType(De),initializerIsFunction:Qe,isRequired:Ne,localName:De,defaultValue:Ze,inferredTypeForSource:ke,resolvedJSDoc:Fe})}if(B.length===0)return}else return;let K=g(this.ctx,this,S);for(let{prop_name:H,kind:j,isFunctionDeclaration:q,value:te,typeSeed:se,explicitType:be,initializerIsFunction:De,isRequired:ee,localName:Ne,defaultValue:Me,inferredTypeForSource:Le,resolvedJSDoc:ke}of B){let{type:Qe,typeSource:Ze,description:Fe,params:Rt,returnType:It,isFunction:_t}=Ve({explicitType:be,typeSeed:se,inferredTypeForSource:Le,jsdocType:K?.type,jsdocDescription:K?.description,jsdocParams:K?.params,jsdocReturnType:K?.returnType,resolvedType:ke?.resolvedType,resolvedDescription:ke?.resolvedDescription,resolvedParams:ke?.resolvedParams,resolvedReturnType:ke?.resolvedReturnType,initializerIsFunction:De,isFunctionDeclaration:q,typedefs:this.ctx.typedefs});d(this.ctx,"prop-unknown-type",H,K?.sveldIgnore),I(this,this.ctx,H,{name:H,...Ne!==void 0&&Ne!==H?{localName:Ne}:{},kind:j,description:Fe,binding:K?.binding,deprecated:K?.deprecated,tags:K?.tags,...K?.internal?{internal:!0}:{},type:Qe,typeSource:Ze,value:te,defaultValue:Me,params:Rt,returnType:It,isFunction:_t,isFunctionDeclaration:q,isRequired:ee,constant:j==="const",reactive:this.ctx.reactive_vars.has(H),source:t(this.ctx,S)})}}if(J==="Comment"){let _=S?.data?.trim()??"";if(At.test(_))this.ctx.componentComment=_.replace(At,"").replace(mn,""),this.ctx.componentCommentSource=t(this.ctx,S)}if(J==="SlotElement"){let w=S,_=w.attributes?.find((j)=>j.name==="name")?.value,B=(Array.isArray(_)?_[0]:void 0)?.data,K=(w.attributes||[]).filter((j)=>j.name!=="name").reduce((j,q)=>{let te={value:void 0,replace:!1},se=q.value;if(se===void 0||se===!0)return j;let be=Array.isArray(se)?se[0]:se;if(be){let{type:De,expression:ee,raw:Ne,start:Me,end:Le}=be;if(De==="Text"&&Ne!==void 0)te.value=JSON.stringify(Ne);else if(!Array.isArray(se)&&De==="ExpressionTag"&&ee&&typeof ee==="object"&&"type"in ee&&ee.type==="Identifier"&&"name"in ee&&ee.name===q.name)te.value=ee.name,te.replace=!0;if(ee&&typeof ee==="object"&&"type"in ee){if(ee.type==="Literal"&&"value"in ee){let ke=ee.value;te.value=typeof ke==="string"?JSON.stringify(ke):String(ke)}else if(ee.type==="MemberExpression")te.value=M(this.ctx,this,ee);else if(ee.type!=="Identifier"){if(Me!==void 0&&Le!==void 0){if(ee.type==="ObjectExpression"||ee.type==="TemplateLiteral")te.value=r(this.ctx,Me+1,Le-1)}}}}if(q.name)j[q.name]=te;return j},{}),H=w.fragment?.nodes?.map(({start:j,end:q})=>{if(j===void 0||q===void 0)return"";return r(this.ctx,j,q)??""}).join("").trim();R(this.ctx,{slot_name:B,slot_props:K,slot_fallback:H,source:t(this.ctx,S)})}if(J==="RenderTag"){let w=S,_=ye(this.ctx,w.expression);if(_){let B,K=!1;if(_.arguments.length===0)B={};else if(_.arguments.length===1&&typeof _.arguments[0]==="object"&&_.arguments[0]&&"type"in _.arguments[0]&&_.arguments[0].type==="ObjectExpression"){let q=Q(this.ctx,this,_.arguments[0]);B=q.slot_props,K=q.hasUnresolvedSpread}else if(_.arguments.length===1)n(this.ctx,"syntax-skipped",_.publicName,`{@render ${_.publicName}(...)} argument is not a plain object literal; the render call was not mapped to slot metadata.`,t(this.ctx,S));let H=_.publicName==="children"?void 0:_.publicName,j=H===void 0?un:H;if(B!==void 0)R(this.ctx,{slot_name:H,slot_props:B,slot_props_unresolved_spread:K||void 0,source:t(this.ctx,S)});if(B!==void 0||this.ctx.slots.has(j))this.ctx.snippetPropLocals.add(_.trackingName)}}if(J==="OnDirective"){let w=S;if(w.expression==null&&w.name){if(k!=null&&typeof k==="object"&&"name"in k){let _=typeof k.name==="string"?k.name:void 0,B="type"in k?String(k.type):void 0;if(_&&B){let K=je(B)?{type:"InlineComponent",name:_}:{type:"Element",name:_};this.ctx.forwardedEvents.set(w.name,K);let H=this.ctx.events.get(w.name),j=this.ctx.eventDescriptions.get(w.name),q=H?.deprecated,te=H?.internal;if(!H)this.ctx.events.set(w.name,{type:"forwarded",name:w.name,element:K,description:j,deprecated:q,...te?{internal:!0}:{},source:t(this.ctx,S)});else if(H.type==="forwarded"&&j&&!H.description)this.ctx.events.set(w.name,{...H,description:j,deprecated:H.deprecated??q,...H.internal||te?{internal:!0}:{},source:H.source||t(this.ctx,S)})}}}}if(J==="BindDirective"&&k&&typeof k==="object"&&"type"in k&&(Be(String(k.type))||je(String(k.type)))){let w=S;if(w.expression?.name){let _=Oe(this.ctx,w.expression.name);if(_)this.ctx.reactive_vars.add(_)}if(Be(String(k.type))&&w.name==="this"&&w.expression?.name&&"name"in k&&typeof k.name==="string"){let _=Oe(this.ctx,w.expression.name);if(!_)return;let B=k.name;if(this.ctx.bindings.has(_)){let K=this.ctx.bindings.get(_);if(K&&!K.elements.includes(B))this.ctx.bindings.set(_,{...K,elements:[...K.elements,B]})}else this.ctx.bindings.set(_,{elements:[B]})}}},(S)=>{if($e(S))this.ctx.activeScopes.pop(),Tt(Ce,S)},{skipTypeOnlySubtrees:!0}),E!==void 0){Ct(this,this.ctx,W,E,t(this.ctx,N));for(let S of Se)if(S.name===E){let k=S.arguments[0],A=k&&typeof k==="object"&&"value"in k?k.value:void 0,O=S.arguments[1],J=ce(this,O),w=J===void 0&&O&&typeof O==="object"&&"value"in O?O.value:void 0;if(A!=null)h(this.ctx,{name:String(A),detail:J??(w==null?"":G(w)),has_argument:Boolean(O),source:t(this.ctx,S.node)})}}let Pe=new Set(U);if(E!==void 0){for(let S of Se)if(S.name===E){let k=S.arguments[0],A=k&&typeof k==="object"&&"value"in k?k.value:void 0;if(A!=null)Pe.add(String(A))}}this.ctx.forwardedEvents.forEach((S,k)=>{let A=this.ctx.events.get(k);if(A&&A.type==="dispatched"&&!Pe.has(k)){let O=this.ctx.eventDescriptions.get(k),J={type:"forwarded",name:k,element:S,description:O,deprecated:A.deprecated,tags:A.tags,source:A.source};if(A.internal)J.internal=!0;if(A.detail!==void 0&&A.detail!=="undefined")J.detail=A.detail;this.ctx.events.set(k,J)}}),Dt(this.ctx,Pe);let Re=this.ctx.syntaxMode==="runes"?new Set(Array.from(this.ctx.snippetPropLocals,(S)=>this.resolvePublicPropName(S))):new Set,we=i.mapToArray(this.ctx.props).filter((S)=>!Re.has(S.name)).map((S)=>{if(this.ctx.bindings.has(S.name)){let k=this.ctx.bindings.get(S.name)?.elements.sort().map((A)=>ut(A)).join(" | ");return{...S,type:`null | ${k}`,typeSource:"inferred",reactive:S.reactive||this.ctx.reactive_vars.has(S.name)}}return{...S,reactive:S.reactive||this.ctx.reactive_vars.has(S.name)}});this.ctx.activeScopes.length=0;let Ie=i.mapToArray(this.ctx.slots).map((S)=>{let{slot_props_unresolved_spread:k,...A}=S;if(!S.slot_props)return A;if(typeof S.slot_props==="string")return fn.test(S.slot_props)?{...A,slot_props:"Record<string, never>"}:A;let O=S.slot_props,J=[];for(let B of Object.keys(O)){if(O[B].replace&&O[B].value!==void 0)O[B].value=this.getPropTypeByLocalOrPublic(O[B].value);if(O[B].value===void 0)O[B].value="any";J.push(`${B}: ${O[B].value}`)}let w=k?" & Record<string, any>":"",_=J.length===0?k?"Record<string, any>":"Record<string, never>":J.length===1?`{ ${J[0]} }${w}`:`{
|
|
2
|
-
${J.join(`;
|
|
3
|
-
`)};
|
|
4
|
-
}${w}`;return{...A,slot_props:_}}).sort((S,k)=>{let A=S.name??"",O=k.name??"";if(A<O)return-1;if(A>O)return 1;return 0});if(this.ctx.deferredSlotBlockGenerics.length>0){let S=[...we.map((k)=>k.type??""),...Ie.map((k)=>k.slot_props??"")].join(`
|
|
5
|
-
`);for(let{name:k,constraint:A}of this.ctx.deferredSlotBlockGenerics){let O=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!new RegExp(`\\b${O}\\b`).test(S))continue;this.accumulateGeneric(k,A)}}if(this.ctx.scriptGenericsAttribute){if(this.ctx.generics)n(this.ctx,"syntax-skipped","generics",'Both the "generics" script attribute and @generics/@template JSDoc tags declare component generics; the script attribute takes precedence and the JSDoc declaration was ignored.',this.ctx.scriptGenericsAttribute.source);this.ctx.generics=he(this.ctx.scriptGenericsAttribute.value)}let _e=i.mapToArray(this.ctx.moduleExports),Ge=i.mapToArray(this.ctx.events).map((S)=>{switch(S.type){case"forwarded":return{...S,element:S.element.name};case"dispatched":return S;default:return S}}).sort((S,k)=>{let A=S.name.localeCompare(k.name);if(A!==0)return A;let O=S.type.localeCompare(k.type);if(O!==0)return O;if(S.type==="forwarded"&&k.type==="forwarded"){let J=S.element.localeCompare(k.element);if(J!==0)return J}return(S.detail??"").localeCompare(k.detail??"")}),He=i.mapToArray(this.ctx.typedefs),We=i.mapToArray(this.ctx.contexts),Je={props:new Map(this.ctx.pendingCallDefaultCandidates.filter((S)=>S.location==="props").map((S)=>[S.propName,S])),moduleExports:new Map(this.ctx.pendingCallDefaultCandidates.filter((S)=>S.location==="moduleExports").map((S)=>[S.propName,S]))};for(let S of we)if(S.typeSource==="unknown"){let k=Je.props.get(S.name);if(k)S.type="any";let A=k?k.importSource?`Prop "${S.name}" default calls "${k.calleeName}()" imported from "${k.importSource}"; falling back to "any" pending cross-file resolution.`:`Prop "${S.name}" default calls "${k.calleeName}()", but its return type could not be inferred; falling back to "any".`:`Prop "${S.name}" type could not be inferred; falling back to "${S.type??"any"}".`;n(this.ctx,"prop-unknown-type",S.name,A,S.source)}for(let S of _e)if(S.typeSource==="unknown"&&Je.moduleExports.has(S.name))S.type="any";for(let S of this.ctx.jsDocEventNames){if(Pe.has(S))continue;if(this.ctx.forwardedEvents.has(S))continue;if(this.ctx.props.has(`on${S}`))continue;n(this.ctx,"event-no-source",S,`@event "${S}" has no matching dispatch or callback prop.`,this.ctx.jsDocEventSources.get(S))}if(this.ctx.rest_props?.type==="InlineComponent")n(this.ctx,"rest-props-unresolved","$$restProps",`$$restProps is only spread onto component "${this.ctx.rest_props.name}"; sveld cannot infer its rest-prop type. Spread onto a plain element or add an @restProps tag.`);let Ke=He.filter((S)=>S.internal).map((S)=>S.name.split("<")[0]);if(Ke.length>0){let S=Ke.map((A)=>({name:A,regex:new RegExp(`\\b${A}\\b`)})),k=(A,O,J)=>{if(!O)return;for(let{name:w,regex:_}of S){if(!_.test(O))continue;n(this.ctx,"internal-typedef-referenced",A,`"${A}" references "${w}", which is @internal and excluded from output; the generated .d.ts will contain a dangling reference to it.`,J)}};for(let A of we){if(A.internal)continue;k(A.name,A.type,A.source)}for(let A of _e){if(A.internal)continue;k(A.name,A.type,A.source)}for(let A of He){if(A.internal)continue;k(A.name,A.ts)}for(let A of Ge){if(A.internal||A.type!=="dispatched")continue;k(A.name,A.detail,A.source)}for(let A of Ie){if(A.internal)continue;k(A.name??"default",A.slot_props,A.source)}for(let A of We){if(A.internal)continue;for(let O of A.properties)k(O.name,O.type)}}let ze={source:V(this.ctx,0,this.ctx.source?.length),syntaxMode:this.ctx.syntaxMode,...this.ctx.scriptLanguage?{scriptLanguage:this.ctx.scriptLanguage}:{},props:we,moduleExports:_e,slots:Ie,events:Ge,typedefs:He,generics:this.ctx.generics,rest_props:this.ctx.rest_props,extends:this.ctx.extends,componentComment:this.ctx.componentComment,componentCommentSource:this.ctx.componentCommentSource,contexts:We,customElementTag:this.ctx.customElementTag,customElement:this.ctx.customElement,...this.ctx.cssParts.length>0?{cssParts:this.ctx.cssParts.slice()}:{},...this.ctx.cssProperties.length>0?{cssProperties:this.ctx.cssProperties.slice()}:{},diagnostics:this.ctx.diagnosticRecords.slice()},Xe=me(this.ctx);if(Xe)ze[y]=Xe;return ze}}
|
|
6
|
-
export{i};
|