sveld 0.35.0 → 0.35.2
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 +46 -4
- package/cli.js +1 -1
- package/lib/ComponentParser.d.ts +164 -398
- package/lib/ast-guards.d.ts +2 -0
- package/lib/browser.d.ts +39 -0
- package/lib/browser.js +268 -0
- package/lib/bundle.d.ts +9 -4
- package/lib/chunk-1p4ka68s.js +2 -0
- package/lib/chunk-72hx9e9w.js +20 -0
- package/lib/chunk-7qz0hzgw.js +217 -0
- package/lib/chunk-8xw75w8t.js +10 -0
- package/lib/chunk-cxrw7gzr.js +2 -0
- package/lib/chunk-jdnsv86e.js +1 -0
- package/lib/chunk-pmj8c3yv.js +6 -0
- package/lib/chunk-s9mzxa4y.js +1 -0
- package/lib/chunk-v4q9vw0y.js +62 -0
- package/lib/chunk-xkrgedm4.js +4 -0
- package/lib/chunk-zva3xjwa.js +13 -0
- package/lib/cli-entry.d.ts +12 -0
- package/lib/cli-entry.js +1 -0
- package/lib/get-svelte-entry.d.ts +0 -1
- package/lib/index.js +1 -484
- package/lib/parse-cache.d.ts +1 -1
- package/lib/parse-entry-exports.d.ts +2 -2
- package/lib/parse-exports.d.ts +5 -1
- package/lib/parsed-component-metadata.d.ts +13 -0
- package/lib/parser/bindings.d.ts +0 -2
- package/lib/parser/context.d.ts +13 -51
- package/lib/parser/events.d.ts +0 -2
- package/lib/parser/jsdoc.d.ts +0 -4
- package/lib/parser/prop-shared.d.ts +84 -0
- package/lib/parser/props.d.ts +6 -2
- package/lib/parser/rest-props.d.ts +0 -2
- package/lib/parser/runes-detection.d.ts +13 -0
- package/lib/parser/scopes.d.ts +23 -7
- package/lib/parser/slots.d.ts +1 -6
- package/lib/parser/source-position.d.ts +0 -4
- package/lib/parser/type-resolution.d.ts +4 -14
- package/lib/parser/typescript-casts.d.ts +1 -0
- package/lib/parser/utils.d.ts +1 -0
- package/lib/parser/variable-jsdoc.d.ts +12 -0
- package/lib/parser-stack.d.ts +20 -0
- package/lib/path.d.ts +0 -1
- package/lib/resolve-types.d.ts +1 -1
- package/lib/svelte-parse.d.ts +4 -0
- package/lib/svelte-version.d.ts +1 -0
- package/lib/writer/Writer.d.ts +7 -29
- package/lib/writer/WriterMarkdown.d.ts +0 -2
- package/lib/writer/markdown-format-utils.d.ts +0 -84
- package/lib/writer/writer-json.d.ts +2 -12
- package/lib/writer/writer-markdown.d.ts +0 -2
- package/lib/writer/writer-ts-definitions-core.d.ts +1 -9
- package/lib/writer/writer-ts-definitions.d.ts +1 -28
- package/package.json +6 -1
package/lib/bundle.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type NormalizedPath } from "./brands";
|
|
2
|
-
import {
|
|
1
|
+
import { asRelativeSourcePath, type NormalizedPath } from "./brands";
|
|
2
|
+
import type { ParsedComponent } from "./ComponentParser";
|
|
3
3
|
import { type SveldDiagnostic } from "./diagnostics";
|
|
4
4
|
import { ParseCache } from "./parse-cache";
|
|
5
5
|
import { type EntryExports } from "./parse-entry-exports";
|
|
@@ -99,6 +99,13 @@ export interface CollectedComponents {
|
|
|
99
99
|
rootDir: string;
|
|
100
100
|
resolveComponentFilePath: ResolveComponentFilePath;
|
|
101
101
|
}
|
|
102
|
+
/** A `.svelte` file discovered on disk, before it's merged into `exports`/`allComponents`. */
|
|
103
|
+
export interface GlobbedComponentSource {
|
|
104
|
+
moduleName: string;
|
|
105
|
+
source: ReturnType<typeof asRelativeSourcePath>;
|
|
106
|
+
}
|
|
107
|
+
/** Globs every `.svelte` file under `rootDir`, resolving each to its module name and source path. */
|
|
108
|
+
export declare function globComponentSources(rootDir: string): GlobbedComponentSource[];
|
|
102
109
|
/**
|
|
103
110
|
* Discovers component sources for an entry point without parsing them.
|
|
104
111
|
*
|
|
@@ -134,9 +141,7 @@ export declare function readFileMap(filePaths: Iterable<string>): Promise<Map<st
|
|
|
134
141
|
* @param options - Parse-failure handling (`failFast` / `onParseError`)
|
|
135
142
|
*/
|
|
136
143
|
export declare function processComponent([exportName, entry]: [string, ParsedExports[string]], entries: Array<[string, ParsedExports[string]]>, fileMap: Map<string, string | null>, resolveComponentFilePath: ResolveComponentFilePath, options?: ProcessComponentOptions): ComponentDocApi | null;
|
|
137
|
-
/** Collects the resolved, absolute paths of all `.svelte` entries. */
|
|
138
144
|
export declare function collectSvelteFilePaths(entriesList: Array<Array<[string, ParsedExports[string]]>>, resolveComponentFilePath: ResolveComponentFilePath): Set<string>;
|
|
139
|
-
/** Reports collected component parse errors to stderr. No-op when empty. */
|
|
140
145
|
export declare function reportParseErrors(errors: ComponentParseError[]): void;
|
|
141
146
|
/**
|
|
142
147
|
* Generates component documentation bundle from Svelte source files.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as s}from"node:module";var j=Object.create;var{getPrototypeOf:k,defineProperty:f,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,t=(a,b,c)=>{var g=a!=null&&typeof a==="object";if(g){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?j(k(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of l(a))if(!m.call(d,e))f(d,e,{get:n.bind(a,e),enumerable:!0});if(g)h.set(a,d);return d};var u=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var q=(a)=>a;function r(a,b){this[a]=q.bind(null,b)}var v=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:r.bind(b,c)})};var x=s(import.meta.url);
|
|
2
|
+
export{t as T,u as U,v as V,x as W};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import{A as m,B as KO,C as vO,D as gO,E as yO,F as S0,G as xO,H as uO,I as eO,J as IO,K as O1,L as mO,u as ZO,x as tO,y as v,z as r0}from"./chunk-xkrgedm4.js";import{M as b0}from"./chunk-v4q9vw0y.js";class R0{constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:()=>this.should_skip=!0,remove:()=>this.should_remove=!0,replace:(O)=>this.replacement=O}}replace(O,Z,$,Q){if(O&&Z)if($!=null)O[Z][$]=Q;else O[Z]=Q}remove(O,Z,$){if(O&&Z)if($!==null&&$!==void 0)O[Z].splice($,1);else delete O[Z]}}class T0 extends R0{constructor(O,Z){super();this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:()=>this.should_skip=!0,remove:()=>this.should_remove=!0,replace:($)=>this.replacement=$},this.enter=O,this.leave=Z}visit(O,Z,$,Q){if(O){if(this.enter){let Y=this.should_skip,X=this.should_remove,K=this.replacement;if(this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,O,Z,$,Q),this.replacement)O=this.replacement,this.replace(Z,$,Q,O);if(this.should_remove)this.remove(Z,$,Q);let q=this.should_skip,z=this.should_remove;if(this.should_skip=Y,this.should_remove=X,this.replacement=K,q)return O;if(z)return null}let W;for(W in O){let Y=O[W];if(Y&&typeof Y==="object"){if(Array.isArray(Y)){let X=Y;for(let K=0;K<X.length;K+=1){let q=X[K];if($O(q)){if(!this.visit(q,O,W,K))K--}}}else if($O(Y))this.visit(Y,O,W,null)}}if(this.leave){let Y=this.replacement,X=this.should_remove;if(this.replacement=null,this.should_remove=!1,this.leave.call(this.context,O,Z,$,Q),this.replacement)O=this.replacement,this.replace(Z,$,Q,O);if(this.should_remove)this.remove(Z,$,Q);let K=this.should_remove;if(this.replacement=Y,this.should_remove=X,K)return null}}return O}}function $O(O){return O!==null&&typeof O==="object"&&"type"in O&&typeof O.type==="string"}function Q0(O,{enter:Z,leave:$}){return new T0(Z,$).visit(O,null)}function e(O){return typeof O==="object"&&O!==null}function QO(O){return e(O)&&O.type==="VariableDeclaration"&&Array.isArray(O.declarations)}function G0(O){return e(O)&&O.type==="Literal"}function O0(O){return e(O)&&O.type==="Identifier"&&typeof O.name==="string"}function WO(O){return e(O)&&O.type==="MemberExpression"}function A0(O){return e(O)&&O.type==="ObjectExpression"&&Array.isArray(O.properties)}function Z1(O){return e(O)&&O.type==="CallExpression"}function Z0(O,Z){if(!Z1(O))return!1;return!!O.callee&&e(O.callee)&&O.callee.type==="Identifier"&&O.callee.name===Z}function X0(O){if(e(O)&&(O.type==="TSAsExpression"||O.type==="TSSatisfiesExpression")&&"expression"in O)return X0(O.expression);return O}function YO(O){if(e(O)&&(O.type==="TSAsExpression"||O.type==="TSSatisfiesExpression")&&"typeAnnotation"in O)return O.typeAnnotation;return}function $1(O){return e(O)&&O.type==="NewExpression"}function N0(O,Z){if(!$1(O))return!1;return!!O.callee&&e(O.callee)&&O.callee.type==="Identifier"&&O.callee.name===Z}var qO={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 Q1(O){return O in qO}function XO(O){if(Q1(O))return qO[O];return"HTMLElement"}var W1=/\w/;function Y1(O,Z){let $=O.trim();if(!$.startsWith("{")||!$.endsWith("}"))return;let Q=$.slice(1,-1),W=[],Y=0,X="";for(let K of Q)if(K==="{"||K==="<"||K==="("||K==="[")Y++,X+=K;else if(K==="}"||K===">"||K===")"||K==="]")Y--,X+=K;else if((K===";"||K===",")&&Y===0)W.push(X.trim()),X="";else X+=K;if(X.trim())W.push(X.trim());for(let K of W){if(!K.startsWith(Z))continue;let q=K.slice(Z.length);if(q.length>0&&W1.test(q[0]))continue;let z=q.trimStart();if(z.startsWith("?"))z=z.slice(1).trimStart();if(z.startsWith(":"))return z.slice(1).trim()}return}function I0(O,Z,$){let Q=$;if(Q.computed||Q.object?.type!=="Identifier"||Q.property?.type!=="Identifier")return;let W=Q.object.name,Y=Q.property.name;if(!W||!Y)return;if(O.wholePropsLocals.has(W))return Z.getPropTypeByLocalOrPublic(Y);let X=Z.getPropTypeByLocalOrPublic(W)??Z.findVariableTypeAndDescription(W)?.type;if(!X)return;return Y1(X,Y)}function v0(){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,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}}function W0(O,Z,$,Q,W){O.diagnosticRecords.push({component:O.componentFilePath,kind:Z,name:$,message:Q,...W?{source:W}:{}})}function a(O){return O===void 0||O===""?void 0:O}var q1=/[\r\n]+/g;function j0(O,Z,$,Q){if(a($)===void 0)return;if(O.trackPropLocalName($),Z.props.has($)){let W=Z.props.get($);Z.props.set($,{...W,...Q})}else Z.props.set($,Q)}function z0(O,Z,$,Q=0){let W,Y,X=!1;if(!$||typeof $!=="object"||!("type"in $))return{value:W,type:Y,isFunction:X};let K=j1(O,Z,$);if($.type==="ObjectExpression"||$.type==="BinaryExpression"||$.type==="ArrayExpression"||$.type==="ArrowFunctionExpression"||$.type==="FunctionExpression"){let q=$;if("start"in q&&"end"in q&&typeof q.start==="number"&&typeof q.end==="number")W=m(Z,q.start,q.end)?.replace(q1," ");if(Y=W,X=$.type==="ArrowFunctionExpression"||$.type==="FunctionExpression",$.type==="BinaryExpression"){let z=$;if(z.left&&typeof z.left==="object"&&"type"in z.left&&z.left.type==="Literal"&&"value"in z.left&&typeof z.left.value==="string")Y="string"}if($.type==="ArrowFunctionExpression"||$.type==="FunctionExpression")Y=zO($),W=void 0}else if($.type==="UnaryExpression"){let q=$;if("start"in q&&"end"in q&&typeof q.start==="number"&&typeof q.end==="number")W=m(Z,q.start,q.end);if(q.argument){if(typeof q.argument==="object"&&"type"in q.argument&&q.argument.type==="UnaryExpression")Y=z0(O,Z,q.argument).type;else if(typeof q.argument==="object"&&"value"in q.argument)Y=typeof q.argument.value}}else if($.type==="NewExpression"){let q=$;if("start"in q&&"end"in q&&typeof q.start==="number"&&typeof q.end==="number")W=m(Z,q.start,q.end);if(q.callee&&typeof q.callee==="object"&&"type"in q.callee&&q.callee.type==="Identifier"){let z=q.callee.name;if(z==="Date")Y="Date";else if(z==="Map")Y="Map<any, any>";else if(z==="Set")Y="Set<any>";else if(z==="WeakMap")Y="WeakMap<object, any>";else if(z==="WeakSet")Y="WeakSet<object>";else if(z==="Array")Y="any[]";else if(z==="RegExp"||z==="Regexp")Y="RegExp";else if(z==="Error")Y="Error";else Y=z}}else if($.type==="CallExpression"){let q=$;if("start"in q&&"end"in q&&typeof q.start==="number"&&typeof q.end==="number")W=m(Z,q.start,q.end)}else if($.type==="Identifier"){let q=$;if(Q<5){let z=X1(Z,q.name);if(z){let H=z0(O,Z,z,Q+1),w=O.resolveLocalVarJSDoc(q.name);return{...H,resolvedType:w?.type??H.resolvedType,resolvedDescription:w?.description??H.resolvedDescription,resolvedParams:w?.params??H.resolvedParams,resolvedReturnType:w?.returnType??H.resolvedReturnType}}if(Z.funcDecls.has(q.name)){let H=O.resolveLocalVarJSDoc(q.name),w=Z.funcDecls.get(q.name);return{value:void 0,type:void 0,isFunction:!0,resolvedType:H?.type??K1(H,w),resolvedDescription:H?.description,resolvedParams:H?.params,resolvedReturnType:H?.returnType}}}if("start"in q&&"end"in q&&typeof q.start==="number"&&typeof q.end==="number")W=m(Z,q.start,q.end)}else if($.type==="MemberExpression"){let q=$;if("start"in q&&"end"in q&&typeof q.start==="number"&&typeof q.end==="number")W=m(Z,q.start,q.end);if(O.isNumericConstant($))Y="number"}else if($.type==="TemplateLiteral"){let q=$;if("start"in q&&"end"in q&&typeof q.start==="number"&&typeof q.end==="number")W=m(Z,q.start,q.end);Y="string"}else if("raw"in $&&typeof $.raw==="string"){if(W=$.raw,"value"in $)Y=$.value==null?void 0:typeof $.value}return{value:W,type:Y,isFunction:X,defaultValue:K}}function X1(O,Z){for(let $ of O.vars)for(let Q of $.declarations)if(Q.id&&typeof Q.id==="object"&&"type"in Q.id&&Q.id.type==="Identifier"&&"name"in Q.id&&Q.id.name===Z&&Q.init)return Q.init;return}function GO(O,Z){for(let $ of O.vars){if($.kind!=="const")continue;for(let Q of $.declarations)if(Q.id&&typeof Q.id==="object"&&"type"in Q.id&&Q.id.type==="Identifier"&&"name"in Q.id&&Q.id.name===Z&&Q.init)return Q.init}return}function K1(O,Z){let $=O?.returnType??"any",Q=O?.params;if(Q&&Q.length>0)return`(${Q.map((Y)=>`${Y.name}${Y.optional?"?":""}: ${Y.type}`).join(", ")}) => ${$}`;if(O?.returnType)return`() => ${$}`;if(Z)return zO(Z);return"(...args: any[]) => any"}function zO(O){return`(${G1(O)}) => ${z1(O)}`}function G1(O){let Z=O.params;if(!Array.isArray(Z)||Z.length===0)return"...args: any[]";let $=[];for(let Q of Z)if(Q&&typeof Q==="object"&&"type"in Q&&Q.type==="Identifier"&&"name"in Q&&typeof Q.name==="string")$.push(`${Q.name}: any`);else return"...args: any[]";return $.join(", ")}function z1(O){if(O.async||O.generator)return"any";let Z=O.body,$;if(Z&&typeof Z==="object"&&"type"in Z&&Z.type==="BlockStatement"){if($=H1(Z),$.length===0)return"any"}else $=[Z];let Q=null;for(let W of $){let Y=U1(W);if(!Y)return"any";if(Q===null)Q=Y;else if(Q!==Y)return"any"}return Q??"any"}function H1(O){let Z=[];return Q0(O,{enter($){if($.type==="FunctionDeclaration"||$.type==="FunctionExpression"||$.type==="ArrowFunctionExpression"){this.skip();return}if($.type==="ReturnStatement")Z.push($.argument??null)}}),Z}function U1(O){if(!O||typeof O!=="object"||!("type"in O))return null;switch(O.type){case"Literal":{let Z=O.value;if(typeof Z==="string")return"string";if(typeof Z==="number")return"number";if(typeof Z==="boolean")return"boolean";return null}case"TemplateLiteral":return"string";case"CallExpression":{let Z=O.callee;if(Z&&typeof Z==="object"&&"type"in Z&&Z.type==="Identifier"){let $=Z.name;if($==="String")return"string";if($==="Number")return"number";if($==="Boolean")return"boolean"}return null}default:return null}}function HO(O){if(Z0(O,"$bindable"))return{init:O.arguments[0],bindable:!0};return{init:O,bindable:!1}}function j1(O,Z,$){let Q=KO(Z,$);if(!Q||!$||typeof $!=="object"||!("type"in $))return;let W="expression";if($.type==="Literal"||$.type==="UnaryExpression")W="literal";else if($.type==="TemplateLiteral")W=$.expressions.length===0?"literal":"expression";else if($.type==="ArrayExpression")W="array";else if($.type==="ObjectExpression")W="object";else if($.type==="ArrowFunctionExpression"||$.type==="FunctionExpression")W="function";let Y={raw:Q,kind:W};if(W==="literal"||W==="array"||W==="object"){let X=g0(O,$);if(X.ok)Y.value=X.value}return Y}function g0(O,Z){if(!Z||typeof Z!=="object"||!("type"in Z))return{ok:!1};if(Z.type==="Literal"){let $=Z.value;return typeof $==="bigint"?{ok:!1}:{ok:!0,value:$}}if(Z.type==="UnaryExpression"){let $=Z,Q=$.argument;if(!Q||typeof Q!=="object"||!("type"in Q)||Q.type!=="Literal")return{ok:!1};let W=Q.value;if(typeof W==="number"){if($.operator==="-")return{ok:!0,value:-W};if($.operator==="+")return{ok:!0,value:W}}if(typeof W==="boolean"&&$.operator==="!")return{ok:!0,value:!W};return{ok:!1}}if(Z.type==="TemplateLiteral"){let $=Z;if($.expressions.length>0||$.quasis.length!==1)return{ok:!1};return{ok:!0,value:$.quasis[0].value.cooked??$.quasis[0].value.raw}}if(Z.type==="ArrayExpression"){let $=Z,Q=[];for(let W of $.elements){if(!W)return{ok:!1};let Y=g0(O,W);if(!Y.ok)return{ok:!1};Q.push(Y.value)}return{ok:!0,value:Q}}if(Z.type==="ObjectExpression"){let $=Z,Q={};for(let W of $.properties){if(W.type!=="Property"||W.computed)return{ok:!1};let Y=O.getPropertyName(W.key);if(!Y)return{ok:!1};let X=g0(O,W.value);if(!X.ok)return{ok:!1};Q[Y]=X.value}return{ok:!0,value:Q}}return{ok:!1}}var w1=/[-_.:/\s]+/;function y0(O){return`${O.split(w1).map((Q)=>Q.charAt(0).toUpperCase()+Q.slice(1)).join("")}Context`}function M1(O,Z,$,Q){if(!$||typeof $!=="object"||!("type"in $))return null;if($.type==="ObjectExpression"){let W=[];if(!A0($))return null;let Y=$;for(let X of Y.properties){if(X.type!=="Property")continue;let K=Z.getPropertyName(X.key);if(!K)continue;let q="any",z;if(O0(X.value)){let H=X.value.name,w=Z.findVariableTypeAndDescription(H);if(w)q=w.type,z=w.description;else W0(O,"context-any-type",K,`Context "${Q}" property "${K}" has no type annotation; defaulted to "any".`,v(O,X))}else if(X.value&&typeof X.value==="object"&&"type"in X.value&&(X.value.type==="ArrowFunctionExpression"||X.value.type==="FunctionExpression"))q=`(${X.value.params?.map((A)=>{if(O0(A))return`${A.name||"arg"}: any`;return"arg: any"}).join(", ")||""}) => any`;else if(G0(X.value))q=X.value.value==null?"null":typeof X.value.value;W.push({name:K,type:q,description:z,optional:!1})}return{key:Q,typeName:y0(Q),properties:W,description:void 0}}else if(O0($)){let W=$.name,Y=Z.findVariableTypeAndDescription(W);if(Y)return{key:Q,typeName:y0(Q),properties:[{name:W,type:Y.type,description:Y.description,optional:!1}]};return W0(O,"context-any-type",W,`Context "${Q}" variable "${W}" has no type annotation; defaulted to "any".`,v(O,$)),{key:Q,typeName:y0(Q),properties:[{name:W,type:"any",description:void 0,optional:!1}]}}return null}function UO(O){let Z=O.callee;if(!Z||typeof Z!=="object"||!("type"in Z))return null;let $=Z.type==="Identifier"&&Z.name==="Symbol",Q=Z.type==="MemberExpression"&&!Z.computed&&Z.object.type==="Identifier"&&Z.object.name==="Symbol"&&Z.property.type==="Identifier"&&Z.property.name==="for";if(!$&&!Q)return null;let W=O.arguments[0];if(!W||typeof W!=="object"||!("type"in W))return"";if(W.type==="Literal"&&typeof W.value==="string")return W.value;if(W.type==="TemplateLiteral"&&W.quasis?.length===1)return W.quasis[0].value.cooked??"";return""}function jO(O,Z,$=0){if(!Z||typeof Z!=="object"||!("type"in Z))return null;let Q=Z;if(Q.type==="Literal")return typeof Q.value==="string"?Q.value:Q.value==null?null:String(Q.value);if(Q.type==="TemplateLiteral"){if(Q.quasis?.length===1){let W=Q.quasis[0].value.cooked;return W==null?null:W}return null}if(Q.type==="CallExpression"||Q.type==="NewExpression")return UO(Q);if(Q.type==="Identifier"){if($>=5)return null;let W=GO(O,Q.name);if(W&&typeof W==="object"&&"type"in W){let Y=W;if((Y.type==="CallExpression"||Y.type==="NewExpression")&&UO(Y)==="")return Q.name;return jO(O,Y,$+1)}return null}return null}function wO(O,Z,$,Q){if(!$||typeof $!=="object"||!("type"in $)||$.type!=="CallExpression")return;let W=$,Y=W.arguments[0];if(!Y)return;let X=jO(O,Y);if(!X){let z=O.componentFilePath?` in ${O.componentFilePath}`:"";console.warn(`Warning: Could not resolve setContext key${z}. Use a string literal, const-bound string, or Symbol(). Skipping context type generation.`);return}let K=W.arguments[1];if(!K)return;let q=M1(O,Z,K,X);if(q&&!O.contexts.has(X))O.contexts.set(X,q)}function x0(O){return typeof O==="string"?JSON.stringify(O):String(O)}function w0(O,{name:Z,detail:$,has_argument:Q,description:W,deprecated:Y,tags:X,source:K}){if(Z===void 0)return;let q=!Q&&!$?"null":a($),z=W,H=O.events.get(Z);if(H?.type==="forwarded")O.events.set(Z,{type:"dispatched",name:Z,detail:q,description:z||H.description,deprecated:Y??H.deprecated,tags:X??H.tags,source:K||H.source});else if(H){let w=H.tags??X;O.events.set(Z,{...H,detail:H.detail===void 0?q:H.detail,description:H.description||z,deprecated:H.deprecated??Y,tags:w,source:K||H.source})}else O.events.set(Z,{type:"dispatched",name:Z,detail:q,description:z,deprecated:Y,tags:X,source:K})}function MO(O,Z){let $=Z.arguments[0],Q=N0($,"CustomEvent");if(!Q&&!N0($,"Event"))return;let W=$.arguments[0],Y=G0(W)?W.value:void 0;if(Y==null)return;let X=Q?$.arguments[1]:void 0,K=!1,q;if(A0(X)){let z=X.properties.find((H)=>H.type==="Property"&&O0(H.key)&&H.key.name==="detail");if(z?.type==="Property")K=!0,q=G0(z.value)?z.value.value:void 0}return w0(O,{name:String(Y),detail:q==null?"":x0(q),has_argument:K,source:v(O,Z)}),String(Y)}function u0(O,Z,$=!1){if(O.length===0)return"null";let Q=O.map(({name:W,type:Y,description:X,optional:K,default:q})=>{let z=K?"?":"",H=X||"";if(q&&H)H=`${H} @default ${q}`;else if(q)H=`@default ${q}`;if(H){if($)return`/** ${H} */
|
|
2
|
+
${W}${z}: ${Y};`;return`/** ${H} */ ${W}${z}: ${Y};`}return`${W}${z}: ${Y};`}).join($?`
|
|
3
|
+
`:" ");return $?`{
|
|
4
|
+
${Q}
|
|
5
|
+
}`:`{ ${Q} }`}var t;(function(O){O.start="/**",O.nostart="/***",O.delim="*",O.end="*/"})(t=t||(t={}));function m0(O){return/^\s+$/.test(O)}function JO(O){let Z=O.match(/\r+$/);return Z==null?["",O]:[O.slice(-Z[0].length),O.slice(0,-Z[0].length)]}function Y0(O){let Z=O.match(/^\s+/);return Z==null?["",O]:[O.slice(0,Z[0].length),O.slice(Z[0].length)]}function BO(O){return O.split(/\n/)}function VO(O={}){return Object.assign({tag:"",name:"",type:"",optional:!1,description:"",problems:[],source:[]},O)}function l0(O={}){return Object.assign({start:"",delimiter:"",postDelimiter:"",tag:"",postTag:"",name:"",postName:"",type:"",postType:"",description:"",end:"",lineEnd:""},O)}var J1=/^@\S+/;function d0({fence:O="```"}={}){let Z=B1(O),$=(Q,W)=>Z(Q)?!W:W;return function(W){let Y=[[]],X=!1;for(let K of W){if(J1.test(K.tokens.description)&&!X)Y.push([K]);else Y[Y.length-1].push(K);X=$(K.tokens.description,X)}return Y}}function B1(O){if(typeof O==="string")return(Z)=>Z.split(O).length%2===0;return O}function i0({startLine:O=0,markers:Z=t}={}){let $=null,Q=O;return function(Y){let X=Y,K=l0();if([K.lineEnd,X]=JO(X),[K.start,X]=Y0(X),$===null&&X.startsWith(Z.start)&&!X.startsWith(Z.nostart))$=[],K.delimiter=X.slice(0,Z.start.length),X=X.slice(Z.start.length),[K.postDelimiter,X]=Y0(X);if($===null)return Q++,null;let q=X.trimRight().endsWith(Z.end);if(K.delimiter===""&&X.startsWith(Z.delim)&&!X.startsWith(Z.end))K.delimiter=Z.delim,X=X.slice(Z.delim.length),[K.postDelimiter,X]=Y0(X);if(q){let z=X.trimRight();K.end=X.slice(z.length-Z.end.length),X=z.slice(0,-Z.end.length)}if(K.description=X,$.push({number:Q,source:Y,tokens:K}),Q++,q){let z=$.slice();return $=null,z}return null}}function c0({tokenizers:O}){return function($){var Q;let W=VO({source:$});for(let Y of O)if(W=Y(W),(Q=W.problems[W.problems.length-1])===null||Q===void 0?void 0:Q.critical)break;return W}}function F0(){return(O)=>{let{tokens:Z}=O.source[0],$=Z.description.match(/\s*(@(\S+))(\s*)/);if($===null)return O.problems.push({code:"spec:tag:prefix",message:'tag should start with "@" symbol',line:O.source[0].number,critical:!0}),O;return Z.tag=$[1],Z.postTag=$[3],Z.description=Z.description.slice($[0].length),O.tag=$[2],O}}function C0(O="compact"){let Z=L1(O);return($)=>{let Q=0,W=[];for(let[K,{tokens:q}]of $.source.entries()){let z="";if(K===0&&q.description[0]!=="{")return $;for(let H of q.description){if(H==="{")Q++;if(H==="}")Q--;if(z+=H,Q===0)break}if(W.push([q,z]),Q===0)break}if(Q!==0)return $.problems.push({code:"spec:type:unpaired-curlies",message:"unpaired curlies",line:$.source[0].number,critical:!0}),$;let Y=[],X=W[0][0].postDelimiter.length;for(let[K,[q,z]]of W.entries()){if(q.type=z,K>0)q.type=q.postDelimiter.slice(X)+z,q.postDelimiter=q.postDelimiter.slice(0,X);[q.postType,q.description]=Y0(q.description.slice(z.length)),Y.push(q.type)}return Y[0]=Y[0].slice(1),Y[Y.length-1]=Y[Y.length-1].slice(0,-1),$.type=Z(Y),$}}var V1=(O)=>O.trim();function L1(O){if(O==="compact")return(Z)=>Z.map(V1).join("");else if(O==="preserve")return(Z)=>Z.join(`
|
|
6
|
+
`);else return O}var R1=(O)=>O&&O.startsWith('"')&&O.endsWith('"');function P0(){let O=(Z,{tokens:$},Q)=>$.type===""?Z:Q;return(Z)=>{let{tokens:$}=Z.source[Z.source.reduce(O,0)],Q=$.description.trimLeft(),W=Q.split('"');if(W.length>1&&W[0]===""&&W.length%2===1)return Z.name=W[1],$.name=`"${W[1]}"`,[$.postName,$.description]=Y0(Q.slice($.name.length)),Z;let Y=0,X="",K=!1,q;for(let H of Q){if(Y===0&&m0(H))break;if(H==="[")Y++;if(H==="]")Y--;X+=H}if(Y!==0)return Z.problems.push({code:"spec:name:unpaired-brackets",message:"unpaired brackets",line:Z.source[0].number,critical:!0}),Z;let z=X;if(X[0]==="["&&X[X.length-1]==="]"){K=!0,X=X.slice(1,-1);let H=X.split("=");if(X=H[0].trim(),H[1]!==void 0)q=H.slice(1).join("=").trim();if(X==="")return Z.problems.push({code:"spec:name:empty-name",message:"empty name",line:Z.source[0].number,critical:!0}),Z;if(q==="")return Z.problems.push({code:"spec:name:empty-default",message:"empty default value",line:Z.source[0].number,critical:!0}),Z;if(!R1(q)&&/=(?!>)/.test(q))return Z.problems.push({code:"spec:name:invalid-default",message:"invalid default value syntax",line:Z.source[0].number,critical:!0}),Z}if(Z.optional=K,Z.name=X,$.name=z,q!==void 0)Z.default=q;return[$.postName,$.description]=Y0(Q.slice($.name.length)),Z}}function h0(O="compact",Z=t){let $=s0(O);return(Q)=>{return Q.description=$(Q.source,Z),Q}}function s0(O){if(O==="compact")return A1;if(O==="preserve")return C1;return O}function A1(O,Z=t){return O.map(({tokens:{description:$}})=>$.trim()).filter(($)=>$!=="").join(" ")}var I1=(O,{tokens:Z},$)=>Z.type===""?O:$,F1=({tokens:O})=>(O.delimiter===""?O.start:O.postDelimiter.slice(1))+O.description;function C1(O,Z=t){if(O.length===0)return"";if(O[0].tokens.description===""&&O[0].tokens.delimiter===Z.start)O=O.slice(1);let $=O[O.length-1];if($!==void 0&&$.tokens.description===""&&$.tokens.end.endsWith(Z.end))O=O.slice(0,-1);return O=O.slice(O.reduce(I1,0)),O.map(F1).join(`
|
|
7
|
+
`)}function p0({startLine:O=0,fence:Z="```",spacing:$="compact",markers:Q=t,tokenizers:W=[F0(),C0($),P0(),h0($)]}={}){if(O<0||O%1>0)throw Error("Invalid startLine");let Y=i0({startLine:O,markers:Q}),X=d0({fence:Z}),K=c0({tokenizers:W}),q=s0($);return function(z){let H=[];for(let w of BO(z)){let A=Y(w);if(A===null)continue;let f=X(A),N=f.slice(1).map(K);H.push({description:q(f[0],Q),tags:N,source:A,problems:N.reduce((s,i)=>s.concat(i.problems),[])})}return H}}function P1(O){return O.start+O.delimiter+O.postDelimiter+O.tag+O.postTag+O.type+O.postType+O.name+O.postName+O.description+O.end+O.lineEnd}function o0(){return(O)=>O.source.map(({tokens:Z})=>P1(Z)).join(`
|
|
8
|
+
`)}var h1={line:0,start:0,delimiter:0,postDelimiter:0,tag:0,postTag:0,name:0,postName:0,type:0,postType:0,description:0,end:0,lineEnd:0};var V3=Object.keys(h1);function M0(O,Z={}){return p0(Z)(O)}var y3=o0();var f1=null;function D1(O,Z,$){let Q={value:void 0,replace:!1};if(!$||typeof $!=="object"||!("type"in $))return Q;if($.type==="Identifier")Q.value=$.name,Q.replace=!0;else if($.type==="Literal")Q.value=String($.value);else if($.type==="MemberExpression")Q.value=I0(O,Z,$);else if(($.type==="ObjectExpression"||$.type==="TemplateLiteral")&&"start"in $&&"end"in $&&typeof $.start==="number"&&typeof $.end==="number")Q.value=m(O,$.start,$.end);return Q}function LO(O,Z,$){let Q={};for(let W of $.properties){if(W.type!=="Property"||W.computed)continue;let Y=Z.getPropertyName(W.key);if(!Y)continue;Q[Y]=D1(O,Z,W.value)}return Q}function E1(O,Z){if(!Z||typeof Z!=="object"||!("type"in Z))return null;if(Z.type==="Identifier"){let Y=Z,X=O.propLocalToPublicName.get(Y.name);if(!X)return null;return{publicName:X,trackingName:Y.name}}if(Z.type!=="MemberExpression")return null;let $=Z,Q=$.object&&typeof $.object==="object"&&"type"in $.object&&$.object.type==="Identifier"?$.object.name:void 0;if(!Q||!O.wholePropsLocals.has(Q))return null;let W;if(!$.computed&&$.property&&typeof $.property==="object"&&"type"in $.property){if($.property.type==="Identifier")W=$.property.name;else if($.property.type==="Literal"&&$.property.value!=null)W=String($.property.value)}else if($.computed&&$.property&&typeof $.property==="object"&&"type"in $.property&&$.property.type==="Literal"&&"value"in $.property&&$.property.value!=null)W=String($.property.value);if(!W)return null;return{publicName:W,trackingName:W}}function RO(O,Z){let $=Z;if($&&typeof $==="object"&&"type"in $&&$.type==="ChainExpression")$=$.expression;if(!$||typeof $!=="object"||!("type"in $)||$.type!=="CallExpression")return null;let Q=$;if(!Q.callee||typeof Q.callee!=="object"||!("type"in Q.callee))return null;let W=E1(O,Q.callee);if(!W)return null;return{...W,arguments:Q.arguments}}function S1(O){return O===void 0||O===""?void 0:O}function J0(O,{slot_name:Z,slot_props:$,slot_fallback:Q,slot_description:W,slot_deprecated:Y,slot_tags:X,source:K}){let q=Z===void 0||Z==="",z=q?f1:Z??"",H=a(Q),w=S1($),A=W?.trim()||void 0;if(O.slots.has(z)){let f=O.slots.get(z);if(f)O.slots.set(z,{...f,default:f.default??q,fallback:H,slot_props:f.slot_props===void 0?w:f.slot_props,description:f.description||A,deprecated:f.deprecated??Y,tags:f.tags||X,source:K||f.source})}else O.slots.set(z,{name:z,default:q,fallback:H,slot_props:$,description:A,deprecated:Y,tags:X,source:K})}var b1=/\s*=\s*/;function AO(O){let Z=O.indexOf("<");if(Z===-1||!O.endsWith(">"))return O;let $=O.slice(0,Z),Q=O.slice(Z+1,-1),W=IO(Q).map((Y)=>Y.trim().replace(b1," = ")).join(", ");return`${$}<${W}>`}var _1=/^\s*$/,k1=/;$/,T1=/^-\s*/;function H0(O){if(O===void 0)return;let Z=O.replace(T1,"").trim();return Z===""?"":Z}function B0(O){if(!O||O.length===0)return;return O[0].tokens.description}var FO=new Set(["since","example"]);function CO(O){if(!O||O.length===0)return"";let Z=[];for(let $ of O){let Q=$.tokens;if((Q.end??"").trim()==="*/")break;if(Q.tag){let W=`${Q.name??""}${Q.postName??""}${Q.description??""}`.trimEnd();if(W)Z.push(W)}else Z.push(`${Q.postDelimiter??""}${Q.description??""}`)}return Z.join(`
|
|
9
|
+
`)}function N1(O){let Z=O.trim();return Z===""?!0:Z}function PO(O,Z){return N1(`${O??""}${Z?` ${Z}`:""}`)}function v1(O){let Z=O.trim().replace(k1,"").trimEnd();if(!Z.startsWith("{")||!Z.endsWith("}"))return!1;let $=0,Q=null;for(let W=0;W<Z.length;W++){let Y=Z[W];if(Q!==null){if(Y==="\\"){W++;continue}if(Y===Q)Q=null;continue}if(Y==='"'||Y==="'"||Y==="`"){Q=Y;continue}if(Y==="{"||Y==="["||Y==="(")$++;else if(Y==="}"||Y==="]"||Y===")"){if($--,$===0&&W<Z.length-1)return!1}}return $===0}function g1(O){let Z=O;if(!Z.startsWith("/*"))Z=`/*${Z}`;if(!Z.endsWith("*/"))Z+="*/";return Z}function a0(O){let Z=O[0]?.tags??[],$=new Set(["type","param","returns","return","extends","extendProps","restProps","slot","snippet","event","typedef","callback","bindable","deprecated"]),Q,W=[],Y,X,K,q=[],z=[];for(let H of Z)if(H.tag==="type")Q=H;else if(H.tag==="param")W.push(H);else if(H.tag==="returns"||H.tag==="return")Y=H;else if(H.tag==="deprecated")K??=PO(H.name,H.description);else if(FO.has(H.tag))z.push(H);else if(H.tag==="bindable"){if(H.type)continue;let w=`${H.name}${H.description?` ${H.description}`:""}`.trim();if(w==="readonly"||w==="writable")X??=w}else if(!$.has(H.tag))q.push(H);return{type:Q,param:W,returns:Y,binding:X,deprecated:K,additional:q,passthrough:z,description:O[0]?.description}}function y1(O){if(!O||O.length===0)return;let Z=O[O.length-1];return Z&&typeof Z==="object"&&"value"in Z?Z:void 0}function x1(O,Z,$){if(!Z||Z.length===0||$===void 0||!O.source)return;for(let Q=Z.length-1;Q>=0;Q--){let W=Z[Q];if(!W||typeof W!=="object"||!("value"in W)||!("end"in W))continue;if(typeof W.end!=="number")continue;let Y=O.source.slice(W.end,$);if(_1.test(Y))return W}return}function K0(O,Z,$){if(!$?.leadingComments)return;let Q=x1(O,$.leadingComments,$.start);if(!Q)return;return u1(Z,[Q])}function hO(O,Z,$){if(!$?.leadingComments)return;return K0(O,Z,$)}function u1(O,Z){if(!Z)return;let $=y1(Z);if(!$)return;let Q=M0(g1($.value),{spacing:"preserve"}),{type:W,param:Y,returns:X,binding:K,deprecated:q,additional:z,passthrough:H,description:w}=a0(Q),A,f,N,s;if(W)A=O.aliasType(W.type);if(Y.length>0)f=Y.filter((b)=>!b.name.includes(".")).map((b)=>({name:b.name,type:O.aliasType(b.type),description:H0(b.description),optional:b.optional||!1}));if(X)N=O.aliasType(X.type);let i=a(w?.trim());if(i||z.length>0){let b=[];if(i)b.push(i);for(let G of z){let U=`@${G.tag}${G.name?` ${G.name}`:""}${G.description?` ${G.description}`:""}`;b.push(U)}s=b.join(`
|
|
10
|
+
`)}let x=H.length>0?H.map((b)=>({name:b.tag,body:CO(b.source)})):void 0;return{type:A,params:f,returnType:N,description:s,binding:K,deprecated:q,tags:x}}function fO(O,Z){if(!O.source)return;let $=0;for(let{tags:Q,description:W,source:Y}of M0(O.source,{spacing:"preserve"})){let X=Y.map((V)=>V.source).join(`
|
|
11
|
+
`),K=O.source.indexOf(X,$),q=K===-1?void 0:K;if(K!==-1)$=K+X.length;let z,H,w,A,f,N,s=[],i=[],x,b,G,U=[],J,F,j=[],M,L=!1,B=!0,I=[],T,S=new Map,u=new Set,p=new Set;for(let V of Q)if(V.source&&V.source.length>0)u.add(V.source[0].number);for(let V of Y)if(!V.tokens.tag&&V.tokens.description&&V.tokens.description.trim()!=="}")S.set(V.number,V.tokens.description);let $0=(V)=>{if(!V||V.length===0)return;let k=V[0].number,C=[],y=[],D=!1;for(let R=k-1;R>=1;R--){if(u.has(R))break;let P=S.get(R);if(P)C.unshift(P),y.unshift(R),D=!0;else if(D){let E=Y.find((h)=>h.number===R);if(!(!E||!E.tokens.tag&&(!E.tokens.description||E.tokens.description.trim()==="")))break}}if(C.length===0)return;for(let R of y)p.add(R);return C.join(`
|
|
12
|
+
`).trim()},_=()=>{if(z!==void 0){let V=H&&H!=="object"&&H!=="Object"?H:void 0,k;if(V)k=V;else if(i.length>0)k=u0(i,z,!0);else k=H||"";if(N!==void 0){let C;for(let R of Q){let P=R.source?.[0]?.number;if(typeof P!=="number")continue;if(P<=N)continue;if(R.tag==="property"||R.tag==="type")continue;C=P;break}let y=[],D=Array.from(S.keys()).sort((R,P)=>R-P);for(let R of D){if(R<=N)continue;if(C!==void 0&&R>=C)continue;if(p.has(R))continue;let E=S.get(R)?.trim();if(E)y.push(E),p.add(R)}if(y.length>0){let R=y.join(`
|
|
13
|
+
`);w=w?`${w}
|
|
14
|
+
${R}`:R}}w0(O,{name:z,detail:k,has_argument:!1,description:w,deprecated:A,tags:s.length>0?s:void 0,source:f}),O.eventDescriptions.set(z,w),O.jsDocEventNames.add(z),O.jsDocEventSources.set(z,f),i.length=0,z=void 0,H=void 0,w=void 0,A=void 0,f=void 0,N=void 0,s=[]}},o=()=>{if(x!==void 0){let V,k;if(U.length>0)V=u0(U,void 0,!0),k=`type ${x} = ${V};`;else if(b)V=b,k=v1(V)?`interface ${x} ${V}`:`type ${x} = ${V};`;else V="{}",k=`type ${x} = ${V};`;O.typedefs.set(x,{type:V,name:x,description:a(G),ts:k}),U.length=0,x=void 0,b=void 0,G=void 0}},c=()=>{if(J!==void 0){let C=`(${j.map(({name:D,type:R,optional:P})=>{return`${D}${P?"?":""}: ${R}`}).join(", ")}) => ${M||"void"}`,y=`type ${J} = ${C};`;O.typedefs.set(J,{type:C,name:J,description:a(F),ts:y}),j.length=0,M=void 0,J=void 0,F=void 0}},q0=Q.some((V)=>V.tag==="slot"||V.tag==="snippet"),n=Q.some((V)=>V.tag==="extends"||V.tag==="extendProps");for(let{tag:V,type:k,name:C,description:y,optional:D,default:R,source:P}of Q){let E=Z.aliasType(k),r=$0(P);switch(V){case"extends":case"extendProps":if(O.extends={interface:C,import:E},B)B=!1;break;case"restProps":{let h=C?y?`${C} ${y}`:C:y,k0=H0(h)||r;if(!k0&&B&&!L&&W)k0=W,L=!0;if(O.rest_props={type:"Element",name:E,description:k0||void 0},B)B=!1;break}case"slot":case"snippet":{let U0=H0(B0(P));if(!U0&&B&&!L&&W)U0=W,L=!0;if(!U0&&I.length===0)U0=r;if(B)B=!1;J0(O,{slot_name:C,slot_props:E,slot_description:U0||void 0,slot_deprecated:T,slot_tags:I.length>0?[...I]:void 0,source:r0(O,Y,P,q)}),I.length=0,T=void 0;break}case"event":{if(_(),z=C,H=E,N=P&&P.length>0?P[0].number:void 0,w=H0(B0(P))||r,!w&&B&&!L&&W)w=W,L=!0;if(f=r0(O,Y,P,q),B)B=!1;break}case"type":if(z!==void 0)H=E;break;case"param":if(J!==void 0)j.push({name:C,type:E,optional:D||!1});break;case"returns":case"return":if(J!==void 0)M=E;break;case"property":{let h={name:C,type:E,description:H0(B0(P)),optional:D||!1,default:R};if(z!==void 0)i.push(h);else if(x!==void 0)U.push(h);break}case"typedef":{if(o(),x=AO(C),b=E,G=H0(B0(P))||r,!G&&B&&!L&&W)G=W,L=!0;if(B)B=!1;break}case"callback":{if(c(),J=AO(C),F=H0(B0(P))||r,!F&&B&&!L&&W)F=W,L=!0;if(B)B=!1;break}case"generics":if(O.generics=[C,E],B)B=!1;break;case"template":{let h=C;if(E)h=`${C} extends ${E}`;if(R)h+=` = ${R}`;if(q0&&!n){O.deferredSlotBlockGenerics.push({name:C,constraint:h});break}if(Z.accumulateGeneric(C,h),B)B=!1;break}case"deprecated":{let h=PO(C,y);if(z===void 0)T??=h;else A??=h;break}case"enum":case"class":case"implements":case"this":case"namespace":case"memberof":case"module":case"file":case"overview":break;default:{let h={name:V,body:CO(P)};if(z!==void 0&&FO.has(V))s.push(h);else I.push(h)}break}}_(),o(),c()}}function m1({hasTypeScriptType:O,hasJSDocType:Z,inferredType:$,finalType:Q}){if(O)return"typescript";if(Z)return"jsdoc";if($!==void 0)return"default";if(Q!==void 0)return"inferred";return"unknown"}function V0(O){let Z=O.explicitType??O.jsdocType??O.resolvedType??O.typeSeed,$=O.jsdocParams??O.resolvedParams,Q=O.jsdocReturnType??O.resolvedReturnType;if(O.isFunctionDeclaration&&Z==="() => any"&&Q)Z=$&&$.length>0?`(${$.map((K)=>`${K.name}${K.optional?"?":""}: ${K.type}`).join(", ")}) => ${Q}`:`() => ${Q}`;let W=O.jsdocDescription??O.resolvedDescription;if(W===void 0&&Z!==void 0)W=O.typedefs?.get(Z)?.description;let Y=m1({hasTypeScriptType:O.explicitType!==void 0,hasJSDocType:O.jsdocType!==void 0||O.jsdocParams!==void 0||O.jsdocReturnType!==void 0||O.resolvedType!==void 0,inferredType:O.inferredTypeForSource,finalType:Z}),X=O.initializerIsFunction||O.isFunctionDeclaration||O.inferIsFunctionFromTypeSignature===!0&&(!!O.jsdocParams?.length||O.jsdocReturnType!==void 0||!!O.jsdocType?.includes("=>")||!!O.resolvedType?.includes("=>")||!!O.explicitType?.includes("=>"));return{type:Z,typeSource:Y,description:W,params:$,returnType:Q,isFunction:X}}function l1(O){if(!O||typeof O!=="object"||!("type"in O))return;let Z=String(O.type);if(Z!=="InlineComponent"&&Z!=="Element")return;let $="name"in O&&typeof O.name==="string"?O.name:void 0;if(!$)return;let Q=Z==="InlineComponent"?{type:"InlineComponent",name:$}:{type:"Element",name:$};if(Z==="Element"&&$==="svelte:element"&&"tag"in O&&typeof O.tag==="string")Q.thisValue=O.tag;return Q}function DO(O,Z){if(O.rest_props!==void 0)return;let $=l1(Z);if($)O.rest_props=$}function d(O,Z,$){if(!Z||O.has(Z))return;O.set(Z,$)}function f0(O,Z){for(let $=O.activeScopes.length-1;$>=0;$-=1){let Q=O.activeScopes[$]?.get(Z);if(!Q)continue;return Q.kind==="prop"?Q.publicPropName:void 0}return}function g(O,Z=new Set){if(!O||typeof O!=="object"||!("type"in O))return Z;switch(O.type){case"Identifier":Z.add(O.name);break;case"AssignmentPattern":g(O.left,Z);break;case"ArrayPattern":for(let $ of O.elements)g($??void 0,Z);break;case"ObjectPattern":for(let $ of O.properties)if($.type==="Property")g($.value,Z);else if($.type==="RestElement")g($.argument,Z);break;case"RestElement":g(O.argument,Z);break}return Z}function e0(O,Z){let $=g(Z);if(!$)return;for(let Q of $){let W=f0(O,Q);if(W)O.reactive_vars.add(W)}}function D0(O){if(!O||typeof O!=="object"||!("type"in O))return!1;switch(String(O.type)){case"BlockStatement":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"EachBlock":case"ThenBlock":case"CatchBlock":return!0;default:return!1}}function EO(O){if(!O||typeof O!=="object"||!("type"in O))return!1;let Z=String(O.type);return Z==="FunctionDeclaration"||Z==="FunctionExpression"||Z==="ArrowFunctionExpression"}function d1(O,Z){let $=O.scopeDeclarations.get(Z);if(!$)$=new Map,O.scopeDeclarations.set(Z,$);return $}function i1(O,Z,$){let Q=[];if($.id.type==="Identifier")return Q.push({kind:"local",name:$.id.name}),Q;if($.id.type!=="ObjectPattern")return Q;for(let W of $.id.properties){if(W.type==="RestElement"){if(W.argument.type==="Identifier")Q.push({kind:"local",name:W.argument.name});continue}if(W.computed)continue;let Y=O.getPropertyName(W.key);if(!Y)continue;let X;if(W.value.type==="Identifier")X=W.value.name;else if(W.value.type==="AssignmentPattern"&&W.value.left.type==="Identifier")X=W.value.left.name;if(!X)continue;Q.push({kind:"prop",name:X,publicPropName:Y})}return Q}function t0(O,Z,$,Q,W){if(!QO(Z))return;let Y=W?.allowRunesProps??!1,X=W?.forceProp??!1,K=Z;for(let q of K.declarations){if(Y&&Z0(X0(q.init),"$props")){for(let w of i1(O,K,q))d(w.kind==="prop"?$:Q,w.name,w.kind==="prop"?{kind:"prop",publicPropName:w.publicPropName}:{kind:"local"});continue}let z=K.kind==="var"?Q:$,H=X?"prop":"local";for(let w of g(q.id))d(z,w,H==="prop"?{kind:"prop",publicPropName:w}:{kind:"local"})}}function c1(O,Z){if("id"in O&&O.id&&typeof O.id==="object"&&"name"in O.id&&typeof O.id.name==="string")d(Z,O.id.name,{kind:"local"});for(let $ of O.params)for(let Q of g($))d(Z,Q,{kind:"local"})}function s1(O,Z,$,Q){if(!Array.isArray(Z))return;for(let W of Z){if(!W||typeof W!=="object"||!("type"in W))continue;switch(W.type){case"VariableDeclaration":t0(O,W,$,Q);break;case"FunctionDeclaration":if(W.id?.name)d($,W.id.name,{kind:"local"});break;case"ClassDeclaration":if(W.id?.name)d($,W.id.name,{kind:"local"});break}}}function p1(O,Z,$){if(!$||typeof $!=="object")return;let Q="content"in $&&$.content&&typeof $.content==="object"&&"body"in $.content&&Array.isArray($.content.body)?$.content:("body"in $)&&Array.isArray($.body)?$:void 0;if(!Q||!("body"in Q)||!Array.isArray(Q.body))return;for(let W of Q.body){if(!W||typeof W!=="object"||!("type"in W))continue;switch(W.type){case"ImportDeclaration":for(let Y of W.specifiers??[])if(Y.local?.name)d(Z.componentScope,Y.local.name,{kind:"local"});break;case"VariableDeclaration":t0(O,W,Z.componentScope,Z.componentScope,{allowRunesProps:!0});break;case"FunctionDeclaration":if(W.id?.name)d(Z.componentScope,W.id.name,{kind:"local"});break;case"ClassDeclaration":if(W.id?.name)d(Z.componentScope,W.id.name,{kind:"local"});break;case"ExportNamedDeclaration":if(!W.declaration||typeof W.declaration!=="object"||!("type"in W.declaration))break;if(W.declaration.type==="VariableDeclaration")t0(O,W.declaration,Z.componentScope,Z.componentScope,{forceProp:!0});else if(W.declaration.type==="FunctionDeclaration"&&W.declaration.id?.name)d(Z.componentScope,W.declaration.id.name,{kind:"prop",publicPropName:W.declaration.id.name});break}}}function SO(O,Z){Z.componentScope.clear(),Z.scopeDeclarations=new WeakMap,Z.activeScopes.length=0,p1(O,Z,Z.parsed?.instance)}function bO(O){return{varScopeStack:[O.componentScope]}}function _O(O,Z,$,Q){if(!D0(Q))return;let W=d1(Z,Q),Y=$.varScopeStack[$.varScopeStack.length-1]??Z.componentScope;switch(String(Q.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":c1(Q,W);break;case"BlockStatement":s1(O,Q.body,W,Y);break;case"CatchClause":if("param"in Q)for(let K of g(Q.param))d(W,K,{kind:"local"});break;case"EachBlock":{let K=Q;for(let q of g(K.context))d(W,q,{kind:"local"});if(typeof K.index==="string")d(W,K.index,{kind:"local"});else if(K.index&&"name"in K.index)d(W,K.index.name,{kind:"local"});break}case"ThenBlock":if("value"in Q)for(let K of g(Q.value))d(W,K,{kind:"local"});break;case"CatchBlock":if("error"in Q)for(let K of g(Q.error))d(W,K,{kind:"local"});break}if(EO(Q))$.varScopeStack.push(W)}function kO(O,Z){if(EO(Z))O.varScopeStack.pop()}var o1=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]);function n1(O,Z){switch(Z?.type){case"MemberExpression":return Z.computed||O===Z.object;case"MethodDefinition":return!!Z.computed;case"MetaProperty":return O===Z.meta;case"PropertyDefinition":return Z.computed||O===Z.value;case"Property":return Z.computed||O===Z.value;case"ExportSpecifier":case"ImportSpecifier":return O===Z.local;case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return!1;default:return!0}}function r1(O,Z){for(let $=Z.length-1;$>=0;$-=1)if(Z[$]?.has(O))return!0;return!1}function a1(O){let Z=new Set;if(!O||typeof O!=="object"||!("type"in O))return Z;switch(String(O.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":{let $=O;if($.id?.name)Z.add($.id.name);for(let Q of $.params??[])g(Q,Z);break}case"BlockStatement":E0(O.body,Z);break;case"CatchClause":g(O.param,Z);break;case"EachBlock":{let $=O;if(g($.context,Z),typeof $.index==="string")Z.add($.index);else if($.index?.name)Z.add($.index.name);break}case"ThenBlock":g(O.value,Z);break;case"CatchBlock":g(O.error,Z);break}return Z}function E0(O,Z){if(!Array.isArray(O))return;for(let $ of O){if(!$||typeof $!=="object"||!("type"in $))continue;switch(String($.type)){case"ImportDeclaration":for(let Q of $.specifiers??[])if(Q.local?.name)Z.add(Q.local.name);break;case"VariableDeclaration":for(let Q of $.declarations??[])g(Q.id,Z);break;case"FunctionDeclaration":case"ClassDeclaration":{let Q=$.id?.name;if(Q)Z.add(Q);break}case"ExportNamedDeclaration":{let Q=$.declaration;if(Q&&typeof Q==="object"&&"type"in Q)E0([Q],Z);break}}}}function OO(O,Z){if(!O||typeof O!=="object")return!1;let $=[...Z],Q=!1;return Q0(O,{enter(W,Y){if(Q){this.skip();return}if(D0(W))$.push(a1(W));if(Y&&W.type==="Identifier"&&o1.has(W.name)&&!Y.type.startsWith("TS")&&n1(W,Y)&&!r1(W.name,$))Q=!0,this.skip()},leave(W){if(D0(W))$.pop()}}),Q}function TO(O){if(!O||typeof O!=="object")return;if("content"in O){let Z=O.content,$=Z&&typeof Z==="object"&&"body"in Z?Z.body:void 0;if(Array.isArray($))return $}if("body"in O&&Array.isArray(O.body))return O.body;return}function NO(O){if(O.runesOptionOverride!==void 0)return O.runesOptionOverride?"runes":"legacy";let Z=O.parsed;if(!Z)return"legacy";let $=new Set;E0(TO(Z.module),$);let Q=new Set;return E0(TO(Z.instance),Q),OO(Z.module,[$])||OO(Z.instance,[$,Q])||OO(Z.html,[$,Q])?"runes":"legacy"}var t1=/[A-Za-z_$][\w$]*/g;function e1(O,Z,$){let Q=new Map,W=Z.typeParameters?.params,Y=$.typeArguments?.params;if(!W?.length||!Y?.length)return Q;for(let X=0;X<W.length;X++){let K=W[X]?.name,q=Y[X];if(!K||q?.start===void 0||q?.end===void 0)continue;let z=m(O,q.start,q.end)?.trim();if(z)Q.set(K,z)}return Q}function O2(O,Z){if(Z.size===0)return O;return O.replace(t1,($)=>Z.get($)??$)}function L0(O,Z,$,Q,W=new Set){let Y=new Map;if(!$?.type)return Y;let X=(K)=>{for(let q of K){if(q?.type!=="TSPropertySignature"||q.computed)continue;if(!q.key)continue;let z=O.getPropertyName(q.key);if(!z)continue;let H=q.typeAnnotation?.start,w=q.typeAnnotation?.end;if(H===void 0||w===void 0)continue;let A=m(Z,H+1,w)?.trim();if(!A)continue;Y.set(z,{type:A,optional:q.optional===!0,source:v(Z,q)})}};switch($.type){case"TSTypeLiteral":X($.members??[]);break;case"TSInterfaceDeclaration":X($.body?.body??[]);break;case"TSTypeAliasDeclaration":{let K=L0(O,Z,$.typeAnnotation,Q,W);for(let[q,z]of K)Y.set(q,z);break}case"TSTypeReference":{let K=yO($.typeName);if(!K||W.has(K))break;let q=Q.get(K);if(!q)break;W.add(K);let z=L0(O,Z,q,Q,W);W.delete(K);let H=e1(Z,q,$);for(let[w,A]of z)Y.set(w,H.size===0?A:{...A,type:O2(A.type,H)});break}case"TSIntersectionType":for(let K of $.types??[]){let q=L0(O,Z,K,Q,W);for(let[z,H]of q)Y.set(z,H)}break;case"TSParenthesizedType":{let K=L0(O,Z,$.typeAnnotation,Q,W);for(let[q,z]of K)Y.set(q,z);break}}return Y}function lO(O,Z){if(Z.runesPropsDeclarationMetadataByDeclaratorStart.clear(),Z.explicitPropTypesByName.clear(),Z.explicitVariableTypesByName.clear(),Z.typeImportBindingsByLocalName.clear(),Z.localTypeDeclarationsByName.clear(),Z.typedRunesPropsDeclarations.length=0,!Z.source)return;let $=b0(Z.source,{modern:!0});Z.scriptLanguage=O.resolveScriptLanguage($),Z.customElementTag=$.options?.customElement?.tag,Z.runesOptionOverride=$.options?.runes,Z.scriptGenericsAttribute=O.resolveScriptGenericsAttribute($);let Q=$.instance?.content?.body??[];for(let W of Q){if(!W?.type)continue;if(W.type==="ImportDeclaration"&&W.source?.value)for(let Y of W.specifiers??[]){let X=Y.local?.name;if(!X)continue;if(!(W.importKind==="type"||Y.importKind==="type"))continue;let q,z;if(Y.type==="ImportSpecifier")q="named",z=Y.imported?.type==="Identifier"?Y.imported.name:typeof Y.imported?.value==="string"?Y.imported.value:void 0;else if(Y.type==="ImportDefaultSpecifier")q="default";else if(Y.type==="ImportNamespaceSpecifier")q="namespace";if(!q)continue;Z.typeImportBindingsByLocalName.set(X,{importedName:z,localName:X,source:String(W.source.value),specifierType:q})}if((W.type==="TSInterfaceDeclaration"||W.type==="TSTypeAliasDeclaration")&&W.id?.name&&W.start!==void 0&&W.end!==void 0)Z.localTypeDeclarationsByName.set(W.id.name,{code:m(Z,W.start,W.end)?.trim()??"",node:W,start:W.start});if(W.type==="ExportNamedDeclaration"&&W.declaration?.type==="VariableDeclaration")for(let Y of W.declaration.declarations??[]){if(Y.id?.type!=="Identifier"||!Y.id.name)continue;let X=S0(Z,Y.id.typeAnnotation);if(X)Z.explicitPropTypesByName.set(Y.id.name,X)}else if(W.type==="VariableDeclaration")for(let Y of W.declarations??[]){if(Y.id?.type!=="Identifier"||!Y.id.name)continue;let X=S0(Z,Y.id.typeAnnotation);if(X)Z.explicitVariableTypesByName.set(Y.id.name,X)}}for(let W of Q){if(!W||typeof W!=="object"||!("declarations"in W))continue;for(let Y of W.declarations??[]){if(!Z0(X0(Y.init),"$props"))continue;let X=Y.id?.typeAnnotation?void 0:YO(Y.init),K=Y.id?.typeAnnotation?.typeAnnotation??X,q=Y.id?.typeAnnotation?S0(Z,Y.id.typeAnnotation):xO(Z,X),z=L0(O,Z,K,new Map(Array.from(Z.localTypeDeclarationsByName.entries(),([A,f])=>[A,f.node]))),H=new Set,w=new Set;if(uO(Z,K,H,w),mO(Z,H,w),Y.start!==void 0){let A={canonicalType:q,props:z,referencedImportedTypes:H,referencedLocalTypes:w};if(Z.runesPropsDeclarationMetadataByDeclaratorStart.set(Y.start,A),q)Z.typedRunesPropsDeclarations.push(A)}}}}function dO(O,Z,$){for(let Q of $.declarations){if(!Z0(X0(Q.init),"$props"))continue;if(Q.id.type==="Identifier"){Z.wholePropsLocals.add(Q.id.name),Z.restPropLocals.add(Q.id.name);let X=vO(Z,Q.start);if(X)for(let[K,q]of X.props)j0(O,Z,K,{name:K,kind:"let",type:q.type,typeSource:"typescript",isFunction:!1,isFunctionDeclaration:!1,isRequired:!q.optional,constant:!1,reactive:!1,source:q.source});continue}if(Q.id.type!=="ObjectPattern")continue;let W=K0(Z,O,$),Y=Q.id.properties.filter((X)=>{if(X.type!=="Property"||X.computed)return!1;if(!O.getPropertyName(X.key))return!1;if(X.value.type==="Identifier")return!0;return X.value.type==="AssignmentPattern"&&X.value.left.type==="Identifier"}).length;for(let X of Q.id.properties){if(X.type==="RestElement"){if(X.argument.type==="Identifier")Z.restPropLocals.add(X.argument.name);continue}let K=O.getPropertyName(X.key);if(!K)continue;let q,z;if(X.value.type==="Identifier")q=X.value.name;else{let B=X.value;q=B.left.name,z=B.right}if(!q)continue;if(O.trackPropLocalName(K,q),K==="children")Z.snippetPropLocals.add(q);let H=hO(Z,O,X)??(Y===1?W:void 0),w=gO(Z,Q.start,K),{init:A,bindable:f}=HO(z),N=A==null?{isFunction:!1}:z0(O,Z,A),{value:s,type:i,isFunction:x,defaultValue:b}=N,G=w?.type===void 0&&H?.type===void 0?N.resolvedType:void 0,{type:U,typeSource:J,description:F,params:j,returnType:M,isFunction:L}=V0({explicitType:w?.type,typeSeed:i,inferredTypeForSource:i,jsdocType:H?.type,jsdocDescription:H?.description,jsdocParams:H?.params,jsdocReturnType:H?.returnType,resolvedType:G,resolvedDescription:N.resolvedDescription,resolvedParams:N.resolvedParams,resolvedReturnType:N.resolvedReturnType,initializerIsFunction:x,isFunctionDeclaration:!1,inferIsFunctionFromTypeSignature:!0});if(f)Z.reactive_vars.add(K);j0(O,Z,K,{name:K,...q===K?{}:{localName:q},kind:"let",description:F,binding:H?.binding,deprecated:H?.deprecated,tags:H?.tags,...f?{bindable:!0}:{},type:U,typeSource:J,value:s,defaultValue:b,params:j,returnType:M,isFunction:L,isFunctionDeclaration:!1,isRequired:A==null&&w?.optional!==!0,constant:!1,reactive:f,source:v(Z,X)})}}}function iO(O,Z){if(O.syntaxMode!=="runes")return;for(let[$,Q]of Array.from(O.events.entries())){if(Q.type!=="dispatched")continue;if(Z.has($)||O.forwardedEvents.has($))continue;let W=`on${$}`,Y=O.props.get(W);if(!Y)continue;let X=Y.type!==void 0||Y.params!==void 0||Y.returnType!==void 0,K=Q.detail===void 0||Q.detail==="undefined"||Q.detail==="null"?"() => void":`(detail: ${Q.detail}) => void`;O.props.set(W,{...Y,description:Y.description??Q.description,type:X?Y.type:K,typeSource:X?Y.typeSource:"inferred",isFunction:!0}),O.events.delete($)}}var cO=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function _0(O){if(!O||typeof O!=="object")return;Q0(O,{enter(Z){if(!cO.has(Z.type))return;let $=Z.expression;while($&&cO.has($.type))$=$.expression;if($)this.replace($)}})}var Z2=/^\s*$/;function pO(O,Z,$){let Q=Z+1;while(Q<O.length){if(O[Q]==="\\"){Q+=2;continue}if(O[Q]===$)return Q+1;Q++}return Q}function oO(O,Z){let $=Z+1,Q=0;while($<O.length){let W=O[$];if(W==="\\"){$+=2;continue}if(Q===0){if(W==="`")return $+1;if(W==="$"&&O[$+1]==="{"){Q=1,$+=2;continue}$++;continue}if(W==="{")Q++;else if(W==="}")Q--;else if(W==='"'||W==="'"){$=pO(O,$,W);continue}else if(W==="`"){$=oO(O,$);continue}$++}return $}function $2(O,Z){let $=[],Q=O.length,W=0;while(W<Q){let Y=O[W];if(Y==='"'||Y==="'"){W=pO(O,W,Y);continue}if(Y==="`"){W=oO(O,W);continue}if(Y==="/"&&O[W+1]==="/"){let X=W+2;while(X<Q&&O[X]!==`
|
|
15
|
+
`)X++;W=X;continue}if(Y==="/"&&O[W+1]==="*"){let X=W,K=W+2;while(K<Q&&!(O[K]==="*"&&O[K+1]==="/"))K++;let q=Math.min(K+2,Q),z=O.slice(X,q);$.push({end:q+Z,isJsDoc:z.startsWith("/**")&&z.length>4,text:z}),W=q;continue}W++}return $}function sO(O,Z,$){if(!O||typeof O!=="object"||!("type"in O))return;let Q=O;if(Q.type==="FunctionDeclaration"){if(Q.id?.type==="Identifier"&&Q.id.name)$.push({name:Q.id.name,start:Z});return}if(Q.type==="VariableDeclaration"){for(let W of Q.declarations??[])if(W?.id?.type==="Identifier"&&W.id.name)$.push({name:W.id.name,start:Z})}}function Q2(O){let Z=[];for(let $ of O){if(!$||typeof $!=="object"||!("type"in $))continue;let Q=$;if(Q.start===void 0)continue;if(Q.type==="ExportNamedDeclaration"&&Q.declaration)sO(Q.declaration,Q.start,Z);else sO(Q,Q.start,Z)}return Z}function W2(O,Z,$){let Q;for(let W of O){if(W.end>Z)break;if(!W.isJsDoc)continue;if(!Z2.test($.slice(W.end,Z)))continue;Q=W}return Q}function nO(O,Z){let $=new Map;if(!O.source)return $;let Q=[O.parsed?.module,O.parsed?.instance],W=[],Y=[];for(let X of Q){let K=X?.content;if(!K?.body||K.start===void 0||K.end===void 0)continue;W.push(...$2(O.source.slice(K.start,K.end),K.start)),Y.push(...Q2(K.body))}W.sort((X,K)=>X.end-K.end);for(let X of Y){let K=W2(W,X.start,O.source);if(!K)continue;let q=M0(K.text,{spacing:"preserve"}),{type:z,description:H}=a0(q);if(!z)continue;$.set(X.name,{type:Z.aliasType(z.type),description:H||z.description})}return $}function rO(O){if(O==="var")return"let";if(O==="using"||O==="await using")return"const";return O}var Y2=null,aO=/^@component/,q2=/\r/g,X2=/^\{\s*\}$/;class l{ctx=v0();static mapToArray(O){return Array.from(O,([Z,$])=>$)}static getStaticAttributeValue(O){if(!Array.isArray(O.value))return;return O.value.map((Z)=>Z.data??Z.raw??"").join("").trim()}resolveScriptLanguage(O){let Z=[O.instance,O.module].filter((Q)=>Q!==void 0),$=!1;for(let Q of Z){let W=Q.attributes?.find((X)=>X.name==="lang");if(!W){$=!0;continue}if(l.getStaticAttributeValue(W)?.toLowerCase()==="ts")return"ts"}return $?"js":void 0}resolveScriptGenericsAttribute(O){let Z=O.instance?.attributes?.find((X)=>X.name==="generics");if(!Z)return;let $=v(this.ctx,Z),Q=O.instance?.attributes?.find((X)=>X.name==="lang");if((Q?l.getStaticAttributeValue(Q)?.toLowerCase():void 0)!=="ts"){W0(this.ctx,"syntax-skipped","generics",'<script generics="..."> requires lang="ts"; the generics attribute was ignored because the script is not TypeScript.',$);return}let Y=l.getStaticAttributeValue(Z);if(!Y)return;return{value:Y,source:$}}static assignValue(O){return a(O)}resolvePublicPropName(O){return this.ctx.propLocalToPublicName.get(O)??O}trackPropLocalName(O,Z=O){this.ctx.propLocalToPublicName.set(Z,O)}getPropByLocalOrPublic(O){return this.ctx.props.get(this.resolvePublicPropName(O))}getPropTypeByLocalOrPublic(O){return this.getPropByLocalOrPublic(O)?.type}getExplicitPropType(O){return this.ctx.explicitPropTypesByName.get(O)}getPropertyName(O){if(!O||typeof O!=="object"||!("type"in O))return;if(O0(O))return O.name;if(G0(O))return O.value==null?void 0:String(O.value);return}isNumericConstant(O){if(!O||typeof O!=="object"||!("type"in O))return!1;if(O.type!=="MemberExpression")return!1;let Z=O,$=Z.object&&"name"in Z.object?Z.object.name:void 0,Q=Z.property&&"name"in Z.property?Z.property.name:void 0;if(!$||!Q)return!1;if($==="Number")return["POSITIVE_INFINITY","NEGATIVE_INFINITY","MAX_VALUE","MIN_VALUE","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","EPSILON","NaN"].includes(Q);if($==="Math")return["PI","E","LN2","LN10","LOG2E","LOG10E","SQRT2","SQRT1_2"].includes(Q);return!1}resolveLocalVarJSDoc(O){for(let $ of this.ctx.vars)if($.declarations.some((W)=>W.id&&typeof W.id==="object"&&("type"in W.id)&&W.id.type==="Identifier"&&("name"in W.id)&&W.id.name===O))return K0(this.ctx,this,$);let Z=this.ctx.funcDecls.get(O);if(Z)return K0(this.ctx,this,Z);return}addModuleExport(O,Z){if(l.assignValue(O)===void 0)return;if(this.ctx.moduleExports.has(O)){let $=this.ctx.moduleExports.get(O);this.ctx.moduleExports.set(O,{...$,...Z})}else this.ctx.moduleExports.set(O,Z)}aliasType(O){if(O==="*")return"any";return O.trim()}findVariableTypeAndDescription(O){let Z=this.getPropByLocalOrPublic(O);if(Z?.type)return{type:Z.type,description:Z.description};if(!this.ctx.variableInfoCacheBuilt)this.ctx.variableInfoCache=nO(this.ctx,this),this.ctx.variableInfoCacheBuilt=!0;let $=this.ctx.variableInfoCache.get(O),Q=this.ctx.explicitVariableTypesByName.get(O);if(Q)return{type:Q,description:$?.description};return $??null}accumulateGeneric(O,Z){if(this.ctx.generics)this.ctx.generics=[`${this.ctx.generics[0]}, ${O}`,`${this.ctx.generics[1]}, ${Z}`];else this.ctx.generics=[O,Z]}cleanup(){this.ctx=v0()}static SCRIPT_BLOCK_REGEX=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi;static TS_DIRECTIVE_REGEX=/\/\/\s*@ts-[^\n\r]*/g;static stripTypeScriptDirectivesFromScripts(O){return l.SCRIPT_BLOCK_REGEX.lastIndex=0,O.replace(l.SCRIPT_BLOCK_REGEX,(Z,$,Q,W)=>{l.TS_DIRECTIVE_REGEX.lastIndex=0;let Y=Q.replace(l.TS_DIRECTIVE_REGEX,"");return $+Y+W})}parseSvelteComponent(O,Z){this.cleanup(),this.ctx.componentFilePath=Z.filePath;let $=l.stripTypeScriptDirectivesFromScripts(O);if(this.ctx.source=$,lO(this,this.ctx),this.ctx.parsed=b0($,{modern:!1}),this.ctx.scriptLanguage==="ts")_0(this.ctx.parsed.module),_0(this.ctx.parsed.instance),_0(this.ctx.parsed.html);if(this.ctx.syntaxMode=NO(this.ctx),fO(this.ctx,this),this.ctx.parsed?.module)Q0(this.ctx.parsed?.module,{enter:(G)=>{if(G.type==="ExportNamedDeclaration"){if(G.declaration==null)return;if(!G.declaration||typeof G.declaration!=="object"||!("type"in G.declaration))return;let U,J,F=!1,j,M,L,B=!1,I,T,S;if(G.declaration.type==="FunctionDeclaration"){let n=G.declaration;if(!n.id?.name)return;U=n.id.name,J="function",j=void 0,M="() => any",B=!0,F=!0}else if(G.declaration.type==="VariableDeclaration"){let n=G.declaration,V=n.declarations[0];if(!V||typeof V!=="object"||!("id"in V))return;let{id:k,init:C}=V;if(!k||typeof k!=="object"||!("name"in k))return;let y=k.name;U=y,J=rO(n.kind);let D=C==null?{isFunction:!1}:z0(this,this.ctx,C);({value:j,type:M,isFunction:B,defaultValue:I}=D),T=M,S=D,L=this.getExplicitPropType(y)}else return;let u=K0(this.ctx,this,G),{type:p,typeSource:$0,description:_,params:o,returnType:c,isFunction:q0}=V0({explicitType:L,typeSeed:M,inferredTypeForSource:T,jsdocType:u?.type,jsdocDescription:u?.description,jsdocParams:u?.params,jsdocReturnType:u?.returnType,resolvedType:S?.resolvedType,resolvedDescription:S?.resolvedDescription,resolvedParams:S?.resolvedParams,resolvedReturnType:S?.resolvedReturnType,initializerIsFunction:B,isFunctionDeclaration:F,typedefs:this.ctx.typedefs});this.addModuleExport(U,{name:U,kind:J,description:_,deprecated:u?.deprecated,tags:u?.tags,type:p,typeSource:$0,value:j,defaultValue:I,params:o,returnType:c,isFunction:q0,isFunctionDeclaration:F,isRequired:!1,constant:J==="const",reactive:!1,source:v(this.ctx,G)})}}});let Q,W=new Set,Y=new Set,X=[],K={type:"ComponentRoot",instance:this.ctx.parsed.instance,html:this.ctx.parsed.html};SO(this,this.ctx),this.ctx.activeScopes.push(this.ctx.componentScope);let q=bO(this.ctx);if(Q0(K,{enter:(G,U,J)=>{_O(this,this.ctx,q,G);let F=this.ctx.scopeDeclarations.get(G);if(F)this.ctx.activeScopes.push(F);if(G.type==="AssignmentExpression")e0(this.ctx,G.left);if(G.type==="UpdateExpression")e0(this.ctx,G.argument);if(G.type==="CallExpression"){let j=G,M=j.callee&&typeof j.callee==="object"&&"name"in j.callee?j.callee.name:void 0;if(M==="createEventDispatcher"){if(U&&typeof U==="object"&&"id"in U&&U.id&&typeof U.id==="object"&&"name"in U.id)Q=U.id.name}if(M==="$host"){if(U&&typeof U==="object"&&"id"in U&&U.id&&typeof U.id==="object"&&"name"in U.id)W.add(U.id.name)}if(M==="setContext")wO(this.ctx,this,G,U??void 0);if(M)X.push({name:M,arguments:j.arguments,source:v(this.ctx,j)});if(WO(j.callee)&&O0(j.callee.property)&&j.callee.property.name==="dispatchEvent"&&(Z0(j.callee.object,"$host")||O0(j.callee.object)&&W.has(j.callee.object.name))){let L=MO(this.ctx,j);if(L)Y.add(L)}}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="Spread"){let j=G;if(j.expression?.name==="$$restProps"||this.ctx.restPropLocals.has(j.expression?.name??""))DO(this.ctx,U)}if(G.type==="FunctionDeclaration"){let j=G;if(j.id?.name)this.ctx.funcDecls.set(j.id.name,j)}if(G.type==="VariableDeclaration"){if(this.ctx.vars.add(G),U&&typeof U==="object"&&"type"in U&&U.type==="Program"&&G.declarations.some((j)=>Z0(X0(j.init),"$props")))dO(this,this.ctx,G)}if(G.type==="ExportNamedDeclaration"){if(G.declaration==null&&G.specifiers.length===0)return;let j;if(G.declaration==null&&G.specifiers[0]?.type==="ExportSpecifier"){let D=G.specifiers[0],R=D.local&&typeof D.local==="object"&&"name"in D.local?D.local.name:void 0,P=D.exported&&typeof D.exported==="object"&&"name"in D.exported?D.exported.name:void 0;if(!R||!P)return;let E;for(let r of Array.from(this.ctx.vars))if(r.declarations.some((h)=>h.id&&typeof h.id==="object"&&("type"in h.id)&&h.id.type==="Identifier"&&h.id.name===R)){E=r;break}G.declaration=E,j=P}if(G.declaration==null)return;if(!G.declaration||typeof G.declaration!=="object"||!("type"in G.declaration))return;let M,L=!1,B,I,T,S=!1,u=!1,p,$0,_,o;if(G.declaration.type==="FunctionDeclaration"){let D=G.declaration;if(!D.id?.name)return;j??=D.id.name,p=D.id.name,M="function",B=void 0,I="() => any",S=!0,L=!0,u=!1}else if(G.declaration.type==="VariableDeclaration"){let D=G.declaration,R=D.declarations[0];if(!R||typeof R!=="object"||!("id"in R))return;let{id:P,init:E}=R;if(P&&typeof P==="object"&&"name"in P){let h=P.name;p=h,j??=h,T=this.getExplicitPropType(h)}else return;M=rO(D.kind),u=M==="let"&&E==null;let r=E==null?{isFunction:!1}:z0(this,this.ctx,E);({value:B,type:I,isFunction:S,defaultValue:$0}=r),_=I,o=r}else return;let c=K0(this.ctx,this,G),{type:q0,typeSource:n,description:V,params:k,returnType:C,isFunction:y}=V0({explicitType:T,typeSeed:I,inferredTypeForSource:_,jsdocType:c?.type,jsdocDescription:c?.description,jsdocParams:c?.params,jsdocReturnType:c?.returnType,resolvedType:o?.resolvedType,resolvedDescription:o?.resolvedDescription,resolvedParams:o?.resolvedParams,resolvedReturnType:o?.resolvedReturnType,initializerIsFunction:S,isFunctionDeclaration:L,typedefs:this.ctx.typedefs});j0(this,this.ctx,j,{name:j,...p!==void 0&&p!==j?{localName:p}:{},kind:M,description:V,binding:c?.binding,deprecated:c?.deprecated,tags:c?.tags,type:q0,typeSource:n,value:B,defaultValue:$0,params:k,returnType:C,isFunction:y,isFunctionDeclaration:L,isRequired:u,constant:M==="const",reactive:this.ctx.reactive_vars.has(j),source:v(this.ctx,G)})}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="Comment"){let M=G?.data?.trim()??"";if(aO.test(M))this.ctx.componentComment=M.replace(aO,"").replace(q2,""),this.ctx.componentCommentSource=v(this.ctx,G)}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="Slot"){let j=G,M=j.attributes?.find((I)=>I.name==="name")?.value?.[0]?.data,L=(j.attributes||[]).filter((I)=>I.name!=="name").reduce((I,T)=>{let S={value:void 0,replace:!1},u=T.value;if(u===void 0)return I;if(u[0]){let p=u[0],{type:$0,expression:_,raw:o,start:c,end:q0}=p;if($0==="Text"&&o!==void 0)S.value=JSON.stringify(o);else if($0==="AttributeShorthand"&&_&&typeof _==="object"&&"name"in _)S.value=_.name,S.replace=!0;if(_&&typeof _==="object"&&"type"in _){if(_.type==="Literal"&&"value"in _){let n=_.value;S.value=typeof n==="string"?JSON.stringify(n):String(n)}else if(_.type==="MemberExpression")S.value=I0(this.ctx,this,_);else if(_.type!=="Identifier"){if(c!==void 0&&q0!==void 0){if(_.type==="ObjectExpression"||_.type==="TemplateLiteral")S.value=m(this.ctx,c+1,q0-1)}}}}if(T.name)I[T.name]=S;return I},{}),B=j.children?.map(({start:I,end:T})=>{if(I===void 0||T===void 0)return"";return m(this.ctx,I,T)??""}).join("").trim();J0(this.ctx,{slot_name:M,slot_props:L,slot_fallback:B,source:v(this.ctx,G)})}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="RenderTag"){let j=G,M=RO(this.ctx,j.expression);if(M){let L;if(M.arguments.length===0)L={};else if(M.arguments.length===1&&typeof M.arguments[0]==="object"&&M.arguments[0]&&"type"in M.arguments[0]&&M.arguments[0].type==="ObjectExpression")L=LO(this.ctx,this,M.arguments[0]);else if(M.arguments.length===1)W0(this.ctx,"syntax-skipped",M.publicName,`{@render ${M.publicName}(...)} argument is not a plain object literal; the render call was not mapped to slot metadata.`,v(this.ctx,G));let B=M.publicName==="children"?void 0:M.publicName,I=B===void 0?Y2:B;if(L!==void 0)J0(this.ctx,{slot_name:B,slot_props:L,source:v(this.ctx,G)});if(L!==void 0||this.ctx.slots.has(I))this.ctx.snippetPropLocals.add(M.trackingName)}}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="EventHandler"){let j=G;if(j.expression==null&&j.name){if(U!=null&&typeof U==="object"&&"name"in U){let M=typeof U.name==="string"?U.name:void 0,L="type"in U?String(U.type):void 0;if(M&&L){let B=L==="InlineComponent"?{type:"InlineComponent",name:M}:{type:"Element",name:M};this.ctx.forwardedEvents.set(j.name,B);let I=this.ctx.events.get(j.name),T=this.ctx.eventDescriptions.get(j.name),S=I?.deprecated;if(!I)this.ctx.events.set(j.name,{type:"forwarded",name:j.name,element:B,description:T,deprecated:S,source:v(this.ctx,G)});else if(I.type==="forwarded"&&T&&!I.description)this.ctx.events.set(j.name,{...I,description:T,deprecated:I.deprecated??S,source:I.source||v(this.ctx,G)})}}}}if(U&&typeof U==="object"&&"type"in U&&(String(U.type)==="Element"||String(U.type)==="InlineComponent")&&G&&typeof G==="object"&&"type"in G&&String(G.type)==="Binding"){let j=G;if(j.expression?.name){let M=f0(this.ctx,j.expression.name);if(M)this.ctx.reactive_vars.add(M)}if(String(U.type)==="Element"&&j.name==="this"&&j.expression?.name&&"name"in U&&typeof U.name==="string"){let M=f0(this.ctx,j.expression.name);if(!M)return;let L=U.name;if(this.ctx.bindings.has(M)){let B=this.ctx.bindings.get(M);if(B&&!B.elements.includes(L))this.ctx.bindings.set(M,{...B,elements:[...B.elements,L]})}else this.ctx.bindings.set(M,{elements:[L]})}}},leave:(G)=>{if(this.ctx.scopeDeclarations.has(G))this.ctx.activeScopes.pop();kO(q,G)}}),Q!==void 0){for(let G of X)if(G.name===Q){let U=G.arguments[0],J=U&&typeof U==="object"&&"value"in U?U.value:void 0,F=G.arguments[1],j=F&&typeof F==="object"&&"value"in F?F.value:void 0;if(J!=null)w0(this.ctx,{name:String(J),detail:j==null?"":x0(j),has_argument:Boolean(F),source:G.source})}}let z=new Set(Y);if(Q!==void 0){for(let G of X)if(G.name===Q){let U=G.arguments[0],J=U&&typeof U==="object"&&"value"in U?U.value:void 0;if(J!=null)z.add(String(J))}}this.ctx.forwardedEvents.forEach((G,U)=>{let J=this.ctx.events.get(U);if(J&&J.type==="dispatched"&&!z.has(U)){let F=this.ctx.eventDescriptions.get(U),j={type:"forwarded",name:U,element:G,description:F,deprecated:J.deprecated,tags:J.tags,source:J.source};if(J.detail!==void 0&&J.detail!=="undefined")j.detail=J.detail;this.ctx.events.set(U,j)}}),iO(this.ctx,z);let H=this.ctx.syntaxMode==="runes"?new Set(Array.from(this.ctx.snippetPropLocals,(G)=>this.resolvePublicPropName(G))):new Set,w=l.mapToArray(this.ctx.props).filter((G)=>!H.has(G.name)).map((G)=>{if(this.ctx.bindings.has(G.name)){let U=this.ctx.bindings.get(G.name)?.elements.sort().map((J)=>XO(J)).join(" | ");return{...G,type:`null | ${U}`,typeSource:"inferred",reactive:G.reactive||this.ctx.reactive_vars.has(G.name)}}return{...G,reactive:G.reactive||this.ctx.reactive_vars.has(G.name)}});this.ctx.activeScopes.length=0;let A=l.mapToArray(this.ctx.slots).map((G)=>{if(!G.slot_props)return G;if(typeof G.slot_props==="string")return X2.test(G.slot_props)?{...G,slot_props:"Record<string, never>"}:G;let U=G.slot_props,J=[];for(let j of Object.keys(U)){if(U[j].replace&&U[j].value!==void 0)U[j].value=this.getPropTypeByLocalOrPublic(U[j].value);if(U[j].value===void 0)U[j].value="any";J.push(`${j}: ${U[j].value}`)}let F=J.length===0?"Record<string, never>":J.length===1?`{ ${J[0]} }`:`{
|
|
16
|
+
${J.join(`;
|
|
17
|
+
`)};
|
|
18
|
+
}`;return{...G,slot_props:F}}).sort((G,U)=>{let J=G.name??"",F=U.name??"";if(J<F)return-1;if(J>F)return 1;return 0});if(this.ctx.deferredSlotBlockGenerics.length>0){let G=[...w.map((U)=>U.type??""),...A.map((U)=>U.slot_props??"")].join(`
|
|
19
|
+
`);for(let{name:U,constraint:J}of this.ctx.deferredSlotBlockGenerics){let F=U.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!new RegExp(`\\b${F}\\b`).test(G))continue;this.accumulateGeneric(U,J)}}if(this.ctx.scriptGenericsAttribute){if(this.ctx.generics)W0(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=O1(this.ctx.scriptGenericsAttribute.value)}let f=l.mapToArray(this.ctx.moduleExports),N=l.mapToArray(this.ctx.events).map((G)=>{switch(G.type){case"forwarded":return{...G,element:G.element.name};case"dispatched":return G;default:return G}}).sort((G,U)=>{let J=G.name.localeCompare(U.name);if(J!==0)return J;let F=G.type.localeCompare(U.type);if(F!==0)return F;if(G.type==="forwarded"&&U.type==="forwarded"){let j=G.element.localeCompare(U.element);if(j!==0)return j}return(G.detail??"").localeCompare(U.detail??"")}),s=l.mapToArray(this.ctx.typedefs),i=l.mapToArray(this.ctx.contexts);for(let G of w)if(G.typeSource==="unknown")W0(this.ctx,"prop-unknown-type",G.name,`Prop "${G.name}" type could not be inferred; falling back to "${G.type??"any"}".`,G.source);for(let G of this.ctx.jsDocEventNames){if(z.has(G))continue;if(this.ctx.forwardedEvents.has(G))continue;if(this.ctx.props.has(`on${G}`))continue;W0(this.ctx,"event-no-source",G,`@event "${G}" has no matching dispatch or callback prop.`,this.ctx.jsDocEventSources.get(G))}let x={source:tO(this.ctx,0,this.ctx.source?.length),syntaxMode:this.ctx.syntaxMode,...this.ctx.scriptLanguage?{scriptLanguage:this.ctx.scriptLanguage}:{},props:w,moduleExports:f,slots:A,events:N,typedefs:s,generics:this.ctx.generics,rest_props:this.ctx.rest_props,extends:this.ctx.extends,componentComment:this.ctx.componentComment,componentCommentSource:this.ctx.componentCommentSource,contexts:i,customElementTag:this.ctx.customElementTag,diagnostics:this.ctx.diagnosticRecords.slice()},b=eO(this.ctx);if(b)x[ZO]=b;return x}}
|
|
20
|
+
export{a as s,l as t};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import{J as b0,u as m0,v as D0,w as r2}from"./chunk-xkrgedm4.js";import{Q as s2}from"./chunk-8xw75w8t.js";import{S as F}from"./chunk-cxrw7gzr.js";import{W as p0}from"./chunk-1p4ka68s.js";var W2="sveld",V0="0.35.2";var O2={name:W2,version:V0,license:"Apache-2.0",description:"Generate TypeScript definitions and component documentation for your Svelte components.",type:"module",main:"./lib/index.js",types:"./lib/index.d.ts",exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./browser":{types:"./lib/browser.d.ts",import:"./lib/browser.js",default:"./lib/browser.js"}},scripts:{test:"bun test --parallel","test:fixtures-types":"tsc --project tsconfig.fixtures.json","test:e2e":"bun tests/test-e2e.ts",format:"biome format --write .",lint:"biome lint .","lint:fix":"biome check --write --unsafe .",build:"bun scripts/build.ts",bench:"bun scripts/bench.ts","bench:cache":"bun scripts/bench.ts --cache",typecheck:"tsc --noEmit"},devDependencies:{"@biomejs/biome":"2.5.3","@types/bun":"^1.3.14","@types/jest":"^30.0.0",acorn:"^8.17.0","comment-parser":"^1.4.1",culls:"^0.2.0","estree-walker":"^3.0.3",svelte:"^5.56.3",typescript:"^7.0.2"},bin:{sveld:"cli.js"},files:["lib","cli.js"],repository:{type:"git",url:"git+https://github.com/carbon-design-system/sveld.git"},homepage:"https://github.com/carbon-design-system/sveld",bugs:"https://github.com/carbon-design-system/sveld/issues",keywords:["svelte","svelte component","documentation","docgen","typescript","definitions","JSDocs","vite","vite-plugin"],maintainers:["Eric Liu (https://github.com/metonym)"]};var k2="5.56.3";var X0=k2;var G0=1,L2=new WeakMap;function x(j,$={}){let Z=L2.get(j),Q=Z?.get($.entryExports);if(Q)return Q;let J=Array.from(j,([,K])=>{let{diagnostics:z,...H}=K;return H}).sort((K,z)=>K.moduleName.localeCompare(z.moduleName)),Y={schemaVersion:G0,generator:{name:W2,version:V0,svelteVersion:X0},total:J.length,components:J};if($.entryExports&&$.entryExports.length>0)Y.totalExports=$.entryExports.length,Y.exports=$.entryExports;if(!Z)Z=new Map,L2.set(j,Z);return Z.set($.entryExports,Y),Y}import{readFile as vj}from"node:fs/promises";import fj from"node:path";var B2={none:0,patch:1,minor:2,major:3};function hj(j,$){return B2[$]>B2[j]?$:j}function uj(j){return j.reduce(($,Z)=>hj($,Z.bump),"none")}function R2(j){let $=[],Z=0,Q="",J=null;for(let Y=0;Y<j.length;Y++){let K=j[Y];if(J){if(Q+=K,K==="\\")Y++,Q+=j[Y]??"";else if(K===J)J=null;continue}if(K==='"'||K==="'"||K==="`"){J=K,Q+=K;continue}if(K==="<"||K==="("||K==="{"||K==="[")Z++;if(K===">"||K===")"||K==="}"||K==="]")Z--;if(K==="|"&&Z===0){$.push(Q.trim()),Q="";continue}Q+=K}return $.push(Q.trim()),new Set($.filter((Y)=>Y.length>0))}function f0(j,$){if(j===$)return"none";if(j===void 0||$===void 0)return"major";let Z=R2(j),Q=R2($),J=[...Q].some((K)=>!Z.has(K)),Y=[...Z].some((K)=>!Q.has(K));if(!J&&!Y)return"none";if(J&&!Y)return"minor";if(Y&&!J)return"major";return"major"}function I2(j,$,Z,Q){let J=$==="prop"?"prop":"export",Y=[],K=new Map(Z.map((H)=>[H.name,H])),z=new Map(Q.map((H)=>[H.name,H]));for(let[H,U]of z){if(K.has(H))continue;Y.push({component:j,kind:$,name:H,bump:U.isRequired?"major":"minor",message:`${J} "${H}" added${U.isRequired?" (required)":""}`})}for(let[H]of K){if(z.has(H))continue;Y.push({component:j,kind:$,name:H,bump:"major",message:`${J} "${H}" removed`})}for(let[H,U]of K){let V=z.get(H);if(!V)continue;if(U.isRequired!==V.isRequired)Y.push({component:j,kind:$,name:H,bump:V.isRequired?"major":"minor",message:`${J} "${H}" became ${V.isRequired?"required":"optional"}`});let G=f0(U.type,V.type);if(G!=="none")Y.push({component:j,kind:$,name:H,bump:G,message:`${J} "${H}" type changed from \`${U.type??"unknown"}\` to \`${V.type??"unknown"}\``})}return Y}function mj(j,$,Z){let Q=[],J=new Map($.map((K)=>[K.name,K])),Y=new Map(Z.map((K)=>[K.name,K]));for(let[K]of Y){if(J.has(K))continue;Q.push({component:j,kind:"event",name:K,bump:"minor",message:`event "${K}" added`})}for(let[K]of J){if(Y.has(K))continue;Q.push({component:j,kind:"event",name:K,bump:"major",message:`event "${K}" removed`})}for(let[K,z]of J){let H=Y.get(K);if(!H)continue;if(z.type!==H.type){Q.push({component:j,kind:"event",name:K,bump:"major",message:`event "${K}" changed from ${z.type} to ${H.type}`});continue}let U=z.type==="dispatched"?z.detail:void 0,V=H.type==="dispatched"?H.detail:void 0,G=f0(U,V);if(G!=="none")Q.push({component:j,kind:"event",name:K,bump:G,message:`event "${K}" detail changed from \`${U??"unknown"}\` to \`${V??"unknown"}\``})}return Q}function M2(j){return j.name??"default"}function cj(j,$,Z){let Q=[],J=new Map($.map((K)=>[M2(K),K])),Y=new Map(Z.map((K)=>[M2(K),K]));for(let[K]of Y){if(J.has(K))continue;Q.push({component:j,kind:"slot",name:K,bump:"minor",message:`slot "${K}" added`})}for(let[K]of J){if(Y.has(K))continue;Q.push({component:j,kind:"slot",name:K,bump:"major",message:`slot "${K}" removed`})}for(let[K,z]of J){let H=Y.get(K);if(!H)continue;let U=f0(z.slot_props,H.slot_props);if(U!=="none")Q.push({component:j,kind:"slot",name:K,bump:U,message:`slot "${K}" props changed from \`${z.slot_props??"none"}\` to \`${H.slot_props??"none"}\``})}return Q}var dj=new Set(["description","source","componentCommentSource","tags"]);function q0(j){if(Array.isArray(j))return j.map(q0);if(j!==null&&typeof j==="object"){let $={};for(let[Z,Q]of Object.entries(j)){if(dj.has(Z))continue;$[Z]=q0(Q)}return $}return j}var lj=["generics","rest_props","extends","contexts","typedefs"];function ij(j,$,Z){let Q=[];for(let J of lj){let Y=JSON.stringify(q0($[J])),K=JSON.stringify(q0(Z[J]));if(Y!==K)Q.push({component:j,kind:"shape",name:J,bump:"major",message:`"${J}" changed (breaking)`})}return Q}function pj(j,$){let Z=$.moduleName;return[...I2(Z,"prop",j.props,$.props),...I2(Z,"moduleExport",j.moduleExports,$.moduleExports),...mj(Z,j.events,$.events),...cj(Z,j.slots,$.slots),...ij(Z,j,$)]}function aj(j,$){let Z=[],Q=new Map(j.components.map((Y)=>[Y.moduleName,Y])),J=new Map($.components.map((Y)=>[Y.moduleName,Y]));for(let[Y]of J){if(Q.has(Y))continue;Z.push({component:Y,kind:"component",bump:"minor",message:`component "${Y}" added`})}for(let[Y]of Q){if(J.has(Y))continue;Z.push({component:Y,kind:"component",bump:"major",message:`component "${Y}" removed`})}for(let[Y,K]of Q){let z=J.get(Y);if(!z)continue;Z.push(...pj(K,z))}return Z}async function sj(j){let $;try{$=await vj(fj.resolve(j),"utf-8")}catch(Z){if(Z.code==="ENOENT")return null;throw Z}try{return JSON.parse($)}catch{throw Error(`sveld: could not parse "${j}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function D2(j){if(typeof j.check==="string")return j.check;return j.jsonOptions?.outFile??"COMPONENT_API.json"}async function A2(j,$,Z={}){let Q=await sj($);if(Q===null)return{snapshotExists:!1,snapshotFile:$,changes:[],bump:"none"};if(Q.schemaVersion!==G0)return{snapshotExists:!0,snapshotFile:$,changes:[{component:"*",kind:"shape",bump:"none",message:`snapshot schemaVersion ${Q.schemaVersion} does not match the current schemaVersion ${G0}; skipping diff`}],bump:"none"};let J=x(j,{entryExports:Z.entryExports}),Y=aj(Q,J);return{snapshotExists:!0,snapshotFile:$,changes:Y,bump:uj(Y)}}var rj={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function T2(j){if(!j.snapshotExists)return`sveld --check: no snapshot found at "${j.snapshotFile}". Run \`sveld --json\` and commit the output first.`;if(j.changes.length===0)return`sveld --check: no API changes detected against "${j.snapshotFile}".`;let $=[],Z=j.changes.length;$.push(`sveld --check: ${Z} API change${Z===1?"":"s"} detected against "${j.snapshotFile}".`),$.push(`Suggested semver bump: ${j.bump}.`);let Q=new Map;for(let J of j.changes){let Y=Q.get(J.component)??[];Y.push(J),Q.set(J.component,Y)}for(let[J,Y]of Q){$.push(""),$.push(` ${J}`);for(let K of Y)$.push(` [${rj[K.bump]}] ${K.message}`)}return $.join(`
|
|
2
|
+
`)}import{existsSync as nj}from"node:fs";import{join as tj}from"node:path";import{pathToFileURL as oj}from"node:url";function u(j){return typeof j==="object"&&j!==null}function S2(j){if(!u(j))return{};let $=j.svelte;return typeof $==="string"?{svelte:$}:{}}function b2(j){if(!u(j))return{};let $={};if(typeof j.extends==="string")$.extends=j.extends;if(u(j.compilerOptions)){let Z={};if(typeof j.compilerOptions.baseUrl==="string")Z.baseUrl=j.compilerOptions.baseUrl;if(u(j.compilerOptions.paths)){let Q={};for(let[J,Y]of Object.entries(j.compilerOptions.paths))if(Array.isArray(Y)&&Y.every((K)=>typeof K==="string"))Q[J]=Y;if(Object.keys(Q).length>0)Z.paths=Q}if(Object.keys(Z).length>0)$.compilerOptions=Z}return $}var ej=["sveld.config.js","sveld.config.mjs","sveld.config.ts"];function s1(j){return j}function j3(j=process.cwd()){for(let $ of ej){let Z=tj(j,$);if(nj(Z))return Z}return null}async function $3(j){let $;try{$=await import(`${oj(j).href}?t=${Date.now()}`)}catch(Q){let J=Q instanceof Error?Q.message:String(Q);throw Error(`sveld: failed to load config file "${j}".
|
|
3
|
+
${J}`)}let Z=$.default;if(!u(Z)||Array.isArray(Z))throw Error(`sveld: config file "${j}" must export a configuration object as its default export. Did you forget \`export default defineConfig({ ... })\`?`);return Z}async function F2(j=process.cwd()){let $=j3(j);if($===null)return{};return $3($)}function _2(...j){return Object.assign({},...j.filter(Boolean))}var h0=new Map;function p(j){h0.set(j.name,j)}function u0(j){return h0.get(j)}function n1(){return Array.from(h0.values())}import{dirname as M1}from"node:path";import{lstatSync as n2,readdirSync as l3,readFileSync as i3,realpathSync as p3,statSync as a3}from"node:fs";import{readFile as s3}from"node:fs/promises";import{dirname as r3,isAbsolute as n3,join as t3,parse as n0,relative as o3,resolve as e}from"node:path";function a(j){return j}function y(j){if(j==="")return j;return j.startsWith(".")?j:`./${j}`}import{dirname as Z3,resolve as Q3}from"node:path";var J3=/\.svelte$/,Y3=/^(['"])(.*)\1$/;function K3(j,$){let Z=j.extends?.import;if(Z===void 0)return null;let Q=Z.replace(Y3,"$2");if(!J3.test(Q))return null;return Q3(Z3($),Q)}function s(j,$){let Z=new Map;for(let Q of j.values()){let J=$(Q.filePath),Y=K3(Q,J);if(Y===null)continue;let K=Z.get(Y);if(K===void 0)K=new Set,Z.set(Y,K);K.add(J)}return Z}function W0(j,$){let Z=new Set,Q=[];for(let J of j)if(!Z.has(J))Z.add(J),Q.push(J);while(Q.length>0){let J=Q.shift(),Y=$.get(J);if(Y===void 0)continue;for(let K of Y)if(!Z.has(K))Z.add(K),Q.push(K)}return Z}var U3={"prop-unknown-type":"Props without inferred types","context-any-type":"Context values typed as `any`","event-no-source":"@event tags with no dispatch or callback","example-compile-error":"@example blocks that failed to compile","syntax-skipped":"Component syntax sveld skipped"},z3=["prop-unknown-type","context-any-type","event-no-source","example-compile-error","syntax-skipped"];function O0(j){let $=new Set,Z=[];for(let Q of j){let J=`${Q.component}:${Q.kind}:${Q.name}`;if($.has(J))continue;$.add(J),Z.push(Q)}return Z}function N2(j){if(j.length===0)return"sveld: all types resolved.";let $=[],Z=j.length;$.push(`sveld: ${Z} unresolved type${Z===1?"":"s"} found.`);for(let Q of z3){let J=j.filter((K)=>K.kind===Q);if(J.length===0)continue;$.push(""),$.push(`${U3[Q]} (${J.length}):`);let Y=new Map;for(let K of J){let z=Y.get(K.component)??[];z.push(K),Y.set(K.component,z)}for(let[K,z]of Y){$.push(` ${K}`);for(let H of z){let U=H.source?` (${K}:${H.source.start.line}:${H.source.start.column})`:"";$.push(` - ${H.message}${U}`)}}}return $.join(`
|
|
4
|
+
`)}var H3=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,V3=new Set(["","js","jsx","ts","tsx","javascript","typescript"]);function X3(j){let $=j.trim();if($==="")return null;let Z=$.match(H3);if(Z){let Q=Z[1].toLowerCase();if(!V3.has(Q))return null;let J=Z[2].trim();return J===""?null:J}if($.startsWith("<"))return null;return $}function w2(j){if(!j.isFunction)return"any";return`(${(j.params??[]).map((Z)=>`${Z.name}${Z.optional?"?":""}: any`).join(", ")}) => any`}function k0(j,$,Z,Q,J){let Y=(j??[]).filter((z)=>z.name==="example"),K=[];return Y.forEach((z,H)=>{let U=X3(z.body);if(U===null)return;let V=Y.length>1;K.push({id:V?`${$}#${H}`:$,name:V?`${Z} (example ${H+1})`:Z,type:Q,code:U,...J?{source:J}:{}})}),K}function C2(j){return j.name??"default"}function x2(j){let $=[];for(let Z of j.props)$.push(...k0(Z.tags,`prop:${Z.name}`,Z.name,w2(Z),Z.source));for(let Z of j.moduleExports)$.push(...k0(Z.tags,`export:${Z.name}`,Z.name,w2(Z),Z.source));for(let Z of j.slots)$.push(...k0(Z.tags,`slot:${C2(Z)}`,C2(Z),"any",Z.source));for(let Z of j.events)$.push(...k0(Z.tags,`event:${Z.name}`,Z.name,"any",Z.source));return $}import{createHash as G3}from"node:crypto";import{mkdirSync as q3,readFileSync as W3,writeFileSync as O3}from"node:fs";import{dirname as k3,isAbsolute as L3,join as B3,resolve as g2}from"node:path";var c0=1,R3=B3("node_modules",".cache","sveld","parse-cache.json");function d0(){return`${V0}+svelte@${X0}`}function y2(j,$){if(typeof $==="string")return L3($)?$:g2(j,$);return g2(j,R3)}function P2(j){return G3("sha256").update(j).digest("hex")}function E2(){return{formatVersion:c0,toolchainVersion:d0(),entries:{}}}function I3(j){try{let $=W3(j,"utf-8"),Z=JSON.parse($);if(Z.formatVersion!==c0||Z.toolchainVersion!==d0())return E2();return Z}catch{return E2()}}class l0{cacheFilePath;file;next=new Map;blocked=new Set;constructor(j){this.cacheFilePath=j,this.file=I3(j)}has(j,$){if(this.blocked.has(j))return!1;let Z=this.file.entries[j];return Z!==void 0&&Z.hash===$}get(j,$){if(this.blocked.has(j))return null;let Z=this.file.entries[j];if(Z===void 0||Z.hash!==$)return null;if(this.next.set(j,Z),Z.typeScriptMetadata!==void 0)Z.parsed[m0]=Z.typeScriptMetadata;return Z.parsed}set(j,$,Z){this.next.set(j,{hash:$,parsed:Z,typeScriptMetadata:Z[m0]})}invalidate(j){this.blocked.add(j)}save(){q3(k3(this.cacheFilePath),{recursive:!0});let j={formatVersion:c0,toolchainVersion:d0(),entries:Object.fromEntries(this.next)};O3(this.cacheFilePath,JSON.stringify(j))}}import{existsSync as R0,lstatSync as u2,readFileSync as _3}from"node:fs";import{dirname as l2,join as N3,relative as w3,resolve as i2}from"node:path";var m=null,i0=null;function c(){if(m)return Promise.resolve(m);if(!i0)i0=Promise.all([import("./chunk-jdnsv86e.js"),import("./chunk-s9mzxa4y.js")]).then(([j,$])=>{return m={ComponentParser:j.default,parseSvelte:$.parse},m});return i0}function r(){if(!m)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return m}import{existsSync as f2,readFileSync as M3}from"node:fs";import{dirname as a0,isAbsolute as D3,join as A3,relative as T3,resolve as B0}from"node:path";var L0=new Map,v2=new Map,S3=/\/\*[\s\S]*?\*\/|\/\/.*/g,b3=/[.+?^${}()|[\]\\]/g;function F3(j){let $=j,Z=B0($,"/");while($!==Z){for(let Q of["tsconfig.json","jsconfig.json"]){let J=A3($,Q);if(f2(J))return J}$=a0($)}return null}function h2(j){if(L0.has(j))return L0.get(j)??null;try{let $=M3(j,"utf-8"),Z;try{Z=JSON.parse($)}catch{let J=$.replace(S3,"");Z=JSON.parse(J)}let Q=b2(Z);if(Q.extends){let J=D3(Q.extends)?Q.extends:B0(a0(j),Q.extends),Y=J.endsWith(".json")?J:`${J}.json`;if(f2(Y)){let K=h2(Y);if(K)Q.compilerOptions={...K.compilerOptions,...Q.compilerOptions,paths:{...K.compilerOptions?.paths,...Q.compilerOptions?.paths}}}}return L0.set(j,Q),Q}catch{return L0.set(j,null),null}}function n(j,$){if(j.startsWith(".")||j.startsWith("/"))return j;let Z=F3($);if(!Z)return j;let Q=h2(Z);if(!Q?.compilerOptions?.paths)return j;let{baseUrl:J=".",paths:Y}=Q.compilerOptions,K=a0(Z),z=B0(K,J);for(let[H,U]of Object.entries(Y)){let V=v2.get(H);if(!V){let q=H.split("*").map((W)=>W.replace(b3,"\\$&")).join("(.*)");V=new RegExp(`^${q}$`),v2.set(H,V)}let G=j.match(V);if(G){let q=U[0];if(!q)continue;let W=q;for(let X=1;X<G.length;X++)W=W.replace("*",G[X]);return B0(z,W)}}return j}function t(j,$){if(j.startsWith(".")||j.startsWith("/"))return j;let Z=n(j,$);if(Z===j)return j;let Q=T3($,Z);return Q=F(Q),Q.startsWith(".")?Q:`./${Q}`}var m2=[".ts",".mts",".cts",".tsx",".js",".mjs",".cjs",".jsx",".d.ts"],C3=/\r?\n/,x3=/^\s*\*+/;function T(j){return j&&typeof j==="object"?j:void 0}function o(j){return Array.isArray(j)?j:[]}function E(j){if(j&&j.type==="Identifier"&&typeof j.name==="string")return j.name;return}function s0(j,$){let Z=n(j,$),Q=i2($,Z);if(R0(Q)&&u2(Q).isFile())return Q;for(let J of m2){let Y=Q+J;if(R0(Y))return Y}if(R0(Q)&&u2(Q).isDirectory())for(let J of m2){let Y=N3(Q,`index${J}`);if(R0(Y))return Y}return null}function g3(j,$){let Z=j.slice(0,$).trimEnd();if(!Z.endsWith("*/"))return;let Q=Z.length-2,J=Z.lastIndexOf("/**",Q);if(J===-1)return;let Y=[];for(let K of Z.slice(J+3,Q).split(C3)){let z=K.replace(x3,"").trim();if(z.startsWith("@"))break;if(z)Y.push(z)}return Y.join(" ")||void 0}function d(j,$){if(!$)return;return j.text.slice($.start,$.end)}function E3(j,$){let Z=T($?.typeAnnotation);if(Z?.type!=="TSTypeAnnotation")return;return d(j,T(Z.typeAnnotation))}function c2(j,$){let Z=o($.params).map((Y)=>d(j,Y)??"").join(", "),Q=T($.returnType),J=Q?.type==="TSTypeAnnotation"?d(j,T(Q.typeAnnotation)):void 0;return`(${Z})${J?` => ${J}`:""}`}function y3(j){if(j.type==="Literal"){let $=j.value;if(typeof $==="string")return"string";if(typeof $==="number")return"number";if(typeof $==="boolean")return"boolean"}if(j.type==="TemplateLiteral")return"string";return}function d2(j,$,Z){let Q=j.filePath,J=g3(j.text,Z);if($.type==="VariableDeclaration"){let Y=$.kind??"const",K=[];for(let z of o($.declarations)){let H=T(z.id),U=E(H);if(!U)continue;let V=E3(j,H),G,q=T(z.init);if(q){if(q.type==="ArrowFunctionExpression"||q.type==="FunctionExpression"){if(!V)V=c2(j,q)}else if(G=d(j,q),!V)V=y3(q)}K.push({name:U,kind:Y,type:V,value:G,description:J,declFile:Q,isTypeOnly:!1})}return K}if($.type==="FunctionDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"function",type:c2(j,$),description:J,declFile:Q,isTypeOnly:!1}]}if($.type==="ClassDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"class",type:Y,description:J,declFile:Q,isTypeOnly:!1}]}if($.type==="TSTypeAliasDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"type",type:d(j,T($.typeAnnotation)),description:J,declFile:Q,isTypeOnly:!0}]}if($.type==="TSInterfaceDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"interface",type:d(j,T($.body)),description:J,declFile:Q,isTypeOnly:!0}]}if($.type==="TSEnumDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"enum",type:Y,description:J,declFile:Q,isTypeOnly:!1}]}return[]}function P3(j){let $;try{$=_3(j,"utf-8")}catch{return null}let Z=`<script lang="ts">
|
|
5
|
+
${$}
|
|
6
|
+
</script>`;try{let Q=r().parseSvelte(Z,{modern:!0}),J=o(Q.instance?.content?.body);return{source:{text:Z,filePath:j,dir:l2(j)},body:J}}catch(Q){let J=Q instanceof Error?Q.message:String(Q);return console.warn(`Warning: Failed to parse entry export module ${j}: ${J}`),null}}function v3(j,$){for(let Z of j){if(Z.type!=="ImportDeclaration")continue;let Q=T(Z.source)?.value;if(typeof Q!=="string")continue;for(let J of o(Z.specifiers)){if(J.type!=="ImportSpecifier")continue;if(E(T(J.local))===$){let Y=E(T(J.imported))??$;return{specifier:Q,importedName:Y}}}}return null}function I0(j,$){let Z=$.cache.get(j);if(Z)return Z;if($.computing.has(j))return[];$.computing.add(j);let Q=P3(j);if(!Q)return $.computing.delete(j),$.cache.set(j,[]),[];let{source:J,body:Y}=Q,K=[],z=new Map;for(let U of Y){let V=U.type==="ExportNamedDeclaration"?T(U.declaration):U;if(!V)continue;for(let G of d2(J,V,V.start))z.set(G.name,G)}let H=(U)=>{let V=z.get(U);if(V)return V;let G=v3(Y,U);if(!G||G.specifier.endsWith(".svelte"))return null;let q=s0(G.specifier,J.dir);if(!q)return null;return I0(q,$).find((W)=>W.name===G.importedName)??null};for(let U of Y){if(U.type==="ExportAllDeclaration"){let L=T(U.source)?.value;if(typeof L!=="string"||L.endsWith(".svelte"))continue;let X=s0(L,J.dir);if(!X)continue;let k=U.exportKind==="type";for(let I of I0(X,$))K.push(k?{...I,isTypeOnly:!0}:I);continue}if(U.type!=="ExportNamedDeclaration")continue;let V=T(U.declaration);if(V){K.push(...d2(J,V,U.start));continue}let G=T(U.source)?.value,q=typeof G==="string"?G:void 0;if(q?.endsWith(".svelte"))continue;let W=U.exportKind==="type";for(let L of o(U.specifiers)){if(L.type!=="ExportSpecifier")continue;let X=E(T(L.exported)),k=E(T(L.local));if(!X||!k||k==="default"||X==="default")continue;let I=W||L.exportKind==="type",O=null;if(q){let M=s0(q,J.dir);if(M)O=I0(M,$).find((D)=>D.name===k)??null}else O=H(k);if(O?.declFile.endsWith(".svelte"))continue;if(O)K.push({...O,name:X,isTypeOnly:O.isTypeOnly||I});else K.push({name:X,kind:I?"type":"const",declFile:j,isTypeOnly:I})}}return $.computing.delete(j),$.cache.set(j,K),K}async function M0(j){await c();let $=i2(j),Z=l2($),Q=I0($,{cache:new Map,computing:new Set}),J=new Map;for(let Y of Q){let{declFile:K,...z}=Y,H=F(`./${w3(Z,K)}`);J.set(Y.name,{...z,source:H})}return Array.from(J.values()).sort((Y,K)=>Y.name.localeCompare(K.name))}import{lstatSync as f3,readdirSync as h3,readFileSync as u3}from"node:fs";import{dirname as m3,join as p2,resolve as c3}from"node:path";var a2=new Map;function d3(j){return s2(j,{ecmaVersion:"latest",sourceType:"module"})}function r0(j,$,Z=new Set){let Q=a2.get(j);if(!Q)Q=d3(j),a2.set(j,Q);let J={};for(let Y of Q.body)if(Y.type==="ExportDefaultDeclaration"){let K=Y.declaration.name;if(K in J)J[K].default=!0;else J[K]={source:y(""),default:!0}}else if(Y.type==="ExportAllDeclaration"){if(!Y.source)continue;let K=n(Y.source.value,$),z=c3($,K);if(!f3(z).isFile()){let V=h3(z);for(let G of V)if(G.includes("index")){z=p2(z,G);break}}if(Z.has(z))continue;Z.add(z);let H=u3(z,"utf-8"),U=r0(H,m3(z),Z);Z.delete(z);for(let[V,G]of Object.entries(U)){let q=y(F(`./${p2(Y.source.value,G.source)}`));J[V]={...G,source:q}}}else if(Y.type==="ExportNamedDeclaration")for(let K of Y.specifiers){let z=K.exported.name,H=K.local.name,U=z||H;if(U in J){if(Y.type==="ExportNamedDeclaration")J[U].mixed=!0;if(!J[U].source)J[U].source=y(t(Y.source?.value??"",$))}else J[U]={source:y(t(Y.source?.value??"",$)),default:H==="default"}}else if(Y.type==="ImportDeclaration"){let K=Y.specifiers[0].local.name;if(K in J){if(!J[K].source)J[K].source=y(t(Y.source?.value??"",$))}else J[K]={source:y(t(Y.source?.value??"",$)),default:K==="default"}}return J}function j0(j){return{failFast:j?.failFast,resolveTypes:j?.resolveTypes===!0,documentExports:j?.documentExports===!0,cache:j?.cache,checkExamples:j?.checkExamples===!0}}var e3=/<style.+?<\/style>/gims,j5=/-/g;function $5(j){if(!j.includes("<style"))return j;try{let $=r().parseSvelte(j,{modern:!1}),Z=$.css?.start,Q=$.css?.end;if(Z===void 0||Q===void 0)return j;return`${j.slice(0,Z)}${j.slice(Q)}`}catch{return j.replace(e3,"")}}function t2(j,$=[],Z=new Set){let Q;try{let J=p3(j);if(Z.has(J))return $;Z.add(J),Q=l3(j,{withFileTypes:!0})}catch{return $}for(let J of Q){if(J.name.startsWith("."))continue;let Y=t3(j,J.name),K=J.isSymbolicLink()?a3(Y,{throwIfNoEntry:!1}):J;if(!K)continue;if(K.isDirectory())t2(Y,$,Z);else if(K.isFile()&&J.name.endsWith(".svelte"))$.push(Y)}return $}function t0(j){return t2(j).map(($)=>{let Z=n0($).name.replace(j5,""),Q=y(F(`./${o3(j,$)}`));return{moduleName:Z,source:Q}})}function A0(j,$,Z=!1){let Q=n2(j).isFile(),J=Q?r3(j):j,Y=e(J),K=(U)=>n3(U)?e(U):e(Y,U),z={};if(Q){let U=i3(j,"utf-8");try{z=r0(U,Y,new Set([e(j)]))}catch(V){if(!Z)throw V;let G=V instanceof Error?V.message:String(V);console.warn(`Warning: Failed to parse component exports from ${j}: ${G}`)}}let H={...z};if($)for(let{moduleName:U,source:V}of t0(Y)){if(z[U])z[U].source=V;if(H[U])H[U].source=V;else H[U]={source:V,default:!1}}return{exports:z,allComponents:H,rootDir:Y,resolveComponentFilePath:K}}async function $0(j){let $=await Promise.all(Array.from(j).map(async(Z)=>{try{let Q=await s3(Z,"utf-8");return{path:Z,content:Q}}catch(Q){return console.warn(`Warning: Failed to read file ${Z}:`,Q),{path:Z,content:null}}}));return new Map($.map(({path:Z,content:Q})=>[Z,Q]))}function P([j,$],Z,Q,J,Y={}){let K=$.source,{ext:z,name:H}=n0(K),U=j;if(Z.length===1&&j==="default")U=H;if(z===".svelte"){let V=J(K),G=Q.get(V);if(G===null||G===void 0)return null;let q=F(K),W=Y.memo?.get(V),L=Y.hashes?.get(V),X=W===void 0?L===void 0?null:Y.cache?.get(V,L):null,k;if(W!==void 0)k=W;else if(X)k=X;else{let I=new(r()).ComponentParser;try{k=I.parseSvelteComponent($5(G),{moduleName:U,filePath:q})}catch(O){if(Y.failFast)throw O;let M=O instanceof Error?O.message:String(O),D=O instanceof Error?O.stack:void 0;return Y.onParseError?.({filePath:q,moduleName:U,message:M,stack:D}),null}if(L!==void 0)Y.cache?.set(V,L,k);Y.memo?.set(V,k)}return{moduleName:U,filePath:q,...k}}return null}function T0(j,$){let Z=new Set;for(let Q of j)for(let[,J]of Q)if(n0(J.source).ext===".svelte")Z.add($(J.source));return Z}function Z0(j){if(j.length===0)return;console.error(`sveld: failed to parse ${j.length} component(s):`);for(let{filePath:$,message:Z}of j)console.error(` - ${$}: ${Z}`)}async function Q0(j,$,Z={}){let Q=Z.documentExports===!0,{exports:J,allComponents:Y,rootDir:K,resolveComponentFilePath:z}=A0(j,$,Q),H=Q&&n2(j).isFile()?await M0(e(j)):[],U=Object.entries(J),V=Object.entries(Y),G=T0([U,V],z),q=await $0(G),W=new Map,L=new Map,X=Z.cache===!1?void 0:new l0(y2(K,Z.cache??!0)),k=new Set,I=new Map;if(X)for(let B of G){let R=q.get(B);if(R===null||R===void 0)continue;let b=P2(R);if(I.set(B,b),!X.has(B,b))k.add(B)}if(G.size>0&&(!X||k.size>0))await c();let O=new Map,M=new Map,D={failFast:Z.failFast===!0,onParseError:(B)=>O.set(B.filePath,B),cache:X,hashes:I,memo:M};for(let B of U){let R=P(B,U,q,z,D);if(R)W.set(R.moduleName,R)}for(let B of V){let R=P(B,V,q,z,D);if(R)L.set(R.moduleName,R)}if(X&&k.size>0){let B=s(L,z),R=W0(k,B);for(let b of R){if(k.has(b))continue;X.invalidate(b),M.delete(b)}for(let b of U){let v=z(b[1].source);if(!R.has(v)||k.has(v))continue;let C=P(b,U,q,z,D);if(C)W.set(C.moduleName,C)}for(let b of V){let v=z(b[1].source);if(!R.has(v)||k.has(v))continue;let C=P(b,V,q,z,D);if(C)L.set(C.moduleName,C)}}let S=Array.from(O.values());Z0(S),X?.save();let _=Z.resolveTypes?Z5(W):[],N=Z.checkExamples?J5(L):[];if(_.length>0||N.length>0){let{TypeResolver:B}=await import("./chunk-pmj8c3yv.js"),R=await B.create(K);try{if(_.length>0)await Q5(_,R,z);if(N.length>0)await Y5(N,R,z)}finally{await R?.dispose()}}let A=O0(Array.from(L.values()).flatMap((B)=>B.diagnostics??[]));return{exports:J,entryExports:H,components:W,allComponentsForTypes:L,errors:S,diagnostics:A}}function Z5(j){let $=[];for(let Z of j.values()){let Q=D0(Z);if(!Q?.canonicalPropsType||Z.props.length>0)continue;$.push({component:Z,metadata:Q})}return $}async function Q5(j,$,Z){if(!$)return;let Q=await $.expandAll(j.map(({component:J,metadata:Y})=>({moduleName:J.moduleName,metadata:Y,filePath:Z(J.filePath)})));for(let{component:J}of j){let Y=Q.get(J.moduleName);if(Y)r2(J,Y)}}function J5(j){let $=[];for(let Z of j.values()){let Q=x2(Z);if(Q.length===0)continue;$.push({component:Z,sources:Q})}return $}async function Y5(j,$,Z){if(!$)return;let Q=await $.checkExamples(j.map(({component:J,sources:Y})=>({moduleName:J.moduleName,filePath:Z(J.filePath),sources:Y})));for(let{component:J,sources:Y}of j){let K=Q.get(J.moduleName);if(!K||K.length===0)continue;let z=new Map(Y.map((U)=>[U.id,U.source])),H=J.diagnostics??[];for(let U of K){let V=z.get(U.id);H.push({component:J.filePath,kind:"example-compile-error",name:U.name,message:U.message,...V?{source:V}:{}})}J.diagnostics=H}}import{existsSync as o2,readFileSync as K5}from"node:fs";import{join as e2}from"node:path";function S0(j){if(j){let Z=e2(process.cwd(),j);if(o2(Z))return a(j);return console.error(`Invalid entry point: ${Z}. Pass a valid --entry (or "entry" option), or unset it and`),console.error('set the "svelte" field in your package.json instead.'),null}let $=e2(process.cwd(),"package.json");if(!o2($))return console.error("Could not locate a package.json file."),console.error(`Specify an entry point with --entry (or the "entry" option) instead.
|
|
7
|
+
`),null;try{let Z=S2(JSON.parse(K5($,"utf-8")));if(Z.svelte?.trim())return a(Z.svelte);return console.error(`Could not determine an entry point.
|
|
8
|
+
`),console.error(`Specify an entry point to your Svelte code in the "svelte" field of your package.json, or pass --entry (or the "entry" option).
|
|
9
|
+
`),null}catch(Z){throw console.error("Error reading package.json:",Z),Z}}import{lstatSync as U5}from"node:fs";import{resolve as jj}from"node:path";var z5=/\.svelte$/;async function $j(j,$,Z=!1){let{exports:Q,allComponents:J,rootDir:Y,resolveComponentFilePath:K}=A0(j,$,Z),z=Z&&U5(j).isFile()?await M0(jj(j)):[],H=Object.entries(Q),U=Object.entries(J),V=new Map,G=new Map;await c();let q=new Map,W={onParseError:(O)=>q.set(O.filePath,O)},L=()=>({exports:Q,entryExports:z,components:V,allComponentsForTypes:G,errors:Array.from(q.values()),diagnostics:O0(Array.from(G.values()).flatMap((O)=>O.diagnostics??[]))});{let O=T0([H,U],K),M=await $0(O);for(let D of H){let S=P(D,H,M,K,W);if(S)V.set(S.moduleName,S)}for(let D of U){let S=P(D,U,M,K,W);if(S)G.set(S.moduleName,S)}Z0(L().errors)}let X=s(G,K),k=(O,M,D,S)=>{let _=new Set;for(let N of M){let A=K(N[1].source);if(!D.has(A))continue;let B=P(N,M,S,K,W);if(B)O.set(B.moduleName,B),_.add(A);else for(let[R,b]of O)if(K(b.filePath)===A)O.delete(R)}return _};return{get result(){return L()},update:async(O)=>{let M=O.filter((A)=>z5.test(A)).map((A)=>jj(A));if(M.length===0)return{result:L(),reparsed:[]};if($)for(let{moduleName:A,source:B}of t0(Y)){let R=J[A];if(R)R.source=B;else{let b={source:B,default:!1};J[A]=b,U.push([A,b])}}let D=W0(M,X);for(let[A,B]of q)if(D.has(K(B.filePath)))q.delete(A);let S=await $0(D),_=new Set;for(let A of k(V,H,D,S))_.add(A);for(let A of k(G,U,D,S))_.add(A);X=s(G,K);let N=L();return Z0(N.errors),{result:N,reparsed:Array.from(_)}}}}import o0 from"node:path";import{mkdir as H5,readFile as V5,writeFile as X5}from"node:fs/promises";import{parse as G5}from"node:path";class l{async write(j,$){try{if(await V5(j,"utf-8")===$)return!1}catch{}return await H5(G5(j).dir,{recursive:!0}),await X5(j,$),!0}}function J0(){return new l}function Zj(){return new l}var q5=new Set(["string","number","boolean"]);function W5(j){return j.map(($)=>({kind:"field",name:$.name,...$.type?{type:{text:$.type}}:{},...$.value===void 0?{}:{default:$.value},...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function O5(j){let $=new Map;for(let Q of j){if(!Q.type||!q5.has(Q.type.trim()))continue;let J=Q.name.toLowerCase(),Y=$.get(J);if(Y)Y.push(Q);else $.set(J,[Q])}let Z=[];for(let[Q,J]of $){if(J.length!==1)continue;let Y=J[0];Z.push({name:Q,fieldName:Y.name,type:{text:Y.type},...Y.value===void 0?{}:{default:Y.value},...Y.description?{description:Y.description}:{}})}return Z}function k5(j){return j.filter(($)=>$.type==="dispatched").map(($)=>({name:$.name,type:{text:`CustomEvent<${$.detail??"unknown"}>`},...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function L5(j){return j.map(($)=>({name:$.default?"":$.name??"",...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function B5(j){let $={kind:"class",name:j.moduleName,...j.componentComment?{description:j.componentComment}:{},members:W5(j.props),attributes:O5(j.props),events:k5(j.events),slots:L5(j.slots)};if(j.customElementTag)$.tagName=j.customElementTag,$.customElement=!0;return $}function R5(j,$){let Z=[{kind:"js",name:j.moduleName,declaration:{name:j.moduleName,module:$}}];if(j.customElementTag)Z.push({kind:"custom-element-definition",name:j.customElementTag,declaration:{name:j.moduleName,module:$}});return Z}function Qj(j,$={}){let Z=x(j),Q=$.resolveModulePath??((Y)=>Y.filePath);return{schemaVersion:"1.0.0",modules:Z.components.map((Y)=>{let K=Q(Y);return{kind:"javascript-module",path:K,declarations:[B5(Y)],exports:R5(Y,K)}})}}function I5(j,$){return F(o0.join($,o0.normalize(j.filePath)))}async function e0(j,$){let Z=Qj(j,{resolveModulePath:(Y)=>I5(Y,$.inputDir)}),Q=o0.join(process.cwd(),$.outFile);await J0().write(Q,`${JSON.stringify(Z,null,2)}
|
|
10
|
+
`),console.log(`created "${$.outFile}".`)}import Y0 from"node:path";function Jj(j,$){return j.map((Z)=>({...Z,filePath:F(Y0.join($,Y0.normalize(Z.filePath)))}))}async function M5(j,$){let Z=x(j),Q=Jj(Z.components,$.inputDir);await Promise.all(Q.map(async(J)=>{let Y=Y0.resolve(Y0.join($.outDir||"",`${J.moduleName}.api.json`)),z=await J0().write(Y,`${JSON.stringify(J,null,2)}
|
|
11
|
+
`);console.log(`${z?"created":"unchanged"} "${Y}".`)}))}async function D5(j,$){let Z=x(j,{entryExports:$.entryExports}),Q={...Z,components:Jj(Z.components,$.inputDir)},J=Y0.join(process.cwd(),$.outFile);await J0().write(J,`${JSON.stringify(Q,null,2)}
|
|
12
|
+
`),console.log(`created "${$.outFile}".`)}async function j2(j,$){if($.outDir)await M5(j,$);else await D5(j,$)}import{join as I1}from"node:path";var Yj=/^[}\])>]/,A5=new Set(["{","(","["]),T5=new Set(["}",")","]"]);var S5=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,Kj=/[ \t]+$/,b5=/\s+$/,F5=/[{([]$/,_5=/\s/;function N5(j){return S5.test(j.slice(-200))}function w5(j){let $="",Z=null,Q=!1;for(let J=0;J<j.length;J++){let Y=j[J],K=j[J-1];if(Z){if($+=Y,Z==="double"&&Y==='"'&&K!=="\\"||Z==="single"&&Y==="'"&&K!=="\\"||Z==="template"&&Y==="`"&&K!=="\\")Z=null;Q=!1;continue}if(Y==='"'||Y==="'"||Y==="`"){Z=Y==='"'?"double":Y==="'"?"single":"template",$+=Y,Q=!1;continue}if(_5.test(Y)){if(!Q&&$.length>0)$+=" ",Q=!0;continue}$+=Y,Q=!1}return $.trimEnd()}function C5(j,$){let Z=0,Q="normal";for(let J=$;J<j.length;J++){let Y=j[J],K=j[J-1];if(Q==="blockComment"){if(K==="*"&&Y==="/")Q="normal";continue}if(Q==="double"||Q==="single"){if(Y===(Q==="double"?'"':"'")&&K!=="\\")Q="normal";continue}if(Q==="template"){if(Y==="`"&&K!=="\\")Q="normal";continue}if(Y==="/"&&j[J+1]==="*")Q="blockComment";else if(Y==='"')Q="double";else if(Y==="'")Q="single";else if(Y==="`")Q="template";else if(Y==="{")Z++;else if(Y==="}"){if(Z--,Z===0)return J}}return-1}function Uj(j){let $="",Z="normal";for(let Q=0;Q<j.length;Q++){let J=j[Q],Y=j[Q-1];if(Z==="blockComment"){if($+=J,Y==="*"&&J==="/")Z="normal";continue}if(Z==="double"||Z==="single"){if($+=J,J===(Z==="double"?'"':"'")&&Y!=="\\")Z="normal";continue}if(Z==="template"){if($+=J,J==="`"&&Y!=="\\")Z="normal";continue}if(J==="/"&&j[Q+1]==="*"){Z="blockComment",$+=J;continue}if(J==='"'){Z="double",$+=J;continue}if(J==="'"){Z="single",$+=J;continue}if(J==="`"){Z="template",$+=J;continue}if(J==="{"){let K=C5(j,Q);if(K===-1){$+=J;continue}let z=j.slice(Q+1,K);if(z.trim()===""){$+="{}",Q=K;continue}if(!z.includes("/*")&&j[Q+1]!==`
|
|
13
|
+
`&&!N5($)){let H=Uj(z).trim();if(!H.includes(`
|
|
14
|
+
`)){let U=H.endsWith(";")?H.slice(0,-1):H,V=`{ ${w5(U)} }`;if(V.length<=120){$+=V,Q=K;continue}}}if($+=J,j[Q+1]!==`
|
|
15
|
+
`)$+=`
|
|
16
|
+
`;continue}if(J==="}"){if($=$.replace(Kj,""),!$.endsWith(`
|
|
17
|
+
`))$+=`
|
|
18
|
+
`;$+=J;continue}if(J===";"){if($=$.replace(b5,""),$+=";",j[Q+1]!==`
|
|
19
|
+
`)$+=`
|
|
20
|
+
`;continue}$+=J}return $}function x5(j){let $="",Z=null;for(let Q=0;Q<j.length;Q++){let J=j[Q],Y=j[Q-1];if(Z){if($+=J,Z==="double"&&J==='"'&&Y!=="\\"||Z==="single"&&J==="'"&&Y!=="\\"||Z==="template"&&J==="`"&&Y!=="\\")Z=null;continue}if(J==='"'||J==="'"||J==="`"){Z=J==='"'?"double":J==="'"?"single":"template",$+=J;continue}if(J===" "&&$.endsWith(" "))continue;$+=J}return $}function g5(j){let $=j.split(`
|
|
21
|
+
`),Z=[],Q=0,J=!1,Y=0;for(let K of $){let z=K.trim();if(z===""){Z.push("");continue}if(J){if(Z.push(`${" ".repeat(Y)} ${z}`),z.includes("*/"))J=!1;continue}if(z.startsWith("/**")&&!z.includes("*/")){Z.push(" ".repeat(Q)+z),J=!0,Y=Q;continue}let H=x5(z),U=Yj.test(H),V=Math.max(0,Q-(U?1:0));if(Z.push(" ".repeat(V)+H),H.startsWith("/**")&&H.includes("*/"))continue;let G=null;for(let q=0;q<H.length;q++){let W=H[q],L=H[q-1];if(G){if(G==="double"&&W==='"'&&L!=="\\"||G==="single"&&W==="'"&&L!=="\\"||G==="template"&&W==="`"&&L!=="\\")G=null;continue}if(W==='"')G="double";else if(W==="'")G="single";else if(W==="`")G="template";else if(A5.has(W))Q++;else if(T5.has(W))Q=Math.max(0,Q-1);else if(W==="<")Q++;else if(W===">"&&L!=="=")Q=Math.max(0,Q-1)}}return Z.join(`
|
|
22
|
+
`)}function E5(j){let $=j.split(`
|
|
23
|
+
`).map((Q)=>Q.replace(Kj,"")),Z=[];for(let Q of $){let J=Q==="",Y=Z.length>0&&Z[Z.length-1]==="",K=Z.length>0&&F5.test(Z[Z.length-1]);if(J){if(Z.length===0||Y||K)continue;Z.push(Q);continue}if(Yj.test(Q)&&Y)Z.pop();Z.push(Q)}while(Z.length>0&&Z[Z.length-1]==="")Z.pop();return Z.join(`
|
|
24
|
+
`)}function zj(j){let $=Uj(j),Z=g5($);return`${E5(Z)}
|
|
25
|
+
`}var f="any",w="",y5="Record<string, any>",Z2="Record<string, never>",P5=/(-|\s+|:)/,v5=/("|')/,f5=/CustomEvent/,h5=/^[A-Z]/,u5=/\n/,Hj=/=>/,m5=/(?:^|\n)@default\b/,Q2=/\n/g,c5=/\s+/g,d5=/(^|[^.\w])Snippet(?:\s*<|\b)/,l5=/import\s+type\s+[^;]*\bSnippet\b[^;]*from\s+"svelte";/,i5=/[.*+?^${}()|[\]\\]/g,p5=/^const\s+/;function J2(j){return j.replace(p5,"")}function a5(j){if(!j)return;return j.replace(Q2,`
|
|
26
|
+
* `)}function F0(j){if(!j)return"";return`/** ${j} */`}function _0(j){if(!j)return"";return`/**
|
|
27
|
+
* ${j.replace(Q2,`
|
|
28
|
+
* `)}
|
|
29
|
+
*/`}function Vj(j){if(j===void 0)return;return j===!0?"@deprecated":`@deprecated ${j}`}function s5(j){let $=Vj(j);if($===void 0)return;return`* ${$.replace(Q2,`
|
|
30
|
+
* `)}
|
|
31
|
+
`}function r5(j,$){if(!$)return[`@${j}`];if(!$.includes(`
|
|
32
|
+
`))return[`@${j} ${$}`];return[`@${j}`,...$.split(`
|
|
33
|
+
`)]}function Xj(j){let $=[];for(let{name:Z,body:Q}of j??[])$.push(...r5(Z,Q));return $}function K0(j,$,Z){let Q=Vj(Z),J=Xj($),Y=J.length>0;if(!j&&!Y&&!Q)return"";if(!Y&&!Q)return j?.includes(`
|
|
34
|
+
`)?_0(j):F0(j);let K=[];if(j)K.push(...j.split(`
|
|
35
|
+
`));if(K.push(...J),Q)K.push(...Q.split(`
|
|
36
|
+
`));return`/**
|
|
37
|
+
* ${K.join(`
|
|
38
|
+
* `)}
|
|
39
|
+
*/`}function n5(j){let $=Xj(j);if($.length===0)return"";return $.map((Z)=>`* ${Z}
|
|
40
|
+
`).join("")}function N0(j){if(j===void 0)return f;return`${j}
|
|
41
|
+
`}function w0(j){if(j.typedefs.length===0)return w;return j.typedefs.map(($)=>{return`${$.description?`${_0($.description)}
|
|
42
|
+
`:""}export ${$.ts}`}).join(`
|
|
43
|
+
|
|
44
|
+
`)}function Gj(j,$){let Z=$.replace(i5,"\\$&");return new RegExp(`\\b${Z}\\b`).test(j)}function t5(j){if(j===null)return[];return j[0].split(",").map(($,Z)=>({name:$.trim(),constraint:(b0(j[1]??"")[Z]??$).trim()}))}function o5(j,$){let Z=t5(j).filter(({name:Q})=>Gj($,Q));if(Z.length===0)return{declSuffix:w,refSuffix:w};return{declSuffix:`<${Z.map(({constraint:Q})=>J2(Q)).join(", ")}>`,refSuffix:`<${Z.map(({name:Q})=>Q).join(", ")}>`}}function qj(j){if(!j.contexts||j.contexts.length===0)return w;let $=j.generics===null?[]:j.generics[0].split(",").map((Z,Q)=>({name:Z.trim(),constraint:(b0(j.generics?.[1]??"")[Q]??Z).trim()}));return j.contexts.map((Z)=>{let Q=Z.properties.map((z)=>{let H=z.description?`${F0(z.description)}
|
|
45
|
+
`:"",U=z.optional?"?":"";return`${H}${z.name}${U}: ${z.type};`}).join(`
|
|
46
|
+
`),J=Z.description?`${_0(Z.description)}
|
|
47
|
+
`:"",Y=$.filter(({name:z})=>Z.properties.some((H)=>Gj(H.type,z))).map(({constraint:z})=>z),K=Y.length>0?`<${Y.map(J2).join(", ")}>`:"";if(Z.properties.length===0)return`${J}export type ${Z.typeName} = Record<string, never>;`;return`${J}export type ${Z.typeName}${K} = {
|
|
48
|
+
${Q}
|
|
49
|
+
};`}).join(`
|
|
50
|
+
|
|
51
|
+
`)}function U0(j){if(P5.test(j))return v5.test(j)?j:`"${j}"`;return j}function Wj(j,$){if(!j)return;return`* ${$||j}
|
|
52
|
+
`}function Y2(j,$,Z){return[Wj(a5(j)),s5($),n5(Z)].filter(Boolean).join("")}function K2(j){return j.length>0?`/**
|
|
53
|
+
${j}*/`:w}function e5(j){let $=new Set([...j.props.filter((X)=>!X.isFunctionDeclaration&&X.kind!=="const").map((X)=>X.name),...Array.from(j.canonicalPropNames??[])]),Z=j.props.filter((X)=>!X.isFunctionDeclaration&&X.kind!=="const").map((X)=>{let k=X.value;if(typeof X.value==="string")k=X.value.replace(c5," ");if(X.value===void 0)k="undefined";let I=m5.test(X.description??""),O=[Y2(X.description,X.deprecated,X.tags),Wj(X.constant,"@constant"),X.isFunction||I?null:`* @default ${k}
|
|
54
|
+
`].filter(Boolean).join(""),M=X.constant&&!X.isFunction?X.value:X.type;return`
|
|
55
|
+
${K2(O)}
|
|
56
|
+
${X.name}${X.isRequired?"":"?"}: ${M};`}),Q=j.canonicalPropsType?Z.filter((X,k)=>{let I=j.props.filter((O)=>!O.isFunctionDeclaration&&O.kind!=="const")[k];return I?!(j.canonicalPropNames?.has(I.name)??!1):!0}):Z,J=(j.slots||[]).filter((X)=>!X.default&&X.name!=null&&!$.has(X.name)).map((X)=>{let k=X.name,I=U0(k),O=K0(X.description,X.tags,X.deprecated),M=O?`${O}
|
|
57
|
+
`:"",S=X.slot_props&&X.slot_props!=="Record<string, never>"?`(this: void, ...args: [${X.slot_props}]) => void`:"(this: void) => void";return`
|
|
58
|
+
${M}${I}?: ${S};`}),Y=(j.slots||[]).find((X)=>X.default||X.name===null),K=Y&&!$.has("children")?(()=>{let X=K0(Y.description,Y.tags,Y.deprecated),k=X?`${X}
|
|
59
|
+
`:"",O=Y.slot_props&&Y.slot_props!=="Record<string, never>"?`(this: void, ...args: [${Y.slot_props}]) => void`:"(this: void) => void";return`
|
|
60
|
+
${k}children?: ${O};`})():"",z=j.events?Y1({events:j.events},$):[],H=[...J,K,...z].filter(Boolean),U=[...Q,...H].join(`
|
|
61
|
+
`),V=`${j.moduleName}Props`,G=w,q=j.generics?`<${b0(j.generics[1]).map((X)=>J2(X.trim())).join(", ")}>`:"",W=j.generics?`<${j.generics[0]}>`:"",L=j.canonicalPropsType?`
|
|
62
|
+
type $Props${q} = ${j.canonicalPropsType}${U.trim()===""?"":` & {${U}
|
|
63
|
+
}`};
|
|
64
|
+
`:`
|
|
65
|
+
type $Props${q} = {
|
|
66
|
+
${U}
|
|
67
|
+
};
|
|
68
|
+
`;if(j.rest_props?.type==="Element"){let X;if(j.rest_props.name==="svelte:element")if(j.rest_props.thisValue)X=`SvelteHTMLElements["${j.rest_props.thisValue}"]`;else X="HTMLAttributes<HTMLElement>";else X=j.rest_props.name.split("|").map((O)=>{return`SvelteHTMLElements["${O.trim()}"]`}).join(" & ");let k="[key: `data-${string}`]: unknown;",I=j.rest_props.description?j.rest_props.description.includes(`
|
|
69
|
+
`)?`${_0(j.rest_props.description)}
|
|
70
|
+
`:`${F0(j.rest_props.description)}
|
|
71
|
+
`:"";if(j.extends===void 0)G=`
|
|
72
|
+
${I}${X?`type $RestProps = ${X};
|
|
73
|
+
`:""}
|
|
74
|
+
${j.canonicalPropsType?`type $Props${q} = (${j.canonicalPropsType}) & {${U}
|
|
75
|
+
|
|
76
|
+
${k}
|
|
77
|
+
};`:`type $Props${q} = {
|
|
78
|
+
${U}
|
|
79
|
+
|
|
80
|
+
${k}
|
|
81
|
+
};`}
|
|
82
|
+
|
|
83
|
+
export type ${V}${q} = Omit<$RestProps, keyof $Props${W}> & $Props${W};
|
|
84
|
+
`;else G=`
|
|
85
|
+
${I}${X?`type $RestProps = ${X};
|
|
86
|
+
`:""}
|
|
87
|
+
${j.canonicalPropsType?`type $Props${q} = (${j.canonicalPropsType}) & {${U}
|
|
88
|
+
|
|
89
|
+
${k}
|
|
90
|
+
};`:`type $Props${q} = {
|
|
91
|
+
${U}
|
|
92
|
+
|
|
93
|
+
${k}
|
|
94
|
+
};`}
|
|
95
|
+
|
|
96
|
+
export type ${V}${q} = Omit<$RestProps, keyof ($Props${W} & ${j.extends.interface})> & $Props${W} & ${j.extends.interface};
|
|
97
|
+
`}else if(U.trim()===""&&j.extends===void 0&&!j.canonicalPropsType)G=`
|
|
98
|
+
export type ${V}${q} = ${Z2};
|
|
99
|
+
`;else if(j.canonicalPropsType)G=`
|
|
100
|
+
${L}
|
|
101
|
+
export type ${V}${q} = ${j.extends===void 0?"":`${j.extends.interface} & `}$Props${W};
|
|
102
|
+
`;else G=`
|
|
103
|
+
export type ${V}${q} = ${j.extends===void 0?"":`${j.extends.interface} & `} {
|
|
104
|
+
${U}
|
|
105
|
+
};
|
|
106
|
+
`;return{props_name:V,prop_def:G}}function j1(j){if(j.slots.length===0)return Z2;let $=j.slots.map(({name:Z,slot_props:Q,...J})=>{let Y=J.default||Z===null?"default":U0(Z??""),K=K0(J.description,J.tags,J.deprecated);return`${K?`${K}
|
|
107
|
+
`:""}${U0(Y)}: ${N0(Q)};`}).join(`
|
|
108
|
+
`);return j.slots.length===1?`{${$}}`:`{
|
|
109
|
+
${$}
|
|
110
|
+
}`}var $1=()=>"WindowEventMap",Z1=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave","contextmenu","wheel","keydown","keyup","keypress","submit","change","input","focus","blur","focusin","focusout","reset","select","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragover","dragenter","dragleave","drop","pointerdown","pointerup","pointermove","pointerover","pointerout","pointerenter","pointerleave","pointercancel","gotpointercapture","lostpointercapture","play","pause","ended","volumechange","timeupdate","loadeddata","loadedmetadata","canplay","canplaythrough","seeking","seeked","playing","waiting","stalled","suspend","abort","error","emptied","ratechange","durationchange","loadstart","progress","loadend","animationstart","animationend","animationiteration","animationcancel","transitionstart","transitionend","transitionrun","transitioncancel","scroll","resize","load","unload","beforeunload","cut","copy","paste","compositionstart","compositionupdate","compositionend"]);function $2(j=f){if(f5.test(j))return j;return`CustomEvent<${j}>`}function Q1(j){return Z1.has(j)}function Oj(j){switch(j.type){case"dispatched":return $2(j.detail);case"forwarded":{let $=j.element,Q=!($&&h5.test($))||Q1(j.name),J=j.detail!==void 0&&j.detail!=="undefined"&&!(j.detail==="null"&&Q),Y=j.detail==="null"&&!Q;if(J||Y)return $2(j.detail);else if(Q)return`${$1()}["${j.name}"]`;else return $2()}default:return j}}function J1(j){if(j.events.length===0)return y5;let $=j.events.map((Z)=>{let Q="",J=K0(Z.description,Z.tags,Z.deprecated);if(J)Q=`${J}
|
|
111
|
+
`;return`${Q}${U0(Z.name)}: ${Oj(Z)};
|
|
112
|
+
`}).join("");return j.events.length===1?`{${$}}`:`{
|
|
113
|
+
${$}}`}function Y1(j,$){return j.events.map((Z)=>{let Q=`on${Z.name}`;if($.has(Q))return;let J="",Y=K0(Z.description,Z.tags,Z.deprecated);if(Y)J=`${Y}
|
|
114
|
+
`;return`
|
|
115
|
+
${J}${U0(Q)}?: (event: ${Oj(Z)}) => void;`}).filter((Z)=>Z!==void 0)}function K1(j){let $=j.type==="() => any";if(j.type&&Hj.test(j.type)&&!$)return j.type;else if(j.params&&j.params.length>0){let Q=j.params.map((Y)=>{let K=Y.optional?"?":"";return`${Y.name}${K}: ${Y.type}`}).join(", "),J=j.returnType||f;return`(${Q}) => ${J}`}else if(j.returnType)return`() => ${j.returnType}`;else return j.type||f}function kj(j){return j.props.filter(($)=>$.isFunctionDeclaration||$.kind==="const").map(($)=>{let Z=Y2($.description,$.deprecated,$.tags),Q=K1($);return`
|
|
116
|
+
${K2(Z)}
|
|
117
|
+
${$.name}: ${Q};`}).join(`
|
|
118
|
+
`)}function U1(j){let $=`${j.moduleName}Exports`,Z=kj({props:j.props});if(Z.trim()==="")return{exports_name:$,exports_ref:$,exports_def:`export type ${$} = ${Z2};`};let{declSuffix:Q,refSuffix:J}=o5(j.generics,Z);return{exports_name:$,exports_ref:`${$}${J}`,exports_def:`export type ${$}${Q} = {${Z}
|
|
119
|
+
};`}}function z1(j){let $=j.props.filter((Z)=>Z.bindable===!0||Z.binding==="writable").map((Z)=>`"${Z.name}"`);return $.length===0?w:$.join(" | ")}function H1(j){let $=j.moduleName==="default"?"$$Component":j.moduleName,Z=j.bindings===w?'""':j.bindings;return`declare const ${$}: Component<
|
|
120
|
+
${j.propsRef},
|
|
121
|
+
${j.exportsRef},
|
|
122
|
+
${Z}
|
|
123
|
+
>;
|
|
124
|
+
export default ${$};`}function V1(j){let $=j.moduleName==="default"?"$$Component":j.moduleName,Z=`${$}Component`,Q=j.bindings===w?'""':j.bindings;return`interface ${Z} {
|
|
125
|
+
new ${j.generic}(
|
|
126
|
+
options: ComponentConstructorOptions<${j.propsRef}>
|
|
127
|
+
): SvelteComponent<${j.propsRef}> & ${j.exportsRef};
|
|
128
|
+
${j.generic}(
|
|
129
|
+
this: void,
|
|
130
|
+
internals: ComponentInternals,
|
|
131
|
+
props: ${j.propsRef}
|
|
132
|
+
): {
|
|
133
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
134
|
+
$set?(props: Partial<${j.propsRef}>): void;
|
|
135
|
+
} & ${j.exportsRef};
|
|
136
|
+
element?: typeof HTMLElement;
|
|
137
|
+
z_$$bindings?: ${Q};
|
|
138
|
+
}
|
|
139
|
+
declare const ${$}: ${Z};
|
|
140
|
+
export default ${$};`}function X1(j){if(j.extends===void 0)return"";return`import type { ${j.extends.interface} } from ${j.extends.import};`}function G1(j){if(!j.componentComment)return"";if(!u5.test(j.componentComment))return F0(j.componentComment.trim());return`/*${j.componentComment.split(`
|
|
141
|
+
`).map(($)=>`* ${$}`).join(`
|
|
142
|
+
`)}
|
|
143
|
+
*/`}function q1(j){return j.moduleExports.map(($)=>{let Z=Y2($.description,$.deprecated,$.tags),Q,J=$.type&&Hj.test($.type),Y=$.type==="() => any";if($.kind==="const"&&!J)Q=`export declare const ${$.name}: ${$.type||f};
|
|
144
|
+
`;else if($.params&&$.params.length>0){let z=$.params.map((U)=>{let V=U.optional?"?":"";return`${U.name}${V}: ${U.type}`}).join(", "),H=$.returnType||f;Q=`export declare function ${$.name}(${z}): ${H};`}else if($.returnType)Q=`export declare function ${$.name}(): ${$.returnType};`;else if(J&&$.type&&!Y){let[K,z,...H]=$.type.split("=>"),U=H.map((V)=>` => ${V.trim()}`).join("");Q=`export declare function ${$.name}${K.trimEnd()}: ${z.trim()}${U};`}else if(J&&$.type){let[K,z,...H]=$.type.split("=>"),U=H.map((V)=>` => ${V.trim()}`).join("");Q=`export declare function ${$.name}${K.trimEnd()}: ${z.trim()}${U};`}else if($.kind==="const")Q=`export declare const ${$.name}: ${$.type||f};
|
|
145
|
+
`;else Q=`export type ${$.name} = ${$.type||f};`;return`
|
|
146
|
+
${K2(Z)}
|
|
147
|
+
${Q}`}).join(`
|
|
148
|
+
`)}var W1=120;function O1(j){let Z=`export default class ${j.moduleName==="default"?"":j.moduleName}${j.generic} extends SvelteComponentTyped<`,Q=[j.genericProps,j.events,j.slots];if(j.accessors.trim()===""&&Q.every((J)=>!J.includes(`
|
|
149
|
+
`))){let J=`${Z}${Q.join(", ")}> {}`;if(J.length<=W1)return J}return`${Z}
|
|
150
|
+
${j.genericProps},
|
|
151
|
+
${j.events},
|
|
152
|
+
${j.slots}
|
|
153
|
+
> {
|
|
154
|
+
${j.accessors}
|
|
155
|
+
}`}function U2(j,$){let Z=D0(j),{moduleName:Q,typedefs:J,generics:Y,props:K,moduleExports:z,slots:H,events:U,rest_props:V,extends:G,componentComment:q,contexts:W,syntaxMode:L}=j,X=$?.format==="component",k=Y!==null,{props_name:I,prop_def:O}=e5({moduleName:Q,props:K,rest_props:V,extends:G,generics:Y,slots:H,canonicalPropNames:new Set(Z?.canonicalPropNames??[]),canonicalPropsType:Z?.canonicalPropsType,events:X&&L==="legacy"?U:void 0}),M=Y?`<${Y[1]}>`:"",D=Y?`${I}<${Y[0]}>`:I,S=q1({moduleExports:z}),_=w0({typedefs:J}),N=qj({contexts:W,generics:Y}),A=(Z?.typeImportStatements??[]).join(`
|
|
156
|
+
`),B=(Z?.localTypeDeclarations??[]).join(`
|
|
157
|
+
|
|
158
|
+
`),{exports_ref:R,exports_def:b}=X?U1({props:K,moduleName:Q,generics:Y}):{exports_ref:w,exports_def:w},v=X?z1({props:K}):w,C=!l5.test(A)&&d5.test(`${O}
|
|
159
|
+
${S}
|
|
160
|
+
${_}
|
|
161
|
+
${N}
|
|
162
|
+
${B}
|
|
163
|
+
${b}`),Cj=V?.type==="Element"&&(V.name!=="svelte:element"||V.name==="svelte:element"&&V.thisValue),xj=V?.type==="Element"&&V.name==="svelte:element"&&!V.thisValue,gj=[X?k?`import type { SvelteComponent, ComponentConstructorOptions, ComponentInternals${C?", Snippet":""} } from "svelte";`:`import type { Component${C?", Snippet":""} } from "svelte";`:`import { SvelteComponentTyped${C?", type Snippet":""} } from "svelte";`,Cj?'import type { SvelteHTMLElements } from "svelte/elements";':"",xj?'import type { HTMLAttributes } from "svelte/elements";':"",A,X1({extends:G})].filter(Boolean).join(`
|
|
164
|
+
`),Ej=X?k?V1({moduleName:Q,generic:M,propsRef:D,exportsRef:R,bindings:v}):H1({moduleName:Q,propsRef:D,exportsRef:R,bindings:v}):O1({moduleName:Q,generic:M,genericProps:D,events:J1({events:U}),slots:j1({slots:H}),accessors:kj({props:K})}),yj=[S,_,B,N,O,b,[G1({componentComment:q}),Ej].filter(Boolean).join(`
|
|
165
|
+
`)].map((Pj)=>Pj.trim()).filter(Boolean).join(`
|
|
166
|
+
|
|
167
|
+
`);return zj([gj,yj].filter(Boolean).join(`
|
|
168
|
+
|
|
169
|
+
`))}var z2=/`/g,C0=/\s+/g,g="--",Lj=`| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |
|
|
170
|
+
| :- | :- | :- | :- | :- | :- | :- | :- |
|
|
171
|
+
`,Bj=`| Slot name | Default | Props | Fallback | Description |
|
|
172
|
+
| :- | :- | :- | :- | :- |
|
|
173
|
+
`,Rj=`| Event name | Type | Detail | Description |
|
|
174
|
+
| :- | :- | :- | :- |
|
|
175
|
+
`,Ij=`| Name | Kind | Type | Description |
|
|
176
|
+
| :- | :- | :- | :- |
|
|
177
|
+
`,x0=/\|/g,k1=/</g,L1=/>/g,i=/\n/g;function h(j){if(j===void 0)return g;return`<code>${j.replace(x0,"|")}</code>`}function z0(j){return j.replace(k1,"<").replace(L1,">")}function Mj(j){if(j===void 0)return g;return`<code>${j.replace(z2,"\\`").replace(x0,"|")}</code>`}function g0(j,$){if($===void 0)return j;let Z=typeof $==="string"&&$.trim().length>0?`: ${z0($).replace(i," ").replace(x0,"|")}`:"";return`<s>${j}</s><br />**Deprecated**${Z}`}function E0(j){if(j===void 0||j.trim().length===0)return g;return z0(j).replace(i,"<br />")}function Dj(j){if(j===void 0||j==="{}")return g;return h(N0(j).replace(i," "))}function Aj(j){if(j===void 0)return g;return h(z0(j).replace(i,"<br />"))}function Tj(j,$){let Z=[];if(j!==void 0&&j.trim().length>0)Z.push(z0(j));for(let{name:Q,body:J}of $??[]){let Y=J?.trim();Z.push(Y?`@${Q} ${z0(Y)}`:`@${Q}`)}if(Z.length===0)return g;return Z.join(`
|
|
178
|
+
`).replace(x0,"|").replace(i,"<br />")}function Sj(j){if(j===void 0)return g;return h(j.replace(i," "))}function bj(j,$,Z){if(j.append("h1","Component Index"),j.append("h2","Components").tableOfContents(),j.append("divider"),Z&&Z.length>0)B1(j,Z);let Q=x($);for(let J of Q.components)R1(j,J)}function B1(j,$){j.append("h2","Exports"),j.append("raw",Ij);for(let Z of $){let Q=(Z.type??Z.value)?.replace(C0," ").trim();j.append("raw",`| ${Z.name} | ${`<code>${Z.kind}</code>`} | ${h(Q)} | ${E0(Z.description)} |
|
|
179
|
+
`)}j.append("raw",`
|
|
180
|
+
`),j.append("divider")}function H2(j,$,Z,Q){if($.length>0)Z(),j.append("raw",`
|
|
181
|
+
`);else j.append("p",Q??"None.")}function R1(j,$){if(j.append("h2",`\`${$.moduleName}\``),$.generics)j.append("p",`**Type parameters:** ${h(`<${$.generics[1]}>`)}`);if($.typedefs.length>0)j.append("h3","Types").append("raw",`\`\`\`ts
|
|
182
|
+
${w0({typedefs:$.typedefs})}
|
|
183
|
+
\`\`\`
|
|
184
|
+
|
|
185
|
+
`);j.append("h3","Props"),H2(j,$.props,()=>{j.append("raw",Lj);let Z=[...$.props].sort((Q)=>{if(Q.reactive)return-1;if(Q.constant)return 1;return 0});for(let Q of Z)j.append("raw",`| ${g0(Q.name,Q.deprecated)} | ${Q.isRequired?"Yes":"No"} | ${`<code>${Q.kind}</code>`} | ${Q.reactive?"Yes":"No"} | ${Q.binding??"--"} | ${h(Q.type)} | ${Mj(Q.value)} | ${E0(Q.description)} |
|
|
186
|
+
`)}),j.append("h3","Slots"),H2(j,$.slots,()=>{j.append("raw",Bj);for(let Z of $.slots)j.append("raw",`| ${g0(Z.default?g:Z.name??g,Z.deprecated)} | ${Z.default?"Yes":"No"} | ${Dj(Z.slot_props)} | ${Aj(Z.fallback)} | ${Tj(Z.description,Z.tags)} |
|
|
187
|
+
`)}),j.append("h3","Events"),H2(j,$.events,()=>{j.append("raw",Rj);for(let Z of $.events)j.append("raw",`| ${g0(Z.name,Z.deprecated)} | ${Z.type} | ${Z.type==="dispatched"?Sj(Z.detail):g} | ${E0(Z.description)} |
|
|
188
|
+
`)})}class V2{sourceParts=[];hasToC=!1;toc=[];get source(){return this.sourceParts.join("")}appendLineBreaks(){return this.sourceParts.push(`
|
|
189
|
+
|
|
190
|
+
`),this}append(j,$){switch(j){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{let Z=Number(j.slice(-1));if(this.sourceParts.push(`${"#".repeat(Z)} ${$}`),this.hasToC&&j==="h2")this.toc.push({indent:0,raw:$??""});break}case"quote":this.sourceParts.push(`> ${$}`);break;case"p":this.sourceParts.push($??"");break;case"divider":this.sourceParts.push("---");break;case"raw":this.sourceParts.push($??"");break}if(j!=="raw")this.appendLineBreaks();return this}tableOfContents(){return this.sourceParts.push("<!-- __TOC__ -->"),this.hasToC=!0,this.appendLineBreaks(),this}end(){return this.sourceParts.join("").replace("<!-- __TOC__ -->",this.toc.map(({indent:$,raw:Z})=>{return`${" ".repeat($)}- [${Z}](#${Z.toLowerCase().replace(z2,"").replace(C0,"-")})`}).join(`
|
|
191
|
+
`))}}class y0 extends l{onAppend;markdownBase;constructor(j){super();this.onAppend=j.onAppend,this.markdownBase=new V2}get source(){return this.markdownBase.source}get hasToC(){return this.markdownBase.hasToC}get toc(){return this.markdownBase.toc}appendLineBreaks(){return this.markdownBase.appendLineBreaks(),this}append(j,$){return this.markdownBase.append(j,$),this.onAppend?.call(this,j,this),this}tableOfContents(){return this.markdownBase.tableOfContents(),this}end(){return this.markdownBase.end()}}async function X2(j,$){let Z=$?.write!==!1,Q=new y0({onAppend:(J,Y)=>{$.onAppend?.call(null,J,Y,j)}});if(bj(Q,j,$.entryExports),Z){let J=I1(process.cwd(),$.outFile);await Q.write(J,Q.end()),console.log(`created "${$.outFile}".`)}return Q.end()}import{join as wj}from"node:path";var Fj=/\.svelte$/;function _j(j){let $=new Map;for(let[Q,J]of Object.entries(j)){let Y=$.get(J.source)||[];Y.push({id:Q,exportee:J}),$.set(J.source,Y)}let Z=[];for(let[Q,J]of $){let Y=Fj.test(Q),K=J.some(({id:q,exportee:W})=>q!=="default"&&W.default),z=J.some(({exportee:q})=>!q.default),H=Y&&K&&z,U=[],V=[],G=[];for(let{id:q,exportee:W}of J){if(q==="default"){V.push(`export { default } from "${Q}";`);continue}if(W.default)if(W.mixed)V.push(`export { default as ${q} } from "${Q}";`),V.push(`export { default } from "${Q}";`);else G.push(`default as ${q}`);else if(Y&&!H)G.push(`default as ${q}`);else U.push(q)}if(G.length>0&&U.length>0)Z.push(`export { ${[...G,...U].join(", ")} } from "${Q}";`);else{if(U.length>0)Z.push(`export { ${U.join(", ")} } from "${Q}";`);if(G.length>0)Z.push(`export { ${G.join(", ")} } from "${Q}";`)}Z.push(...V)}return Z.join(`
|
|
192
|
+
`)}function Nj(j){return j.replace(Fj,".svelte.d.ts")}async function G2(j,$){let Z=wj(process.cwd(),$.outDir,"index.d.ts"),Q=Zj(),J=$.preamble+_j($.exports),K=x(j).components.map(async(z)=>{let H=Nj(wj($.outDir,z.filePath));await Q.write(H,U2(z,{format:$.format}))});await Promise.all([...K,Q.write(Z,`${J}
|
|
193
|
+
`)]),console.log("created TypeScript definitions.")}p({name:"json",componentSet:"exported",write:j2});p({name:"markdown",componentSet:"exported",write:X2});p({name:"types",componentSet:"all",write:G2});p({name:"custom-elements",componentSet:"exported",write:e0});var D1=50,A1=/\.svelte$/;function T1(j){let $=j?.watch===!0,Z,Q,J=null,Y,K=new Set,z=async()=>{if(J==null||Q==null||K.size===0)return;let U=Array.from(K);K.clear();try{let{result:V}=await J.update(U);await H0(V,j||{},Q)}catch(V){console.error("sveld: failed to regenerate types in watch mode:",V)}},H=(U)=>{if(!$||J==null||!A1.test(U))return;K.add(U),clearTimeout(Y),Y=setTimeout(z,D1)};return{name:"vite-plugin-sveld",apply:$?void 0:"build",enforce:"post",async buildStart(){if(Q=S0(j?.entry),$&&Q!=null)J=await $j(Q,j?.glob===!0,j?.documentExports===!0),await H0(J.result,j||{},Q)},async generateBundle(){if($)return;if(Q!=null)Z=await Q0(Q,j?.glob===!0,j0(j))},async writeBundle(){if($)return;if(Q!=null)await H0(Z,j||{},Q)},handleHotUpdate(U){H(U.file)},watchChange(U){H(U)}}}function P0(j,$,Z){let Q=u0(j);if(!Q)throw Error(`sveld: built-in writer "${j}" is not registered.`);return Q.write($,Z)}async function H0(j,$,Z){let Q=M1(Z);if($?.types!==!1)await P0("types",j.allComponentsForTypes,{outDir:"types",preamble:"",...$?.typesOptions,exports:j.exports,inputDir:Q});if($?.json)await P0("json",j.components,{outFile:"COMPONENT_API.json",...$?.jsonOptions,input:Z,inputDir:Q,entryExports:j.entryExports});if($?.markdown)await P0("markdown",j.components,{outFile:"COMPONENT_INDEX.md",...$?.markdownOptions,entryExports:j.entryExports});if($?.customElements)await P0("custom-elements",j.components,{outFile:"custom-elements.json",...$?.customElementsOptions,inputDir:Q});let J=Object.entries($?.additionalWriters??{}).map(([Y,K])=>{let z=u0(Y);if(!z){console.warn(`sveld: no writer registered with name "${Y}"; skipping.`);return}let H=z.componentSet==="all"?j.allComponentsForTypes:j.components;return z.write(H,K)});await Promise.all(J)}import{existsSync as S1}from"node:fs";import{join as b1}from"node:path";var q2="src/index.js",F1=`Usage: sveld [options]
|
|
194
|
+
|
|
195
|
+
Generate TypeScript definitions and component documentation for a Svelte
|
|
196
|
+
library. With no flags, only TypeScript definitions are generated for the
|
|
197
|
+
entry resolved from package.json#svelte.
|
|
198
|
+
|
|
199
|
+
Options:
|
|
200
|
+
--entry=<path> Entry point to uncompiled Svelte source (default: package.json "svelte" field)
|
|
201
|
+
--glob Analyze all *.svelte files instead of the entry barrel
|
|
202
|
+
--types Generate TypeScript definitions (default: true)
|
|
203
|
+
--json Generate component documentation in JSON format
|
|
204
|
+
--markdown Generate component documentation in Markdown format
|
|
205
|
+
--custom-elements Generate a Custom Elements Manifest (custom-elements.json)
|
|
206
|
+
--fail-fast Abort the run when a single component fails to parse
|
|
207
|
+
--cache[=<path>] Persist parsed output and skip re-parsing unchanged files (on by default, default path: node_modules/.cache/sveld/parse-cache.json; pass --cache=false to disable)
|
|
208
|
+
--resolve-types Expand opaque imported $props() types into JSON (alias: --resolveTypes, deprecated)
|
|
209
|
+
--check-examples Compile-check @example blocks against the TypeScript program (alias: --checkExamples, deprecated)
|
|
210
|
+
--report-diagnostics Print unresolved-type diagnostics to stderr
|
|
211
|
+
--strict Exit with code 1 when diagnostics exist (implies --report-diagnostics)
|
|
212
|
+
--types-format=<format> ".d.ts" output format: "class" (default) or "component" (Svelte 5 Component<...>)
|
|
213
|
+
--check[=<path>] Diff the parsed API against a committed snapshot; exit 1 on a breaking change (default path: COMPONENT_API.json)
|
|
214
|
+
--help Print this help message and exit
|
|
215
|
+
--version Print the installed sveld version and exit
|
|
216
|
+
`,_1={resolveTypes:"resolve-types",checkExamples:"check-examples"};function N1(j){if(!j.startsWith("--"))return{kind:"unknown",arg:j};let $=j.indexOf("="),Z=$===-1?j.slice(2):j.slice(2,$),Q=$===-1?!0:j.slice($+1),J=_1[Z]??Z;switch(J){case"help":return{kind:"help"};case"version":return{kind:"version"};case"glob":case"types":case"json":case"markdown":return{kind:"option",option:{[J]:Q===!0||Q==="true"}};case"custom-elements":return{kind:"option",option:{customElements:Q===!0||Q==="true"}};case"strict":return{kind:"option",option:{strict:Q===!0||Q==="true"}};case"report-diagnostics":return{kind:"option",option:{reportDiagnostics:Q===!0||Q==="true"}};case"resolve-types":return{kind:"option",option:{resolveTypes:Q===!0||Q==="true"}};case"check-examples":return{kind:"option",option:{checkExamples:Q===!0||Q==="true"}};case"fail-fast":return{kind:"option",option:{failFast:Q===!0||Q==="true"}};case"entry":return typeof Q==="string"?{kind:"option",option:{entry:Q}}:{kind:"option",option:{}};case"cache":if(Q==="false")return{kind:"option",option:{cache:!1}};return{kind:"option",option:{cache:typeof Q==="string"?Q:!0}};case"check":if(Q==="false")return{kind:"option",option:{check:!1}};return{kind:"option",option:{check:typeof Q==="string"?Q:!0}};case"types-format":return typeof Q==="string"?{kind:"option",option:{typesOptions:{format:Q}}}:{kind:"option",option:{}};default:return{kind:"unknown",arg:j}}}function w1(j){let $={};for(let Z of j){let Q=N1(Z);if(Q.kind!=="option")return Q;Object.assign($,Q.option)}return{kind:"options",options:$}}async function W6(j){let $=w1(j.argv.slice(2));if($.kind==="help"){console.log(F1);return}if($.kind==="version"){console.log(O2.version);return}if($.kind==="unknown"){console.error(`Unknown flag: ${$.arg}`),console.error("Run sveld --help for a list of available flags."),j.exitCode=1;return}let Z=$.options,Q=await F2(),J=_2(Q,Z);if(Q.typesOptions||Z.typesOptions)J.typesOptions={...Q.typesOptions,...Z.typesOptions};let Y=S0(J.entry),K;if(Y!==null)K=Y;else if(S1(b1(j.cwd(),q2)))console.error(`sveld: could not resolve an entry point; falling back to "${q2}". Set package.json#svelte (or pass --entry) to avoid relying on this fallback.`),K=a(F(q2));else{j.exitCode=1;return}let z=await Q0(K,J.glob===!0,j0(J)),H;if(J.check)H=await A2(z.components,D2(J),{entryExports:z.entryExports});await H0(z,J,K);let{diagnostics:U}=z;if((J.reportDiagnostics||J.strict)&&U.length>0)console.error(N2(U));if(H){if(console.log(T2(H)),H.bump==="major")j.exitCode=1}if(J.strict&&U.length>0)j.exitCode=1}
|
|
217
|
+
export{x as a,aj as b,D2 as c,A2 as d,T2 as e,N2 as f,S0 as g,s1 as h,F2 as i,_2 as j,j0 as k,Q0 as l,p as m,u0 as n,n1 as o,T1 as p,H0 as q,W6 as r};
|