svelte-docinfo 0.1.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.
Files changed (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -0
  3. package/dist/analyze-core.d.ts +1386 -0
  4. package/dist/analyze-core.d.ts.map +1 -0
  5. package/dist/analyze-core.js +324 -0
  6. package/dist/analyze.d.ts +137 -0
  7. package/dist/analyze.d.ts.map +1 -0
  8. package/dist/analyze.js +148 -0
  9. package/dist/cli.d.ts +102 -0
  10. package/dist/cli.d.ts.map +1 -0
  11. package/dist/cli.js +206 -0
  12. package/dist/concurrency.d.ts +38 -0
  13. package/dist/concurrency.d.ts.map +1 -0
  14. package/dist/concurrency.js +57 -0
  15. package/dist/declaration-build.d.ts +164 -0
  16. package/dist/declaration-build.d.ts.map +1 -0
  17. package/dist/declaration-build.js +15 -0
  18. package/dist/declaration-helpers.d.ts +169 -0
  19. package/dist/declaration-helpers.d.ts.map +1 -0
  20. package/dist/declaration-helpers.js +239 -0
  21. package/dist/dep-resolver.d.ts +166 -0
  22. package/dist/dep-resolver.d.ts.map +1 -0
  23. package/dist/dep-resolver.js +144 -0
  24. package/dist/diagnostics.d.ts +650 -0
  25. package/dist/diagnostics.d.ts.map +1 -0
  26. package/dist/diagnostics.js +377 -0
  27. package/dist/discovery.d.ts +115 -0
  28. package/dist/discovery.d.ts.map +1 -0
  29. package/dist/discovery.js +126 -0
  30. package/dist/exports.d.ts +105 -0
  31. package/dist/exports.d.ts.map +1 -0
  32. package/dist/exports.js +274 -0
  33. package/dist/files.d.ts +77 -0
  34. package/dist/files.d.ts.map +1 -0
  35. package/dist/files.js +95 -0
  36. package/dist/index.d.ts +32 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +30 -0
  39. package/dist/log.d.ts +32 -0
  40. package/dist/log.d.ts.map +1 -0
  41. package/dist/log.js +11 -0
  42. package/dist/logo.d.ts +8 -0
  43. package/dist/logo.d.ts.map +1 -0
  44. package/dist/logo.js +9 -0
  45. package/dist/main.d.ts +11 -0
  46. package/dist/main.d.ts.map +1 -0
  47. package/dist/main.js +18 -0
  48. package/dist/paths.d.ts +35 -0
  49. package/dist/paths.d.ts.map +1 -0
  50. package/dist/paths.js +34 -0
  51. package/dist/postprocess.d.ts +145 -0
  52. package/dist/postprocess.d.ts.map +1 -0
  53. package/dist/postprocess.js +305 -0
  54. package/dist/session.d.ts +248 -0
  55. package/dist/session.d.ts.map +1 -0
  56. package/dist/session.js +496 -0
  57. package/dist/source-config.d.ts +330 -0
  58. package/dist/source-config.d.ts.map +1 -0
  59. package/dist/source-config.js +356 -0
  60. package/dist/source.d.ts +126 -0
  61. package/dist/source.d.ts.map +1 -0
  62. package/dist/source.js +68 -0
  63. package/dist/svelte.d.ts +179 -0
  64. package/dist/svelte.d.ts.map +1 -0
  65. package/dist/svelte.js +898 -0
  66. package/dist/tsdoc.d.ts +145 -0
  67. package/dist/tsdoc.d.ts.map +1 -0
  68. package/dist/tsdoc.js +262 -0
  69. package/dist/types.d.ts +3381 -0
  70. package/dist/types.d.ts.map +1 -0
  71. package/dist/types.js +588 -0
  72. package/dist/typescript-exports.d.ts +91 -0
  73. package/dist/typescript-exports.d.ts.map +1 -0
  74. package/dist/typescript-exports.js +656 -0
  75. package/dist/typescript-extract-class.d.ts +29 -0
  76. package/dist/typescript-extract-class.d.ts.map +1 -0
  77. package/dist/typescript-extract-class.js +251 -0
  78. package/dist/typescript-extract-function.d.ts +47 -0
  79. package/dist/typescript-extract-function.d.ts.map +1 -0
  80. package/dist/typescript-extract-function.js +108 -0
  81. package/dist/typescript-extract-shared.d.ts +166 -0
  82. package/dist/typescript-extract-shared.d.ts.map +1 -0
  83. package/dist/typescript-extract-shared.js +528 -0
  84. package/dist/typescript-extract-type-properties.d.ts +34 -0
  85. package/dist/typescript-extract-type-properties.d.ts.map +1 -0
  86. package/dist/typescript-extract-type-properties.js +241 -0
  87. package/dist/typescript-extract-type.d.ts +48 -0
  88. package/dist/typescript-extract-type.d.ts.map +1 -0
  89. package/dist/typescript-extract-type.js +238 -0
  90. package/dist/typescript-program.d.ts +211 -0
  91. package/dist/typescript-program.d.ts.map +1 -0
  92. package/dist/typescript-program.js +290 -0
  93. package/dist/vite.d.ts +116 -0
  94. package/dist/vite.d.ts.map +1 -0
  95. package/dist/vite.js +418 -0
  96. package/package.json +131 -0
  97. package/virtual-svelte-docinfo.d.ts +49 -0
@@ -0,0 +1,650 @@
1
+ /**
2
+ * Diagnostic collection for source analysis.
3
+ *
4
+ * Provides structured error/warning collection during TypeScript and Svelte
5
+ * analysis, replacing silent catch blocks with actionable diagnostics.
6
+ *
7
+ * ## Error Handling Contract
8
+ *
9
+ * The pipeline accumulates failures into the `diagnostics` array and keeps
10
+ * going — analysis continues, declarations/members reach the output with
11
+ * `partial: true` when extraction failed mid-flight, and the caller decides
12
+ * how to react. Producers include type resolution failures, individual
13
+ * member/prop extraction failures, svelte2tsx transform failures, source-map
14
+ * construction failures, import lex / resolver failures, and duplicate
15
+ * declarations.
16
+ *
17
+ * A small set of conditions still throws from public entry points — these are
18
+ * setup-level, not per-file: missing `tsconfig.json` (`loadTsconfig`), Svelte
19
+ * <5 detected (`transformSvelteSource`), or strict `discovery: 'exports'`
20
+ * mode with no resolvable exports (`discoverSourceFiles`). Wrap the top-level
21
+ * `analyze` / `analyzeFromFiles` call if you want to handle these.
22
+ *
23
+ * ## Usage Pattern
24
+ *
25
+ * ```ts
26
+ * const {modules, diagnostics} = await analyze({sourceFiles, sourceOptions});
27
+ *
28
+ * if (hasErrors(diagnostics)) {
29
+ * for (const err of errorsOf(diagnostics)) {
30
+ * console.error(formatDiagnostic(err));
31
+ * }
32
+ * }
33
+ * for (const warning of warningsOf(diagnostics)) {
34
+ * console.warn(formatDiagnostic(warning));
35
+ * }
36
+ * ```
37
+ *
38
+ * ## Schema-Validated Plain Data
39
+ *
40
+ * `AnalyzeResultJson.diagnostics` is `Array<Diagnostic>` — no wrapper object,
41
+ * no methods, no private fields. Round-trip-safe through `JSON.stringify` /
42
+ * `z.array(Diagnostic).parse` and symmetric with `AnalyzeResultJson.modules`
43
+ * (also Zod-validated). The full envelope is itself a Zod schema
44
+ * (`AnalyzeResultJson` in `analyze-core.ts`) with both fields defaulting to
45
+ * `[]`, so the whole `{modules, diagnostics}` shape round-trips through
46
+ * `JSON.stringify(result, compactReplacer)` / `AnalyzeResultJson.parse` even
47
+ * when one or both arrays are empty (the wire form becomes `{}` and `.parse()`
48
+ * restores the defaults). Use the free helpers `hasErrors`, `errorsOf`,
49
+ * `byKind` for queries; mutate the array with native `Array.push`.
50
+ *
51
+ * ## File Path Contract
52
+ *
53
+ * `Diagnostic.file` is always project-root-relative — no leading slash,
54
+ * no `./` prefix. `analyze` / `analyzeFromFiles` normalize paths from all
55
+ * sources (extraction, discovery, dependency resolution) before returning.
56
+ * Consumers that need an absolute path can rejoin with `projectRoot`.
57
+ *
58
+ * @module
59
+ */
60
+ import { z } from 'zod';
61
+ /**
62
+ * Diagnostic severity levels.
63
+ *
64
+ * - `'error'` — analysis failed, declaration may be incomplete or missing data
65
+ * - `'warning'` — partial success, something seems off but analysis continued
66
+ */
67
+ export declare const DiagnosticSeverity: z.ZodEnum<{
68
+ error: "error";
69
+ warning: "warning";
70
+ }>;
71
+ export type DiagnosticSeverity = z.infer<typeof DiagnosticSeverity>;
72
+ /**
73
+ * Discriminant for `Diagnostic` variant types.
74
+ */
75
+ export declare const DiagnosticKind: z.ZodEnum<{
76
+ type_extraction_failed: "type_extraction_failed";
77
+ signature_analysis_failed: "signature_analysis_failed";
78
+ class_member_failed: "class_member_failed";
79
+ svelte_prop_failed: "svelte_prop_failed";
80
+ module_skipped: "module_skipped";
81
+ module_unreadable: "module_unreadable";
82
+ import_parse_failed: "import_parse_failed";
83
+ duplicate_comment: "duplicate_comment";
84
+ misplaced_tag: "misplaced_tag";
85
+ unknown_param: "unknown_param";
86
+ source_map_failed: "source_map_failed";
87
+ duplicate_declaration: "duplicate_declaration";
88
+ transform_failed: "transform_failed";
89
+ resolver_failed: "resolver_failed";
90
+ }>;
91
+ export type DiagnosticKind = z.infer<typeof DiagnosticKind>;
92
+ /**
93
+ * Type extraction failed (e.g., complex or recursive types).
94
+ */
95
+ export declare const TypeExtractionDiagnostic: z.ZodObject<{
96
+ /** Name of the symbol whose type couldn't be extracted. */
97
+ symbolName: z.ZodString;
98
+ /**
99
+ * File path relative to project root (no leading slash, no `./` prefix).
100
+ *
101
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
102
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
103
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
104
+ * pipeline may write absolute or virtual paths (e.g.,
105
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
106
+ * project-relative form before they reach consumers.
107
+ */
108
+ file: z.ZodString;
109
+ /** Line number (1-based), absent if location unavailable. */
110
+ line: z.ZodOptional<z.ZodNumber>;
111
+ /** Column number (1-based), absent if location unavailable. */
112
+ column: z.ZodOptional<z.ZodNumber>;
113
+ /** Human-readable description of the issue. */
114
+ message: z.ZodString;
115
+ severity: z.ZodEnum<{
116
+ error: "error";
117
+ warning: "warning";
118
+ }>;
119
+ kind: z.ZodLiteral<"type_extraction_failed">;
120
+ }, z.core.$strict>;
121
+ export type TypeExtractionDiagnostic = z.infer<typeof TypeExtractionDiagnostic>;
122
+ /**
123
+ * Function/method signature analysis failed.
124
+ */
125
+ export declare const SignatureAnalysisDiagnostic: z.ZodObject<{
126
+ /** Name of the function or method. */
127
+ functionName: z.ZodString;
128
+ /**
129
+ * File path relative to project root (no leading slash, no `./` prefix).
130
+ *
131
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
132
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
133
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
134
+ * pipeline may write absolute or virtual paths (e.g.,
135
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
136
+ * project-relative form before they reach consumers.
137
+ */
138
+ file: z.ZodString;
139
+ /** Line number (1-based), absent if location unavailable. */
140
+ line: z.ZodOptional<z.ZodNumber>;
141
+ /** Column number (1-based), absent if location unavailable. */
142
+ column: z.ZodOptional<z.ZodNumber>;
143
+ /** Human-readable description of the issue. */
144
+ message: z.ZodString;
145
+ severity: z.ZodEnum<{
146
+ error: "error";
147
+ warning: "warning";
148
+ }>;
149
+ kind: z.ZodLiteral<"signature_analysis_failed">;
150
+ }, z.core.$strict>;
151
+ export type SignatureAnalysisDiagnostic = z.infer<typeof SignatureAnalysisDiagnostic>;
152
+ /**
153
+ * Class member analysis failed.
154
+ */
155
+ export declare const ClassMemberDiagnostic: z.ZodObject<{
156
+ /** Name of the class. */
157
+ className: z.ZodString;
158
+ /** Name of the member that failed. */
159
+ memberName: z.ZodString;
160
+ /**
161
+ * File path relative to project root (no leading slash, no `./` prefix).
162
+ *
163
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
164
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
165
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
166
+ * pipeline may write absolute or virtual paths (e.g.,
167
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
168
+ * project-relative form before they reach consumers.
169
+ */
170
+ file: z.ZodString;
171
+ /** Line number (1-based), absent if location unavailable. */
172
+ line: z.ZodOptional<z.ZodNumber>;
173
+ /** Column number (1-based), absent if location unavailable. */
174
+ column: z.ZodOptional<z.ZodNumber>;
175
+ /** Human-readable description of the issue. */
176
+ message: z.ZodString;
177
+ severity: z.ZodEnum<{
178
+ error: "error";
179
+ warning: "warning";
180
+ }>;
181
+ kind: z.ZodLiteral<"class_member_failed">;
182
+ }, z.core.$strict>;
183
+ export type ClassMemberDiagnostic = z.infer<typeof ClassMemberDiagnostic>;
184
+ /**
185
+ * Svelte prop type resolution failed.
186
+ */
187
+ export declare const SveltePropDiagnostic: z.ZodObject<{
188
+ /** Name of the component. */
189
+ componentName: z.ZodString;
190
+ /** Name of the prop. */
191
+ propName: z.ZodString;
192
+ /**
193
+ * File path relative to project root (no leading slash, no `./` prefix).
194
+ *
195
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
196
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
197
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
198
+ * pipeline may write absolute or virtual paths (e.g.,
199
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
200
+ * project-relative form before they reach consumers.
201
+ */
202
+ file: z.ZodString;
203
+ /** Line number (1-based), absent if location unavailable. */
204
+ line: z.ZodOptional<z.ZodNumber>;
205
+ /** Column number (1-based), absent if location unavailable. */
206
+ column: z.ZodOptional<z.ZodNumber>;
207
+ /** Human-readable description of the issue. */
208
+ message: z.ZodString;
209
+ severity: z.ZodEnum<{
210
+ error: "error";
211
+ warning: "warning";
212
+ }>;
213
+ kind: z.ZodLiteral<"svelte_prop_failed">;
214
+ }, z.core.$strict>;
215
+ export type SveltePropDiagnostic = z.infer<typeof SveltePropDiagnostic>;
216
+ /**
217
+ * Module was skipped during the analysis pass.
218
+ *
219
+ * Always `warning` severity — the rest of the analysis still runs and the
220
+ * module's absence in `modules` reflects the skip. Reasons:
221
+ *
222
+ * - `not_in_program` — the file wasn't in the `ts.Program` (race between
223
+ * session ingest and `query`, or virtual file missing for a `.svelte`)
224
+ * - `no_analyzer` — file extension didn't match any analyzer
225
+ * - `requires_program` — Svelte file reached the non-Svelte dispatcher (caller
226
+ * should use the session API instead of `analyzeModule` directly)
227
+ *
228
+ * Discovery-time file-read failures are a separate kind: `module_unreadable`.
229
+ */
230
+ export declare const ModuleSkippedDiagnostic: z.ZodObject<{
231
+ /** Reason the module was skipped. */
232
+ reason: z.ZodEnum<{
233
+ not_in_program: "not_in_program";
234
+ no_analyzer: "no_analyzer";
235
+ requires_program: "requires_program";
236
+ }>;
237
+ /**
238
+ * File path relative to project root (no leading slash, no `./` prefix).
239
+ *
240
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
241
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
242
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
243
+ * pipeline may write absolute or virtual paths (e.g.,
244
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
245
+ * project-relative form before they reach consumers.
246
+ */
247
+ file: z.ZodString;
248
+ /** Line number (1-based), absent if location unavailable. */
249
+ line: z.ZodOptional<z.ZodNumber>;
250
+ /** Column number (1-based), absent if location unavailable. */
251
+ column: z.ZodOptional<z.ZodNumber>;
252
+ /** Human-readable description of the issue. */
253
+ message: z.ZodString;
254
+ severity: z.ZodEnum<{
255
+ error: "error";
256
+ warning: "warning";
257
+ }>;
258
+ kind: z.ZodLiteral<"module_skipped">;
259
+ }, z.core.$strict>;
260
+ export type ModuleSkippedDiagnostic = z.infer<typeof ModuleSkippedDiagnostic>;
261
+ /**
262
+ * File discovered via package.json `exports` exists but couldn't be read.
263
+ *
264
+ * Always `error` severity — discovery-time, emitted by `discoverFromExports`
265
+ * when `readFile` fails (permission denied, FS error). Distinct from
266
+ * `module_skipped` so severity is a stable per-kind property and downstream
267
+ * consumers can route discovery failures separately from analysis-pass skips.
268
+ */
269
+ export declare const ModuleUnreadableDiagnostic: z.ZodObject<{
270
+ /**
271
+ * File path relative to project root (no leading slash, no `./` prefix).
272
+ *
273
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
274
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
275
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
276
+ * pipeline may write absolute or virtual paths (e.g.,
277
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
278
+ * project-relative form before they reach consumers.
279
+ */
280
+ file: z.ZodString;
281
+ /** Line number (1-based), absent if location unavailable. */
282
+ line: z.ZodOptional<z.ZodNumber>;
283
+ /** Column number (1-based), absent if location unavailable. */
284
+ column: z.ZodOptional<z.ZodNumber>;
285
+ /** Human-readable description of the issue. */
286
+ message: z.ZodString;
287
+ severity: z.ZodEnum<{
288
+ error: "error";
289
+ warning: "warning";
290
+ }>;
291
+ kind: z.ZodLiteral<"module_unreadable">;
292
+ }, z.core.$strict>;
293
+ export type ModuleUnreadableDiagnostic = z.infer<typeof ModuleUnreadableDiagnostic>;
294
+ /**
295
+ * Import parsing failed during dependency resolution.
296
+ */
297
+ export declare const ImportParseDiagnostic: z.ZodObject<{
298
+ /**
299
+ * File path relative to project root (no leading slash, no `./` prefix).
300
+ *
301
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
302
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
303
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
304
+ * pipeline may write absolute or virtual paths (e.g.,
305
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
306
+ * project-relative form before they reach consumers.
307
+ */
308
+ file: z.ZodString;
309
+ /** Line number (1-based), absent if location unavailable. */
310
+ line: z.ZodOptional<z.ZodNumber>;
311
+ /** Column number (1-based), absent if location unavailable. */
312
+ column: z.ZodOptional<z.ZodNumber>;
313
+ /** Human-readable description of the issue. */
314
+ message: z.ZodString;
315
+ severity: z.ZodEnum<{
316
+ error: "error";
317
+ warning: "warning";
318
+ }>;
319
+ kind: z.ZodLiteral<"import_parse_failed">;
320
+ }, z.core.$strict>;
321
+ export type ImportParseDiagnostic = z.infer<typeof ImportParseDiagnostic>;
322
+ /**
323
+ * Duplicate comment sources detected (e.g., both HTML and JSDoc `@module`,
324
+ * or both HTML `@component` and JSDoc for component `docComment`).
325
+ */
326
+ export declare const DuplicateCommentDiagnostic: z.ZodObject<{
327
+ /** Which comment type is duplicated. */
328
+ commentType: z.ZodEnum<{
329
+ module_comment: "module_comment";
330
+ doc_comment: "doc_comment";
331
+ }>;
332
+ /**
333
+ * File path relative to project root (no leading slash, no `./` prefix).
334
+ *
335
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
336
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
337
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
338
+ * pipeline may write absolute or virtual paths (e.g.,
339
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
340
+ * project-relative form before they reach consumers.
341
+ */
342
+ file: z.ZodString;
343
+ /** Line number (1-based), absent if location unavailable. */
344
+ line: z.ZodOptional<z.ZodNumber>;
345
+ /** Column number (1-based), absent if location unavailable. */
346
+ column: z.ZodOptional<z.ZodNumber>;
347
+ /** Human-readable description of the issue. */
348
+ message: z.ZodString;
349
+ severity: z.ZodEnum<{
350
+ error: "error";
351
+ warning: "warning";
352
+ }>;
353
+ kind: z.ZodLiteral<"duplicate_comment">;
354
+ }, z.core.$strict>;
355
+ export type DuplicateCommentDiagnostic = z.infer<typeof DuplicateCommentDiagnostic>;
356
+ /**
357
+ * Symbol-scope JSDoc tag (`@example`, `@deprecated`, `@since`, `@see`,
358
+ * `@throws`, `@mutates`, `@default`, `@nodocs`) found on a non-primary overload
359
+ * signature.
360
+ *
361
+ * Symbol-scope tags describe the function as a whole, not individual
362
+ * signatures. The primary signature's JSDoc feeds the parent declaration's
363
+ * symbol-level extraction; tags on non-primary overload signatures are
364
+ * silently dropped from output. This diagnostic surfaces them so authors
365
+ * can move them to the primary signature.
366
+ *
367
+ * `@default` and `@nodocs` are included here even though overloads never
368
+ * carry a `defaultValue` or per-overload exclusion: their presence on a
369
+ * non-primary signature is always a misplacement.
370
+ */
371
+ export declare const MisplacedTagDiagnostic: z.ZodObject<{
372
+ /** The tag name without the `@` prefix (e.g., `'example'`, `'deprecated'`). */
373
+ tagName: z.ZodEnum<{
374
+ default: "default";
375
+ throws: "throws";
376
+ since: "since";
377
+ mutates: "mutates";
378
+ deprecated: "deprecated";
379
+ example: "example";
380
+ see: "see";
381
+ nodocs: "nodocs";
382
+ }>;
383
+ /** Name of the function or method whose overload carries the misplaced tag. */
384
+ functionName: z.ZodString;
385
+ /**
386
+ * File path relative to project root (no leading slash, no `./` prefix).
387
+ *
388
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
389
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
390
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
391
+ * pipeline may write absolute or virtual paths (e.g.,
392
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
393
+ * project-relative form before they reach consumers.
394
+ */
395
+ file: z.ZodString;
396
+ /** Line number (1-based), absent if location unavailable. */
397
+ line: z.ZodOptional<z.ZodNumber>;
398
+ /** Column number (1-based), absent if location unavailable. */
399
+ column: z.ZodOptional<z.ZodNumber>;
400
+ /** Human-readable description of the issue. */
401
+ message: z.ZodString;
402
+ severity: z.ZodEnum<{
403
+ error: "error";
404
+ warning: "warning";
405
+ }>;
406
+ kind: z.ZodLiteral<"misplaced_tag">;
407
+ }, z.core.$strict>;
408
+ export type MisplacedTagDiagnostic = z.infer<typeof MisplacedTagDiagnostic>;
409
+ /**
410
+ * `@param` tag references a name that doesn't match any actual parameter.
411
+ *
412
+ * Usually a typo (`@param argz` for parameter `args`) or stale doc after a
413
+ * rename. The description is dropped; analysis continues.
414
+ */
415
+ export declare const UnknownParamDiagnostic: z.ZodObject<{
416
+ /** The `@param` key that didn't match a real parameter. */
417
+ paramName: z.ZodString;
418
+ /** Name of the function or method. */
419
+ functionName: z.ZodString;
420
+ /**
421
+ * File path relative to project root (no leading slash, no `./` prefix).
422
+ *
423
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
424
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
425
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
426
+ * pipeline may write absolute or virtual paths (e.g.,
427
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
428
+ * project-relative form before they reach consumers.
429
+ */
430
+ file: z.ZodString;
431
+ /** Line number (1-based), absent if location unavailable. */
432
+ line: z.ZodOptional<z.ZodNumber>;
433
+ /** Column number (1-based), absent if location unavailable. */
434
+ column: z.ZodOptional<z.ZodNumber>;
435
+ /** Human-readable description of the issue. */
436
+ message: z.ZodString;
437
+ severity: z.ZodEnum<{
438
+ error: "error";
439
+ warning: "warning";
440
+ }>;
441
+ kind: z.ZodLiteral<"unknown_param">;
442
+ }, z.core.$strict>;
443
+ export type UnknownParamDiagnostic = z.infer<typeof UnknownParamDiagnostic>;
444
+ /**
445
+ * A declaration `name` appears in more than one module.
446
+ *
447
+ * Library docs assume a flat namespace — two modules exporting the same name
448
+ * collide when consumers `import {name}`. Emitted at `warning` severity so
449
+ * the analysis result remains usable; consumers who want it fatal can promote
450
+ * via `onDuplicates: 'throw'` or by inspecting the diagnostic. The default
451
+ * slot (`name === 'default'`) is excluded — every module owns its own.
452
+ */
453
+ export declare const DuplicateDeclarationDiagnostic: z.ZodObject<{
454
+ /** The duplicated declaration name. */
455
+ declarationName: z.ZodString;
456
+ /** Module paths where the name was defined (>= 2). */
457
+ modules: z.ZodArray<z.ZodString>;
458
+ /**
459
+ * File path relative to project root (no leading slash, no `./` prefix).
460
+ *
461
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
462
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
463
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
464
+ * pipeline may write absolute or virtual paths (e.g.,
465
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
466
+ * project-relative form before they reach consumers.
467
+ */
468
+ file: z.ZodString;
469
+ /** Line number (1-based), absent if location unavailable. */
470
+ line: z.ZodOptional<z.ZodNumber>;
471
+ /** Column number (1-based), absent if location unavailable. */
472
+ column: z.ZodOptional<z.ZodNumber>;
473
+ /** Human-readable description of the issue. */
474
+ message: z.ZodString;
475
+ severity: z.ZodEnum<{
476
+ error: "error";
477
+ warning: "warning";
478
+ }>;
479
+ kind: z.ZodLiteral<"duplicate_declaration">;
480
+ }, z.core.$strict>;
481
+ export type DuplicateDeclarationDiagnostic = z.infer<typeof DuplicateDeclarationDiagnostic>;
482
+ /**
483
+ * Source map parsing failed for a Svelte virtual file.
484
+ *
485
+ * Analysis continues using virtual-file positions, so downstream `line`/`column`
486
+ * fields on other diagnostics may point into the svelte2tsx-generated TS rather
487
+ * than the original `.svelte` source. Rare; usually signals a malformed or
488
+ * incompatible svelte2tsx output.
489
+ *
490
+ * Emitted at ingest time by `transformSvelteSource` (in `svelte.ts`); flows
491
+ * through `setFile`/`setFiles` ingest diagnostics rather than the analysis
492
+ * pass.
493
+ */
494
+ export declare const SourceMapFailedDiagnostic: z.ZodObject<{
495
+ /**
496
+ * File path relative to project root (no leading slash, no `./` prefix).
497
+ *
498
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
499
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
500
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
501
+ * pipeline may write absolute or virtual paths (e.g.,
502
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
503
+ * project-relative form before they reach consumers.
504
+ */
505
+ file: z.ZodString;
506
+ /** Line number (1-based), absent if location unavailable. */
507
+ line: z.ZodOptional<z.ZodNumber>;
508
+ /** Column number (1-based), absent if location unavailable. */
509
+ column: z.ZodOptional<z.ZodNumber>;
510
+ /** Human-readable description of the issue. */
511
+ message: z.ZodString;
512
+ severity: z.ZodEnum<{
513
+ error: "error";
514
+ warning: "warning";
515
+ }>;
516
+ kind: z.ZodLiteral<"source_map_failed">;
517
+ }, z.core.$strict>;
518
+ export type SourceMapFailedDiagnostic = z.infer<typeof SourceMapFailedDiagnostic>;
519
+ /**
520
+ * svelte2tsx transform threw for a `.svelte` file.
521
+ *
522
+ * Unrecoverable at ingest — the file's owned-entry stays in the session
523
+ * (`virtual: undefined`, `unfilteredDeps: []`, `transformFailed: true`) so
524
+ * `query()` can synthesize a placeholder `ModuleJson` (`partial: true`,
525
+ * empty `declarations`). The originating error message lives in `message`;
526
+ * this diagnostic is the authoritative cause-of-failure signal.
527
+ */
528
+ export declare const TransformFailedDiagnostic: z.ZodObject<{
529
+ /**
530
+ * File path relative to project root (no leading slash, no `./` prefix).
531
+ *
532
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
533
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
534
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
535
+ * pipeline may write absolute or virtual paths (e.g.,
536
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
537
+ * project-relative form before they reach consumers.
538
+ */
539
+ file: z.ZodString;
540
+ /** Line number (1-based), absent if location unavailable. */
541
+ line: z.ZodOptional<z.ZodNumber>;
542
+ /** Column number (1-based), absent if location unavailable. */
543
+ column: z.ZodOptional<z.ZodNumber>;
544
+ /** Human-readable description of the issue. */
545
+ message: z.ZodString;
546
+ severity: z.ZodEnum<{
547
+ error: "error";
548
+ warning: "warning";
549
+ }>;
550
+ kind: z.ZodLiteral<"transform_failed">;
551
+ }, z.core.$strict>;
552
+ export type TransformFailedDiagnostic = z.infer<typeof TransformFailedDiagnostic>;
553
+ /**
554
+ * Import resolver threw while resolving a specifier.
555
+ *
556
+ * Distinguishes a buggy resolver from a legitimately unresolvable specifier:
557
+ * resolvers that return `null` for unknown specifiers stay silent (the normal
558
+ * "external package" case); resolvers that *throw* surface here so consumers
559
+ * can fix the resolver. Recoverable — the session treats the throw as `null`
560
+ * and continues, so analysis still runs but with a missing dependency edge.
561
+ *
562
+ * Emitted at ingest time by the session's resolve phase.
563
+ */
564
+ export declare const ResolverFailedDiagnostic: z.ZodObject<{
565
+ /** The import specifier the resolver failed on. */
566
+ specifier: z.ZodString;
567
+ /**
568
+ * File path relative to project root (no leading slash, no `./` prefix).
569
+ *
570
+ * Normalized at every public API boundary — `session.setFile`/`setFiles`
571
+ * (ingest-time), `session.query` (query-time, via `analyzeCore`), and the
572
+ * one-shot wrappers `analyze` / `analyzeFromFiles`. Producers inside the
573
+ * pipeline may write absolute or virtual paths (e.g.,
574
+ * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
575
+ * project-relative form before they reach consumers.
576
+ */
577
+ file: z.ZodString;
578
+ /** Line number (1-based), absent if location unavailable. */
579
+ line: z.ZodOptional<z.ZodNumber>;
580
+ /** Column number (1-based), absent if location unavailable. */
581
+ column: z.ZodOptional<z.ZodNumber>;
582
+ /** Human-readable description of the issue. */
583
+ message: z.ZodString;
584
+ severity: z.ZodEnum<{
585
+ error: "error";
586
+ warning: "warning";
587
+ }>;
588
+ kind: z.ZodLiteral<"resolver_failed">;
589
+ }, z.core.$strict>;
590
+ export type ResolverFailedDiagnostic = z.infer<typeof ResolverFailedDiagnostic>;
591
+ /**
592
+ * Discriminated union of all diagnostic variants.
593
+ */
594
+ export declare const Diagnostic: z.ZodDiscriminatedUnion<[
595
+ typeof TypeExtractionDiagnostic,
596
+ typeof SignatureAnalysisDiagnostic,
597
+ typeof ClassMemberDiagnostic,
598
+ typeof SveltePropDiagnostic,
599
+ typeof ModuleSkippedDiagnostic,
600
+ typeof ModuleUnreadableDiagnostic,
601
+ typeof ImportParseDiagnostic,
602
+ typeof DuplicateCommentDiagnostic,
603
+ typeof MisplacedTagDiagnostic,
604
+ typeof UnknownParamDiagnostic,
605
+ typeof SourceMapFailedDiagnostic,
606
+ typeof DuplicateDeclarationDiagnostic,
607
+ typeof TransformFailedDiagnostic,
608
+ typeof ResolverFailedDiagnostic
609
+ ], 'kind'>;
610
+ export type Diagnostic = z.infer<typeof Diagnostic>;
611
+ /**
612
+ * Check if any error-severity diagnostics were collected.
613
+ */
614
+ export declare const hasErrors: (diagnostics: Array<Diagnostic>) => boolean;
615
+ /**
616
+ * Check if any warning-severity diagnostics were collected.
617
+ */
618
+ export declare const hasWarnings: (diagnostics: Array<Diagnostic>) => boolean;
619
+ /**
620
+ * Get all error-severity diagnostics.
621
+ */
622
+ export declare const errorsOf: (diagnostics: Array<Diagnostic>) => Array<Diagnostic>;
623
+ /**
624
+ * Get all warning-severity diagnostics.
625
+ */
626
+ export declare const warningsOf: (diagnostics: Array<Diagnostic>) => Array<Diagnostic>;
627
+ /**
628
+ * Get diagnostics of a specific kind, narrowed to the matching variant.
629
+ */
630
+ export declare const byKind: <K extends DiagnosticKind>(diagnostics: Array<Diagnostic>, kind: K) => Array<Extract<Diagnostic, {
631
+ kind: K;
632
+ }>>;
633
+ /**
634
+ * Format a diagnostic for display.
635
+ *
636
+ * Assumes `diagnostic.file` is project-root-relative (the contract enforced
637
+ * by `analyze` / `analyzeFromFiles`). The displayed path is prefixed with `./`.
638
+ *
639
+ * @param diagnostic - the diagnostic to format
640
+ * @returns formatted string like `'./file.ts:10:5: error: message'`
641
+ *
642
+ * @example
643
+ * ```ts
644
+ * for (const d of errorsOf(diagnostics)) {
645
+ * console.error(formatDiagnostic(d));
646
+ * }
647
+ * ```
648
+ */
649
+ export declare const formatDiagnostic: (diagnostic: Diagnostic) => string;
650
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;EAA+B,CAAC;AAC/D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAezB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAiC5D;;GAEG;AACH,eAAO,MAAM,wBAAwB;IAGpC,2DAA2D;;IA1B3D;;;;;;;;;OASG;;IAEH,6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