sveld 0.35.2 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -6
- package/lib/browser.d.ts +660 -39
- package/lib/browser.js +172 -172
- package/lib/chunk-0fqdg2xa.js +20 -0
- package/lib/chunk-2vwf7nck.js +1 -0
- package/lib/chunk-8myyzjb1.js +4 -0
- package/lib/{chunk-v4q9vw0y.js → chunk-as5hgj7e.js} +57 -57
- package/lib/{chunk-zva3xjwa.js → chunk-denfbw92.js} +1 -1
- package/lib/chunk-h1r040pg.js +6 -0
- package/lib/chunk-m538qnhp.js +230 -0
- package/lib/chunk-r4rrncmd.js +1 -0
- package/lib/{chunk-1p4ka68s.js → chunk-t9d5k3p7.js} +1 -1
- package/lib/{chunk-8xw75w8t.js → chunk-tmj7vnjr.js} +2 -2
- package/lib/chunk-xryt7ad2.js +3 -0
- package/lib/cli-entry.js +1 -1
- package/lib/index.d.ts +767 -10
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/lib/ComponentParser.d.ts +0 -560
- package/lib/ast-guards.d.ts +0 -16
- package/lib/brands.d.ts +0 -11
- package/lib/bundle.d.ts +0 -174
- package/lib/check.d.ts +0 -43
- package/lib/chunk-72hx9e9w.js +0 -20
- package/lib/chunk-7qz0hzgw.js +0 -217
- package/lib/chunk-cxrw7gzr.js +0 -2
- package/lib/chunk-jdnsv86e.js +0 -1
- package/lib/chunk-pmj8c3yv.js +0 -6
- package/lib/chunk-s9mzxa4y.js +0 -1
- package/lib/chunk-xkrgedm4.js +0 -4
- package/lib/cli-entry.d.ts +0 -12
- package/lib/cli.d.ts +0 -28
- package/lib/create-exports.d.ts +0 -32
- package/lib/dependency-graph.d.ts +0 -20
- package/lib/diagnostics.d.ts +0 -34
- package/lib/element-tag-map.d.ts +0 -146
- package/lib/example-check.d.ts +0 -24
- package/lib/get-svelte-entry.d.ts +0 -3
- package/lib/load-config.d.ts +0 -62
- package/lib/parse-cache.d.ts +0 -28
- package/lib/parse-entry-exports.d.ts +0 -30
- package/lib/parse-exports.d.ts +0 -25
- package/lib/parsed-component-metadata.d.ts +0 -13
- package/lib/parser/bindings.d.ts +0 -4
- package/lib/parser/context.d.ts +0 -72
- package/lib/parser/contexts.d.ts +0 -19
- package/lib/parser/diagnostics.d.ts +0 -8
- package/lib/parser/events.d.ts +0 -21
- package/lib/parser/generics.d.ts +0 -24
- package/lib/parser/jsdoc.d.ts +0 -55
- package/lib/parser/prop-shared.d.ts +0 -84
- package/lib/parser/props.d.ts +0 -71
- package/lib/parser/rest-props.d.ts +0 -4
- package/lib/parser/runes-detection.d.ts +0 -13
- package/lib/parser/runes-props.d.ts +0 -18
- package/lib/parser/scopes.d.ts +0 -56
- package/lib/parser/slots.d.ts +0 -24
- package/lib/parser/source-position.d.ts +0 -26
- package/lib/parser/type-resolution.d.ts +0 -17
- package/lib/parser/typescript-casts.d.ts +0 -1
- package/lib/parser/utils.d.ts +0 -1
- package/lib/parser/variable-jsdoc.d.ts +0 -12
- package/lib/parser-stack.d.ts +0 -20
- package/lib/path.d.ts +0 -2
- package/lib/plugin.d.ts +0 -85
- package/lib/resolve-alias.d.ts +0 -30
- package/lib/resolve-types.d.ts +0 -52
- package/lib/sveld.d.ts +0 -29
- package/lib/svelte-parse.d.ts +0 -4
- package/lib/svelte-version.d.ts +0 -1
- package/lib/validate.d.ts +0 -13
- package/lib/watch.d.ts +0 -34
- package/lib/writer/MarkdownWriterBase.d.ts +0 -26
- package/lib/writer/Writer.d.ts +0 -31
- package/lib/writer/WriterMarkdown.d.ts +0 -31
- package/lib/writer/built-in-writers.d.ts +0 -1
- package/lib/writer/document-model.d.ts +0 -34
- package/lib/writer/format-generated-ts.d.ts +0 -8
- package/lib/writer/markdown-format-utils.d.ts +0 -20
- package/lib/writer/markdown-render-utils.d.ts +0 -10
- package/lib/writer/registry.d.ts +0 -17
- package/lib/writer/writer-custom-elements-core.d.ts +0 -86
- package/lib/writer/writer-custom-elements.d.ts +0 -15
- package/lib/writer/writer-json.d.ts +0 -27
- package/lib/writer/writer-markdown-core.d.ts +0 -32
- package/lib/writer/writer-markdown.d.ts +0 -23
- package/lib/writer/writer-ts-definitions-core.d.ts +0 -30
- package/lib/writer/writer-ts-definitions.d.ts +0 -43
package/lib/chunk-7qz0hzgw.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import{J as b0,u as m0,v as D0,w as r2}from"./chunk-xkrgedm4.js";import{Q as s2}from"./chunk-8xw75w8t.js";import{S as F}from"./chunk-cxrw7gzr.js";import{W as p0}from"./chunk-1p4ka68s.js";var W2="sveld",V0="0.35.2";var O2={name:W2,version:V0,license:"Apache-2.0",description:"Generate TypeScript definitions and component documentation for your Svelte components.",type:"module",main:"./lib/index.js",types:"./lib/index.d.ts",exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./browser":{types:"./lib/browser.d.ts",import:"./lib/browser.js",default:"./lib/browser.js"}},scripts:{test:"bun test --parallel","test:fixtures-types":"tsc --project tsconfig.fixtures.json","test:e2e":"bun tests/test-e2e.ts",format:"biome format --write .",lint:"biome lint .","lint:fix":"biome check --write --unsafe .",build:"bun scripts/build.ts",bench:"bun scripts/bench.ts","bench:cache":"bun scripts/bench.ts --cache",typecheck:"tsc --noEmit"},devDependencies:{"@biomejs/biome":"2.5.3","@types/bun":"^1.3.14","@types/jest":"^30.0.0",acorn:"^8.17.0","comment-parser":"^1.4.1",culls:"^0.2.0","estree-walker":"^3.0.3",svelte:"^5.56.3",typescript:"^7.0.2"},bin:{sveld:"cli.js"},files:["lib","cli.js"],repository:{type:"git",url:"git+https://github.com/carbon-design-system/sveld.git"},homepage:"https://github.com/carbon-design-system/sveld",bugs:"https://github.com/carbon-design-system/sveld/issues",keywords:["svelte","svelte component","documentation","docgen","typescript","definitions","JSDocs","vite","vite-plugin"],maintainers:["Eric Liu (https://github.com/metonym)"]};var k2="5.56.3";var X0=k2;var G0=1,L2=new WeakMap;function x(j,$={}){let Z=L2.get(j),Q=Z?.get($.entryExports);if(Q)return Q;let J=Array.from(j,([,K])=>{let{diagnostics:z,...H}=K;return H}).sort((K,z)=>K.moduleName.localeCompare(z.moduleName)),Y={schemaVersion:G0,generator:{name:W2,version:V0,svelteVersion:X0},total:J.length,components:J};if($.entryExports&&$.entryExports.length>0)Y.totalExports=$.entryExports.length,Y.exports=$.entryExports;if(!Z)Z=new Map,L2.set(j,Z);return Z.set($.entryExports,Y),Y}import{readFile as vj}from"node:fs/promises";import fj from"node:path";var B2={none:0,patch:1,minor:2,major:3};function hj(j,$){return B2[$]>B2[j]?$:j}function uj(j){return j.reduce(($,Z)=>hj($,Z.bump),"none")}function R2(j){let $=[],Z=0,Q="",J=null;for(let Y=0;Y<j.length;Y++){let K=j[Y];if(J){if(Q+=K,K==="\\")Y++,Q+=j[Y]??"";else if(K===J)J=null;continue}if(K==='"'||K==="'"||K==="`"){J=K,Q+=K;continue}if(K==="<"||K==="("||K==="{"||K==="[")Z++;if(K===">"||K===")"||K==="}"||K==="]")Z--;if(K==="|"&&Z===0){$.push(Q.trim()),Q="";continue}Q+=K}return $.push(Q.trim()),new Set($.filter((Y)=>Y.length>0))}function f0(j,$){if(j===$)return"none";if(j===void 0||$===void 0)return"major";let Z=R2(j),Q=R2($),J=[...Q].some((K)=>!Z.has(K)),Y=[...Z].some((K)=>!Q.has(K));if(!J&&!Y)return"none";if(J&&!Y)return"minor";if(Y&&!J)return"major";return"major"}function I2(j,$,Z,Q){let J=$==="prop"?"prop":"export",Y=[],K=new Map(Z.map((H)=>[H.name,H])),z=new Map(Q.map((H)=>[H.name,H]));for(let[H,U]of z){if(K.has(H))continue;Y.push({component:j,kind:$,name:H,bump:U.isRequired?"major":"minor",message:`${J} "${H}" added${U.isRequired?" (required)":""}`})}for(let[H]of K){if(z.has(H))continue;Y.push({component:j,kind:$,name:H,bump:"major",message:`${J} "${H}" removed`})}for(let[H,U]of K){let V=z.get(H);if(!V)continue;if(U.isRequired!==V.isRequired)Y.push({component:j,kind:$,name:H,bump:V.isRequired?"major":"minor",message:`${J} "${H}" became ${V.isRequired?"required":"optional"}`});let G=f0(U.type,V.type);if(G!=="none")Y.push({component:j,kind:$,name:H,bump:G,message:`${J} "${H}" type changed from \`${U.type??"unknown"}\` to \`${V.type??"unknown"}\``})}return Y}function mj(j,$,Z){let Q=[],J=new Map($.map((K)=>[K.name,K])),Y=new Map(Z.map((K)=>[K.name,K]));for(let[K]of Y){if(J.has(K))continue;Q.push({component:j,kind:"event",name:K,bump:"minor",message:`event "${K}" added`})}for(let[K]of J){if(Y.has(K))continue;Q.push({component:j,kind:"event",name:K,bump:"major",message:`event "${K}" removed`})}for(let[K,z]of J){let H=Y.get(K);if(!H)continue;if(z.type!==H.type){Q.push({component:j,kind:"event",name:K,bump:"major",message:`event "${K}" changed from ${z.type} to ${H.type}`});continue}let U=z.type==="dispatched"?z.detail:void 0,V=H.type==="dispatched"?H.detail:void 0,G=f0(U,V);if(G!=="none")Q.push({component:j,kind:"event",name:K,bump:G,message:`event "${K}" detail changed from \`${U??"unknown"}\` to \`${V??"unknown"}\``})}return Q}function M2(j){return j.name??"default"}function cj(j,$,Z){let Q=[],J=new Map($.map((K)=>[M2(K),K])),Y=new Map(Z.map((K)=>[M2(K),K]));for(let[K]of Y){if(J.has(K))continue;Q.push({component:j,kind:"slot",name:K,bump:"minor",message:`slot "${K}" added`})}for(let[K]of J){if(Y.has(K))continue;Q.push({component:j,kind:"slot",name:K,bump:"major",message:`slot "${K}" removed`})}for(let[K,z]of J){let H=Y.get(K);if(!H)continue;let U=f0(z.slot_props,H.slot_props);if(U!=="none")Q.push({component:j,kind:"slot",name:K,bump:U,message:`slot "${K}" props changed from \`${z.slot_props??"none"}\` to \`${H.slot_props??"none"}\``})}return Q}var dj=new Set(["description","source","componentCommentSource","tags"]);function q0(j){if(Array.isArray(j))return j.map(q0);if(j!==null&&typeof j==="object"){let $={};for(let[Z,Q]of Object.entries(j)){if(dj.has(Z))continue;$[Z]=q0(Q)}return $}return j}var lj=["generics","rest_props","extends","contexts","typedefs"];function ij(j,$,Z){let Q=[];for(let J of lj){let Y=JSON.stringify(q0($[J])),K=JSON.stringify(q0(Z[J]));if(Y!==K)Q.push({component:j,kind:"shape",name:J,bump:"major",message:`"${J}" changed (breaking)`})}return Q}function pj(j,$){let Z=$.moduleName;return[...I2(Z,"prop",j.props,$.props),...I2(Z,"moduleExport",j.moduleExports,$.moduleExports),...mj(Z,j.events,$.events),...cj(Z,j.slots,$.slots),...ij(Z,j,$)]}function aj(j,$){let Z=[],Q=new Map(j.components.map((Y)=>[Y.moduleName,Y])),J=new Map($.components.map((Y)=>[Y.moduleName,Y]));for(let[Y]of J){if(Q.has(Y))continue;Z.push({component:Y,kind:"component",bump:"minor",message:`component "${Y}" added`})}for(let[Y]of Q){if(J.has(Y))continue;Z.push({component:Y,kind:"component",bump:"major",message:`component "${Y}" removed`})}for(let[Y,K]of Q){let z=J.get(Y);if(!z)continue;Z.push(...pj(K,z))}return Z}async function sj(j){let $;try{$=await vj(fj.resolve(j),"utf-8")}catch(Z){if(Z.code==="ENOENT")return null;throw Z}try{return JSON.parse($)}catch{throw Error(`sveld: could not parse "${j}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function D2(j){if(typeof j.check==="string")return j.check;return j.jsonOptions?.outFile??"COMPONENT_API.json"}async function A2(j,$,Z={}){let Q=await sj($);if(Q===null)return{snapshotExists:!1,snapshotFile:$,changes:[],bump:"none"};if(Q.schemaVersion!==G0)return{snapshotExists:!0,snapshotFile:$,changes:[{component:"*",kind:"shape",bump:"none",message:`snapshot schemaVersion ${Q.schemaVersion} does not match the current schemaVersion ${G0}; skipping diff`}],bump:"none"};let J=x(j,{entryExports:Z.entryExports}),Y=aj(Q,J);return{snapshotExists:!0,snapshotFile:$,changes:Y,bump:uj(Y)}}var rj={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function T2(j){if(!j.snapshotExists)return`sveld --check: no snapshot found at "${j.snapshotFile}". Run \`sveld --json\` and commit the output first.`;if(j.changes.length===0)return`sveld --check: no API changes detected against "${j.snapshotFile}".`;let $=[],Z=j.changes.length;$.push(`sveld --check: ${Z} API change${Z===1?"":"s"} detected against "${j.snapshotFile}".`),$.push(`Suggested semver bump: ${j.bump}.`);let Q=new Map;for(let J of j.changes){let Y=Q.get(J.component)??[];Y.push(J),Q.set(J.component,Y)}for(let[J,Y]of Q){$.push(""),$.push(` ${J}`);for(let K of Y)$.push(` [${rj[K.bump]}] ${K.message}`)}return $.join(`
|
|
2
|
-
`)}import{existsSync as nj}from"node:fs";import{join as tj}from"node:path";import{pathToFileURL as oj}from"node:url";function u(j){return typeof j==="object"&&j!==null}function S2(j){if(!u(j))return{};let $=j.svelte;return typeof $==="string"?{svelte:$}:{}}function b2(j){if(!u(j))return{};let $={};if(typeof j.extends==="string")$.extends=j.extends;if(u(j.compilerOptions)){let Z={};if(typeof j.compilerOptions.baseUrl==="string")Z.baseUrl=j.compilerOptions.baseUrl;if(u(j.compilerOptions.paths)){let Q={};for(let[J,Y]of Object.entries(j.compilerOptions.paths))if(Array.isArray(Y)&&Y.every((K)=>typeof K==="string"))Q[J]=Y;if(Object.keys(Q).length>0)Z.paths=Q}if(Object.keys(Z).length>0)$.compilerOptions=Z}return $}var ej=["sveld.config.js","sveld.config.mjs","sveld.config.ts"];function s1(j){return j}function j3(j=process.cwd()){for(let $ of ej){let Z=tj(j,$);if(nj(Z))return Z}return null}async function $3(j){let $;try{$=await import(`${oj(j).href}?t=${Date.now()}`)}catch(Q){let J=Q instanceof Error?Q.message:String(Q);throw Error(`sveld: failed to load config file "${j}".
|
|
3
|
-
${J}`)}let Z=$.default;if(!u(Z)||Array.isArray(Z))throw Error(`sveld: config file "${j}" must export a configuration object as its default export. Did you forget \`export default defineConfig({ ... })\`?`);return Z}async function F2(j=process.cwd()){let $=j3(j);if($===null)return{};return $3($)}function _2(...j){return Object.assign({},...j.filter(Boolean))}var h0=new Map;function p(j){h0.set(j.name,j)}function u0(j){return h0.get(j)}function n1(){return Array.from(h0.values())}import{dirname as M1}from"node:path";import{lstatSync as n2,readdirSync as l3,readFileSync as i3,realpathSync as p3,statSync as a3}from"node:fs";import{readFile as s3}from"node:fs/promises";import{dirname as r3,isAbsolute as n3,join as t3,parse as n0,relative as o3,resolve as e}from"node:path";function a(j){return j}function y(j){if(j==="")return j;return j.startsWith(".")?j:`./${j}`}import{dirname as Z3,resolve as Q3}from"node:path";var J3=/\.svelte$/,Y3=/^(['"])(.*)\1$/;function K3(j,$){let Z=j.extends?.import;if(Z===void 0)return null;let Q=Z.replace(Y3,"$2");if(!J3.test(Q))return null;return Q3(Z3($),Q)}function s(j,$){let Z=new Map;for(let Q of j.values()){let J=$(Q.filePath),Y=K3(Q,J);if(Y===null)continue;let K=Z.get(Y);if(K===void 0)K=new Set,Z.set(Y,K);K.add(J)}return Z}function W0(j,$){let Z=new Set,Q=[];for(let J of j)if(!Z.has(J))Z.add(J),Q.push(J);while(Q.length>0){let J=Q.shift(),Y=$.get(J);if(Y===void 0)continue;for(let K of Y)if(!Z.has(K))Z.add(K),Q.push(K)}return Z}var U3={"prop-unknown-type":"Props without inferred types","context-any-type":"Context values typed as `any`","event-no-source":"@event tags with no dispatch or callback","example-compile-error":"@example blocks that failed to compile","syntax-skipped":"Component syntax sveld skipped"},z3=["prop-unknown-type","context-any-type","event-no-source","example-compile-error","syntax-skipped"];function O0(j){let $=new Set,Z=[];for(let Q of j){let J=`${Q.component}:${Q.kind}:${Q.name}`;if($.has(J))continue;$.add(J),Z.push(Q)}return Z}function N2(j){if(j.length===0)return"sveld: all types resolved.";let $=[],Z=j.length;$.push(`sveld: ${Z} unresolved type${Z===1?"":"s"} found.`);for(let Q of z3){let J=j.filter((K)=>K.kind===Q);if(J.length===0)continue;$.push(""),$.push(`${U3[Q]} (${J.length}):`);let Y=new Map;for(let K of J){let z=Y.get(K.component)??[];z.push(K),Y.set(K.component,z)}for(let[K,z]of Y){$.push(` ${K}`);for(let H of z){let U=H.source?` (${K}:${H.source.start.line}:${H.source.start.column})`:"";$.push(` - ${H.message}${U}`)}}}return $.join(`
|
|
4
|
-
`)}var H3=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,V3=new Set(["","js","jsx","ts","tsx","javascript","typescript"]);function X3(j){let $=j.trim();if($==="")return null;let Z=$.match(H3);if(Z){let Q=Z[1].toLowerCase();if(!V3.has(Q))return null;let J=Z[2].trim();return J===""?null:J}if($.startsWith("<"))return null;return $}function w2(j){if(!j.isFunction)return"any";return`(${(j.params??[]).map((Z)=>`${Z.name}${Z.optional?"?":""}: any`).join(", ")}) => any`}function k0(j,$,Z,Q,J){let Y=(j??[]).filter((z)=>z.name==="example"),K=[];return Y.forEach((z,H)=>{let U=X3(z.body);if(U===null)return;let V=Y.length>1;K.push({id:V?`${$}#${H}`:$,name:V?`${Z} (example ${H+1})`:Z,type:Q,code:U,...J?{source:J}:{}})}),K}function C2(j){return j.name??"default"}function x2(j){let $=[];for(let Z of j.props)$.push(...k0(Z.tags,`prop:${Z.name}`,Z.name,w2(Z),Z.source));for(let Z of j.moduleExports)$.push(...k0(Z.tags,`export:${Z.name}`,Z.name,w2(Z),Z.source));for(let Z of j.slots)$.push(...k0(Z.tags,`slot:${C2(Z)}`,C2(Z),"any",Z.source));for(let Z of j.events)$.push(...k0(Z.tags,`event:${Z.name}`,Z.name,"any",Z.source));return $}import{createHash as G3}from"node:crypto";import{mkdirSync as q3,readFileSync as W3,writeFileSync as O3}from"node:fs";import{dirname as k3,isAbsolute as L3,join as B3,resolve as g2}from"node:path";var c0=1,R3=B3("node_modules",".cache","sveld","parse-cache.json");function d0(){return`${V0}+svelte@${X0}`}function y2(j,$){if(typeof $==="string")return L3($)?$:g2(j,$);return g2(j,R3)}function P2(j){return G3("sha256").update(j).digest("hex")}function E2(){return{formatVersion:c0,toolchainVersion:d0(),entries:{}}}function I3(j){try{let $=W3(j,"utf-8"),Z=JSON.parse($);if(Z.formatVersion!==c0||Z.toolchainVersion!==d0())return E2();return Z}catch{return E2()}}class l0{cacheFilePath;file;next=new Map;blocked=new Set;constructor(j){this.cacheFilePath=j,this.file=I3(j)}has(j,$){if(this.blocked.has(j))return!1;let Z=this.file.entries[j];return Z!==void 0&&Z.hash===$}get(j,$){if(this.blocked.has(j))return null;let Z=this.file.entries[j];if(Z===void 0||Z.hash!==$)return null;if(this.next.set(j,Z),Z.typeScriptMetadata!==void 0)Z.parsed[m0]=Z.typeScriptMetadata;return Z.parsed}set(j,$,Z){this.next.set(j,{hash:$,parsed:Z,typeScriptMetadata:Z[m0]})}invalidate(j){this.blocked.add(j)}save(){q3(k3(this.cacheFilePath),{recursive:!0});let j={formatVersion:c0,toolchainVersion:d0(),entries:Object.fromEntries(this.next)};O3(this.cacheFilePath,JSON.stringify(j))}}import{existsSync as R0,lstatSync as u2,readFileSync as _3}from"node:fs";import{dirname as l2,join as N3,relative as w3,resolve as i2}from"node:path";var m=null,i0=null;function c(){if(m)return Promise.resolve(m);if(!i0)i0=Promise.all([import("./chunk-jdnsv86e.js"),import("./chunk-s9mzxa4y.js")]).then(([j,$])=>{return m={ComponentParser:j.default,parseSvelte:$.parse},m});return i0}function r(){if(!m)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return m}import{existsSync as f2,readFileSync as M3}from"node:fs";import{dirname as a0,isAbsolute as D3,join as A3,relative as T3,resolve as B0}from"node:path";var L0=new Map,v2=new Map,S3=/\/\*[\s\S]*?\*\/|\/\/.*/g,b3=/[.+?^${}()|[\]\\]/g;function F3(j){let $=j,Z=B0($,"/");while($!==Z){for(let Q of["tsconfig.json","jsconfig.json"]){let J=A3($,Q);if(f2(J))return J}$=a0($)}return null}function h2(j){if(L0.has(j))return L0.get(j)??null;try{let $=M3(j,"utf-8"),Z;try{Z=JSON.parse($)}catch{let J=$.replace(S3,"");Z=JSON.parse(J)}let Q=b2(Z);if(Q.extends){let J=D3(Q.extends)?Q.extends:B0(a0(j),Q.extends),Y=J.endsWith(".json")?J:`${J}.json`;if(f2(Y)){let K=h2(Y);if(K)Q.compilerOptions={...K.compilerOptions,...Q.compilerOptions,paths:{...K.compilerOptions?.paths,...Q.compilerOptions?.paths}}}}return L0.set(j,Q),Q}catch{return L0.set(j,null),null}}function n(j,$){if(j.startsWith(".")||j.startsWith("/"))return j;let Z=F3($);if(!Z)return j;let Q=h2(Z);if(!Q?.compilerOptions?.paths)return j;let{baseUrl:J=".",paths:Y}=Q.compilerOptions,K=a0(Z),z=B0(K,J);for(let[H,U]of Object.entries(Y)){let V=v2.get(H);if(!V){let q=H.split("*").map((W)=>W.replace(b3,"\\$&")).join("(.*)");V=new RegExp(`^${q}$`),v2.set(H,V)}let G=j.match(V);if(G){let q=U[0];if(!q)continue;let W=q;for(let X=1;X<G.length;X++)W=W.replace("*",G[X]);return B0(z,W)}}return j}function t(j,$){if(j.startsWith(".")||j.startsWith("/"))return j;let Z=n(j,$);if(Z===j)return j;let Q=T3($,Z);return Q=F(Q),Q.startsWith(".")?Q:`./${Q}`}var m2=[".ts",".mts",".cts",".tsx",".js",".mjs",".cjs",".jsx",".d.ts"],C3=/\r?\n/,x3=/^\s*\*+/;function T(j){return j&&typeof j==="object"?j:void 0}function o(j){return Array.isArray(j)?j:[]}function E(j){if(j&&j.type==="Identifier"&&typeof j.name==="string")return j.name;return}function s0(j,$){let Z=n(j,$),Q=i2($,Z);if(R0(Q)&&u2(Q).isFile())return Q;for(let J of m2){let Y=Q+J;if(R0(Y))return Y}if(R0(Q)&&u2(Q).isDirectory())for(let J of m2){let Y=N3(Q,`index${J}`);if(R0(Y))return Y}return null}function g3(j,$){let Z=j.slice(0,$).trimEnd();if(!Z.endsWith("*/"))return;let Q=Z.length-2,J=Z.lastIndexOf("/**",Q);if(J===-1)return;let Y=[];for(let K of Z.slice(J+3,Q).split(C3)){let z=K.replace(x3,"").trim();if(z.startsWith("@"))break;if(z)Y.push(z)}return Y.join(" ")||void 0}function d(j,$){if(!$)return;return j.text.slice($.start,$.end)}function E3(j,$){let Z=T($?.typeAnnotation);if(Z?.type!=="TSTypeAnnotation")return;return d(j,T(Z.typeAnnotation))}function c2(j,$){let Z=o($.params).map((Y)=>d(j,Y)??"").join(", "),Q=T($.returnType),J=Q?.type==="TSTypeAnnotation"?d(j,T(Q.typeAnnotation)):void 0;return`(${Z})${J?` => ${J}`:""}`}function y3(j){if(j.type==="Literal"){let $=j.value;if(typeof $==="string")return"string";if(typeof $==="number")return"number";if(typeof $==="boolean")return"boolean"}if(j.type==="TemplateLiteral")return"string";return}function d2(j,$,Z){let Q=j.filePath,J=g3(j.text,Z);if($.type==="VariableDeclaration"){let Y=$.kind??"const",K=[];for(let z of o($.declarations)){let H=T(z.id),U=E(H);if(!U)continue;let V=E3(j,H),G,q=T(z.init);if(q){if(q.type==="ArrowFunctionExpression"||q.type==="FunctionExpression"){if(!V)V=c2(j,q)}else if(G=d(j,q),!V)V=y3(q)}K.push({name:U,kind:Y,type:V,value:G,description:J,declFile:Q,isTypeOnly:!1})}return K}if($.type==="FunctionDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"function",type:c2(j,$),description:J,declFile:Q,isTypeOnly:!1}]}if($.type==="ClassDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"class",type:Y,description:J,declFile:Q,isTypeOnly:!1}]}if($.type==="TSTypeAliasDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"type",type:d(j,T($.typeAnnotation)),description:J,declFile:Q,isTypeOnly:!0}]}if($.type==="TSInterfaceDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"interface",type:d(j,T($.body)),description:J,declFile:Q,isTypeOnly:!0}]}if($.type==="TSEnumDeclaration"){let Y=E(T($.id));if(!Y)return[];return[{name:Y,kind:"enum",type:Y,description:J,declFile:Q,isTypeOnly:!1}]}return[]}function P3(j){let $;try{$=_3(j,"utf-8")}catch{return null}let Z=`<script lang="ts">
|
|
5
|
-
${$}
|
|
6
|
-
</script>`;try{let Q=r().parseSvelte(Z,{modern:!0}),J=o(Q.instance?.content?.body);return{source:{text:Z,filePath:j,dir:l2(j)},body:J}}catch(Q){let J=Q instanceof Error?Q.message:String(Q);return console.warn(`Warning: Failed to parse entry export module ${j}: ${J}`),null}}function v3(j,$){for(let Z of j){if(Z.type!=="ImportDeclaration")continue;let Q=T(Z.source)?.value;if(typeof Q!=="string")continue;for(let J of o(Z.specifiers)){if(J.type!=="ImportSpecifier")continue;if(E(T(J.local))===$){let Y=E(T(J.imported))??$;return{specifier:Q,importedName:Y}}}}return null}function I0(j,$){let Z=$.cache.get(j);if(Z)return Z;if($.computing.has(j))return[];$.computing.add(j);let Q=P3(j);if(!Q)return $.computing.delete(j),$.cache.set(j,[]),[];let{source:J,body:Y}=Q,K=[],z=new Map;for(let U of Y){let V=U.type==="ExportNamedDeclaration"?T(U.declaration):U;if(!V)continue;for(let G of d2(J,V,V.start))z.set(G.name,G)}let H=(U)=>{let V=z.get(U);if(V)return V;let G=v3(Y,U);if(!G||G.specifier.endsWith(".svelte"))return null;let q=s0(G.specifier,J.dir);if(!q)return null;return I0(q,$).find((W)=>W.name===G.importedName)??null};for(let U of Y){if(U.type==="ExportAllDeclaration"){let L=T(U.source)?.value;if(typeof L!=="string"||L.endsWith(".svelte"))continue;let X=s0(L,J.dir);if(!X)continue;let k=U.exportKind==="type";for(let I of I0(X,$))K.push(k?{...I,isTypeOnly:!0}:I);continue}if(U.type!=="ExportNamedDeclaration")continue;let V=T(U.declaration);if(V){K.push(...d2(J,V,U.start));continue}let G=T(U.source)?.value,q=typeof G==="string"?G:void 0;if(q?.endsWith(".svelte"))continue;let W=U.exportKind==="type";for(let L of o(U.specifiers)){if(L.type!=="ExportSpecifier")continue;let X=E(T(L.exported)),k=E(T(L.local));if(!X||!k||k==="default"||X==="default")continue;let I=W||L.exportKind==="type",O=null;if(q){let M=s0(q,J.dir);if(M)O=I0(M,$).find((D)=>D.name===k)??null}else O=H(k);if(O?.declFile.endsWith(".svelte"))continue;if(O)K.push({...O,name:X,isTypeOnly:O.isTypeOnly||I});else K.push({name:X,kind:I?"type":"const",declFile:j,isTypeOnly:I})}}return $.computing.delete(j),$.cache.set(j,K),K}async function M0(j){await c();let $=i2(j),Z=l2($),Q=I0($,{cache:new Map,computing:new Set}),J=new Map;for(let Y of Q){let{declFile:K,...z}=Y,H=F(`./${w3(Z,K)}`);J.set(Y.name,{...z,source:H})}return Array.from(J.values()).sort((Y,K)=>Y.name.localeCompare(K.name))}import{lstatSync as f3,readdirSync as h3,readFileSync as u3}from"node:fs";import{dirname as m3,join as p2,resolve as c3}from"node:path";var a2=new Map;function d3(j){return s2(j,{ecmaVersion:"latest",sourceType:"module"})}function r0(j,$,Z=new Set){let Q=a2.get(j);if(!Q)Q=d3(j),a2.set(j,Q);let J={};for(let Y of Q.body)if(Y.type==="ExportDefaultDeclaration"){let K=Y.declaration.name;if(K in J)J[K].default=!0;else J[K]={source:y(""),default:!0}}else if(Y.type==="ExportAllDeclaration"){if(!Y.source)continue;let K=n(Y.source.value,$),z=c3($,K);if(!f3(z).isFile()){let V=h3(z);for(let G of V)if(G.includes("index")){z=p2(z,G);break}}if(Z.has(z))continue;Z.add(z);let H=u3(z,"utf-8"),U=r0(H,m3(z),Z);Z.delete(z);for(let[V,G]of Object.entries(U)){let q=y(F(`./${p2(Y.source.value,G.source)}`));J[V]={...G,source:q}}}else if(Y.type==="ExportNamedDeclaration")for(let K of Y.specifiers){let z=K.exported.name,H=K.local.name,U=z||H;if(U in J){if(Y.type==="ExportNamedDeclaration")J[U].mixed=!0;if(!J[U].source)J[U].source=y(t(Y.source?.value??"",$))}else J[U]={source:y(t(Y.source?.value??"",$)),default:H==="default"}}else if(Y.type==="ImportDeclaration"){let K=Y.specifiers[0].local.name;if(K in J){if(!J[K].source)J[K].source=y(t(Y.source?.value??"",$))}else J[K]={source:y(t(Y.source?.value??"",$)),default:K==="default"}}return J}function j0(j){return{failFast:j?.failFast,resolveTypes:j?.resolveTypes===!0,documentExports:j?.documentExports===!0,cache:j?.cache,checkExamples:j?.checkExamples===!0}}var e3=/<style.+?<\/style>/gims,j5=/-/g;function $5(j){if(!j.includes("<style"))return j;try{let $=r().parseSvelte(j,{modern:!1}),Z=$.css?.start,Q=$.css?.end;if(Z===void 0||Q===void 0)return j;return`${j.slice(0,Z)}${j.slice(Q)}`}catch{return j.replace(e3,"")}}function t2(j,$=[],Z=new Set){let Q;try{let J=p3(j);if(Z.has(J))return $;Z.add(J),Q=l3(j,{withFileTypes:!0})}catch{return $}for(let J of Q){if(J.name.startsWith("."))continue;let Y=t3(j,J.name),K=J.isSymbolicLink()?a3(Y,{throwIfNoEntry:!1}):J;if(!K)continue;if(K.isDirectory())t2(Y,$,Z);else if(K.isFile()&&J.name.endsWith(".svelte"))$.push(Y)}return $}function t0(j){return t2(j).map(($)=>{let Z=n0($).name.replace(j5,""),Q=y(F(`./${o3(j,$)}`));return{moduleName:Z,source:Q}})}function A0(j,$,Z=!1){let Q=n2(j).isFile(),J=Q?r3(j):j,Y=e(J),K=(U)=>n3(U)?e(U):e(Y,U),z={};if(Q){let U=i3(j,"utf-8");try{z=r0(U,Y,new Set([e(j)]))}catch(V){if(!Z)throw V;let G=V instanceof Error?V.message:String(V);console.warn(`Warning: Failed to parse component exports from ${j}: ${G}`)}}let H={...z};if($)for(let{moduleName:U,source:V}of t0(Y)){if(z[U])z[U].source=V;if(H[U])H[U].source=V;else H[U]={source:V,default:!1}}return{exports:z,allComponents:H,rootDir:Y,resolveComponentFilePath:K}}async function $0(j){let $=await Promise.all(Array.from(j).map(async(Z)=>{try{let Q=await s3(Z,"utf-8");return{path:Z,content:Q}}catch(Q){return console.warn(`Warning: Failed to read file ${Z}:`,Q),{path:Z,content:null}}}));return new Map($.map(({path:Z,content:Q})=>[Z,Q]))}function P([j,$],Z,Q,J,Y={}){let K=$.source,{ext:z,name:H}=n0(K),U=j;if(Z.length===1&&j==="default")U=H;if(z===".svelte"){let V=J(K),G=Q.get(V);if(G===null||G===void 0)return null;let q=F(K),W=Y.memo?.get(V),L=Y.hashes?.get(V),X=W===void 0?L===void 0?null:Y.cache?.get(V,L):null,k;if(W!==void 0)k=W;else if(X)k=X;else{let I=new(r()).ComponentParser;try{k=I.parseSvelteComponent($5(G),{moduleName:U,filePath:q})}catch(O){if(Y.failFast)throw O;let M=O instanceof Error?O.message:String(O),D=O instanceof Error?O.stack:void 0;return Y.onParseError?.({filePath:q,moduleName:U,message:M,stack:D}),null}if(L!==void 0)Y.cache?.set(V,L,k);Y.memo?.set(V,k)}return{moduleName:U,filePath:q,...k}}return null}function T0(j,$){let Z=new Set;for(let Q of j)for(let[,J]of Q)if(n0(J.source).ext===".svelte")Z.add($(J.source));return Z}function Z0(j){if(j.length===0)return;console.error(`sveld: failed to parse ${j.length} component(s):`);for(let{filePath:$,message:Z}of j)console.error(` - ${$}: ${Z}`)}async function Q0(j,$,Z={}){let Q=Z.documentExports===!0,{exports:J,allComponents:Y,rootDir:K,resolveComponentFilePath:z}=A0(j,$,Q),H=Q&&n2(j).isFile()?await M0(e(j)):[],U=Object.entries(J),V=Object.entries(Y),G=T0([U,V],z),q=await $0(G),W=new Map,L=new Map,X=Z.cache===!1?void 0:new l0(y2(K,Z.cache??!0)),k=new Set,I=new Map;if(X)for(let B of G){let R=q.get(B);if(R===null||R===void 0)continue;let b=P2(R);if(I.set(B,b),!X.has(B,b))k.add(B)}if(G.size>0&&(!X||k.size>0))await c();let O=new Map,M=new Map,D={failFast:Z.failFast===!0,onParseError:(B)=>O.set(B.filePath,B),cache:X,hashes:I,memo:M};for(let B of U){let R=P(B,U,q,z,D);if(R)W.set(R.moduleName,R)}for(let B of V){let R=P(B,V,q,z,D);if(R)L.set(R.moduleName,R)}if(X&&k.size>0){let B=s(L,z),R=W0(k,B);for(let b of R){if(k.has(b))continue;X.invalidate(b),M.delete(b)}for(let b of U){let v=z(b[1].source);if(!R.has(v)||k.has(v))continue;let C=P(b,U,q,z,D);if(C)W.set(C.moduleName,C)}for(let b of V){let v=z(b[1].source);if(!R.has(v)||k.has(v))continue;let C=P(b,V,q,z,D);if(C)L.set(C.moduleName,C)}}let S=Array.from(O.values());Z0(S),X?.save();let _=Z.resolveTypes?Z5(W):[],N=Z.checkExamples?J5(L):[];if(_.length>0||N.length>0){let{TypeResolver:B}=await import("./chunk-pmj8c3yv.js"),R=await B.create(K);try{if(_.length>0)await Q5(_,R,z);if(N.length>0)await Y5(N,R,z)}finally{await R?.dispose()}}let A=O0(Array.from(L.values()).flatMap((B)=>B.diagnostics??[]));return{exports:J,entryExports:H,components:W,allComponentsForTypes:L,errors:S,diagnostics:A}}function Z5(j){let $=[];for(let Z of j.values()){let Q=D0(Z);if(!Q?.canonicalPropsType||Z.props.length>0)continue;$.push({component:Z,metadata:Q})}return $}async function Q5(j,$,Z){if(!$)return;let Q=await $.expandAll(j.map(({component:J,metadata:Y})=>({moduleName:J.moduleName,metadata:Y,filePath:Z(J.filePath)})));for(let{component:J}of j){let Y=Q.get(J.moduleName);if(Y)r2(J,Y)}}function J5(j){let $=[];for(let Z of j.values()){let Q=x2(Z);if(Q.length===0)continue;$.push({component:Z,sources:Q})}return $}async function Y5(j,$,Z){if(!$)return;let Q=await $.checkExamples(j.map(({component:J,sources:Y})=>({moduleName:J.moduleName,filePath:Z(J.filePath),sources:Y})));for(let{component:J,sources:Y}of j){let K=Q.get(J.moduleName);if(!K||K.length===0)continue;let z=new Map(Y.map((U)=>[U.id,U.source])),H=J.diagnostics??[];for(let U of K){let V=z.get(U.id);H.push({component:J.filePath,kind:"example-compile-error",name:U.name,message:U.message,...V?{source:V}:{}})}J.diagnostics=H}}import{existsSync as o2,readFileSync as K5}from"node:fs";import{join as e2}from"node:path";function S0(j){if(j){let Z=e2(process.cwd(),j);if(o2(Z))return a(j);return console.error(`Invalid entry point: ${Z}. Pass a valid --entry (or "entry" option), or unset it and`),console.error('set the "svelte" field in your package.json instead.'),null}let $=e2(process.cwd(),"package.json");if(!o2($))return console.error("Could not locate a package.json file."),console.error(`Specify an entry point with --entry (or the "entry" option) instead.
|
|
7
|
-
`),null;try{let Z=S2(JSON.parse(K5($,"utf-8")));if(Z.svelte?.trim())return a(Z.svelte);return console.error(`Could not determine an entry point.
|
|
8
|
-
`),console.error(`Specify an entry point to your Svelte code in the "svelte" field of your package.json, or pass --entry (or the "entry" option).
|
|
9
|
-
`),null}catch(Z){throw console.error("Error reading package.json:",Z),Z}}import{lstatSync as U5}from"node:fs";import{resolve as jj}from"node:path";var z5=/\.svelte$/;async function $j(j,$,Z=!1){let{exports:Q,allComponents:J,rootDir:Y,resolveComponentFilePath:K}=A0(j,$,Z),z=Z&&U5(j).isFile()?await M0(jj(j)):[],H=Object.entries(Q),U=Object.entries(J),V=new Map,G=new Map;await c();let q=new Map,W={onParseError:(O)=>q.set(O.filePath,O)},L=()=>({exports:Q,entryExports:z,components:V,allComponentsForTypes:G,errors:Array.from(q.values()),diagnostics:O0(Array.from(G.values()).flatMap((O)=>O.diagnostics??[]))});{let O=T0([H,U],K),M=await $0(O);for(let D of H){let S=P(D,H,M,K,W);if(S)V.set(S.moduleName,S)}for(let D of U){let S=P(D,U,M,K,W);if(S)G.set(S.moduleName,S)}Z0(L().errors)}let X=s(G,K),k=(O,M,D,S)=>{let _=new Set;for(let N of M){let A=K(N[1].source);if(!D.has(A))continue;let B=P(N,M,S,K,W);if(B)O.set(B.moduleName,B),_.add(A);else for(let[R,b]of O)if(K(b.filePath)===A)O.delete(R)}return _};return{get result(){return L()},update:async(O)=>{let M=O.filter((A)=>z5.test(A)).map((A)=>jj(A));if(M.length===0)return{result:L(),reparsed:[]};if($)for(let{moduleName:A,source:B}of t0(Y)){let R=J[A];if(R)R.source=B;else{let b={source:B,default:!1};J[A]=b,U.push([A,b])}}let D=W0(M,X);for(let[A,B]of q)if(D.has(K(B.filePath)))q.delete(A);let S=await $0(D),_=new Set;for(let A of k(V,H,D,S))_.add(A);for(let A of k(G,U,D,S))_.add(A);X=s(G,K);let N=L();return Z0(N.errors),{result:N,reparsed:Array.from(_)}}}}import o0 from"node:path";import{mkdir as H5,readFile as V5,writeFile as X5}from"node:fs/promises";import{parse as G5}from"node:path";class l{async write(j,$){try{if(await V5(j,"utf-8")===$)return!1}catch{}return await H5(G5(j).dir,{recursive:!0}),await X5(j,$),!0}}function J0(){return new l}function Zj(){return new l}var q5=new Set(["string","number","boolean"]);function W5(j){return j.map(($)=>({kind:"field",name:$.name,...$.type?{type:{text:$.type}}:{},...$.value===void 0?{}:{default:$.value},...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function O5(j){let $=new Map;for(let Q of j){if(!Q.type||!q5.has(Q.type.trim()))continue;let J=Q.name.toLowerCase(),Y=$.get(J);if(Y)Y.push(Q);else $.set(J,[Q])}let Z=[];for(let[Q,J]of $){if(J.length!==1)continue;let Y=J[0];Z.push({name:Q,fieldName:Y.name,type:{text:Y.type},...Y.value===void 0?{}:{default:Y.value},...Y.description?{description:Y.description}:{}})}return Z}function k5(j){return j.filter(($)=>$.type==="dispatched").map(($)=>({name:$.name,type:{text:`CustomEvent<${$.detail??"unknown"}>`},...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function L5(j){return j.map(($)=>({name:$.default?"":$.name??"",...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function B5(j){let $={kind:"class",name:j.moduleName,...j.componentComment?{description:j.componentComment}:{},members:W5(j.props),attributes:O5(j.props),events:k5(j.events),slots:L5(j.slots)};if(j.customElementTag)$.tagName=j.customElementTag,$.customElement=!0;return $}function R5(j,$){let Z=[{kind:"js",name:j.moduleName,declaration:{name:j.moduleName,module:$}}];if(j.customElementTag)Z.push({kind:"custom-element-definition",name:j.customElementTag,declaration:{name:j.moduleName,module:$}});return Z}function Qj(j,$={}){let Z=x(j),Q=$.resolveModulePath??((Y)=>Y.filePath);return{schemaVersion:"1.0.0",modules:Z.components.map((Y)=>{let K=Q(Y);return{kind:"javascript-module",path:K,declarations:[B5(Y)],exports:R5(Y,K)}})}}function I5(j,$){return F(o0.join($,o0.normalize(j.filePath)))}async function e0(j,$){let Z=Qj(j,{resolveModulePath:(Y)=>I5(Y,$.inputDir)}),Q=o0.join(process.cwd(),$.outFile);await J0().write(Q,`${JSON.stringify(Z,null,2)}
|
|
10
|
-
`),console.log(`created "${$.outFile}".`)}import Y0 from"node:path";function Jj(j,$){return j.map((Z)=>({...Z,filePath:F(Y0.join($,Y0.normalize(Z.filePath)))}))}async function M5(j,$){let Z=x(j),Q=Jj(Z.components,$.inputDir);await Promise.all(Q.map(async(J)=>{let Y=Y0.resolve(Y0.join($.outDir||"",`${J.moduleName}.api.json`)),z=await J0().write(Y,`${JSON.stringify(J,null,2)}
|
|
11
|
-
`);console.log(`${z?"created":"unchanged"} "${Y}".`)}))}async function D5(j,$){let Z=x(j,{entryExports:$.entryExports}),Q={...Z,components:Jj(Z.components,$.inputDir)},J=Y0.join(process.cwd(),$.outFile);await J0().write(J,`${JSON.stringify(Q,null,2)}
|
|
12
|
-
`),console.log(`created "${$.outFile}".`)}async function j2(j,$){if($.outDir)await M5(j,$);else await D5(j,$)}import{join as I1}from"node:path";var Yj=/^[}\])>]/,A5=new Set(["{","(","["]),T5=new Set(["}",")","]"]);var S5=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,Kj=/[ \t]+$/,b5=/\s+$/,F5=/[{([]$/,_5=/\s/;function N5(j){return S5.test(j.slice(-200))}function w5(j){let $="",Z=null,Q=!1;for(let J=0;J<j.length;J++){let Y=j[J],K=j[J-1];if(Z){if($+=Y,Z==="double"&&Y==='"'&&K!=="\\"||Z==="single"&&Y==="'"&&K!=="\\"||Z==="template"&&Y==="`"&&K!=="\\")Z=null;Q=!1;continue}if(Y==='"'||Y==="'"||Y==="`"){Z=Y==='"'?"double":Y==="'"?"single":"template",$+=Y,Q=!1;continue}if(_5.test(Y)){if(!Q&&$.length>0)$+=" ",Q=!0;continue}$+=Y,Q=!1}return $.trimEnd()}function C5(j,$){let Z=0,Q="normal";for(let J=$;J<j.length;J++){let Y=j[J],K=j[J-1];if(Q==="blockComment"){if(K==="*"&&Y==="/")Q="normal";continue}if(Q==="double"||Q==="single"){if(Y===(Q==="double"?'"':"'")&&K!=="\\")Q="normal";continue}if(Q==="template"){if(Y==="`"&&K!=="\\")Q="normal";continue}if(Y==="/"&&j[J+1]==="*")Q="blockComment";else if(Y==='"')Q="double";else if(Y==="'")Q="single";else if(Y==="`")Q="template";else if(Y==="{")Z++;else if(Y==="}"){if(Z--,Z===0)return J}}return-1}function Uj(j){let $="",Z="normal";for(let Q=0;Q<j.length;Q++){let J=j[Q],Y=j[Q-1];if(Z==="blockComment"){if($+=J,Y==="*"&&J==="/")Z="normal";continue}if(Z==="double"||Z==="single"){if($+=J,J===(Z==="double"?'"':"'")&&Y!=="\\")Z="normal";continue}if(Z==="template"){if($+=J,J==="`"&&Y!=="\\")Z="normal";continue}if(J==="/"&&j[Q+1]==="*"){Z="blockComment",$+=J;continue}if(J==='"'){Z="double",$+=J;continue}if(J==="'"){Z="single",$+=J;continue}if(J==="`"){Z="template",$+=J;continue}if(J==="{"){let K=C5(j,Q);if(K===-1){$+=J;continue}let z=j.slice(Q+1,K);if(z.trim()===""){$+="{}",Q=K;continue}if(!z.includes("/*")&&j[Q+1]!==`
|
|
13
|
-
`&&!N5($)){let H=Uj(z).trim();if(!H.includes(`
|
|
14
|
-
`)){let U=H.endsWith(";")?H.slice(0,-1):H,V=`{ ${w5(U)} }`;if(V.length<=120){$+=V,Q=K;continue}}}if($+=J,j[Q+1]!==`
|
|
15
|
-
`)$+=`
|
|
16
|
-
`;continue}if(J==="}"){if($=$.replace(Kj,""),!$.endsWith(`
|
|
17
|
-
`))$+=`
|
|
18
|
-
`;$+=J;continue}if(J===";"){if($=$.replace(b5,""),$+=";",j[Q+1]!==`
|
|
19
|
-
`)$+=`
|
|
20
|
-
`;continue}$+=J}return $}function x5(j){let $="",Z=null;for(let Q=0;Q<j.length;Q++){let J=j[Q],Y=j[Q-1];if(Z){if($+=J,Z==="double"&&J==='"'&&Y!=="\\"||Z==="single"&&J==="'"&&Y!=="\\"||Z==="template"&&J==="`"&&Y!=="\\")Z=null;continue}if(J==='"'||J==="'"||J==="`"){Z=J==='"'?"double":J==="'"?"single":"template",$+=J;continue}if(J===" "&&$.endsWith(" "))continue;$+=J}return $}function g5(j){let $=j.split(`
|
|
21
|
-
`),Z=[],Q=0,J=!1,Y=0;for(let K of $){let z=K.trim();if(z===""){Z.push("");continue}if(J){if(Z.push(`${" ".repeat(Y)} ${z}`),z.includes("*/"))J=!1;continue}if(z.startsWith("/**")&&!z.includes("*/")){Z.push(" ".repeat(Q)+z),J=!0,Y=Q;continue}let H=x5(z),U=Yj.test(H),V=Math.max(0,Q-(U?1:0));if(Z.push(" ".repeat(V)+H),H.startsWith("/**")&&H.includes("*/"))continue;let G=null;for(let q=0;q<H.length;q++){let W=H[q],L=H[q-1];if(G){if(G==="double"&&W==='"'&&L!=="\\"||G==="single"&&W==="'"&&L!=="\\"||G==="template"&&W==="`"&&L!=="\\")G=null;continue}if(W==='"')G="double";else if(W==="'")G="single";else if(W==="`")G="template";else if(A5.has(W))Q++;else if(T5.has(W))Q=Math.max(0,Q-1);else if(W==="<")Q++;else if(W===">"&&L!=="=")Q=Math.max(0,Q-1)}}return Z.join(`
|
|
22
|
-
`)}function E5(j){let $=j.split(`
|
|
23
|
-
`).map((Q)=>Q.replace(Kj,"")),Z=[];for(let Q of $){let J=Q==="",Y=Z.length>0&&Z[Z.length-1]==="",K=Z.length>0&&F5.test(Z[Z.length-1]);if(J){if(Z.length===0||Y||K)continue;Z.push(Q);continue}if(Yj.test(Q)&&Y)Z.pop();Z.push(Q)}while(Z.length>0&&Z[Z.length-1]==="")Z.pop();return Z.join(`
|
|
24
|
-
`)}function zj(j){let $=Uj(j),Z=g5($);return`${E5(Z)}
|
|
25
|
-
`}var f="any",w="",y5="Record<string, any>",Z2="Record<string, never>",P5=/(-|\s+|:)/,v5=/("|')/,f5=/CustomEvent/,h5=/^[A-Z]/,u5=/\n/,Hj=/=>/,m5=/(?:^|\n)@default\b/,Q2=/\n/g,c5=/\s+/g,d5=/(^|[^.\w])Snippet(?:\s*<|\b)/,l5=/import\s+type\s+[^;]*\bSnippet\b[^;]*from\s+"svelte";/,i5=/[.*+?^${}()|[\]\\]/g,p5=/^const\s+/;function J2(j){return j.replace(p5,"")}function a5(j){if(!j)return;return j.replace(Q2,`
|
|
26
|
-
* `)}function F0(j){if(!j)return"";return`/** ${j} */`}function _0(j){if(!j)return"";return`/**
|
|
27
|
-
* ${j.replace(Q2,`
|
|
28
|
-
* `)}
|
|
29
|
-
*/`}function Vj(j){if(j===void 0)return;return j===!0?"@deprecated":`@deprecated ${j}`}function s5(j){let $=Vj(j);if($===void 0)return;return`* ${$.replace(Q2,`
|
|
30
|
-
* `)}
|
|
31
|
-
`}function r5(j,$){if(!$)return[`@${j}`];if(!$.includes(`
|
|
32
|
-
`))return[`@${j} ${$}`];return[`@${j}`,...$.split(`
|
|
33
|
-
`)]}function Xj(j){let $=[];for(let{name:Z,body:Q}of j??[])$.push(...r5(Z,Q));return $}function K0(j,$,Z){let Q=Vj(Z),J=Xj($),Y=J.length>0;if(!j&&!Y&&!Q)return"";if(!Y&&!Q)return j?.includes(`
|
|
34
|
-
`)?_0(j):F0(j);let K=[];if(j)K.push(...j.split(`
|
|
35
|
-
`));if(K.push(...J),Q)K.push(...Q.split(`
|
|
36
|
-
`));return`/**
|
|
37
|
-
* ${K.join(`
|
|
38
|
-
* `)}
|
|
39
|
-
*/`}function n5(j){let $=Xj(j);if($.length===0)return"";return $.map((Z)=>`* ${Z}
|
|
40
|
-
`).join("")}function N0(j){if(j===void 0)return f;return`${j}
|
|
41
|
-
`}function w0(j){if(j.typedefs.length===0)return w;return j.typedefs.map(($)=>{return`${$.description?`${_0($.description)}
|
|
42
|
-
`:""}export ${$.ts}`}).join(`
|
|
43
|
-
|
|
44
|
-
`)}function Gj(j,$){let Z=$.replace(i5,"\\$&");return new RegExp(`\\b${Z}\\b`).test(j)}function t5(j){if(j===null)return[];return j[0].split(",").map(($,Z)=>({name:$.trim(),constraint:(b0(j[1]??"")[Z]??$).trim()}))}function o5(j,$){let Z=t5(j).filter(({name:Q})=>Gj($,Q));if(Z.length===0)return{declSuffix:w,refSuffix:w};return{declSuffix:`<${Z.map(({constraint:Q})=>J2(Q)).join(", ")}>`,refSuffix:`<${Z.map(({name:Q})=>Q).join(", ")}>`}}function qj(j){if(!j.contexts||j.contexts.length===0)return w;let $=j.generics===null?[]:j.generics[0].split(",").map((Z,Q)=>({name:Z.trim(),constraint:(b0(j.generics?.[1]??"")[Q]??Z).trim()}));return j.contexts.map((Z)=>{let Q=Z.properties.map((z)=>{let H=z.description?`${F0(z.description)}
|
|
45
|
-
`:"",U=z.optional?"?":"";return`${H}${z.name}${U}: ${z.type};`}).join(`
|
|
46
|
-
`),J=Z.description?`${_0(Z.description)}
|
|
47
|
-
`:"",Y=$.filter(({name:z})=>Z.properties.some((H)=>Gj(H.type,z))).map(({constraint:z})=>z),K=Y.length>0?`<${Y.map(J2).join(", ")}>`:"";if(Z.properties.length===0)return`${J}export type ${Z.typeName} = Record<string, never>;`;return`${J}export type ${Z.typeName}${K} = {
|
|
48
|
-
${Q}
|
|
49
|
-
};`}).join(`
|
|
50
|
-
|
|
51
|
-
`)}function U0(j){if(P5.test(j))return v5.test(j)?j:`"${j}"`;return j}function Wj(j,$){if(!j)return;return`* ${$||j}
|
|
52
|
-
`}function Y2(j,$,Z){return[Wj(a5(j)),s5($),n5(Z)].filter(Boolean).join("")}function K2(j){return j.length>0?`/**
|
|
53
|
-
${j}*/`:w}function e5(j){let $=new Set([...j.props.filter((X)=>!X.isFunctionDeclaration&&X.kind!=="const").map((X)=>X.name),...Array.from(j.canonicalPropNames??[])]),Z=j.props.filter((X)=>!X.isFunctionDeclaration&&X.kind!=="const").map((X)=>{let k=X.value;if(typeof X.value==="string")k=X.value.replace(c5," ");if(X.value===void 0)k="undefined";let I=m5.test(X.description??""),O=[Y2(X.description,X.deprecated,X.tags),Wj(X.constant,"@constant"),X.isFunction||I?null:`* @default ${k}
|
|
54
|
-
`].filter(Boolean).join(""),M=X.constant&&!X.isFunction?X.value:X.type;return`
|
|
55
|
-
${K2(O)}
|
|
56
|
-
${X.name}${X.isRequired?"":"?"}: ${M};`}),Q=j.canonicalPropsType?Z.filter((X,k)=>{let I=j.props.filter((O)=>!O.isFunctionDeclaration&&O.kind!=="const")[k];return I?!(j.canonicalPropNames?.has(I.name)??!1):!0}):Z,J=(j.slots||[]).filter((X)=>!X.default&&X.name!=null&&!$.has(X.name)).map((X)=>{let k=X.name,I=U0(k),O=K0(X.description,X.tags,X.deprecated),M=O?`${O}
|
|
57
|
-
`:"",S=X.slot_props&&X.slot_props!=="Record<string, never>"?`(this: void, ...args: [${X.slot_props}]) => void`:"(this: void) => void";return`
|
|
58
|
-
${M}${I}?: ${S};`}),Y=(j.slots||[]).find((X)=>X.default||X.name===null),K=Y&&!$.has("children")?(()=>{let X=K0(Y.description,Y.tags,Y.deprecated),k=X?`${X}
|
|
59
|
-
`:"",O=Y.slot_props&&Y.slot_props!=="Record<string, never>"?`(this: void, ...args: [${Y.slot_props}]) => void`:"(this: void) => void";return`
|
|
60
|
-
${k}children?: ${O};`})():"",z=j.events?Y1({events:j.events},$):[],H=[...J,K,...z].filter(Boolean),U=[...Q,...H].join(`
|
|
61
|
-
`),V=`${j.moduleName}Props`,G=w,q=j.generics?`<${b0(j.generics[1]).map((X)=>J2(X.trim())).join(", ")}>`:"",W=j.generics?`<${j.generics[0]}>`:"",L=j.canonicalPropsType?`
|
|
62
|
-
type $Props${q} = ${j.canonicalPropsType}${U.trim()===""?"":` & {${U}
|
|
63
|
-
}`};
|
|
64
|
-
`:`
|
|
65
|
-
type $Props${q} = {
|
|
66
|
-
${U}
|
|
67
|
-
};
|
|
68
|
-
`;if(j.rest_props?.type==="Element"){let X;if(j.rest_props.name==="svelte:element")if(j.rest_props.thisValue)X=`SvelteHTMLElements["${j.rest_props.thisValue}"]`;else X="HTMLAttributes<HTMLElement>";else X=j.rest_props.name.split("|").map((O)=>{return`SvelteHTMLElements["${O.trim()}"]`}).join(" & ");let k="[key: `data-${string}`]: unknown;",I=j.rest_props.description?j.rest_props.description.includes(`
|
|
69
|
-
`)?`${_0(j.rest_props.description)}
|
|
70
|
-
`:`${F0(j.rest_props.description)}
|
|
71
|
-
`:"";if(j.extends===void 0)G=`
|
|
72
|
-
${I}${X?`type $RestProps = ${X};
|
|
73
|
-
`:""}
|
|
74
|
-
${j.canonicalPropsType?`type $Props${q} = (${j.canonicalPropsType}) & {${U}
|
|
75
|
-
|
|
76
|
-
${k}
|
|
77
|
-
};`:`type $Props${q} = {
|
|
78
|
-
${U}
|
|
79
|
-
|
|
80
|
-
${k}
|
|
81
|
-
};`}
|
|
82
|
-
|
|
83
|
-
export type ${V}${q} = Omit<$RestProps, keyof $Props${W}> & $Props${W};
|
|
84
|
-
`;else G=`
|
|
85
|
-
${I}${X?`type $RestProps = ${X};
|
|
86
|
-
`:""}
|
|
87
|
-
${j.canonicalPropsType?`type $Props${q} = (${j.canonicalPropsType}) & {${U}
|
|
88
|
-
|
|
89
|
-
${k}
|
|
90
|
-
};`:`type $Props${q} = {
|
|
91
|
-
${U}
|
|
92
|
-
|
|
93
|
-
${k}
|
|
94
|
-
};`}
|
|
95
|
-
|
|
96
|
-
export type ${V}${q} = Omit<$RestProps, keyof ($Props${W} & ${j.extends.interface})> & $Props${W} & ${j.extends.interface};
|
|
97
|
-
`}else if(U.trim()===""&&j.extends===void 0&&!j.canonicalPropsType)G=`
|
|
98
|
-
export type ${V}${q} = ${Z2};
|
|
99
|
-
`;else if(j.canonicalPropsType)G=`
|
|
100
|
-
${L}
|
|
101
|
-
export type ${V}${q} = ${j.extends===void 0?"":`${j.extends.interface} & `}$Props${W};
|
|
102
|
-
`;else G=`
|
|
103
|
-
export type ${V}${q} = ${j.extends===void 0?"":`${j.extends.interface} & `} {
|
|
104
|
-
${U}
|
|
105
|
-
};
|
|
106
|
-
`;return{props_name:V,prop_def:G}}function j1(j){if(j.slots.length===0)return Z2;let $=j.slots.map(({name:Z,slot_props:Q,...J})=>{let Y=J.default||Z===null?"default":U0(Z??""),K=K0(J.description,J.tags,J.deprecated);return`${K?`${K}
|
|
107
|
-
`:""}${U0(Y)}: ${N0(Q)};`}).join(`
|
|
108
|
-
`);return j.slots.length===1?`{${$}}`:`{
|
|
109
|
-
${$}
|
|
110
|
-
}`}var $1=()=>"WindowEventMap",Z1=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave","contextmenu","wheel","keydown","keyup","keypress","submit","change","input","focus","blur","focusin","focusout","reset","select","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragover","dragenter","dragleave","drop","pointerdown","pointerup","pointermove","pointerover","pointerout","pointerenter","pointerleave","pointercancel","gotpointercapture","lostpointercapture","play","pause","ended","volumechange","timeupdate","loadeddata","loadedmetadata","canplay","canplaythrough","seeking","seeked","playing","waiting","stalled","suspend","abort","error","emptied","ratechange","durationchange","loadstart","progress","loadend","animationstart","animationend","animationiteration","animationcancel","transitionstart","transitionend","transitionrun","transitioncancel","scroll","resize","load","unload","beforeunload","cut","copy","paste","compositionstart","compositionupdate","compositionend"]);function $2(j=f){if(f5.test(j))return j;return`CustomEvent<${j}>`}function Q1(j){return Z1.has(j)}function Oj(j){switch(j.type){case"dispatched":return $2(j.detail);case"forwarded":{let $=j.element,Q=!($&&h5.test($))||Q1(j.name),J=j.detail!==void 0&&j.detail!=="undefined"&&!(j.detail==="null"&&Q),Y=j.detail==="null"&&!Q;if(J||Y)return $2(j.detail);else if(Q)return`${$1()}["${j.name}"]`;else return $2()}default:return j}}function J1(j){if(j.events.length===0)return y5;let $=j.events.map((Z)=>{let Q="",J=K0(Z.description,Z.tags,Z.deprecated);if(J)Q=`${J}
|
|
111
|
-
`;return`${Q}${U0(Z.name)}: ${Oj(Z)};
|
|
112
|
-
`}).join("");return j.events.length===1?`{${$}}`:`{
|
|
113
|
-
${$}}`}function Y1(j,$){return j.events.map((Z)=>{let Q=`on${Z.name}`;if($.has(Q))return;let J="",Y=K0(Z.description,Z.tags,Z.deprecated);if(Y)J=`${Y}
|
|
114
|
-
`;return`
|
|
115
|
-
${J}${U0(Q)}?: (event: ${Oj(Z)}) => void;`}).filter((Z)=>Z!==void 0)}function K1(j){let $=j.type==="() => any";if(j.type&&Hj.test(j.type)&&!$)return j.type;else if(j.params&&j.params.length>0){let Q=j.params.map((Y)=>{let K=Y.optional?"?":"";return`${Y.name}${K}: ${Y.type}`}).join(", "),J=j.returnType||f;return`(${Q}) => ${J}`}else if(j.returnType)return`() => ${j.returnType}`;else return j.type||f}function kj(j){return j.props.filter(($)=>$.isFunctionDeclaration||$.kind==="const").map(($)=>{let Z=Y2($.description,$.deprecated,$.tags),Q=K1($);return`
|
|
116
|
-
${K2(Z)}
|
|
117
|
-
${$.name}: ${Q};`}).join(`
|
|
118
|
-
`)}function U1(j){let $=`${j.moduleName}Exports`,Z=kj({props:j.props});if(Z.trim()==="")return{exports_name:$,exports_ref:$,exports_def:`export type ${$} = ${Z2};`};let{declSuffix:Q,refSuffix:J}=o5(j.generics,Z);return{exports_name:$,exports_ref:`${$}${J}`,exports_def:`export type ${$}${Q} = {${Z}
|
|
119
|
-
};`}}function z1(j){let $=j.props.filter((Z)=>Z.bindable===!0||Z.binding==="writable").map((Z)=>`"${Z.name}"`);return $.length===0?w:$.join(" | ")}function H1(j){let $=j.moduleName==="default"?"$$Component":j.moduleName,Z=j.bindings===w?'""':j.bindings;return`declare const ${$}: Component<
|
|
120
|
-
${j.propsRef},
|
|
121
|
-
${j.exportsRef},
|
|
122
|
-
${Z}
|
|
123
|
-
>;
|
|
124
|
-
export default ${$};`}function V1(j){let $=j.moduleName==="default"?"$$Component":j.moduleName,Z=`${$}Component`,Q=j.bindings===w?'""':j.bindings;return`interface ${Z} {
|
|
125
|
-
new ${j.generic}(
|
|
126
|
-
options: ComponentConstructorOptions<${j.propsRef}>
|
|
127
|
-
): SvelteComponent<${j.propsRef}> & ${j.exportsRef};
|
|
128
|
-
${j.generic}(
|
|
129
|
-
this: void,
|
|
130
|
-
internals: ComponentInternals,
|
|
131
|
-
props: ${j.propsRef}
|
|
132
|
-
): {
|
|
133
|
-
$on?(type: string, callback: (e: any) => void): () => void;
|
|
134
|
-
$set?(props: Partial<${j.propsRef}>): void;
|
|
135
|
-
} & ${j.exportsRef};
|
|
136
|
-
element?: typeof HTMLElement;
|
|
137
|
-
z_$$bindings?: ${Q};
|
|
138
|
-
}
|
|
139
|
-
declare const ${$}: ${Z};
|
|
140
|
-
export default ${$};`}function X1(j){if(j.extends===void 0)return"";return`import type { ${j.extends.interface} } from ${j.extends.import};`}function G1(j){if(!j.componentComment)return"";if(!u5.test(j.componentComment))return F0(j.componentComment.trim());return`/*${j.componentComment.split(`
|
|
141
|
-
`).map(($)=>`* ${$}`).join(`
|
|
142
|
-
`)}
|
|
143
|
-
*/`}function q1(j){return j.moduleExports.map(($)=>{let Z=Y2($.description,$.deprecated,$.tags),Q,J=$.type&&Hj.test($.type),Y=$.type==="() => any";if($.kind==="const"&&!J)Q=`export declare const ${$.name}: ${$.type||f};
|
|
144
|
-
`;else if($.params&&$.params.length>0){let z=$.params.map((U)=>{let V=U.optional?"?":"";return`${U.name}${V}: ${U.type}`}).join(", "),H=$.returnType||f;Q=`export declare function ${$.name}(${z}): ${H};`}else if($.returnType)Q=`export declare function ${$.name}(): ${$.returnType};`;else if(J&&$.type&&!Y){let[K,z,...H]=$.type.split("=>"),U=H.map((V)=>` => ${V.trim()}`).join("");Q=`export declare function ${$.name}${K.trimEnd()}: ${z.trim()}${U};`}else if(J&&$.type){let[K,z,...H]=$.type.split("=>"),U=H.map((V)=>` => ${V.trim()}`).join("");Q=`export declare function ${$.name}${K.trimEnd()}: ${z.trim()}${U};`}else if($.kind==="const")Q=`export declare const ${$.name}: ${$.type||f};
|
|
145
|
-
`;else Q=`export type ${$.name} = ${$.type||f};`;return`
|
|
146
|
-
${K2(Z)}
|
|
147
|
-
${Q}`}).join(`
|
|
148
|
-
`)}var W1=120;function O1(j){let Z=`export default class ${j.moduleName==="default"?"":j.moduleName}${j.generic} extends SvelteComponentTyped<`,Q=[j.genericProps,j.events,j.slots];if(j.accessors.trim()===""&&Q.every((J)=>!J.includes(`
|
|
149
|
-
`))){let J=`${Z}${Q.join(", ")}> {}`;if(J.length<=W1)return J}return`${Z}
|
|
150
|
-
${j.genericProps},
|
|
151
|
-
${j.events},
|
|
152
|
-
${j.slots}
|
|
153
|
-
> {
|
|
154
|
-
${j.accessors}
|
|
155
|
-
}`}function U2(j,$){let Z=D0(j),{moduleName:Q,typedefs:J,generics:Y,props:K,moduleExports:z,slots:H,events:U,rest_props:V,extends:G,componentComment:q,contexts:W,syntaxMode:L}=j,X=$?.format==="component",k=Y!==null,{props_name:I,prop_def:O}=e5({moduleName:Q,props:K,rest_props:V,extends:G,generics:Y,slots:H,canonicalPropNames:new Set(Z?.canonicalPropNames??[]),canonicalPropsType:Z?.canonicalPropsType,events:X&&L==="legacy"?U:void 0}),M=Y?`<${Y[1]}>`:"",D=Y?`${I}<${Y[0]}>`:I,S=q1({moduleExports:z}),_=w0({typedefs:J}),N=qj({contexts:W,generics:Y}),A=(Z?.typeImportStatements??[]).join(`
|
|
156
|
-
`),B=(Z?.localTypeDeclarations??[]).join(`
|
|
157
|
-
|
|
158
|
-
`),{exports_ref:R,exports_def:b}=X?U1({props:K,moduleName:Q,generics:Y}):{exports_ref:w,exports_def:w},v=X?z1({props:K}):w,C=!l5.test(A)&&d5.test(`${O}
|
|
159
|
-
${S}
|
|
160
|
-
${_}
|
|
161
|
-
${N}
|
|
162
|
-
${B}
|
|
163
|
-
${b}`),Cj=V?.type==="Element"&&(V.name!=="svelte:element"||V.name==="svelte:element"&&V.thisValue),xj=V?.type==="Element"&&V.name==="svelte:element"&&!V.thisValue,gj=[X?k?`import type { SvelteComponent, ComponentConstructorOptions, ComponentInternals${C?", Snippet":""} } from "svelte";`:`import type { Component${C?", Snippet":""} } from "svelte";`:`import { SvelteComponentTyped${C?", type Snippet":""} } from "svelte";`,Cj?'import type { SvelteHTMLElements } from "svelte/elements";':"",xj?'import type { HTMLAttributes } from "svelte/elements";':"",A,X1({extends:G})].filter(Boolean).join(`
|
|
164
|
-
`),Ej=X?k?V1({moduleName:Q,generic:M,propsRef:D,exportsRef:R,bindings:v}):H1({moduleName:Q,propsRef:D,exportsRef:R,bindings:v}):O1({moduleName:Q,generic:M,genericProps:D,events:J1({events:U}),slots:j1({slots:H}),accessors:kj({props:K})}),yj=[S,_,B,N,O,b,[G1({componentComment:q}),Ej].filter(Boolean).join(`
|
|
165
|
-
`)].map((Pj)=>Pj.trim()).filter(Boolean).join(`
|
|
166
|
-
|
|
167
|
-
`);return zj([gj,yj].filter(Boolean).join(`
|
|
168
|
-
|
|
169
|
-
`))}var z2=/`/g,C0=/\s+/g,g="--",Lj=`| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |
|
|
170
|
-
| :- | :- | :- | :- | :- | :- | :- | :- |
|
|
171
|
-
`,Bj=`| Slot name | Default | Props | Fallback | Description |
|
|
172
|
-
| :- | :- | :- | :- | :- |
|
|
173
|
-
`,Rj=`| Event name | Type | Detail | Description |
|
|
174
|
-
| :- | :- | :- | :- |
|
|
175
|
-
`,Ij=`| Name | Kind | Type | Description |
|
|
176
|
-
| :- | :- | :- | :- |
|
|
177
|
-
`,x0=/\|/g,k1=/</g,L1=/>/g,i=/\n/g;function h(j){if(j===void 0)return g;return`<code>${j.replace(x0,"|")}</code>`}function z0(j){return j.replace(k1,"<").replace(L1,">")}function Mj(j){if(j===void 0)return g;return`<code>${j.replace(z2,"\\`").replace(x0,"|")}</code>`}function g0(j,$){if($===void 0)return j;let Z=typeof $==="string"&&$.trim().length>0?`: ${z0($).replace(i," ").replace(x0,"|")}`:"";return`<s>${j}</s><br />**Deprecated**${Z}`}function E0(j){if(j===void 0||j.trim().length===0)return g;return z0(j).replace(i,"<br />")}function Dj(j){if(j===void 0||j==="{}")return g;return h(N0(j).replace(i," "))}function Aj(j){if(j===void 0)return g;return h(z0(j).replace(i,"<br />"))}function Tj(j,$){let Z=[];if(j!==void 0&&j.trim().length>0)Z.push(z0(j));for(let{name:Q,body:J}of $??[]){let Y=J?.trim();Z.push(Y?`@${Q} ${z0(Y)}`:`@${Q}`)}if(Z.length===0)return g;return Z.join(`
|
|
178
|
-
`).replace(x0,"|").replace(i,"<br />")}function Sj(j){if(j===void 0)return g;return h(j.replace(i," "))}function bj(j,$,Z){if(j.append("h1","Component Index"),j.append("h2","Components").tableOfContents(),j.append("divider"),Z&&Z.length>0)B1(j,Z);let Q=x($);for(let J of Q.components)R1(j,J)}function B1(j,$){j.append("h2","Exports"),j.append("raw",Ij);for(let Z of $){let Q=(Z.type??Z.value)?.replace(C0," ").trim();j.append("raw",`| ${Z.name} | ${`<code>${Z.kind}</code>`} | ${h(Q)} | ${E0(Z.description)} |
|
|
179
|
-
`)}j.append("raw",`
|
|
180
|
-
`),j.append("divider")}function H2(j,$,Z,Q){if($.length>0)Z(),j.append("raw",`
|
|
181
|
-
`);else j.append("p",Q??"None.")}function R1(j,$){if(j.append("h2",`\`${$.moduleName}\``),$.generics)j.append("p",`**Type parameters:** ${h(`<${$.generics[1]}>`)}`);if($.typedefs.length>0)j.append("h3","Types").append("raw",`\`\`\`ts
|
|
182
|
-
${w0({typedefs:$.typedefs})}
|
|
183
|
-
\`\`\`
|
|
184
|
-
|
|
185
|
-
`);j.append("h3","Props"),H2(j,$.props,()=>{j.append("raw",Lj);let Z=[...$.props].sort((Q)=>{if(Q.reactive)return-1;if(Q.constant)return 1;return 0});for(let Q of Z)j.append("raw",`| ${g0(Q.name,Q.deprecated)} | ${Q.isRequired?"Yes":"No"} | ${`<code>${Q.kind}</code>`} | ${Q.reactive?"Yes":"No"} | ${Q.binding??"--"} | ${h(Q.type)} | ${Mj(Q.value)} | ${E0(Q.description)} |
|
|
186
|
-
`)}),j.append("h3","Slots"),H2(j,$.slots,()=>{j.append("raw",Bj);for(let Z of $.slots)j.append("raw",`| ${g0(Z.default?g:Z.name??g,Z.deprecated)} | ${Z.default?"Yes":"No"} | ${Dj(Z.slot_props)} | ${Aj(Z.fallback)} | ${Tj(Z.description,Z.tags)} |
|
|
187
|
-
`)}),j.append("h3","Events"),H2(j,$.events,()=>{j.append("raw",Rj);for(let Z of $.events)j.append("raw",`| ${g0(Z.name,Z.deprecated)} | ${Z.type} | ${Z.type==="dispatched"?Sj(Z.detail):g} | ${E0(Z.description)} |
|
|
188
|
-
`)})}class V2{sourceParts=[];hasToC=!1;toc=[];get source(){return this.sourceParts.join("")}appendLineBreaks(){return this.sourceParts.push(`
|
|
189
|
-
|
|
190
|
-
`),this}append(j,$){switch(j){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{let Z=Number(j.slice(-1));if(this.sourceParts.push(`${"#".repeat(Z)} ${$}`),this.hasToC&&j==="h2")this.toc.push({indent:0,raw:$??""});break}case"quote":this.sourceParts.push(`> ${$}`);break;case"p":this.sourceParts.push($??"");break;case"divider":this.sourceParts.push("---");break;case"raw":this.sourceParts.push($??"");break}if(j!=="raw")this.appendLineBreaks();return this}tableOfContents(){return this.sourceParts.push("<!-- __TOC__ -->"),this.hasToC=!0,this.appendLineBreaks(),this}end(){return this.sourceParts.join("").replace("<!-- __TOC__ -->",this.toc.map(({indent:$,raw:Z})=>{return`${" ".repeat($)}- [${Z}](#${Z.toLowerCase().replace(z2,"").replace(C0,"-")})`}).join(`
|
|
191
|
-
`))}}class y0 extends l{onAppend;markdownBase;constructor(j){super();this.onAppend=j.onAppend,this.markdownBase=new V2}get source(){return this.markdownBase.source}get hasToC(){return this.markdownBase.hasToC}get toc(){return this.markdownBase.toc}appendLineBreaks(){return this.markdownBase.appendLineBreaks(),this}append(j,$){return this.markdownBase.append(j,$),this.onAppend?.call(this,j,this),this}tableOfContents(){return this.markdownBase.tableOfContents(),this}end(){return this.markdownBase.end()}}async function X2(j,$){let Z=$?.write!==!1,Q=new y0({onAppend:(J,Y)=>{$.onAppend?.call(null,J,Y,j)}});if(bj(Q,j,$.entryExports),Z){let J=I1(process.cwd(),$.outFile);await Q.write(J,Q.end()),console.log(`created "${$.outFile}".`)}return Q.end()}import{join as wj}from"node:path";var Fj=/\.svelte$/;function _j(j){let $=new Map;for(let[Q,J]of Object.entries(j)){let Y=$.get(J.source)||[];Y.push({id:Q,exportee:J}),$.set(J.source,Y)}let Z=[];for(let[Q,J]of $){let Y=Fj.test(Q),K=J.some(({id:q,exportee:W})=>q!=="default"&&W.default),z=J.some(({exportee:q})=>!q.default),H=Y&&K&&z,U=[],V=[],G=[];for(let{id:q,exportee:W}of J){if(q==="default"){V.push(`export { default } from "${Q}";`);continue}if(W.default)if(W.mixed)V.push(`export { default as ${q} } from "${Q}";`),V.push(`export { default } from "${Q}";`);else G.push(`default as ${q}`);else if(Y&&!H)G.push(`default as ${q}`);else U.push(q)}if(G.length>0&&U.length>0)Z.push(`export { ${[...G,...U].join(", ")} } from "${Q}";`);else{if(U.length>0)Z.push(`export { ${U.join(", ")} } from "${Q}";`);if(G.length>0)Z.push(`export { ${G.join(", ")} } from "${Q}";`)}Z.push(...V)}return Z.join(`
|
|
192
|
-
`)}function Nj(j){return j.replace(Fj,".svelte.d.ts")}async function G2(j,$){let Z=wj(process.cwd(),$.outDir,"index.d.ts"),Q=Zj(),J=$.preamble+_j($.exports),K=x(j).components.map(async(z)=>{let H=Nj(wj($.outDir,z.filePath));await Q.write(H,U2(z,{format:$.format}))});await Promise.all([...K,Q.write(Z,`${J}
|
|
193
|
-
`)]),console.log("created TypeScript definitions.")}p({name:"json",componentSet:"exported",write:j2});p({name:"markdown",componentSet:"exported",write:X2});p({name:"types",componentSet:"all",write:G2});p({name:"custom-elements",componentSet:"exported",write:e0});var D1=50,A1=/\.svelte$/;function T1(j){let $=j?.watch===!0,Z,Q,J=null,Y,K=new Set,z=async()=>{if(J==null||Q==null||K.size===0)return;let U=Array.from(K);K.clear();try{let{result:V}=await J.update(U);await H0(V,j||{},Q)}catch(V){console.error("sveld: failed to regenerate types in watch mode:",V)}},H=(U)=>{if(!$||J==null||!A1.test(U))return;K.add(U),clearTimeout(Y),Y=setTimeout(z,D1)};return{name:"vite-plugin-sveld",apply:$?void 0:"build",enforce:"post",async buildStart(){if(Q=S0(j?.entry),$&&Q!=null)J=await $j(Q,j?.glob===!0,j?.documentExports===!0),await H0(J.result,j||{},Q)},async generateBundle(){if($)return;if(Q!=null)Z=await Q0(Q,j?.glob===!0,j0(j))},async writeBundle(){if($)return;if(Q!=null)await H0(Z,j||{},Q)},handleHotUpdate(U){H(U.file)},watchChange(U){H(U)}}}function P0(j,$,Z){let Q=u0(j);if(!Q)throw Error(`sveld: built-in writer "${j}" is not registered.`);return Q.write($,Z)}async function H0(j,$,Z){let Q=M1(Z);if($?.types!==!1)await P0("types",j.allComponentsForTypes,{outDir:"types",preamble:"",...$?.typesOptions,exports:j.exports,inputDir:Q});if($?.json)await P0("json",j.components,{outFile:"COMPONENT_API.json",...$?.jsonOptions,input:Z,inputDir:Q,entryExports:j.entryExports});if($?.markdown)await P0("markdown",j.components,{outFile:"COMPONENT_INDEX.md",...$?.markdownOptions,entryExports:j.entryExports});if($?.customElements)await P0("custom-elements",j.components,{outFile:"custom-elements.json",...$?.customElementsOptions,inputDir:Q});let J=Object.entries($?.additionalWriters??{}).map(([Y,K])=>{let z=u0(Y);if(!z){console.warn(`sveld: no writer registered with name "${Y}"; skipping.`);return}let H=z.componentSet==="all"?j.allComponentsForTypes:j.components;return z.write(H,K)});await Promise.all(J)}import{existsSync as S1}from"node:fs";import{join as b1}from"node:path";var q2="src/index.js",F1=`Usage: sveld [options]
|
|
194
|
-
|
|
195
|
-
Generate TypeScript definitions and component documentation for a Svelte
|
|
196
|
-
library. With no flags, only TypeScript definitions are generated for the
|
|
197
|
-
entry resolved from package.json#svelte.
|
|
198
|
-
|
|
199
|
-
Options:
|
|
200
|
-
--entry=<path> Entry point to uncompiled Svelte source (default: package.json "svelte" field)
|
|
201
|
-
--glob Analyze all *.svelte files instead of the entry barrel
|
|
202
|
-
--types Generate TypeScript definitions (default: true)
|
|
203
|
-
--json Generate component documentation in JSON format
|
|
204
|
-
--markdown Generate component documentation in Markdown format
|
|
205
|
-
--custom-elements Generate a Custom Elements Manifest (custom-elements.json)
|
|
206
|
-
--fail-fast Abort the run when a single component fails to parse
|
|
207
|
-
--cache[=<path>] Persist parsed output and skip re-parsing unchanged files (on by default, default path: node_modules/.cache/sveld/parse-cache.json; pass --cache=false to disable)
|
|
208
|
-
--resolve-types Expand opaque imported $props() types into JSON (alias: --resolveTypes, deprecated)
|
|
209
|
-
--check-examples Compile-check @example blocks against the TypeScript program (alias: --checkExamples, deprecated)
|
|
210
|
-
--report-diagnostics Print unresolved-type diagnostics to stderr
|
|
211
|
-
--strict Exit with code 1 when diagnostics exist (implies --report-diagnostics)
|
|
212
|
-
--types-format=<format> ".d.ts" output format: "class" (default) or "component" (Svelte 5 Component<...>)
|
|
213
|
-
--check[=<path>] Diff the parsed API against a committed snapshot; exit 1 on a breaking change (default path: COMPONENT_API.json)
|
|
214
|
-
--help Print this help message and exit
|
|
215
|
-
--version Print the installed sveld version and exit
|
|
216
|
-
`,_1={resolveTypes:"resolve-types",checkExamples:"check-examples"};function N1(j){if(!j.startsWith("--"))return{kind:"unknown",arg:j};let $=j.indexOf("="),Z=$===-1?j.slice(2):j.slice(2,$),Q=$===-1?!0:j.slice($+1),J=_1[Z]??Z;switch(J){case"help":return{kind:"help"};case"version":return{kind:"version"};case"glob":case"types":case"json":case"markdown":return{kind:"option",option:{[J]:Q===!0||Q==="true"}};case"custom-elements":return{kind:"option",option:{customElements:Q===!0||Q==="true"}};case"strict":return{kind:"option",option:{strict:Q===!0||Q==="true"}};case"report-diagnostics":return{kind:"option",option:{reportDiagnostics:Q===!0||Q==="true"}};case"resolve-types":return{kind:"option",option:{resolveTypes:Q===!0||Q==="true"}};case"check-examples":return{kind:"option",option:{checkExamples:Q===!0||Q==="true"}};case"fail-fast":return{kind:"option",option:{failFast:Q===!0||Q==="true"}};case"entry":return typeof Q==="string"?{kind:"option",option:{entry:Q}}:{kind:"option",option:{}};case"cache":if(Q==="false")return{kind:"option",option:{cache:!1}};return{kind:"option",option:{cache:typeof Q==="string"?Q:!0}};case"check":if(Q==="false")return{kind:"option",option:{check:!1}};return{kind:"option",option:{check:typeof Q==="string"?Q:!0}};case"types-format":return typeof Q==="string"?{kind:"option",option:{typesOptions:{format:Q}}}:{kind:"option",option:{}};default:return{kind:"unknown",arg:j}}}function w1(j){let $={};for(let Z of j){let Q=N1(Z);if(Q.kind!=="option")return Q;Object.assign($,Q.option)}return{kind:"options",options:$}}async function W6(j){let $=w1(j.argv.slice(2));if($.kind==="help"){console.log(F1);return}if($.kind==="version"){console.log(O2.version);return}if($.kind==="unknown"){console.error(`Unknown flag: ${$.arg}`),console.error("Run sveld --help for a list of available flags."),j.exitCode=1;return}let Z=$.options,Q=await F2(),J=_2(Q,Z);if(Q.typesOptions||Z.typesOptions)J.typesOptions={...Q.typesOptions,...Z.typesOptions};let Y=S0(J.entry),K;if(Y!==null)K=Y;else if(S1(b1(j.cwd(),q2)))console.error(`sveld: could not resolve an entry point; falling back to "${q2}". Set package.json#svelte (or pass --entry) to avoid relying on this fallback.`),K=a(F(q2));else{j.exitCode=1;return}let z=await Q0(K,J.glob===!0,j0(J)),H;if(J.check)H=await A2(z.components,D2(J),{entryExports:z.entryExports});await H0(z,J,K);let{diagnostics:U}=z;if((J.reportDiagnostics||J.strict)&&U.length>0)console.error(N2(U));if(H){if(console.log(T2(H)),H.bump==="major")j.exitCode=1}if(J.strict&&U.length>0)j.exitCode=1}
|
|
217
|
-
export{x as a,aj as b,D2 as c,A2 as d,T2 as e,N2 as f,S0 as g,s1 as h,F2 as i,_2 as j,j0 as k,Q0 as l,p as m,u0 as n,n1 as o,T1 as p,H0 as q,W6 as r};
|
package/lib/chunk-cxrw7gzr.js
DELETED
package/lib/chunk-jdnsv86e.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as d,t as e}from"./chunk-72hx9e9w.js";import{u as a,v as b,w as c}from"./chunk-xkrgedm4.js";import"./chunk-v4q9vw0y.js";import"./chunk-8xw75w8t.js";import"./chunk-1p4ka68s.js";export{b as getParsedComponentTypeScriptMetadata,e as default,d as assignValue,c as applyResolvedProps,a as PARSED_COMPONENT_TYPE_SCRIPT_METADATA};
|
package/lib/chunk-pmj8c3yv.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{S as O}from"./chunk-cxrw7gzr.js";import{W as F}from"./chunk-1p4ka68s.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-zva3xjwa.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-s9mzxa4y.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{M as a}from"./chunk-v4q9vw0y.js";import"./chunk-8xw75w8t.js";import"./chunk-1p4ka68s.js";export{a as parse};
|
package/lib/chunk-xkrgedm4.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var G=Symbol("sveld.parsedComponentTypeScriptMetadata");function E(j){return j[G]}function S(j,q){if(q.length===0)return;let K=new Set(j.props.map((z)=>z.name));for(let z of q){if(K.has(z.name))continue;K.add(z.name),j.props.push({name:z.name,kind:"let",constant:!1,type:z.type,typeSource:"typescript",...z.description?{description:z.description}:{},isFunction:z.type.includes("=>"),isFunctionDeclaration:!1,isRequired:z.isRequired,reactive:!1})}}var k=/[\r\n]+/g;function _(j){if(j.sourceLineStartOffsetsCache)return j.sourceLineStartOffsetsCache;let q=[0];if(j.source){for(let K=0;K<j.source.length;K++)if(j.source[K]===`
|
|
2
|
-
`)q.push(K+1)}return j.sourceLineStartOffsetsCache=q,q}function w(j,q){if(!j.source||q<0||q>j.source.length)return;let K=_(j),z=0,H=K.length-1;while(z<=H){let Q=Math.floor((z+H)/2),U=K[Q],$=K[Q+1]??Number.POSITIVE_INFINITY;if(q<U)H=Q-1;else if(q>=$)z=Q+1;else return{line:Q+1,column:q-U}}return}function X(j,q,K){if(q===void 0||K===void 0||K<q)return;let z=w(j,q),H=w(j,K);if(!z||!H)return;return{start:z,end:H}}function v(j,q){if(!q||typeof q!=="object")return;let K="start"in q&&typeof q.start==="number"?q.start:void 0,z="end"in q&&typeof q.end==="number"?q.end:void 0;return X(j,K,z)}function L(j,q,K,z){if(!K||K.length===0||z===void 0)return;let H=[...K];while(H.length>1){let V=H[H.length-1];if(V.tokens.tag||!V.source.trim().endsWith("*/"))break;H.pop()}let Q=z;for(let V=0;V<H[0].number-1;V++)Q+=q[V]?.source.length??0,Q+=1;let U=H[0],$=U.source.indexOf(U.tokens.tag??""),W=Q+Math.max($,0),J=z,Y=H[H.length-1],F=Y.number;for(let V=0;V<F-1;V++)J+=q[V]?.source.length??0,J+=1;return J+=Y.source.length,X(j,W,J)}function B(j,q,K){return j.source?.slice(q,K)}function g(j,q){if(!q||typeof q!=="object")return;let K="start"in q&&typeof q.start==="number"?q.start:void 0,z="end"in q&&typeof q.end==="number"?q.end:void 0;if(K===void 0||z===void 0)return;return B(j,K,z)?.replace(k," ")}var A=/[A-Za-z_$][\w$]*/g;function O(j,q){if(!q)return!1;let K=new Set(q[0].split(",").map((z)=>z.trim()));for(let[z]of j.matchAll(A))if(K.has(z))return!0;return!1}function P(j,q){if(q===void 0)return;return j.runesPropsDeclarationMetadataByDeclaratorStart.get(q)}function T(j,q,K){return P(j,q)?.props.get(K)}function N(j){if(!j||typeof j!=="object"||!("type"in j))return;if(j.type==="Identifier"&&"name"in j&&typeof j.name==="string")return j.name;if(j.type==="TSQualifiedName"&&"right"in j&&j.right&&typeof j.right==="object"&&"name"in j.right&&typeof j.right.name==="string")return j.right.name;return}function C(j){if(!j||typeof j!=="object"||!("type"in j))return;if(j.type==="Identifier"&&"name"in j&&typeof j.name==="string")return j.name;if(j.type==="TSQualifiedName"&&"left"in j&&j.left&&typeof j.left==="object")return C(j.left);return}function f(j,q){let K=q?.start,z=q?.end;if(K===void 0||z===void 0)return;return B(j,K+1,z)?.trim()}function m(j,q){let K=q?.start,z=q?.end;if(K===void 0||z===void 0)return;return B(j,K,z)?.trim()}function Z(j,q,K,z,H=new Set){if(!q?.type)return;switch(q.type){case"TSInterfaceDeclaration":Z(j,{type:"TSTypeLiteral",members:q.body?.body},K,z,H);return;case"TSTypeAliasDeclaration":case"TSParenthesizedType":case"TSTypeAnnotation":Z(j,q.typeAnnotation,K,z,H);return;case"TSIntersectionType":case"TSUnionType":for(let Q of q.types??[])Z(j,Q,K,z,H);return;case"TSTypeLiteral":for(let Q of q.members??[]){if(Q?.type!=="TSPropertySignature")continue;Z(j,Q.typeAnnotation?.typeAnnotation,K,z,H)}return;case"TSTypeReference":{let Q=C(q.typeName);if(Q){if(j.typeImportBindingsByLocalName.has(Q))K.add(Q);let U=j.localTypeDeclarationsByName.get(Q);if(U&&!H.has(Q))z.add(Q),H.add(Q),Z(j,U.node,K,z,H),H.delete(Q)}if("typeParameters"in q&&q.typeParameters&&typeof q.typeParameters==="object"){let U=q.typeParameters;for(let $ of U.params??[])Z(j,$,K,z,H)}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 Q of Object.values(q)){if(!Q||typeof Q!=="object")continue;if(Array.isArray(Q)){for(let U of Q){if(!U||typeof U!=="object"||!("type"in U))continue;Z(j,U,K,z,H)}continue}if("type"in Q)Z(j,Q,K,z,H)}}function R(j,q){let K=new Map;for(let z of Array.from(q).sort()){let H=j.typeImportBindingsByLocalName.get(z);if(!H)continue;let Q=K.get(H.source)??{default:[],named:[],namespace:[]};if(H.specifierType==="default")Q.default.push(H.localName);else if(H.specifierType==="namespace")Q.namespace.push(H.localName);else Q.named.push({imported:H.importedName,local:H.localName});K.set(H.source,Q)}return Array.from(K.entries()).sort(([z],[H])=>z.localeCompare(H)).map(([z,H])=>{if(H.namespace.length>0)return H.namespace.map((W)=>`import type * as ${W} from "${z}";`).join(`
|
|
3
|
-
`);let Q=H.named.map(({imported:W,local:J})=>{if(!W||W===J)return J;return`${W} as ${J}`}),U=H.default[0],$=Q.length>0?`{ ${Q.join(", ")} }`:"";if(U&&$)return`import type ${U}, ${$} from "${z}";`;if(U)return`import type ${U} from "${z}";`;return`import type ${$} from "${z}";`})}function l(j){if(j.typedRunesPropsDeclarations.length!==1)return;let[q]=j.typedRunesPropsDeclarations;if(!q.canonicalType)return;let K=Array.from(q.referencedLocalTypes).map((z)=>j.localTypeDeclarationsByName.get(z)).filter((z)=>z!==void 0).sort((z,H)=>z.start-H.start).map((z)=>z.code);return{canonicalPropsType:q.canonicalType,canonicalPropNames:Array.from(q.props.keys()).sort(),localTypeDeclarations:K,typeImportStatements:R(j,q.referencedImportedTypes),referencesComponentGenerics:O(q.canonicalType,j.generics)}}var h=/^[A-Za-z_$][\w$]*/,D=/[A-Za-z_$][\w$]*/g,M=/^(?:const|in|out)\s+/;function b(j){let q=[],K=0,z=0;for(let H=0;H<j.length;H++){let Q=j[H];if(Q==="<"||Q==="("||Q==="["||Q==="{")K++;else if(Q===">"||Q===")"||Q==="]"||Q==="}")K=Math.max(K-1,0);else if(Q===","&&K===0)q.push(j.slice(z,H)),z=H+1}return q.push(j.slice(z)),q}function s(j){let q=b(j).map((z)=>z.trim()).filter((z)=>z.length>0);if(q.length===0)return null;return[q.map((z)=>{let H=z;while(M.test(H))H=H.replace(M,"");return H.match(h)?.[0]??z}).join(", "),q.join(", ")]}function d(j,q,K){let z=j.scriptGenericsAttribute?.value;if(!z)return;for(let[H]of z.matchAll(D)){if(j.typeImportBindingsByLocalName.has(H))q.add(H);if(K.has(H))continue;let Q=j.localTypeDeclarationsByName.get(H);if(!Q)continue;K.add(H),Z(j,Q.node,q,K)}}
|
|
4
|
-
export{G as u,E as v,S as w,X as x,v as y,L as z,B as A,g as B,P as C,T as D,N as E,f as F,m as G,Z as H,l as I,b as J,s as K,d as L};
|
package/lib/cli-entry.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dedicated build entrypoint for `cli.js`, kept separate from `./index`.
|
|
3
|
-
*
|
|
4
|
-
* `./index` is the public "sveld" package API and eagerly re-exports the
|
|
5
|
-
* `ComponentParser` class (a real value export, not just a type), which
|
|
6
|
-
* pulls in the whole parser stack. Bundling the CLI against `./index`
|
|
7
|
-
* would force that eager import into the same chunk as `cli()`, defeating
|
|
8
|
-
* the parser stack's lazy loading (see `./parser-stack`) for every CLI
|
|
9
|
-
* invocation. This entrypoint only reaches `cli()`, so a fully cached run
|
|
10
|
-
* never statically needs the parser.
|
|
11
|
-
*/
|
|
12
|
-
export { cli } from "./cli";
|
package/lib/cli.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type SveldRuntimeOptions } from "./load-config";
|
|
2
|
-
/** CLI options: identical surface to the shared runtime options. */
|
|
3
|
-
type CliOptions = SveldRuntimeOptions;
|
|
4
|
-
/** Discriminated result of parsing the full argument list. */
|
|
5
|
-
export type CliParseResult = {
|
|
6
|
-
kind: "options";
|
|
7
|
-
options: CliOptions;
|
|
8
|
-
} | {
|
|
9
|
-
kind: "help";
|
|
10
|
-
} | {
|
|
11
|
-
kind: "version";
|
|
12
|
-
} | {
|
|
13
|
-
kind: "unknown";
|
|
14
|
-
arg: string;
|
|
15
|
-
};
|
|
16
|
-
export declare function parseCliOptions(argv: string[]): CliParseResult;
|
|
17
|
-
/**
|
|
18
|
-
* CLI entry point: parse flags, load any config file, generate docs, write
|
|
19
|
-
* outputs.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* // Called from CLI: sveld --types --json --glob
|
|
24
|
-
* // Parses: { types: true, json: true, glob: true }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare function cli(process: NodeJS.Process): Promise<void>;
|
|
28
|
-
export {};
|
package/lib/create-exports.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ParsedExports } from "./parse-exports";
|
|
2
|
-
/**
|
|
3
|
-
* Builds export statements from parsed export metadata.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* // Input:
|
|
8
|
-
* { Button: { source: "./Button.svelte", default: true } }
|
|
9
|
-
*
|
|
10
|
-
* // Output:
|
|
11
|
-
* // export { default as Button } from "./Button.svelte";
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export declare function createExports(parsed_exports: ParsedExports): string;
|
|
15
|
-
/**
|
|
16
|
-
* Strips the `.svelte` extension from a path.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* removeSvelteExt("./Button.svelte") // Returns: "./Button"
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function removeSvelteExt(filePath: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Maps a `.svelte` path to its `.svelte.d.ts` definition path.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* convertSvelteExt("./Button.svelte") // Returns: "./Button.svelte.d.ts"
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function convertSvelteExt(filePath: string): string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ComponentDocApi, ComponentDocs, ResolveComponentFilePath } from "./bundle";
|
|
2
|
-
/**
|
|
3
|
-
* Resolves a component's `@extendProps` / `@extends` target to an absolute path,
|
|
4
|
-
* or `null` when it doesn't point at a local `.svelte` file (e.g. it references
|
|
5
|
-
* an external package interface like `carbon-components-svelte`).
|
|
6
|
-
*/
|
|
7
|
-
export declare function resolveExtendsDependency(api: ComponentDocApi, componentPath: string): string | null;
|
|
8
|
-
/**
|
|
9
|
-
* Builds a reverse-dependency map: `dependencyPath -> set of dependent paths`.
|
|
10
|
-
*
|
|
11
|
-
* A component is a dependent of `X` when it extends `X` via `@extendProps` /
|
|
12
|
-
* `@extends`. When `X` changes, every dependent must be re-parsed.
|
|
13
|
-
*/
|
|
14
|
-
export declare function buildReverseDeps(components: ComponentDocs, resolveComponentFilePath: ResolveComponentFilePath): Map<string, Set<string>>;
|
|
15
|
-
/**
|
|
16
|
-
* Expands the set of changed paths to include every transitive dependent via
|
|
17
|
-
* the reverse-dependency map (e.g. editing `Button.svelte` also marks the
|
|
18
|
-
* `SecondaryButton.svelte` that `@extendProps`-es it).
|
|
19
|
-
*/
|
|
20
|
-
export declare function expandAffected(changed: Iterable<string>, reverseDeps: Map<string, Set<string>>): Set<string>;
|
package/lib/diagnostics.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { SourceRange } from "./ComponentParser";
|
|
2
|
-
/**
|
|
3
|
-
* Why sveld could not pin a type during parsing.
|
|
4
|
-
*
|
|
5
|
-
* - `prop-unknown-type`: prop `typeSource` is `"unknown"`.
|
|
6
|
-
* - `context-any-type`: `setContext` value inferred as `any`.
|
|
7
|
-
* - `event-no-source`: `@event` with no dispatch, forward, or callback prop.
|
|
8
|
-
* - `example-compile-error`: an `@example` block failed to type-check (opt-in, `checkExamples`).
|
|
9
|
-
* - `syntax-skipped`: `$props()`/`{@render}` syntax the parser can't model; omitted from output.
|
|
10
|
-
*/
|
|
11
|
-
export type SveldDiagnosticKind = "prop-unknown-type" | "context-any-type" | "event-no-source" | "example-compile-error" | "syntax-skipped";
|
|
12
|
-
/**
|
|
13
|
-
* One place sveld had to guess a type instead of inferring it.
|
|
14
|
-
*/
|
|
15
|
-
export interface SveldDiagnostic {
|
|
16
|
-
/** File this came from, e.g. `"./Button.svelte"`. */
|
|
17
|
-
component: string;
|
|
18
|
-
kind: SveldDiagnosticKind;
|
|
19
|
-
/** Prop, context field, or event name. */
|
|
20
|
-
name: string;
|
|
21
|
-
/** What went wrong and what type sveld used. */
|
|
22
|
-
message: string;
|
|
23
|
-
/** Where in the component source this diagnostic points, when the parser holds a stable position. */
|
|
24
|
-
source?: SourceRange;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Drop duplicates (same component, kind, and name). Each file is parsed twice
|
|
28
|
-
* when building exports and `.d.ts`, so without this the CLI summary doubles.
|
|
29
|
-
*/
|
|
30
|
-
export declare function dedupeDiagnostics(diagnostics: SveldDiagnostic[]): SveldDiagnostic[];
|
|
31
|
-
/**
|
|
32
|
-
* Group diagnostics by kind and component for CLI output.
|
|
33
|
-
*/
|
|
34
|
-
export declare function formatDiagnosticsSummary(diagnostics: SveldDiagnostic[]): string;
|