sveld 0.36.2 → 0.36.3
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 +131 -131
- package/lib/{chunk-denfbw92.js → chunk-120ekvgm.js} +1 -1
- package/lib/{chunk-dcbq3977.js → chunk-5fcp13rt.js} +2 -2
- package/lib/{chunk-290pdrzm.js → chunk-5pnev3w1.js} +10 -10
- package/lib/chunk-8avj9zpd.js +3 -0
- package/lib/{chunk-gc8z6pa7.js → chunk-9vv4gm0m.js} +2 -2
- package/lib/chunk-bng0x7cd.js +1 -0
- package/lib/chunk-eagrqdtg.js +1 -0
- package/lib/chunk-fwfazckg.js +4 -0
- package/lib/{chunk-t9d5k3p7.js → chunk-ndh639r1.js} +1 -1
- package/lib/chunk-vq3vjgvs.js +230 -0
- package/lib/chunk-zd76tr9f.js +6 -0
- package/lib/cli-entry.js +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/lib/chunk-4mbjcdex.js +0 -230
- package/lib/chunk-8myyzjb1.js +0 -4
- package/lib/chunk-f7112d82.js +0 -1
- package/lib/chunk-h1r040pg.js +0 -6
- package/lib/chunk-w5kk4gd1.js +0 -1
- package/lib/chunk-xryt7ad2.js +0 -3
package/lib/chunk-4mbjcdex.js
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import{E as lj,F as Aj,G as J1,T as _j,u as l,x as e0}from"./chunk-8myyzjb1.js";import{$ as Y1}from"./chunk-dcbq3977.js";import{ba as w,ca as wj,da as h}from"./chunk-xryt7ad2.js";import{ha as rj}from"./chunk-t9d5k3p7.js";var b0="sveld",Gj="0.36.2";var D0={name:b0,version:Gj,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.7","@types/bun":"^1.3.14","@types/jest":"^30.0.0","@typescript/typescript6":"^6.0.2",acorn:"^8.18.0","comment-parser":"^1.4.7",culls:"^0.2.0","estree-walker":"^3.0.3",svelte:"^5.56.8",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 n="5.56.8";var Xj=1,A0=new WeakMap;function g(j,$={}){let Z=A0.get(j),Q=Z?.get($.entryExports);if(Q)return Q;let Y=Array.from(j,([,K])=>{let{diagnostics:U,...H}=K;return H}).sort((K,U)=>K.moduleName.localeCompare(U.moduleName)),J={schemaVersion:Xj,generator:{name:b0,version:Gj,svelteVersion:n},total:Y.length,components:Y};if($.entryExports&&$.entryExports.length>0)J.totalExports=$.entryExports.length,J.exports=$.entryExports;if(!Z)Z=new Map,A0.set(j,Z);return Z.set($.entryExports,J),J}import{readFile as t1}from"node:fs/promises";import o1 from"node:path";var T0={none:0,patch:1,minor:2,major:3};function e1(j,$){return T0[$]>T0[j]?$:j}function j2(j){return j.reduce(($,Z)=>e1($,Z.bump),"none")}function F0(j){let $=[],Z=0,Q="",Y=null;for(let J=0;J<j.length;J++){let K=j[J];if(Y){if(Q+=K,K==="\\")J++,Q+=j[J]??"";else if(K===Y)Y=null;continue}if(K==='"'||K==="'"||K==="`"){Y=K,Q+=K;continue}if(K==="<"||K==="("||K==="{"||K==="[")Z++;if(K===">"||K===")"||K==="}"||K==="]")Z--;if(K==="|"&&Z===0){$.push(Q.trim()),Q="";continue}Q+=K}return $.push(Q.trim()),new Set($.filter((J)=>J.length>0))}function mj(j,$){if(j===$)return"none";if(j===void 0||$===void 0)return"major";let Z=F0(j),Q=F0($),Y=[...Q].some((K)=>!Z.has(K)),J=[...Z].some((K)=>!Q.has(K));if(!Y&&!J)return"none";if(Y&&!J)return"minor";if(J&&!Y)return"major";return"major"}function S0(j,$,Z,Q){let Y=$==="prop"?"prop":"export",J=[],K=new Map(Z.map((H)=>[H.name,H])),U=new Map(Q.map((H)=>[H.name,H]));for(let[H,z]of U){if(K.has(H))continue;J.push({component:j,kind:$,name:H,bump:z.isRequired?"major":"minor",message:`${Y} "${H}" added${z.isRequired?" (required)":""}`})}for(let[H]of K){if(U.has(H))continue;J.push({component:j,kind:$,name:H,bump:"major",message:`${Y} "${H}" removed`})}for(let[H,z]of K){let V=U.get(H);if(!V)continue;if(z.isRequired!==V.isRequired)J.push({component:j,kind:$,name:H,bump:V.isRequired?"major":"minor",message:`${Y} "${H}" became ${V.isRequired?"required":"optional"}`});let G=mj(z.type,V.type);if(G!=="none")J.push({component:j,kind:$,name:H,bump:G,message:`${Y} "${H}" type changed from \`${z.type??"unknown"}\` to \`${V.type??"unknown"}\``})}return J}function $2(j,$,Z){let Q=[],Y=new Map($.map((K)=>[K.name,K])),J=new Map(Z.map((K)=>[K.name,K]));for(let[K]of J){if(Y.has(K))continue;Q.push({component:j,kind:"event",name:K,bump:"minor",message:`event "${K}" added`})}for(let[K]of Y){if(J.has(K))continue;Q.push({component:j,kind:"event",name:K,bump:"major",message:`event "${K}" removed`})}for(let[K,U]of Y){let H=J.get(K);if(!H)continue;if(U.type!==H.type){Q.push({component:j,kind:"event",name:K,bump:"major",message:`event "${K}" changed from ${U.type} to ${H.type}`});continue}let z=U.type==="dispatched"?U.detail:void 0,V=H.type==="dispatched"?H.detail:void 0,G=mj(z,V);if(G!=="none")Q.push({component:j,kind:"event",name:K,bump:G,message:`event "${K}" detail changed from \`${z??"unknown"}\` to \`${V??"unknown"}\``})}return Q}function w0(j){return j.name??"default"}function Z2(j,$,Z){let Q=[],Y=new Map($.map((K)=>[w0(K),K])),J=new Map(Z.map((K)=>[w0(K),K]));for(let[K]of J){if(Y.has(K))continue;Q.push({component:j,kind:"slot",name:K,bump:"minor",message:`slot "${K}" added`})}for(let[K]of Y){if(J.has(K))continue;Q.push({component:j,kind:"slot",name:K,bump:"major",message:`slot "${K}" removed`})}for(let[K,U]of Y){let H=J.get(K);if(!H)continue;let z=mj(U.slot_props,H.slot_props);if(z!=="none")Q.push({component:j,kind:"slot",name:K,bump:z,message:`slot "${K}" props changed from \`${U.slot_props??"none"}\` to \`${H.slot_props??"none"}\``})}return Q}var Q2=new Set(["description","source","componentCommentSource","tags"]);function Wj(j){if(Array.isArray(j))return j.map(Wj);if(j!==null&&typeof j==="object"){let $={};for(let[Z,Q]of Object.entries(j)){if(Q2.has(Z))continue;$[Z]=Wj(Q)}return $}return j}var Y2=["generics","rest_props","extends","contexts","typedefs"];function J2(j,$,Z){let Q=[];for(let Y of Y2){let J=JSON.stringify(Wj($[Y])),K=JSON.stringify(Wj(Z[Y]));if(J!==K)Q.push({component:j,kind:"shape",name:Y,bump:"major",message:`"${Y}" changed (breaking)`})}return Q}function K2(j,$){let Z=$.moduleName;return[...S0(Z,"prop",j.props,$.props),...S0(Z,"moduleExport",j.moduleExports,$.moduleExports),...$2(Z,j.events,$.events),...Z2(Z,j.slots,$.slots),...J2(Z,j,$)]}function z2(j,$){let Z=[],Q=new Map(j.components.map((J)=>[J.moduleName,J])),Y=new Map($.components.map((J)=>[J.moduleName,J]));for(let[J]of Y){if(Q.has(J))continue;Z.push({component:J,kind:"component",bump:"minor",message:`component "${J}" added`})}for(let[J]of Q){if(Y.has(J))continue;Z.push({component:J,kind:"component",bump:"major",message:`component "${J}" removed`})}for(let[J,K]of Q){let U=Y.get(J);if(!U)continue;Z.push(...K2(K,U))}return Z}async function U2(j){let $;try{$=await t1(o1.resolve(j),"utf-8")}catch(Z){if(Z.code==="ENOENT")return null;throw Z}try{return JSON.parse($)}catch{throw Error(`sveld: could not parse "${j}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function _0(j){if(typeof j.check==="string")return j.check;return j.jsonOptions?.outFile??"COMPONENT_API.json"}async function N0(j,$,Z={}){let Q=await U2($);if(Q===null)return{snapshotExists:!1,snapshotFile:$,changes:[],bump:"none"};if(Q.schemaVersion!==Xj)return{snapshotExists:!0,snapshotFile:$,changes:[{component:"*",kind:"shape",bump:"none",message:`snapshot schemaVersion ${Q.schemaVersion} does not match the current schemaVersion ${Xj}; skipping diff`}],bump:"none"};let Y=g(j,{entryExports:Z.entryExports}),J=z2(Q,Y);return{snapshotExists:!0,snapshotFile:$,changes:J,bump:j2(J)}}var H2={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function y0(j){if(!j.snapshotExists)return`sveld --check: no snapshot found at "${j.snapshotFile}". Run \`sveld --json\` and commit the output first.`;if(j.changes.length===0)return`sveld --check: no API changes detected against "${j.snapshotFile}".`;let $=[],Z=j.changes.length;$.push(`sveld --check: ${Z} API change${Z===1?"":"s"} detected against "${j.snapshotFile}".`),$.push(`Suggested semver bump: ${j.bump}.`);let Q=new Map;for(let Y of j.changes){let J=Q.get(Y.component)??[];J.push(Y),Q.set(Y.component,J)}for(let[Y,J]of Q){$.push(""),$.push(` ${Y}`);for(let K of J)$.push(` [${H2[K.bump]}] ${K.message}`)}return $.join(`
|
|
2
|
-
`)}function x0(j){let $={kind:"check-report",...j};return h($)}import{existsSync as V2}from"node:fs";import{join as q2}from"node:path";import{pathToFileURL as G2}from"node:url";var X2=["sveld.config.js","sveld.config.mjs","sveld.config.ts"];function k4(j){return j}function W2(j=process.cwd()){for(let $ of X2){let Z=q2(j,$);if(V2(Z))return Z}return null}async function k2(j){let $;try{$=await import(`${G2(j).href}?t=${Date.now()}`)}catch(Q){let Y=Q instanceof Error?Q.message:String(Q);throw Error(`sveld: failed to load config file "${j}".
|
|
3
|
-
${Y}`)}let Z=$.default;if(!l(Z)||Array.isArray(Z))throw Error(`sveld: config file "${j}" must export a configuration object as its default export. Did you forget \`export default defineConfig({ ... })\`?`);return Z}async function g0(j=process.cwd()){let $=W2(j);if($===null)return{};return k2($)}function C0(...j){return Object.assign({},...j.filter(Boolean))}var cj=new Map;function t(j){cj.set(j.name,j)}function dj(j){return cj.get(j)}function O4(){return Array.from(cj.values())}import{dirname as d1}from"node:path";import{lstatSync as K1,readdirSync as Y5,readFileSync as J5,realpathSync as K5,statSync as z5}from"node:fs";import{readFile as U5}from"node:fs/promises";import{dirname as H5,isAbsolute as V5,join as q5,parse as ej,relative as G5,resolve as Qj}from"node:path";function o(j){return j}function u(j){if(j==="")return j;return j.startsWith(".")?j:`./${j}`}import{dirname as B2,resolve as O2}from"node:path";var R2=/\.svelte$/,L2=/^(['"])(.*)\1$/;function I2(j,$){let Z=j.extends?.import;if(Z===void 0)return null;let Q=Z.replace(L2,"$2");if(!R2.test(Q))return null;return O2(B2($),Q)}function e(j,$){let Z=new Map;for(let Q of j.values()){let Y=$(Q.filePath),J=I2(Q,Y);if(J===null)continue;let K=Z.get(J);if(K===void 0)K=new Set,Z.set(J,K);K.add(Y)}return Z}function kj(j,$){let Z=new Set,Q=[];for(let Y of j)if(!Z.has(Y))Z.add(Y),Q.push(Y);while(Q.length>0){let Y=Q.shift(),J=$.get(Y);if(J===void 0)continue;for(let K of J)if(!Z.has(K))Z.add(K),Q.push(K)}return Z}var M2={"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"},b2=["prop-unknown-type","context-any-type","event-no-source","example-compile-error","syntax-skipped"];function Bj(j){let $=new Set,Z=[];for(let Q of j){let Y=`${Q.component}:${Q.kind}:${Q.name}`;if($.has(Y))continue;$.add(Y),Z.push(Q)}return Z}function E0(j){if(j.length===0)return"sveld: all types resolved.";let $=[],Z=j.length;$.push(`sveld: ${Z} unresolved type${Z===1?"":"s"} found.`);for(let Q of b2){let Y=j.filter((K)=>K.kind===Q);if(Y.length===0)continue;$.push(""),$.push(`${M2[Q]} (${Y.length}):`);let J=new Map;for(let K of Y){let U=J.get(K.component)??[];U.push(K),J.set(K.component,U)}for(let[K,U]of J){$.push(` ${K}`);for(let H of U){let z=H.source?` (${K}:${H.source.start.line}:${H.source.start.column})`:"";$.push(` - ${H.message}${z}`)}}}return $.join(`
|
|
4
|
-
`)}function P0(j){return h({kind:"diagnostics",diagnostics:j})}var D2=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,A2=new Set(["","js","jsx","ts","tsx","javascript","typescript"]);function T2(j){let $=j.trim();if($==="")return null;let Z=$.match(D2);if(Z){let Q=Z[1].toLowerCase();if(!A2.has(Q))return null;let Y=Z[2].trim();return Y===""?null:Y}if($.startsWith("<"))return null;return $}function v0(j){if(!j.isFunction)return"any";return`(${(j.params??[]).map((Z)=>`${Z.name}${Z.optional?"?":""}: any`).join(", ")}) => any`}function Oj(j,$,Z,Q,Y){let J=(j??[]).filter((U)=>U.name==="example"),K=[];return J.forEach((U,H)=>{let z=T2(U.body);if(z===null)return;let V=J.length>1;K.push({id:V?`${$}#${H}`:$,name:V?`${Z} (example ${H+1})`:Z,type:Q,code:z,...Y?{source:Y}:{}})}),K}function f0(j){return j.name??"default"}function h0(j){let $=[];for(let Z of j.props)$.push(...Oj(Z.tags,`prop:${Z.name}`,Z.name,v0(Z),Z.source));for(let Z of j.moduleExports)$.push(...Oj(Z.tags,`export:${Z.name}`,Z.name,v0(Z),Z.source));for(let Z of j.slots)$.push(...Oj(Z.tags,`slot:${f0(Z)}`,f0(Z),"any",Z.source));for(let Z of j.events)$.push(...Oj(Z.tags,`event:${Z.name}`,Z.name,"any",Z.source));return $}import{createHash as F2}from"node:crypto";import{mkdirSync as S2,readFileSync as w2,writeFileSync as _2}from"node:fs";import{dirname as N2,isAbsolute as y2,join as x2,resolve as u0}from"node:path";var ij=2,g2=x2("node_modules",".cache","sveld","parse-cache.json");function pj(){return`${Gj}+svelte@${n}`}function c0(j,$){if(typeof $==="string")return y2($)?$:u0(j,$);return u0(j,g2)}function d0(j){return F2("sha256").update(j).digest("hex")}function m0(){return{formatVersion:ij,toolchainVersion:pj(),entries:{}}}function C2(j){try{let $=w2(j,"utf-8"),Z=JSON.parse($);if(Z.formatVersion!==ij||Z.toolchainVersion!==pj())return m0();return Z}catch{return m0()}}class sj{cacheFilePath;file;next=new Map;blocked=new Set;constructor(j){this.cacheFilePath=j,this.file=C2(j)}has(j,$){if(this.blocked.has(j))return!1;let Z=this.file.entries[j];return Z!==void 0&&Z.hash===$}get(j,$){if(this.blocked.has(j))return null;let Z=this.file.entries[j];if(Z===void 0||Z.hash!==$)return null;if(this.next.set(j,Z),Z.typeScriptMetadata!==void 0)Z.parsed[lj]=Z.typeScriptMetadata;return Z.parsed}set(j,$,Z){this.next.set(j,{hash:$,parsed:Z,typeScriptMetadata:Z[lj]})}invalidate(j){this.blocked.add(j)}getGeneratedText(j,$){let Z=this.next.get(j);if(Z?.generatedText===void 0||Z.generatedText.format!==$)return;return Z.generatedText.text}setGeneratedText(j,$,Z){let Q=this.next.get(j);if(Q===void 0)return;Q.generatedText={format:$,text:Z}}save(){S2(N2(this.cacheFilePath),{recursive:!0});let j={formatVersion:ij,toolchainVersion:pj(),entries:Object.fromEntries(this.next)};_2(this.cacheFilePath,JSON.stringify(j))}}import{existsSync as Mj,lstatSync as r0,readFileSync as c2}from"node:fs";import{dirname as j1,join as d2,relative as l2,resolve as $1}from"node:path";var p=null,aj=null;function s(){if(p)return Promise.resolve(p);if(!aj)aj=Promise.all([import("./chunk-w5kk4gd1.js"),import("./chunk-f7112d82.js")]).then(([j,$])=>{return p={ComponentParser:j.default,parseSvelte:$.parse},p});return aj}function Rj(){if(!p)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return p}import{existsSync as s0,readFileSync as E2}from"node:fs";import{dirname as nj,isAbsolute as P2,join as v2,relative as f2,resolve as Ij}from"node:path";function l0(j){if(!l(j))return{};let $=j.svelte;return typeof $==="string"?{svelte:$}:{}}function i0(j){if(!l(j))return{};let $={};if(typeof j.extends==="string")$.extends=j.extends;if(l(j.compilerOptions)){let Z={};if(typeof j.compilerOptions.baseUrl==="string")Z.baseUrl=j.compilerOptions.baseUrl;if(l(j.compilerOptions.paths)){let Q={};for(let[Y,J]of Object.entries(j.compilerOptions.paths))if(Array.isArray(J)&&J.every((K)=>typeof K==="string"))Q[Y]=J;if(Object.keys(Q).length>0)Z.paths=Q}if(Object.keys(Z).length>0)$.compilerOptions=Z}return $}var Lj=new Map,p0=new Map,h2=/\/\*[\s\S]*?\*\/|\/\/.*/g,u2=/[.+?^${}()|[\]\\]/g;function m2(j){let $=j,Z=Ij($,"/");while($!==Z){for(let Q of["tsconfig.json","jsconfig.json"]){let Y=v2($,Q);if(s0(Y))return Y}$=nj($)}return null}function a0(j){if(Lj.has(j))return Lj.get(j)??null;try{let $=E2(j,"utf-8"),Z;try{Z=JSON.parse($)}catch{let Y=$.replace(h2,"");Z=JSON.parse(Y)}let Q=i0(Z);if(Q.extends){let Y=P2(Q.extends)?Q.extends:Ij(nj(j),Q.extends),J=Y.endsWith(".json")?Y:`${Y}.json`;if(s0(J)){let K=a0(J);if(K)Q.compilerOptions={...K.compilerOptions,...Q.compilerOptions,paths:{...K.compilerOptions?.paths,...Q.compilerOptions?.paths}}}}return Lj.set(j,Q),Q}catch{return Lj.set(j,null),null}}function jj(j,$){if(j.startsWith(".")||j.startsWith("/"))return j;let Z=m2($);if(!Z)return j;let Q=a0(Z);if(!Q?.compilerOptions?.paths)return j;let{baseUrl:Y=".",paths:J}=Q.compilerOptions,K=nj(Z),U=Ij(K,Y);for(let[H,z]of Object.entries(J)){let V=p0.get(H);if(!V){let X=H.split("*").map((W)=>W.replace(u2,"\\$&")).join("(.*)");V=new RegExp(`^${X}$`),p0.set(H,V)}let G=j.match(V);if(G){let X=z[0];if(!X)continue;let W=X;for(let q=1;q<G.length;q++)W=W.replace("*",G[q]);return Ij(U,W)}}return j}function $j(j,$){if(j.startsWith(".")||j.startsWith("/"))return j;let Z=jj(j,$);if(Z===j)return j;let Q=f2($,Z);return Q=w(Q),Q.startsWith(".")?Q:`./${Q}`}var n0=[".ts",".mts",".cts",".tsx",".js",".mjs",".cjs",".jsx",".d.ts"],i2=/\r?\n/,p2=/^\s*\*+/;function T(j){return j&&typeof j==="object"?j:void 0}function Zj(j){return Array.isArray(j)?j:[]}function f(j){return e0(j)?j.name:void 0}function tj(j,$){let Z=jj(j,$),Q=$1($,Z);if(Mj(Q)&&r0(Q).isFile())return Q;for(let Y of n0){let J=Q+Y;if(Mj(J))return J}if(Mj(Q)&&r0(Q).isDirectory())for(let Y of n0){let J=d2(Q,`index${Y}`);if(Mj(J))return J}return null}function s2(j,$){let Z=j.slice(0,$).trimEnd();if(!Z.endsWith("*/"))return;let Q=Z.length-2,Y=Z.lastIndexOf("/**",Q);if(Y===-1)return;let J=[];for(let K of Z.slice(Y+3,Q).split(i2)){let U=K.replace(p2,"").trim();if(U.startsWith("@"))break;if(U)J.push(U)}return J.join(" ")||void 0}function a(j,$){if(!$)return;return j.text.slice($.start,$.end)}function a2(j,$){let Z=T($?.typeAnnotation);if(Z?.type!=="TSTypeAnnotation")return;return a(j,T(Z.typeAnnotation))}function t0(j,$){let Z=Zj($.params).map((J)=>a(j,J)??"").join(", "),Q=T($.returnType),Y=Q?.type==="TSTypeAnnotation"?a(j,T(Q.typeAnnotation)):void 0;return`(${Z})${Y?` => ${Y}`:""}`}function r2(j){if(j.type==="Literal"){let $=j.value;if(typeof $==="string")return"string";if(typeof $==="number")return"number";if(typeof $==="boolean")return"boolean"}if(j.type==="TemplateLiteral")return"string";return}function o0(j,$,Z){let Q=j.filePath,Y=s2(j.text,Z);if($.type==="VariableDeclaration"){let J=$.kind??"const",K=[];for(let U of Zj($.declarations)){let H=T(U.id),z=f(H);if(!z)continue;let V=a2(j,H),G,X=T(U.init);if(X){if(X.type==="ArrowFunctionExpression"||X.type==="FunctionExpression"){if(!V)V=t0(j,X)}else if(G=a(j,X),!V)V=r2(X)}K.push({name:z,kind:J,type:V,value:G,description:Y,declFile:Q,isTypeOnly:!1})}return K}if($.type==="FunctionDeclaration"){let J=f(T($.id));if(!J)return[];return[{name:J,kind:"function",type:t0(j,$),description:Y,declFile:Q,isTypeOnly:!1}]}if($.type==="ClassDeclaration"){let J=f(T($.id));if(!J)return[];return[{name:J,kind:"class",type:J,description:Y,declFile:Q,isTypeOnly:!1}]}if($.type==="TSTypeAliasDeclaration"){let J=f(T($.id));if(!J)return[];return[{name:J,kind:"type",type:a(j,T($.typeAnnotation)),description:Y,declFile:Q,isTypeOnly:!0}]}if($.type==="TSInterfaceDeclaration"){let J=f(T($.id));if(!J)return[];return[{name:J,kind:"interface",type:a(j,T($.body)),description:Y,declFile:Q,isTypeOnly:!0}]}if($.type==="TSEnumDeclaration"){let J=f(T($.id));if(!J)return[];return[{name:J,kind:"enum",type:J,description:Y,declFile:Q,isTypeOnly:!1}]}return[]}function n2(j){let $;try{$=c2(j,"utf-8")}catch{return null}let Z=`<script lang="ts">
|
|
5
|
-
${$}
|
|
6
|
-
</script>`;try{let Q=Rj().parseSvelte(Z,{modern:!0}),Y=Zj(Q.instance?.content?.body);return{source:{text:Z,filePath:j,dir:j1(j)},body:Y}}catch(Q){let Y=Q instanceof Error?Q.message:String(Q);return console.warn(`Warning: Failed to parse entry export module ${j}: ${Y}`),null}}function t2(j,$){for(let Z of j){if(Z.type!=="ImportDeclaration")continue;let Q=T(Z.source)?.value;if(typeof Q!=="string")continue;for(let Y of Zj(Z.specifiers)){if(Y.type!=="ImportSpecifier")continue;if(f(T(Y.local))===$){let J=f(T(Y.imported))??$;return{specifier:Q,importedName:J}}}}return null}function bj(j,$){let Z=$.cache.get(j);if(Z)return Z;if($.computing.has(j))return[];$.computing.add(j);let Q=n2(j);if(!Q)return $.computing.delete(j),$.cache.set(j,[]),[];let{source:Y,body:J}=Q,K=[],U=new Map;for(let z of J){let V=z.type==="ExportNamedDeclaration"?T(z.declaration):z;if(!V)continue;for(let G of o0(Y,V,V.start))U.set(G.name,G)}let H=(z)=>{let V=U.get(z);if(V)return V;let G=t2(J,z);if(!G||G.specifier.endsWith(".svelte"))return null;let X=tj(G.specifier,Y.dir);if(!X)return null;return bj(X,$).find((W)=>W.name===G.importedName)??null};for(let z of J){if(z.type==="ExportAllDeclaration"){let O=T(z.source)?.value;if(typeof O!=="string"||O.endsWith(".svelte"))continue;let q=tj(O,Y.dir);if(!q)continue;let B=z.exportKind==="type";for(let R of bj(q,$))K.push(B?{...R,isTypeOnly:!0}:R);continue}if(z.type!=="ExportNamedDeclaration")continue;let V=T(z.declaration);if(V){K.push(...o0(Y,V,z.start));continue}let G=T(z.source)?.value,X=typeof G==="string"?G:void 0;if(X?.endsWith(".svelte"))continue;let W=z.exportKind==="type";for(let O of Zj(z.specifiers)){if(O.type!=="ExportSpecifier")continue;let q=f(T(O.exported)),B=f(T(O.local));if(!q||!B||B==="default"||q==="default")continue;let R=W||O.exportKind==="type",k=null;if(X){let M=tj(X,Y.dir);if(M)k=bj(M,$).find((b)=>b.name===B)??null}else k=H(B);if(k?.declFile.endsWith(".svelte"))continue;if(k)K.push({...k,name:q,isTypeOnly:k.isTypeOnly||R});else K.push({name:q,kind:R?"type":"const",declFile:j,isTypeOnly:R})}}return $.computing.delete(j),$.cache.set(j,K),K}async function Dj(j){await s();let $=$1(j),Z=j1($),Q=bj($,{cache:new Map,computing:new Set}),Y=new Map;for(let J of Q){let{declFile:K,...U}=J,H=w(`./${l2(Z,K)}`);Y.set(J.name,{...U,source:H})}return Array.from(Y.values()).sort((J,K)=>J.name.localeCompare(K.name))}import{lstatSync as o2,readdirSync as e2,readFileSync as j5}from"node:fs";import{dirname as $5,join as Z1,resolve as Z5}from"node:path";var Q1=new Map;function Q5(j){return Y1(j,{ecmaVersion:"latest",sourceType:"module"})}function oj(j,$,Z=new Set){let Q=Q1.get(j);if(!Q)Q=Q5(j),Q1.set(j,Q);let Y={};for(let J of Q.body)if(J.type==="ExportDefaultDeclaration"){let K=J.declaration.name;if(K in Y)Y[K].default=!0;else Y[K]={source:u(""),default:!0}}else if(J.type==="ExportAllDeclaration"){if(!J.source)continue;let K=jj(J.source.value,$),U=Z5($,K);if(!o2(U).isFile()){let V=e2(U);for(let G of V)if(G.includes("index")){U=Z1(U,G);break}}if(Z.has(U))continue;Z.add(U);let H=j5(U,"utf-8"),z=oj(H,$5(U),Z);Z.delete(U);for(let[V,G]of Object.entries(z)){let X=u(w(`./${Z1(J.source.value,G.source)}`));Y[V]={...G,source:X}}}else if(J.type==="ExportNamedDeclaration")for(let K of J.specifiers){let U=K.exported.name,H=K.local.name,z=U||H;if(z in Y){if(J.type==="ExportNamedDeclaration")Y[z].mixed=!0;if(!Y[z].source)Y[z].source=u($j(J.source?.value??"",$))}else Y[z]={source:u($j(J.source?.value??"",$)),default:H==="default"}}else if(J.type==="ImportDeclaration"){let K=J.specifiers[0].local.name;if(K in Y){if(!Y[K].source)Y[K].source=u($j(J.source?.value??"",$))}else Y[K]={source:u($j(J.source?.value??"",$)),default:K==="default"}}return Y}function Yj(j){return{failFast:j?.failFast,resolveTypes:j?.resolveTypes===!0,documentExports:j?.documentExports===!0,cache:j?.cache,checkExamples:j?.checkExamples===!0,dryRun:j?.dryRun===!0}}var X5=/-/g;function z1(j,$=[],Z=new Set){let Q;try{let Y=K5(j);if(Z.has(Y))return $;Z.add(Y),Q=Y5(j,{withFileTypes:!0})}catch{return $}for(let Y of Q){if(Y.name.startsWith("."))continue;let J=q5(j,Y.name),K=Y.isSymbolicLink()?z5(J,{throwIfNoEntry:!1}):Y;if(!K)continue;if(K.isDirectory())z1(J,$,Z);else if(K.isFile()&&Y.name.endsWith(".svelte"))$.push(J)}return $}function j0(j){return z1(j).map(($)=>{let Z=ej($).name.replace(X5,""),Q=u(w(`./${G5(j,$)}`));return{moduleName:Z,source:Q}})}function Tj(j,$,Z=!1){let Q=K1(j).isFile(),Y=Q?H5(j):j,J=Qj(Y),K=(z)=>V5(z)?Qj(z):Qj(J,z),U={};if(Q){let z=J5(j,"utf-8");try{U=oj(z,J,new Set([Qj(j)]))}catch(V){if(!Z)throw V;let G=V instanceof Error?V.message:String(V);console.warn(`Warning: Failed to parse component exports from ${j}: ${G}`)}}let H={...U};if($)for(let{moduleName:z,source:V}of j0(J)){if(U[z])U[z].source=V;if(H[z])H[z].source=V;else H[z]={source:V,default:!1}}return{exports:U,allComponents:H,rootDir:J,resolveComponentFilePath:K}}async function Jj(j){let $=await Promise.all(Array.from(j).map(async(Z)=>{try{let Q=await U5(Z,"utf-8");return{path:Z,content:Q}}catch(Q){return console.warn(`Warning: Failed to read file ${Z}:`,Q),{path:Z,content:null}}}));return new Map($.map(({path:Z,content:Q})=>[Z,Q]))}function m([j,$],Z,Q,Y,J={}){let K=$.source,{ext:U,name:H}=ej(K),z=j;if(Z.length===1&&j==="default")z=H;if(U===".svelte"){let V=Y(K),G=Q.get(V);if(G===null||G===void 0)return null;let X=w(K),W=J.memo?.get(V),O=J.hashes?.get(V),q=W===void 0?O===void 0?null:J.cache?.get(V,O):null,B;if(W!==void 0)B=W;else if(q)B=q;else{let R=new(Rj()).ComponentParser;try{B=R.parseSvelteComponent(G,{moduleName:z,filePath:X})}catch(k){if(J.failFast)throw k;let M=k instanceof Error?k.message:String(k),b=k instanceof Error?k.stack:void 0;return J.onParseError?.({filePath:X,moduleName:z,message:M,stack:b}),null}if(O!==void 0)J.cache?.set(V,O,B);J.memo?.set(V,B)}return{moduleName:z,filePath:X,...B}}return null}function Fj(j,$){let Z=new Set;for(let Q of j)for(let[,Y]of Q)if(ej(Y.source).ext===".svelte")Z.add($(Y.source));return Z}function Kj(j){if(j.length===0)return;console.error(`sveld: failed to parse ${j.length} component(s):`);for(let{filePath:$,message:Z}of j)console.error(` - ${$}: ${Z}`)}async function zj(j,$,Z={}){let Q=Z.documentExports===!0,{exports:Y,allComponents:J,rootDir:K,resolveComponentFilePath:U}=Tj(j,$,Q),H=Q&&K1(j).isFile()?await Dj(Qj(j)):[],z=Object.entries(Y),V=Object.entries(J),G=Fj([z,V],U),X=await Jj(G),W=new Map,O=new Map,q=Z.cache===!1?void 0:new sj(c0(K,Z.cache??!0)),B=q?new Map:void 0,R=new Set,k=new Map;if(q)for(let I of G){let L=X.get(I);if(L===null||L===void 0)continue;let F=d0(L);if(k.set(I,F),!q.has(I,F))R.add(I)}if(G.size>0&&(!q||R.size>0))await s();let M=new Map,b=new Map,A={failFast:Z.failFast===!0,onParseError:(I)=>M.set(I.filePath,I),cache:q,hashes:k,memo:b};for(let I of z){let L=m(I,z,X,U,A);if(L)W.set(L.moduleName,L)}for(let I of V){let L=m(I,V,X,U,A);if(L)O.set(L.moduleName,L),B?.set(L.moduleName,U(I[1].source))}if(q&&R.size>0){let I=e(O,U),L=kj(R,I);for(let F of L){if(R.has(F))continue;q.invalidate(F),b.delete(F)}for(let F of z){let P=U(F[1].source);if(!L.has(P)||R.has(P))continue;let v=m(F,z,X,U,A);if(v)W.set(v.moduleName,v)}for(let F of V){let P=U(F[1].source);if(!L.has(P)||R.has(P))continue;let v=m(F,V,X,U,A);if(v)O.set(v.moduleName,v),B?.set(v.moduleName,P)}}let y=Array.from(M.values());if(Kj(y),!Z.dryRun)q?.save();let x=Z.resolveTypes?W5(W):[],D=Z.checkExamples?B5(O):[];if(x.length>0||D.length>0){let{TypeResolver:I}=await import("./chunk-h1r040pg.js"),L=await I.create(K);try{if(x.length>0)await k5(x,L,U);if(D.length>0)await O5(D,L,U)}finally{await L?.dispose()}}let S=Bj(Array.from(O.values()).flatMap((I)=>I.diagnostics??[]));return{exports:Y,entryExports:H,components:W,allComponentsForTypes:O,errors:y,diagnostics:S,cache:q,resolvedPathByModule:B}}function W5(j){let $=[];for(let Z of j.values()){let Q=Aj(Z);if(!Q?.canonicalPropsType||Z.props.length>0)continue;$.push({component:Z,metadata:Q})}return $}async function k5(j,$,Z){if(!$)return;let Q=await $.expandAll(j.map(({component:Y,metadata:J})=>({moduleName:Y.moduleName,metadata:J,filePath:Z(Y.filePath)})));for(let{component:Y}of j){let J=Q.get(Y.moduleName);if(J)J1(Y,J)}}function B5(j){let $=[];for(let Z of j.values()){let Q=h0(Z);if(Q.length===0)continue;$.push({component:Z,sources:Q})}return $}async function O5(j,$,Z){if(!$)return;let Q=await $.checkExamples(j.map(({component:Y,sources:J})=>({moduleName:Y.moduleName,filePath:Z(Y.filePath),sources:J})));for(let{component:Y,sources:J}of j){let K=Q.get(Y.moduleName);if(!K||K.length===0)continue;let U=new Map(J.map((z)=>[z.id,z.source])),H=Y.diagnostics??[];for(let z of K){let V=U.get(z.id);H.push({component:Y.filePath,kind:"example-compile-error",name:z.name,message:z.message,...V?{source:V}:{}})}Y.diagnostics=H}}import{existsSync as U1,readFileSync as R5}from"node:fs";import{join as H1}from"node:path";function Sj(j){if(j){let Z=H1(process.cwd(),j);if(U1(Z))return o(j);return console.error(`Invalid entry point: ${Z}. Pass a valid --entry (or "entry" option), or unset it and`),console.error('set the "svelte" field in your package.json instead.'),null}let $=H1(process.cwd(),"package.json");if(!U1($))return console.error("Could not locate a package.json file."),console.error(`Specify an entry point with --entry (or the "entry" option) instead.
|
|
7
|
-
`),null;try{let Z=l0(JSON.parse(R5($,"utf-8")));if(Z.svelte?.trim())return o(Z.svelte);return console.error(`Could not determine an entry point.
|
|
8
|
-
`),console.error(`Specify an entry point to your Svelte code in the "svelte" field of your package.json, or pass --entry (or the "entry" option).
|
|
9
|
-
`),null}catch(Z){throw console.error("Error reading package.json:",Z),Z}}import{lstatSync as L5}from"node:fs";import{resolve as V1}from"node:path";var I5=/\.svelte$/;async function q1(j,$,Z=!1){let{exports:Q,allComponents:Y,rootDir:J,resolveComponentFilePath:K}=Tj(j,$,Z),U=Z&&L5(j).isFile()?await Dj(V1(j)):[],H=Object.entries(Q),z=Object.entries(Y),V=new Map,G=new Map;await s();let X=new Map,W={onParseError:(k)=>X.set(k.filePath,k)},O=()=>({exports:Q,entryExports:U,components:V,allComponentsForTypes:G,errors:Array.from(X.values()),diagnostics:Bj(Array.from(G.values()).flatMap((k)=>k.diagnostics??[]))});{let k=Fj([H,z],K),M=await Jj(k);for(let b of H){let A=m(b,H,M,K,W);if(A)V.set(A.moduleName,A)}for(let b of z){let A=m(b,z,M,K,W);if(A)G.set(A.moduleName,A)}Kj(O().errors)}let q=e(G,K),B=(k,M,b,A)=>{let y=new Set;for(let x of M){let D=K(x[1].source);if(!b.has(D))continue;let S=m(x,M,A,K,W);if(S)k.set(S.moduleName,S),y.add(D);else for(let[I,L]of k)if(K(L.filePath)===D)k.delete(I)}return y};return{get result(){return O()},update:async(k)=>{let M=k.filter((D)=>I5.test(D)).map((D)=>V1(D));if(M.length===0)return{result:O(),reparsed:[]};if($)for(let{moduleName:D,source:S}of j0(J)){let I=Y[D];if(I)I.source=S;else{let L={source:S,default:!1};Y[D]=L,z.push([D,L])}}let b=kj(M,q);for(let[D,S]of X)if(b.has(K(S.filePath)))X.delete(D);let A=await Jj(b),y=new Set;for(let D of B(V,H,b,A))y.add(D);for(let D of B(G,z,b,A))y.add(D);q=e(G,K);let x=O();return Kj(x.errors),{result:x,reparsed:Array.from(y)}}}}import x5 from"node:path";var G1=!1;function X1(j){G1=j}function c(j){if(!G1)console.error(j)}import{mkdir as M5,readFile as b5,writeFile as D5}from"node:fs/promises";import{parse as A5}from"node:path";class _{dryRun;constructor(j){this.dryRun=j?.dryRun===!0}async write(j,$){if(this.dryRun)return console.log(`would write "${w(j)}"`),!0;try{if(await b5(j,"utf-8")===$)return!1}catch{}return await M5(A5(j).dir,{recursive:!0}),await D5(j,$),!0}}var T5=new Set(["string","number","boolean"]);function F5(j){return j.map(($)=>({kind:"field",name:$.name,...$.type?{type:{text:$.type}}:{},...$.value===void 0?{}:{default:$.value},...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function S5(j){let $=new Map;for(let Q of j){if(!Q.type||!T5.has(Q.type.trim()))continue;let Y=Q.name.toLowerCase(),J=$.get(Y);if(J)J.push(Q);else $.set(Y,[Q])}let Z=[];for(let[Q,Y]of $){if(Y.length!==1)continue;let J=Y[0];Z.push({name:Q,fieldName:J.name,type:{text:J.type},...J.value===void 0?{}:{default:J.value},...J.description?{description:J.description}:{}})}return Z}function w5(j){return j.filter(($)=>$.type==="dispatched").map(($)=>({name:$.name,type:{text:`CustomEvent<${$.detail??"unknown"}>`},...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function _5(j){return j.map(($)=>({name:$.default?"":$.name??"",...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function N5(j){let $={kind:"class",name:j.moduleName,...j.componentComment?{description:j.componentComment}:{},members:F5(j.props),attributes:S5(j.props),events:w5(j.events),slots:_5(j.slots)};if(j.customElementTag)$.tagName=j.customElementTag,$.customElement=!0;return $}function y5(j,$){let Z=[{kind:"js",name:j.moduleName,declaration:{name:j.moduleName,module:$}}];if(j.customElementTag)Z.push({kind:"custom-element-definition",name:j.customElementTag,declaration:{name:j.moduleName,module:$}});return Z}function W1(j,$={}){let Z=g(j),Q=$.resolveModulePath??((J)=>J.filePath);return{schemaVersion:"1.0.0",modules:Z.components.map((J)=>{let K=Q(J);return{kind:"javascript-module",path:K,declarations:[N5(J)],exports:y5(J,K)}})}}function $0(j,$){let Z=W1(j,{resolveModulePath:(Q)=>wj(Q.filePath,$.inputDir)});return h(Z)}async function Z0(j,$){let Z=$0(j,$),Q=x5.join(process.cwd(),$.outFile);if(await new _({dryRun:$.dryRun}).write(Q,Z),!$.dryRun)c(`created "${$.outFile}".`)}import Q0 from"node:path";function Y0(j,$){return j.map((Z)=>({...Z,filePath:wj(Z.filePath,$)}))}async function g5(j,$){let Z=g(j),Q=Y0(Z.components,$.inputDir);await Promise.all(Q.map(async(Y)=>{let J=Q0.resolve(Q0.join($.outDir||"",`${Y.moduleName}.api.json`)),U=await new _({dryRun:$.dryRun}).write(J,h(Y));if(!$.dryRun)c(`${U?"created":"unchanged"} "${J}".`)}))}function J0(j,$){let Z=g(j,{entryExports:$.entryExports}),Q={...Z,components:Y0(Z.components,$.inputDir)};return h(Q)}function k1(j,$){let Z=g(j,{entryExports:$.entryExports});return`${Y0(Z.components,$.inputDir).map((Y)=>JSON.stringify(Y)).join(`
|
|
10
|
-
`)}
|
|
11
|
-
`}async function C5(j,$){let Z=J0(j,$),Q=Q0.join(process.cwd(),$.outFile);if(await new _({dryRun:$.dryRun}).write(Q,Z),!$.dryRun)c(`created "${$.outFile}".`)}async function K0(j,$){if($.outDir)await g5(j,$);else await C5(j,$)}import{join as C3}from"node:path";var O1=/^[}\])>]/,E5=new Set(["{","(","["]),P5=new Set(["}",")","]"]);var v5=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,R1=/[ \t]+$/,f5=/\s+$/,h5=/[{([]$/,u5=/\s/;function m5(j){return v5.test(j.slice(-200))}var c5=200;function d5(j,$){let Z="";for(let Q=j.length-1;Q>=0&&Z.length<$;Q--)Z=j[Q]+Z;return Z.length>$?Z.slice(-$):Z}function B1(j,$){while(j.length>0&&$.test(j[j.length-1]))j.pop()}function l5(j){let $="",Z=null,Q=!1;for(let Y=0;Y<j.length;Y++){let J=j[Y],K=j[Y-1];if(Z){if($+=J,Z==="double"&&J==='"'&&K!=="\\"||Z==="single"&&J==="'"&&K!=="\\"||Z==="template"&&J==="`"&&K!=="\\")Z=null;Q=!1;continue}if(J==='"'||J==="'"||J==="`"){Z=J==='"'?"double":J==="'"?"single":"template",$+=J,Q=!1;continue}if(u5.test(J)){if(!Q&&$.length>0)$+=" ",Q=!0;continue}$+=J,Q=!1}return $.trimEnd()}function i5(j,$){let Z=0,Q="normal";for(let Y=$;Y<j.length;Y++){let J=j[Y],K=j[Y-1];if(Q==="blockComment"){if(K==="*"&&J==="/")Q="normal";continue}if(Q==="double"||Q==="single"){if(J===(Q==="double"?'"':"'")&&K!=="\\")Q="normal";continue}if(Q==="template"){if(J==="`"&&K!=="\\")Q="normal";continue}if(J==="/"&&j[Y+1]==="*")Q="blockComment";else if(J==='"')Q="double";else if(J==="'")Q="single";else if(J==="`")Q="template";else if(J==="{")Z++;else if(J==="}"){if(Z--,Z===0)return Y}}return-1}function L1(j){let $=[],Z="normal";for(let Q=0;Q<j.length;Q++){let Y=j[Q],J=j[Q-1];if(Z==="blockComment"){if($.push(Y),J==="*"&&Y==="/")Z="normal";continue}if(Z==="double"||Z==="single"){if($.push(Y),Y===(Z==="double"?'"':"'")&&J!=="\\")Z="normal";continue}if(Z==="template"){if($.push(Y),Y==="`"&&J!=="\\")Z="normal";continue}if(Y==="/"&&j[Q+1]==="*"){Z="blockComment",$.push(Y);continue}if(Y==='"'){Z="double",$.push(Y);continue}if(Y==="'"){Z="single",$.push(Y);continue}if(Y==="`"){Z="template",$.push(Y);continue}if(Y==="{"){let K=i5(j,Q);if(K===-1){$.push(Y);continue}let U=j.slice(Q+1,K);if(U.trim()===""){$.push("{}"),Q=K;continue}if(!U.includes("/*")&&j[Q+1]!==`
|
|
12
|
-
`&&!m5(d5($,c5))){let H=L1(U).trim();if(!H.includes(`
|
|
13
|
-
`)){let z=H.endsWith(";")?H.slice(0,-1):H,V=`{ ${l5(z)} }`;if(V.length<=120){$.push(V),Q=K;continue}}}if($.push(Y),j[Q+1]!==`
|
|
14
|
-
`)$.push(`
|
|
15
|
-
`);continue}if(Y==="}"){if(B1($,R1),$[$.length-1]!==`
|
|
16
|
-
`)$.push(`
|
|
17
|
-
`);$.push(Y);continue}if(Y===";"){if(B1($,f5),$.push(";"),j[Q+1]!==`
|
|
18
|
-
`)$.push(`
|
|
19
|
-
`);continue}$.push(Y)}return $.join("")}function p5(j){let $="",Z=null;for(let Q=0;Q<j.length;Q++){let Y=j[Q],J=j[Q-1];if(Z){if($+=Y,Z==="double"&&Y==='"'&&J!=="\\"||Z==="single"&&Y==="'"&&J!=="\\"||Z==="template"&&Y==="`"&&J!=="\\")Z=null;continue}if(Y==='"'||Y==="'"||Y==="`"){Z=Y==='"'?"double":Y==="'"?"single":"template",$+=Y;continue}if(Y===" "&&$.endsWith(" "))continue;$+=Y}return $}function s5(j){let $=j.split(`
|
|
20
|
-
`),Z=[],Q=0,Y=!1,J=0;for(let K of $){let U=K.trim();if(U===""){Z.push("");continue}if(Y){if(Z.push(`${" ".repeat(J)} ${U}`),U.includes("*/"))Y=!1;continue}if(U.startsWith("/**")&&!U.includes("*/")){Z.push(" ".repeat(Q)+U),Y=!0,J=Q;continue}let H=p5(U),z=O1.test(H),V=Math.max(0,Q-(z?1:0));if(Z.push(" ".repeat(V)+H),H.startsWith("/**")&&H.includes("*/"))continue;let G=null;for(let X=0;X<H.length;X++){let W=H[X],O=H[X-1];if(G){if(G==="double"&&W==='"'&&O!=="\\"||G==="single"&&W==="'"&&O!=="\\"||G==="template"&&W==="`"&&O!=="\\")G=null;continue}if(W==='"')G="double";else if(W==="'")G="single";else if(W==="`")G="template";else if(E5.has(W))Q++;else if(P5.has(W))Q=Math.max(0,Q-1);else if(W==="<")Q++;else if(W===">"&&O!=="=")Q=Math.max(0,Q-1)}}return Z.join(`
|
|
21
|
-
`)}function a5(j){let $=j.split(`
|
|
22
|
-
`).map((Q)=>Q.replace(R1,"")),Z=[];for(let Q of $){let Y=Q==="",J=Z.length>0&&Z[Z.length-1]==="",K=Z.length>0&&h5.test(Z[Z.length-1]);if(Y){if(Z.length===0||J||K)continue;Z.push(Q);continue}if(O1.test(Q)&&J)Z.pop();Z.push(Q)}while(Z.length>0&&Z[Z.length-1]==="")Z.pop();return Z.join(`
|
|
23
|
-
`)}function I1(j){let $=L1(j),Z=s5($);return`${a5(Z)}
|
|
24
|
-
`}var d="any",C="",r5="Record<string, any>",U0="Record<string, never>",n5=/(-|\s+|:)/,t5=/("|')/,o5=/CustomEvent/,e5=/^[A-Z]/,j3=/\n/,M1=/=>/,$3=/(?:^|\n)@default\b/,H0=/\n/g,Z3=/\s+/g,Q3=/(^|[^.\w])Snippet(?:\s*<|\b)/,Y3=/import\s+type\s+[^;]*\bSnippet\b[^;]*from\s+"svelte";/,J3=/[.*+?^${}()|[\]\\]/g,K3=/^const\s+/;function V0(j){return j.replace(K3,"")}function z3(j){if(!j)return;return j.replace(H0,`
|
|
25
|
-
* `)}function Nj(j){if(!j)return"";return`/** ${j} */`}function yj(j){if(!j)return"";return`/**
|
|
26
|
-
* ${j.replace(H0,`
|
|
27
|
-
* `)}
|
|
28
|
-
*/`}function b1(j){if(j===void 0)return;return j===!0?"@deprecated":`@deprecated ${j}`}function U3(j){let $=b1(j);if($===void 0)return;return`* ${$.replace(H0,`
|
|
29
|
-
* `)}
|
|
30
|
-
`}function H3(j,$){if(!$)return[`@${j}`];if(!$.includes(`
|
|
31
|
-
`))return[`@${j} ${$}`];return[`@${j}`,...$.split(`
|
|
32
|
-
`)]}function D1(j){let $=[];for(let{name:Z,body:Q}of j??[])$.push(...H3(Z,Q));return $}function Uj(j,$,Z){let Q=b1(Z),Y=D1($),J=Y.length>0;if(!j&&!J&&!Q)return"";if(!J&&!Q)return j?.includes(`
|
|
33
|
-
`)?yj(j):Nj(j);let K=[];if(j)K.push(...j.split(`
|
|
34
|
-
`));if(K.push(...Y),Q)K.push(...Q.split(`
|
|
35
|
-
`));return`/**
|
|
36
|
-
* ${K.join(`
|
|
37
|
-
* `)}
|
|
38
|
-
*/`}function V3(j){let $=D1(j);if($.length===0)return"";return $.map((Z)=>`* ${Z}
|
|
39
|
-
`).join("")}function xj(j){if(j===void 0)return d;return`${j}
|
|
40
|
-
`}function gj(j){if(j.typedefs.length===0)return C;return j.typedefs.map(($)=>{return`${$.description?`${yj($.description)}
|
|
41
|
-
`:""}export ${$.ts}`}).join(`
|
|
42
|
-
|
|
43
|
-
`)}function A1(j,$){let Z=$.replace(J3,"\\$&");return new RegExp(`\\b${Z}\\b`).test(j)}function q3(j){if(j===null)return[];return j[0].split(",").map(($,Z)=>({name:$.trim(),constraint:(_j(j[1]??"")[Z]??$).trim()}))}function G3(j,$){let Z=q3(j).filter(({name:Q})=>A1($,Q));if(Z.length===0)return{declSuffix:C,refSuffix:C};return{declSuffix:`<${Z.map(({constraint:Q})=>V0(Q)).join(", ")}>`,refSuffix:`<${Z.map(({name:Q})=>Q).join(", ")}>`}}function T1(j){if(!j.contexts||j.contexts.length===0)return C;let $=j.generics===null?[]:j.generics[0].split(",").map((Z,Q)=>({name:Z.trim(),constraint:(_j(j.generics?.[1]??"")[Q]??Z).trim()}));return j.contexts.map((Z)=>{let Q=Z.properties.map((U)=>{let H=U.description?`${Nj(U.description)}
|
|
44
|
-
`:"",z=U.optional?"?":"";return`${H}${U.name}${z}: ${U.type};`}).join(`
|
|
45
|
-
`),Y=Z.description?`${yj(Z.description)}
|
|
46
|
-
`:"",J=$.filter(({name:U})=>Z.properties.some((H)=>A1(H.type,U))).map(({constraint:U})=>U),K=J.length>0?`<${J.map(V0).join(", ")}>`:"";if(Z.properties.length===0)return`${Y}export type ${Z.typeName} = Record<string, never>;`;return`${Y}export type ${Z.typeName}${K} = {
|
|
47
|
-
${Q}
|
|
48
|
-
};`}).join(`
|
|
49
|
-
|
|
50
|
-
`)}function Hj(j){if(n5.test(j))return t5.test(j)?j:`"${j}"`;return j}function F1(j,$){if(!j)return;return`* ${$||j}
|
|
51
|
-
`}function q0(j,$,Z){return[F1(z3(j)),U3($),V3(Z)].filter(Boolean).join("")}function G0(j){return j.length>0?`/**
|
|
52
|
-
${j}*/`:C}function X3(j){let $=new Set([...j.props.filter((q)=>!q.isFunctionDeclaration&&q.kind!=="const").map((q)=>q.name),...Array.from(j.canonicalPropNames??[])]),Z=j.props.filter((q)=>!q.isFunctionDeclaration&&q.kind!=="const").map((q)=>{let B=q.value;if(typeof q.value==="string")B=q.value.replace(Z3," ");if(q.value===void 0)B="undefined";let k=$3.test(q.description??"")||q.isFunction&&q.value===void 0,M=[q0(q.description,q.deprecated,q.tags),F1(q.constant,"@constant"),k?null:`* @default ${B}
|
|
53
|
-
`].filter(Boolean).join(""),b=q.constant&&!q.isFunction?q.value:q.type;return`
|
|
54
|
-
${G0(M)}
|
|
55
|
-
${q.name}${q.isRequired?"":"?"}: ${b};`}),Q=j.canonicalPropsType?Z.filter((q,B)=>{let R=j.props.filter((k)=>!k.isFunctionDeclaration&&k.kind!=="const")[B];return R?!(j.canonicalPropNames?.has(R.name)??!1):!0}):Z,Y=(j.slots||[]).filter((q)=>!q.default&&q.name!=null&&!$.has(q.name)).map((q)=>{let B=q.name,R=Hj(B),k=Uj(q.description,q.tags,q.deprecated),M=k?`${k}
|
|
56
|
-
`:"",A=q.slot_props&&q.slot_props!=="Record<string, never>"?`(this: void, ...args: [${q.slot_props}]) => void`:"(this: void) => void";return`
|
|
57
|
-
${M}${R}?: ${A};`}),J=(j.slots||[]).find((q)=>q.default||q.name===null),K=J&&!$.has("children")?(()=>{let q=Uj(J.description,J.tags,J.deprecated),B=q?`${q}
|
|
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};`})():"",U=j.events?L3({events:j.events},$):[],H=[...Y,K,...U].filter(Boolean),z=[...Q,...H].join(`
|
|
60
|
-
`),V=`${j.moduleName}Props`,G=C,X=j.generics?`<${_j(j.generics[1]).map((q)=>V0(q.trim())).join(", ")}>`:"",W=j.generics?`<${j.generics[0]}>`:"",O=j.canonicalPropsType?`
|
|
61
|
-
type $Props${X} = ${j.canonicalPropsType}${z.trim()===""?"":` & {${z}
|
|
62
|
-
}`};
|
|
63
|
-
`:`
|
|
64
|
-
type $Props${X} = {
|
|
65
|
-
${z}
|
|
66
|
-
};
|
|
67
|
-
`;if(j.rest_props?.type==="Element"){let q;if(j.rest_props.name==="svelte:element")if(j.rest_props.thisValue)q=`SvelteHTMLElements["${j.rest_props.thisValue}"]`;else q="HTMLAttributes<HTMLElement>";else q=j.rest_props.name.split("|").map((k)=>{return`SvelteHTMLElements["${k.trim()}"]`}).join(" & ");let B="[key: `data-${string}`]: unknown;",R=j.rest_props.description?j.rest_props.description.includes(`
|
|
68
|
-
`)?`${yj(j.rest_props.description)}
|
|
69
|
-
`:`${Nj(j.rest_props.description)}
|
|
70
|
-
`:"";if(j.extends===void 0)G=`
|
|
71
|
-
${R}${q?`type $RestProps = ${q};
|
|
72
|
-
`:""}
|
|
73
|
-
${j.canonicalPropsType?`type $Props${X} = (${j.canonicalPropsType}) & {${z}
|
|
74
|
-
|
|
75
|
-
${B}
|
|
76
|
-
};`:`type $Props${X} = {
|
|
77
|
-
${z}
|
|
78
|
-
|
|
79
|
-
${B}
|
|
80
|
-
};`}
|
|
81
|
-
|
|
82
|
-
export type ${V}${X} = Omit<$RestProps, keyof $Props${W}> & $Props${W};
|
|
83
|
-
`;else G=`
|
|
84
|
-
${R}${q?`type $RestProps = ${q};
|
|
85
|
-
`:""}
|
|
86
|
-
${j.canonicalPropsType?`type $Props${X} = (${j.canonicalPropsType}) & {${z}
|
|
87
|
-
|
|
88
|
-
${B}
|
|
89
|
-
};`:`type $Props${X} = {
|
|
90
|
-
${z}
|
|
91
|
-
|
|
92
|
-
${B}
|
|
93
|
-
};`}
|
|
94
|
-
|
|
95
|
-
export type ${V}${X} = Omit<$RestProps, keyof ($Props${W} & ${j.extends.interface})> & $Props${W} & ${j.extends.interface};
|
|
96
|
-
`}else if(z.trim()===""&&j.extends===void 0&&!j.canonicalPropsType)G=`
|
|
97
|
-
export type ${V}${X} = ${U0};
|
|
98
|
-
`;else if(j.canonicalPropsType)G=`
|
|
99
|
-
${O}
|
|
100
|
-
export type ${V}${X} = ${j.extends===void 0?"":`${j.extends.interface} & `}$Props${W};
|
|
101
|
-
`;else G=`
|
|
102
|
-
export type ${V}${X} = ${j.extends===void 0?"":`${j.extends.interface} & `} {
|
|
103
|
-
${z}
|
|
104
|
-
};
|
|
105
|
-
`;return{props_name:V,prop_def:G}}function W3(j){if(j.slots.length===0)return U0;let $=j.slots.map(({name:Z,slot_props:Q,...Y})=>{let J=Y.default||Z===null?"default":Hj(Z??""),K=Uj(Y.description,Y.tags,Y.deprecated);return`${K?`${K}
|
|
106
|
-
`:""}${Hj(J)}: ${xj(Q)};`}).join(`
|
|
107
|
-
`);return j.slots.length===1?`{${$}}`:`{
|
|
108
|
-
${$}
|
|
109
|
-
}`}var k3=()=>"WindowEventMap",B3=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 z0(j=d){if(o5.test(j))return j;return`CustomEvent<${j}>`}function O3(j){return B3.has(j)}function S1(j){switch(j.type){case"dispatched":return z0(j.detail);case"forwarded":{let $=j.element,Q=!($&&e5.test($))||O3(j.name),Y=j.detail!==void 0&&j.detail!=="undefined"&&!(j.detail==="null"&&Q),J=j.detail==="null"&&!Q;if(Y||J)return z0(j.detail);else if(Q)return`${k3()}["${j.name}"]`;else return z0()}default:return j}}function R3(j){if(j.events.length===0)return r5;let $=j.events.map((Z)=>{let Q="",Y=Uj(Z.description,Z.tags,Z.deprecated);if(Y)Q=`${Y}
|
|
110
|
-
`;return`${Q}${Hj(Z.name)}: ${S1(Z)};
|
|
111
|
-
`}).join("");return j.events.length===1?`{${$}}`:`{
|
|
112
|
-
${$}}`}function L3(j,$){return j.events.map((Z)=>{let Q=`on${Z.name}`;if($.has(Q))return;let Y="",J=Uj(Z.description,Z.tags,Z.deprecated);if(J)Y=`${J}
|
|
113
|
-
`;return`
|
|
114
|
-
${Y}${Hj(Q)}?: (event: ${S1(Z)}) => void;`}).filter((Z)=>Z!==void 0)}function I3(j){let $=j.type==="() => any";if(j.type&&M1.test(j.type)&&!$)return j.type;else if(j.params&&j.params.length>0){let Q=j.params.map((J)=>{let K=J.optional?"?":"";return`${J.name}${K}: ${J.type}`}).join(", "),Y=j.returnType||d;return`(${Q}) => ${Y}`}else if(j.returnType)return`() => ${j.returnType}`;else return j.type||d}function w1(j){return j.props.filter(($)=>$.isFunctionDeclaration||$.kind==="const").map(($)=>{let Z=q0($.description,$.deprecated,$.tags),Q=I3($);return`
|
|
115
|
-
${G0(Z)}
|
|
116
|
-
${$.name}: ${Q};`}).join(`
|
|
117
|
-
`)}function M3(j){let $=`${j.moduleName}Exports`,Z=w1({props:j.props});if(Z.trim()==="")return{exports_name:$,exports_ref:$,exports_def:`export type ${$} = ${U0};`};let{declSuffix:Q,refSuffix:Y}=G3(j.generics,Z);return{exports_name:$,exports_ref:`${$}${Y}`,exports_def:`export type ${$}${Q} = {${Z}
|
|
118
|
-
};`}}function b3(j){let $=j.props.filter((Z)=>Z.bindable===!0||Z.binding==="writable").map((Z)=>`"${Z.name}"`);return $.length===0?C:$.join(" | ")}function D3(j){let $=j.moduleName==="default"?"$$Component":j.moduleName,Z=j.bindings===C?'""':j.bindings;return`declare const ${$}: Component<
|
|
119
|
-
${j.propsRef},
|
|
120
|
-
${j.exportsRef},
|
|
121
|
-
${Z}
|
|
122
|
-
>;
|
|
123
|
-
export default ${$};`}function A3(j){let $=j.moduleName==="default"?"$$Component":j.moduleName,Z=`${$}Component`,Q=j.bindings===C?'""':j.bindings;return`interface ${Z} {
|
|
124
|
-
new ${j.generic}(
|
|
125
|
-
options: ComponentConstructorOptions<${j.propsRef}>
|
|
126
|
-
): SvelteComponent<${j.propsRef}> & ${j.exportsRef};
|
|
127
|
-
${j.generic}(
|
|
128
|
-
this: void,
|
|
129
|
-
internals: ComponentInternals,
|
|
130
|
-
props: ${j.propsRef}
|
|
131
|
-
): {
|
|
132
|
-
$on?(type: string, callback: (e: any) => void): () => void;
|
|
133
|
-
$set?(props: Partial<${j.propsRef}>): void;
|
|
134
|
-
} & ${j.exportsRef};
|
|
135
|
-
element?: typeof HTMLElement;
|
|
136
|
-
z_$$bindings?: ${Q};
|
|
137
|
-
}
|
|
138
|
-
declare const ${$}: ${Z};
|
|
139
|
-
export default ${$};`}function T3(j){if(j.extends===void 0)return"";return`import type { ${j.extends.interface} } from ${j.extends.import};`}function F3(j){if(!j.componentComment)return"";if(!j3.test(j.componentComment))return Nj(j.componentComment.trim());return`/*${j.componentComment.split(`
|
|
140
|
-
`).map(($)=>`* ${$}`).join(`
|
|
141
|
-
`)}
|
|
142
|
-
*/`}function S3(j){return j.moduleExports.map(($)=>{let Z=q0($.description,$.deprecated,$.tags),Q,Y=$.type&&M1.test($.type),J=$.type==="() => any";if($.kind==="const"&&!Y)Q=`export declare const ${$.name}: ${$.type||d};
|
|
143
|
-
`;else if($.params&&$.params.length>0){let U=$.params.map((z)=>{let V=z.optional?"?":"";return`${z.name}${V}: ${z.type}`}).join(", "),H=$.returnType||d;Q=`export declare function ${$.name}(${U}): ${H};`}else if($.returnType)Q=`export declare function ${$.name}(): ${$.returnType};`;else if(Y&&$.type&&!J){let[K,U,...H]=$.type.split("=>"),z=H.map((V)=>` => ${V.trim()}`).join("");Q=`export declare function ${$.name}${K.trimEnd()}: ${U.trim()}${z};`}else if(Y&&$.type){let[K,U,...H]=$.type.split("=>"),z=H.map((V)=>` => ${V.trim()}`).join("");Q=`export declare function ${$.name}${K.trimEnd()}: ${U.trim()}${z};`}else if($.kind==="const")Q=`export declare const ${$.name}: ${$.type||d};
|
|
144
|
-
`;else Q=`export type ${$.name} = ${$.type||d};`;return`
|
|
145
|
-
${G0(Z)}
|
|
146
|
-
${Q}`}).join(`
|
|
147
|
-
`)}var w3=120;function _3(j){let Z=`export default class ${j.moduleName==="default"?"":j.moduleName}${j.generic} extends SvelteComponentTyped<`,Q=[j.genericProps,j.events,j.slots];if(j.accessors.trim()===""&&Q.every((Y)=>!Y.includes(`
|
|
148
|
-
`))){let Y=`${Z}${Q.join(", ")}> {}`;if(Y.length<=w3)return Y}return`${Z}
|
|
149
|
-
${j.genericProps},
|
|
150
|
-
${j.events},
|
|
151
|
-
${j.slots}
|
|
152
|
-
> {
|
|
153
|
-
${j.accessors}
|
|
154
|
-
}`}function X0(j,$){let Z=Aj(j),{moduleName:Q,typedefs:Y,generics:J,props:K,moduleExports:U,slots:H,events:z,rest_props:V,extends:G,componentComment:X,contexts:W,syntaxMode:O}=j,q=$?.format==="component",B=J!==null,{props_name:R,prop_def:k}=X3({moduleName:Q,props:K,rest_props:V,extends:G,generics:J,slots:H,canonicalPropNames:new Set(Z?.canonicalPropNames??[]),canonicalPropsType:Z?.canonicalPropsType,events:q&&O==="legacy"?z:void 0}),M=J?`<${J[1]}>`:"",b=J?`${R}<${J[0]}>`:R,A=S3({moduleExports:U}),y=gj({typedefs:Y}),x=T1({contexts:W,generics:J}),D=(Z?.typeImportStatements??[]).join(`
|
|
155
|
-
`),S=(Z?.localTypeDeclarations??[]).join(`
|
|
156
|
-
|
|
157
|
-
`),{exports_ref:I,exports_def:L}=q?M3({props:K,moduleName:Q,generics:J}):{exports_ref:C,exports_def:C},F=q?b3({props:K}):C,P=!Y3.test(D)&&Q3.test(`${k}
|
|
158
|
-
${A}
|
|
159
|
-
${y}
|
|
160
|
-
${x}
|
|
161
|
-
${S}
|
|
162
|
-
${L}`),v=V?.type==="Element"&&(V.name!=="svelte:element"||V.name==="svelte:element"&&V.thisValue),i1=V?.type==="Element"&&V.name==="svelte:element"&&!V.thisValue,p1=[q?B?`import type { SvelteComponent, ComponentConstructorOptions, ComponentInternals${P?", Snippet":""} } from "svelte";`:`import type { Component${P?", Snippet":""} } from "svelte";`:`import { SvelteComponentTyped${P?", type Snippet":""} } from "svelte";`,v?'import type { SvelteHTMLElements } from "svelte/elements";':"",i1?'import type { HTMLAttributes } from "svelte/elements";':"",D,T3({extends:G})].filter(Boolean).join(`
|
|
163
|
-
`),s1=q?B?A3({moduleName:Q,generic:M,propsRef:b,exportsRef:I,bindings:F}):D3({moduleName:Q,propsRef:b,exportsRef:I,bindings:F}):_3({moduleName:Q,generic:M,genericProps:b,events:R3({events:z}),slots:W3({slots:H}),accessors:w1({props:K})}),a1=[A,y,S,x,k,L,[F3({componentComment:X}),s1].filter(Boolean).join(`
|
|
164
|
-
`)].map((r1)=>r1.trim()).filter(Boolean).join(`
|
|
165
|
-
|
|
166
|
-
`);return I1([p1,a1].filter(Boolean).join(`
|
|
167
|
-
|
|
168
|
-
`))}var W0=/`/g,Cj=/\s+/g,E="--",_1=`| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |
|
|
169
|
-
| :- | :- | :- | :- | :- | :- | :- | :- |
|
|
170
|
-
`,N1=`| Slot name | Default | Props | Fallback | Description |
|
|
171
|
-
| :- | :- | :- | :- | :- |
|
|
172
|
-
`,y1=`| Event name | Type | Detail | Description |
|
|
173
|
-
| :- | :- | :- | :- |
|
|
174
|
-
`,x1=`| Name | Kind | Type | Description |
|
|
175
|
-
| :- | :- | :- | :- |
|
|
176
|
-
`,Ej=/\|/g,N3=/</g,y3=/>/g,r=/\n/g;function i(j){if(j===void 0)return E;return`<code>${j.replace(Ej,"|")}</code>`}function Vj(j){return j.replace(N3,"<").replace(y3,">")}function g1(j){if(j===void 0)return E;return`<code>${j.replace(W0,"\\`").replace(Ej,"|")}</code>`}function Pj(j,$){if($===void 0)return j;let Z=typeof $==="string"&&$.trim().length>0?`: ${Vj($).replace(r," ").replace(Ej,"|")}`:"";return`<s>${j}</s><br />**Deprecated**${Z}`}function vj(j){if(j===void 0||j.trim().length===0)return E;return Vj(j).replace(r,"<br />")}function C1(j){if(j===void 0||j==="{}")return E;return i(xj(j).replace(r," "))}function E1(j){if(j===void 0)return E;return i(Vj(j).replace(r,"<br />"))}function P1(j,$){let Z=[];if(j!==void 0&&j.trim().length>0)Z.push(Vj(j));for(let{name:Q,body:Y}of $??[]){let J=Y?.trim();Z.push(J?`@${Q} ${Vj(J)}`:`@${Q}`)}if(Z.length===0)return E;return Z.join(`
|
|
177
|
-
`).replace(Ej,"|").replace(r,"<br />")}function v1(j){if(j===void 0)return E;return i(j.replace(r," "))}function f1(j,$,Z){if(j.append("h1","Component Index"),j.append("h2","Components").tableOfContents(),j.append("divider"),Z&&Z.length>0)x3(j,Z);let Q=g($);for(let Y of Q.components)g3(j,Y)}function x3(j,$){j.append("h2","Exports"),j.append("raw",x1);for(let Z of $){let Q=(Z.type??Z.value)?.replace(Cj," ").trim();j.append("raw",`| ${Z.name} | ${`<code>${Z.kind}</code>`} | ${i(Q)} | ${vj(Z.description)} |
|
|
178
|
-
`)}j.append("raw",`
|
|
179
|
-
`),j.append("divider")}function k0(j,$,Z,Q){if($.length>0)Z(),j.append("raw",`
|
|
180
|
-
`);else j.append("p",Q??"None.")}function g3(j,$){if(j.append("h2",`\`${$.moduleName}\``),$.generics)j.append("p",`**Type parameters:** ${i(`<${$.generics[1]}>`)}`);if($.typedefs.length>0)j.append("h3","Types").append("raw",`\`\`\`ts
|
|
181
|
-
${gj({typedefs:$.typedefs})}
|
|
182
|
-
\`\`\`
|
|
183
|
-
|
|
184
|
-
`);j.append("h3","Props"),k0(j,$.props,()=>{j.append("raw",_1);let Z=[...$.props].sort((Q)=>{if(Q.reactive)return-1;if(Q.constant)return 1;return 0});for(let Q of Z)j.append("raw",`| ${Pj(Q.name,Q.deprecated)} | ${Q.isRequired?"Yes":"No"} | ${`<code>${Q.kind}</code>`} | ${Q.reactive?"Yes":"No"} | ${Q.binding??"--"} | ${i(Q.type)} | ${g1(Q.value)} | ${vj(Q.description)} |
|
|
185
|
-
`)}),j.append("h3","Slots"),k0(j,$.slots,()=>{j.append("raw",N1);for(let Z of $.slots)j.append("raw",`| ${Pj(Z.default?E:Z.name??E,Z.deprecated)} | ${Z.default?"Yes":"No"} | ${C1(Z.slot_props)} | ${E1(Z.fallback)} | ${P1(Z.description,Z.tags)} |
|
|
186
|
-
`)}),j.append("h3","Events"),k0(j,$.events,()=>{j.append("raw",y1);for(let Z of $.events)j.append("raw",`| ${Pj(Z.name,Z.deprecated)} | ${Z.type} | ${Z.type==="dispatched"?v1(Z.detail):E} | ${vj(Z.description)} |
|
|
187
|
-
`)})}class B0{sourceParts=[];hasToC=!1;toc=[];get source(){return this.sourceParts.join("")}appendLineBreaks(){return this.sourceParts.push(`
|
|
188
|
-
|
|
189
|
-
`),this}append(j,$){switch(j){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{let Z=Number(j.slice(-1));if(this.sourceParts.push(`${"#".repeat(Z)} ${$}`),this.hasToC&&j==="h2")this.toc.push({indent:0,raw:$??""});break}case"quote":this.sourceParts.push(`> ${$}`);break;case"p":this.sourceParts.push($??"");break;case"divider":this.sourceParts.push("---");break;case"raw":this.sourceParts.push($??"");break}if(j!=="raw")this.appendLineBreaks();return this}tableOfContents(){return this.sourceParts.push("<!-- __TOC__ -->"),this.hasToC=!0,this.appendLineBreaks(),this}end(){return this.sourceParts.join("").replace("<!-- __TOC__ -->",this.toc.map(({indent:$,raw:Z})=>{return`${" ".repeat($)}- [${Z}](#${Z.toLowerCase().replace(W0,"").replace(Cj,"-")})`}).join(`
|
|
190
|
-
`))}}class fj extends _{onAppend;markdownBase;constructor(j){super();this.onAppend=j.onAppend,this.markdownBase=new B0}get source(){return this.markdownBase.source}get hasToC(){return this.markdownBase.hasToC}get toc(){return this.markdownBase.toc}appendLineBreaks(){return this.markdownBase.appendLineBreaks(),this}append(j,$){return this.markdownBase.append(j,$),this.onAppend?.call(this,j,this),this}tableOfContents(){return this.markdownBase.tableOfContents(),this}end(){return this.markdownBase.end()}}function O0(j,$){let Z=new fj({onAppend:(Q,Y)=>{$.onAppend?.call(null,Q,Y,j)}});return f1(Z,j,$.entryExports),Z.end()}async function R0(j,$){let Z=$?.write!==!1,Q=O0(j,$);if(Z){let Y=C3(process.cwd(),$.outFile);if(await new _({dryRun:$.dryRun}).write(Y,Q),!$.dryRun)c(`created "${$.outFile}".`)}return Q}import{join as c1}from"node:path";var h1=/\.svelte$/;function u1(j){let $=new Map;for(let[Q,Y]of Object.entries(j)){let J=$.get(Y.source)||[];J.push({id:Q,exportee:Y}),$.set(Y.source,J)}let Z=[];for(let[Q,Y]of $){let J=h1.test(Q),K=Y.some(({id:X,exportee:W})=>X!=="default"&&W.default),U=Y.some(({exportee:X})=>!X.default),H=J&&K&&U,z=[],V=[],G=[];for(let{id:X,exportee:W}of Y){if(X==="default"){V.push(`export { default } from "${Q}";`);continue}if(W.default)if(W.mixed)V.push(`export { default as ${X} } from "${Q}";`),V.push(`export { default } from "${Q}";`);else G.push(`default as ${X}`);else if(J&&!H)G.push(`default as ${X}`);else z.push(X)}if(G.length>0&&z.length>0)Z.push(`export { ${[...G,...z].join(", ")} } from "${Q}";`);else{if(z.length>0)Z.push(`export { ${z.join(", ")} } from "${Q}";`);if(G.length>0)Z.push(`export { ${G.join(", ")} } from "${Q}";`)}Z.push(...V)}return Z.join(`
|
|
191
|
-
`)}function m1(j){return j.replace(h1,".svelte.d.ts")}async function L0(j,$){let Z=c1(process.cwd(),$.outDir,"index.d.ts"),Q=new _({dryRun:$.dryRun}),Y=$.preamble+u1($.exports),J=g(j),K=$.format??"class",U=J.components.map(async(H)=>{let z=m1(c1($.outDir,H.filePath)),V=$.resolvedPathByModule?.get(H.moduleName),G=V?$.cache?.getGeneratedText(V,K):void 0;if(G===void 0){if(G=X0(H,{format:$.format}),V)$.cache?.setGeneratedText(V,K,G)}await Q.write(z,G)});if(await Promise.all([...U,Q.write(Z,`${Y}
|
|
192
|
-
`)]),!$.dryRun)c("created TypeScript definitions.")}t({name:"json",componentSet:"exported",write:K0});t({name:"markdown",componentSet:"exported",write:R0});t({name:"types",componentSet:"all",write:L0});t({name:"custom-elements",componentSet:"exported",write:Z0});var E3=50,P3=/\.svelte$/;function v3(j){let $=j?.watch===!0,Z,Q,Y=null,J,K=new Set,U=async()=>{if(Y==null||Q==null||K.size===0)return;let z=Array.from(K);K.clear();try{let{result:V}=await Y.update(z);await qj(V,j||{},Q)}catch(V){console.error("sveld: failed to regenerate types in watch mode:",V)}},H=(z)=>{if(!$||Y==null||!P3.test(z))return;K.add(z),clearTimeout(J),J=setTimeout(U,E3)};return{name:"vite-plugin-sveld",apply:$?void 0:"build",enforce:"post",async buildStart(){if(Q=Sj(j?.entry),$&&Q!=null)Y=await q1(Q,j?.glob===!0,j?.documentExports===!0),await qj(Y.result,j||{},Q)},async generateBundle(){if($)return;if(Q!=null)Z=await zj(Q,j?.glob===!0,Yj(j))},async writeBundle(){if($)return;if(Q!=null)await qj(Z,j||{},Q),Z.cache?.save()},handleHotUpdate(z){H(z.file)},watchChange(z){H(z)}}}function hj(j,$,Z){let Q=dj(j);if(!Q)throw Error(`sveld: built-in writer "${j}" is not registered.`);return Q.write($,Z)}async function qj(j,$,Z){let Q=d1(Z),Y=$?.dryRun===!0;if($?.types!==!1)await hj("types",j.allComponentsForTypes,{outDir:"types",preamble:"",...$?.typesOptions,exports:j.exports,inputDir:Q,dryRun:Y,cache:j.cache,resolvedPathByModule:j.resolvedPathByModule});if($?.json)await hj("json",j.components,{outFile:"COMPONENT_API.json",...$?.jsonOptions,input:Z,inputDir:Q,entryExports:j.entryExports,dryRun:Y});if($?.markdown)await hj("markdown",j.components,{outFile:"COMPONENT_INDEX.md",...$?.markdownOptions,entryExports:j.entryExports,dryRun:Y});if($?.customElements)await hj("custom-elements",j.components,{outFile:"custom-elements.json",...$?.customElementsOptions,inputDir:Q,dryRun:Y});let J=Object.entries($?.additionalWriters??{}).map(([K,U])=>{let H=dj(K);if(!H){console.warn(`sveld: no writer registered with name "${K}"; skipping.`);return}let z=H.componentSet==="all"?j.allComponentsForTypes:j.components;return H.write(z,U)});await Promise.all(J)}async function l1(j,$,Z){let Q=d1(Z);if($?.json){let Y={...$?.jsonOptions,inputDir:Q,entryExports:j.entryExports},J=$.stdout==="ndjson"?k1(j.components,Y):J0(j.components,Y);process.stdout.write(J);return}if($?.markdown){let Y=O0(j.components,{...$?.markdownOptions,entryExports:j.entryExports});process.stdout.write(Y);return}if($?.customElements){let Y=$0(j.components,{...$?.customElementsOptions,inputDir:Q});process.stdout.write(Y)}}import{existsSync as f3}from"node:fs";import{join as h3}from"node:path";var I0="src/index.js",N={SUCCESS:0,USAGE_ERROR:1,GENERATION_FAILURE:2,BREAKING_CHANGE:3,DIAGNOSTICS:4},u3=`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
|
-
`,M0={resolveTypes:"resolve-types",checkExamples:"check-examples"},m3=["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"],c3=[...m3,...Object.keys(M0)],d3=new Set(["glob","types","json","markdown","quiet","custom-elements","strict","report-diagnostics","resolve-types","check-examples","fail-fast"]),l3=new Set(["entry","cache","check","types-format"]),i3=new Set(["entry","types-format"]),p3=3;function s3(j,$){let Z=j.length+1,Q=$.length+1,Y=Array.from({length:Z},()=>Array(Q).fill(0));for(let J=0;J<Z;J++)Y[J][0]=J;for(let J=0;J<Q;J++)Y[0][J]=J;for(let J=1;J<Z;J++)for(let K=1;K<Q;K++){let U=j[J-1]===$[K-1]?0:1;Y[J][K]=Math.min(Y[J-1][K]+1,Y[J][K-1]+1,Y[J-1][K-1]+U)}return Y[Z-1][Q-1]}function a3(j){let $,Z=Number.POSITIVE_INFINITY;for(let Q of c3){let Y=s3(j,Q);if(Y<Z)$=Q,Z=Y}if($===void 0||Z>p3)return;return M0[$]??$}function r3(j,$){let Z=j.indexOf("="),Q=Z===-1?j.slice(2):j.slice(2,Z),Y=M0[Q]??Q,J=Z===-1?!0:j.slice(Z+1),K=!1;if(Z===-1&&l3.has(Y)){if($!==void 0&&!$.startsWith("--"))J=$,K=!0;else if(i3.has(Y))return{result:{kind:"usage-error",message:`sveld: --${Y} requires a value (pass --${Y}=<value> or --${Y} <value>).`},consumedNext:!1,flag:Y}}return{result:n3(Y,J,j,Q),consumedNext:K,flag:Y}}function n3(j,$,Z,Q){switch(j){case"help":return{kind:"help"};case"version":return{kind:"version"};case"glob":case"types":case"json":case"markdown":case"quiet":return{kind:"option",option:{[j]:$===!0||$==="true"}};case"stdout":if($===!0||$==="true")return{kind:"option",option:{stdout:!0}};if($==="false")return{kind:"option",option:{stdout:!1}};return{kind:"option",option:{stdout:$}};case"custom-elements":return{kind:"option",option:{customElements:$===!0||$==="true"}};case"strict":return{kind:"option",option:{strict:$===!0||$==="true"}};case"report-diagnostics":return{kind:"option",option:{reportDiagnostics:$===!0||$==="true"}};case"resolve-types":return{kind:"option",option:{resolveTypes:$===!0||$==="true"}};case"check-examples":return{kind:"option",option:{checkExamples:$===!0||$==="true"}};case"fail-fast":return{kind:"option",option:{failFast:$===!0||$==="true"}};case"dry-run":return{kind:"option",option:{dryRun:$===!0||$==="true"}};case"entry":return typeof $==="string"?{kind:"option",option:{entry:$}}:{kind:"option",option:{}};case"cache":if($==="false")return{kind:"option",option:{cache:!1}};return{kind:"option",option:{cache:typeof $==="string"?$:!0}};case"check":if($==="false")return{kind:"option",option:{check:!1}};return{kind:"option",option:{check:typeof $==="string"?$:!0}};case"types-format":return typeof $==="string"?{kind:"option",option:{typesOptions:{format:$}}}:{kind:"option",option:{}};case"format":return typeof $==="string"?{kind:"option",option:{format:$}}:{kind:"option",option:{}};default:return{kind:"unknown",arg:Z,suggestion:a3(Q)}}}function t3(j){let $={},Z=!1;for(let Q=0;Q<j.length;Q++){let Y=j[Q];if(!Y.startsWith("--"))return{kind:"unknown",arg:Y,positionalHint:Z?!0:void 0};let{result:J,consumedNext:K,flag:U}=r3(Y,j[Q+1]);if(J.kind!=="option")return J;if(Object.assign($,J.option),Z=d3.has(U),K)Q++}return{kind:"options",options:$}}async function n6(j){let $=t3(j.argv.slice(2));if($.kind==="help"){console.log(u3);return}if($.kind==="version"){console.log(D0.version);return}if($.kind==="usage-error"){console.error($.message),j.exitCode=N.USAGE_ERROR;return}if($.kind==="unknown"){let X=`Unknown flag: ${$.arg}`;if($.suggestion)X+=` Did you mean --${$.suggestion}?`;if($.positionalHint)X+=" (values are passed as --flag=value or --flag value)";console.error(X),console.error("Run sveld --help for a list of available flags."),j.exitCode=N.USAGE_ERROR;return}let Z=$.options,Q=await g0(),Y=C0(Q,Z);if(Q.typesOptions||Z.typesOptions)Y.typesOptions={...Q.typesOptions,...Z.typesOptions};if(Y.stdout){if(Y.stdout!==!0&&Y.stdout!=="json"&&Y.stdout!=="ndjson"){console.error(`sveld: --stdout must be "json" or "ndjson"; got "${Y.stdout}".`),j.exitCode=N.USAGE_ERROR;return}if([Y.json,Y.markdown,Y.customElements].filter(Boolean).length!==1){console.error("sveld: --stdout requires exactly one of --json, --markdown, or --custom-elements."),j.exitCode=N.USAGE_ERROR;return}if(Y.stdout==="ndjson"&&!Y.json){console.error("sveld: --stdout=ndjson is only valid with --json."),j.exitCode=N.USAGE_ERROR;return}if(Y.types===!0){console.error("sveld: --stdout cannot be combined with --types; type definitions span multiple files."),j.exitCode=N.USAGE_ERROR;return}if(Y.check){console.error("sveld: --stdout cannot be combined with --check; both write their document to stdout."),j.exitCode=N.USAGE_ERROR;return}}if(Y.format!==void 0&&Y.format!=="text"&&Y.format!=="json"){console.error(`sveld: --format must be "text" or "json"; got "${Y.format}".`),j.exitCode=N.USAGE_ERROR;return}X1(Y.quiet===!0);let J=Sj(Y.entry),K;if(J!==null)K=J;else if(f3(h3(j.cwd(),I0)))console.error(`sveld: could not resolve an entry point; falling back to "${I0}". Set package.json#svelte (or pass --entry) to avoid relying on this fallback.`),K=o(w(I0));else{j.exitCode=N.USAGE_ERROR;return}let U,H;try{if(U=await zj(K,Y.glob===!0,Yj(Y)),Y.check)H=await N0(U.components,_0(Y),{entryExports:U.entryExports});if(Y.stdout)await l1(U,Y,K);else if(await qj(U,Y,K),!Y.dryRun)U.cache?.save()}catch(X){console.error(X instanceof Error?X.message:String(X)),j.exitCode=N.GENERATION_FAILURE;return}let{diagnostics:z}=U;if((Y.reportDiagnostics||Y.strict)&&z.length>0)if(Y.format==="json")j.stderr.write(P0(z));else console.error(E0(z));if(H)if(Y.format==="json")j.stdout.write(x0(H));else console.log(y0(H));let G;if(H?.bump==="major")G=N.BREAKING_CHANGE;if(Y.strict&&z.length>0)G=G===void 0?N.DIAGNOSTICS:Math.min(G,N.DIAGNOSTICS);if(G!==void 0)j.exitCode=G}
|
|
230
|
-
export{g as a,z2 as b,_0 as c,N0 as d,y0 as e,x0 as f,E0 as g,Sj as h,k4 as i,g0 as j,C0 as k,Yj as l,zj as m,t as n,dj as o,O4 as p,v3 as q,qj as r,n6 as s};
|
package/lib/chunk-8myyzjb1.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
function q(w){return typeof w==="object"&&w!==null}function x(w){return q(w)&&w.type==="VariableDeclaration"&&Array.isArray(w.declarations)}function I(w){return q(w)&&w.type==="Literal"}function v(w){return q(w)&&w.type==="Identifier"&&typeof w.name==="string"}function L(w){return q(w)&&w.type==="MemberExpression"}function g(w){return q(w)&&w.type==="ObjectExpression"&&Array.isArray(w.properties)}function A(w){return q(w)&&w.type==="CallExpression"}function f(w,j){if(!A(w))return!1;return!!w.callee&&q(w.callee)&&w.callee.type==="Identifier"&&w.callee.name===j}function X(w){if(q(w)&&(w.type==="TSAsExpression"||w.type==="TSSatisfiesExpression")&&"expression"in w)return X(w.expression);return w}function n(w){if(q(w)&&(w.type==="TSAsExpression"||w.type==="TSSatisfiesExpression")&&"typeAnnotation"in w)return w.typeAnnotation;return}function G(w){return q(w)&&w.type==="NewExpression"}function T(w,j){if(!G(w))return!1;return!!w.callee&&q(w.callee)&&w.callee.type==="Identifier"&&w.callee.name===j}var b=Symbol("sveld.parsedComponentTypeScriptMetadata");function l(w){return w[b]}function s(w,j){if(j.length===0)return;let F=new Set(w.props.map((E)=>E.name));for(let E of j){if(F.has(E.name))continue;F.add(E.name),w.props.push({name:E.name,kind:"let",constant:!1,type:E.type,typeSource:"typescript",...E.description?{description:E.description}:{},isFunction:E.type.includes("=>"),isFunctionDeclaration:!1,isRequired:E.isRequired,reactive:!1})}}var O=/[\r\n]+/g;function D(w){if(w.sourceLineStartOffsetsCache)return w.sourceLineStartOffsetsCache;let j=[0];if(w.source){for(let F=0;F<w.source.length;F++)if(w.source[F]===`
|
|
2
|
-
`)j.push(F+1)}return w.sourceLineStartOffsetsCache=j,j}function J(w,j){if(!w.source||j<0||j>w.source.length)return;let F=D(w),E=0,k=F.length-1;while(E<=k){let V=Math.floor((E+k)/2),C=F[V],K=F[V+1]??Number.POSITIVE_INFINITY;if(j<C)k=V-1;else if(j>=K)E=V+1;else return{line:V+1,column:j-C}}return}function W(w,j,F){if(j===void 0||F===void 0||F<j)return;let E=J(w,j),k=J(w,F);if(!E||!k)return;return{start:E,end:k}}function y(w,j){if(!j||typeof j!=="object")return;let F="start"in j&&typeof j.start==="number"?j.start:void 0,E="end"in j&&typeof j.end==="number"?j.end:void 0;return W(w,F,E)}function r(w,j,F,E){if(!F||F.length===0||E===void 0)return;let k=[...F];while(k.length>1){let z=k[k.length-1];if(z.tokens.tag||!z.source.trim().endsWith("*/"))break;k.pop()}let V=E;for(let z=0;z<k[0].number-1;z++)V+=j[z]?.source.length??0,V+=1;let C=k[0],K=C.source.indexOf(C.tokens.tag??""),U=V+Math.max(K,0),Q=E,$=k[k.length-1],Y=$.number;for(let z=0;z<Y-1;z++)Q+=j[z]?.source.length??0,Q+=1;return Q+=$.source.length,W(w,U,Q)}function Z(w,j,F){return w.source?.slice(j,F)}function p(w,j){if(!j||typeof j!=="object")return;let F="start"in j&&typeof j.start==="number"?j.start:void 0,E="end"in j&&typeof j.end==="number"?j.end:void 0;if(F===void 0||E===void 0)return;return Z(w,F,E)?.replace(O," ")}var u=/[A-Za-z_$][\w$]*/g;function _(w,j){if(!j)return!1;let F=new Set(j[0].split(",").map((E)=>E.trim()));for(let[E]of w.matchAll(u))if(F.has(E))return!0;return!1}function P(w,j){if(j===void 0)return;return w.runesPropsDeclarationMetadataByDeclaratorStart.get(j)}function a(w,j,F){return P(w,j)?.props.get(F)}function d(w){if(!w||typeof w!=="object"||!("type"in w))return;if(w.type==="Identifier"&&"name"in w&&typeof w.name==="string")return w.name;if(w.type==="TSQualifiedName"&&"right"in w&&w.right&&typeof w.right==="object"&&"name"in w.right&&typeof w.right.name==="string")return w.right.name;return}function B(w){if(!w||typeof w!=="object"||!("type"in w))return;if(w.type==="Identifier"&&"name"in w&&typeof w.name==="string")return w.name;if(w.type==="TSQualifiedName"&&"left"in w&&w.left&&typeof w.left==="object")return B(w.left);return}function t(w,j){let F=j?.start,E=j?.end;if(F===void 0||E===void 0)return;return Z(w,F+1,E)?.trim()}function e(w,j){let F=j?.start,E=j?.end;if(F===void 0||E===void 0)return;return Z(w,F,E)?.trim()}function H(w,j,F,E,k=new Set){if(!j?.type)return;switch(j.type){case"TSInterfaceDeclaration":H(w,{type:"TSTypeLiteral",members:j.body?.body},F,E,k);return;case"TSTypeAliasDeclaration":case"TSParenthesizedType":case"TSTypeAnnotation":H(w,j.typeAnnotation,F,E,k);return;case"TSIntersectionType":case"TSUnionType":for(let V of j.types??[])H(w,V,F,E,k);return;case"TSTypeLiteral":for(let V of j.members??[]){if(V?.type!=="TSPropertySignature")continue;H(w,V.typeAnnotation?.typeAnnotation,F,E,k)}return;case"TSTypeReference":{let V=B(j.typeName);if(V){if(w.typeImportBindingsByLocalName.has(V))F.add(V);let C=w.localTypeDeclarationsByName.get(V);if(C&&!k.has(V))E.add(V),k.add(V),H(w,C.node,F,E,k),k.delete(V)}if("typeParameters"in j&&j.typeParameters&&typeof j.typeParameters==="object"){let C=j.typeParameters;for(let K of C.params??[])H(w,K,F,E,k)}return}case"TSArrayType":case"TSRestType":case"TSOptionalType":case"TSIndexedAccessType":case"TSTypeOperator":case"TSExpressionWithTypeArguments":case"TSTupleType":case"TSConditionalType":case"TSInferType":case"TSMappedType":case"TSFunctionType":case"TSConstructorType":case"TSTypeQuery":case"TSImportType":case"TSLiteralType":case"TSTypePredicate":case"TSNamedTupleMember":break;default:break}for(let V of Object.values(j)){if(!V||typeof V!=="object")continue;if(Array.isArray(V)){for(let C of V){if(!C||typeof C!=="object"||!("type"in C))continue;H(w,C,F,E,k)}continue}if("type"in V)H(w,V,F,E,k)}}function R(w,j){let F=new Map;for(let E of Array.from(j).sort()){let k=w.typeImportBindingsByLocalName.get(E);if(!k)continue;let V=F.get(k.source)??{default:[],named:[],namespace:[]};if(k.specifierType==="default")V.default.push(k.localName);else if(k.specifierType==="namespace")V.namespace.push(k.localName);else V.named.push({imported:k.importedName,local:k.localName});F.set(k.source,V)}return Array.from(F.entries()).sort(([E],[k])=>E.localeCompare(k)).map(([E,k])=>{if(k.namespace.length>0)return k.namespace.map((U)=>`import type * as ${U} from "${E}";`).join(`
|
|
3
|
-
`);let V=k.named.map(({imported:U,local:Q})=>{if(!U||U===Q)return Q;return`${U} as ${Q}`}),C=k.default[0],K=V.length>0?`{ ${V.join(", ")} }`:"";if(C&&K)return`import type ${C}, ${K} from "${E}";`;if(C)return`import type ${C} from "${E}";`;return`import type ${K} from "${E}";`})}function ww(w){if(w.typedRunesPropsDeclarations.length!==1)return;let[j]=w.typedRunesPropsDeclarations;if(!j.canonicalType)return;let F=Array.from(j.referencedLocalTypes).map((E)=>w.localTypeDeclarationsByName.get(E)).filter((E)=>E!==void 0).sort((E,k)=>E.start-k.start).map((E)=>E.code);return{canonicalPropsType:j.canonicalType,canonicalPropNames:Array.from(j.props.keys()).sort(),localTypeDeclarations:F,typeImportStatements:R(w,j.referencedImportedTypes),referencesComponentGenerics:_(j.canonicalType,w.generics)}}var h=/^[A-Za-z_$][\w$]*/,i=/[A-Za-z_$][\w$]*/g,M=/^(?:const|in|out)\s+/;function S(w){let j=[],F=0,E=0;for(let k=0;k<w.length;k++){let V=w[k];if(V==="<"||V==="("||V==="["||V==="{")F++;else if(V===">"||V===")"||V==="]"||V==="}")F=Math.max(F-1,0);else if(V===","&&F===0)j.push(w.slice(E,k)),E=k+1}return j.push(w.slice(E)),j}function kw(w){let j=S(w).map((E)=>E.trim()).filter((E)=>E.length>0);if(j.length===0)return null;return[j.map((E)=>{let k=E;while(M.test(k))k=k.replace(M,"");return k.match(h)?.[0]??E}).join(", "),j.join(", ")]}function Fw(w,j,F){let E=w.scriptGenericsAttribute?.value;if(!E)return;for(let[k]of E.matchAll(i)){if(w.typeImportBindingsByLocalName.has(k))j.add(k);if(F.has(k))continue;let V=w.localTypeDeclarationsByName.get(k);if(!V)continue;F.add(k),H(w,V.node,j,F)}}
|
|
4
|
-
export{q as u,x as v,I as w,v as x,L as y,g as z,f as A,X as B,n as C,T as D,b as E,l as F,s as G,W as H,y as I,r as J,Z as K,p as L,P as M,a as N,d as O,t as P,e as Q,H as R,ww as S,S as T,kw as U,Fw as V};
|
package/lib/chunk-f7112d82.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as a,X as b}from"./chunk-gc8z6pa7.js";import"./chunk-dcbq3977.js";import"./chunk-t9d5k3p7.js";export{b as parseModernAndLegacy,a as parse};
|
package/lib/chunk-h1r040pg.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{ba as O}from"./chunk-xryt7ad2.js";import{ha as F}from"./chunk-t9d5k3p7.js";import{existsSync as h,readdirSync as N,statSync as b}from"node:fs";import B from"node:path";var E="__sveld_resolved_props__",_="__SveldResolvedProps__",I=/ \| undefined$/,x=/[^A-Za-z0-9_-]/g,f=/[^A-Za-z0-9_$]/g,g=/^[0-9]/,y=2;class P{api;symbolFlags;typeFlags;tsconfigPath;overlay=new Map;constructor(J,K,Q,$){this.api=J,this.symbolFlags=K,this.typeFlags=Q,this.tsconfigPath=$}static async create(J=process.cwd()){let K=n(J);if(!K)return console.warn("Warning: `resolveTypes` could not locate a tsconfig.json. Skipping semantic resolution."),null;let Q;try{Q=await import("./chunk-denfbw92.js")}catch(q){return console.warn("Warning: `resolveTypes` requires the `typescript` package to be installed. Skipping semantic resolution.",q),null}let $=new P(null,Q.SymbolFlags,Q.TypeFlags,K),Z=new Q.API({cwd:J,fs:$.createFileSystem()});return $.api=Z,$}async expandAll(J){let K=new Map;if(J.length===0)return K;let Q=new Map;for(let Z of J){if(!Z.metadata.canonicalPropsType)continue;if(Z.metadata.referencesComponentGenerics)continue;let q=this.virtualFileName(Z.filePath,Z.moduleName);this.overlay.set(q,c(Z.metadata)),Q.set(q,Z)}if(Q.size===0)return K;let $=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:Array.from(Q.keys())}});try{let[Z]=Q.keys(),q=await $.getDefaultProjectForFile(Z);if(!q)return K;let W=q.checker,D=await Promise.all(Array.from(Q,async([H,C])=>{let Y=this.overlay.get(H);if(!Y)return null;let U=p(Y),M=await W.getTypeAtPosition(H,U);if(!M)return null;let X=new Map,w=await W.getPropertiesOfType(M);for(let V of w){if(!V.name||V.name.startsWith("__"))continue;X.set(V.name,{name:V.name,symbols:[V],forceOptional:!1})}if((M.flags&this.typeFlags.Union)!==0){let V=await M.getTypes(),T=await Promise.all(V.map((v)=>W.getPropertiesOfType(v)));for(let v of T)for(let k of v){if(!k.name||k.name.startsWith("__")||X.has(k.name))continue;let R=X.get(k.name);if(R)R.symbols.push(k);else X.set(k.name,{name:k.name,symbols:[k],forceOptional:!0})}}return{moduleName:C.moduleName,groups:Array.from(X.values())}})),j=[],A=[];D.forEach((H,C)=>{if(!H)return;H.groups.forEach((Y,U)=>{for(let M of Y.symbols)j.push(M),A.push({fileIndex:C,groupIndex:U})})});let S=j.length>0?await W.getTypeOfSymbol(j):[],G=await Promise.all(S.map((H)=>H?W.typeToString(H):Promise.resolve("any"))),L=new Map;j.forEach((H,C)=>{let{fileIndex:Y,groupIndex:U}=A[C],M=(H.flags&this.symbolFlags.Optional)!==0,X=G[C];if(M)X=X.replace(I,"");let w=L.get(Y)??new Map,z=w.get(U)??[];z.push(X),w.set(U,z),L.set(Y,w)}),D.forEach((H,C)=>{if(!H)return;let Y=L.get(C),U=H.groups.map((M,X)=>{let w=Y?.get(X)??[],z=!(M.forceOptional||M.symbols.some((V)=>(V.flags&this.symbolFlags.Optional)!==0));return{name:M.name,type:Array.from(new Set(w)).join(" | "),isRequired:z}});U.sort((M,X)=>M.name.localeCompare(X.name)),K.set(H.moduleName,U)})}finally{await $.dispose?.()}return K}async checkExamples(J){let K=new Map;if(J.length===0)return K;let Q=[];for(let Z of J)for(let q of Z.sources){let W=this.exampleFileName(Z.filePath,Z.moduleName,q.id);this.overlay.set(W,u(q)),Q.push({moduleName:Z.moduleName,source:q,file:W})}if(Q.length===0)return K;let $=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:Q.map((Z)=>Z.file)}});try{let[Z]=Q,q=await $.getDefaultProjectForFile(Z.file);if(!q)return K;await Promise.all(Q.map(async({moduleName:W,source:D,file:j})=>{let[A,S]=await Promise.all([q.program.getSyntacticDiagnostics(j),q.program.getSemanticDiagnostics(j)]),G=[...A,...S];if(G.length===0)return;let L=this.overlay.get(j)??"",H=G.map((Y)=>m(Y,L)).sort((Y,U)=>Y.line-U.line).map((Y)=>`Line ${Y.line}: ${Y.text}`).join(`
|
|
2
|
-
`),C=K.get(W)??[];C.push({id:D.id,name:D.name,message:H}),K.set(W,C)}))}finally{await $.dispose?.()}return K}async dispose(){this.overlay.clear(),await this.api?.close?.()}createFileSystem(){return{readFile:(J)=>this.overlay.get(O(J)),fileExists:(J)=>this.overlay.has(O(J))?!0:void 0,getAccessibleEntries:(J)=>{let K=O(J),Q=Array.from(this.overlay.keys()).filter((q)=>O(B.dirname(q))===K);if(Q.length===0)return;let $=[],Z=[];try{for(let q of N(J)){let W=B.join(J,q);try{(b(W).isDirectory()?Z:$).push(q)}catch{}}}catch{}for(let q of Q){let W=B.basename(q);if(!$.includes(W))$.push(W)}return{files:$,directories:Z}}}}virtualFileName(J,K){let Q=B.dirname(B.resolve(J));return O(B.join(Q,`__sveld_resolved_${K}.ts`))}exampleFileName(J,K,Q){let $=B.dirname(B.resolve(J)),Z=Q.replace(x,"_");return O(B.join($,`__sveld_example_${K}_${Z}.ts`))}}function c(J){return[...J.typeImportStatements,...J.localTypeDeclarations,`type ${_} = ${J.canonicalPropsType};`,`declare const ${E}: ${_};`].join(`
|
|
3
|
-
`)}function d(J){let K=J.replace(f,"_");if(K===""||g.test(K))return`_${K}`;return K}function u(J){return`const ${d(J.name)} = null as unknown as (${J.type});
|
|
4
|
-
${J.code}
|
|
5
|
-
`}function m(J,K){let Q=J.pos??0,$=K.slice(0,Q).split(`
|
|
6
|
-
`).length;return{line:Math.max(1,$-y+1),text:String(J.text??"").trim()}}function p(J){let K=J.lastIndexOf("declare const");return J.indexOf(E,K)+2}function n(J){let K=B.resolve(J);while(!0){let Q=B.join(K,"tsconfig.json");if(h(Q))return Q;let $=B.dirname(K);if($===K)return null;K=$}}export{P as TypeResolver};
|
package/lib/chunk-w5kk4gd1.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as d}from"./chunk-290pdrzm.js";import{E as a,F as b,G as c}from"./chunk-8myyzjb1.js";import"./chunk-gc8z6pa7.js";import"./chunk-dcbq3977.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-xryt7ad2.js
DELETED