sveld 0.40.5 → 0.40.6

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.
@@ -0,0 +1 @@
1
+ import{R,ve}from"./chunk-9fmhgf46.js";import{Kt,ne,qt,Wt,Ht,Be,zt,re}from"./chunk-0e70e5s3.js";export{re as ComponentParser,Wt as deriveLiteralDetailType,qt as extractJsDocDeprecatedAndTags,Kt as extractJsDocReturnType,ne as extractJsDocType,ve as formatParseError,Ht as literalDetailToTypeText,R as parseModule,Be as parseSvelte,zt as parseSvelteScripts};
@@ -0,0 +1,5 @@
1
+ import{n,r,U}from"./chunk-9fmhgf46.js";import{readdirSync as x,readFileSync as _,statSync as w}from"node:fs";import{createRequire as A}from"node:module";import l from"node:path";function R(e){return n(e)&&typeof e.API==="function"}var I=/[^A-Za-z0-9_-]/g,D=/[^A-Za-z0-9_$]/g,j=/^[0-9]/,C=2,y=7,h=`TypeScript ${y} or later, which provides \`typescript/async\` (\`typescript/unstable/async\` in 7.0)`,F=["typescript/async","typescript/unstable/async"];function d(e){return`requires ${h}; found \`typescript@${e??"unknown"}\` installed, which does not expose that module`}function b(e){if(!e)return!1;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=y}async function N(e){let t;try{let o=A(l.join(e,"package.json")).resolve("typescript/package.json"),a=JSON.parse(_(o,"utf8"));if(n(a)&&typeof a.version==="string")t=a.version}catch{return{installed:!1}}if(!b(t))return{installed:!0,version:t};for(let i of F)try{let o=await import(i);return{installed:!0,version:t,module:o}}catch{}return{installed:!0,version:t}}class P{api=null;usesFileSystemLayer=!1;tsconfigPath;overlay=new Map;constructor(e){this.tsconfigPath=e}static async create(e=process.cwd(),{importTs:t=N}={}){let i=await t(e);if(!i.installed)return{ok:!1,reason:"not-installed",message:`requires the \`typescript\` package to be installed (${h}); none was found`};if(!i.module)return{ok:!1,reason:"unsupported-version",message:d(i.version)};let o=U(e,["tsconfig.json"]);if(!o)return{ok:!1,reason:"no-tsconfig",message:`could not locate a tsconfig.json starting from "${e}"`};let{module:a}=i;if(!R(a))return{ok:!1,reason:"unsupported-version",message:d(i.version)};let s=new P(o);return s.usesFileSystemLayer=typeof a.API.prototype?.createSnapshot==="function",s.api=s.usesFileSystemLayer?new a.API({cwd:e}):new a.API({cwd:e,fs:s.createFileSystem()}),{ok:!0,resolver:s}}async checkExamples(e){let t=new Map,i=[];for(let s of e)for(let c of s.sources){let u=this.exampleFileName(s.filePath,s.moduleName,c.id);this.overlay.set(u,L(c)),i.push({filePath:s.filePath,source:c,file:u})}let{api:o}=this;if(i.length===0||!o)return t;let a=this.usesFileSystemLayer?await o.createSnapshot({openProjects:[this.tsconfigPath],fileSystem:{kind:"layer",files:Object.fromEntries(this.overlay)}}):await o.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:i.map((s)=>s.file)}});try{let s=await a.getDefaultProjectForFile(i[0].file);if(!s)return t;await Promise.all(i.map(async({filePath:c,source:u,file:f})=>{let[S,v]=await Promise.all([s.program.getSyntacticDiagnostics(f),s.program.getSemanticDiagnostics(f)]),g=[...S,...v];if(g.length===0)return;let E=this.overlay.get(f)??"",T=g.map((p)=>O(p,E)).sort((p,k)=>p.line-k.line).map((p)=>`Line ${p.line}: ${p.text}`).join(`
2
+ `),m=t.get(c)??[];m.push({id:u.id,name:u.name,message:T}),t.set(c,m)}))}finally{await a.dispose?.()}return t}async dispose(){this.overlay.clear(),await this.api?.close?.()}createFileSystem(){return{readFile:(e)=>this.overlay.get(r(e)),fileExists:(e)=>this.overlay.has(r(e))?!0:void 0,getAccessibleEntries:(e)=>{let t=r(e),i=Array.from(this.overlay.keys()).filter((s)=>r(l.dirname(s))===t);if(i.length===0)return;let o=[],a=[];try{for(let s of x(e)){let c=l.join(e,s);try{(w(c).isDirectory()?a:o).push(s)}catch{}}}catch{}for(let s of i){let c=l.basename(s);if(!o.includes(c))o.push(c)}return{files:o,directories:a}}}}exampleFileName(e,t,i){let o=l.dirname(l.resolve(e)),a=i.replace(I,"_");return r(l.join(o,`__sveld_example_${t}_${a}.ts`))}}function M(e){let t=e.replace(D,"_");if(t===""||j.test(t))return`_${t}`;return t}function L(e){return`const ${M(e.name)} = null as unknown as (${e.type});
3
+ ${e.code}
4
+ `}function O(e,t){let i=e.pos??0,o=t.slice(0,i).split(`
5
+ `).length;return{line:Math.max(1,o-C+1),text:String(e.text??"").trim()}}export{P as TypeResolver};
package/cli-entry.js CHANGED
@@ -1,4 +1,4 @@
1
- import{L,n,Mt,xe,Ee,G,O,W,ee,U,J,Le,Oe,Me}from"./chunk-ep5n8z9k.js";import{existsSync as v}from"node:fs";import{join as S}from"node:path";var f="src/index.js",m={SUCCESS:0,USAGE_ERROR:1,GENERATION_FAILURE:2,BREAKING_CHANGE:3,DIAGNOSTICS:4},x=`Usage: sveld [options]
1
+ import{I,te,r,Bt,Ee,Se,W,L,H,J,K,Oe,Me,Fe}from"./chunk-9fmhgf46.js";import{existsSync as S}from"node:fs";import{join as x}from"node:path";var g="src/index.js",m={SUCCESS:0,USAGE_ERROR:1,GENERATION_FAILURE:2,BREAKING_CHANGE:3,DIAGNOSTICS:4},E=`Usage: sveld [options]
2
2
 
3
3
  Generate TypeScript definitions and component documentation for a Svelte
4
4
  library. With no flags, only TypeScript definitions are generated for the
@@ -35,4 +35,4 @@ Exit codes:
35
35
  2 generation failure
36
36
  3 breaking API change detected by --check
37
37
  4 diagnostics present under --strict
38
- `,E=["help","version","glob","types","json","markdown","quiet","stdout","strict","report-diagnostics","check-examples","fail-fast","entry","config","cache","check","check-level","types-format","types-index-types","format"],k=new Map([["-h","--help"],["-v","--version"],["-q","--quiet"]]),b=/[A-Z]/g,w=new Set(["glob","types","json","markdown","quiet","stdout","strict","report-diagnostics","check-examples","fail-fast","types-index-types"]),R=new Set(["entry","config","cache","check","types-format"]),C=new Set(["entry","config","types-format"]);function A(o){let s=o.replace(b,(r)=>`-${r.toLowerCase()}`);return L(s,E)}function j(o,s){let r=o.indexOf("="),t=r===-1?o.slice(2):o.slice(2,r),i=r===-1?!0:o.slice(r+1),e=!1;if(r===-1&&R.has(t)){if(s!==void 0&&!s.startsWith("--")&&!k.has(s))i=s,e=!0;else if(C.has(t))return{result:{kind:"usage-error",message:`sveld: --${t} requires a value (pass --${t}=<value> or --${t} <value>).`},consumedNext:!1,flag:t}}return{result:P(t,i,o),consumedNext:e,flag:t}}function P(o,s,r){let t=(c)=>({kind:"option",option:c}),i=s===!0||s==="true",e=typeof s==="string"?s:void 0;switch(o){case"help":return{kind:"help"};case"version":return{kind:"version"};case"glob":case"types":case"json":case"markdown":case"quiet":return t({[o]:i});case"stdout":if(i)return t({stdout:!0});if(s==="false")return t({stdout:!1});return{kind:"usage-error",message:`sveld: --stdout does not take a value; got "${s}".`};case"strict":if(i)return t({strict:!0});if(s==="false")return t({strict:!1});return t({strict:s});case"report-diagnostics":return t({reportDiagnostics:i});case"check-examples":if(i)return t({checkExamples:!0});if(s==="false")return t({checkExamples:!1});return t({checkExamples:s});case"fail-fast":return t({failFast:i});case"entry":return t(e===void 0?{}:{entry:e});case"config":return t(e===void 0?{}:{config:e});case"cache":if(s==="false")return t({cache:!1});return t({cache:e??!0});case"check":if(s==="false")return t({check:!1});return t({check:e??!0});case"types-format":return t(e===void 0?{}:{typesOptions:{format:e}});case"types-index-types":return t({typesOptions:{indexTypes:i}});case"format":return t(e===void 0?{}:{format:e});case"check-level":return t(e===void 0?{}:{checkLevel:e});default:return{kind:"unknown",arg:r,suggestion:A(o)}}}function T(o){let s={},r=!1;for(let t=0;t<o.length;t++){let i=k.get(o[t])??o[t];if(!i.startsWith("--"))return{kind:"unknown",arg:i,positionalHint:r?!0:void 0};let{result:e,consumedNext:c,flag:l}=j(i,o[t+1]);if(e.kind!=="option")return e;if(s=O(s,e.option),r=w.has(l),c)t++}return{kind:"options",options:s}}function u(o,s){return o!==void 0&&!s.includes(o)}async function _(o){let s=(a)=>{console.error(a),o.exitCode=m.USAGE_ERROR},r=T(o.argv.slice(2));if(r.kind==="help"){console.log(x);return}if(r.kind==="version"){console.log(Mt.version);return}if(r.kind==="usage-error")return s(r.message);if(r.kind==="unknown"){let a=`sveld: unknown flag "${r.arg}".`;if(r.suggestion)a+=` Did you mean "--${r.suggestion}"?`;if(r.positionalHint)a+=" Values are passed as --flag=value or --flag value.";return console.error(a),s("Run sveld --help for a list of available flags.")}let t=r.options,i;try{i=await G(t.config,o.cwd(),!0)}catch(a){return s(a instanceof Error?a.message:String(a))}let e=O(i,t);if(W(e),e.stdout){if([e.json,e.markdown].filter(Boolean).length!==1)return s("sveld: --stdout requires exactly one of --json or --markdown.");if(e.types===!0)return s("sveld: --stdout cannot be combined with --types; type definitions span multiple files.");if(e.check)return s("sveld: --stdout cannot be combined with --check; both write their document to stdout.")}if(u(e.format,["text","json","github"]))return s(`sveld: --format must be "text", "json", or "github"; got "${e.format}".`);if(u(e.strict,[!0,!1,"errors"]))return s(`sveld: --strict must be "errors" when given a value; got "${e.strict}".`);if(u(e.checkLevel,["major","minor","patch"]))return s(`sveld: --check-level must be "major", "minor", or "patch"; got "${e.checkLevel}".`);if(u(e.checkExamples,[!0,!1,"syntax"]))return s(`sveld: --check-examples must be "syntax" when given a value; got "${e.checkExamples}".`);let c=e.typesOptions?.format;if(u(c,["class","component"]))return s(`sveld: --types-format must be "class" or "component"; got "${c}".`);U(e.quiet===!0);let l=Le(e.entry),d;if(l.entry!==null)d=l.entry;else if(!l.configured&&v(S(o.cwd(),f)))console.error(`sveld: no entry point configured; using "${f}". Set package.json#svelte (or pass --entry) to silence this.`),d=ee(n(f));else return s(`sveld: ${l.message}`);let g;try{g=await Oe(d,e,e.stdout===!0)}catch(a){if(a instanceof J)return s(`sveld: ${a.message}`);console.error(a instanceof Error?a.message:String(a)),o.exitCode=m.GENERATION_FAILURE;return}let{result:y,check:p}=g,{exitCode:h}=Me(y,p,e,d);if(p)if(e.format==="json")o.stdout.write(Ee(p));else console.log(xe(p));if(h!==m.SUCCESS)o.exitCode=h}export{_ as cli};
38
+ `,b=["help","version","glob","types","json","markdown","quiet","stdout","strict","report-diagnostics","check-examples","fail-fast","entry","config","cache","check","check-level","types-format","types-index-types","format"],y=new Map([["-h","--help"],["-v","--version"],["-q","--quiet"]]),w=/[A-Z]/g,R=new Set(["glob","types","json","markdown","quiet","stdout","strict","report-diagnostics","check-examples","fail-fast","types-index-types"]),C=new Set(["entry","config","cache","check","types-format"]),O=new Set(["entry","config","types-format"]);function A(s){let n=s.replace(w,(o)=>`-${o.toLowerCase()}`);return I(n,b)}function j(s,n){let o=s.indexOf("="),t=o===-1?s.slice(2):s.slice(2,o),i=o===-1?!0:s.slice(o+1),e=!1;if(o===-1&&C.has(t)){if(n!==void 0&&!n.startsWith("--")&&!y.has(n))i=n,e=!0;else if(O.has(t))return{result:{kind:"usage-error",message:`sveld: --${t} requires a value (pass --${t}=<value> or --${t} <value>).`},consumedNext:!1,flag:t}}return{result:T(t,i,s),consumedNext:e,flag:t}}function u(s){return s}function T(s,n,o){let t=(c)=>({kind:"option",option:c}),i=n===!0||n==="true",e=typeof n==="string"?n:void 0;switch(s){case"help":return{kind:"help"};case"version":return{kind:"version"};case"glob":case"types":case"json":case"markdown":case"quiet":return t({[s]:i});case"stdout":if(i)return t({stdout:!0});if(n==="false")return t({stdout:!1});return{kind:"usage-error",message:`sveld: --stdout does not take a value; got "${n}".`};case"strict":if(i)return t({strict:!0});if(n==="false")return t({strict:!1});return t({strict:u(n)});case"report-diagnostics":return t({reportDiagnostics:i});case"check-examples":if(i)return t({checkExamples:!0});if(n==="false")return t({checkExamples:!1});return t({checkExamples:u(n)});case"fail-fast":return t({failFast:i});case"entry":return t(e===void 0?{}:{entry:e});case"config":return t(e===void 0?{}:{config:e});case"cache":if(n==="false")return t({cache:!1});return t({cache:e??!0});case"check":if(n==="false")return t({check:!1});return t({check:e??!0});case"types-format":return t(e===void 0?{}:{typesOptions:{format:u(e)}});case"types-index-types":return t({typesOptions:{indexTypes:i}});case"format":return t(e===void 0?{}:{format:u(e)});case"check-level":return t(e===void 0?{}:{checkLevel:u(e)});default:return{kind:"unknown",arg:o,suggestion:A(s)}}}function P(s){let n={},o=!1;for(let t=0;t<s.length;t++){let i=y.get(s[t])??s[t];if(!i.startsWith("--"))return{kind:"unknown",arg:i,positionalHint:o?!0:void 0};let{result:e,consumedNext:c,flag:l}=j(i,s[t+1]);if(e.kind!=="option")return e;if(n=L(n,e.option),o=R.has(l),c)t++}return{kind:"options",options:n}}function d(s,n){return s!==void 0&&!n.includes(s)}async function _(s){let n=(a)=>{console.error(a),s.exitCode=m.USAGE_ERROR},o=P(s.argv.slice(2));if(o.kind==="help"){console.log(E);return}if(o.kind==="version"){console.log(Bt.version);return}if(o.kind==="usage-error")return n(o.message);if(o.kind==="unknown"){let a=`sveld: unknown flag "${o.arg}".`;if(o.suggestion)a+=` Did you mean "--${o.suggestion}"?`;if(o.positionalHint)a+=" Values are passed as --flag=value or --flag value.";return console.error(a),n("Run sveld --help for a list of available flags.")}let t=o.options,i;try{i=await W(t.config,s.cwd(),!0)}catch(a){return n(a instanceof Error?a.message:String(a))}let e=L(i,t);if(H(e),e.stdout){if([e.json,e.markdown].filter(Boolean).length!==1)return n("sveld: --stdout requires exactly one of --json or --markdown.");if(e.types===!0)return n("sveld: --stdout cannot be combined with --types; type definitions span multiple files.");if(e.check)return n("sveld: --stdout cannot be combined with --check; both write their document to stdout.")}if(d(e.format,["text","json","github"]))return n(`sveld: --format must be "text", "json", or "github"; got "${e.format}".`);if(d(e.strict,[!0,!1,"errors"]))return n(`sveld: --strict must be "errors" when given a value; got "${e.strict}".`);if(d(e.checkLevel,["major","minor","patch"]))return n(`sveld: --check-level must be "major", "minor", or "patch"; got "${e.checkLevel}".`);if(d(e.checkExamples,[!0,!1,"syntax"]))return n(`sveld: --check-examples must be "syntax" when given a value; got "${e.checkExamples}".`);let c=e.typesOptions?.format;if(d(c,["class","component"]))return n(`sveld: --types-format must be "class" or "component"; got "${c}".`);J(e.quiet===!0);let l=Oe(e.entry),p;if(l.entry!==null)p=l.entry;else if(!l.configured&&S(x(s.cwd(),g)))console.error(`sveld: no entry point configured; using "${g}". Set package.json#svelte (or pass --entry) to silence this.`),p=te(r(g));else return n(`sveld: ${l.message}`);let h;try{h=await Me(p,e,e.stdout===!0)}catch(a){if(a instanceof K)return n(`sveld: ${a.message}`);console.error(a instanceof Error?a.message:String(a)),s.exitCode=m.GENERATION_FAILURE;return}let{result:v,check:f}=h,{exitCode:k}=Fe(v,f,e,p);if(f)if(e.format==="json")s.stdout.write(Se(f));else console.log(Ee(f));if(k!==m.SUCCESS)s.exitCode=k}export{_ as cli};
package/index.d.ts CHANGED
@@ -68,14 +68,20 @@ interface PendingConstDefaultCandidate {
68
68
  location: "props" | "moduleExports";
69
69
  importSource: string;
70
70
  importedName: string;
71
- /** Members read off the import, through namespace exports: `["DELAY"]` for `C.timing.DELAY`. */
71
+ /**
72
+ * Members read off the import, through namespace exports: `["DELAY"]`
73
+ * for `C.timing.DELAY`.
74
+ */
72
75
  members?: string[];
73
76
  }
74
77
 
75
78
  interface PendingContextKeyCandidate {
76
79
  importSource: string;
77
80
  importedName: string;
78
- /** Members read off the import, through namespace exports: `["THEME"]` for `ns.keys.THEME`. */
81
+ /**
82
+ * Members read off the import, through namespace exports: `["THEME"]`
83
+ * for `ns.keys.THEME`.
84
+ */
79
85
  members?: string[];
80
86
  /** See {@link ComponentContext.type}. */
81
87
  type?: string;
@@ -92,7 +98,10 @@ interface PendingContextKeyCandidate {
92
98
  interface PendingDispatchEscapeCandidate {
93
99
  importSource: string;
94
100
  importedName: string;
95
- /** Members read off the import, through namespace exports: `["helper"]` for `ns.helper`. */
101
+ /**
102
+ * Members read off the import, through namespace exports: `["helper"]`
103
+ * for `ns.helper`.
104
+ */
96
105
  members?: string[];
97
106
  /** Callee as written, for messages. */
98
107
  calleeText: string;
@@ -100,7 +109,10 @@ interface PendingDispatchEscapeCandidate {
100
109
  dispatcherName: string;
101
110
  /** Argument position the dispatcher is passed at. */
102
111
  argumentIndex: number;
103
- /** Set when passed as an object literal property (`{ dispatch }`): that property's key. */
112
+ /**
113
+ * Set when passed as an object literal property (`{ dispatch }`): that
114
+ * property's key.
115
+ */
104
116
  property?: string;
105
117
  /** Source range of the call, when available. */
106
118
  source?: SourceRange;
@@ -115,7 +127,8 @@ interface PendingCrossFileCandidates {
115
127
  pendingDispatchEscapeCandidates?: PendingDispatchEscapeCandidate[];
116
128
  /**
117
129
  * `event-no-source` diagnostics held back while the dispatcher escapes to
118
- * imported functions: the cross-file pass keeps those the functions don't dispatch.
130
+ * imported functions: the cross-file pass keeps those the functions
131
+ * don't dispatch.
119
132
  */
120
133
  deferredEventNoSourceDiagnostics?: SveldDiagnostic[];
121
134
  /**
@@ -129,7 +142,10 @@ interface ParsedComponentTypeScriptMetadata extends PendingCrossFileCandidates {
129
142
  canonicalPropsType?: string;
130
143
  canonicalPropNames: string[];
131
144
  localTypeDeclarations: string[];
132
- /** Types the module script exports (`export interface Item`), emitted with `export`. */
145
+ /**
146
+ * Types the module script exports (`export interface Item`), emitted
147
+ * with `export`.
148
+ */
133
149
  moduleTypeDeclarations?: string[];
134
150
  typeImportStatements: string[];
135
151
  }
@@ -166,25 +182,41 @@ interface ComponentPropParam {
166
182
  interface ComponentPropReExport {
167
183
  /** Module specifier as written in the source (e.g. `"./utils.js"`). */
168
184
  from: string;
169
- /** Name `from` exports: `"default"` for a default import, `"*"` for `export *` or a namespace import. */
185
+ /**
186
+ * Name `from` exports: `"default"` for a default import, `"*"` for
187
+ * `export *` or a namespace import.
188
+ */
170
189
  imported: string;
171
190
  }
172
191
 
173
192
  interface ComponentClassMember {
174
193
  /**
175
- * `"property"` covers fields, constructor parameter properties, and getter/setter pairs;
176
- * `"index"` is an index signature (`[key: string]: unknown`).
194
+ * `"property"` covers fields, constructor parameter properties, and
195
+ * getter/setter pairs; `"index"` is an index
196
+ * signature (`[key: string]: unknown`).
177
197
  */
178
198
  kind: "constructor" | "method" | "property" | "index";
179
- /** Member name; `"constructor"` for the constructor, the bracketed key (`[key: string]`) for an index signature. */
199
+ /**
200
+ * Member name; `"constructor"` for the constructor, the bracketed key
201
+ * (`[key: string]`) for an index signature.
202
+ */
180
203
  name: string;
181
204
  /** Property type text; `"any"` when neither TypeScript nor JSDoc types it. */
182
205
  type?: string;
183
- /** Method or constructor parameters, typed from TypeScript or JSDoc `@param`, else `"any"`. A rest parameter's name starts with `...`. */
206
+ /**
207
+ * Method or constructor parameters, typed from TypeScript or JSDoc
208
+ * `@param`, else `"any"`. A rest parameter's name starts with `...`.
209
+ */
184
210
  params?: ComponentPropParam[];
185
- /** Method return type from TypeScript or JSDoc `@returns`; unset when neither gives one. */
211
+ /**
212
+ * Method return type from TypeScript or JSDoc `@returns`; unset when
213
+ * neither gives one.
214
+ */
186
215
  returnType?: string;
187
- /** A method's own type parameter list (`U extends object`), without the angle brackets. */
216
+ /**
217
+ * A method's own type parameter list (`U extends object`), without the
218
+ * angle brackets.
219
+ */
188
220
  typeParameters?: string;
189
221
  static?: true;
190
222
  /** A `readonly` field, or a getter with no setter. */
@@ -210,15 +242,27 @@ interface ComponentProp {
210
242
  /** True when declared with `const`. */
211
243
  constant: boolean;
212
244
  type?: string;
213
- /** Conservative provenance for the prop type. See the precedence rule on {@link ComponentProp}. */
245
+ /**
246
+ * Conservative provenance for the prop type. See the precedence rule on
247
+ * {@link ComponentProp}.
248
+ */
214
249
  typeSource?: ComponentPropTypeSource;
215
250
  /** Local binding when it differs from the public name. */
216
251
  localName?: string;
217
- /** Default value as source text; unset when the prop has no initializer/default. */
252
+ /**
253
+ * Default value as source text; unset when the prop has
254
+ * no initializer/default.
255
+ */
218
256
  value?: string;
219
- /** Structured default value metadata for docs UIs; set alongside `value` from the same initializer. */
257
+ /**
258
+ * Structured default value metadata for docs UIs; set alongside `value`
259
+ * from the same initializer.
260
+ */
220
261
  defaultValue?: ComponentPropDefaultValue;
221
- /** From JSDoc, or a matching `@typedef`'s own description (legacy only; see {@link ComponentProp}). */
262
+ /**
263
+ * From JSDoc, or a matching `@typedef`'s own description (legacy only; see
264
+ * {@link ComponentProp}).
265
+ */
222
266
  description?: string;
223
267
  /** From JSDoc `@param` on function props. */
224
268
  params?: ComponentPropParam[];
@@ -227,17 +271,23 @@ interface ComponentProp {
227
271
  /**
228
272
  * A function's own type parameter list from its `@template` tags (e.g.
229
273
  * `T extends { id: string }`), without the angle brackets. Also prefixed
230
- * onto `type` when that signature is built from `@param`/`@returns`.
231
- * For a `"class"`, the class's type parameters, from TypeScript or `@template`.
274
+ * onto `type` when that signature is built from `@param`/`@returns`. For a
275
+ * `"class"`, the class's type parameters, from TypeScript or `@template`.
232
276
  */
233
277
  typeParameters?: string;
234
- /** Set when `kind` is `"class"`: its public constructor, methods, and properties, in source order. */
278
+ /**
279
+ * Set when `kind` is `"class"`: its public constructor, methods, and
280
+ * properties, in source order.
281
+ */
235
282
  members?: ComponentClassMember[];
236
283
  /** Set when `kind` is `"class"` and the class is `abstract`. */
237
284
  abstract?: true;
238
285
  /** Set when `kind` is `"class"` and it extends a base class: `Base<T>`. */
239
286
  extends?: string;
240
- /** Set when `kind` is `"class"` and it implements interfaces: `["Disposable"]`. */
287
+ /**
288
+ * Set when `kind` is `"class"` and it
289
+ * implements interfaces: `["Disposable"]`.
290
+ */
241
291
  implements?: string[];
242
292
  /**
243
293
  * True for arrow/function-expression initializers and bare `function`
@@ -261,7 +311,10 @@ interface ComponentProp {
261
311
  deprecated?: DeprecatedValue;
262
312
  /** `@since` / `@example` tags in source order. */
263
313
  tags?: JsDocPassthroughTag[];
264
- /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */
314
+ /**
315
+ * True from `@ignore`/`@internal` JSDoc; excluded from every output
316
+ * by `buildComponentApiDocument`.
317
+ */
265
318
  internal?: boolean;
266
319
  /** Set when `kind` is `"re-export"`. */
267
320
  reExport?: ComponentPropReExport;
@@ -280,9 +333,15 @@ interface ComponentSlot {
280
333
  description?: string;
281
334
  /** From `@deprecated` JSDoc. */
282
335
  deprecated?: DeprecatedValue;
283
- /** Tags between the description and `@slot`/`@snippet` (e.g. `@example`), in source order. */
336
+ /**
337
+ * Tags between the description and `@slot`/`@snippet` (e.g. `@example`),
338
+ * in source order.
339
+ */
284
340
  tags?: JsDocPassthroughTag[];
285
- /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */
341
+ /**
342
+ * True from `@ignore`/`@internal` JSDoc; excluded from every output
343
+ * by `buildComponentApiDocument`.
344
+ */
286
345
  internal?: boolean;
287
346
  source?: SourceRange;
288
347
  }
@@ -297,7 +356,10 @@ interface DispatchedEvent {
297
356
  deprecated?: DeprecatedValue;
298
357
  /** `@since` / `@example` tags in source order. */
299
358
  tags?: JsDocPassthroughTag[];
300
- /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */
359
+ /**
360
+ * True from `@ignore`/`@internal` JSDoc; excluded from every output
361
+ * by `buildComponentApiDocument`.
362
+ */
301
363
  internal?: boolean;
302
364
  source?: SourceRange;
303
365
  }
@@ -315,7 +377,10 @@ interface SerializedForwardedEvent {
315
377
  detail?: string;
316
378
  /** `@since` / `@example` tags in source order. */
317
379
  tags?: JsDocPassthroughTag[];
318
- /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */
380
+ /**
381
+ * True from `@ignore`/`@internal` JSDoc; excluded from every output
382
+ * by `buildComponentApiDocument`.
383
+ */
319
384
  internal?: boolean;
320
385
  source?: SourceRange;
321
386
  }
@@ -329,9 +394,15 @@ interface TypeDef {
329
394
  description?: string;
330
395
  /** Full `type` alias declaration text. */
331
396
  ts: string;
332
- /** Tags in the same block (e.g. `@since`, `@example`, `@see`), in source order. */
397
+ /**
398
+ * Tags in the same block (e.g. `@since`, `@example`, `@see`), in
399
+ * source order.
400
+ */
333
401
  tags?: JsDocPassthroughTag[];
334
- /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */
402
+ /**
403
+ * True from `@ignore`/`@internal` JSDoc; excluded from every output
404
+ * by `buildComponentApiDocument`.
405
+ */
335
406
  internal?: boolean;
336
407
  /** Source range of the `@typedef`/`@callback` tag, when available. */
337
408
  source?: SourceRange;
@@ -348,7 +419,8 @@ interface ComponentElement {
348
419
  type: "Element";
349
420
  name: string;
350
421
  /**
351
- * Static tag for `svelte:element this="div"`. Undefined when `this` is dynamic.
422
+ * Static tag for `svelte:element this="div"`. Undefined when `this`
423
+ * is dynamic.
352
424
  *
353
425
  * @example
354
426
  * ```svelte
@@ -383,7 +455,11 @@ interface Extends {
383
455
  type CustomElementPropType = "String" | "Boolean" | "Number" | "Array" | "Object";
384
456
 
385
457
  interface CustomElementPropConfig {
386
- /** Explicit attribute name. Svelte itself always observes every prop as an attribute; sveld's own output omits the attribute entirely when this is `false`. */
458
+ /**
459
+ * Explicit attribute name. Svelte itself always observes every prop as an
460
+ * attribute; sveld's own output omits the attribute entirely when this
461
+ * is `false`.
462
+ */
387
463
  attribute?: string | false;
388
464
  reflect?: boolean;
389
465
  type?: CustomElementPropType;
@@ -414,7 +490,10 @@ interface ComponentContextProp {
414
490
  type: string;
415
491
  description?: string;
416
492
  optional: boolean;
417
- /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */
493
+ /**
494
+ * True from `@ignore`/`@internal` JSDoc; excluded from every output
495
+ * by `buildComponentApiDocument`.
496
+ */
418
497
  internal?: boolean;
419
498
  }
420
499
 
@@ -423,17 +502,23 @@ interface ComponentContext {
423
502
  /** Generated type name (e.g. `"ModalContext"`). */
424
503
  typeName: string;
425
504
  /**
426
- * The context's whole type, when the `setContext` value is a variable whose
427
- * type isn't an object type literal (`ModalAPI`, `Writable<number>`, or `any`
428
- * when untyped). `properties` is empty then.
505
+ * The context's whole type, when the `setContext` value is a variable
506
+ * whose type isn't an object type literal (`ModalAPI`, `Writable<number>`,
507
+ * or `any` when untyped). `properties` is empty then.
429
508
  */
430
509
  type?: string;
431
510
  description?: string;
432
511
  /** Empty when {@link ComponentContext.type} is set. */
433
512
  properties: ComponentContextProp[];
434
- /** True when a `{...spread}` in the context's object literal couldn't be resolved; the generated type intersects with `Record<string, any>`. */
513
+ /**
514
+ * True when a `{...spread}` in the context's object literal couldn't be
515
+ * resolved; the generated type intersects with `Record<string, any>`.
516
+ */
435
517
  hasUnresolvedSpread?: boolean;
436
- /** True from `@ignore`/`@internal` JSDoc on the `setContext` call; excluded from every output by `buildComponentApiDocument`. */
518
+ /**
519
+ * True from `@ignore`/`@internal` JSDoc on the `setContext` call; excluded
520
+ * from every output by `buildComponentApiDocument`.
521
+ */
437
522
  internal?: boolean;
438
523
  /** Source range of the `setContext(...)` call, when available. */
439
524
  source?: SourceRange;
@@ -443,9 +528,16 @@ interface ParsedComponent {
443
528
  source?: SourceRange;
444
529
  syntaxMode: SyntaxMode;
445
530
  scriptLanguage?: ScriptLanguage;
446
- /** Instance-level props (`export let`/`export function`, or runes `$props()`). See {@link ComponentProp} for the shared IR these are built from. */
531
+ /**
532
+ * Instance-level props (`export let`/`export function`, or runes
533
+ * `$props()`). See {@link ComponentProp} for the shared IR these are
534
+ * built from.
535
+ */
447
536
  props: ComponentProp[];
448
- /** Exports from `<script context="module">`. Same {@link ComponentProp} shape as `props`, resolved through the same shared decisions. */
537
+ /**
538
+ * Exports from `<script context="module">`. Same {@link ComponentProp}
539
+ * shape as `props`, resolved through the same shared decisions.
540
+ */
449
541
  moduleExports: ComponentProp[];
450
542
  slots: ComponentSlot[];
451
543
  /** Serialized events for JSON/API output. */
@@ -459,13 +551,19 @@ interface ParsedComponent {
459
551
  componentCommentSource?: SourceRange;
460
552
  contexts?: ComponentContext[];
461
553
  customElementTag?: string;
462
- /** Full `<svelte:options customElement=... />` config (shorthand or object form), when present. */
554
+ /**
555
+ * Full `<svelte:options customElement=... />` config (shorthand or object
556
+ * form), when present.
557
+ */
463
558
  customElement?: CustomElementOptions;
464
559
  /** From component-level `@csspart` JSDoc tags. */
465
560
  cssParts?: ComponentCssPart[];
466
561
  /** From component-level `@cssprop`/`@cssproperty` JSDoc tags. */
467
562
  cssProperties?: ComponentCssProperty[];
468
- /** Type guesses from this parse (unknown props, `any` contexts, orphan `@event` tags). */
563
+ /**
564
+ * Type guesses from this parse (unknown props, `any` contexts, orphan
565
+ * `@event` tags).
566
+ */
469
567
  diagnostics?: SveldDiagnostic[];
470
568
  /** Writer-only TypeScript metadata. Not serialized to JSON. */
471
569
  [PARSED_COMPONENT_TYPE_SCRIPT_METADATA]?: ParsedComponentTypeScriptMetadata;
@@ -483,19 +581,25 @@ export interface SveldDiagnostic {
483
581
  */
484
582
  component: string;
485
583
  kind: SveldDiagnosticKind;
486
- /** Stable, namespaced identifier for `kind` (e.g. `"sveld/prop-unknown-type"`). */
584
+ /**
585
+ * Stable, namespaced identifier for `kind`
586
+ * (e.g. `"sveld/prop-unknown-type"`).
587
+ */
487
588
  code: string;
488
589
  severity: SveldDiagnosticSeverity;
489
590
  /** Prop, context field, or event name. */
490
591
  name: string;
491
592
  /** What went wrong and what type sveld used. */
492
593
  message: string;
493
- /** Where in the component source this diagnostic points, when the parser holds a stable position. */
594
+ /**
595
+ * Where in the component source this diagnostic points, when the parser
596
+ * holds a stable position.
597
+ */
494
598
  source?: SourceRange;
495
599
  /**
496
- * True when suppressed by an inline `@sveld-ignore` tag or a `diagnostics.ignore`
497
- * config matcher. Still present here (and counted in the summary) but never
498
- * fails `--strict` / `--strict=errors`.
600
+ * True when suppressed by an inline `@sveld-ignore` tag or a
601
+ * `diagnostics.ignore` config matcher. Still present here (and counted in
602
+ * the summary) but never fails `--strict` / `--strict=errors`.
499
603
  */
500
604
  ignored?: boolean;
501
605
  }
@@ -523,12 +627,21 @@ declare const PARSED_COMPONENT_PROP_IGNORES: unique symbol;
523
627
  export type SemverBump = "major" | "minor" | "patch" | "none";
524
628
 
525
629
  export interface ApiChange {
526
- /** Component `moduleName` this change belongs to, or `"*"` for document-wide notices. */
630
+ /**
631
+ * Component `moduleName` this change belongs to, or `"*"` for
632
+ * document-wide notices.
633
+ */
527
634
  component: string;
528
635
  kind: "component" | "prop" | "moduleExport" | "event" | "slot" | "context" | "typedef" | "shape" | "schema";
529
- /** Prop, event, slot, context key, typedef, or shape-field name, when applicable. */
636
+ /**
637
+ * Prop, event, slot, context key, typedef, or shape-field name,
638
+ * when applicable.
639
+ */
530
640
  name?: string;
531
- /** For `kind: "context"`, the context property the change is about. Absent when it's the context as a whole. */
641
+ /**
642
+ * For `kind: "context"`, the context property the change is about. Absent
643
+ * when it's the context as a whole.
644
+ */
532
645
  property?: string;
533
646
  bump: SemverBump;
534
647
  message: string;
@@ -583,13 +696,16 @@ interface GenerateBundleOptions {
583
696
  * the failure and continuing with the remaining components.
584
697
  */
585
698
  failFast?: boolean;
586
- /** Record consts, functions, and types from the entry barrel. Off by default. */
699
+ /**
700
+ * Record consts, functions, and types from the entry barrel. Off
701
+ * by default.
702
+ */
587
703
  documentExports?: boolean;
588
704
  /**
589
- * Cache parsed component output to disk. Unchanged files skip re-parsing on
590
- * later runs. On by default, writing to
591
- * `node_modules/.cache/sveld/parse-cache.json`; a string sets a custom path.
592
- * Pass `false` to disable.
705
+ * Cache parsed component output to disk. Unchanged files skip re-parsing
706
+ * on later runs. On by default, writing to
707
+ * `node_modules/.cache/sveld/parse-cache.json`; a string sets a custom
708
+ * path. Pass `false` to disable.
593
709
  */
594
710
  cache?: boolean | string;
595
711
  /**
@@ -603,11 +719,11 @@ interface GenerateBundleOptions {
603
719
  */
604
720
  checkExamples?: boolean | "syntax";
605
721
  /**
606
- * `ignore`: diagnostics matching at least one `{ code?, component?, name? }`
607
- * matcher are marked `ignored` (an omitted field matches anything;
608
- * `component` is a glob). Ignored diagnostics still appear in
609
- * `SveldResult.diagnostics` and are counted in the text summary, but never
610
- * fail `--strict` / `--strict=errors`.
722
+ * `ignore`: diagnostics matching at least one
723
+ * `{ code?, component?, name? }` matcher are marked `ignored` (an omitted
724
+ * field matches anything; `component` is a glob). Ignored diagnostics
725
+ * still appear in `SveldResult.diagnostics` and are counted in the text
726
+ * summary, but never fail `--strict` / `--strict=errors`.
611
727
  */
612
728
  diagnostics?: {
613
729
  ignore?: DiagnosticIgnoreMatcher[];
@@ -640,7 +756,10 @@ interface EntryExport {
640
756
  deprecated?: DeprecatedValue;
641
757
  /** `@since` / `@example` / `@see` tags in source order. */
642
758
  tags?: JsDocPassthroughTag[];
643
- /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */
759
+ /**
760
+ * True from `@ignore`/`@internal` JSDoc; excluded from every output
761
+ * by `buildComponentApiDocument`.
762
+ */
644
763
  internal?: boolean;
645
764
  /** Declaring module, relative to the entry file. */
646
765
  source?: string;
@@ -685,8 +804,9 @@ export interface SveldRuntimeOptions extends PluginSveldOptions {
685
804
  *
686
805
  * `"github"` prints the text report and summary, preceded by one GitHub
687
806
  * Actions annotation per diagnostic (`::warning file=...::message`), so
688
- * findings appear on the pull request's diff. Annotation paths are relative
689
- * to `GITHUB_WORKSPACE`, or the working directory when it isn't set.
807
+ * findings appear on the pull request's diff. Annotation paths are
808
+ * relative to `GITHUB_WORKSPACE`, or the working directory when it
809
+ * isn't set.
690
810
  */
691
811
  format?: "text" | "json" | "github";
692
812
  }
@@ -713,7 +833,10 @@ interface PluginSveldOptions extends Pick<GenerateBundleOptions, "cache" | "chec
713
833
  glob?: boolean;
714
834
  /** Suppress writer progress logs (`created "..."` / `unchanged "..."`). */
715
835
  quiet?: boolean;
716
- /** Record consts, functions, and types from the entry barrel. Off by default. */
836
+ /**
837
+ * Record consts, functions, and types from the entry barrel. Off
838
+ * by default.
839
+ */
717
840
  documentExports?: boolean;
718
841
  types?: boolean;
719
842
  typesOptions?: TypesOptions;
@@ -822,8 +945,8 @@ export interface MarkdownOptions {
822
945
  /**
823
946
  * Emit one `<ModuleName>.md` file per component into this directory,
824
947
  * plus an index `README.md` linking to each, instead of the single
825
- * combined `outFile`. See `jsonOptions.outDir` for the equivalent JSON
826
- * option.
948
+ * combined `outFile`. See `jsonOptions.outDir` for the equivalent
949
+ * JSON option.
827
950
  */
828
951
  outDir?: string;
829
952
  /**
@@ -836,7 +959,10 @@ export interface MarkdownOptions {
836
959
  type AppendType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "quote" | "p" | "divider" | "raw";
837
960
 
838
961
  interface TocLine {
839
- /** Leading space count; 0 for the top-level (`h2`) entries the TOC currently lists. */
962
+ /**
963
+ * Leading space count; 0 for the top-level (`h2`) entries the TOC
964
+ * currently lists.
965
+ */
840
966
  indent: number;
841
967
  raw: string;
842
968
  }
@@ -871,14 +997,14 @@ type TransformContext = {
871
997
 
872
998
  export interface TypesOptions extends WriteTsDefinitionOptions {
873
999
  /**
874
- * Output directory for generated `.d.ts` files, relative to the project
875
- * root.
1000
+ * Output directory for generated `.d.ts` files, relative to the
1001
+ * project root.
876
1002
  * @default "types"
877
1003
  */
878
1004
  outDir?: string;
879
1005
  /**
880
- * Raw text prepended to the generated `index.d.ts` barrel, e.g. a license
881
- * header.
1006
+ * Raw text prepended to the generated `index.d.ts` barrel, e.g. a
1007
+ * license header.
882
1008
  * @default ""
883
1009
  */
884
1010
  preamble?: string;
@@ -898,10 +1024,11 @@ export interface TypesOptions extends WriteTsDefinitionOptions {
898
1024
  interface WriteTsDefinitionOptions {
899
1025
  /**
900
1026
  * `"class"` (default) extends the deprecated `SvelteComponentTyped`.
901
- * `"component"` emits `declare const X: Component<Props, Exports, Bindings>`
902
- * instead, for Svelte 5+ consumers. Generic components and components with
903
- * events get a per-component interface instead, since a `declare const`
904
- * can't carry a generic type parameter and `Component` has no events slot.
1027
+ * `"component"` emits
1028
+ * `declare const X: Component<Props, Exports, Bindings>` instead, for
1029
+ * Svelte 5+ consumers. Generic components and components with events get a
1030
+ * per-component interface instead, since a `declare const` can't carry a
1031
+ * generic type parameter and `Component` has no events slot.
905
1032
  */
906
1033
  format?: "class" | "component";
907
1034
  }
@@ -909,9 +1036,15 @@ interface WriteTsDefinitionOptions {
909
1036
  export interface SveldResult {
910
1037
  /** Diagnostics from this run. */
911
1038
  diagnostics: SveldDiagnostic[];
912
- /** Populated when `check` is enabled: the API diff against the committed snapshot. */
1039
+ /**
1040
+ * Populated when `check` is enabled: the API diff against the
1041
+ * committed snapshot.
1042
+ */
913
1043
  check?: CheckResult;
914
- /** Parse errors for components that failed to parse (empty unless `failFast` is disabled and a component errors). */
1044
+ /**
1045
+ * Parse errors for components that failed to parse (empty unless
1046
+ * `failFast` is disabled and a component errors).
1047
+ */
915
1048
  errors: ComponentParseError[];
916
1049
  /**
917
1050
  * The component API document for the exported components, exactly as the
@@ -921,8 +1054,9 @@ export interface SveldResult {
921
1054
  document: ComponentApiDocument;
922
1055
  /**
923
1056
  * Suggested process exit code for this run, using the same mapping as the
924
- * CLI (see {@link resolveExitCode}). `sveld()` never mutates `process.exitCode` itself; assign this
925
- * value yourself if you want the process to exit non-zero.
1057
+ * CLI (see {@link resolveExitCode}). `sveld()` never mutates
1058
+ * `process.exitCode` itself; assign this value yourself if you want the
1059
+ * process to exit non-zero.
926
1060
  */
927
1061
  exitCode: ExitCode;
928
1062
  }
@@ -931,8 +1065,8 @@ type ExitCode = 0 | 1 | 2 | 3 | 4;
931
1065
 
932
1066
  export interface SveldOptions extends Omit<SveldRuntimeOptions, "config"> {
933
1067
  /**
934
- * Whether to load `sveld.config.{js,mjs,ts}` from the working directory and
935
- * merge it under these options. `false` ignores it.
1068
+ * Whether to load `sveld.config.{js,mjs,ts}` from the working directory
1069
+ * and merge it under these options. `false` ignores it.
936
1070
  * @default true
937
1071
  */
938
1072
  config?: boolean;
package/index.js CHANGED
@@ -1 +1 @@
1
- import{q,je,y,Ft,Ie,xe,Bt,Ee,Wt,jt,Ht}from"./chunk-ep5n8z9k.js";import{ne}from"./chunk-xv4tka7y.js";export{Bt as CHECK_REPORT_SCHEMA_VERSION,ne as ComponentParser,je as DIAGNOSTICS_SCHEMA_VERSION,q as DIAGNOSTIC_CODES,y as buildComponentApiDocument,jt as default,Wt as defineConfig,Ft as diffApiDocuments,xe as formatCheckReport,Ee as formatCheckReportJson,Ie as runCheck,Ht as sveld};
1
+ import{X,Ve,y,jt,Le,Ee,Vt,Se,Ut,Gt,Jt}from"./chunk-9fmhgf46.js";import{re}from"./chunk-0e70e5s3.js";export{Vt as CHECK_REPORT_SCHEMA_VERSION,re as ComponentParser,Ve as DIAGNOSTICS_SCHEMA_VERSION,X as DIAGNOSTIC_CODES,y as buildComponentApiDocument,Gt as default,Ut as defineConfig,jt as diffApiDocuments,Ee as formatCheckReport,Se as formatCheckReportJson,Le as runCheck,Jt as sveld};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveld",
3
- "version": "0.40.5",
3
+ "version": "0.40.6",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Generate TypeScript definitions and component documentation for your Svelte components.",
6
6
  "type": "module",