sveld 0.36.0 → 0.36.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/lib/browser.js +185 -185
- package/lib/chunk-290pdrzm.js +20 -0
- package/lib/chunk-4mbjcdex.js +230 -0
- package/lib/{chunk-tmj7vnjr.js → chunk-dcbq3977.js} +4 -4
- package/lib/chunk-f7112d82.js +1 -0
- package/lib/{chunk-as5hgj7e.js → chunk-gc8z6pa7.js} +2 -2
- package/lib/chunk-w5kk4gd1.js +1 -0
- package/lib/cli-entry.js +1 -1
- package/lib/index.d.ts +40 -0
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/lib/chunk-0fqdg2xa.js +0 -20
- package/lib/chunk-2vwf7nck.js +0 -1
- package/lib/chunk-m538qnhp.js +0 -230
- package/lib/chunk-r4rrncmd.js +0 -1
package/lib/chunk-0fqdg2xa.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import{A as $0,B as J0,C as TO,D as y0,E as ZO,H as tO,I as v,J as r0,K as x,L as YO,M as NO,N as vO,O as gO,P as _0,Q as yO,R as xO,S as eO,T as wO,U as O1,V as uO,v as hO,w as U0,x as Q0,y as nO,z as C0}from"./chunk-8myyzjb1.js";import{X as Z1}from"./chunk-as5hgj7e.js";class A0{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 A0{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,q=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 X=this.should_skip,H=this.should_remove;if(this.should_skip=Y,this.should_remove=q,this.replacement=K,X)return O;if(H)return null}let W;for(W in O){let Y=O[W];if(Y&&typeof Y==="object"){if(Array.isArray(Y)){let q=Y;for(let K=0;K<q.length;K+=1){let X=q[K];if($O(X)){if(!this.visit(X,O,W,K))K--}}}else if($O(Y))this.visit(Y,O,W,null)}}if(this.leave){let Y=this.replacement,q=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=q,K)return null}}return O}}function $O(O){return O!==null&&typeof O==="object"&&"type"in O&&typeof O.type==="string"}function X0(O,{enter:Z,leave:$}){return new T0(Z,$).visit(O,null)}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 $1(O){return O in QO}function WO(O){if($1(O))return QO[O];return"HTMLElement"}var Q1=/\w/;function W1(O,Z){let $=O.trim();if(!$.startsWith("{")||!$.endsWith("}"))return;let Q=$.slice(1,-1),W=[],Y=0,q="";for(let K of Q)if(K==="{"||K==="<"||K==="("||K==="[")Y++,q+=K;else if(K==="}"||K===">"||K===")"||K==="]")Y--,q+=K;else if((K===";"||K===",")&&Y===0)W.push(q.trim()),q="";else q+=K;if(q.trim())W.push(q.trim());for(let K of W){if(!K.startsWith(Z))continue;let X=K.slice(Z.length);if(X.length>0&&Q1.test(X[0]))continue;let H=X.trimStart();if(H.startsWith("?"))H=H.slice(1).trimStart();if(H.startsWith(":"))return H.slice(1).trim()}return}function F0(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 q=Z.getPropTypeByLocalOrPublic(W)??Z.findVariableTypeAndDescription(W)?.type;if(!q)return;return W1(q,Y)}function N0(){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 K0(O,Z,$,Q,W){O.diagnosticRecords.push({component:O.componentFilePath,kind:Z,name:$,message:Q,...W?{source:W}:{}})}function n(O){return O===void 0||O===""?void 0:O}var Y1=/[\r\n]+/g;function M0(O,Z,$,Q){if(n($)===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 H0(O,Z,$,Q=0){let W,Y,q=!1;if(!$||typeof $!=="object"||!("type"in $))return{value:W,type:Y,isFunction:q};let K=U1(O,Z,$);if($.type==="ObjectExpression"||$.type==="BinaryExpression"||$.type==="ArrayExpression"||$.type==="ArrowFunctionExpression"||$.type==="FunctionExpression"){let X=$;if("start"in X&&"end"in X&&typeof X.start==="number"&&typeof X.end==="number")W=x(Z,X.start,X.end)?.replace(Y1," ");if(Y=W,q=$.type==="ArrowFunctionExpression"||$.type==="FunctionExpression",$.type==="BinaryExpression"){let H=$;if(H.left&&typeof H.left==="object"&&"type"in H.left&&H.left.type==="Literal"&&"value"in H.left&&typeof H.left.value==="string")Y="string"}if($.type==="ArrowFunctionExpression"||$.type==="FunctionExpression")Y=XO($),W=void 0}else if($.type==="UnaryExpression"){let X=$;if("start"in X&&"end"in X&&typeof X.start==="number"&&typeof X.end==="number")W=x(Z,X.start,X.end);if(X.argument){if(typeof X.argument==="object"&&"type"in X.argument&&X.argument.type==="UnaryExpression")Y=H0(O,Z,X.argument).type;else if(typeof X.argument==="object"&&"value"in X.argument)Y=typeof X.argument.value}}else if($.type==="NewExpression"){let X=$;if("start"in X&&"end"in X&&typeof X.start==="number"&&typeof X.end==="number")W=x(Z,X.start,X.end);if(X.callee&&typeof X.callee==="object"&&"type"in X.callee&&X.callee.type==="Identifier"){let H=X.callee.name;if(H==="Date")Y="Date";else if(H==="Map")Y="Map<any, any>";else if(H==="Set")Y="Set<any>";else if(H==="WeakMap")Y="WeakMap<object, any>";else if(H==="WeakSet")Y="WeakSet<object>";else if(H==="Array")Y="any[]";else if(H==="RegExp"||H==="Regexp")Y="RegExp";else if(H==="Error")Y="Error";else Y=H}}else if($.type==="CallExpression"){let X=$;if("start"in X&&"end"in X&&typeof X.start==="number"&&typeof X.end==="number")W=x(Z,X.start,X.end)}else if($.type==="Identifier"){let X=$;if(Q<5){let H=q1(Z,X.name);if(H){let z=H0(O,Z,H,Q+1),J=O.resolveLocalVarJSDoc(X.name);return{...z,resolvedType:J?.type??z.resolvedType,resolvedDescription:J?.description??z.resolvedDescription,resolvedParams:J?.params??z.resolvedParams,resolvedReturnType:J?.returnType??z.resolvedReturnType}}if(Z.funcDecls.has(X.name)){let z=O.resolveLocalVarJSDoc(X.name),J=Z.funcDecls.get(X.name);return{value:void 0,type:void 0,isFunction:!0,resolvedType:z?.type??X1(z,J),resolvedDescription:z?.description,resolvedParams:z?.params,resolvedReturnType:z?.returnType}}}if("start"in X&&"end"in X&&typeof X.start==="number"&&typeof X.end==="number")W=x(Z,X.start,X.end)}else if($.type==="MemberExpression"){let X=$;if("start"in X&&"end"in X&&typeof X.start==="number"&&typeof X.end==="number")W=x(Z,X.start,X.end);if(O.isNumericConstant($))Y="number"}else if($.type==="TemplateLiteral"){let X=$;if("start"in X&&"end"in X&&typeof X.start==="number"&&typeof X.end==="number")W=x(Z,X.start,X.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:q,defaultValue:K}}function q1(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 qO(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 X1(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 XO(Z);return"(...args: any[]) => any"}function XO(O){return`(${K1(O)}) => ${G1(O)}`}function K1(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 G1(O){if(O.async||O.generator)return"any";let Z=O.body,$;if(Z&&typeof Z==="object"&&"type"in Z&&Z.type==="BlockStatement"){if($=z1(Z),$.length===0)return"any"}else $=[Z];let Q=null;for(let W of $){let Y=H1(W);if(!Y)return"any";if(Q===null)Q=Y;else if(Q!==Y)return"any"}return Q??"any"}function z1(O){let Z=[];return X0(O,{enter($){if($.type==="FunctionDeclaration"||$.type==="FunctionExpression"||$.type==="ArrowFunctionExpression"){this.skip();return}if($.type==="ReturnStatement")Z.push($.argument??null)}}),Z}function H1(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 KO(O){if($0(O,"$bindable"))return{init:O.arguments[0],bindable:!0};return{init:O,bindable:!1}}function U1(O,Z,$){let Q=YO(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 q=v0(O,$);if(q.ok)Y.value=q.value}return Y}function v0(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=v0(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 q=v0(O,W.value);if(!q.ok)return{ok:!1};Q[Y]=q.value}return{ok:!0,value:Q}}return{ok:!1}}var j1=/[-_.:/\s]+/;function g0(O){return`${O.split(j1).map((Q)=>Q.charAt(0).toUpperCase()+Q.slice(1)).join("")}Context`}function J1(O,Z,$,Q){if(!$||typeof $!=="object"||!("type"in $))return null;if($.type==="ObjectExpression"){let W=[];if(!C0($))return null;let Y=$;for(let q of Y.properties){if(q.type!=="Property")continue;let K=Z.getPropertyName(q.key);if(!K)continue;let X="any",H;if(Q0(q.value)){let z=q.value.name,J=Z.findVariableTypeAndDescription(z);if(J)X=J.type,H=J.description;else K0(O,"context-any-type",K,`Context "${Q}" property "${K}" has no type annotation; defaulted to "any".`,v(O,q))}else if(q.value&&typeof q.value==="object"&&"type"in q.value&&(q.value.type==="ArrowFunctionExpression"||q.value.type==="FunctionExpression"))X=`(${q.value.params?.map((L)=>{if(Q0(L))return`${L.name||"arg"}: any`;return"arg: any"}).join(", ")||""}) => any`;else if(U0(q.value))X=q.value.value==null?"null":typeof q.value.value;W.push({name:K,type:X,description:H,optional:!1})}return{key:Q,typeName:g0(Q),properties:W,description:void 0}}else if(Q0($)){let W=$.name,Y=Z.findVariableTypeAndDescription(W);if(Y)return{key:Q,typeName:g0(Q),properties:[{name:W,type:Y.type,description:Y.description,optional:!1}]};return K0(O,"context-any-type",W,`Context "${Q}" variable "${W}" has no type annotation; defaulted to "any".`,v(O,$)),{key:Q,typeName:g0(Q),properties:[{name:W,type:"any",description:void 0,optional:!1}]}}return null}function GO(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 zO(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 GO(Q);if(Q.type==="Identifier"){if($>=5)return null;let W=qO(O,Q.name);if(W&&typeof W==="object"&&"type"in W){let Y=W;if((Y.type==="CallExpression"||Y.type==="NewExpression")&&GO(Y)==="")return Q.name;return zO(O,Y,$+1)}return null}return null}function HO(O,Z,$,Q){if(!$||typeof $!=="object"||!("type"in $)||$.type!=="CallExpression")return;let W=$,Y=W.arguments[0];if(!Y)return;let q=zO(O,Y);if(!q){let H=O.componentFilePath?` in ${O.componentFilePath}`:"";console.warn(`Warning: Could not resolve setContext key${H}. Use a string literal, const-bound string, or Symbol(). Skipping context type generation.`);return}let K=W.arguments[1];if(!K)return;let X=J1(O,Z,K,q);if(X&&!O.contexts.has(q))O.contexts.set(q,X)}function x0(O){return typeof O==="string"?JSON.stringify(O):String(O)}function B0(O,{name:Z,detail:$,has_argument:Q,description:W,deprecated:Y,tags:q,source:K}){if(Z===void 0)return;let X=!Q&&!$?"null":n($),H=W,z=O.events.get(Z);if(z?.type==="forwarded")O.events.set(Z,{type:"dispatched",name:Z,detail:X,description:H||z.description,deprecated:Y??z.deprecated,tags:q??z.tags,source:K||z.source});else if(z){let J=z.tags??q;O.events.set(Z,{...z,detail:z.detail===void 0?X:z.detail,description:z.description||H,deprecated:z.deprecated??Y,tags:J,source:K||z.source})}else O.events.set(Z,{type:"dispatched",name:Z,detail:X,description:H,deprecated:Y,tags:q,source:K})}function UO(O,Z){let $=Z.arguments[0],Q=y0($,"CustomEvent");if(!Q&&!y0($,"Event"))return;let W=$.arguments[0],Y=U0(W)?W.value:void 0;if(Y==null)return;let q=Q?$.arguments[1]:void 0,K=!1,X;if(C0(q)){let H=q.properties.find((z)=>z.type==="Property"&&Q0(z.key)&&z.key.name==="detail");if(H?.type==="Property")K=!0,X=U0(H.value)?H.value.value:void 0}return B0(O,{name:String(Y),detail:X==null?"":x0(X),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:q,optional:K,default:X})=>{let H=K?"?":"",z=q||"";if(X&&z)z=`${z} @default ${X}`;else if(X)z=`@default ${X}`;if(z){if($)return`/** ${z} */
|
|
2
|
-
${W}${H}: ${Y};`;return`/** ${z} */ ${W}${H}: ${Y};`}return`${W}${H}: ${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 G0(O){let Z=O.match(/^\s+/);return Z==null?["",O]:[O.slice(0,Z[0].length),O.slice(Z[0].length)]}function JO(O){return O.split(/\n/)}function MO(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 M1=/^@\S+/;function d0({fence:O="```"}={}){let Z=B1(O),$=(Q,W)=>Z(Q)?!W:W;return function(W){let Y=[[]],q=!1;for(let K of W){if(M1.test(K.tokens.description)&&!q)Y.push([K]);else Y[Y.length-1].push(K);q=$(K.tokens.description,q)}return Y}}function B1(O){if(typeof O==="string")return(Z)=>Z.split(O).length%2===0;return O}function c0({startLine:O=0,markers:Z=t}={}){let $=null,Q=O;return function(Y){let q=Y,K=l0();if([K.lineEnd,q]=jO(q),[K.start,q]=G0(q),$===null&&q.startsWith(Z.start)&&!q.startsWith(Z.nostart))$=[],K.delimiter=q.slice(0,Z.start.length),q=q.slice(Z.start.length),[K.postDelimiter,q]=G0(q);if($===null)return Q++,null;let X=q.trimRight().endsWith(Z.end);if(K.delimiter===""&&q.startsWith(Z.delim)&&!q.startsWith(Z.end))K.delimiter=Z.delim,q=q.slice(Z.delim.length),[K.postDelimiter,q]=G0(q);if(X){let H=q.trimRight();K.end=q.slice(H.length-Z.end.length),q=H.slice(0,-Z.end.length)}if(K.description=q,$.push({number:Q,source:Y,tokens:K}),Q++,X){let H=$.slice();return $=null,H}return null}}function i0({tokenizers:O}){return function($){var Q;let W=MO({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 P0(){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 h0(O="compact"){let Z=L1(O);return($)=>{let Q=0,W=[];for(let[K,{tokens:X}]of $.source.entries()){let H="";if(K===0&&X.description[0]!=="{")return $;for(let z of X.description){if(z==="{")Q++;if(z==="}")Q--;if(H+=z,Q===0)break}if(W.push([X,H]),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=[],q=W[0][0].postDelimiter.length;for(let[K,[X,H]]of W.entries()){if(X.type=H,K>0)X.type=X.postDelimiter.slice(q)+H,X.postDelimiter=X.postDelimiter.slice(0,q);[X.postType,X.description]=G0(X.description.slice(H.length)),Y.push(X.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 w1=(O)=>O&&O.startsWith('"')&&O.endsWith('"');function f0(){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]=G0(Q.slice($.name.length)),Z;let Y=0,q="",K=!1,X;for(let z of Q){if(Y===0&&m0(z))break;if(z==="[")Y++;if(z==="]")Y--;q+=z}if(Y!==0)return Z.problems.push({code:"spec:name:unpaired-brackets",message:"unpaired brackets",line:Z.source[0].number,critical:!0}),Z;let H=q;if(q[0]==="["&&q[q.length-1]==="]"){K=!0,q=q.slice(1,-1);let z=q.split("=");if(q=z[0].trim(),z[1]!==void 0)X=z.slice(1).join("=").trim();if(q==="")return Z.problems.push({code:"spec:name:empty-name",message:"empty name",line:Z.source[0].number,critical:!0}),Z;if(X==="")return Z.problems.push({code:"spec:name:empty-default",message:"empty default value",line:Z.source[0].number,critical:!0}),Z;if(!w1(X)&&/=(?!>)/.test(X))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=q,$.name=H,X!==void 0)Z.default=X;return[$.postName,$.description]=G0(Q.slice($.name.length)),Z}}function D0(O="compact",Z=t){let $=s0(O);return(Q)=>{return Q.description=$(Q.source,Z),Q}}function s0(O){if(O==="compact")return R1;if(O==="preserve")return F1;return O}function R1(O,Z=t){return O.map(({tokens:{description:$}})=>$.trim()).filter(($)=>$!=="").join(" ")}var I1=(O,{tokens:Z},$)=>Z.type===""?O:$,A1=({tokens:O})=>(O.delimiter===""?O.start:O.postDelimiter.slice(1))+O.description;function F1(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(A1).join(`
|
|
7
|
-
`)}function p0({startLine:O=0,fence:Z="```",spacing:$="compact",markers:Q=t,tokenizers:W=[P0(),h0($),f0(),D0($)]}={}){if(O<0||O%1>0)throw Error("Invalid startLine");let Y=c0({startLine:O,markers:Q}),q=d0({fence:Z}),K=i0({tokenizers:W}),X=s0($);return function(H){let z=[];for(let J of JO(H)){let L=Y(J);if(L===null)continue;let F=q(L),k=F.slice(1).map(K);z.push({description:X(F[0],Q),tags:k,source:L,problems:k.reduce((u,m)=>u.concat(m.problems),[])})}return z}}function C1(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})=>C1(Z)).join(`
|
|
8
|
-
`)}var P1={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 M3=Object.keys(P1);function V0(O,Z={}){return p0(Z)(O)}var N3=o0();var h1=null;function f1(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=F0(O,Z,$);else if(($.type==="ObjectExpression"||$.type==="TemplateLiteral")&&"start"in $&&"end"in $&&typeof $.start==="number"&&typeof $.end==="number")Q.value=x(O,$.start,$.end);return Q}function BO(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]=f1(O,Z,W.value)}return Q}function D1(O,Z){if(!Z||typeof Z!=="object"||!("type"in Z))return null;if(Z.type==="Identifier"){let Y=Z,q=O.propLocalToPublicName.get(Y.name);if(!q)return null;return{publicName:q,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 VO(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=D1(O,Q.callee);if(!W)return null;return{...W,arguments:Q.arguments}}function L0(O,{slot_name:Z,slot_props:$,slot_fallback:Q,slot_description:W,slot_deprecated:Y,slot_tags:q,source:K}){let X=Z===void 0||Z==="",H=X?h1:Z??"",z=n(Q),J=$===void 0||$===""?void 0:$,L=W?.trim()||void 0;if(O.slots.has(H)){let F=O.slots.get(H);if(F)O.slots.set(H,{...F,default:F.default??X,fallback:z,slot_props:F.slot_props===void 0?J:F.slot_props,description:F.description||L,deprecated:F.deprecated??Y,tags:F.tags||q,source:K||F.source})}else O.slots.set(H,{name:H,default:X,fallback:z,slot_props:$,description:L,deprecated:Y,tags:q,source:K})}var S1=/\s*=\s*/;function LO(O){let Z=O.indexOf("<");if(Z===-1||!O.endsWith(">"))return O;let $=O.slice(0,Z),Q=O.slice(Z+1,-1),W=wO(Q).map((Y)=>Y.trim().replace(S1," = ")).join(", ");return`${$}<${W}>`}var E1=/^\s*$/,b1=/;$/,_1=/^-\s*/;function j0(O){if(O===void 0)return;let Z=O.replace(_1,"").trim();return Z===""?"":Z}function w0(O){if(!O||O.length===0)return;return O[0].tokens.description}var RO=new Set(["since","example"]);function IO(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 k1(O){let Z=O.trim();return Z===""?!0:Z}function AO(O,Z){return k1(`${O??""}${Z?` ${Z}`:""}`)}function T1(O){let Z=O.trim().replace(b1,"").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 N1(O){let Z=O;if(!Z.startsWith("/*"))Z=`/*${Z}`;if(!Z.endsWith("*/"))Z+="*/";return Z}function n0(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,q,K,X=[],H=[];for(let z of Z)if(z.tag==="type")Q=z;else if(z.tag==="param")W.push(z);else if(z.tag==="returns"||z.tag==="return")Y=z;else if(z.tag==="deprecated")K??=AO(z.name,z.description);else if(RO.has(z.tag))H.push(z);else if(z.tag==="bindable"){if(z.type)continue;let J=`${z.name}${z.description?` ${z.description}`:""}`.trim();if(J==="readonly"||J==="writable")q??=J}else if(!$.has(z.tag))X.push(z);return{type:Q,param:W,returns:Y,binding:q,deprecated:K,additional:X,passthrough:H,description:O[0]?.description}}function v1(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 g1(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(E1.test(Y))return W}return}function z0(O,Z,$){if(!$?.leadingComments)return;let Q=g1(O,$.leadingComments,$.start);if(!Q)return;return y1(Z,[Q])}function FO(O,Z,$){if(!$?.leadingComments)return;return z0(O,Z,$)}function y1(O,Z){if(!Z)return;let $=v1(Z);if(!$)return;let Q=V0(N1($.value),{spacing:"preserve"}),{type:W,param:Y,returns:q,binding:K,deprecated:X,additional:H,passthrough:z,description:J}=n0(Q),L,F,k,u;if(W)L=O.aliasType(W.type);if(Y.length>0)F=Y.filter((f)=>!f.name.includes(".")).map((f)=>({name:f.name,type:O.aliasType(f.type),description:j0(f.description),optional:f.optional||!1}));if(q)k=O.aliasType(q.type);let m=n(J?.trim());if(m||H.length>0){let f=[];if(m)f.push(m);for(let i of H){let e=`@${i.tag}${i.name?` ${i.name}`:""}${i.description?` ${i.description}`:""}`;f.push(e)}u=f.join(`
|
|
10
|
-
`)}let O0=z.length>0?z.map((f)=>({name:f.tag,body:IO(f.source)})):void 0;return{type:L,params:F,returnType:k,description:u,binding:K,deprecated:X,tags:O0}}function CO(O,Z,$=O.source){if(!$)return;let Q=0;for(let{tags:W,description:Y,source:q}of V0($,{spacing:"preserve"})){let K=q.map((B)=>B.source).join(`
|
|
11
|
-
`),X=$.indexOf(K,Q),H=X===-1?void 0:X;if(X!==-1)Q=X+K.length;let z,J,L,F,k,u,m=[],O0=[],f,i,e,W0=[],p,G,j=[],V,I=!1,U=!0,M=[],D,S=new Map,C=new Set,T=new Set;for(let B of W)if(B.source&&B.source.length>0)C.add(B.source[0].number);for(let B of q)if(!B.tokens.tag&&B.tokens.description&&B.tokens.description.trim()!=="}")S.set(B.number,B.tokens.description);let E=(B)=>{if(!B||B.length===0)return;let _=B[0].number,R=[],N=[],l=!1;for(let A=_-1;A>=1;A--){if(C.has(A))break;let P=S.get(A);if(P)R.unshift(P),N.unshift(A),l=!0;else if(l){let w=q.find((h)=>h.number===A);if(!(!w||!w.tokens.tag&&(!w.tokens.description||w.tokens.description.trim()==="")))break}}if(R.length===0)return;for(let A of N)T.add(A);return R.join(`
|
|
12
|
-
`).trim()},y=()=>{if(z!==void 0){let B=J&&J!=="object"&&J!=="Object"?J:void 0,_;if(B)_=B;else if(O0.length>0)_=u0(O0,z,!0);else _=J||"";if(u!==void 0){let R;for(let A of W){let P=A.source?.[0]?.number;if(typeof P!=="number")continue;if(P<=u)continue;if(A.tag==="property"||A.tag==="type")continue;R=P;break}let N=[],l=Array.from(S.keys()).sort((A,P)=>A-P);for(let A of l){if(A<=u)continue;if(R!==void 0&&A>=R)continue;if(T.has(A))continue;let w=S.get(A)?.trim();if(w)N.push(w),T.add(A)}if(N.length>0){let A=N.join(`
|
|
13
|
-
`);L=L?`${L}
|
|
14
|
-
${A}`:A}}B0(O,{name:z,detail:_,has_argument:!1,description:L,deprecated:F,tags:m.length>0?m:void 0,source:k}),O.eventDescriptions.set(z,L),O.jsDocEventNames.add(z),O.jsDocEventSources.set(z,k),O0.length=0,z=void 0,J=void 0,L=void 0,F=void 0,k=void 0,u=void 0,m=[]}},a=()=>{if(f!==void 0){let B,_;if(W0.length>0)B=u0(W0,void 0,!0),_=`type ${f} = ${B};`;else if(i)B=i,_=T1(B)?`interface ${f} ${B}`:`type ${f} = ${B};`;else B="{}",_=`type ${f} = ${B};`;O.typedefs.set(f,{type:B,name:f,description:n(e),ts:_}),W0.length=0,f=void 0,i=void 0,e=void 0}},Z0=()=>{if(p!==void 0){let R=`(${j.map(({name:l,type:A,optional:P})=>{return`${l}${P?"?":""}: ${A}`}).join(", ")}) => ${V||"void"}`,N=`type ${p} = ${R};`;O.typedefs.set(p,{type:R,name:p,description:n(G),ts:N}),j.length=0,V=void 0,p=void 0,G=void 0}},b=W.some((B)=>B.tag==="slot"||B.tag==="snippet"),r=W.some((B)=>B.tag==="extends"||B.tag==="extendProps");for(let{tag:B,type:_,name:R,description:N,optional:l,default:A,source:P}of W){let w=Z.aliasType(_),s=E(P);switch(B){case"extends":case"extendProps":if(O.extends={interface:R,import:w},U)U=!1;break;case"restProps":{let h=R?N?`${R} ${N}`:R:N,Y0=j0(h)||s;if(!Y0&&U&&!I&&Y)Y0=Y,I=!0;if(O.rest_props={type:"Element",name:w,description:Y0||void 0},U)U=!1;break}case"slot":case"snippet":{let o=j0(w0(P));if(!o&&U&&!I&&Y)o=Y,I=!0;if(!o&&M.length===0)o=s;if(U)U=!1;L0(O,{slot_name:R,slot_props:w,slot_description:o||void 0,slot_deprecated:D,slot_tags:M.length>0?[...M]:void 0,source:r0(O,q,P,H)}),M.length=0,D=void 0;break}case"event":{if(y(),z=R,J=w,u=P&&P.length>0?P[0].number:void 0,L=j0(w0(P))||s,!L&&U&&!I&&Y)L=Y,I=!0;if(k=r0(O,q,P,H),U)U=!1;break}case"type":if(z!==void 0)J=w;break;case"param":if(p!==void 0)j.push({name:R,type:w,optional:l||!1});break;case"returns":case"return":if(p!==void 0)V=w;break;case"property":{let h={name:R,type:w,description:j0(w0(P)),optional:l||!1,default:A};if(z!==void 0)O0.push(h);else if(f!==void 0)W0.push(h);break}case"typedef":{if(a(),f=LO(R),i=w,e=j0(w0(P))||s,!e&&U&&!I&&Y)e=Y,I=!0;if(U)U=!1;break}case"callback":{if(Z0(),p=LO(R),G=j0(w0(P))||s,!G&&U&&!I&&Y)G=Y,I=!0;if(U)U=!1;break}case"generics":if(O.generics=[R,w],U)U=!1;break;case"template":{let h=R;if(w)h=`${R} extends ${w}`;if(A)h+=` = ${A}`;if(b&&!r){O.deferredSlotBlockGenerics.push({name:R,constraint:h});break}if(Z.accumulateGeneric(R,h),U)U=!1;break}case"deprecated":{let h=AO(R,N);if(z===void 0)D??=h;else F??=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:B,body:IO(P)};if(z!==void 0&&RO.has(B))m.push(h);else M.push(h)}break}}y(),a(),Z0()}}function x1({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 R0(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=x1({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}),q=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:q}}function u1(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 PO(O,Z){if(O.rest_props!==void 0)return;let $=u1(Z);if($)O.rest_props=$}function d(O,Z,$){if(!Z||O.has(Z))return;O.set(Z,$)}function S0(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=S0(O,Q);if(W)O.reactive_vars.add(W)}}function E0(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 fO(O){if(!O||typeof O!=="object"||!("type"in O))return!1;let Z=String(O.type);return Z==="FunctionDeclaration"||Z==="FunctionExpression"||Z==="ArrowFunctionExpression"}function m1(O,Z){let $=O.scopeDeclarations.get(Z);if(!$)$=new Map,O.scopeDeclarations.set(Z,$);return $}function l1(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 q;if(W.value.type==="Identifier")q=W.value.name;else if(W.value.type==="AssignmentPattern"&&W.value.left.type==="Identifier")q=W.value.left.name;if(!q)continue;Q.push({kind:"prop",name:q,publicPropName:Y})}return Q}function t0(O,Z,$,Q,W){if(!hO(Z))return;let Y=W?.allowRunesProps??!1,q=W?.forceProp??!1,K=Z;for(let X of K.declarations){if(Y&&$0(J0(X.init),"$props")){for(let J of l1(O,K,X))d(J.kind==="prop"?$:Q,J.name,J.kind==="prop"?{kind:"prop",publicPropName:J.publicPropName}:{kind:"local"});continue}let H=K.kind==="var"?Q:$,z=q?"prop":"local";for(let J of g(X.id))d(H,J,z==="prop"?{kind:"prop",publicPropName:J}:{kind:"local"})}}function d1(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 c1(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 i1(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 DO(O,Z){Z.componentScope.clear(),Z.scopeDeclarations=new WeakMap,Z.activeScopes.length=0,i1(O,Z,Z.parsed?.instance)}function SO(O){return{varScopeStack:[O.componentScope]}}function EO(O,Z,$,Q){if(!E0(Q))return;let W=m1(Z,Q),Y=$.varScopeStack[$.varScopeStack.length-1]??Z.componentScope;switch(String(Q.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":d1(Q,W);break;case"BlockStatement":c1(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 X of g(K.context))d(W,X,{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(fO(Q))$.varScopeStack.push(W)}function bO(O,Z){if(fO(Z))O.varScopeStack.pop()}var s1=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]);function p1(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 o1(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":b0(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 b0(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)b0([Q],Z);break}}}}function OO(O,Z){if(!O||typeof O!=="object")return!1;let $=[...Z],Q=!1;return X0(O,{enter(W,Y){if(Q){this.skip();return}if(E0(W))$.push(a1(W));if(Y&&W.type==="Identifier"&&s1.has(W.name)&&!Y.type.startsWith("TS")&&p1(W,Y)&&!o1(W.name,$))Q=!0,this.skip()},leave(W){if(E0(W))$.pop()}}),Q}function _O(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 kO(O){if(O.runesOptionOverride!==void 0)return O.runesOptionOverride?"runes":"legacy";let Z=O.parsed;if(!Z)return"legacy";let $=new Set;b0(_O(Z.module),$);let Q=new Set;return b0(_O(Z.instance),Q),OO(Z.module,[$])||OO(Z.instance,[$,Q])||OO(Z.html,[$,Q])?"runes":"legacy"}var r1=/[A-Za-z_$][\w$]*/g;function n1(O,Z,$){let Q=new Map,W=Z.typeParameters?.params,Y=$.typeArguments?.params;if(!W?.length||!Y?.length)return Q;for(let q=0;q<W.length;q++){let K=W[q]?.name,X=Y[q];if(!K||X?.start===void 0||X?.end===void 0)continue;let H=x(O,X.start,X.end)?.trim();if(H)Q.set(K,H)}return Q}function t1(O,Z){if(Z.size===0)return O;return O.replace(r1,($)=>Z.get($)??$)}function I0(O,Z,$,Q,W=new Set){let Y=new Map;if(!$?.type)return Y;let q=(K)=>{for(let X of K){if(X?.type!=="TSPropertySignature"||X.computed)continue;if(!X.key)continue;let H=O.getPropertyName(X.key);if(!H)continue;let z=X.typeAnnotation?.start,J=X.typeAnnotation?.end;if(z===void 0||J===void 0)continue;let L=x(Z,z+1,J)?.trim();if(!L)continue;Y.set(H,{type:L,optional:X.optional===!0,source:v(Z,X)})}};switch($.type){case"TSTypeLiteral":q($.members??[]);break;case"TSInterfaceDeclaration":q($.body?.body??[]);break;case"TSTypeAliasDeclaration":{let K=I0(O,Z,$.typeAnnotation,Q,W);for(let[X,H]of K)Y.set(X,H);break}case"TSTypeReference":{let K=gO($.typeName);if(!K||W.has(K))break;let X=Q.get(K);if(!X)break;W.add(K);let H=I0(O,Z,X,Q,W);W.delete(K);let z=n1(Z,X,$);for(let[J,L]of H)Y.set(J,z.size===0?L:{...L,type:t1(L.type,z)});break}case"TSIntersectionType":for(let K of $.types??[]){let X=I0(O,Z,K,Q,W);for(let[H,z]of X)Y.set(H,z)}break;case"TSParenthesizedType":{let K=I0(O,Z,$.typeAnnotation,Q,W);for(let[X,H]of K)Y.set(X,H);break}}return Y}function mO(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 Q=$;Z.scriptLanguage=O.resolveScriptLanguage(Q),Z.customElementTag=Q.options?.customElement?.tag,Z.runesOptionOverride=Q.options?.runes,Z.scriptGenericsAttribute=O.resolveScriptGenericsAttribute(Q);let W=Q.instance?.content?.body??[];for(let Y of W){if(!Y?.type)continue;if(Y.type==="ImportDeclaration"&&Y.source?.value)for(let q of Y.specifiers??[]){let K=q.local?.name;if(!K)continue;if(!(Y.importKind==="type"||q.importKind==="type"))continue;let H,z;if(q.type==="ImportSpecifier")H="named",z=q.imported?.type==="Identifier"?q.imported.name:typeof q.imported?.value==="string"?q.imported.value:void 0;else if(q.type==="ImportDefaultSpecifier")H="default";else if(q.type==="ImportNamespaceSpecifier")H="namespace";if(!H)continue;Z.typeImportBindingsByLocalName.set(K,{importedName:z,localName:K,source:String(Y.source.value),specifierType:H})}if((Y.type==="TSInterfaceDeclaration"||Y.type==="TSTypeAliasDeclaration")&&Y.id?.name&&Y.start!==void 0&&Y.end!==void 0)Z.localTypeDeclarationsByName.set(Y.id.name,{code:x(Z,Y.start,Y.end)?.trim()??"",node:Y,start:Y.start});if(Y.type==="ExportNamedDeclaration"&&Y.declaration?.type==="VariableDeclaration")for(let q of Y.declaration.declarations??[]){if(q.id?.type!=="Identifier"||!q.id.name)continue;let K=_0(Z,q.id.typeAnnotation);if(K)Z.explicitPropTypesByName.set(q.id.name,K)}else if(Y.type==="VariableDeclaration")for(let q of Y.declarations??[]){if(q.id?.type!=="Identifier"||!q.id.name)continue;let K=_0(Z,q.id.typeAnnotation);if(K)Z.explicitVariableTypesByName.set(q.id.name,K)}}for(let Y of W){if(!Y||typeof Y!=="object"||!("declarations"in Y))continue;for(let q of Y.declarations??[]){if(!$0(J0(q.init),"$props"))continue;let K=q.id?.typeAnnotation?void 0:TO(q.init),X=q.id?.typeAnnotation?.typeAnnotation??K,H=q.id?.typeAnnotation?_0(Z,q.id.typeAnnotation):yO(Z,K),z=I0(O,Z,X,new Map(Array.from(Z.localTypeDeclarationsByName.entries(),([F,k])=>[F,k.node]))),J=new Set,L=new Set;if(xO(Z,X,J,L),uO(Z,J,L),q.start!==void 0){let F={canonicalType:H,props:z,referencedImportedTypes:J,referencedLocalTypes:L};if(Z.runesPropsDeclarationMetadataByDeclaratorStart.set(q.start,F),H)Z.typedRunesPropsDeclarations.push(F)}}}}function lO(O,Z,$){for(let Q of $.declarations){if(!$0(J0(Q.init),"$props"))continue;if(Q.id.type==="Identifier"){Z.wholePropsLocals.add(Q.id.name),Z.restPropLocals.add(Q.id.name);let q=NO(Z,Q.start);if(q)for(let[K,X]of q.props)M0(O,Z,K,{name:K,kind:"let",type:X.type,typeSource:"typescript",isFunction:!1,isFunctionDeclaration:!1,isRequired:!X.optional,constant:!1,reactive:!1,source:X.source});continue}if(Q.id.type!=="ObjectPattern")continue;let W=z0(Z,O,$),Y=Q.id.properties.filter((q)=>{if(q.type!=="Property"||q.computed)return!1;if(!O.getPropertyName(q.key))return!1;if(q.value.type==="Identifier")return!0;return q.value.type==="AssignmentPattern"&&q.value.left.type==="Identifier"}).length;for(let q of Q.id.properties){if(q.type==="RestElement"){if(q.argument.type==="Identifier")Z.restPropLocals.add(q.argument.name);continue}let K=O.getPropertyName(q.key);if(!K)continue;let X,H;if(q.value.type==="Identifier")X=q.value.name;else{let I=q.value;X=I.left.name,H=I.right}if(!X)continue;if(O.trackPropLocalName(K,X),K==="children")Z.snippetPropLocals.add(X);let z=FO(Z,O,q)??(Y===1?W:void 0),J=vO(Z,Q.start,K),{init:L,bindable:F}=KO(H),k=L==null?{isFunction:!1}:H0(O,Z,L),{value:u,type:m,isFunction:O0,defaultValue:f}=k,i=J?.type===void 0&&z?.type===void 0?k.resolvedType:void 0,{type:e,typeSource:W0,description:p,params:G,returnType:j,isFunction:V}=R0({explicitType:J?.type,typeSeed:m,inferredTypeForSource:m,jsdocType:z?.type,jsdocDescription:z?.description,jsdocParams:z?.params,jsdocReturnType:z?.returnType,resolvedType:i,resolvedDescription:k.resolvedDescription,resolvedParams:k.resolvedParams,resolvedReturnType:k.resolvedReturnType,initializerIsFunction:O0,isFunctionDeclaration:!1,inferIsFunctionFromTypeSignature:!0});if(F)Z.reactive_vars.add(K);M0(O,Z,K,{name:K,...X===K?{}:{localName:X},kind:"let",description:p,binding:z?.binding,deprecated:z?.deprecated,tags:z?.tags,...F?{bindable:!0}:{},type:e,typeSource:W0,value:u,defaultValue:f,params:G,returnType:j,isFunction:V,isFunctionDeclaration:!1,isRequired:L==null&&J?.optional!==!0,constant:!1,reactive:F,source:v(Z,q)})}}}function dO(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 q=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:q?Y.type:K,typeSource:q?Y.typeSource:"inferred",isFunction:!0}),O.events.delete($)}}var cO=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function k0(O){if(!O||typeof O!=="object")return;X0(O,{enter(Z){if(!cO.has(Z.type))return;let $=Z.expression;while($&&cO.has($.type))$=$.expression;if($)this.replace($)}})}var e1=/^\s*$/;function sO(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 pO(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==="'"){$=sO(O,$,W);continue}else if(W==="`"){$=pO(O,$);continue}$++}return $}function O2(O,Z){let $=[],Q=O.length,W=0;while(W<Q){let Y=O[W];if(Y==='"'||Y==="'"){W=sO(O,W,Y);continue}if(Y==="`"){W=pO(O,W);continue}if(Y==="/"&&O[W+1]==="/"){let q=W+2;while(q<Q&&O[q]!==`
|
|
15
|
-
`)q++;W=q;continue}if(Y==="/"&&O[W+1]==="*"){let q=W,K=W+2;while(K<Q&&!(O[K]==="*"&&O[K+1]==="/"))K++;let X=Math.min(K+2,Q),H=O.slice(q,X);$.push({end:X+Z,isJsDoc:H.startsWith("/**")&&H.length>4,text:H}),W=X;continue}W++}return $}function iO(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 Z2(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)iO(Q.declaration,Q.start,Z);else iO(Q,Q.start,Z)}return Z}function $2(O,Z,$){let Q;for(let W of O){if(W.end>Z)break;if(!W.isJsDoc)continue;if(!e1.test($.slice(W.end,Z)))continue;Q=W}return Q}function oO(O,Z){let $=new Map;if(!O.source)return $;let Q=[O.parsed?.module,O.parsed?.instance],W=[],Y=[];for(let q of Q){let K=q?.content;if(!K?.body||K.start===void 0||K.end===void 0)continue;W.push(...O2(O.source.slice(K.start,K.end),K.start)),Y.push(...Z2(K.body))}W.sort((q,K)=>q.end-K.end);for(let q of Y){let K=$2(W,q.start,O.source);if(!K)continue;let X=V0(K.text,{spacing:"preserve"}),{type:H,description:z}=n0(X);if(!H)continue;$.set(q.name,{type:Z.aliasType(H.type),description:z||H.description})}return $}function aO(O){if(O==="var")return"let";if(O==="using"||O==="await using")return"const";return O}var Q2=null,rO=/^@component/,W2=/\r/g,Y2=/^\{\s*\}$/;class c{ctx=N0();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((q)=>q.name==="lang");if(!W){$=!0;continue}if(c.getStaticAttributeValue(W)?.toLowerCase()==="ts")return"ts"}return $?"js":void 0}resolveScriptGenericsAttribute(O){let Z=O.instance?.attributes?.find((q)=>q.name==="generics");if(!Z)return;let $=v(this.ctx,Z),Q=O.instance?.attributes?.find((q)=>q.name==="lang");if((Q?c.getStaticAttributeValue(Q)?.toLowerCase():void 0)!=="ts"){K0(this.ctx,"syntax-skipped","generics",'<script generics="..."> requires lang="ts"; the generics attribute was ignored because the script is not TypeScript.',$);return}let Y=c.getStaticAttributeValue(Z);if(!Y)return;return{value:Y,source:$}}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(Q0(O))return O.name;if(U0(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 z0(this.ctx,this,$);let Z=this.ctx.funcDecls.get(O);if(Z)return z0(this.ctx,this,Z);return}addModuleExport(O,Z){if(n(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=oO(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=N0()}static SCRIPT_BLOCK_REGEX=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi;static TS_DIRECTIVE_REGEX=/\/\/\s*@ts-[^\n\r]*/g;static stripTypeScriptDirectivesFromScripts(O){return c.SCRIPT_BLOCK_REGEX.lastIndex=0,O.replace(c.SCRIPT_BLOCK_REGEX,(Z,$,Q,W)=>{c.TS_DIRECTIVE_REGEX.lastIndex=0;let Y=Q.replace(c.TS_DIRECTIVE_REGEX,"");return $+Y+W})}parseSvelteComponent(O,Z){this.cleanup(),this.ctx.componentFilePath=Z.filePath;let $=c.stripTypeScriptDirectivesFromScripts(O);this.ctx.source=$;let{modern:Q,legacy:W}=Z1($);if(mO(this,this.ctx,Q),this.ctx.parsed=W,this.ctx.scriptLanguage==="ts")k0(this.ctx.parsed.module),k0(this.ctx.parsed.instance),k0(this.ctx.parsed.html);this.ctx.syntaxMode=kO(this.ctx);let Y=this.ctx.parsed.css,q=Y?.start!==void 0&&Y?.end!==void 0?$.slice(0,Y.start)+" ".repeat(Y.end-Y.start)+$.slice(Y.end):$;if(CO(this.ctx,this,q),this.ctx.parsed?.module)X0(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 j,V,I=!1,U,M,D,S=!1,C,T,E;if(G.declaration.type==="FunctionDeclaration"){let R=G.declaration;if(!R.id?.name)return;j=R.id.name,V="function",U=void 0,M="() => any",S=!0,I=!0}else if(G.declaration.type==="VariableDeclaration"){let R=G.declaration,N=R.declarations[0];if(!N||typeof N!=="object"||!("id"in N))return;let{id:l,init:A}=N;if(!l||typeof l!=="object"||!("name"in l))return;let P=l.name;j=P,V=aO(R.kind);let w=A==null?{isFunction:!1}:H0(this,this.ctx,A);({value:U,type:M,isFunction:S,defaultValue:C}=w),T=M,E=w,D=this.getExplicitPropType(P)}else return;let y=z0(this.ctx,this,G),{type:a,typeSource:Z0,description:b,params:r,returnType:B,isFunction:_}=R0({explicitType:D,typeSeed:M,inferredTypeForSource:T,jsdocType:y?.type,jsdocDescription:y?.description,jsdocParams:y?.params,jsdocReturnType:y?.returnType,resolvedType:E?.resolvedType,resolvedDescription:E?.resolvedDescription,resolvedParams:E?.resolvedParams,resolvedReturnType:E?.resolvedReturnType,initializerIsFunction:S,isFunctionDeclaration:I,typedefs:this.ctx.typedefs});this.addModuleExport(j,{name:j,kind:V,description:b,deprecated:y?.deprecated,tags:y?.tags,type:a,typeSource:Z0,value:U,defaultValue:C,params:r,returnType:B,isFunction:_,isFunctionDeclaration:I,isRequired:!1,constant:V==="const",reactive:!1,source:v(this.ctx,G)})}}});let K,X=new Set,H=new Set,z=[],J={type:"ComponentRoot",instance:this.ctx.parsed.instance,html:this.ctx.parsed.html};DO(this,this.ctx),this.ctx.activeScopes.push(this.ctx.componentScope);let L=SO(this.ctx);if(X0(J,{enter:(G,j,V)=>{EO(this,this.ctx,L,G);let I=this.ctx.scopeDeclarations.get(G);if(I)this.ctx.activeScopes.push(I);if(G.type==="AssignmentExpression")e0(this.ctx,G.left);if(G.type==="UpdateExpression")e0(this.ctx,G.argument);if(G.type==="CallExpression"){let U=G,M=U.callee&&typeof U.callee==="object"&&"name"in U.callee?U.callee.name:void 0;if(M==="createEventDispatcher"){if(j&&typeof j==="object"&&"id"in j&&j.id&&typeof j.id==="object"&&"name"in j.id)K=j.id.name}if(M==="$host"){if(j&&typeof j==="object"&&"id"in j&&j.id&&typeof j.id==="object"&&"name"in j.id)X.add(j.id.name)}if(M==="setContext")HO(this.ctx,this,G,j??void 0);if(M)z.push({name:M,arguments:U.arguments,source:v(this.ctx,U)});if(nO(U.callee)&&Q0(U.callee.property)&&U.callee.property.name==="dispatchEvent"&&($0(U.callee.object,"$host")||Q0(U.callee.object)&&X.has(U.callee.object.name))){let D=UO(this.ctx,U);if(D)H.add(D)}}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="Spread"){let U=G;if(U.expression?.name==="$$restProps"||this.ctx.restPropLocals.has(U.expression?.name??""))PO(this.ctx,j)}if(G.type==="FunctionDeclaration"){let U=G;if(U.id?.name)this.ctx.funcDecls.set(U.id.name,U)}if(G.type==="VariableDeclaration"){if(this.ctx.vars.add(G),j&&typeof j==="object"&&"type"in j&&j.type==="Program"&&G.declarations.some((U)=>$0(J0(U.init),"$props")))lO(this,this.ctx,G)}if(G.type==="ExportNamedDeclaration"){if(G.declaration==null&&G.specifiers.length===0)return;let U;if(G.declaration==null&&G.specifiers[0]?.type==="ExportSpecifier"){let w=G.specifiers[0],s=w.local&&typeof w.local==="object"&&"name"in w.local?w.local.name:void 0,h=w.exported&&typeof w.exported==="object"&&"name"in w.exported?w.exported.name:void 0;if(!s||!h)return;let o;for(let Y0 of Array.from(this.ctx.vars))if(Y0.declarations.some((q0)=>q0.id&&typeof q0.id==="object"&&("type"in q0.id)&&q0.id.type==="Identifier"&&q0.id.name===s)){o=Y0;break}G.declaration=o,U=h}if(G.declaration==null)return;if(!G.declaration||typeof G.declaration!=="object"||!("type"in G.declaration))return;let M,D=!1,S,C,T,E=!1,y=!1,a,Z0,b,r;if(G.declaration.type==="FunctionDeclaration"){let w=G.declaration;if(!w.id?.name)return;U??=w.id.name,a=w.id.name,M="function",S=void 0,C="() => any",E=!0,D=!0,y=!1}else if(G.declaration.type==="VariableDeclaration"){let w=G.declaration,s=w.declarations[0];if(!s||typeof s!=="object"||!("id"in s))return;let{id:h,init:o}=s;if(h&&typeof h==="object"&&"name"in h){let q0=h.name;a=q0,U??=q0,T=this.getExplicitPropType(q0)}else return;M=aO(w.kind),y=M==="let"&&o==null;let Y0=o==null?{isFunction:!1}:H0(this,this.ctx,o);({value:S,type:C,isFunction:E,defaultValue:Z0}=Y0),b=C,r=Y0}else return;let B=z0(this.ctx,this,G),{type:_,typeSource:R,description:N,params:l,returnType:A,isFunction:P}=R0({explicitType:T,typeSeed:C,inferredTypeForSource:b,jsdocType:B?.type,jsdocDescription:B?.description,jsdocParams:B?.params,jsdocReturnType:B?.returnType,resolvedType:r?.resolvedType,resolvedDescription:r?.resolvedDescription,resolvedParams:r?.resolvedParams,resolvedReturnType:r?.resolvedReturnType,initializerIsFunction:E,isFunctionDeclaration:D,typedefs:this.ctx.typedefs});M0(this,this.ctx,U,{name:U,...a!==void 0&&a!==U?{localName:a}:{},kind:M,description:N,binding:B?.binding,deprecated:B?.deprecated,tags:B?.tags,type:_,typeSource:R,value:S,defaultValue:Z0,params:l,returnType:A,isFunction:P,isFunctionDeclaration:D,isRequired:y,constant:M==="const",reactive:this.ctx.reactive_vars.has(U),source:v(this.ctx,G)})}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="Comment"){let M=G?.data?.trim()??"";if(rO.test(M))this.ctx.componentComment=M.replace(rO,"").replace(W2,""),this.ctx.componentCommentSource=v(this.ctx,G)}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="Slot"){let U=G,M=U.attributes?.find((C)=>C.name==="name")?.value?.[0]?.data,D=(U.attributes||[]).filter((C)=>C.name!=="name").reduce((C,T)=>{let E={value:void 0,replace:!1},y=T.value;if(y===void 0)return C;if(y[0]){let a=y[0],{type:Z0,expression:b,raw:r,start:B,end:_}=a;if(Z0==="Text"&&r!==void 0)E.value=JSON.stringify(r);else if(Z0==="AttributeShorthand"&&b&&typeof b==="object"&&"name"in b)E.value=b.name,E.replace=!0;if(b&&typeof b==="object"&&"type"in b){if(b.type==="Literal"&&"value"in b){let R=b.value;E.value=typeof R==="string"?JSON.stringify(R):String(R)}else if(b.type==="MemberExpression")E.value=F0(this.ctx,this,b);else if(b.type!=="Identifier"){if(B!==void 0&&_!==void 0){if(b.type==="ObjectExpression"||b.type==="TemplateLiteral")E.value=x(this.ctx,B+1,_-1)}}}}if(T.name)C[T.name]=E;return C},{}),S=U.children?.map(({start:C,end:T})=>{if(C===void 0||T===void 0)return"";return x(this.ctx,C,T)??""}).join("").trim();L0(this.ctx,{slot_name:M,slot_props:D,slot_fallback:S,source:v(this.ctx,G)})}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="RenderTag"){let U=G,M=VO(this.ctx,U.expression);if(M){let D;if(M.arguments.length===0)D={};else if(M.arguments.length===1&&typeof M.arguments[0]==="object"&&M.arguments[0]&&"type"in M.arguments[0]&&M.arguments[0].type==="ObjectExpression")D=BO(this.ctx,this,M.arguments[0]);else if(M.arguments.length===1)K0(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 S=M.publicName==="children"?void 0:M.publicName,C=S===void 0?Q2:S;if(D!==void 0)L0(this.ctx,{slot_name:S,slot_props:D,source:v(this.ctx,G)});if(D!==void 0||this.ctx.slots.has(C))this.ctx.snippetPropLocals.add(M.trackingName)}}if(G&&typeof G==="object"&&"type"in G&&String(G.type)==="EventHandler"){let U=G;if(U.expression==null&&U.name){if(j!=null&&typeof j==="object"&&"name"in j){let M=typeof j.name==="string"?j.name:void 0,D="type"in j?String(j.type):void 0;if(M&&D){let S=D==="InlineComponent"?{type:"InlineComponent",name:M}:{type:"Element",name:M};this.ctx.forwardedEvents.set(U.name,S);let C=this.ctx.events.get(U.name),T=this.ctx.eventDescriptions.get(U.name),E=C?.deprecated;if(!C)this.ctx.events.set(U.name,{type:"forwarded",name:U.name,element:S,description:T,deprecated:E,source:v(this.ctx,G)});else if(C.type==="forwarded"&&T&&!C.description)this.ctx.events.set(U.name,{...C,description:T,deprecated:C.deprecated??E,source:C.source||v(this.ctx,G)})}}}}if(j&&typeof j==="object"&&"type"in j&&(String(j.type)==="Element"||String(j.type)==="InlineComponent")&&G&&typeof G==="object"&&"type"in G&&String(G.type)==="Binding"){let U=G;if(U.expression?.name){let M=S0(this.ctx,U.expression.name);if(M)this.ctx.reactive_vars.add(M)}if(String(j.type)==="Element"&&U.name==="this"&&U.expression?.name&&"name"in j&&typeof j.name==="string"){let M=S0(this.ctx,U.expression.name);if(!M)return;let D=j.name;if(this.ctx.bindings.has(M)){let S=this.ctx.bindings.get(M);if(S&&!S.elements.includes(D))this.ctx.bindings.set(M,{...S,elements:[...S.elements,D]})}else this.ctx.bindings.set(M,{elements:[D]})}}},leave:(G)=>{if(this.ctx.scopeDeclarations.has(G))this.ctx.activeScopes.pop();bO(L,G)}}),K!==void 0){for(let G of z)if(G.name===K){let j=G.arguments[0],V=j&&typeof j==="object"&&"value"in j?j.value:void 0,I=G.arguments[1],U=I&&typeof I==="object"&&"value"in I?I.value:void 0;if(V!=null)B0(this.ctx,{name:String(V),detail:U==null?"":x0(U),has_argument:Boolean(I),source:G.source})}}let F=new Set(H);if(K!==void 0){for(let G of z)if(G.name===K){let j=G.arguments[0],V=j&&typeof j==="object"&&"value"in j?j.value:void 0;if(V!=null)F.add(String(V))}}this.ctx.forwardedEvents.forEach((G,j)=>{let V=this.ctx.events.get(j);if(V&&V.type==="dispatched"&&!F.has(j)){let I=this.ctx.eventDescriptions.get(j),U={type:"forwarded",name:j,element:G,description:I,deprecated:V.deprecated,tags:V.tags,source:V.source};if(V.detail!==void 0&&V.detail!=="undefined")U.detail=V.detail;this.ctx.events.set(j,U)}}),dO(this.ctx,F);let k=this.ctx.syntaxMode==="runes"?new Set(Array.from(this.ctx.snippetPropLocals,(G)=>this.resolvePublicPropName(G))):new Set,u=c.mapToArray(this.ctx.props).filter((G)=>!k.has(G.name)).map((G)=>{if(this.ctx.bindings.has(G.name)){let j=this.ctx.bindings.get(G.name)?.elements.sort().map((V)=>WO(V)).join(" | ");return{...G,type:`null | ${j}`,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 m=c.mapToArray(this.ctx.slots).map((G)=>{if(!G.slot_props)return G;if(typeof G.slot_props==="string")return Y2.test(G.slot_props)?{...G,slot_props:"Record<string, never>"}:G;let j=G.slot_props,V=[];for(let U of Object.keys(j)){if(j[U].replace&&j[U].value!==void 0)j[U].value=this.getPropTypeByLocalOrPublic(j[U].value);if(j[U].value===void 0)j[U].value="any";V.push(`${U}: ${j[U].value}`)}let I=V.length===0?"Record<string, never>":V.length===1?`{ ${V[0]} }`:`{
|
|
16
|
-
${V.join(`;
|
|
17
|
-
`)};
|
|
18
|
-
}`;return{...G,slot_props:I}}).sort((G,j)=>{let V=G.name??"",I=j.name??"";if(V<I)return-1;if(V>I)return 1;return 0});if(this.ctx.deferredSlotBlockGenerics.length>0){let G=[...u.map((j)=>j.type??""),...m.map((j)=>j.slot_props??"")].join(`
|
|
19
|
-
`);for(let{name:j,constraint:V}of this.ctx.deferredSlotBlockGenerics){let I=j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!new RegExp(`\\b${I}\\b`).test(G))continue;this.accumulateGeneric(j,V)}}if(this.ctx.scriptGenericsAttribute){if(this.ctx.generics)K0(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 O0=c.mapToArray(this.ctx.moduleExports),f=c.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,j)=>{let V=G.name.localeCompare(j.name);if(V!==0)return V;let I=G.type.localeCompare(j.type);if(I!==0)return I;if(G.type==="forwarded"&&j.type==="forwarded"){let U=G.element.localeCompare(j.element);if(U!==0)return U}return(G.detail??"").localeCompare(j.detail??"")}),i=c.mapToArray(this.ctx.typedefs),e=c.mapToArray(this.ctx.contexts);for(let G of u)if(G.typeSource==="unknown")K0(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(F.has(G))continue;if(this.ctx.forwardedEvents.has(G))continue;if(this.ctx.props.has(`on${G}`))continue;K0(this.ctx,"event-no-source",G,`@event "${G}" has no matching dispatch or callback prop.`,this.ctx.jsDocEventSources.get(G))}let W0={source:tO(this.ctx,0,this.ctx.source?.length),syntaxMode:this.ctx.syntaxMode,...this.ctx.scriptLanguage?{scriptLanguage:this.ctx.scriptLanguage}:{},props:u,moduleExports:O0,slots:m,events:f,typedefs:i,generics:this.ctx.generics,rest_props:this.ctx.rest_props,extends:this.ctx.extends,componentComment:this.ctx.componentComment,componentCommentSource:this.ctx.componentCommentSource,contexts:e,customElementTag:this.ctx.customElementTag,diagnostics:this.ctx.diagnosticRecords.slice()},p=eO(this.ctx);if(p)W0[ZO]=p;return W0}}
|
|
20
|
-
export{c as t};
|
package/lib/chunk-2vwf7nck.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as d}from"./chunk-0fqdg2xa.js";import{E as a,F as b,G as c}from"./chunk-8myyzjb1.js";import"./chunk-as5hgj7e.js";import"./chunk-tmj7vnjr.js";import"./chunk-t9d5k3p7.js";export{b as getParsedComponentTypeScriptMetadata,d as default,c as applyResolvedProps,a as PARSED_COMPONENT_TYPE_SCRIPT_METADATA};
|
package/lib/chunk-m538qnhp.js
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import{E as d0,F as A0,G as J3,T as N0,u as d,x as e2}from"./chunk-8myyzjb1.js";import{$ as j3}from"./chunk-tmj7vnjr.js";import{ba as N,ca as S0,da as v}from"./chunk-xryt7ad2.js";import{ha as r0}from"./chunk-t9d5k3p7.js";var M2="sveld",V0="0.36.0";var D2={name:M2,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","@typescript/typescript6":"^6.0.2",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 A2="5.56.3";var G0=A2;var X0=1,T2=new WeakMap;function C($,Z={}){let Q=T2.get($),Y=Q?.get(Z.entryExports);if(Y)return Y;let j=Array.from($,([,K])=>{let{diagnostics:z,...U}=K;return U}).sort((K,z)=>K.moduleName.localeCompare(z.moduleName)),J={schemaVersion:X0,generator:{name:M2,version:V0,svelteVersion:G0},total:j.length,components:j};if(Z.entryExports&&Z.entryExports.length>0)J.totalExports=Z.entryExports.length,J.exports=Z.entryExports;if(!Q)Q=new Map,T2.set($,Q);return Q.set(Z.entryExports,J),J}import{readFile as n3}from"node:fs/promises";import t3 from"node:path";var b2={none:0,patch:1,minor:2,major:3};function o3($,Z){return b2[Z]>b2[$]?Z:$}function e3($){return $.reduce((Z,Q)=>o3(Z,Q.bump),"none")}function F2($){let Z=[],Q=0,Y="",j=null;for(let J=0;J<$.length;J++){let K=$[J];if(j){if(Y+=K,K==="\\")J++,Y+=$[J]??"";else if(K===j)j=null;continue}if(K==='"'||K==="'"||K==="`"){j=K,Y+=K;continue}if(K==="<"||K==="("||K==="{"||K==="[")Q++;if(K===">"||K===")"||K==="}"||K==="]")Q--;if(K==="|"&&Q===0){Z.push(Y.trim()),Y="";continue}Y+=K}return Z.push(Y.trim()),new Set(Z.filter((J)=>J.length>0))}function u0($,Z){if($===Z)return"none";if($===void 0||Z===void 0)return"major";let Q=F2($),Y=F2(Z),j=[...Y].some((K)=>!Q.has(K)),J=[...Q].some((K)=>!Y.has(K));if(!j&&!J)return"none";if(j&&!J)return"minor";if(J&&!j)return"major";return"major"}function S2($,Z,Q,Y){let j=Z==="prop"?"prop":"export",J=[],K=new Map(Q.map((U)=>[U.name,U])),z=new Map(Y.map((U)=>[U.name,U]));for(let[U,H]of z){if(K.has(U))continue;J.push({component:$,kind:Z,name:U,bump:H.isRequired?"major":"minor",message:`${j} "${U}" added${H.isRequired?" (required)":""}`})}for(let[U]of K){if(z.has(U))continue;J.push({component:$,kind:Z,name:U,bump:"major",message:`${j} "${U}" removed`})}for(let[U,H]of K){let V=z.get(U);if(!V)continue;if(H.isRequired!==V.isRequired)J.push({component:$,kind:Z,name:U,bump:V.isRequired?"major":"minor",message:`${j} "${U}" became ${V.isRequired?"required":"optional"}`});let X=u0(H.type,V.type);if(X!=="none")J.push({component:$,kind:Z,name:U,bump:X,message:`${j} "${U}" type changed from \`${H.type??"unknown"}\` to \`${V.type??"unknown"}\``})}return J}function $1($,Z,Q){let Y=[],j=new Map(Z.map((K)=>[K.name,K])),J=new Map(Q.map((K)=>[K.name,K]));for(let[K]of J){if(j.has(K))continue;Y.push({component:$,kind:"event",name:K,bump:"minor",message:`event "${K}" added`})}for(let[K]of j){if(J.has(K))continue;Y.push({component:$,kind:"event",name:K,bump:"major",message:`event "${K}" removed`})}for(let[K,z]of j){let U=J.get(K);if(!U)continue;if(z.type!==U.type){Y.push({component:$,kind:"event",name:K,bump:"major",message:`event "${K}" changed from ${z.type} to ${U.type}`});continue}let H=z.type==="dispatched"?z.detail:void 0,V=U.type==="dispatched"?U.detail:void 0,X=u0(H,V);if(X!=="none")Y.push({component:$,kind:"event",name:K,bump:X,message:`event "${K}" detail changed from \`${H??"unknown"}\` to \`${V??"unknown"}\``})}return Y}function N2($){return $.name??"default"}function Z1($,Z,Q){let Y=[],j=new Map(Z.map((K)=>[N2(K),K])),J=new Map(Q.map((K)=>[N2(K),K]));for(let[K]of J){if(j.has(K))continue;Y.push({component:$,kind:"slot",name:K,bump:"minor",message:`slot "${K}" added`})}for(let[K]of j){if(J.has(K))continue;Y.push({component:$,kind:"slot",name:K,bump:"major",message:`slot "${K}" removed`})}for(let[K,z]of j){let U=J.get(K);if(!U)continue;let H=u0(z.slot_props,U.slot_props);if(H!=="none")Y.push({component:$,kind:"slot",name:K,bump:H,message:`slot "${K}" props changed from \`${z.slot_props??"none"}\` to \`${U.slot_props??"none"}\``})}return Y}var Q1=new Set(["description","source","componentCommentSource","tags"]);function q0($){if(Array.isArray($))return $.map(q0);if($!==null&&typeof $==="object"){let Z={};for(let[Q,Y]of Object.entries($)){if(Q1.has(Q))continue;Z[Q]=q0(Y)}return Z}return $}var Y1=["generics","rest_props","extends","contexts","typedefs"];function j1($,Z,Q){let Y=[];for(let j of Y1){let J=JSON.stringify(q0(Z[j])),K=JSON.stringify(q0(Q[j]));if(J!==K)Y.push({component:$,kind:"shape",name:j,bump:"major",message:`"${j}" changed (breaking)`})}return Y}function J1($,Z){let Q=Z.moduleName;return[...S2(Q,"prop",$.props,Z.props),...S2(Q,"moduleExport",$.moduleExports,Z.moduleExports),...$1(Q,$.events,Z.events),...Z1(Q,$.slots,Z.slots),...j1(Q,$,Z)]}function K1($,Z){let Q=[],Y=new Map($.components.map((J)=>[J.moduleName,J])),j=new Map(Z.components.map((J)=>[J.moduleName,J]));for(let[J]of j){if(Y.has(J))continue;Q.push({component:J,kind:"component",bump:"minor",message:`component "${J}" added`})}for(let[J]of Y){if(j.has(J))continue;Q.push({component:J,kind:"component",bump:"major",message:`component "${J}" removed`})}for(let[J,K]of Y){let z=j.get(J);if(!z)continue;Q.push(...J1(K,z))}return Q}async function H1($){let Z;try{Z=await n3(t3.resolve($),"utf-8")}catch(Q){if(Q.code==="ENOENT")return null;throw Q}try{return JSON.parse(Z)}catch{throw Error(`sveld: could not parse "${$}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function _2($){if(typeof $.check==="string")return $.check;return $.jsonOptions?.outFile??"COMPONENT_API.json"}async function w2($,Z,Q={}){let Y=await H1(Z);if(Y===null)return{snapshotExists:!1,snapshotFile:Z,changes:[],bump:"none"};if(Y.schemaVersion!==X0)return{snapshotExists:!0,snapshotFile:Z,changes:[{component:"*",kind:"shape",bump:"none",message:`snapshot schemaVersion ${Y.schemaVersion} does not match the current schemaVersion ${X0}; skipping diff`}],bump:"none"};let j=C($,{entryExports:Q.entryExports}),J=K1(Y,j);return{snapshotExists:!0,snapshotFile:Z,changes:J,bump:e3(J)}}var z1={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function x2($){if(!$.snapshotExists)return`sveld --check: no snapshot found at "${$.snapshotFile}". Run \`sveld --json\` and commit the output first.`;if($.changes.length===0)return`sveld --check: no API changes detected against "${$.snapshotFile}".`;let Z=[],Q=$.changes.length;Z.push(`sveld --check: ${Q} API change${Q===1?"":"s"} detected against "${$.snapshotFile}".`),Z.push(`Suggested semver bump: ${$.bump}.`);let Y=new Map;for(let j of $.changes){let J=Y.get(j.component)??[];J.push(j),Y.set(j.component,J)}for(let[j,J]of Y){Z.push(""),Z.push(` ${j}`);for(let K of J)Z.push(` [${z1[K.bump]}] ${K.message}`)}return Z.join(`
|
|
2
|
-
`)}function C2($){let Z={kind:"check-report",...$};return v(Z)}import{existsSync as U1}from"node:fs";import{join as V1}from"node:path";import{pathToFileURL as G1}from"node:url";var X1=["sveld.config.js","sveld.config.mjs","sveld.config.ts"];function X4($){return $}function q1($=process.cwd()){for(let Z of X1){let Q=V1($,Z);if(U1(Q))return Q}return null}async function W1($){let Z;try{Z=await import(`${G1($).href}?t=${Date.now()}`)}catch(Y){let j=Y instanceof Error?Y.message:String(Y);throw Error(`sveld: failed to load config file "${$}".
|
|
3
|
-
${j}`)}let Q=Z.default;if(!d(Q)||Array.isArray(Q))throw Error(`sveld: config file "${$}" must export a configuration object as its default export. Did you forget \`export default defineConfig({ ... })\`?`);return Q}async function y2($=process.cwd()){let Z=q1($);if(Z===null)return{};return W1(Z)}function P2(...$){return Object.assign({},...$.filter(Boolean))}var m0=new Map;function s($){m0.set($.name,$)}function c0($){return m0.get($)}function W4(){return Array.from(m0.values())}import{dirname as c3}from"node:path";import{lstatSync as K3,readdirSync as Y5,readFileSync as j5,realpathSync as J5,statSync as K5}from"node:fs";import{readFile as H5}from"node:fs/promises";import{dirname as z5,isAbsolute as U5,join as V5,parse as o0,relative as G5,resolve as Z0}from"node:path";function n($){return $}function f($){if($==="")return $;return $.startsWith(".")?$:`./${$}`}import{dirname as k1,resolve as B1}from"node:path";var L1=/\.svelte$/,O1=/^(['"])(.*)\1$/;function R1($,Z){let Q=$.extends?.import;if(Q===void 0)return null;let Y=Q.replace(O1,"$2");if(!L1.test(Y))return null;return B1(k1(Z),Y)}function t($,Z){let Q=new Map;for(let Y of $.values()){let j=Z(Y.filePath),J=R1(Y,j);if(J===null)continue;let K=Q.get(J);if(K===void 0)K=new Set,Q.set(J,K);K.add(j)}return Q}function W0($,Z){let Q=new Set,Y=[];for(let j of $)if(!Q.has(j))Q.add(j),Y.push(j);while(Y.length>0){let j=Y.shift(),J=Z.get(j);if(J===void 0)continue;for(let K of J)if(!Q.has(K))Q.add(K),Y.push(K)}return Q}var I1={"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"},M1=["prop-unknown-type","context-any-type","event-no-source","example-compile-error","syntax-skipped"];function k0($){let Z=new Set,Q=[];for(let Y of $){let j=`${Y.component}:${Y.kind}:${Y.name}`;if(Z.has(j))continue;Z.add(j),Q.push(Y)}return Q}function g2($){if($.length===0)return"sveld: all types resolved.";let Z=[],Q=$.length;Z.push(`sveld: ${Q} unresolved type${Q===1?"":"s"} found.`);for(let Y of M1){let j=$.filter((K)=>K.kind===Y);if(j.length===0)continue;Z.push(""),Z.push(`${I1[Y]} (${j.length}):`);let J=new Map;for(let K of j){let z=J.get(K.component)??[];z.push(K),J.set(K.component,z)}for(let[K,z]of J){Z.push(` ${K}`);for(let U of z){let H=U.source?` (${K}:${U.source.start.line}:${U.source.start.column})`:"";Z.push(` - ${U.message}${H}`)}}}return Z.join(`
|
|
4
|
-
`)}function E2($){return v({kind:"diagnostics",diagnostics:$})}var D1=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,A1=new Set(["","js","jsx","ts","tsx","javascript","typescript"]);function T1($){let Z=$.trim();if(Z==="")return null;let Q=Z.match(D1);if(Q){let Y=Q[1].toLowerCase();if(!A1.has(Y))return null;let j=Q[2].trim();return j===""?null:j}if(Z.startsWith("<"))return null;return Z}function v2($){if(!$.isFunction)return"any";return`(${($.params??[]).map((Q)=>`${Q.name}${Q.optional?"?":""}: any`).join(", ")}) => any`}function B0($,Z,Q,Y,j){let J=($??[]).filter((z)=>z.name==="example"),K=[];return J.forEach((z,U)=>{let H=T1(z.body);if(H===null)return;let V=J.length>1;K.push({id:V?`${Z}#${U}`:Z,name:V?`${Q} (example ${U+1})`:Q,type:Y,code:H,...j?{source:j}:{}})}),K}function f2($){return $.name??"default"}function h2($){let Z=[];for(let Q of $.props)Z.push(...B0(Q.tags,`prop:${Q.name}`,Q.name,v2(Q),Q.source));for(let Q of $.moduleExports)Z.push(...B0(Q.tags,`export:${Q.name}`,Q.name,v2(Q),Q.source));for(let Q of $.slots)Z.push(...B0(Q.tags,`slot:${f2(Q)}`,f2(Q),"any",Q.source));for(let Q of $.events)Z.push(...B0(Q.tags,`event:${Q.name}`,Q.name,"any",Q.source));return Z}import{createHash as b1}from"node:crypto";import{mkdirSync as F1,readFileSync as S1,writeFileSync as N1}from"node:fs";import{dirname as _1,isAbsolute as w1,join as x1,resolve as u2}from"node:path";var l0=1,C1=x1("node_modules",".cache","sveld","parse-cache.json");function i0(){return`${V0}+svelte@${G0}`}function c2($,Z){if(typeof Z==="string")return w1(Z)?Z:u2($,Z);return u2($,C1)}function d2($){return b1("sha256").update($).digest("hex")}function m2(){return{formatVersion:l0,toolchainVersion:i0(),entries:{}}}function y1($){try{let Z=S1($,"utf-8"),Q=JSON.parse(Z);if(Q.formatVersion!==l0||Q.toolchainVersion!==i0())return m2();return Q}catch{return m2()}}class p0{cacheFilePath;file;next=new Map;blocked=new Set;constructor($){this.cacheFilePath=$,this.file=y1($)}has($,Z){if(this.blocked.has($))return!1;let Q=this.file.entries[$];return Q!==void 0&&Q.hash===Z}get($,Z){if(this.blocked.has($))return null;let Q=this.file.entries[$];if(Q===void 0||Q.hash!==Z)return null;if(this.next.set($,Q),Q.typeScriptMetadata!==void 0)Q.parsed[d0]=Q.typeScriptMetadata;return Q.parsed}set($,Z,Q){this.next.set($,{hash:Z,parsed:Q,typeScriptMetadata:Q[d0]})}invalidate($){this.blocked.add($)}save(){F1(_1(this.cacheFilePath),{recursive:!0});let $={formatVersion:l0,toolchainVersion:i0(),entries:Object.fromEntries(this.next)};N1(this.cacheFilePath,JSON.stringify($))}}import{existsSync as I0,lstatSync as s2,readFileSync as m1}from"node:fs";import{dirname as $3,join as c1,relative as d1,resolve as Z3}from"node:path";var i=null,a0=null;function p(){if(i)return Promise.resolve(i);if(!a0)a0=Promise.all([import("./chunk-2vwf7nck.js"),import("./chunk-r4rrncmd.js")]).then(([$,Z])=>{return i={ComponentParser:$.default,parseSvelte:Z.parse},i});return a0}function L0(){if(!i)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return i}import{existsSync as a2,readFileSync as P1}from"node:fs";import{dirname as s0,isAbsolute as g1,join as E1,relative as v1,resolve as R0}from"node:path";function l2($){if(!d($))return{};let Z=$.svelte;return typeof Z==="string"?{svelte:Z}:{}}function i2($){if(!d($))return{};let Z={};if(typeof $.extends==="string")Z.extends=$.extends;if(d($.compilerOptions)){let Q={};if(typeof $.compilerOptions.baseUrl==="string")Q.baseUrl=$.compilerOptions.baseUrl;if(d($.compilerOptions.paths)){let Y={};for(let[j,J]of Object.entries($.compilerOptions.paths))if(Array.isArray(J)&&J.every((K)=>typeof K==="string"))Y[j]=J;if(Object.keys(Y).length>0)Q.paths=Y}if(Object.keys(Q).length>0)Z.compilerOptions=Q}return Z}var O0=new Map,p2=new Map,f1=/\/\*[\s\S]*?\*\/|\/\/.*/g,h1=/[.+?^${}()|[\]\\]/g;function u1($){let Z=$,Q=R0(Z,"/");while(Z!==Q){for(let Y of["tsconfig.json","jsconfig.json"]){let j=E1(Z,Y);if(a2(j))return j}Z=s0(Z)}return null}function r2($){if(O0.has($))return O0.get($)??null;try{let Z=P1($,"utf-8"),Q;try{Q=JSON.parse(Z)}catch{let j=Z.replace(f1,"");Q=JSON.parse(j)}let Y=i2(Q);if(Y.extends){let j=g1(Y.extends)?Y.extends:R0(s0($),Y.extends),J=j.endsWith(".json")?j:`${j}.json`;if(a2(J)){let K=r2(J);if(K)Y.compilerOptions={...K.compilerOptions,...Y.compilerOptions,paths:{...K.compilerOptions?.paths,...Y.compilerOptions?.paths}}}}return O0.set($,Y),Y}catch{return O0.set($,null),null}}function o($,Z){if($.startsWith(".")||$.startsWith("/"))return $;let Q=u1(Z);if(!Q)return $;let Y=r2(Q);if(!Y?.compilerOptions?.paths)return $;let{baseUrl:j=".",paths:J}=Y.compilerOptions,K=s0(Q),z=R0(K,j);for(let[U,H]of Object.entries(J)){let V=p2.get(U);if(!V){let q=U.split("*").map((W)=>W.replace(h1,"\\$&")).join("(.*)");V=new RegExp(`^${q}$`),p2.set(U,V)}let X=$.match(V);if(X){let q=H[0];if(!q)continue;let W=q;for(let G=1;G<X.length;G++)W=W.replace("*",X[G]);return R0(z,W)}}return $}function e($,Z){if($.startsWith(".")||$.startsWith("/"))return $;let Q=o($,Z);if(Q===$)return $;let Y=v1(Z,Q);return Y=N(Y),Y.startsWith(".")?Y:`./${Y}`}var n2=[".ts",".mts",".cts",".tsx",".js",".mjs",".cjs",".jsx",".d.ts"],l1=/\r?\n/,i1=/^\s*\*+/;function T($){return $&&typeof $==="object"?$:void 0}function $0($){return Array.isArray($)?$:[]}function E($){return e2($)?$.name:void 0}function n0($,Z){let Q=o($,Z),Y=Z3(Z,Q);if(I0(Y)&&s2(Y).isFile())return Y;for(let j of n2){let J=Y+j;if(I0(J))return J}if(I0(Y)&&s2(Y).isDirectory())for(let j of n2){let J=c1(Y,`index${j}`);if(I0(J))return J}return null}function p1($,Z){let Q=$.slice(0,Z).trimEnd();if(!Q.endsWith("*/"))return;let Y=Q.length-2,j=Q.lastIndexOf("/**",Y);if(j===-1)return;let J=[];for(let K of Q.slice(j+3,Y).split(l1)){let z=K.replace(i1,"").trim();if(z.startsWith("@"))break;if(z)J.push(z)}return J.join(" ")||void 0}function a($,Z){if(!Z)return;return $.text.slice(Z.start,Z.end)}function a1($,Z){let Q=T(Z?.typeAnnotation);if(Q?.type!=="TSTypeAnnotation")return;return a($,T(Q.typeAnnotation))}function t2($,Z){let Q=$0(Z.params).map((J)=>a($,J)??"").join(", "),Y=T(Z.returnType),j=Y?.type==="TSTypeAnnotation"?a($,T(Y.typeAnnotation)):void 0;return`(${Q})${j?` => ${j}`:""}`}function r1($){if($.type==="Literal"){let Z=$.value;if(typeof Z==="string")return"string";if(typeof Z==="number")return"number";if(typeof Z==="boolean")return"boolean"}if($.type==="TemplateLiteral")return"string";return}function o2($,Z,Q){let Y=$.filePath,j=p1($.text,Q);if(Z.type==="VariableDeclaration"){let J=Z.kind??"const",K=[];for(let z of $0(Z.declarations)){let U=T(z.id),H=E(U);if(!H)continue;let V=a1($,U),X,q=T(z.init);if(q){if(q.type==="ArrowFunctionExpression"||q.type==="FunctionExpression"){if(!V)V=t2($,q)}else if(X=a($,q),!V)V=r1(q)}K.push({name:H,kind:J,type:V,value:X,description:j,declFile:Y,isTypeOnly:!1})}return K}if(Z.type==="FunctionDeclaration"){let J=E(T(Z.id));if(!J)return[];return[{name:J,kind:"function",type:t2($,Z),description:j,declFile:Y,isTypeOnly:!1}]}if(Z.type==="ClassDeclaration"){let J=E(T(Z.id));if(!J)return[];return[{name:J,kind:"class",type:J,description:j,declFile:Y,isTypeOnly:!1}]}if(Z.type==="TSTypeAliasDeclaration"){let J=E(T(Z.id));if(!J)return[];return[{name:J,kind:"type",type:a($,T(Z.typeAnnotation)),description:j,declFile:Y,isTypeOnly:!0}]}if(Z.type==="TSInterfaceDeclaration"){let J=E(T(Z.id));if(!J)return[];return[{name:J,kind:"interface",type:a($,T(Z.body)),description:j,declFile:Y,isTypeOnly:!0}]}if(Z.type==="TSEnumDeclaration"){let J=E(T(Z.id));if(!J)return[];return[{name:J,kind:"enum",type:J,description:j,declFile:Y,isTypeOnly:!1}]}return[]}function s1($){let Z;try{Z=m1($,"utf-8")}catch{return null}let Q=`<script lang="ts">
|
|
5
|
-
${Z}
|
|
6
|
-
</script>`;try{let Y=L0().parseSvelte(Q,{modern:!0}),j=$0(Y.instance?.content?.body);return{source:{text:Q,filePath:$,dir:$3($)},body:j}}catch(Y){let j=Y instanceof Error?Y.message:String(Y);return console.warn(`Warning: Failed to parse entry export module ${$}: ${j}`),null}}function n1($,Z){for(let Q of $){if(Q.type!=="ImportDeclaration")continue;let Y=T(Q.source)?.value;if(typeof Y!=="string")continue;for(let j of $0(Q.specifiers)){if(j.type!=="ImportSpecifier")continue;if(E(T(j.local))===Z){let J=E(T(j.imported))??Z;return{specifier:Y,importedName:J}}}}return null}function M0($,Z){let Q=Z.cache.get($);if(Q)return Q;if(Z.computing.has($))return[];Z.computing.add($);let Y=s1($);if(!Y)return Z.computing.delete($),Z.cache.set($,[]),[];let{source:j,body:J}=Y,K=[],z=new Map;for(let H of J){let V=H.type==="ExportNamedDeclaration"?T(H.declaration):H;if(!V)continue;for(let X of o2(j,V,V.start))z.set(X.name,X)}let U=(H)=>{let V=z.get(H);if(V)return V;let X=n1(J,H);if(!X||X.specifier.endsWith(".svelte"))return null;let q=n0(X.specifier,j.dir);if(!q)return null;return M0(q,Z).find((W)=>W.name===X.importedName)??null};for(let H of J){if(H.type==="ExportAllDeclaration"){let L=T(H.source)?.value;if(typeof L!=="string"||L.endsWith(".svelte"))continue;let G=n0(L,j.dir);if(!G)continue;let B=H.exportKind==="type";for(let I of M0(G,Z))K.push(B?{...I,isTypeOnly:!0}:I);continue}if(H.type!=="ExportNamedDeclaration")continue;let V=T(H.declaration);if(V){K.push(...o2(j,V,H.start));continue}let X=T(H.source)?.value,q=typeof X==="string"?X:void 0;if(q?.endsWith(".svelte"))continue;let W=H.exportKind==="type";for(let L of $0(H.specifiers)){if(L.type!=="ExportSpecifier")continue;let G=E(T(L.exported)),B=E(T(L.local));if(!G||!B||B==="default"||G==="default")continue;let I=W||L.exportKind==="type",k=null;if(q){let M=n0(q,j.dir);if(M)k=M0(M,Z).find((D)=>D.name===B)??null}else k=U(B);if(k?.declFile.endsWith(".svelte"))continue;if(k)K.push({...k,name:G,isTypeOnly:k.isTypeOnly||I});else K.push({name:G,kind:I?"type":"const",declFile:$,isTypeOnly:I})}}return Z.computing.delete($),Z.cache.set($,K),K}async function D0($){await p();let Z=Z3($),Q=$3(Z),Y=M0(Z,{cache:new Map,computing:new Set}),j=new Map;for(let J of Y){let{declFile:K,...z}=J,U=N(`./${d1(Q,K)}`);j.set(J.name,{...z,source:U})}return Array.from(j.values()).sort((J,K)=>J.name.localeCompare(K.name))}import{lstatSync as t1,readdirSync as o1,readFileSync as e1}from"node:fs";import{dirname as $5,join as Q3,resolve as Z5}from"node:path";var Y3=new Map;function Q5($){return j3($,{ecmaVersion:"latest",sourceType:"module"})}function t0($,Z,Q=new Set){let Y=Y3.get($);if(!Y)Y=Q5($),Y3.set($,Y);let j={};for(let J of Y.body)if(J.type==="ExportDefaultDeclaration"){let K=J.declaration.name;if(K in j)j[K].default=!0;else j[K]={source:f(""),default:!0}}else if(J.type==="ExportAllDeclaration"){if(!J.source)continue;let K=o(J.source.value,Z),z=Z5(Z,K);if(!t1(z).isFile()){let V=o1(z);for(let X of V)if(X.includes("index")){z=Q3(z,X);break}}if(Q.has(z))continue;Q.add(z);let U=e1(z,"utf-8"),H=t0(U,$5(z),Q);Q.delete(z);for(let[V,X]of Object.entries(H)){let q=f(N(`./${Q3(J.source.value,X.source)}`));j[V]={...X,source:q}}}else if(J.type==="ExportNamedDeclaration")for(let K of J.specifiers){let z=K.exported.name,U=K.local.name,H=z||U;if(H in j){if(J.type==="ExportNamedDeclaration")j[H].mixed=!0;if(!j[H].source)j[H].source=f(e(J.source?.value??"",Z))}else j[H]={source:f(e(J.source?.value??"",Z)),default:U==="default"}}else if(J.type==="ImportDeclaration"){let K=J.specifiers[0].local.name;if(K in j){if(!j[K].source)j[K].source=f(e(J.source?.value??"",Z))}else j[K]={source:f(e(J.source?.value??"",Z)),default:K==="default"}}return j}function Q0($){return{failFast:$?.failFast,resolveTypes:$?.resolveTypes===!0,documentExports:$?.documentExports===!0,cache:$?.cache,checkExamples:$?.checkExamples===!0,dryRun:$?.dryRun===!0}}var X5=/-/g;function H3($,Z=[],Q=new Set){let Y;try{let j=J5($);if(Q.has(j))return Z;Q.add(j),Y=Y5($,{withFileTypes:!0})}catch{return Z}for(let j of Y){if(j.name.startsWith("."))continue;let J=V5($,j.name),K=j.isSymbolicLink()?K5(J,{throwIfNoEntry:!1}):j;if(!K)continue;if(K.isDirectory())H3(J,Z,Q);else if(K.isFile()&&j.name.endsWith(".svelte"))Z.push(J)}return Z}function e0($){return H3($).map((Z)=>{let Q=o0(Z).name.replace(X5,""),Y=f(N(`./${G5($,Z)}`));return{moduleName:Q,source:Y}})}function T0($,Z,Q=!1){let Y=K3($).isFile(),j=Y?z5($):$,J=Z0(j),K=(H)=>U5(H)?Z0(H):Z0(J,H),z={};if(Y){let H=j5($,"utf-8");try{z=t0(H,J,new Set([Z0($)]))}catch(V){if(!Q)throw V;let X=V instanceof Error?V.message:String(V);console.warn(`Warning: Failed to parse component exports from ${$}: ${X}`)}}let U={...z};if(Z)for(let{moduleName:H,source:V}of e0(J)){if(z[H])z[H].source=V;if(U[H])U[H].source=V;else U[H]={source:V,default:!1}}return{exports:z,allComponents:U,rootDir:J,resolveComponentFilePath:K}}async function Y0($){let Z=await Promise.all(Array.from($).map(async(Q)=>{try{let Y=await H5(Q,"utf-8");return{path:Q,content:Y}}catch(Y){return console.warn(`Warning: Failed to read file ${Q}:`,Y),{path:Q,content:null}}}));return new Map(Z.map(({path:Q,content:Y})=>[Q,Y]))}function h([$,Z],Q,Y,j,J={}){let K=Z.source,{ext:z,name:U}=o0(K),H=$;if(Q.length===1&&$==="default")H=U;if(z===".svelte"){let V=j(K),X=Y.get(V);if(X===null||X===void 0)return null;let q=N(K),W=J.memo?.get(V),L=J.hashes?.get(V),G=W===void 0?L===void 0?null:J.cache?.get(V,L):null,B;if(W!==void 0)B=W;else if(G)B=G;else{let I=new(L0()).ComponentParser;try{B=I.parseSvelteComponent(X,{moduleName:H,filePath:q})}catch(k){if(J.failFast)throw k;let M=k instanceof Error?k.message:String(k),D=k instanceof Error?k.stack:void 0;return J.onParseError?.({filePath:q,moduleName:H,message:M,stack:D}),null}if(L!==void 0)J.cache?.set(V,L,B);J.memo?.set(V,B)}return{moduleName:H,filePath:q,...B}}return null}function b0($,Z){let Q=new Set;for(let Y of $)for(let[,j]of Y)if(o0(j.source).ext===".svelte")Q.add(Z(j.source));return Q}function j0($){if($.length===0)return;console.error(`sveld: failed to parse ${$.length} component(s):`);for(let{filePath:Z,message:Q}of $)console.error(` - ${Z}: ${Q}`)}async function J0($,Z,Q={}){let Y=Q.documentExports===!0,{exports:j,allComponents:J,rootDir:K,resolveComponentFilePath:z}=T0($,Z,Y),U=Y&&K3($).isFile()?await D0(Z0($)):[],H=Object.entries(j),V=Object.entries(J),X=b0([H,V],z),q=await Y0(X),W=new Map,L=new Map,G=Q.cache===!1?void 0:new p0(c2(K,Q.cache??!0)),B=new Set,I=new Map;if(G)for(let O of X){let R=q.get(O);if(R===null||R===void 0)continue;let F=d2(R);if(I.set(O,F),!G.has(O,F))B.add(O)}if(X.size>0&&(!G||B.size>0))await p();let k=new Map,M=new Map,D={failFast:Q.failFast===!0,onParseError:(O)=>k.set(O.filePath,O),cache:G,hashes:I,memo:M};for(let O of H){let R=h(O,H,q,z,D);if(R)W.set(R.moduleName,R)}for(let O of V){let R=h(O,V,q,z,D);if(R)L.set(R.moduleName,R)}if(G&&B.size>0){let O=t(L,z),R=W0(B,O);for(let F of R){if(B.has(F))continue;G.invalidate(F),M.delete(F)}for(let F of H){let m=z(F[1].source);if(!R.has(m)||B.has(m))continue;let P=h(F,H,q,z,D);if(P)W.set(P.moduleName,P)}for(let F of V){let m=z(F[1].source);if(!R.has(m)||B.has(m))continue;let P=h(F,V,q,z,D);if(P)L.set(P.moduleName,P)}}let b=Array.from(k.values());if(j0(b),!Q.dryRun)G?.save();let S=Q.resolveTypes?q5(W):[],x=Q.checkExamples?k5(L):[];if(S.length>0||x.length>0){let{TypeResolver:O}=await import("./chunk-h1r040pg.js"),R=await O.create(K);try{if(S.length>0)await W5(S,R,z);if(x.length>0)await B5(x,R,z)}finally{await R?.dispose()}}let A=k0(Array.from(L.values()).flatMap((O)=>O.diagnostics??[]));return{exports:j,entryExports:U,components:W,allComponentsForTypes:L,errors:b,diagnostics:A}}function q5($){let Z=[];for(let Q of $.values()){let Y=A0(Q);if(!Y?.canonicalPropsType||Q.props.length>0)continue;Z.push({component:Q,metadata:Y})}return Z}async function W5($,Z,Q){if(!Z)return;let Y=await Z.expandAll($.map(({component:j,metadata:J})=>({moduleName:j.moduleName,metadata:J,filePath:Q(j.filePath)})));for(let{component:j}of $){let J=Y.get(j.moduleName);if(J)J3(j,J)}}function k5($){let Z=[];for(let Q of $.values()){let Y=h2(Q);if(Y.length===0)continue;Z.push({component:Q,sources:Y})}return Z}async function B5($,Z,Q){if(!Z)return;let Y=await Z.checkExamples($.map(({component:j,sources:J})=>({moduleName:j.moduleName,filePath:Q(j.filePath),sources:J})));for(let{component:j,sources:J}of $){let K=Y.get(j.moduleName);if(!K||K.length===0)continue;let z=new Map(J.map((H)=>[H.id,H.source])),U=j.diagnostics??[];for(let H of K){let V=z.get(H.id);U.push({component:j.filePath,kind:"example-compile-error",name:H.name,message:H.message,...V?{source:V}:{}})}j.diagnostics=U}}import{existsSync as z3,readFileSync as L5}from"node:fs";import{join as U3}from"node:path";function F0($){if($){let Q=U3(process.cwd(),$);if(z3(Q))return n($);return console.error(`Invalid entry point: ${Q}. Pass a valid --entry (or "entry" option), or unset it and`),console.error('set the "svelte" field in your package.json instead.'),null}let Z=U3(process.cwd(),"package.json");if(!z3(Z))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 Q=l2(JSON.parse(L5(Z,"utf-8")));if(Q.svelte?.trim())return n(Q.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(Q){throw console.error("Error reading package.json:",Q),Q}}import{lstatSync as O5}from"node:fs";import{resolve as V3}from"node:path";var R5=/\.svelte$/;async function G3($,Z,Q=!1){let{exports:Y,allComponents:j,rootDir:J,resolveComponentFilePath:K}=T0($,Z,Q),z=Q&&O5($).isFile()?await D0(V3($)):[],U=Object.entries(Y),H=Object.entries(j),V=new Map,X=new Map;await p();let q=new Map,W={onParseError:(k)=>q.set(k.filePath,k)},L=()=>({exports:Y,entryExports:z,components:V,allComponentsForTypes:X,errors:Array.from(q.values()),diagnostics:k0(Array.from(X.values()).flatMap((k)=>k.diagnostics??[]))});{let k=b0([U,H],K),M=await Y0(k);for(let D of U){let b=h(D,U,M,K,W);if(b)V.set(b.moduleName,b)}for(let D of H){let b=h(D,H,M,K,W);if(b)X.set(b.moduleName,b)}j0(L().errors)}let G=t(X,K),B=(k,M,D,b)=>{let S=new Set;for(let x of M){let A=K(x[1].source);if(!D.has(A))continue;let O=h(x,M,b,K,W);if(O)k.set(O.moduleName,O),S.add(A);else for(let[R,F]of k)if(K(F.filePath)===A)k.delete(R)}return S};return{get result(){return L()},update:async(k)=>{let M=k.filter((A)=>R5.test(A)).map((A)=>V3(A));if(M.length===0)return{result:L(),reparsed:[]};if(Z)for(let{moduleName:A,source:O}of e0(J)){let R=j[A];if(R)R.source=O;else{let F={source:O,default:!1};j[A]=F,H.push([A,F])}}let D=W0(M,G);for(let[A,O]of q)if(D.has(K(O.filePath)))q.delete(A);let b=await Y0(D),S=new Set;for(let A of B(V,U,D,b))S.add(A);for(let A of B(X,H,D,b))S.add(A);G=t(X,K);let x=L();return j0(x.errors),{result:x,reparsed:Array.from(S)}}}}import x5 from"node:path";var X3=!1;function q3($){X3=$}function u($){if(!X3)console.error($)}import{mkdir as I5,readFile as M5,writeFile as D5}from"node:fs/promises";import{parse as A5}from"node:path";class _{dryRun;constructor($){this.dryRun=$?.dryRun===!0}async write($,Z){if(this.dryRun)return console.log(`would write "${N($)}"`),!0;try{if(await M5($,"utf-8")===Z)return!1}catch{}return await I5(A5($).dir,{recursive:!0}),await D5($,Z),!0}}var T5=new Set(["string","number","boolean"]);function b5($){return $.map((Z)=>({kind:"field",name:Z.name,...Z.type?{type:{text:Z.type}}:{},...Z.value===void 0?{}:{default:Z.value},...Z.description?{description:Z.description}:{},...Z.deprecated===void 0?{}:{deprecated:Z.deprecated}}))}function F5($){let Z=new Map;for(let Y of $){if(!Y.type||!T5.has(Y.type.trim()))continue;let j=Y.name.toLowerCase(),J=Z.get(j);if(J)J.push(Y);else Z.set(j,[Y])}let Q=[];for(let[Y,j]of Z){if(j.length!==1)continue;let J=j[0];Q.push({name:Y,fieldName:J.name,type:{text:J.type},...J.value===void 0?{}:{default:J.value},...J.description?{description:J.description}:{}})}return Q}function S5($){return $.filter((Z)=>Z.type==="dispatched").map((Z)=>({name:Z.name,type:{text:`CustomEvent<${Z.detail??"unknown"}>`},...Z.description?{description:Z.description}:{},...Z.deprecated===void 0?{}:{deprecated:Z.deprecated}}))}function N5($){return $.map((Z)=>({name:Z.default?"":Z.name??"",...Z.description?{description:Z.description}:{},...Z.deprecated===void 0?{}:{deprecated:Z.deprecated}}))}function _5($){let Z={kind:"class",name:$.moduleName,...$.componentComment?{description:$.componentComment}:{},members:b5($.props),attributes:F5($.props),events:S5($.events),slots:N5($.slots)};if($.customElementTag)Z.tagName=$.customElementTag,Z.customElement=!0;return Z}function w5($,Z){let Q=[{kind:"js",name:$.moduleName,declaration:{name:$.moduleName,module:Z}}];if($.customElementTag)Q.push({kind:"custom-element-definition",name:$.customElementTag,declaration:{name:$.moduleName,module:Z}});return Q}function W3($,Z={}){let Q=C($),Y=Z.resolveModulePath??((J)=>J.filePath);return{schemaVersion:"1.0.0",modules:Q.components.map((J)=>{let K=Y(J);return{kind:"javascript-module",path:K,declarations:[_5(J)],exports:w5(J,K)}})}}function $2($,Z){let Q=W3($,{resolveModulePath:(Y)=>S0(Y.filePath,Z.inputDir)});return v(Q)}async function Z2($,Z){let Q=$2($,Z),Y=x5.join(process.cwd(),Z.outFile);if(await new _({dryRun:Z.dryRun}).write(Y,Q),!Z.dryRun)u(`created "${Z.outFile}".`)}import Q2 from"node:path";function Y2($,Z){return $.map((Q)=>({...Q,filePath:S0(Q.filePath,Z)}))}async function C5($,Z){let Q=C($),Y=Y2(Q.components,Z.inputDir);await Promise.all(Y.map(async(j)=>{let J=Q2.resolve(Q2.join(Z.outDir||"",`${j.moduleName}.api.json`)),z=await new _({dryRun:Z.dryRun}).write(J,v(j));if(!Z.dryRun)u(`${z?"created":"unchanged"} "${J}".`)}))}function j2($,Z){let Q=C($,{entryExports:Z.entryExports}),Y={...Q,components:Y2(Q.components,Z.inputDir)};return v(Y)}function k3($,Z){let Q=C($,{entryExports:Z.entryExports});return`${Y2(Q.components,Z.inputDir).map((j)=>JSON.stringify(j)).join(`
|
|
10
|
-
`)}
|
|
11
|
-
`}async function y5($,Z){let Q=j2($,Z),Y=Q2.join(process.cwd(),Z.outFile);if(await new _({dryRun:Z.dryRun}).write(Y,Q),!Z.dryRun)u(`created "${Z.outFile}".`)}async function J2($,Z){if(Z.outDir)await C5($,Z);else await y5($,Z)}import{join as x$}from"node:path";var B3=/^[}\])>]/,P5=new Set(["{","(","["]),g5=new Set(["}",")","]"]);var E5=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,L3=/[ \t]+$/,v5=/\s+$/,f5=/[{([]$/,h5=/\s/;function u5($){return E5.test($.slice(-200))}function m5($){let Z="",Q=null,Y=!1;for(let j=0;j<$.length;j++){let J=$[j],K=$[j-1];if(Q){if(Z+=J,Q==="double"&&J==='"'&&K!=="\\"||Q==="single"&&J==="'"&&K!=="\\"||Q==="template"&&J==="`"&&K!=="\\")Q=null;Y=!1;continue}if(J==='"'||J==="'"||J==="`"){Q=J==='"'?"double":J==="'"?"single":"template",Z+=J,Y=!1;continue}if(h5.test(J)){if(!Y&&Z.length>0)Z+=" ",Y=!0;continue}Z+=J,Y=!1}return Z.trimEnd()}function c5($,Z){let Q=0,Y="normal";for(let j=Z;j<$.length;j++){let J=$[j],K=$[j-1];if(Y==="blockComment"){if(K==="*"&&J==="/")Y="normal";continue}if(Y==="double"||Y==="single"){if(J===(Y==="double"?'"':"'")&&K!=="\\")Y="normal";continue}if(Y==="template"){if(J==="`"&&K!=="\\")Y="normal";continue}if(J==="/"&&$[j+1]==="*")Y="blockComment";else if(J==='"')Y="double";else if(J==="'")Y="single";else if(J==="`")Y="template";else if(J==="{")Q++;else if(J==="}"){if(Q--,Q===0)return j}}return-1}function O3($){let Z="",Q="normal";for(let Y=0;Y<$.length;Y++){let j=$[Y],J=$[Y-1];if(Q==="blockComment"){if(Z+=j,J==="*"&&j==="/")Q="normal";continue}if(Q==="double"||Q==="single"){if(Z+=j,j===(Q==="double"?'"':"'")&&J!=="\\")Q="normal";continue}if(Q==="template"){if(Z+=j,j==="`"&&J!=="\\")Q="normal";continue}if(j==="/"&&$[Y+1]==="*"){Q="blockComment",Z+=j;continue}if(j==='"'){Q="double",Z+=j;continue}if(j==="'"){Q="single",Z+=j;continue}if(j==="`"){Q="template",Z+=j;continue}if(j==="{"){let K=c5($,Y);if(K===-1){Z+=j;continue}let z=$.slice(Y+1,K);if(z.trim()===""){Z+="{}",Y=K;continue}if(!z.includes("/*")&&$[Y+1]!==`
|
|
12
|
-
`&&!u5(Z)){let U=O3(z).trim();if(!U.includes(`
|
|
13
|
-
`)){let H=U.endsWith(";")?U.slice(0,-1):U,V=`{ ${m5(H)} }`;if(V.length<=120){Z+=V,Y=K;continue}}}if(Z+=j,$[Y+1]!==`
|
|
14
|
-
`)Z+=`
|
|
15
|
-
`;continue}if(j==="}"){if(Z=Z.replace(L3,""),!Z.endsWith(`
|
|
16
|
-
`))Z+=`
|
|
17
|
-
`;Z+=j;continue}if(j===";"){if(Z=Z.replace(v5,""),Z+=";",$[Y+1]!==`
|
|
18
|
-
`)Z+=`
|
|
19
|
-
`;continue}Z+=j}return Z}function d5($){let Z="",Q=null;for(let Y=0;Y<$.length;Y++){let j=$[Y],J=$[Y-1];if(Q){if(Z+=j,Q==="double"&&j==='"'&&J!=="\\"||Q==="single"&&j==="'"&&J!=="\\"||Q==="template"&&j==="`"&&J!=="\\")Q=null;continue}if(j==='"'||j==="'"||j==="`"){Q=j==='"'?"double":j==="'"?"single":"template",Z+=j;continue}if(j===" "&&Z.endsWith(" "))continue;Z+=j}return Z}function l5($){let Z=$.split(`
|
|
20
|
-
`),Q=[],Y=0,j=!1,J=0;for(let K of Z){let z=K.trim();if(z===""){Q.push("");continue}if(j){if(Q.push(`${" ".repeat(J)} ${z}`),z.includes("*/"))j=!1;continue}if(z.startsWith("/**")&&!z.includes("*/")){Q.push(" ".repeat(Y)+z),j=!0,J=Y;continue}let U=d5(z),H=B3.test(U),V=Math.max(0,Y-(H?1:0));if(Q.push(" ".repeat(V)+U),U.startsWith("/**")&&U.includes("*/"))continue;let X=null;for(let q=0;q<U.length;q++){let W=U[q],L=U[q-1];if(X){if(X==="double"&&W==='"'&&L!=="\\"||X==="single"&&W==="'"&&L!=="\\"||X==="template"&&W==="`"&&L!=="\\")X=null;continue}if(W==='"')X="double";else if(W==="'")X="single";else if(W==="`")X="template";else if(P5.has(W))Y++;else if(g5.has(W))Y=Math.max(0,Y-1);else if(W==="<")Y++;else if(W===">"&&L!=="=")Y=Math.max(0,Y-1)}}return Q.join(`
|
|
21
|
-
`)}function i5($){let Z=$.split(`
|
|
22
|
-
`).map((Y)=>Y.replace(L3,"")),Q=[];for(let Y of Z){let j=Y==="",J=Q.length>0&&Q[Q.length-1]==="",K=Q.length>0&&f5.test(Q[Q.length-1]);if(j){if(Q.length===0||J||K)continue;Q.push(Y);continue}if(B3.test(Y)&&J)Q.pop();Q.push(Y)}while(Q.length>0&&Q[Q.length-1]==="")Q.pop();return Q.join(`
|
|
23
|
-
`)}function R3($){let Z=O3($),Q=l5(Z);return`${i5(Q)}
|
|
24
|
-
`}var c="any",y="",p5="Record<string, any>",H2="Record<string, never>",a5=/(-|\s+|:)/,r5=/("|')/,s5=/CustomEvent/,n5=/^[A-Z]/,t5=/\n/,I3=/=>/,o5=/(?:^|\n)@default\b/,z2=/\n/g,e5=/\s+/g,$$=/(^|[^.\w])Snippet(?:\s*<|\b)/,Z$=/import\s+type\s+[^;]*\bSnippet\b[^;]*from\s+"svelte";/,Q$=/[.*+?^${}()|[\]\\]/g,Y$=/^const\s+/;function U2($){return $.replace(Y$,"")}function j$($){if(!$)return;return $.replace(z2,`
|
|
25
|
-
* `)}function _0($){if(!$)return"";return`/** ${$} */`}function w0($){if(!$)return"";return`/**
|
|
26
|
-
* ${$.replace(z2,`
|
|
27
|
-
* `)}
|
|
28
|
-
*/`}function M3($){if($===void 0)return;return $===!0?"@deprecated":`@deprecated ${$}`}function J$($){let Z=M3($);if(Z===void 0)return;return`* ${Z.replace(z2,`
|
|
29
|
-
* `)}
|
|
30
|
-
`}function K$($,Z){if(!Z)return[`@${$}`];if(!Z.includes(`
|
|
31
|
-
`))return[`@${$} ${Z}`];return[`@${$}`,...Z.split(`
|
|
32
|
-
`)]}function D3($){let Z=[];for(let{name:Q,body:Y}of $??[])Z.push(...K$(Q,Y));return Z}function K0($,Z,Q){let Y=M3(Q),j=D3(Z),J=j.length>0;if(!$&&!J&&!Y)return"";if(!J&&!Y)return $?.includes(`
|
|
33
|
-
`)?w0($):_0($);let K=[];if($)K.push(...$.split(`
|
|
34
|
-
`));if(K.push(...j),Y)K.push(...Y.split(`
|
|
35
|
-
`));return`/**
|
|
36
|
-
* ${K.join(`
|
|
37
|
-
* `)}
|
|
38
|
-
*/`}function H$($){let Z=D3($);if(Z.length===0)return"";return Z.map((Q)=>`* ${Q}
|
|
39
|
-
`).join("")}function x0($){if($===void 0)return c;return`${$}
|
|
40
|
-
`}function C0($){if($.typedefs.length===0)return y;return $.typedefs.map((Z)=>{return`${Z.description?`${w0(Z.description)}
|
|
41
|
-
`:""}export ${Z.ts}`}).join(`
|
|
42
|
-
|
|
43
|
-
`)}function A3($,Z){let Q=Z.replace(Q$,"\\$&");return new RegExp(`\\b${Q}\\b`).test($)}function z$($){if($===null)return[];return $[0].split(",").map((Z,Q)=>({name:Z.trim(),constraint:(N0($[1]??"")[Q]??Z).trim()}))}function U$($,Z){let Q=z$($).filter(({name:Y})=>A3(Z,Y));if(Q.length===0)return{declSuffix:y,refSuffix:y};return{declSuffix:`<${Q.map(({constraint:Y})=>U2(Y)).join(", ")}>`,refSuffix:`<${Q.map(({name:Y})=>Y).join(", ")}>`}}function T3($){if(!$.contexts||$.contexts.length===0)return y;let Z=$.generics===null?[]:$.generics[0].split(",").map((Q,Y)=>({name:Q.trim(),constraint:(N0($.generics?.[1]??"")[Y]??Q).trim()}));return $.contexts.map((Q)=>{let Y=Q.properties.map((z)=>{let U=z.description?`${_0(z.description)}
|
|
44
|
-
`:"",H=z.optional?"?":"";return`${U}${z.name}${H}: ${z.type};`}).join(`
|
|
45
|
-
`),j=Q.description?`${w0(Q.description)}
|
|
46
|
-
`:"",J=Z.filter(({name:z})=>Q.properties.some((U)=>A3(U.type,z))).map(({constraint:z})=>z),K=J.length>0?`<${J.map(U2).join(", ")}>`:"";if(Q.properties.length===0)return`${j}export type ${Q.typeName} = Record<string, never>;`;return`${j}export type ${Q.typeName}${K} = {
|
|
47
|
-
${Y}
|
|
48
|
-
};`}).join(`
|
|
49
|
-
|
|
50
|
-
`)}function H0($){if(a5.test($))return r5.test($)?$:`"${$}"`;return $}function b3($,Z){if(!$)return;return`* ${Z||$}
|
|
51
|
-
`}function V2($,Z,Q){return[b3(j$($)),J$(Z),H$(Q)].filter(Boolean).join("")}function G2($){return $.length>0?`/**
|
|
52
|
-
${$}*/`:y}function V$($){let Z=new Set([...$.props.filter((G)=>!G.isFunctionDeclaration&&G.kind!=="const").map((G)=>G.name),...Array.from($.canonicalPropNames??[])]),Q=$.props.filter((G)=>!G.isFunctionDeclaration&&G.kind!=="const").map((G)=>{let B=G.value;if(typeof G.value==="string")B=G.value.replace(e5," ");if(G.value===void 0)B="undefined";let I=o5.test(G.description??""),k=[V2(G.description,G.deprecated,G.tags),b3(G.constant,"@constant"),G.isFunction||I?null:`* @default ${B}
|
|
53
|
-
`].filter(Boolean).join(""),M=G.constant&&!G.isFunction?G.value:G.type;return`
|
|
54
|
-
${G2(k)}
|
|
55
|
-
${G.name}${G.isRequired?"":"?"}: ${M};`}),Y=$.canonicalPropsType?Q.filter((G,B)=>{let I=$.props.filter((k)=>!k.isFunctionDeclaration&&k.kind!=="const")[B];return I?!($.canonicalPropNames?.has(I.name)??!1):!0}):Q,j=($.slots||[]).filter((G)=>!G.default&&G.name!=null&&!Z.has(G.name)).map((G)=>{let B=G.name,I=H0(B),k=K0(G.description,G.tags,G.deprecated),M=k?`${k}
|
|
56
|
-
`:"",b=G.slot_props&&G.slot_props!=="Record<string, never>"?`(this: void, ...args: [${G.slot_props}]) => void`:"(this: void) => void";return`
|
|
57
|
-
${M}${I}?: ${b};`}),J=($.slots||[]).find((G)=>G.default||G.name===null),K=J&&!Z.has("children")?(()=>{let G=K0(J.description,J.tags,J.deprecated),B=G?`${G}
|
|
58
|
-
`:"",k=J.slot_props&&J.slot_props!=="Record<string, never>"?`(this: void, ...args: [${J.slot_props}]) => void`:"(this: void) => void";return`
|
|
59
|
-
${B}children?: ${k};`})():"",z=$.events?B$({events:$.events},Z):[],U=[...j,K,...z].filter(Boolean),H=[...Y,...U].join(`
|
|
60
|
-
`),V=`${$.moduleName}Props`,X=y,q=$.generics?`<${N0($.generics[1]).map((G)=>U2(G.trim())).join(", ")}>`:"",W=$.generics?`<${$.generics[0]}>`:"",L=$.canonicalPropsType?`
|
|
61
|
-
type $Props${q} = ${$.canonicalPropsType}${H.trim()===""?"":` & {${H}
|
|
62
|
-
}`};
|
|
63
|
-
`:`
|
|
64
|
-
type $Props${q} = {
|
|
65
|
-
${H}
|
|
66
|
-
};
|
|
67
|
-
`;if($.rest_props?.type==="Element"){let G;if($.rest_props.name==="svelte:element")if($.rest_props.thisValue)G=`SvelteHTMLElements["${$.rest_props.thisValue}"]`;else G="HTMLAttributes<HTMLElement>";else G=$.rest_props.name.split("|").map((k)=>{return`SvelteHTMLElements["${k.trim()}"]`}).join(" & ");let B="[key: `data-${string}`]: unknown;",I=$.rest_props.description?$.rest_props.description.includes(`
|
|
68
|
-
`)?`${w0($.rest_props.description)}
|
|
69
|
-
`:`${_0($.rest_props.description)}
|
|
70
|
-
`:"";if($.extends===void 0)X=`
|
|
71
|
-
${I}${G?`type $RestProps = ${G};
|
|
72
|
-
`:""}
|
|
73
|
-
${$.canonicalPropsType?`type $Props${q} = (${$.canonicalPropsType}) & {${H}
|
|
74
|
-
|
|
75
|
-
${B}
|
|
76
|
-
};`:`type $Props${q} = {
|
|
77
|
-
${H}
|
|
78
|
-
|
|
79
|
-
${B}
|
|
80
|
-
};`}
|
|
81
|
-
|
|
82
|
-
export type ${V}${q} = Omit<$RestProps, keyof $Props${W}> & $Props${W};
|
|
83
|
-
`;else X=`
|
|
84
|
-
${I}${G?`type $RestProps = ${G};
|
|
85
|
-
`:""}
|
|
86
|
-
${$.canonicalPropsType?`type $Props${q} = (${$.canonicalPropsType}) & {${H}
|
|
87
|
-
|
|
88
|
-
${B}
|
|
89
|
-
};`:`type $Props${q} = {
|
|
90
|
-
${H}
|
|
91
|
-
|
|
92
|
-
${B}
|
|
93
|
-
};`}
|
|
94
|
-
|
|
95
|
-
export type ${V}${q} = Omit<$RestProps, keyof ($Props${W} & ${$.extends.interface})> & $Props${W} & ${$.extends.interface};
|
|
96
|
-
`}else if(H.trim()===""&&$.extends===void 0&&!$.canonicalPropsType)X=`
|
|
97
|
-
export type ${V}${q} = ${H2};
|
|
98
|
-
`;else if($.canonicalPropsType)X=`
|
|
99
|
-
${L}
|
|
100
|
-
export type ${V}${q} = ${$.extends===void 0?"":`${$.extends.interface} & `}$Props${W};
|
|
101
|
-
`;else X=`
|
|
102
|
-
export type ${V}${q} = ${$.extends===void 0?"":`${$.extends.interface} & `} {
|
|
103
|
-
${H}
|
|
104
|
-
};
|
|
105
|
-
`;return{props_name:V,prop_def:X}}function G$($){if($.slots.length===0)return H2;let Z=$.slots.map(({name:Q,slot_props:Y,...j})=>{let J=j.default||Q===null?"default":H0(Q??""),K=K0(j.description,j.tags,j.deprecated);return`${K?`${K}
|
|
106
|
-
`:""}${H0(J)}: ${x0(Y)};`}).join(`
|
|
107
|
-
`);return $.slots.length===1?`{${Z}}`:`{
|
|
108
|
-
${Z}
|
|
109
|
-
}`}var X$=()=>"WindowEventMap",q$=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 K2($=c){if(s5.test($))return $;return`CustomEvent<${$}>`}function W$($){return q$.has($)}function F3($){switch($.type){case"dispatched":return K2($.detail);case"forwarded":{let Z=$.element,Y=!(Z&&n5.test(Z))||W$($.name),j=$.detail!==void 0&&$.detail!=="undefined"&&!($.detail==="null"&&Y),J=$.detail==="null"&&!Y;if(j||J)return K2($.detail);else if(Y)return`${X$()}["${$.name}"]`;else return K2()}default:return $}}function k$($){if($.events.length===0)return p5;let Z=$.events.map((Q)=>{let Y="",j=K0(Q.description,Q.tags,Q.deprecated);if(j)Y=`${j}
|
|
110
|
-
`;return`${Y}${H0(Q.name)}: ${F3(Q)};
|
|
111
|
-
`}).join("");return $.events.length===1?`{${Z}}`:`{
|
|
112
|
-
${Z}}`}function B$($,Z){return $.events.map((Q)=>{let Y=`on${Q.name}`;if(Z.has(Y))return;let j="",J=K0(Q.description,Q.tags,Q.deprecated);if(J)j=`${J}
|
|
113
|
-
`;return`
|
|
114
|
-
${j}${H0(Y)}?: (event: ${F3(Q)}) => void;`}).filter((Q)=>Q!==void 0)}function L$($){let Z=$.type==="() => any";if($.type&&I3.test($.type)&&!Z)return $.type;else if($.params&&$.params.length>0){let Y=$.params.map((J)=>{let K=J.optional?"?":"";return`${J.name}${K}: ${J.type}`}).join(", "),j=$.returnType||c;return`(${Y}) => ${j}`}else if($.returnType)return`() => ${$.returnType}`;else return $.type||c}function S3($){return $.props.filter((Z)=>Z.isFunctionDeclaration||Z.kind==="const").map((Z)=>{let Q=V2(Z.description,Z.deprecated,Z.tags),Y=L$(Z);return`
|
|
115
|
-
${G2(Q)}
|
|
116
|
-
${Z.name}: ${Y};`}).join(`
|
|
117
|
-
`)}function O$($){let Z=`${$.moduleName}Exports`,Q=S3({props:$.props});if(Q.trim()==="")return{exports_name:Z,exports_ref:Z,exports_def:`export type ${Z} = ${H2};`};let{declSuffix:Y,refSuffix:j}=U$($.generics,Q);return{exports_name:Z,exports_ref:`${Z}${j}`,exports_def:`export type ${Z}${Y} = {${Q}
|
|
118
|
-
};`}}function R$($){let Z=$.props.filter((Q)=>Q.bindable===!0||Q.binding==="writable").map((Q)=>`"${Q.name}"`);return Z.length===0?y:Z.join(" | ")}function I$($){let Z=$.moduleName==="default"?"$$Component":$.moduleName,Q=$.bindings===y?'""':$.bindings;return`declare const ${Z}: Component<
|
|
119
|
-
${$.propsRef},
|
|
120
|
-
${$.exportsRef},
|
|
121
|
-
${Q}
|
|
122
|
-
>;
|
|
123
|
-
export default ${Z};`}function M$($){let Z=$.moduleName==="default"?"$$Component":$.moduleName,Q=`${Z}Component`,Y=$.bindings===y?'""':$.bindings;return`interface ${Q} {
|
|
124
|
-
new ${$.generic}(
|
|
125
|
-
options: ComponentConstructorOptions<${$.propsRef}>
|
|
126
|
-
): SvelteComponent<${$.propsRef}> & ${$.exportsRef};
|
|
127
|
-
${$.generic}(
|
|
128
|
-
this: void,
|
|
129
|
-
internals: ComponentInternals,
|
|
130
|
-
props: ${$.propsRef}
|
|
131
|
-
): {
|
|
132
|
-
$on?(type: string, callback: (e: any) => void): () => void;
|
|
133
|
-
$set?(props: Partial<${$.propsRef}>): void;
|
|
134
|
-
} & ${$.exportsRef};
|
|
135
|
-
element?: typeof HTMLElement;
|
|
136
|
-
z_$$bindings?: ${Y};
|
|
137
|
-
}
|
|
138
|
-
declare const ${Z}: ${Q};
|
|
139
|
-
export default ${Z};`}function D$($){if($.extends===void 0)return"";return`import type { ${$.extends.interface} } from ${$.extends.import};`}function A$($){if(!$.componentComment)return"";if(!t5.test($.componentComment))return _0($.componentComment.trim());return`/*${$.componentComment.split(`
|
|
140
|
-
`).map((Z)=>`* ${Z}`).join(`
|
|
141
|
-
`)}
|
|
142
|
-
*/`}function T$($){return $.moduleExports.map((Z)=>{let Q=V2(Z.description,Z.deprecated,Z.tags),Y,j=Z.type&&I3.test(Z.type),J=Z.type==="() => any";if(Z.kind==="const"&&!j)Y=`export declare const ${Z.name}: ${Z.type||c};
|
|
143
|
-
`;else if(Z.params&&Z.params.length>0){let z=Z.params.map((H)=>{let V=H.optional?"?":"";return`${H.name}${V}: ${H.type}`}).join(", "),U=Z.returnType||c;Y=`export declare function ${Z.name}(${z}): ${U};`}else if(Z.returnType)Y=`export declare function ${Z.name}(): ${Z.returnType};`;else if(j&&Z.type&&!J){let[K,z,...U]=Z.type.split("=>"),H=U.map((V)=>` => ${V.trim()}`).join("");Y=`export declare function ${Z.name}${K.trimEnd()}: ${z.trim()}${H};`}else if(j&&Z.type){let[K,z,...U]=Z.type.split("=>"),H=U.map((V)=>` => ${V.trim()}`).join("");Y=`export declare function ${Z.name}${K.trimEnd()}: ${z.trim()}${H};`}else if(Z.kind==="const")Y=`export declare const ${Z.name}: ${Z.type||c};
|
|
144
|
-
`;else Y=`export type ${Z.name} = ${Z.type||c};`;return`
|
|
145
|
-
${G2(Q)}
|
|
146
|
-
${Y}`}).join(`
|
|
147
|
-
`)}var b$=120;function F$($){let Q=`export default class ${$.moduleName==="default"?"":$.moduleName}${$.generic} extends SvelteComponentTyped<`,Y=[$.genericProps,$.events,$.slots];if($.accessors.trim()===""&&Y.every((j)=>!j.includes(`
|
|
148
|
-
`))){let j=`${Q}${Y.join(", ")}> {}`;if(j.length<=b$)return j}return`${Q}
|
|
149
|
-
${$.genericProps},
|
|
150
|
-
${$.events},
|
|
151
|
-
${$.slots}
|
|
152
|
-
> {
|
|
153
|
-
${$.accessors}
|
|
154
|
-
}`}function X2($,Z){let Q=A0($),{moduleName:Y,typedefs:j,generics:J,props:K,moduleExports:z,slots:U,events:H,rest_props:V,extends:X,componentComment:q,contexts:W,syntaxMode:L}=$,G=Z?.format==="component",B=J!==null,{props_name:I,prop_def:k}=V$({moduleName:Y,props:K,rest_props:V,extends:X,generics:J,slots:U,canonicalPropNames:new Set(Q?.canonicalPropNames??[]),canonicalPropsType:Q?.canonicalPropsType,events:G&&L==="legacy"?H:void 0}),M=J?`<${J[1]}>`:"",D=J?`${I}<${J[0]}>`:I,b=T$({moduleExports:z}),S=C0({typedefs:j}),x=T3({contexts:W,generics:J}),A=(Q?.typeImportStatements??[]).join(`
|
|
155
|
-
`),O=(Q?.localTypeDeclarations??[]).join(`
|
|
156
|
-
|
|
157
|
-
`),{exports_ref:R,exports_def:F}=G?O$({props:K,moduleName:Y,generics:J}):{exports_ref:y,exports_def:y},m=G?R$({props:K}):y,P=!Z$.test(A)&&$$.test(`${k}
|
|
158
|
-
${b}
|
|
159
|
-
${S}
|
|
160
|
-
${x}
|
|
161
|
-
${O}
|
|
162
|
-
${F}`),l3=V?.type==="Element"&&(V.name!=="svelte:element"||V.name==="svelte:element"&&V.thisValue),i3=V?.type==="Element"&&V.name==="svelte:element"&&!V.thisValue,p3=[G?B?`import type { SvelteComponent, ComponentConstructorOptions, ComponentInternals${P?", Snippet":""} } from "svelte";`:`import type { Component${P?", Snippet":""} } from "svelte";`:`import { SvelteComponentTyped${P?", type Snippet":""} } from "svelte";`,l3?'import type { SvelteHTMLElements } from "svelte/elements";':"",i3?'import type { HTMLAttributes } from "svelte/elements";':"",A,D$({extends:X})].filter(Boolean).join(`
|
|
163
|
-
`),a3=G?B?M$({moduleName:Y,generic:M,propsRef:D,exportsRef:R,bindings:m}):I$({moduleName:Y,propsRef:D,exportsRef:R,bindings:m}):F$({moduleName:Y,generic:M,genericProps:D,events:k$({events:H}),slots:G$({slots:U}),accessors:S3({props:K})}),r3=[b,S,O,x,k,F,[A$({componentComment:q}),a3].filter(Boolean).join(`
|
|
164
|
-
`)].map((s3)=>s3.trim()).filter(Boolean).join(`
|
|
165
|
-
|
|
166
|
-
`);return R3([p3,r3].filter(Boolean).join(`
|
|
167
|
-
|
|
168
|
-
`))}var q2=/`/g,y0=/\s+/g,g="--",N3=`| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |
|
|
169
|
-
| :- | :- | :- | :- | :- | :- | :- | :- |
|
|
170
|
-
`,_3=`| Slot name | Default | Props | Fallback | Description |
|
|
171
|
-
| :- | :- | :- | :- | :- |
|
|
172
|
-
`,w3=`| Event name | Type | Detail | Description |
|
|
173
|
-
| :- | :- | :- | :- |
|
|
174
|
-
`,x3=`| Name | Kind | Type | Description |
|
|
175
|
-
| :- | :- | :- | :- |
|
|
176
|
-
`,P0=/\|/g,S$=/</g,N$=/>/g,r=/\n/g;function l($){if($===void 0)return g;return`<code>${$.replace(P0,"|")}</code>`}function z0($){return $.replace(S$,"<").replace(N$,">")}function C3($){if($===void 0)return g;return`<code>${$.replace(q2,"\\`").replace(P0,"|")}</code>`}function g0($,Z){if(Z===void 0)return $;let Q=typeof Z==="string"&&Z.trim().length>0?`: ${z0(Z).replace(r," ").replace(P0,"|")}`:"";return`<s>${$}</s><br />**Deprecated**${Q}`}function E0($){if($===void 0||$.trim().length===0)return g;return z0($).replace(r,"<br />")}function y3($){if($===void 0||$==="{}")return g;return l(x0($).replace(r," "))}function P3($){if($===void 0)return g;return l(z0($).replace(r,"<br />"))}function g3($,Z){let Q=[];if($!==void 0&&$.trim().length>0)Q.push(z0($));for(let{name:Y,body:j}of Z??[]){let J=j?.trim();Q.push(J?`@${Y} ${z0(J)}`:`@${Y}`)}if(Q.length===0)return g;return Q.join(`
|
|
177
|
-
`).replace(P0,"|").replace(r,"<br />")}function E3($){if($===void 0)return g;return l($.replace(r," "))}function v3($,Z,Q){if($.append("h1","Component Index"),$.append("h2","Components").tableOfContents(),$.append("divider"),Q&&Q.length>0)_$($,Q);let Y=C(Z);for(let j of Y.components)w$($,j)}function _$($,Z){$.append("h2","Exports"),$.append("raw",x3);for(let Q of Z){let Y=(Q.type??Q.value)?.replace(y0," ").trim();$.append("raw",`| ${Q.name} | ${`<code>${Q.kind}</code>`} | ${l(Y)} | ${E0(Q.description)} |
|
|
178
|
-
`)}$.append("raw",`
|
|
179
|
-
`),$.append("divider")}function W2($,Z,Q,Y){if(Z.length>0)Q(),$.append("raw",`
|
|
180
|
-
`);else $.append("p",Y??"None.")}function w$($,Z){if($.append("h2",`\`${Z.moduleName}\``),Z.generics)$.append("p",`**Type parameters:** ${l(`<${Z.generics[1]}>`)}`);if(Z.typedefs.length>0)$.append("h3","Types").append("raw",`\`\`\`ts
|
|
181
|
-
${C0({typedefs:Z.typedefs})}
|
|
182
|
-
\`\`\`
|
|
183
|
-
|
|
184
|
-
`);$.append("h3","Props"),W2($,Z.props,()=>{$.append("raw",N3);let Q=[...Z.props].sort((Y)=>{if(Y.reactive)return-1;if(Y.constant)return 1;return 0});for(let Y of Q)$.append("raw",`| ${g0(Y.name,Y.deprecated)} | ${Y.isRequired?"Yes":"No"} | ${`<code>${Y.kind}</code>`} | ${Y.reactive?"Yes":"No"} | ${Y.binding??"--"} | ${l(Y.type)} | ${C3(Y.value)} | ${E0(Y.description)} |
|
|
185
|
-
`)}),$.append("h3","Slots"),W2($,Z.slots,()=>{$.append("raw",_3);for(let Q of Z.slots)$.append("raw",`| ${g0(Q.default?g:Q.name??g,Q.deprecated)} | ${Q.default?"Yes":"No"} | ${y3(Q.slot_props)} | ${P3(Q.fallback)} | ${g3(Q.description,Q.tags)} |
|
|
186
|
-
`)}),$.append("h3","Events"),W2($,Z.events,()=>{$.append("raw",w3);for(let Q of Z.events)$.append("raw",`| ${g0(Q.name,Q.deprecated)} | ${Q.type} | ${Q.type==="dispatched"?E3(Q.detail):g} | ${E0(Q.description)} |
|
|
187
|
-
`)})}class k2{sourceParts=[];hasToC=!1;toc=[];get source(){return this.sourceParts.join("")}appendLineBreaks(){return this.sourceParts.push(`
|
|
188
|
-
|
|
189
|
-
`),this}append($,Z){switch($){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{let Q=Number($.slice(-1));if(this.sourceParts.push(`${"#".repeat(Q)} ${Z}`),this.hasToC&&$==="h2")this.toc.push({indent:0,raw:Z??""});break}case"quote":this.sourceParts.push(`> ${Z}`);break;case"p":this.sourceParts.push(Z??"");break;case"divider":this.sourceParts.push("---");break;case"raw":this.sourceParts.push(Z??"");break}if($!=="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:Z,raw:Q})=>{return`${" ".repeat(Z)}- [${Q}](#${Q.toLowerCase().replace(q2,"").replace(y0,"-")})`}).join(`
|
|
190
|
-
`))}}class v0 extends _{onAppend;markdownBase;constructor($){super();this.onAppend=$.onAppend,this.markdownBase=new k2}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($,Z){return this.markdownBase.append($,Z),this.onAppend?.call(this,$,this),this}tableOfContents(){return this.markdownBase.tableOfContents(),this}end(){return this.markdownBase.end()}}function B2($,Z){let Q=new v0({onAppend:(Y,j)=>{Z.onAppend?.call(null,Y,j,$)}});return v3(Q,$,Z.entryExports),Q.end()}async function L2($,Z){let Q=Z?.write!==!1,Y=B2($,Z);if(Q){let j=x$(process.cwd(),Z.outFile);if(await new _({dryRun:Z.dryRun}).write(j,Y),!Z.dryRun)u(`created "${Z.outFile}".`)}return Y}import{join as m3}from"node:path";var f3=/\.svelte$/;function h3($){let Z=new Map;for(let[Y,j]of Object.entries($)){let J=Z.get(j.source)||[];J.push({id:Y,exportee:j}),Z.set(j.source,J)}let Q=[];for(let[Y,j]of Z){let J=f3.test(Y),K=j.some(({id:q,exportee:W})=>q!=="default"&&W.default),z=j.some(({exportee:q})=>!q.default),U=J&&K&&z,H=[],V=[],X=[];for(let{id:q,exportee:W}of j){if(q==="default"){V.push(`export { default } from "${Y}";`);continue}if(W.default)if(W.mixed)V.push(`export { default as ${q} } from "${Y}";`),V.push(`export { default } from "${Y}";`);else X.push(`default as ${q}`);else if(J&&!U)X.push(`default as ${q}`);else H.push(q)}if(X.length>0&&H.length>0)Q.push(`export { ${[...X,...H].join(", ")} } from "${Y}";`);else{if(H.length>0)Q.push(`export { ${H.join(", ")} } from "${Y}";`);if(X.length>0)Q.push(`export { ${X.join(", ")} } from "${Y}";`)}Q.push(...V)}return Q.join(`
|
|
191
|
-
`)}function u3($){return $.replace(f3,".svelte.d.ts")}async function O2($,Z){let Q=m3(process.cwd(),Z.outDir,"index.d.ts"),Y=new _({dryRun:Z.dryRun}),j=Z.preamble+h3(Z.exports),K=C($).components.map(async(z)=>{let U=u3(m3(Z.outDir,z.filePath));await Y.write(U,X2(z,{format:Z.format}))});if(await Promise.all([...K,Y.write(Q,`${j}
|
|
192
|
-
`)]),!Z.dryRun)u("created TypeScript definitions.")}s({name:"json",componentSet:"exported",write:J2});s({name:"markdown",componentSet:"exported",write:L2});s({name:"types",componentSet:"all",write:O2});s({name:"custom-elements",componentSet:"exported",write:Z2});var C$=50,y$=/\.svelte$/;function P$($){let Z=$?.watch===!0,Q,Y,j=null,J,K=new Set,z=async()=>{if(j==null||Y==null||K.size===0)return;let H=Array.from(K);K.clear();try{let{result:V}=await j.update(H);await U0(V,$||{},Y)}catch(V){console.error("sveld: failed to regenerate types in watch mode:",V)}},U=(H)=>{if(!Z||j==null||!y$.test(H))return;K.add(H),clearTimeout(J),J=setTimeout(z,C$)};return{name:"vite-plugin-sveld",apply:Z?void 0:"build",enforce:"post",async buildStart(){if(Y=F0($?.entry),Z&&Y!=null)j=await G3(Y,$?.glob===!0,$?.documentExports===!0),await U0(j.result,$||{},Y)},async generateBundle(){if(Z)return;if(Y!=null)Q=await J0(Y,$?.glob===!0,Q0($))},async writeBundle(){if(Z)return;if(Y!=null)await U0(Q,$||{},Y)},handleHotUpdate(H){U(H.file)},watchChange(H){U(H)}}}function f0($,Z,Q){let Y=c0($);if(!Y)throw Error(`sveld: built-in writer "${$}" is not registered.`);return Y.write(Z,Q)}async function U0($,Z,Q){let Y=c3(Q),j=Z?.dryRun===!0;if(Z?.types!==!1)await f0("types",$.allComponentsForTypes,{outDir:"types",preamble:"",...Z?.typesOptions,exports:$.exports,inputDir:Y,dryRun:j});if(Z?.json)await f0("json",$.components,{outFile:"COMPONENT_API.json",...Z?.jsonOptions,input:Q,inputDir:Y,entryExports:$.entryExports,dryRun:j});if(Z?.markdown)await f0("markdown",$.components,{outFile:"COMPONENT_INDEX.md",...Z?.markdownOptions,entryExports:$.entryExports,dryRun:j});if(Z?.customElements)await f0("custom-elements",$.components,{outFile:"custom-elements.json",...Z?.customElementsOptions,inputDir:Y,dryRun:j});let J=Object.entries(Z?.additionalWriters??{}).map(([K,z])=>{let U=c0(K);if(!U){console.warn(`sveld: no writer registered with name "${K}"; skipping.`);return}let H=U.componentSet==="all"?$.allComponentsForTypes:$.components;return U.write(H,z)});await Promise.all(J)}async function d3($,Z,Q){let Y=c3(Q);if(Z?.json){let j={...Z?.jsonOptions,inputDir:Y,entryExports:$.entryExports},J=Z.stdout==="ndjson"?k3($.components,j):j2($.components,j);process.stdout.write(J);return}if(Z?.markdown){let j=B2($.components,{...Z?.markdownOptions,entryExports:$.entryExports});process.stdout.write(j);return}if(Z?.customElements){let j=$2($.components,{...Z?.customElementsOptions,inputDir:Y});process.stdout.write(j)}}import{existsSync as g$}from"node:fs";import{join as E$}from"node:path";var R2="src/index.js",w={SUCCESS:0,USAGE_ERROR:1,GENERATION_FAILURE:2,BREAKING_CHANGE:3,DIAGNOSTICS:4},v$=`Usage: sveld [options]
|
|
193
|
-
|
|
194
|
-
Generate TypeScript definitions and component documentation for a Svelte
|
|
195
|
-
library. With no flags, only TypeScript definitions are generated for the
|
|
196
|
-
entry resolved from package.json#svelte.
|
|
197
|
-
|
|
198
|
-
--entry, --cache, --check, and --types-format accept their value as
|
|
199
|
-
--flag=value or as a separate --flag value argument.
|
|
200
|
-
|
|
201
|
-
Options:
|
|
202
|
-
--entry=<path> Entry point to uncompiled Svelte source (default: package.json "svelte" field)
|
|
203
|
-
--glob Analyze all *.svelte files instead of the entry barrel
|
|
204
|
-
--types Generate TypeScript definitions (default: true)
|
|
205
|
-
--json Generate component documentation in JSON format
|
|
206
|
-
--markdown Generate component documentation in Markdown format
|
|
207
|
-
--custom-elements Generate a Custom Elements Manifest (custom-elements.json)
|
|
208
|
-
--fail-fast Abort the run when a single component fails to parse
|
|
209
|
-
--dry-run Resolve, parse, and print "would write" lines for each output file instead of writing anything (including the parse cache)
|
|
210
|
-
--quiet Suppress progress logs (errors, the diagnostics summary, and the --check report are unaffected)
|
|
211
|
-
--stdout[=json|ndjson] Print the document from exactly one of --json, --markdown, or --custom-elements to stdout and write nothing to disk (rejects --types and --check); --stdout=ndjson prints one JSON object per component per line and requires --json
|
|
212
|
-
--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)
|
|
213
|
-
--resolve-types Expand opaque imported $props() types into JSON (alias: --resolveTypes, deprecated)
|
|
214
|
-
--check-examples Compile-check @example blocks against the TypeScript program (alias: --checkExamples, deprecated)
|
|
215
|
-
--report-diagnostics Print unresolved-type diagnostics to stderr
|
|
216
|
-
--strict Exit with code 1 when diagnostics exist (implies --report-diagnostics)
|
|
217
|
-
--types-format=<format> ".d.ts" output format: "class" (default) or "component" (Svelte 5 Component<...>)
|
|
218
|
-
--check[=<path>] Diff the parsed API against a committed snapshot; exit 1 on a breaking change (default path: COMPONENT_API.json)
|
|
219
|
-
--format=<text|json> Output format for the --check report and the diagnostics summary (default: text)
|
|
220
|
-
--help Print this help message and exit
|
|
221
|
-
--version Print the installed sveld version and exit
|
|
222
|
-
|
|
223
|
-
Exit codes:
|
|
224
|
-
0 success
|
|
225
|
-
1 usage or configuration error
|
|
226
|
-
2 generation failure
|
|
227
|
-
3 breaking API change detected by --check
|
|
228
|
-
4 diagnostics present under --strict
|
|
229
|
-
`,I2={resolveTypes:"resolve-types",checkExamples:"check-examples"},f$=["help","version","glob","types","json","markdown","quiet","stdout","custom-elements","strict","report-diagnostics","resolve-types","check-examples","fail-fast","entry","cache","check","types-format","format"],h$=[...f$,...Object.keys(I2)],u$=new Set(["glob","types","json","markdown","quiet","custom-elements","strict","report-diagnostics","resolve-types","check-examples","fail-fast"]),m$=new Set(["entry","cache","check","types-format"]),c$=new Set(["entry","types-format"]),d$=3;function l$($,Z){let Q=$.length+1,Y=Z.length+1,j=Array.from({length:Q},()=>Array(Y).fill(0));for(let J=0;J<Q;J++)j[J][0]=J;for(let J=0;J<Y;J++)j[0][J]=J;for(let J=1;J<Q;J++)for(let K=1;K<Y;K++){let z=$[J-1]===Z[K-1]?0:1;j[J][K]=Math.min(j[J-1][K]+1,j[J][K-1]+1,j[J-1][K-1]+z)}return j[Q-1][Y-1]}function i$($){let Z,Q=Number.POSITIVE_INFINITY;for(let Y of h$){let j=l$($,Y);if(j<Q)Z=Y,Q=j}if(Z===void 0||Q>d$)return;return I2[Z]??Z}function p$($,Z){let Q=$.indexOf("="),Y=Q===-1?$.slice(2):$.slice(2,Q),j=I2[Y]??Y,J=Q===-1?!0:$.slice(Q+1),K=!1;if(Q===-1&&m$.has(j)){if(Z!==void 0&&!Z.startsWith("--"))J=Z,K=!0;else if(c$.has(j))return{result:{kind:"usage-error",message:`sveld: --${j} requires a value (pass --${j}=<value> or --${j} <value>).`},consumedNext:!1,flag:j}}return{result:a$(j,J,$,Y),consumedNext:K,flag:j}}function a$($,Z,Q,Y){switch($){case"help":return{kind:"help"};case"version":return{kind:"version"};case"glob":case"types":case"json":case"markdown":case"quiet":return{kind:"option",option:{[$]:Z===!0||Z==="true"}};case"stdout":if(Z===!0||Z==="true")return{kind:"option",option:{stdout:!0}};if(Z==="false")return{kind:"option",option:{stdout:!1}};return{kind:"option",option:{stdout:Z}};case"custom-elements":return{kind:"option",option:{customElements:Z===!0||Z==="true"}};case"strict":return{kind:"option",option:{strict:Z===!0||Z==="true"}};case"report-diagnostics":return{kind:"option",option:{reportDiagnostics:Z===!0||Z==="true"}};case"resolve-types":return{kind:"option",option:{resolveTypes:Z===!0||Z==="true"}};case"check-examples":return{kind:"option",option:{checkExamples:Z===!0||Z==="true"}};case"fail-fast":return{kind:"option",option:{failFast:Z===!0||Z==="true"}};case"dry-run":return{kind:"option",option:{dryRun:Z===!0||Z==="true"}};case"entry":return typeof Z==="string"?{kind:"option",option:{entry:Z}}:{kind:"option",option:{}};case"cache":if(Z==="false")return{kind:"option",option:{cache:!1}};return{kind:"option",option:{cache:typeof Z==="string"?Z:!0}};case"check":if(Z==="false")return{kind:"option",option:{check:!1}};return{kind:"option",option:{check:typeof Z==="string"?Z:!0}};case"types-format":return typeof Z==="string"?{kind:"option",option:{typesOptions:{format:Z}}}:{kind:"option",option:{}};case"format":return typeof Z==="string"?{kind:"option",option:{format:Z}}:{kind:"option",option:{}};default:return{kind:"unknown",arg:Q,suggestion:i$(Y)}}}function r$($){let Z={},Q=!1;for(let Y=0;Y<$.length;Y++){let j=$[Y];if(!j.startsWith("--"))return{kind:"unknown",arg:j,positionalHint:Q?!0:void 0};let{result:J,consumedNext:K,flag:z}=p$(j,$[Y+1]);if(J.kind!=="option")return J;if(Object.assign(Z,J.option),Q=u$.has(z),K)Y++}return{kind:"options",options:Z}}async function a7($){let Z=r$($.argv.slice(2));if(Z.kind==="help"){console.log(v$);return}if(Z.kind==="version"){console.log(D2.version);return}if(Z.kind==="usage-error"){console.error(Z.message),$.exitCode=w.USAGE_ERROR;return}if(Z.kind==="unknown"){let q=`Unknown flag: ${Z.arg}`;if(Z.suggestion)q+=` Did you mean --${Z.suggestion}?`;if(Z.positionalHint)q+=" (values are passed as --flag=value or --flag value)";console.error(q),console.error("Run sveld --help for a list of available flags."),$.exitCode=w.USAGE_ERROR;return}let Q=Z.options,Y=await y2(),j=P2(Y,Q);if(Y.typesOptions||Q.typesOptions)j.typesOptions={...Y.typesOptions,...Q.typesOptions};if(j.stdout){if(j.stdout!==!0&&j.stdout!=="json"&&j.stdout!=="ndjson"){console.error(`sveld: --stdout must be "json" or "ndjson"; got "${j.stdout}".`),$.exitCode=w.USAGE_ERROR;return}if([j.json,j.markdown,j.customElements].filter(Boolean).length!==1){console.error("sveld: --stdout requires exactly one of --json, --markdown, or --custom-elements."),$.exitCode=w.USAGE_ERROR;return}if(j.stdout==="ndjson"&&!j.json){console.error("sveld: --stdout=ndjson is only valid with --json."),$.exitCode=w.USAGE_ERROR;return}if(j.types===!0){console.error("sveld: --stdout cannot be combined with --types; type definitions span multiple files."),$.exitCode=w.USAGE_ERROR;return}if(j.check){console.error("sveld: --stdout cannot be combined with --check; both write their document to stdout."),$.exitCode=w.USAGE_ERROR;return}}if(j.format!==void 0&&j.format!=="text"&&j.format!=="json"){console.error(`sveld: --format must be "text" or "json"; got "${j.format}".`),$.exitCode=w.USAGE_ERROR;return}q3(j.quiet===!0);let J=F0(j.entry),K;if(J!==null)K=J;else if(g$(E$($.cwd(),R2)))console.error(`sveld: could not resolve an entry point; falling back to "${R2}". Set package.json#svelte (or pass --entry) to avoid relying on this fallback.`),K=n(N(R2));else{$.exitCode=w.USAGE_ERROR;return}let z,U;try{if(z=await J0(K,j.glob===!0,Q0(j)),j.check)U=await w2(z.components,_2(j),{entryExports:z.entryExports});if(j.stdout)await d3(z,j,K);else await U0(z,j,K)}catch(q){console.error(q instanceof Error?q.message:String(q)),$.exitCode=w.GENERATION_FAILURE;return}let{diagnostics:H}=z;if((j.reportDiagnostics||j.strict)&&H.length>0)if(j.format==="json")$.stderr.write(E2(H));else console.error(g2(H));if(U)if(j.format==="json")$.stdout.write(C2(U));else console.log(x2(U));let X;if(U?.bump==="major")X=w.BREAKING_CHANGE;if(j.strict&&H.length>0)X=X===void 0?w.DIAGNOSTICS:Math.min(X,w.DIAGNOSTICS);if(X!==void 0)$.exitCode=X}
|
|
230
|
-
export{C as a,K1 as b,_2 as c,w2 as d,x2 as e,C2 as f,g2 as g,F0 as h,X4 as i,y2 as j,P2 as k,Q0 as l,J0 as m,s as n,c0 as o,W4 as p,P$ as q,U0 as r,a7 as s};
|
package/lib/chunk-r4rrncmd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as a,X as b}from"./chunk-as5hgj7e.js";import"./chunk-tmj7vnjr.js";import"./chunk-t9d5k3p7.js";export{b as parseModernAndLegacy,a as parse};
|