sveld 0.36.11 → 0.37.0
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 +522 -66
- package/lib/browser.d.ts +121 -2
- package/lib/browser.js +160 -139
- package/lib/{chunk-3a9n8agv.js → chunk-550yx3gf.js} +9 -9
- package/lib/chunk-6n4d12tf.js +1 -0
- package/lib/chunk-74rbv9gf.js +1 -0
- package/lib/chunk-eybp3ae7.js +6 -0
- package/lib/chunk-jtm65qmd.js +300 -0
- package/lib/chunk-s1v2vjye.js +7 -0
- package/lib/cli-entry.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +5 -3
- package/schema/component-api.schema.json +431 -0
- package/lib/chunk-04eb8yj0.js +0 -245
- package/lib/chunk-5b7hj275.js +0 -7
- package/lib/chunk-e1e89j27.js +0 -1
- package/lib/chunk-ncw3wbrj.js +0 -6
- package/lib/chunk-qnj6xmb6.js +0 -7
- package/lib/chunk-wq8f3w8t.js +0 -1
package/lib/chunk-5b7hj275.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{f,X,x,u,Q,d,m,Y,T,N,h,I,n,e,p,A,y,Z,K,F,v,ee,V,te,re,L,ne,l,ie,se,oe,w,ae,ce,_,U,R,g,ue,pe}from"./chunk-04eb8yj0.js";import{q}from"./chunk-qnj6xmb6.js";var ot={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 Ct(t){return t in ot}function it(t){if(Ct(t))return ot[t];return"HTMLElement"}function Ze(){return{syntaxMode:"legacy",scriptLanguage:void 0,source:void 0,parsed:void 0,runesOptionOverride:void 0,sourceLineStartOffsetsCache:void 0,rest_props:void 0,extends:void 0,customElementTag: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,wholePropsLocals:new Set,restPropLocals:new Set,componentScope:new Map,scopeDeclarations:new WeakMap,activeScopes:[],slots:new Map,snippetPropLocals:new Set,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}}var Dt=new Set(["Component","SvelteComponent","SvelteSelf"]),kt=new Set(["RegularElement","SvelteElement"]);function je(t){return Dt.has(t)}function _e(t){return kt.has(t)}function Lt({hasTypeScriptType:t,hasJSDocType:r,inferredType:o,finalType:a}){if(t)return"typescript";if(r)return"jsdoc";if(o!==void 0)return"default";if(a!==void 0)return"inferred";return"unknown"}function Fe(t){let r=t.explicitType??t.jsdocType??t.resolvedType??t.typeSeed,o=t.jsdocParams??t.resolvedParams,a=t.jsdocReturnType??t.resolvedReturnType;if(t.isFunctionDeclaration&&r==="() => any"&&a)r=o&&o.length>0?`(${o.map((E)=>`${E.name}${E.optional?"?":""}: ${E.type}`).join(", ")}) => ${a}`:`() => ${a}`;let s=t.jsdocDescription??t.resolvedDescription;if(s===void 0&&r!==void 0)s=t.typedefs?.get(r)?.description;let P=Lt({hasTypeScriptType:t.explicitType!==void 0,hasJSDocType:t.jsdocType!==void 0||t.jsdocParams!==void 0||t.jsdocReturnType!==void 0||t.resolvedType!==void 0,inferredType:t.inferredTypeForSource,finalType:r}),S=t.initializerIsFunction||t.isFunctionDeclaration||t.inferIsFunctionFromTypeSignature===!0&&(!!t.jsdocParams?.length||t.jsdocReturnType!==void 0||!!t.jsdocType?.includes("=>")||!!t.resolvedType?.includes("=>")||!!t.explicitType?.includes("=>"));return{type:r,typeSource:P,description:s,params:o,returnType:a,isFunction:S}}function Nt(t){if(!t||typeof t!=="object"||!("type"in t))return;let r=String(t.type),o=je(r);if(!o&&!_e(r))return;let a="name"in t&&typeof t.name==="string"?t.name:void 0;if(!a)return;let s=o?{type:"InlineComponent",name:a}:{type:"Element",name:a};if(a==="svelte:element"&&"tag"in t&&t.tag&&typeof t.tag==="object"){let P=t.tag;if(P.type==="Literal"&&typeof P.value==="string")s.thisValue=P.value}return s}function at(t,r){if(t.rest_props!==void 0)return;let o=Nt(r);if(o)t.rest_props=o}function ge(t,r,o){if(!r||t.has(r))return;t.set(r,o)}function Be(t,r){for(let o=t.activeScopes.length-1;o>=0;o-=1){let a=t.activeScopes[o]?.get(r);if(!a)continue;return a.kind==="prop"?a.publicPropName:void 0}return}function ye(t,r=new Set){if(!t||typeof t!=="object"||!("type"in t))return r;switch(t.type){case"Identifier":r.add(t.name);break;case"AssignmentPattern":ye(t.left,r);break;case"ArrayPattern":for(let o of t.elements)ye(o??void 0,r);break;case"ObjectPattern":for(let o of t.properties)if(o.type==="Property")ye(o.value,r);else if(o.type==="RestElement")ye(o.argument,r);break;case"RestElement":ye(t.argument,r);break}return r}function tt(t,r){if(!r||typeof r!=="object"||!("type"in r))return;if(r.type==="Identifier"){let a=Be(t,r.name);if(a)t.reactive_vars.add(a);return}let o=ye(r);for(let a of o){let s=Be(t,a);if(s)t.reactive_vars.add(s)}}function Re(t){if(!t||typeof t!=="object"||!("type"in t))return!1;switch(String(t.type)){case"BlockStatement":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"EachBlock":case"AwaitBlock":return!0;default:return!1}}function st(t){if(!t||typeof t!=="object"||!("type"in t))return!1;let r=String(t.type);return r==="FunctionDeclaration"||r==="FunctionExpression"||r==="ArrowFunctionExpression"}function wt(t,r){let o=t.scopeDeclarations.get(r);if(!o)o=new Map,t.scopeDeclarations.set(r,o);return o}function Rt(t,r,o){let a=[];if(o.id.type==="Identifier")return a.push({kind:"local",name:o.id.name}),a;if(o.id.type!=="ObjectPattern")return a;for(let s of o.id.properties){if(s.type==="RestElement"){if(s.argument.type==="Identifier")a.push({kind:"local",name:s.argument.name});continue}if(s.computed)continue;let P=t.getPropertyName(s.key);if(!P)continue;let S;if(s.value.type==="Identifier")S=s.value.name;else if(s.value.type==="AssignmentPattern"&&s.value.left.type==="Identifier")S=s.value.left.name;if(!S)continue;a.push({kind:"prop",name:S,publicPropName:P})}return a}function et(t,r,o,a,s){if(!X(r))return;let P=s?.allowRunesProps??!1,S=s?.forceProp??!1,E=r;for(let M of E.declarations){if(P&&d(m(M.init),"$props")){for(let W of Rt(t,E,M))ge(W.kind==="prop"?o:a,W.name,W.kind==="prop"?{kind:"prop",publicPropName:W.publicPropName}:{kind:"local"});continue}let H=E.kind==="var"?a:o,j=S?"prop":"local";for(let W of ye(M.id))ge(H,W,j==="prop"?{kind:"prop",publicPropName:W}:{kind:"local"})}}function At(t,r){if("id"in t&&t.id&&typeof t.id==="object"&&"name"in t.id&&typeof t.id.name==="string")ge(r,t.id.name,{kind:"local"});for(let o of t.params)for(let a of ye(o))ge(r,a,{kind:"local"})}function It(t,r,o,a){if(!Array.isArray(r))return;for(let s of r){if(!s||typeof s!=="object"||!("type"in s))continue;switch(s.type){case"VariableDeclaration":et(t,s,o,a);break;case"FunctionDeclaration":if(s.id?.name)ge(o,s.id.name,{kind:"local"});break;case"ClassDeclaration":if(s.id?.name)ge(o,s.id.name,{kind:"local"});break}}}function Ht(t,r,o){if(!o||typeof o!=="object")return;let a="content"in o&&o.content&&typeof o.content==="object"&&"body"in o.content&&Array.isArray(o.content.body)?o.content:("body"in o)&&Array.isArray(o.body)?o:void 0;if(!a||!("body"in a)||!Array.isArray(a.body))return;for(let s of a.body){if(!s||typeof s!=="object"||!("type"in s))continue;switch(s.type){case"ImportDeclaration":for(let P of s.specifiers??[])if(P.local?.name)ge(r.componentScope,P.local.name,{kind:"local"});break;case"VariableDeclaration":et(t,s,r.componentScope,r.componentScope,{allowRunesProps:!0});break;case"FunctionDeclaration":if(s.id?.name)ge(r.componentScope,s.id.name,{kind:"local"});break;case"ClassDeclaration":if(s.id?.name)ge(r.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")et(t,s.declaration,r.componentScope,r.componentScope,{forceProp:!0});else if(s.declaration.type==="FunctionDeclaration"&&s.declaration.id?.name)ge(r.componentScope,s.declaration.id.name,{kind:"prop",publicPropName:s.declaration.id.name});break}}}function ct(t,r){r.componentScope.clear(),r.scopeDeclarations=new WeakMap,r.activeScopes.length=0,Ht(t,r,r.parsed?.instance)}function pt(t){return{varScopeStack:[t.componentScope]}}function lt(t,r,o,a){if(!Re(a))return;let s=wt(r,a),P=o.varScopeStack[o.varScopeStack.length-1]??r.componentScope;switch(String(a.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":At(a,s);break;case"BlockStatement":It(t,a.body,s,P);break;case"CatchClause":if("param"in a)for(let E of ye(a.param))ge(s,E,{kind:"local"});break;case"EachBlock":{let E=a;for(let M of ye(E.context))ge(s,M,{kind:"local"});if(typeof E.index==="string")ge(s,E.index,{kind:"local"});else if(E.index&&"name"in E.index)ge(s,E.index.name,{kind:"local"});break}case"AwaitBlock":{let E=a;for(let M of ye(E.value))ge(s,M,{kind:"local"});for(let M of ye(E.error))ge(s,M,{kind:"local"});break}}if(st(a))o.varScopeStack.push(s);return s}function dt(t,r){if(st(r))t.varScopeStack.pop()}var ft=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]);function jt(t,r){switch(r?.type){case"MemberExpression":return r.computed||t===r.object;case"MethodDefinition":return!!r.computed;case"MetaProperty":return t===r.meta;case"PropertyDefinition":return r.computed||t===r.value;case"Property":return r.computed||t===r.value;case"ExportSpecifier":case"ImportSpecifier":return t===r.local;case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return!1;default:return!0}}var _t=Array.from(ft);function ut(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95||t===36}function Ft(t){if(t.includes("\\u"))return!0;for(let r of _t){let o=t.indexOf(r);while(o!==-1){if(!ut(t.charCodeAt(o-1))&&!ut(t.charCodeAt(o+r.length)))return!0;o=t.indexOf(r,o+1)}}return!1}function Bt(t,r){for(let o=r.length-1;o>=0;o-=1)if(r[o]?.has(t))return!0;return!1}function Vt(t){let r=new Set;if(!t||typeof t!=="object"||!("type"in t))return r;switch(String(t.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":{let o=t;if(o.id?.name)r.add(o.id.name);for(let a of o.params??[])ye(a,r);break}case"BlockStatement":We(t.body,r);break;case"CatchClause":ye(t.param,r);break;case"EachBlock":{let o=t;if(ye(o.context,r),typeof o.index==="string")r.add(o.index);else if(o.index?.name)r.add(o.index.name);break}case"AwaitBlock":{let o=t;ye(o.value,r),ye(o.error,r);break}}return r}function We(t,r){if(!Array.isArray(t))return;for(let o of t){if(!o||typeof o!=="object"||!("type"in o))continue;switch(String(o.type)){case"ImportDeclaration":for(let a of o.specifiers??[])if(a.local?.name)r.add(a.local.name);break;case"VariableDeclaration":for(let a of o.declarations??[])ye(a.id,r);break;case"FunctionDeclaration":case"ClassDeclaration":{let a=o.id?.name;if(a)r.add(a);break}case"ExportNamedDeclaration":{let a=o.declaration;if(a&&typeof a==="object"&&"type"in a)We([a],r);break}}}}function nt(t,r){if(!t||typeof t!=="object")return!1;let o=[...r],a=!1;return f(t,{enter(s,P){if(a){this.skip();return}if(Re(s))o.push(Vt(s));if(P&&s.type==="Identifier"&&ft.has(s.name)&&!P.type.startsWith("TS")&&jt(s,P)&&!Bt(s.name,o))a=!0,this.skip()},leave(s){if(Re(s))o.pop()}}),a}function mt(t){if(!t||typeof t!=="object")return;if("content"in t){let r=t.content,o=r&&typeof r==="object"&&"body"in r?r.body:void 0;if(Array.isArray(o))return o}if("body"in t&&Array.isArray(t.body))return t.body;return}function yt(t){if(t.runesOptionOverride!==void 0)return t.runesOptionOverride?"runes":"legacy";let r=t.parsed;if(!r)return"legacy";if(t.source!==void 0&&!Ft(t.source))return"legacy";let o=new Set;We(mt(r.module),o);let a=new Set;return We(mt(r.instance),a),nt(r.module,[o])||nt(r.instance,[o,a])||nt(r.fragment,[o,a])?"runes":"legacy"}var Ot=/[A-Za-z_$][\w$]*/g;function $t(t,r,o){let a=new Map,s=r.typeParameters?.params,P=o.typeArguments?.params;if(!s?.length||!P?.length)return a;for(let S=0;S<s.length;S++){let E=s[S]?.name,M=P[S];if(!E||M?.start===void 0||M?.end===void 0)continue;let H=e(t,M.start,M.end)?.trim();if(H)a.set(E,H)}return a}function Gt(t,r){if(r.size===0)return t;return t.replace(Ot,(o)=>r.get(o)??o)}function Ve(t,r,o,a,s=new Set){let P=new Map;if(!o?.type)return P;let S=(E)=>{for(let M of E){if(M?.type!=="TSPropertySignature"||M.computed)continue;if(!M.key)continue;let H=t.getPropertyName(M.key);if(!H)continue;let j=M.typeAnnotation?.start,W=M.typeAnnotation?.end;if(j===void 0||W===void 0)continue;let me=e(r,j+1,W)?.trim();if(!me)continue;P.set(H,{type:me,optional:M.optional===!0,source:n(r,M)})}};switch(o.type){case"TSTypeLiteral":S(o.members??[]);break;case"TSInterfaceDeclaration":S(o.body?.body??[]);break;case"TSTypeAliasDeclaration":{let E=Ve(t,r,o.typeAnnotation,a,s);for(let[M,H]of E)P.set(M,H);break}case"TSTypeReference":{let E=re(o.typeName);if(!E||s.has(E))break;let M=a.get(E);if(!M)break;s.add(E);let H=Ve(t,r,M,a,s);s.delete(E);let j=$t(r,M,o);for(let[W,me]of H)P.set(W,j.size===0?me:{...me,type:Gt(me.type,j)});break}case"TSIntersectionType":for(let E of o.types??[]){let M=Ve(t,r,E,a,s);for(let[H,j]of M)P.set(H,j)}break;case"TSParenthesizedType":{let E=Ve(t,r,o.typeAnnotation,a,s);for(let[M,H]of E)P.set(M,H);break}}return P}function gt(t,r,o){if(r.runesPropsDeclarationMetadataByDeclaratorStart.clear(),r.explicitPropTypesByName.clear(),r.explicitVariableTypesByName.clear(),r.typeImportBindingsByLocalName.clear(),r.localTypeDeclarationsByName.clear(),r.typedRunesPropsDeclarations.length=0,!r.source)return;let a=o;r.scriptLanguage=t.resolveScriptLanguage(a),r.customElementTag=a.options?.customElement?.tag,r.runesOptionOverride=a.options?.runes,r.scriptGenericsAttribute=t.resolveScriptGenericsAttribute(a);let s=a.instance?.content?.body??[];for(let P of s){if(!P?.type)continue;if(P.type==="ImportDeclaration"&&P.source?.value)for(let S of P.specifiers??[]){let E=S.local?.name;if(!E)continue;if(!(P.importKind==="type"||S.importKind==="type"))continue;let H,j;if(S.type==="ImportSpecifier")H="named",j=S.imported?.type==="Identifier"?S.imported.name:typeof S.imported?.value==="string"?S.imported.value:void 0;else if(S.type==="ImportDefaultSpecifier")H="default";else if(S.type==="ImportNamespaceSpecifier")H="namespace";if(!H)continue;r.typeImportBindingsByLocalName.set(E,{importedName:j,localName:E,source:String(P.source.value),specifierType:H})}if((P.type==="TSInterfaceDeclaration"||P.type==="TSTypeAliasDeclaration")&&P.id?.name&&P.start!==void 0&&P.end!==void 0)r.localTypeDeclarationsByName.set(P.id.name,{code:e(r,P.start,P.end)?.trim()??"",node:P,start:P.start});if(P.type==="ExportNamedDeclaration"&&P.declaration?.type==="VariableDeclaration")for(let S of P.declaration.declarations??[]){if(S.id?.type!=="Identifier"||!S.id.name)continue;let E=L(r,S.id.typeAnnotation);if(E)r.explicitPropTypesByName.set(S.id.name,E)}else if(P.type==="VariableDeclaration")for(let S of P.declarations??[]){if(S.id?.type!=="Identifier"||!S.id.name)continue;let E=L(r,S.id.typeAnnotation);if(E)r.explicitVariableTypesByName.set(S.id.name,E)}}for(let P of s){if(!P||typeof P!=="object"||!("declarations"in P))continue;for(let S of P.declarations??[]){if(!d(m(S.init),"$props"))continue;let E=S.id?.typeAnnotation?void 0:Y(S.init),M=S.id?.typeAnnotation?.typeAnnotation??E,H=S.id?.typeAnnotation?L(r,S.id.typeAnnotation):ne(r,E),j=Ve(t,r,M,new Map(Array.from(r.localTypeDeclarationsByName.entries(),([Ee,xe])=>[Ee,xe.node]))),W=new Set,me=new Set;if(l(r,M,W,me),oe(r,W,me),S.start!==void 0){let Ee={canonicalType:H,props:j,referencedImportedTypes:W,referencedLocalTypes:me};if(r.runesPropsDeclarationMetadataByDeclaratorStart.set(S.start,Ee),H)r.typedRunesPropsDeclarations.push(Ee)}}}}function Tt(t,r,o){for(let a of o.declarations){if(!d(m(a.init),"$props"))continue;if(a.id.type==="Identifier"){r.wholePropsLocals.add(a.id.name),r.restPropLocals.add(a.id.name);let S=V(r,a.start);if(S)for(let[E,M]of S.props)A(t,r,E,{name:E,kind:"let",type:M.type,typeSource:"typescript",isFunction:!1,isFunctionDeclaration:!1,isRequired:!M.optional,constant:!1,reactive:!1,source:M.source});continue}if(a.id.type!=="ObjectPattern")continue;let s=g(r,t,o),P=a.id.properties.filter((S)=>{if(S.type!=="Property"||S.computed)return!1;if(!t.getPropertyName(S.key))return!1;if(S.value.type==="Identifier")return!0;return S.value.type==="AssignmentPattern"&&S.value.left.type==="Identifier"}).length;for(let S of a.id.properties){if(S.type==="RestElement"){if(S.argument.type==="Identifier")r.restPropLocals.add(S.argument.name);continue}let E=t.getPropertyName(S.key);if(!E)continue;let M,H;if(S.value.type==="Identifier")M=S.value.name;else{let G=S.value;M=G.left.name,H=G.right}if(!M)continue;if(t.trackPropLocalName(E,M),E==="children")r.snippetPropLocals.add(M);let j=ue(r,t,S)??(P===1?s:void 0),W=te(r,a.start,E),{init:me,bindable:Ee}=Z(H),xe=me==null?{isFunction:!1}:y(t,r,me),{value:Oe,type:Ae,isFunction:Ye,defaultValue:qe}=xe,Qe=W?.type===void 0&&j?.type===void 0?xe.resolvedType:void 0;if(xe.pendingCallDefault)r.pendingCallDefaultCandidates.push({propName:E,location:"props",...xe.pendingCallDefault});let{type:$e,typeSource:Ge,description:Ke,params:c,returnType:b,isFunction:k}=Fe({explicitType:W?.type,typeSeed:Ae,inferredTypeForSource:Ae,jsdocType:j?.type,jsdocDescription:j?.description,jsdocParams:j?.params,jsdocReturnType:j?.returnType,resolvedType:Qe,resolvedDescription:xe.resolvedDescription,resolvedParams:xe.resolvedParams,resolvedReturnType:xe.resolvedReturnType,initializerIsFunction:Ye,isFunctionDeclaration:!1,inferIsFunctionFromTypeSignature:!0});if(Ee)r.reactive_vars.add(E);A(t,r,E,{name:E,...M===E?{}:{localName:M},kind:"let",description:Ke,binding:j?.binding,deprecated:j?.deprecated,tags:j?.tags,...Ee?{bindable:!0}:{},type:$e,typeSource:Ge,value:Oe,defaultValue:qe,params:c,returnType:b,isFunction:k,isFunctionDeclaration:!1,isRequired:me==null&&W?.optional!==!0,constant:!1,reactive:Ee,source:n(r,S)})}}}function bt(t,r){if(t.syntaxMode!=="runes")return;for(let[o,a]of Array.from(t.events.entries())){if(a.type!=="dispatched")continue;if(r.has(o)||t.forwardedEvents.has(o))continue;let s=`on${o}`,P=t.props.get(s);if(!P)continue;let S=P.type!==void 0||P.params!==void 0||P.returnType!==void 0,E=a.detail===void 0||a.detail==="undefined"||a.detail==="null"?"() => void":`(detail: ${a.detail}) => void`;t.props.set(s,{...P,description:P.description??a.description,type:S?P.type:E,typeSource:S?P.typeSource:"inferred",isFunction:!0}),t.events.delete(o)}}var xt=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function Xe(t){if(!t||typeof t!=="object")return;f(t,{enter(r){if(!xt.has(r.type))return;let o=r.expression;while(o&&xt.has(o.type))o=o.expression;if(o)this.replace(o)}})}function Ue(t,r){let o=r.source?.value;if(typeof o!=="string"||r.importKind==="type")return;for(let a of r.specifiers??[]){if(a.type!=="ImportSpecifier"||a.importKind==="type")continue;let s=a.local?.name;if(!s)continue;let P=a.imported?.name??(typeof a.imported?.value==="string"?a.imported.value:s);t.valueImportBindingsByLocalName.set(s,{localName:s,importedName:P,source:o})}}function rt(t,r){if(!r)return;f(r,{enter(o){if(o.type==="ImportDeclaration")Ue(t,o);if(o.type==="FunctionDeclaration"){let a=o;if(a.id?.name)t.funcDecls.set(a.id.name,a)}}})}function St(t,r,o){let a=r+1;while(a<t.length){if(t[a]==="\\"){a+=2;continue}if(t[a]===o)return a+1;a++}return a}function Et(t,r){let o=r+1,a=0;while(o<t.length){let s=t[o];if(s==="\\"){o+=2;continue}if(a===0){if(s==="`")return o+1;if(s==="$"&&t[o+1]==="{"){a=1,o+=2;continue}o++;continue}if(s==="{")a++;else if(s==="}")a--;else if(s==='"'||s==="'"){o=St(t,o,s);continue}else if(s==="`"){o=Et(t,o);continue}o++}return o}function Kt(t,r){let o=[],a=t.length,s=0;while(s<a){let P=t[s];if(P==='"'||P==="'"){s=St(t,s,P);continue}if(P==="`"){s=Et(t,s);continue}if(P==="/"&&t[s+1]==="/"){let S=s+2;while(S<a&&t[S]!==`
|
|
2
|
-
`)S++;s=S;continue}if(P==="/"&&t[s+1]==="*"){let S=s,E=s+2;while(E<a&&!(t[E]==="*"&&t[E+1]==="/"))E++;let M=Math.min(E+2,a),H=t.slice(S,M);o.push({end:M+r,isJsDoc:H.startsWith("/**")&&H.length>4,text:H}),s=M;continue}s++}return o}function ht(t,r,o){if(!t||typeof t!=="object"||!("type"in t))return;let a=t;if(a.type==="FunctionDeclaration"){if(a.id?.type==="Identifier"&&a.id.name)o.push({name:a.id.name,start:r});return}if(a.type==="VariableDeclaration"){for(let s of a.declarations??[])if(s?.id?.type==="Identifier"&&s.id.name)o.push({name:s.id.name,start:r})}}function Jt(t){let r=[];for(let o of t){if(!o||typeof o!=="object"||!("type"in o))continue;let a=o;if(a.start===void 0)continue;if(a.type==="ExportNamedDeclaration"&&a.declaration)ht(a.declaration,a.start,r);else ht(a,a.start,r)}return r}function zt(t,r,o){let a;for(let s of t){if(s.end>r)break;if(!s.isJsDoc)continue;if(!U.test(o.slice(s.end,r)))continue;a=s}return a}function Pt(t,r){let o=new Map;if(!t.source)return o;let a=[t.parsed?.module,t.parsed?.instance],s=[],P=[];for(let S of a){let E=S?.content;if(!E?.body||E.start===void 0||E.end===void 0)continue;s.push(...Kt(t.source.slice(E.start,E.end),E.start)),P.push(...Jt(E.body))}s.sort((S,E)=>S.end-E.end);for(let S of P){let E=zt(s,S.start,t.source);if(!E)continue;let M=w(E.text),{type:H,description:j}=R(M);if(!H)continue;o.set(S.name,{type:r.aliasType(H.type),description:j||H.description})}return o}function vt(t){if(t==="var")return"let";if(t==="using"||t==="await using")return"const";return t}var Wt=null,Mt=/^@component/,Xt=/\r/g,Ut=/^\{\s*\}$/;class i{ctx=Ze();static mapToArray(t){return Array.from(t,([r,o])=>o)}static getStaticAttributeValue(t){if(!Array.isArray(t.value))return;return t.value.map((r)=>r.data??r.raw??"").join("").trim()}resolveScriptLanguage(t){let r=[t.instance,t.module].filter((a)=>a!==void 0),o=!1;for(let a of r){let s=a.attributes?.find((S)=>S.name==="lang");if(!s){o=!0;continue}if(i.getStaticAttributeValue(s)?.toLowerCase()==="ts")return"ts"}return o?"js":void 0}resolveScriptGenericsAttribute(t){let r=t.instance?.attributes?.find((S)=>S.name==="generics");if(!r)return;let o=n(this.ctx,r),a=t.instance?.attributes?.find((S)=>S.name==="lang");if((a?i.getStaticAttributeValue(a)?.toLowerCase():void 0)!=="ts"){h(this.ctx,"syntax-skipped","generics",'<script generics="..."> requires lang="ts"; the generics attribute was ignored because the script is not TypeScript.',o);return}let P=i.getStaticAttributeValue(r);if(!P)return;return{value:P,source:o}}resolvePublicPropName(t){return this.ctx.propLocalToPublicName.get(t)??t}trackPropLocalName(t,r=t){this.ctx.propLocalToPublicName.set(r,t)}getPropByLocalOrPublic(t){return this.ctx.props.get(this.resolvePublicPropName(t))}getPropTypeByLocalOrPublic(t){return this.getPropByLocalOrPublic(t)?.type}getExplicitPropType(t){return this.ctx.explicitPropTypesByName.get(t)}getPropertyName(t){if(!t||typeof t!=="object"||!("type"in t))return;if(u(t))return t.name;if(x(t))return t.value==null?void 0:String(t.value);return}isNumericConstant(t){if(!t||typeof t!=="object"||!("type"in t))return!1;if(t.type!=="MemberExpression")return!1;let r=t,o=r.object&&"name"in r.object?r.object.name:void 0,a=r.property&&"name"in r.property?r.property.name:void 0;if(!o||!a)return!1;if(o==="Number")return["POSITIVE_INFINITY","NEGATIVE_INFINITY","MAX_VALUE","MIN_VALUE","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","EPSILON","NaN"].includes(a);if(o==="Math")return["PI","E","LN2","LN10","LOG2E","LOG10E","SQRT2","SQRT1_2"].includes(a);return!1}resolveLocalVarJSDoc(t){for(let o of this.ctx.vars)if(o.declarations.some((s)=>s.id&&typeof s.id==="object"&&("type"in s.id)&&s.id.type==="Identifier"&&("name"in s.id)&&s.id.name===t))return g(this.ctx,this,o);let r=this.ctx.funcDecls.get(t);if(r)return g(this.ctx,this,r);return}addModuleExport(t,r){if(p(t)===void 0)return;if(this.ctx.moduleExports.has(t)){let o=this.ctx.moduleExports.get(t);this.ctx.moduleExports.set(t,{...o,...r})}else this.ctx.moduleExports.set(t,r)}aliasType(t){if(t==="*")return"any";return t.trim()}findVariableTypeAndDescription(t){let r=this.getPropByLocalOrPublic(t);if(r?.type)return{type:r.type,description:r.description};if(!this.ctx.variableInfoCacheBuilt)this.ctx.variableInfoCache=Pt(this.ctx,this),this.ctx.variableInfoCacheBuilt=!0;let o=this.ctx.variableInfoCache.get(t),a=this.ctx.explicitVariableTypesByName.get(t);if(a)return{type:a,description:o?.description};return o??null}accumulateGeneric(t,r){if(this.ctx.generics)this.ctx.generics=[`${this.ctx.generics[0]}, ${t}`,`${this.ctx.generics[1]}, ${r}`];else this.ctx.generics=[t,r]}cleanup(){this.ctx=Ze()}static SCRIPT_BLOCK_REGEX=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi;static TS_DIRECTIVE_REGEX=/\/\/\s*@ts-[^\n\r]*/g;static stripTypeScriptDirectivesFromScripts(t){if(!t.includes("@ts-"))return t;return i.SCRIPT_BLOCK_REGEX.lastIndex=0,t.replace(i.SCRIPT_BLOCK_REGEX,(r,o,a,s)=>{i.TS_DIRECTIVE_REGEX.lastIndex=0;let P=a.replace(i.TS_DIRECTIVE_REGEX,"");return o+P+s})}parseSvelteComponent(t,r){this.cleanup(),this.ctx.componentFilePath=r.filePath;let o=i.stripTypeScriptDirectivesFromScripts(t);this.ctx.source=o;let a=q(o);if(gt(this,this.ctx,a),this.ctx.parsed=a,this.ctx.scriptLanguage==="ts")Xe(this.ctx.parsed.module),Xe(this.ctx.parsed.instance),Xe(this.ctx.parsed.fragment);this.ctx.syntaxMode=yt(this.ctx);let s=this.ctx.parsed.css,P=s?.start!==void 0&&s?.end!==void 0?o.slice(0,s.start)+" ".repeat(s.end-s.start)+o.slice(s.end):o;pe(this.ctx,this,P);let S={type:"ComponentRoot",instance:this.ctx.parsed.instance,fragment:this.ctx.parsed.fragment};if(rt(this.ctx,this.ctx.parsed?.module),rt(this.ctx,this.ctx.parsed?.instance),this.ctx.parsed?.module)f(this.ctx.parsed?.module,{enter:(c)=>{if(c.type==="ImportDeclaration")Ue(this.ctx,c);if(c.type==="FunctionDeclaration"){let b=c;if(b.id?.name)this.ctx.funcDecls.set(b.id.name,b)}if(c.type==="VariableDeclaration")this.ctx.vars.add(c);if(c.type==="ExportNamedDeclaration"){if(c.declaration==null)return;if(!c.declaration||typeof c.declaration!=="object"||!("type"in c.declaration))return;let b,k,G=!1,B,C,D,J=!1,de,fe,z;if(c.declaration.type==="FunctionDeclaration"){let Pe=c.declaration;if(!Pe.id?.name)return;b=Pe.id.name,k="function",B=void 0,C="() => any",J=!0,G=!0}else if(c.declaration.type==="VariableDeclaration"){let Pe=c.declaration,Me=Pe.declarations[0];if(!Me||typeof Me!=="object"||!("id"in Me))return;let{id:ve,init:Je}=Me;if(!ve||typeof ve!=="object"||!("name"in ve))return;let Ie=ve.name;b=Ie,k=vt(Pe.kind);let ze=Je==null?{isFunction:!1}:y(this,this.ctx,Je);if({value:B,type:C,isFunction:J,defaultValue:de}=ze,fe=C,z=ze,D=this.getExplicitPropType(Ie),z.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:Ie,location:"moduleExports",...z.pendingCallDefault})}else return;let le=g(this.ctx,this,c),{type:he,typeSource:be,description:De,params:ke,returnType:O,isFunction:Se}=Fe({explicitType:D,typeSeed:C,inferredTypeForSource:fe,jsdocType:le?.type,jsdocDescription:le?.description,jsdocParams:le?.params,jsdocReturnType:le?.returnType,resolvedType:z?.resolvedType,resolvedDescription:z?.resolvedDescription,resolvedParams:z?.resolvedParams,resolvedReturnType:z?.resolvedReturnType,initializerIsFunction:J,isFunctionDeclaration:G,typedefs:this.ctx.typedefs});this.addModuleExport(b,{name:b,kind:k,description:De,deprecated:le?.deprecated,tags:le?.tags,type:he,typeSource:be,value:B,defaultValue:de,params:ke,returnType:O,isFunction:Se,isFunctionDeclaration:G,isRequired:!1,constant:k==="const",reactive:!1,source:n(this.ctx,c)})}}});let E,M=new Set,H=new Set,j=[];ct(this,this.ctx),this.ctx.activeScopes.push(this.ctx.componentScope);let W=pt(this.ctx);if(f(S,{enter:(c,b,k)=>{let G=lt(this,this.ctx,W,c);if(G)this.ctx.activeScopes.push(G);let B=c.type;if(c.type==="AssignmentExpression")tt(this.ctx,c.left);if(c.type==="UpdateExpression")tt(this.ctx,c.argument);if(c.type==="CallExpression"){let C=c,D=C.callee&&typeof C.callee==="object"&&"name"in C.callee?C.callee.name:void 0;if(D==="createEventDispatcher"){if(b&&typeof b==="object"&&"id"in b&&b.id&&typeof b.id==="object"&&"name"in b.id)E=b.id.name}if(D==="$host"){if(b&&typeof b==="object"&&"id"in b&&b.id&&typeof b.id==="object"&&"name"in b.id)M.add(b.id.name)}if(D==="setContext")K(this.ctx,this,c,b??void 0);if(D)j.push({name:D,arguments:C.arguments,node:C});if(Q(C.callee)&&u(C.callee.property)&&C.callee.property.name==="dispatchEvent"&&(d(C.callee.object,"$host")||u(C.callee.object)&&M.has(C.callee.object.name))){let J=ee(this.ctx,C);if(J)H.add(J)}}if(B==="SpreadAttribute"){let C=c;if(C.expression?.name==="$$restProps"||this.ctx.restPropLocals.has(C.expression?.name??""))at(this.ctx,b)}if(c.type==="FunctionDeclaration"){let C=c;if(C.id?.name)this.ctx.funcDecls.set(C.id.name,C)}if(c.type==="ImportDeclaration")Ue(this.ctx,c);if(c.type==="VariableDeclaration"){if(this.ctx.vars.add(c),b&&typeof b==="object"&&"type"in b&&b.type==="Program"&&c.declarations.some((C)=>d(m(C.init),"$props")))Tt(this,this.ctx,c)}if(c.type==="ExportNamedDeclaration"){if(c.declaration==null&&c.specifiers.length===0)return;let C;if(c.declaration==null&&c.specifiers[0]?.type==="ExportSpecifier"){let Te=c.specifiers[0],Le=Te.local&&typeof Te.local==="object"&&"name"in Te.local?Te.local.name:void 0,Ne=Te.exported&&typeof Te.exported==="object"&&"name"in Te.exported?Te.exported.name:void 0;if(!Le||!Ne)return;let we;for(let He of Array.from(this.ctx.vars))if(He.declarations.some((Ce)=>Ce.id&&typeof Ce.id==="object"&&("type"in Ce.id)&&Ce.id.type==="Identifier"&&Ce.id.name===Le)){we=He;break}c.declaration=we,C=Ne}if(c.declaration==null)return;if(!c.declaration||typeof c.declaration!=="object"||!("type"in c.declaration))return;let D,J=!1,de,fe,z,le=!1,he=!1,be,De,ke,O;if(c.declaration.type==="FunctionDeclaration"){let Te=c.declaration;if(!Te.id?.name)return;C??=Te.id.name,be=Te.id.name,D="function",de=void 0,fe="() => any",le=!0,J=!0,he=!1}else if(c.declaration.type==="VariableDeclaration"){let Te=c.declaration,Le=Te.declarations[0];if(!Le||typeof Le!=="object"||!("id"in Le))return;let{id:Ne,init:we}=Le;if(Ne&&typeof Ne==="object"&&"name"in Ne){let Ce=Ne.name;be=Ce,C??=Ce,z=this.getExplicitPropType(Ce)}else return;D=vt(Te.kind),he=D==="let"&&we==null;let He=we==null?{isFunction:!1}:y(this,this.ctx,we);if({value:de,type:fe,isFunction:le,defaultValue:De}=He,ke=fe,O=He,O.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:C,location:"props",...O.pendingCallDefault})}else return;let Se=g(this.ctx,this,c),{type:Pe,typeSource:Me,description:ve,params:Je,returnType:Ie,isFunction:ze}=Fe({explicitType:z,typeSeed:fe,inferredTypeForSource:ke,jsdocType:Se?.type,jsdocDescription:Se?.description,jsdocParams:Se?.params,jsdocReturnType:Se?.returnType,resolvedType:O?.resolvedType,resolvedDescription:O?.resolvedDescription,resolvedParams:O?.resolvedParams,resolvedReturnType:O?.resolvedReturnType,initializerIsFunction:le,isFunctionDeclaration:J,typedefs:this.ctx.typedefs});A(this,this.ctx,C,{name:C,...be!==void 0&&be!==C?{localName:be}:{},kind:D,description:ve,binding:Se?.binding,deprecated:Se?.deprecated,tags:Se?.tags,type:Pe,typeSource:Me,value:de,defaultValue:De,params:Je,returnType:Ie,isFunction:ze,isFunctionDeclaration:J,isRequired:he,constant:D==="const",reactive:this.ctx.reactive_vars.has(C),source:n(this.ctx,c)})}if(B==="Comment"){let D=c?.data?.trim()??"";if(Mt.test(D))this.ctx.componentComment=D.replace(Mt,"").replace(Xt,""),this.ctx.componentCommentSource=n(this.ctx,c)}if(B==="SlotElement"){let C=c,D=C.attributes?.find((z)=>z.name==="name")?.value,J=(Array.isArray(D)?D[0]:void 0)?.data,de=(C.attributes||[]).filter((z)=>z.name!=="name").reduce((z,le)=>{let he={value:void 0,replace:!1},be=le.value;if(be===void 0||be===!0)return z;let De=Array.isArray(be)?be[0]:be;if(De){let{type:ke,expression:O,raw:Se,start:Pe,end:Me}=De;if(ke==="Text"&&Se!==void 0)he.value=JSON.stringify(Se);else if(!Array.isArray(be)&&ke==="ExpressionTag"&&O&&typeof O==="object"&&"type"in O&&O.type==="Identifier"&&"name"in O&&O.name===le.name)he.value=O.name,he.replace=!0;if(O&&typeof O==="object"&&"type"in O){if(O.type==="Literal"&&"value"in O){let ve=O.value;he.value=typeof ve==="string"?JSON.stringify(ve):String(ve)}else if(O.type==="MemberExpression")he.value=N(this.ctx,this,O);else if(O.type!=="Identifier"){if(Pe!==void 0&&Me!==void 0){if(O.type==="ObjectExpression"||O.type==="TemplateLiteral")he.value=e(this.ctx,Pe+1,Me-1)}}}}if(le.name)z[le.name]=he;return z},{}),fe=C.fragment?.nodes?.map(({start:z,end:le})=>{if(z===void 0||le===void 0)return"";return e(this.ctx,z,le)??""}).join("").trim();_(this.ctx,{slot_name:J,slot_props:de,slot_fallback:fe,source:n(this.ctx,c)})}if(B==="RenderTag"){let C=c,D=ce(this.ctx,C.expression);if(D){let J;if(D.arguments.length===0)J={};else if(D.arguments.length===1&&typeof D.arguments[0]==="object"&&D.arguments[0]&&"type"in D.arguments[0]&&D.arguments[0].type==="ObjectExpression")J=ae(this.ctx,this,D.arguments[0]);else if(D.arguments.length===1)h(this.ctx,"syntax-skipped",D.publicName,`{@render ${D.publicName}(...)} argument is not a plain object literal; the render call was not mapped to slot metadata.`,n(this.ctx,c));let de=D.publicName==="children"?void 0:D.publicName,fe=de===void 0?Wt:de;if(J!==void 0)_(this.ctx,{slot_name:de,slot_props:J,source:n(this.ctx,c)});if(J!==void 0||this.ctx.slots.has(fe))this.ctx.snippetPropLocals.add(D.trackingName)}}if(B==="OnDirective"){let C=c;if(C.expression==null&&C.name){if(b!=null&&typeof b==="object"&&"name"in b){let D=typeof b.name==="string"?b.name:void 0,J="type"in b?String(b.type):void 0;if(D&&J){let de=je(J)?{type:"InlineComponent",name:D}:{type:"Element",name:D};this.ctx.forwardedEvents.set(C.name,de);let fe=this.ctx.events.get(C.name),z=this.ctx.eventDescriptions.get(C.name),le=fe?.deprecated;if(!fe)this.ctx.events.set(C.name,{type:"forwarded",name:C.name,element:de,description:z,deprecated:le,source:n(this.ctx,c)});else if(fe.type==="forwarded"&&z&&!fe.description)this.ctx.events.set(C.name,{...fe,description:z,deprecated:fe.deprecated??le,source:fe.source||n(this.ctx,c)})}}}}if(B==="BindDirective"&&b&&typeof b==="object"&&"type"in b&&(_e(String(b.type))||je(String(b.type)))){let C=c;if(C.expression?.name){let D=Be(this.ctx,C.expression.name);if(D)this.ctx.reactive_vars.add(D)}if(_e(String(b.type))&&C.name==="this"&&C.expression?.name&&"name"in b&&typeof b.name==="string"){let D=Be(this.ctx,C.expression.name);if(!D)return;let J=b.name;if(this.ctx.bindings.has(D)){let de=this.ctx.bindings.get(D);if(de&&!de.elements.includes(J))this.ctx.bindings.set(D,{...de,elements:[...de.elements,J]})}else this.ctx.bindings.set(D,{elements:[J]})}}},leave:(c)=>{if(Re(c))this.ctx.activeScopes.pop(),dt(W,c)}}),E!==void 0){for(let c of j)if(c.name===E){let b=c.arguments[0],k=b&&typeof b==="object"&&"value"in b?b.value:void 0,G=c.arguments[1],B=G&&typeof G==="object"&&"value"in G?G.value:void 0;if(k!=null)v(this.ctx,{name:String(k),detail:B==null?"":F(B),has_argument:Boolean(G),source:n(this.ctx,c.node)})}}let me=new Set(H);if(E!==void 0){for(let c of j)if(c.name===E){let b=c.arguments[0],k=b&&typeof b==="object"&&"value"in b?b.value:void 0;if(k!=null)me.add(String(k))}}this.ctx.forwardedEvents.forEach((c,b)=>{let k=this.ctx.events.get(b);if(k&&k.type==="dispatched"&&!me.has(b)){let G=this.ctx.eventDescriptions.get(b),B={type:"forwarded",name:b,element:c,description:G,deprecated:k.deprecated,tags:k.tags,source:k.source};if(k.detail!==void 0&&k.detail!=="undefined")B.detail=k.detail;this.ctx.events.set(b,B)}}),bt(this.ctx,me);let Ee=this.ctx.syntaxMode==="runes"?new Set(Array.from(this.ctx.snippetPropLocals,(c)=>this.resolvePublicPropName(c))):new Set,xe=i.mapToArray(this.ctx.props).filter((c)=>!Ee.has(c.name)).map((c)=>{if(this.ctx.bindings.has(c.name)){let b=this.ctx.bindings.get(c.name)?.elements.sort().map((k)=>it(k)).join(" | ");return{...c,type:`null | ${b}`,typeSource:"inferred",reactive:c.reactive||this.ctx.reactive_vars.has(c.name)}}return{...c,reactive:c.reactive||this.ctx.reactive_vars.has(c.name)}});this.ctx.activeScopes.length=0;let Oe=i.mapToArray(this.ctx.slots).map((c)=>{if(!c.slot_props)return c;if(typeof c.slot_props==="string")return Ut.test(c.slot_props)?{...c,slot_props:"Record<string, never>"}:c;let b=c.slot_props,k=[];for(let B of Object.keys(b)){if(b[B].replace&&b[B].value!==void 0)b[B].value=this.getPropTypeByLocalOrPublic(b[B].value);if(b[B].value===void 0)b[B].value="any";k.push(`${B}: ${b[B].value}`)}let G=k.length===0?"Record<string, never>":k.length===1?`{ ${k[0]} }`:`{
|
|
3
|
-
${k.join(`;
|
|
4
|
-
`)};
|
|
5
|
-
}`;return{...c,slot_props:G}}).sort((c,b)=>{let k=c.name??"",G=b.name??"";if(k<G)return-1;if(k>G)return 1;return 0});if(this.ctx.deferredSlotBlockGenerics.length>0){let c=[...xe.map((b)=>b.type??""),...Oe.map((b)=>b.slot_props??"")].join(`
|
|
6
|
-
`);for(let{name:b,constraint:k}of this.ctx.deferredSlotBlockGenerics){let G=b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!new RegExp(`\\b${G}\\b`).test(c))continue;this.accumulateGeneric(b,k)}}if(this.ctx.scriptGenericsAttribute){if(this.ctx.generics)h(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=se(this.ctx.scriptGenericsAttribute.value)}let Ae=i.mapToArray(this.ctx.moduleExports),Ye=i.mapToArray(this.ctx.events).map((c)=>{switch(c.type){case"forwarded":return{...c,element:c.element.name};case"dispatched":return c;default:return c}}).sort((c,b)=>{let k=c.name.localeCompare(b.name);if(k!==0)return k;let G=c.type.localeCompare(b.type);if(G!==0)return G;if(c.type==="forwarded"&&b.type==="forwarded"){let B=c.element.localeCompare(b.element);if(B!==0)return B}return(c.detail??"").localeCompare(b.detail??"")}),qe=i.mapToArray(this.ctx.typedefs),Qe=i.mapToArray(this.ctx.contexts),$e={props:new Map(this.ctx.pendingCallDefaultCandidates.filter((c)=>c.location==="props").map((c)=>[c.propName,c])),moduleExports:new Map(this.ctx.pendingCallDefaultCandidates.filter((c)=>c.location==="moduleExports").map((c)=>[c.propName,c]))};for(let c of xe)if(c.typeSource==="unknown"){let b=$e.props.get(c.name);if(b)c.type="any";let k=b?b.importSource?`Prop "${c.name}" default calls "${b.calleeName}()" imported from "${b.importSource}"; falling back to "any" pending cross-file resolution.`:`Prop "${c.name}" default calls "${b.calleeName}()", but its return type could not be inferred; falling back to "any".`:`Prop "${c.name}" type could not be inferred; falling back to "${c.type??"any"}".`;h(this.ctx,"prop-unknown-type",c.name,k,c.source)}for(let c of Ae)if(c.typeSource==="unknown"&&$e.moduleExports.has(c.name))c.type="any";for(let c of this.ctx.jsDocEventNames){if(me.has(c))continue;if(this.ctx.forwardedEvents.has(c))continue;if(this.ctx.props.has(`on${c}`))continue;h(this.ctx,"event-no-source",c,`@event "${c}" has no matching dispatch or callback prop.`,this.ctx.jsDocEventSources.get(c))}let Ge={source:I(this.ctx,0,this.ctx.source?.length),syntaxMode:this.ctx.syntaxMode,...this.ctx.scriptLanguage?{scriptLanguage:this.ctx.scriptLanguage}:{},props:xe,moduleExports:Ae,slots:Oe,events:Ye,typedefs:qe,generics:this.ctx.generics,rest_props:this.ctx.rest_props,extends:this.ctx.extends,componentComment:this.ctx.componentComment,componentCommentSource:this.ctx.componentCommentSource,contexts:Qe,customElementTag:this.ctx.customElementTag,diagnostics:this.ctx.diagnosticRecords.slice()},Ke=ie(this.ctx);if(Ke)Ge[T]=Ke;return Ge}}
|
|
7
|
-
export{i};
|
package/lib/chunk-e1e89j27.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i}from"./chunk-5b7hj275.js";import"./chunk-qnj6xmb6.js";export{i as default};
|
package/lib/chunk-ncw3wbrj.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{r}from"./chunk-04eb8yj0.js";import{existsSync as R,readdirSync as k,statSync as N}from"node:fs";import f from"node:path";var F="__sveld_resolved_props__",C="__SveldResolvedProps__",D=/ \| undefined$/,M=/[^A-Za-z0-9_-]/g,O=/[^A-Za-z0-9_$]/g,j=/^[0-9]/,G=2;class I{api;symbolFlags;typeFlags;tsconfigPath;overlay=new Map;constructor(e,t,n,o){this.api=e,this.symbolFlags=t,this.typeFlags=n,this.tsconfigPath=o}static async create(e=process.cwd()){let t=V(e);if(!t)return console.warn("Warning: `resolveTypes` could not locate a tsconfig.json. Skipping semantic resolution."),null;let n;try{n=await import("./chunk-3a9n8agv.js")}catch(i){return console.warn("Warning: `resolveTypes` requires the `typescript` package to be installed. Skipping semantic resolution.",i),null}let o=new I(null,n.SymbolFlags,n.TypeFlags,t),s=new n.API({cwd:e,fs:o.createFileSystem()});return o.api=s,o}async expandAll(e){let t=new Map;if(e.length===0)return t;let n=new Map;for(let s of e){if(!s.metadata.canonicalPropsType)continue;if(s.metadata.referencesComponentGenerics)continue;let i=this.virtualFileName(s.filePath,s.moduleName);this.overlay.set(i,L(s.metadata)),n.set(i,s)}if(n.size===0)return t;let o=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:Array.from(n.keys())}});try{let[s]=n.keys(),i=await o.getDefaultProjectForFile(s);if(!i)return t;let a=i.checker,T=await Promise.all(Array.from(n,async([l,g])=>{let c=this.overlay.get(l);if(!c)return null;let u=X(c),p=await a.getTypeAtPosition(l,u);if(!p)return null;let m=new Map,P=await a.getPropertiesOfType(p);for(let y of P){if(!y.name||y.name.startsWith("__"))continue;m.set(y.name,{name:y.name,symbols:[y],forceOptional:!1})}if((p.flags&this.typeFlags.Union)!==0){let y=await p.getTypes(),A=await Promise.all(y.map((b)=>a.getPropertiesOfType(b)));for(let b of A)for(let h of b){if(!h.name||h.name.startsWith("__")||m.has(h.name))continue;let w=m.get(h.name);if(w)w.symbols.push(h);else m.set(h.name,{name:h.name,symbols:[h],forceOptional:!0})}}return{filePath:g.filePath,groups:Array.from(m.values())}})),d=[],x=[];T.forEach((l,g)=>{if(!l)return;l.groups.forEach((c,u)=>{for(let p of c.symbols)d.push(p),x.push({fileIndex:g,groupIndex:u})})});let E=d.length>0?await a.getTypeOfSymbol(d):[],_=await Promise.all(E.map((l)=>l?a.typeToString(l):Promise.resolve("any"))),v=new Map;d.forEach((l,g)=>{let{fileIndex:c,groupIndex:u}=x[g],p=(l.flags&this.symbolFlags.Optional)!==0,m=_[g];if(p)m=m.replace(D,"");let P=v.get(c)??new Map,S=P.get(u)??[];S.push(m),P.set(u,S),v.set(c,P)}),T.forEach((l,g)=>{if(!l)return;let c=v.get(g),u=l.groups.map((p,m)=>{let P=c?.get(m)??[],S=!(p.forceOptional||p.symbols.some((y)=>(y.flags&this.symbolFlags.Optional)!==0));return{name:p.name,type:Array.from(new Set(P)).join(" | "),isRequired:S}});u.sort((p,m)=>p.name.localeCompare(m.name)),t.set(l.filePath,u)})}finally{await o.dispose?.()}return t}async checkExamples(e){let t=new Map;if(e.length===0)return t;let n=[];for(let s of e)for(let i of s.sources){let a=this.exampleFileName(s.filePath,s.moduleName,i.id);this.overlay.set(a,U(i)),n.push({filePath:s.filePath,source:i,file:a})}if(n.length===0)return t;let o=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:n.map((s)=>s.file)}});try{let[s]=n,i=await o.getDefaultProjectForFile(s.file);if(!i)return t;await Promise.all(n.map(async({filePath:a,source:T,file:d})=>{let[x,E]=await Promise.all([i.program.getSyntacticDiagnostics(d),i.program.getSemanticDiagnostics(d)]),_=[...x,...E];if(_.length===0)return;let v=this.overlay.get(d)??"",l=_.map((c)=>W(c,v)).sort((c,u)=>c.line-u.line).map((c)=>`Line ${c.line}: ${c.text}`).join(`
|
|
2
|
-
`),g=t.get(a)??[];g.push({id:T.id,name:T.name,message:l}),t.set(a,g)}))}finally{await o.dispose?.()}return t}async dispose(){this.overlay.clear(),await this.api?.close?.()}createFileSystem(){return{readFile:(e)=>this.overlay.get(r(e)),fileExists:(e)=>this.overlay.has(r(e))?!0:void 0,getAccessibleEntries:(e)=>{let t=r(e),n=Array.from(this.overlay.keys()).filter((i)=>r(f.dirname(i))===t);if(n.length===0)return;let o=[],s=[];try{for(let i of k(e)){let a=f.join(e,i);try{(N(a).isDirectory()?s:o).push(i)}catch{}}}catch{}for(let i of n){let a=f.basename(i);if(!o.includes(a))o.push(a)}return{files:o,directories:s}}}}virtualFileName(e,t){let n=f.dirname(f.resolve(e));return r(f.join(n,`__sveld_resolved_${t}.ts`))}exampleFileName(e,t,n){let o=f.dirname(f.resolve(e)),s=n.replace(M,"_");return r(f.join(o,`__sveld_example_${t}_${s}.ts`))}}function L(e){return[...e.typeImportStatements,...e.localTypeDeclarations,`type ${C} = ${e.canonicalPropsType};`,`declare const ${F}: ${C};`].join(`
|
|
3
|
-
`)}function z(e){let t=e.replace(O,"_");if(t===""||j.test(t))return`_${t}`;return t}function U(e){return`const ${z(e.name)} = null as unknown as (${e.type});
|
|
4
|
-
${e.code}
|
|
5
|
-
`}function W(e,t){let n=e.pos??0,o=t.slice(0,n).split(`
|
|
6
|
-
`).length;return{line:Math.max(1,o-G+1),text:String(e.text??"").trim()}}function X(e){let t=e.lastIndexOf("declare const");return e.indexOf(F,t)+2}function V(e){let t=f.resolve(e);while(!0){let n=f.join(t,"tsconfig.json");if(R(n))return n;let o=f.dirname(t);if(o===t)return null;t=o}}export{I as TypeResolver};
|