sveld 0.37.3 → 0.37.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/lib/browser.d.ts +32 -4
- package/lib/browser.js +150 -136
- package/lib/chunk-49hdrj4n.js +6 -0
- package/lib/chunk-7e36grhy.js +1 -0
- package/lib/{chunk-m2bfvdte.js → chunk-nxa0q3f3.js} +5 -5
- package/lib/chunk-rftengvg.js +331 -0
- package/lib/chunk-w37f2cq2.js +1 -0
- package/lib/{chunk-s4f6b34h.js → chunk-yzb9k33r.js} +1 -1
- package/lib/cli-entry.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/schema/component-api.schema.json +20 -1
- package/lib/chunk-ag202nwj.js +0 -317
- package/lib/chunk-n14td14g.js +0 -1
- package/lib/chunk-te52wx32.js +0 -1
- package/lib/chunk-v4be4g6y.js +0 -6
package/lib/chunk-n14td14g.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i}from"./chunk-v4be4g6y.js";export{i as default};
|
package/lib/chunk-te52wx32.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T,A}from"./chunk-ag202nwj.js";export{T as TemplateParseNotImplementedError,A as parse};
|
package/lib/chunk-v4be4g6y.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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};
|