sveld 0.40.6 → 0.41.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 +4 -2
- package/browser.js +1 -1
- package/{chunk-a5y3ysxx.js → chunk-29ptmasm.js} +1 -1
- package/{chunk-9fmhgf46.js → chunk-h308tz7m.js} +8 -8
- package/{chunk-jw5zhqjv.js → chunk-qbdh04vs.js} +1 -1
- package/{chunk-0e70e5s3.js → chunk-zmd679kg.js} +6 -6
- package/cli-entry.js +23 -11
- package/index.d.ts +9 -7
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -223,8 +223,8 @@ See [Output](docs/output.md#json-output) for the full shape.
|
|
|
223
223
|
Commit `COMPONENT_API.json`, then gate pull requests on API changes and inference gaps:
|
|
224
224
|
|
|
225
225
|
```sh
|
|
226
|
-
npx sveld --check # exit
|
|
227
|
-
npx sveld --strict # exit
|
|
226
|
+
npx sveld --check # exit 1 on a breaking API change against the snapshot
|
|
227
|
+
npx sveld --strict # exit 1 when a prop fell back to `any`, a tag was dropped, ...
|
|
228
228
|
```
|
|
229
229
|
|
|
230
230
|
```
|
|
@@ -238,6 +238,8 @@ Suggested semver bump: major.
|
|
|
238
238
|
|
|
239
239
|
See [CI](docs/ci.md) for exit codes, the change classification table, diagnostic codes, and how to ignore a diagnostic.
|
|
240
240
|
|
|
241
|
+
For an agent or a script: pass `--format=json` and read stdout. The `--check` report is one object (`kind: "check-report"`, `schemaVersion`, `bump`, `changes`), and an exit `2` prints `{ schemaVersion, ok: false, error: { kind, message } }`. Exit `0` is done, `1` is problems found, `2` is called wrong or couldn't finish ([Exit codes](docs/ci.md#exit-codes)).
|
|
242
|
+
|
|
241
243
|
## JSDoc tags
|
|
242
244
|
|
|
243
245
|
| Tag | Use it to | Example |
|
package/browser.js
CHANGED
|
@@ -55,7 +55,7 @@ ${" ".repeat(r+2+qp(s.slice(0,t)).length)}^`}).join(`
|
|
|
55
55
|
`).length===e.lines.length}function Sr(e,t){if(t<=0)return e;return e.split(`
|
|
56
56
|
`).slice(0,-t).join(`
|
|
57
57
|
`).trimEnd()}var oS=new Set(["abstract","access","alias","alpha","arg","argument","async","augments","author","beta","borrows","const","constructs","copyright","defaultValue","description","emits","experimental","exports","external","fires","function","global","import","inner","instance","kind","lends","license","link","listens","member","name","override","package","private","prop","protected","public","readonly","remarks","requires","satisfies","sealed","static","summary","throws","todo","tutorial","typeParam","version","virtual","yields"]),aS=[...pi,...ts,"type","param","returns","typedef","property","callback","template","generics","slot","snippet","event","restProps","extends","extendProps","deprecated","ignore","internal","sveld-ignore","csspart","cssprop"],lS=/;$/;function pS(e){let t=e.trim().replace(lS,"").trimEnd();if(!t.startsWith("{")||!t.endsWith("}"))return!1;return Ke(t,0)===t.length-1}var cS=/[\w$]+/g,uS=new Set(["property","param","returns","return"]);function dS(e,t,n){let i=[e[t].type];for(let s=t+1;uS.has(e[s]?.tag);s++)i.push(e[s].type);let r=new Set(i.join(" ").match(cS));return n.some(({name:s})=>r.has(s))}function fS(e){let t=e.trim();return!t||t==="object"||t==="Object"}function td(e,t){if(t.usedGenericsTag&&t.usedTemplateTag&&!t.warnedMixedGenericsTags){t.warnedMixedGenericsTags=!0;let n=e.componentFilePath?` in ${e.componentFilePath}`:"";console.warn(`Warning: Both @generics and @template tags are used to declare component generics${n}; their declarations are combined in the order encountered.`)}}function nd(e,t,n,i){if(t.seenGenericNames.has(n))D(e,"generics-conflict",n,`Duplicate generic name "${n}".`,i);else t.seenGenericNames.add(n)}function id(e,t,n){if(e.generics){let r=F(e.generics[0],",").map((s)=>s.trim()).indexOf(t.trim());if(r!==-1){let s=F(e.generics[1],",").map((l)=>l.trim());s[r]=n,e.generics=[e.generics[0],s.join(", ")];return}}bi(e,t,n)}function rd(e,{name:t,description:n,tags:i,internal:r,source:s},l,o){if(e.typedefs.has(t))D(e,"typedef-duplicate",t,`Duplicate typedef/callback name "${t}"; the later declaration overwrites the earlier one.`,s);e.typedefs.set(t,{type:l,name:t,description:n||void 0,ts:o,tags:i.length>0?i:void 0,...r?{internal:!0}:{},source:s})}function hS(e,t,n,i,r){let s=t.findIndex((l)=>l.name===n.name);if(s===-1)t.push(n);else{let l=i?` of "${i}"`:"";D(e,"property-duplicate",n.name,`Duplicate property "${n.name}"${l}; the later declaration overwrites the earlier one.`,r),t[s]=n}}class sd{tags;lines;commentDescription;commentDescriptionUsed=!1;isFirstTag=!0;event;typedef;callback;typeDeclaration;attachTrailingTag;pendingTags=[];pendingDeprecated;pendingInternal=!1;pendingTypeParameters=[];lineDescriptions=new Map;tagLineNumbers=new Set;consumedDescriptionLines=new Set;indentedContinuationLines=new Set;trimBodyAbove;trimThisBody;hasSlotOrSnippetTag;hasExtendsTag;ctx;generics;documentsFunction;constructor(e,t,n,i){this.ctx=e,this.generics=t,this.documentsFunction=i;let{tags:r,lines:s}=n;this.tags=r,this.lines=s,this.commentDescription=n.description,this.hasSlotOrSnippetTag=r.some((a)=>a.tag==="slot"||a.tag==="snippet"),this.hasExtendsTag=r.some((a)=>a.tag==="extends"||a.tag==="extendProps");for(let a of r)if(a.lines.length>0)this.tagLineNumbers.add(a.lines[0].number);for(let a of s)if(a.continuesType)this.tagLineNumbers.add(a.number);let l=!1,o=!1;for(let a of s){if(!a.tag&&!a.continuesType&&a.content&&(o||a.content.trim()!=="}"))this.lineDescriptions.set(a.number,a.content);if(a.tag!==void 0||a.continuesType)l=!0;else if(!a.content.trim());else if(l&&(a.indent||o))this.indentedContinuationLines.add(a.number);else l=!1;if(on(a.content))o=!o}}orCommentDescription(e){if(e||!this.isFirstTag||this.commentDescriptionUsed||!this.commentDescription)return e;return this.commentDescriptionUsed=!0,this.commentDescription}typeDeclarationName(e){if(this.pendingTypeParameters.length===0)return iS(e);let t=`${e}<${this.pendingTypeParameters.join(", ")}>`;return this.pendingTypeParameters.length=0,t}joinBlockLines(e,t){let n=t?t.text.split(`
|
|
58
|
-
`):[],i=t?.line;for(let r of e){if(i!==void 0&&r-i>1){let l=i+1;while(l<r&&ed(this.lines[l]))l++;if(l===r)for(let o=i+1;o<r;o++)n.push("")}let s=this.lines[r];n.push(s.indent+s.content),i=r}return li(n)}getPrecedingDescription(e){if(e.length===0)return;let t=e[0].number,n=[],i=!1;for(let r=t-1;r>=0;r--){if(this.tagLineNumbers.has(r)||this.indentedContinuationLines.has(r)||this.consumedDescriptionLines.has(r))break;if(this.lineDescriptions.has(r))n.unshift(r),i=!0;else if(i&&!ed(this.lines[r]))break}if(n.length===0)return;for(let r of n)this.consumedDescriptionLines.add(r);return this.trimBodyAbove?.(n[0]),this.joinBlockLines(n)}claimBodyLines(e,t){if(!sS(e)){for(let i=1;i<e.lines.length;i++)this.consumedDescriptionLines.add(e.lines[i].number);return}let n=e.lines[e.lines.length-1].number;this.trimThisBody=(i)=>t(n-i+1)}getTagDescription(e,t,n=!1){let i=Er(e),r=t!==void 0&&rS.has(t.tag)&&!Er(t.lines),s=n&&(t===void 0||!Mo.has(t.tag)),l=[];for(let o=1;o<e.length;o++){let a=e[o];if((r||s)&&!this.indentedContinuationLines.has(a.number))continue;if(!this.lineDescriptions.get(a.number)?.trim()||this.consumedDescriptionLines.has(a.number))continue;l.push(a.number),this.consumedDescriptionLines.add(a.number)}if(l.length===0)return i;return this.joinBlockLines(l,{text:i??"",line:e[es(e)].number})}flagDescriptionAfterEvent(e,t,n,i){let{event:r}=this;if(r===void 0||r.description)return;if(r.tagLine!==void 0&&this.indentedContinuationLines.has(r.tagLine+1))return;if(i?.tag!=="event"&&!Mo.has(i?.tag??""))return;if(Er(n))return;let s=t?`@${e} "${t}"`:`@${e}`;D(this.ctx,"event-description-ambiguous",r.name,`Text after @event "${r.name}" was used as the description of ${s}. Move it above the tag it describes, indent it as a continuation line, or give each event its own comment block.`,_e(this.ctx,n))}takePrecedingDescription(e){let{tag:t,name:n,lines:i}=this.tags[e],r=this.getPrecedingDescription(i);if(r)this.flagDescriptionAfterEvent(t,n,i,this.tags[e-1]);return r}finalizeEvent(){let{ctx:e,event:t}=this;if(t===void 0)return;this.event=void 0;let i=(t.type&&t.type!=="object"&&t.type!=="Object"?t.type:void 0)??(t.properties.length>0?Cn(t.properties,!0):t.type||""),{tagLine:r}=t;if(r!==void 0){let p=this.tags.find((u)=>{let f=u.lines[0]?.number;return f!==void 0&&f>r&&!Mo.has(u.tag)})?.lines[0].number,c=Array.from(this.lineDescriptions.keys()).sort((u,f)=>u-f).filter((u)=>u>r&&(p===void 0||u<p)&&!this.consumedDescriptionLines.has(u)&&this.lineDescriptions.get(u)?.trim());for(let u of c)this.consumedDescriptionLines.add(u);if(c.length>0)t.description=this.joinBlockLines(c,t.description?{text:t.description,line:r}:void 0)}let{name:s,description:l,source:o}=t,a=i===""&&(!e.events.has(s)||e.untypedJsDocEventNames.has(s));if(Qe(e,{name:s,detail:i,has_argument:!1,description:l,deprecated:t.deprecated,tags:t.tags.length>0?t.tags:void 0,internal:t.internal||void 0,source:o}),a)e.untypedJsDocEventNames.add(s);e.eventDescriptions.set(s,l),e.jsDocEventNames.add(s),e.jsDocEventSources.set(s,o),Je(e,"event-no-source",s,t.ignores)}finalizeTypedef(){let{ctx:e,typedef:t}=this;if(t===void 0)return;this.typedef=void 0;let{properties:n}=t,i=n.length>0,r=i?Cn(n,!0):t.type||"{}",s=!i&&t.type&&pS(r)?`interface ${t.name} ${r}`:`type ${t.name} = ${r};`,l=i?n.filter(({name:o})=>!o.includes(".")&&!o.startsWith("[")).map(({name:o,type:a,optional:p,description:c})=>({name:o,type:a,optional:p===!0,...c?{description:c}:{}})):Ge(r,{skipIndexSignatures:!0});if(l)e.typedefMembersByName.set(t.name,l);rd(e,t,r,s)}finalizeCallback(){let{callback:e}=this;if(e===void 0)return;this.callback=void 0;let t=`(${ge(e.params)}) => ${e.returnType||"void"}`;rd(this.ctx,e,t,`type ${e.name} = ${t};`)}openTypeDeclaration(e){let{name:t,lines:n}=this.tags[e],i={name:this.typeDeclarationName(t),source:_e(this.ctx,n),description:this.orCommentDescription(this.getTagDescription(n,this.tags[e+1])||this.takePrecedingDescription(e)),tags:this.pendingTags.splice(0),internal:this.pendingInternal},{tags:r}=i;if(this.pendingDeprecated!==void 0)r.push({name:"deprecated",body:this.pendingDeprecated===!0?"":this.pendingDeprecated}),this.pendingDeprecated=void 0;return this.pendingInternal=!1,this.attachTrailingTag=(s)=>r.push(s),this.isFirstTag=!1,i}readExtends(e,t){let{name:n,lines:i}=this.tags[e];if(this.ctx.extends!==void 0)D(this.ctx,"extend-props-duplicate",n,`A second @extends/@extendProps tag ("${n}") overwrote the first ("${this.ctx.extends.interface}"); only one is used.`,_e(this.ctx,i));this.ctx.extends={interface:n,import:nS.test(t)?JSON.stringify(t):t},this.isFirstTag=!1}readRestProps(e,t){let{name:n,description:i}=this.tags[e],r=n?i?`${n} ${i}`:n:i,s=Lt(r),l=this.orCommentDescription(s||this.takePrecedingDescription(e)),o={type:"Element",name:t,description:l||void 0};if(this.ctx.rest_props=o,s)this.claimBodyLines(this.tags[e],(a)=>{o.description=Lt(Sr(r,a))||void 0});this.isFirstTag=!1}readSlot(e,t){let{tag:n,name:i,lines:r}=this.tags[e],s=i==="-"||n==="snippet"&&i==="children"?void 0:i,l=this.orCommentDescription(this.getTagDescription(r,this.tags[e+1]));if(!l&&this.pendingTags.length===0)l=this.takePrecedingDescription(e);this.isFirstTag=!1;let o=t||"Record<string, never>",a=_e(this.ctx,r);if(!t)D(this.ctx,"slot-missing-type",s||"default",`@${n}${s?` "${s}"`:""} is missing a required {Type} annotation; falling back to "${o}".`,a);let p=this.pendingTags.splice(0),c=et(s);this.ctx.jsDocSlots.set(c,{tag:n,source:a}),_n(this.ctx,{slot_name:s,slot_props:o,slot_description:l||void 0,slot_deprecated:this.pendingDeprecated,slot_tags:p.length>0?p:void 0,slot_internal:this.pendingInternal||void 0,source:a}),this.pendingDeprecated=void 0,this.pendingInternal=!1,this.typeDeclaration=void 0,this.attachTrailingTag=(u)=>{let f=this.ctx.slots.get(c);if(f)f.tags=[...f.tags??[],u]}}readEvent(e,t){let{name:n,lines:i}=this.tags[e],r=Er(i)||this.takePrecedingDescription(e);this.finalizeEvent();let s=this.pendingTags.splice(0);this.event={name:n,type:t,tagLine:i.length>0?i[0].number:void 0,description:this.orCommentDescription(r),source:_e(this.ctx,i),tags:s,internal:this.pendingInternal,deprecated:this.pendingDeprecated,ignores:[],properties:[]},this.pendingInternal=!1,this.pendingDeprecated=void 0,this.typeDeclaration=void 0,this.attachTrailingTag=(l)=>s.push(l),this.isFirstTag=!1}readProperty(e,t){let{name:n,optional:i,default:r,lines:s}=this.tags[e],l=this.getTagDescription(s,this.tags[e+1],this.event!==void 0),o=this.event??(this.typedef&&fS(this.typedef.type)?this.typedef:void 0);if(o===void 0)return;hS(this.ctx,o.properties,{name:n,type:t,description:l,optional:i||!1,default:r},o.name,_e(this.ctx,s))}readTypedef(e,t){this.finalizeTypedef(),this.typedef={...this.openTypeDeclaration(e),type:t,properties:[]},this.typeDeclaration=this.typedef}readCallback(e){this.finalizeCallback(),this.callback={...this.openTypeDeclaration(e),params:[],returnType:void 0},this.typeDeclaration=this.callback}readGenerics(e,t){let{name:n,lines:i}=this.tags[e],r=_e(this.ctx,i);for(let s of F(n,","))nd(this.ctx,this.generics,s.trim(),r);this.generics.usedGenericsTag=!0,td(this.ctx,this.generics),id(this.ctx,n,t||n),this.isFirstTag=!1}readTemplate(e,t){let{tags:n}=this,i=is(n[e],t),r=e+1;while(n[r]?.tag==="template")r++;let s=n[r];if((s?.tag==="typedef"||s?.tag==="callback")&&!s.name.includes("<")&&dS(n,r,i)){this.pendingTypeParameters.push(...i.map(({constraint:o})=>o));return}if(this.hasSlotOrSnippetTag&&!this.hasExtendsTag){this.ctx.deferredSlotBlockGenerics.push(...i);return}if(this.documentsFunction)return;let l=_e(this.ctx,n[e].lines);for(let o of i)nd(this.ctx,this.generics,o.name,l),id(this.ctx,o.name,o.constraint);this.generics.usedTemplateTag=!0,td(this.ctx,this.generics),this.isFirstTag=!1}readDeprecated(e){let{text:t}=this.tags[e],{event:n}=this;if(!n&&this.typeDeclaration){let r={name:"deprecated",body:t};this.typeDeclaration.tags.push(r),this.claimBodyLines(this.tags[e],(s)=>{r.body=Sr(t,s)});return}if((n?n.deprecated:this.pendingDeprecated)!==void 0)return;let i=(r)=>{if(n)n.deprecated=r;else this.pendingDeprecated=r};i(ci(t)),this.claimBodyLines(this.tags[e],(r)=>{i(ci(Sr(t,r)))})}readPassthrough(e){let{tag:t,text:n,lines:i}=this.tags[e],r={name:t,body:n};if(this.claimBodyLines(this.tags[e],(s)=>{r.body=Sr(n,s)}),!pi.has(t)&&!ts.has(t)){let s=oS.has(t)?void 0:Qu(t,aS,t.length<=4?1:2);D(this.ctx,"jsdoc-unknown-tag",t,s?`Unknown JSDoc tag "@${t}"; did you mean "@${s}"? Passed through unchanged.`:`Unknown JSDoc tag "@${t}"; passed through unchanged. If this is a typo, fix the tag name.`,_e(this.ctx,i))}if(this.attachTrailingTag)this.attachTrailingTag(r);else this.pendingTags.push(r)}read(){let{tags:e}=this;for(let i=0;i<e.length;i++){let{tag:r,type:s,name:l,optional:o}=e[i],a=ke(s);switch(this.trimBodyAbove=this.trimThisBody,this.trimThisBody=void 0,r){case"extends":case"extendProps":this.readExtends(i,a);break;case"restProps":this.readRestProps(i,a);break;case"slot":case"snippet":this.readSlot(i,a);break;case"csspart":{let p=this.getTagDescription(e[i].lines,e[i+1]);this.ctx.cssParts.push({name:l,...p?{description:p}:{}});break}case"cssprop":case"cssproperty":{let p=this.getTagDescription(e[i].lines,e[i+1]),c=e[i].default;this.ctx.cssProperties.push({name:l,...a?{type:a}:{},...c===void 0?{}:{default:c},...p?{description:p}:{}});break}case"event":this.readEvent(i,a);break;case"type":if(this.event)this.event.type=a;break;case"param":this.callback?.params.push({name:l,type:a,optional:o||!1});break;case"returns":case"return":if(this.callback)this.callback.returnType=a;break;case"property":this.readProperty(i,a);break;case"typedef":this.readTypedef(i,a);break;case"callback":this.readCallback(i);break;case"generics":this.readGenerics(i,a);break;case"template":this.readTemplate(i,a);break;case"deprecated":this.readDeprecated(i);break;case"ignore":case"internal":if(this.event)this.event.internal=!0;else if(this.typeDeclaration)this.typeDeclaration.internal=!0;else this.pendingInternal=!0;break;case"sveld-ignore":this.event?.ignores.push(l);break;case"enum":case"class":case"implements":case"this":case"namespace":case"memberof":case"module":case"file":case"overview":break;default:this.readPassthrough(i);break}if(Zu.has(r))this.finalizeEvent()}this.finalizeEvent(),this.finalizeTypedef(),this.finalizeCallback();let t=[...this.pendingTags,...this.pendingDeprecated===void 0?[]:[{name:"deprecated"}],...this.pendingInternal?[{name:"internal"}]:[]];if(t.length===0)return;if(!e.some((i)=>i.tag==="event"||Zu.has(i.tag)))return;for(let i of t)D(this.ctx,"jsdoc-tag-dropped",i.name,`@${i.name} could not attach to a @slot/@snippet/@event/@typedef/@callback tag in the same comment block and was dropped.`)}}function od(e,t=e.source){if(!t)return;let n={usedGenericsTag:!1,usedTemplateTag:!1,warnedMixedGenericsTags:!1,seenGenericNames:new Set},i=t.includes("@template")?wa(e):new Set;e.functionDocCommentStarts=i;let r=an(t);for(let s of r)e.jsDocBlocksByStart.set(s.start,s);for(let s of r)new sd(e,n,s,i.has(s.start)).read()}var ld=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]),mS=Array.from(ld);function ad(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function yS(e){if(e.includes("\\u"))return!0;for(let t of mS){let n=e.indexOf(t);while(n!==-1){if(!ad(e.charCodeAt(n-1))&&!ad(e.charCodeAt(n+t.length)))return!0;n=e.indexOf(t,n+1)}}return!1}function gS(e,t){for(let n=t.length-1;n>=0;n-=1)if(t[n]?.has(e))return!0;return!1}function xS(e){let t=new Set;switch(e.type){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":if(e.type!=="ArrowFunctionExpression"&&e.id)t.add(e.id.name);for(let n of e.params)Q(n,t);break;case"BlockStatement":Tr(e.body,t);break;case"CatchClause":Q(e.param,t);break;case"EachBlock":if(Q(e.context,t),e.index)t.add(e.index);break;case"AwaitBlock":Q(e.value,t),Q(e.error,t);break}return t}function Tr(e,t){for(let n of e??[])switch(n.type){case"ImportDeclaration":for(let i of n.specifiers)t.add(i.local.name);break;case"VariableDeclaration":for(let i of n.declarations)Q(i.id,t);break;case"FunctionDeclaration":case"ClassDeclaration":if(n.id?.name)t.add(n.id.name);break;case"ExportNamedDeclaration":if(n.declaration)Tr([n.declaration],t);break;case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExportAllDeclaration":case"ExportDefaultDeclaration":case"ExpressionStatement":case"ForInStatement":case"ForOfStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"StaticBlock":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"TSDeclareFunction":case"TSEnumDeclaration":case"TSExportAssignment":case"TSImportEqualsDeclaration":case"TSInterfaceDeclaration":case"TSModuleDeclaration":case"TSNamespaceExportDeclaration":case"TSTypeAliasDeclaration":case"WhileStatement":case"WithStatement":break}}function Oo(e,t){if(!e)return!1;let n=[...t],i=!1;return K(e,{enter(r,s){if(mi(r.type))return re;if(jt(r))n.push(xS(r));if(r.type==="Identifier"&&ld.has(r.name)&&Vr(r,s)&&!gS(r.name,n))return i=!0,en},leave(r){if(jt(r))n.pop()}}),i}function pd(e){if(e.runesOptionOverride!==void 0)return e.runesOptionOverride?"runes":"legacy";let t=e.parsed;if(!t)return"legacy";if(e.source!==void 0&&!yS(e.source))return"legacy";let n=new Set;Tr(t.module?.content.body,n);let i=new Set;return Tr(t.instance?.content.body,i),Oo(t.module,[n])||Oo(t.instance,[n,i])||Oo(t.fragment,[n,i])?"runes":"legacy"}var ES=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function SS(e){if(e.type!=="TSAsExpression"&&e.type!=="TSTypeAssertion")return!1;let t="typeAnnotation"in e?e.typeAnnotation:void 0;return t?.type==="TSTypeReference"&&t.typeName.type==="Identifier"&&t.typeName.name==="const"}function br(e,t){if(!e)return;K(e,{enter(n){if(!ES.has(n.type)||!("expression"in n)||!n.expression)return;let{expression:i}=n;if(typeof i!=="object")return i;let r=t.typeAssertions.get(n);if(t.constAssertions.has(n)||r===void 0&&SS(n))t.constAssertions.add(i);else if(r!==void 0)t.typeAssertions.set(i,r);else if((n.type==="TSAsExpression"||n.type==="TSTypeAssertion")&&"typeAnnotation"in n)t.typeAssertions.set(i,n.typeAnnotation);return i}})}var TS=/\/\/(?<!^[ \t]*\*.*\/\/)\s*@ts-[^\n\r]*/gm;function bS(e){if(!e.includes("@ts-"))return e;let t=e.charCodeAt(0)===65279?1:0,{instance:n,module:i}=Ji(e),r=[n,i].flatMap((o)=>o?[o.content]:[]).sort((o,a)=>o.start-a.start),s="",l=0;for(let{start:o,end:a}of r)s+=e.slice(l,o+t),s+=e.slice(o+t,a+t).replace(TS,""),l=a+t;return s+e.slice(l)}function cd(e,t,n){e.componentFilePath=n;let i=bS(t);e.source=i;let r=Yu(i);if(Il(e,r),e.parsed=r,e.scriptLanguage==="ts")br(r.module,e.typeCasts),br(r.instance,e.typeCasts),br(r.fragment,e.typeCasts);e.syntaxMode=pd(e);let s=r.css,l=s?i.slice(0,s.start)+" ".repeat(s.end-s.start)+i.slice(s.end):i;cs(e,r.module),cs(e,r.instance),od(e,l)}class Bo{ctx=Hr();cleanup(){this.ctx=Hr()}parseSvelteComponent(e,t){let{component:n,pending:i}=this.parse(e,t);if(i)n[Oe]={...n[Oe]??{canonicalPropNames:[],localTypeDeclarations:[],typeImportStatements:[]},...i};return n}parse(e,t){this.cleanup();let n=this.ctx;cd(n,e,t.filePath),lu(n);let i=Vl(n);return eu(n,i)}}var vS=/\.$/,Fo="resolving it needs file access (generateBundle or the CLI)";function CS(e,t={}){let n=e[Oe];if(!n)return e;let{pendingCallDefaultCandidates:i,pendingConstDefaultCandidates:r,pendingContextKeyCandidates:s,pendingDispatchEscapeCandidates:l,deferredEventNoSourceDiagnostics:o,untypedJsDocEventNames:a,...p}=n,c=(i??[]).filter((v)=>v.importSource!==void 0);if(c.length===0&&!r&&!s&&!l&&!o)return e;let u="filePath"in e?e.filePath:void 0,f=t.filePath??(typeof u==="string"?u:""),h=[],m=(v,Y,me,Le)=>{h.push(oi({component:f,kind:"cross-file-unresolved",name:v,message:Y,...me?{source:me}:{},...Le?{ignored:Le}:{}}))},g=(v,Y)=>(v==="props"?e.props:e.moduleExports).find((me)=>me.name===Y)?.source,y=(v)=>v==="props"?"Prop":"Module export";for(let v of s??[]){let Y=dn(v);m(Y,`setContext key \`${Y}\` is imported from "${v.importSource}"; ${Fo}, so the context is omitted.`,v.source)}for(let v of r??[])m(v.propName,`${y(v.location)} "${v.propName}" defaults to \`${dn(v)}\` imported from "${v.importSource}"; ${Fo}, so the default shows the identifier and its type isn't read.`,g(v.location,v.propName));for(let v of c)m(v.propName,`${y(v.location)} "${v.propName}" defaults to \`${v.calleeName}()\` imported from "${v.importSource}"; ${Fo}, so its return type isn't read and the prop falls back to "any".`,g(v.location,v.propName));for(let v of l??[])m(v.calleeText,`\`${v.dispatcherName}\` is passed to \`${v.calleeText}\`, imported from "${v.importSource}"; reading the events it dispatches needs file access (generateBundle or the CLI), so they're omitted.`,v.source,v.ignored);let S=Array.from(new Set((l??[]).map((v)=>`\`${v.calleeText}\``))).join(", "),b=(o??[]).map((v)=>S?{...v,message:`${v.message.replace(vS,"")} in this file; ${S} may dispatch it, but imported helpers aren't read without file access.`}:v),M={...e,diagnostics:[...e.diagnostics??[],...b,...h]};return M[Oe]=p,M}var dd="sveld",fd="0.40.6";var Vo="5.59.1";var hd=1;function rt(e){return e.some((t)=>t.internal)?e.filter((t)=>!t.internal):e}function wS(e){return{...e,props:rt(e.props),moduleExports:rt(e.moduleExports),slots:rt(e.slots),events:rt(e.events),typedefs:rt(e.typedefs),...e.contexts?{contexts:rt(e.contexts).map((t)=>({...t,properties:rt(t.properties)}))}:{}}}function jo(e,t={}){let n=Array.from(e.values(),(s)=>{let{diagnostics:l,...o}=s;return wS(o)}).sort((s,l)=>Ve(s.moduleName,l.moduleName)),i={schemaVersion:hd,generator:{name:dd,version:fd,svelteVersion:Vo},total:n.length,components:n},r=t.entryExports?rt(t.entryExports):void 0;if(r&&r.length>0)i.totalExports=r.length,i.exports=r;return i}var PS=" ",kS=120,_S=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,NS=200,xd=/\s/,DS=/\s{2}|[^\S ]/,$S=/["'`{}/]/g,IS=/["'`{};/]/g,Ed=9,Go=10,LS=13,Kn=32,Cr=34,RS=38,Ar=39,MS=40,OS=41,vr=42,md=46,Ho=47,Sd=59,BS=62,FS=91,Uo=92,VS=93,wr=96,qo=123,jS=124,zo=125;function GS(e){return _S.test(HS(e,NS))}var yd=[""];function WS(e){let t=yd[e];if(t===void 0)t=PS.repeat(e),yd[e]=t;return t}function HS(e,t){let n="";for(let i=e.length-1;i>=0&&n.length<t;i--)n=e[i]+n;return n.length>t?n.slice(-t):n}function US(e){if(e.length===0)return!1;let t=e[e.length-1];return t.charCodeAt(t.length-1)===Go}function qS(e){while(e.length>0){let t=e[e.length-1],n=t.length;while(n>0){let i=t.charCodeAt(n-1);if(i!==Kn&&i!==Ed)break;n--}if(n===t.length)return;if(n===0){e.pop();continue}e[e.length-1]=t.slice(0,n);return}}function zS(e){while(e.length>0){let t=e[e.length-1];if(!xd.test(t[t.length-1]))return;let n=t.trimEnd();if(n.length===t.length)return;if(n.length===0){e.pop();continue}e[e.length-1]=n;return}}function KS(e){if(e.includes("{"))return!1;let t=0,n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(t!==0){if(r===t&&e.charCodeAt(i-1)!==Uo)t=0;continue}if(r===Cr||r===Ar||r===wr){t=r;continue}if(r===Sd&&++n>=2)return!0}return!1}function JS(e){if(!DS.test(e))return e.trimEnd();let t="",n=null,i=!1;for(let r=0;r<e.length;r++){let s=e[r],l=e[r-1];if(n){if(t+=s,n==="double"&&s==='"'&&l!=="\\"||n==="single"&&s==="'"&&l!=="\\"||n==="template"&&s==="`"&&l!=="\\")n=null;i=!1;continue}if(s==='"'||s==="'"||s==="`"){n=s==='"'?"double":s==="'"?"single":"template",t+=s,i=!1;continue}if(xd.test(s)){if(!i&&t.length>0)t+=" ",i=!0;continue}t+=s,i=!1}return t.trimEnd()}function Td(e,t){let n=e[t],i=e.indexOf(n,t+1);while(i!==-1&&e.charCodeAt(i-1)===Uo)i=e.indexOf(n,i+1);return i}function bd(e,t){let n=e.indexOf("*/",t+1);return n===-1?-1:n+1}function XS(e){let t=new Map,n=[],i=$S,r=0;while(r<e.length){if(i.lastIndex=r,!i.test(e))break;r=i.lastIndex-1;let s=e.charCodeAt(r);if(s===Ho){if(e.charCodeAt(r+1)===vr){let l=bd(e,r);if(l===-1)break;r=l}}else if(s===Cr||s===Ar||s===wr){let l=Td(e,r);if(l===-1)break;r=l}else if(s===qo)n.push(r);else if(s===zo){let l=n.pop();if(l!==void 0)t.set(l,r)}r++}return t}function YS(e,t,n){for(let i=t;i<n;i++)if(!Wo(e.charCodeAt(i)))return!1;return!0}function Wo(e){if(e<=Kn)return e===Kn||e>=Ed&&e<=LS;if(e<160)return!1;return e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function vd(e,t,n,i){let r=[],s=IS,l=t,o=t;while(o<n){if(s.lastIndex=o,!s.test(e))break;if(o=s.lastIndex-1,o>=n)break;let a=e.charCodeAt(o);if(a===Ho){if(e.charCodeAt(o+1)===vr){let p=bd(e,o);if(p===-1)break;o=p}o++;continue}if(a===Cr||a===Ar||a===wr){let p=Td(e,o);if(p===-1)break;o=p+1;continue}if(a===qo){let p=i.get(o);if(p===void 0||p>=n){o++;continue}if(l<o)r.push(e.slice(l,o));let c=o+1;if(YS(e,c,p)){r.push("{}"),o=p+1,l=o;continue}let u=e.slice(c,p),f=e.charCodeAt(c)===Go;if(!f&&!u.includes("/*")&&!KS(u)&&!GS(r)){let h=vd(e,c,p,i),m=h.trim();if(!m.includes(`
|
|
58
|
+
`):[],i=t?.line;for(let r of e){if(i!==void 0&&r-i>1){let l=i+1;while(l<r&&ed(this.lines[l]))l++;if(l===r)for(let o=i+1;o<r;o++)n.push("")}let s=this.lines[r];n.push(s.indent+s.content),i=r}return li(n)}getPrecedingDescription(e){if(e.length===0)return;let t=e[0].number,n=[],i=!1;for(let r=t-1;r>=0;r--){if(this.tagLineNumbers.has(r)||this.indentedContinuationLines.has(r)||this.consumedDescriptionLines.has(r))break;if(this.lineDescriptions.has(r))n.unshift(r),i=!0;else if(i&&!ed(this.lines[r]))break}if(n.length===0)return;for(let r of n)this.consumedDescriptionLines.add(r);return this.trimBodyAbove?.(n[0]),this.joinBlockLines(n)}claimBodyLines(e,t){if(!sS(e)){for(let i=1;i<e.lines.length;i++)this.consumedDescriptionLines.add(e.lines[i].number);return}let n=e.lines[e.lines.length-1].number;this.trimThisBody=(i)=>t(n-i+1)}getTagDescription(e,t,n=!1){let i=Er(e),r=t!==void 0&&rS.has(t.tag)&&!Er(t.lines),s=n&&(t===void 0||!Mo.has(t.tag)),l=[];for(let o=1;o<e.length;o++){let a=e[o];if((r||s)&&!this.indentedContinuationLines.has(a.number))continue;if(!this.lineDescriptions.get(a.number)?.trim()||this.consumedDescriptionLines.has(a.number))continue;l.push(a.number),this.consumedDescriptionLines.add(a.number)}if(l.length===0)return i;return this.joinBlockLines(l,{text:i??"",line:e[es(e)].number})}flagDescriptionAfterEvent(e,t,n,i){let{event:r}=this;if(r===void 0||r.description)return;if(r.tagLine!==void 0&&this.indentedContinuationLines.has(r.tagLine+1))return;if(i?.tag!=="event"&&!Mo.has(i?.tag??""))return;if(Er(n))return;let s=t?`@${e} "${t}"`:`@${e}`;D(this.ctx,"event-description-ambiguous",r.name,`Text after @event "${r.name}" was used as the description of ${s}. Move it above the tag it describes, indent it as a continuation line, or give each event its own comment block.`,_e(this.ctx,n))}takePrecedingDescription(e){let{tag:t,name:n,lines:i}=this.tags[e],r=this.getPrecedingDescription(i);if(r)this.flagDescriptionAfterEvent(t,n,i,this.tags[e-1]);return r}finalizeEvent(){let{ctx:e,event:t}=this;if(t===void 0)return;this.event=void 0;let i=(t.type&&t.type!=="object"&&t.type!=="Object"?t.type:void 0)??(t.properties.length>0?Cn(t.properties,!0):t.type||""),{tagLine:r}=t;if(r!==void 0){let p=this.tags.find((u)=>{let f=u.lines[0]?.number;return f!==void 0&&f>r&&!Mo.has(u.tag)})?.lines[0].number,c=Array.from(this.lineDescriptions.keys()).sort((u,f)=>u-f).filter((u)=>u>r&&(p===void 0||u<p)&&!this.consumedDescriptionLines.has(u)&&this.lineDescriptions.get(u)?.trim());for(let u of c)this.consumedDescriptionLines.add(u);if(c.length>0)t.description=this.joinBlockLines(c,t.description?{text:t.description,line:r}:void 0)}let{name:s,description:l,source:o}=t,a=i===""&&(!e.events.has(s)||e.untypedJsDocEventNames.has(s));if(Qe(e,{name:s,detail:i,has_argument:!1,description:l,deprecated:t.deprecated,tags:t.tags.length>0?t.tags:void 0,internal:t.internal||void 0,source:o}),a)e.untypedJsDocEventNames.add(s);e.eventDescriptions.set(s,l),e.jsDocEventNames.add(s),e.jsDocEventSources.set(s,o),Je(e,"event-no-source",s,t.ignores)}finalizeTypedef(){let{ctx:e,typedef:t}=this;if(t===void 0)return;this.typedef=void 0;let{properties:n}=t,i=n.length>0,r=i?Cn(n,!0):t.type||"{}",s=!i&&t.type&&pS(r)?`interface ${t.name} ${r}`:`type ${t.name} = ${r};`,l=i?n.filter(({name:o})=>!o.includes(".")&&!o.startsWith("[")).map(({name:o,type:a,optional:p,description:c})=>({name:o,type:a,optional:p===!0,...c?{description:c}:{}})):Ge(r,{skipIndexSignatures:!0});if(l)e.typedefMembersByName.set(t.name,l);rd(e,t,r,s)}finalizeCallback(){let{callback:e}=this;if(e===void 0)return;this.callback=void 0;let t=`(${ge(e.params)}) => ${e.returnType||"void"}`;rd(this.ctx,e,t,`type ${e.name} = ${t};`)}openTypeDeclaration(e){let{name:t,lines:n}=this.tags[e],i={name:this.typeDeclarationName(t),source:_e(this.ctx,n),description:this.orCommentDescription(this.getTagDescription(n,this.tags[e+1])||this.takePrecedingDescription(e)),tags:this.pendingTags.splice(0),internal:this.pendingInternal},{tags:r}=i;if(this.pendingDeprecated!==void 0)r.push({name:"deprecated",body:this.pendingDeprecated===!0?"":this.pendingDeprecated}),this.pendingDeprecated=void 0;return this.pendingInternal=!1,this.attachTrailingTag=(s)=>r.push(s),this.isFirstTag=!1,i}readExtends(e,t){let{name:n,lines:i}=this.tags[e];if(this.ctx.extends!==void 0)D(this.ctx,"extend-props-duplicate",n,`A second @extends/@extendProps tag ("${n}") overwrote the first ("${this.ctx.extends.interface}"); only one is used.`,_e(this.ctx,i));this.ctx.extends={interface:n,import:nS.test(t)?JSON.stringify(t):t},this.isFirstTag=!1}readRestProps(e,t){let{name:n,description:i}=this.tags[e],r=n?i?`${n} ${i}`:n:i,s=Lt(r),l=this.orCommentDescription(s||this.takePrecedingDescription(e)),o={type:"Element",name:t,description:l||void 0};if(this.ctx.rest_props=o,s)this.claimBodyLines(this.tags[e],(a)=>{o.description=Lt(Sr(r,a))||void 0});this.isFirstTag=!1}readSlot(e,t){let{tag:n,name:i,lines:r}=this.tags[e],s=i==="-"||n==="snippet"&&i==="children"?void 0:i,l=this.orCommentDescription(this.getTagDescription(r,this.tags[e+1]));if(!l&&this.pendingTags.length===0)l=this.takePrecedingDescription(e);this.isFirstTag=!1;let o=t||"Record<string, never>",a=_e(this.ctx,r);if(!t)D(this.ctx,"slot-missing-type",s||"default",`@${n}${s?` "${s}"`:""} is missing a required {Type} annotation; falling back to "${o}".`,a);let p=this.pendingTags.splice(0),c=et(s);this.ctx.jsDocSlots.set(c,{tag:n,source:a}),_n(this.ctx,{slot_name:s,slot_props:o,slot_description:l||void 0,slot_deprecated:this.pendingDeprecated,slot_tags:p.length>0?p:void 0,slot_internal:this.pendingInternal||void 0,source:a}),this.pendingDeprecated=void 0,this.pendingInternal=!1,this.typeDeclaration=void 0,this.attachTrailingTag=(u)=>{let f=this.ctx.slots.get(c);if(f)f.tags=[...f.tags??[],u]}}readEvent(e,t){let{name:n,lines:i}=this.tags[e],r=Er(i)||this.takePrecedingDescription(e);this.finalizeEvent();let s=this.pendingTags.splice(0);this.event={name:n,type:t,tagLine:i.length>0?i[0].number:void 0,description:this.orCommentDescription(r),source:_e(this.ctx,i),tags:s,internal:this.pendingInternal,deprecated:this.pendingDeprecated,ignores:[],properties:[]},this.pendingInternal=!1,this.pendingDeprecated=void 0,this.typeDeclaration=void 0,this.attachTrailingTag=(l)=>s.push(l),this.isFirstTag=!1}readProperty(e,t){let{name:n,optional:i,default:r,lines:s}=this.tags[e],l=this.getTagDescription(s,this.tags[e+1],this.event!==void 0),o=this.event??(this.typedef&&fS(this.typedef.type)?this.typedef:void 0);if(o===void 0)return;hS(this.ctx,o.properties,{name:n,type:t,description:l,optional:i||!1,default:r},o.name,_e(this.ctx,s))}readTypedef(e,t){this.finalizeTypedef(),this.typedef={...this.openTypeDeclaration(e),type:t,properties:[]},this.typeDeclaration=this.typedef}readCallback(e){this.finalizeCallback(),this.callback={...this.openTypeDeclaration(e),params:[],returnType:void 0},this.typeDeclaration=this.callback}readGenerics(e,t){let{name:n,lines:i}=this.tags[e],r=_e(this.ctx,i);for(let s of F(n,","))nd(this.ctx,this.generics,s.trim(),r);this.generics.usedGenericsTag=!0,td(this.ctx,this.generics),id(this.ctx,n,t||n),this.isFirstTag=!1}readTemplate(e,t){let{tags:n}=this,i=is(n[e],t),r=e+1;while(n[r]?.tag==="template")r++;let s=n[r];if((s?.tag==="typedef"||s?.tag==="callback")&&!s.name.includes("<")&&dS(n,r,i)){this.pendingTypeParameters.push(...i.map(({constraint:o})=>o));return}if(this.hasSlotOrSnippetTag&&!this.hasExtendsTag){this.ctx.deferredSlotBlockGenerics.push(...i);return}if(this.documentsFunction)return;let l=_e(this.ctx,n[e].lines);for(let o of i)nd(this.ctx,this.generics,o.name,l),id(this.ctx,o.name,o.constraint);this.generics.usedTemplateTag=!0,td(this.ctx,this.generics),this.isFirstTag=!1}readDeprecated(e){let{text:t}=this.tags[e],{event:n}=this;if(!n&&this.typeDeclaration){let r={name:"deprecated",body:t};this.typeDeclaration.tags.push(r),this.claimBodyLines(this.tags[e],(s)=>{r.body=Sr(t,s)});return}if((n?n.deprecated:this.pendingDeprecated)!==void 0)return;let i=(r)=>{if(n)n.deprecated=r;else this.pendingDeprecated=r};i(ci(t)),this.claimBodyLines(this.tags[e],(r)=>{i(ci(Sr(t,r)))})}readPassthrough(e){let{tag:t,text:n,lines:i}=this.tags[e],r={name:t,body:n};if(this.claimBodyLines(this.tags[e],(s)=>{r.body=Sr(n,s)}),!pi.has(t)&&!ts.has(t)){let s=oS.has(t)?void 0:Qu(t,aS,t.length<=4?1:2);D(this.ctx,"jsdoc-unknown-tag",t,s?`Unknown JSDoc tag "@${t}"; did you mean "@${s}"? Passed through unchanged.`:`Unknown JSDoc tag "@${t}"; passed through unchanged. If this is a typo, fix the tag name.`,_e(this.ctx,i))}if(this.attachTrailingTag)this.attachTrailingTag(r);else this.pendingTags.push(r)}read(){let{tags:e}=this;for(let i=0;i<e.length;i++){let{tag:r,type:s,name:l,optional:o}=e[i],a=ke(s);switch(this.trimBodyAbove=this.trimThisBody,this.trimThisBody=void 0,r){case"extends":case"extendProps":this.readExtends(i,a);break;case"restProps":this.readRestProps(i,a);break;case"slot":case"snippet":this.readSlot(i,a);break;case"csspart":{let p=this.getTagDescription(e[i].lines,e[i+1]);this.ctx.cssParts.push({name:l,...p?{description:p}:{}});break}case"cssprop":case"cssproperty":{let p=this.getTagDescription(e[i].lines,e[i+1]),c=e[i].default;this.ctx.cssProperties.push({name:l,...a?{type:a}:{},...c===void 0?{}:{default:c},...p?{description:p}:{}});break}case"event":this.readEvent(i,a);break;case"type":if(this.event)this.event.type=a;break;case"param":this.callback?.params.push({name:l,type:a,optional:o||!1});break;case"returns":case"return":if(this.callback)this.callback.returnType=a;break;case"property":this.readProperty(i,a);break;case"typedef":this.readTypedef(i,a);break;case"callback":this.readCallback(i);break;case"generics":this.readGenerics(i,a);break;case"template":this.readTemplate(i,a);break;case"deprecated":this.readDeprecated(i);break;case"ignore":case"internal":if(this.event)this.event.internal=!0;else if(this.typeDeclaration)this.typeDeclaration.internal=!0;else this.pendingInternal=!0;break;case"sveld-ignore":this.event?.ignores.push(l);break;case"enum":case"class":case"implements":case"this":case"namespace":case"memberof":case"module":case"file":case"overview":break;default:this.readPassthrough(i);break}if(Zu.has(r))this.finalizeEvent()}this.finalizeEvent(),this.finalizeTypedef(),this.finalizeCallback();let t=[...this.pendingTags,...this.pendingDeprecated===void 0?[]:[{name:"deprecated"}],...this.pendingInternal?[{name:"internal"}]:[]];if(t.length===0)return;if(!e.some((i)=>i.tag==="event"||Zu.has(i.tag)))return;for(let i of t)D(this.ctx,"jsdoc-tag-dropped",i.name,`@${i.name} could not attach to a @slot/@snippet/@event/@typedef/@callback tag in the same comment block and was dropped.`)}}function od(e,t=e.source){if(!t)return;let n={usedGenericsTag:!1,usedTemplateTag:!1,warnedMixedGenericsTags:!1,seenGenericNames:new Set},i=t.includes("@template")?wa(e):new Set;e.functionDocCommentStarts=i;let r=an(t);for(let s of r)e.jsDocBlocksByStart.set(s.start,s);for(let s of r)new sd(e,n,s,i.has(s.start)).read()}var ld=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]),mS=Array.from(ld);function ad(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function yS(e){if(e.includes("\\u"))return!0;for(let t of mS){let n=e.indexOf(t);while(n!==-1){if(!ad(e.charCodeAt(n-1))&&!ad(e.charCodeAt(n+t.length)))return!0;n=e.indexOf(t,n+1)}}return!1}function gS(e,t){for(let n=t.length-1;n>=0;n-=1)if(t[n]?.has(e))return!0;return!1}function xS(e){let t=new Set;switch(e.type){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":if(e.type!=="ArrowFunctionExpression"&&e.id)t.add(e.id.name);for(let n of e.params)Q(n,t);break;case"BlockStatement":Tr(e.body,t);break;case"CatchClause":Q(e.param,t);break;case"EachBlock":if(Q(e.context,t),e.index)t.add(e.index);break;case"AwaitBlock":Q(e.value,t),Q(e.error,t);break}return t}function Tr(e,t){for(let n of e??[])switch(n.type){case"ImportDeclaration":for(let i of n.specifiers)t.add(i.local.name);break;case"VariableDeclaration":for(let i of n.declarations)Q(i.id,t);break;case"FunctionDeclaration":case"ClassDeclaration":if(n.id?.name)t.add(n.id.name);break;case"ExportNamedDeclaration":if(n.declaration)Tr([n.declaration],t);break;case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExportAllDeclaration":case"ExportDefaultDeclaration":case"ExpressionStatement":case"ForInStatement":case"ForOfStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"StaticBlock":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"TSDeclareFunction":case"TSEnumDeclaration":case"TSExportAssignment":case"TSImportEqualsDeclaration":case"TSInterfaceDeclaration":case"TSModuleDeclaration":case"TSNamespaceExportDeclaration":case"TSTypeAliasDeclaration":case"WhileStatement":case"WithStatement":break}}function Oo(e,t){if(!e)return!1;let n=[...t],i=!1;return K(e,{enter(r,s){if(mi(r.type))return re;if(jt(r))n.push(xS(r));if(r.type==="Identifier"&&ld.has(r.name)&&Vr(r,s)&&!gS(r.name,n))return i=!0,en},leave(r){if(jt(r))n.pop()}}),i}function pd(e){if(e.runesOptionOverride!==void 0)return e.runesOptionOverride?"runes":"legacy";let t=e.parsed;if(!t)return"legacy";if(e.source!==void 0&&!yS(e.source))return"legacy";let n=new Set;Tr(t.module?.content.body,n);let i=new Set;return Tr(t.instance?.content.body,i),Oo(t.module,[n])||Oo(t.instance,[n,i])||Oo(t.fragment,[n,i])?"runes":"legacy"}var ES=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function SS(e){if(e.type!=="TSAsExpression"&&e.type!=="TSTypeAssertion")return!1;let t="typeAnnotation"in e?e.typeAnnotation:void 0;return t?.type==="TSTypeReference"&&t.typeName.type==="Identifier"&&t.typeName.name==="const"}function br(e,t){if(!e)return;K(e,{enter(n){if(!ES.has(n.type)||!("expression"in n)||!n.expression)return;let{expression:i}=n;if(typeof i!=="object")return i;let r=t.typeAssertions.get(n);if(t.constAssertions.has(n)||r===void 0&&SS(n))t.constAssertions.add(i);else if(r!==void 0)t.typeAssertions.set(i,r);else if((n.type==="TSAsExpression"||n.type==="TSTypeAssertion")&&"typeAnnotation"in n)t.typeAssertions.set(i,n.typeAnnotation);return i}})}var TS=/\/\/(?<!^[ \t]*\*.*\/\/)\s*@ts-[^\n\r]*/gm;function bS(e){if(!e.includes("@ts-"))return e;let t=e.charCodeAt(0)===65279?1:0,{instance:n,module:i}=Ji(e),r=[n,i].flatMap((o)=>o?[o.content]:[]).sort((o,a)=>o.start-a.start),s="",l=0;for(let{start:o,end:a}of r)s+=e.slice(l,o+t),s+=e.slice(o+t,a+t).replace(TS,""),l=a+t;return s+e.slice(l)}function cd(e,t,n){e.componentFilePath=n;let i=bS(t);e.source=i;let r=Yu(i);if(Il(e,r),e.parsed=r,e.scriptLanguage==="ts")br(r.module,e.typeCasts),br(r.instance,e.typeCasts),br(r.fragment,e.typeCasts);e.syntaxMode=pd(e);let s=r.css,l=s?i.slice(0,s.start)+" ".repeat(s.end-s.start)+i.slice(s.end):i;cs(e,r.module),cs(e,r.instance),od(e,l)}class Bo{ctx=Hr();cleanup(){this.ctx=Hr()}parseSvelteComponent(e,t){let{component:n,pending:i}=this.parse(e,t);if(i)n[Oe]={...n[Oe]??{canonicalPropNames:[],localTypeDeclarations:[],typeImportStatements:[]},...i};return n}parse(e,t){this.cleanup();let n=this.ctx;cd(n,e,t.filePath),lu(n);let i=Vl(n);return eu(n,i)}}var vS=/\.$/,Fo="resolving it needs file access (generateBundle or the CLI)";function CS(e,t={}){let n=e[Oe];if(!n)return e;let{pendingCallDefaultCandidates:i,pendingConstDefaultCandidates:r,pendingContextKeyCandidates:s,pendingDispatchEscapeCandidates:l,deferredEventNoSourceDiagnostics:o,untypedJsDocEventNames:a,...p}=n,c=(i??[]).filter((v)=>v.importSource!==void 0);if(c.length===0&&!r&&!s&&!l&&!o)return e;let u="filePath"in e?e.filePath:void 0,f=t.filePath??(typeof u==="string"?u:""),h=[],m=(v,Y,me,Le)=>{h.push(oi({component:f,kind:"cross-file-unresolved",name:v,message:Y,...me?{source:me}:{},...Le?{ignored:Le}:{}}))},g=(v,Y)=>(v==="props"?e.props:e.moduleExports).find((me)=>me.name===Y)?.source,y=(v)=>v==="props"?"Prop":"Module export";for(let v of s??[]){let Y=dn(v);m(Y,`setContext key \`${Y}\` is imported from "${v.importSource}"; ${Fo}, so the context is omitted.`,v.source)}for(let v of r??[])m(v.propName,`${y(v.location)} "${v.propName}" defaults to \`${dn(v)}\` imported from "${v.importSource}"; ${Fo}, so the default shows the identifier and its type isn't read.`,g(v.location,v.propName));for(let v of c)m(v.propName,`${y(v.location)} "${v.propName}" defaults to \`${v.calleeName}()\` imported from "${v.importSource}"; ${Fo}, so its return type isn't read and the prop falls back to "any".`,g(v.location,v.propName));for(let v of l??[])m(v.calleeText,`\`${v.dispatcherName}\` is passed to \`${v.calleeText}\`, imported from "${v.importSource}"; reading the events it dispatches needs file access (generateBundle or the CLI), so they're omitted.`,v.source,v.ignored);let S=Array.from(new Set((l??[]).map((v)=>`\`${v.calleeText}\``))).join(", "),b=(o??[]).map((v)=>S?{...v,message:`${v.message.replace(vS,"")} in this file; ${S} may dispatch it, but imported helpers aren't read without file access.`}:v),M={...e,diagnostics:[...e.diagnostics??[],...b,...h]};return M[Oe]=p,M}var dd="sveld",fd="0.41.0";var Vo="5.59.1";var hd=1;function rt(e){return e.some((t)=>t.internal)?e.filter((t)=>!t.internal):e}function wS(e){return{...e,props:rt(e.props),moduleExports:rt(e.moduleExports),slots:rt(e.slots),events:rt(e.events),typedefs:rt(e.typedefs),...e.contexts?{contexts:rt(e.contexts).map((t)=>({...t,properties:rt(t.properties)}))}:{}}}function jo(e,t={}){let n=Array.from(e.values(),(s)=>{let{diagnostics:l,...o}=s;return wS(o)}).sort((s,l)=>Ve(s.moduleName,l.moduleName)),i={schemaVersion:hd,generator:{name:dd,version:fd,svelteVersion:Vo},total:n.length,components:n},r=t.entryExports?rt(t.entryExports):void 0;if(r&&r.length>0)i.totalExports=r.length,i.exports=r;return i}var PS=" ",kS=120,_S=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,NS=200,xd=/\s/,DS=/\s{2}|[^\S ]/,$S=/["'`{}/]/g,IS=/["'`{};/]/g,Ed=9,Go=10,LS=13,Kn=32,Cr=34,RS=38,Ar=39,MS=40,OS=41,vr=42,md=46,Ho=47,Sd=59,BS=62,FS=91,Uo=92,VS=93,wr=96,qo=123,jS=124,zo=125;function GS(e){return _S.test(HS(e,NS))}var yd=[""];function WS(e){let t=yd[e];if(t===void 0)t=PS.repeat(e),yd[e]=t;return t}function HS(e,t){let n="";for(let i=e.length-1;i>=0&&n.length<t;i--)n=e[i]+n;return n.length>t?n.slice(-t):n}function US(e){if(e.length===0)return!1;let t=e[e.length-1];return t.charCodeAt(t.length-1)===Go}function qS(e){while(e.length>0){let t=e[e.length-1],n=t.length;while(n>0){let i=t.charCodeAt(n-1);if(i!==Kn&&i!==Ed)break;n--}if(n===t.length)return;if(n===0){e.pop();continue}e[e.length-1]=t.slice(0,n);return}}function zS(e){while(e.length>0){let t=e[e.length-1];if(!xd.test(t[t.length-1]))return;let n=t.trimEnd();if(n.length===t.length)return;if(n.length===0){e.pop();continue}e[e.length-1]=n;return}}function KS(e){if(e.includes("{"))return!1;let t=0,n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(t!==0){if(r===t&&e.charCodeAt(i-1)!==Uo)t=0;continue}if(r===Cr||r===Ar||r===wr){t=r;continue}if(r===Sd&&++n>=2)return!0}return!1}function JS(e){if(!DS.test(e))return e.trimEnd();let t="",n=null,i=!1;for(let r=0;r<e.length;r++){let s=e[r],l=e[r-1];if(n){if(t+=s,n==="double"&&s==='"'&&l!=="\\"||n==="single"&&s==="'"&&l!=="\\"||n==="template"&&s==="`"&&l!=="\\")n=null;i=!1;continue}if(s==='"'||s==="'"||s==="`"){n=s==='"'?"double":s==="'"?"single":"template",t+=s,i=!1;continue}if(xd.test(s)){if(!i&&t.length>0)t+=" ",i=!0;continue}t+=s,i=!1}return t.trimEnd()}function Td(e,t){let n=e[t],i=e.indexOf(n,t+1);while(i!==-1&&e.charCodeAt(i-1)===Uo)i=e.indexOf(n,i+1);return i}function bd(e,t){let n=e.indexOf("*/",t+1);return n===-1?-1:n+1}function XS(e){let t=new Map,n=[],i=$S,r=0;while(r<e.length){if(i.lastIndex=r,!i.test(e))break;r=i.lastIndex-1;let s=e.charCodeAt(r);if(s===Ho){if(e.charCodeAt(r+1)===vr){let l=bd(e,r);if(l===-1)break;r=l}}else if(s===Cr||s===Ar||s===wr){let l=Td(e,r);if(l===-1)break;r=l}else if(s===qo)n.push(r);else if(s===zo){let l=n.pop();if(l!==void 0)t.set(l,r)}r++}return t}function YS(e,t,n){for(let i=t;i<n;i++)if(!Wo(e.charCodeAt(i)))return!1;return!0}function Wo(e){if(e<=Kn)return e===Kn||e>=Ed&&e<=LS;if(e<160)return!1;return e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function vd(e,t,n,i){let r=[],s=IS,l=t,o=t;while(o<n){if(s.lastIndex=o,!s.test(e))break;if(o=s.lastIndex-1,o>=n)break;let a=e.charCodeAt(o);if(a===Ho){if(e.charCodeAt(o+1)===vr){let p=bd(e,o);if(p===-1)break;o=p}o++;continue}if(a===Cr||a===Ar||a===wr){let p=Td(e,o);if(p===-1)break;o=p+1;continue}if(a===qo){let p=i.get(o);if(p===void 0||p>=n){o++;continue}if(l<o)r.push(e.slice(l,o));let c=o+1;if(YS(e,c,p)){r.push("{}"),o=p+1,l=o;continue}let u=e.slice(c,p),f=e.charCodeAt(c)===Go;if(!f&&!u.includes("/*")&&!KS(u)&&!GS(r)){let h=vd(e,c,p,i),m=h.trim();if(!m.includes(`
|
|
59
59
|
`)){let g=m.endsWith(";")?m.slice(0,-1):m,y=`{ ${JS(g)} }`;if(y.length<=kS){r.push(y),o=p+1,l=o;continue}}if(r.push("{"),h.charCodeAt(0)!==Sd)r.push(`
|
|
60
60
|
`);if(h.length>0)r.push(h);o=p,l=p;continue}if(r.push("{"),!f)r.push(`
|
|
61
61
|
`);o=c,l=c;continue}if(a===zo){if(l<o)r.push(e.slice(l,o));if(qS(r),!US(r))r.push(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R,ve}from"./chunk-
|
|
1
|
+
import{R,ve}from"./chunk-h308tz7m.js";import{Kt,ne,qt,Wt,Ht,Be,zt,re}from"./chunk-zmd679kg.js";export{re as ComponentParser,Wt as deriveLiteralDetailType,qt as extractJsDocDeprecatedAndTags,Kt as extractJsDocReturnType,ne as extractJsDocType,ve as formatParseError,Ht as literalDetailToTypeText,R as parseModule,Be as parseSvelte,zt as parseSvelteScripts};
|