svelte-docinfo 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121,7 +121,11 @@ export interface DeclarationAnalysis {
121
121
  * Produced by `analyzeExports` in `typescript-exports.ts`.
122
122
  */
123
123
  export interface ModuleExportsAnalysis {
124
- /** Module-level documentation comment. */
124
+ /**
125
+ * Module-level documentation comment. Always `undefined` for svelte2tsx
126
+ * virtual files — `analyzeSvelteModule` extracts Svelte module comments
127
+ * from the original source instead.
128
+ */
125
129
  moduleComment?: string;
126
130
  /** All exported declarations with `@nodocs` flags — consumer filters based on policy. */
127
131
  declarations: Array<DeclarationAnalysis>;
@@ -1 +1 @@
1
- {"version":3,"file":"declaration-build.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC;IAClD,UAAU,CAAC,EA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IACrC,0CAA0C;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,YAAY,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,2FAA2F;IAC3F,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACpD,6EAA6E;IAC7E,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC5D,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,gFAAgF;IAChF,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B"}
1
+ {"version":3,"file":"declaration-build.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CA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GAQG;AACH,MAAM,WAAW,mBAAmB;IACnC,0DAA0D;IAC1D,WAAW,EAAE,oBAAoB,CAAC;IAClC,2FAA2F;IAC3F,MAAM,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,YAAY,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,2FAA2F;IAC3F,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACpD,6EAA6E;IAC7E,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC5D,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,gFAAgF;IAChF,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B"}
package/dist/svelte.d.ts CHANGED
@@ -90,6 +90,16 @@ export declare const transformSvelteSource: (sourceFile: SourceFileInfo) => Tran
90
90
  * @returns the script tag content, or undefined if no matching script tag is found
91
91
  */
92
92
  export declare const extractScriptContent: (svelteSource: string) => string | undefined;
93
+ /**
94
+ * Extract the content of the module `<script>` tag from Svelte source.
95
+ *
96
+ * Counterpart of `extractScriptContent` with the same attribute test inverted:
97
+ * matches only module scripts (`<script module>`, `<script context="module">`),
98
+ * so the two partition a source's script tags consistently.
99
+ *
100
+ * @returns the module script tag content, or undefined if no module script is found
101
+ */
102
+ export declare const extractModuleScriptContent: (svelteSource: string) => string | undefined;
93
103
  /**
94
104
  * Extract `@module` comment from HTML comments in Svelte source.
95
105
  *
@@ -105,9 +115,11 @@ export declare const extractHtmlModuleComment: (svelteSource: string) => string
105
115
  * Extract module-level comment from Svelte script content.
106
116
  *
107
117
  * Parses the script content as TypeScript and delegates to `extractModuleComment`
108
- * for the shared `@module` tag detection logic.
118
+ * for the shared `@module` tag detection logic. Works on either script's
119
+ * content — instance `<script>` and `<script module>` (see
120
+ * `extractScriptContent`/`extractModuleScriptContent`).
109
121
  *
110
- * @param scriptContent - the content of the `<script>` tag
122
+ * @param scriptContent - the content of a `<script>` or `<script module>` tag
111
123
  * @returns the cleaned module comment text, or undefined if none found
112
124
  */
113
125
  export declare const extractSvelteModuleComment: (scriptContent: string) => string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAC,QAAQ,EAAsB,MAAM,2BAA2B,CAAC;AAGxE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EAA2C,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAC7F,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAAC,KAAK,cAAc,EAA0C,MAAM,aAAa,CAAC;AACzF,OAAO,EAAC,KAAK,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAC,KAAK,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAGjD,0FAA0F;AAC1F,KAAK,SAAS,GAAG,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,sGAAsG;IACt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AG,MAAM,GAAG,SAC9B,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,GAAI,cAAc,MAAM,KAAG,MAAM,GAAG,SACrC,CAAC;AAmBvC;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,cAAc,MAAM,KAAG,MAAM,GAAG,SA0BxE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,GAAI,eAAe,MAAM,KAAG,MAAM,GAAG,SAU3E,CAAC;AAyPF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,OAExD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,GACpC,aAAa,EAAE,CAAC,IAAI,EACpB,SAAS,EAAE,CAAC,WAAW,KACrB,KAAK,CAAC,kBAAkB,CAqB1B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,OAKxD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,GAAI,YAAY,KAAK,CAAC,kBAAkB,CAAC,KAAG,MAGtF,CAAC;AA8NF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,GAC/B,YAAY,cAAc,GAAG;IAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAC,EACjE,YAAY,MAAM,EAClB,SAAS,EAAE,CAAC,WAAW,EACvB,SAAS,mBAAmB,EAC5B,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,SAAS,EAAE,CAAC,OAAO,EACnB,aAAa,iBAAiB,KAC5B,cAAc,GAAG,SAiRnB,CAAC"}
package/dist/svelte.js CHANGED
@@ -204,19 +204,31 @@ const extractComponentSourceLine = (virtualSource, sourceMap) => {
204
204
  *
205
205
  * @returns the script tag content, or undefined if no matching script tag is found
206
206
  */
207
- export const extractScriptContent = (svelteSource) => {
208
- // Match <script> with any attributes, excluding module scripts:
209
- // - Svelte 5: <script module> or <script lang="ts" module>
210
- // - Svelte 4: <script context="module"> or <script lang="ts" context="module">
211
- // Uses global regex to skip module scripts and find the instance script
207
+ export const extractScriptContent = (svelteSource) => findScriptContent(svelteSource, false);
208
+ /**
209
+ * Extract the content of the module `<script>` tag from Svelte source.
210
+ *
211
+ * Counterpart of `extractScriptContent` with the same attribute test inverted:
212
+ * matches only module scripts (`<script module>`, `<script context="module">`),
213
+ * so the two partition a source's script tags consistently.
214
+ *
215
+ * @returns the module script tag content, or undefined if no module script is found
216
+ */
217
+ export const extractModuleScriptContent = (svelteSource) => findScriptContent(svelteSource, true);
218
+ /**
219
+ * Shared scan behind `extractScriptContent`/`extractModuleScriptContent`.
220
+ *
221
+ * A script tag is a module script when its attributes contain the word
222
+ * `module` — covers Svelte 5 `<script module>` (with any `lang`) and
223
+ * Svelte 4 `<script context="module">`.
224
+ */
225
+ const findScriptContent = (svelteSource, wantModule) => {
212
226
  const scriptRegex = /<script(\s+[^>]*)?>([^]*?)<\/script>/gi;
213
227
  let match;
214
228
  while ((match = scriptRegex.exec(svelteSource)) !== null) {
215
229
  const attrs = match[1] ?? '';
216
- // Skip module scripts (Svelte 5 `module` attribute or Svelte 4 `context="module"`)
217
- if (/\bmodule\b/.test(attrs))
218
- continue;
219
- return match[2];
230
+ if (/\bmodule\b/.test(attrs) === wantModule)
231
+ return match[2];
220
232
  }
221
233
  return undefined;
222
234
  };
@@ -259,9 +271,11 @@ export const extractHtmlModuleComment = (svelteSource) => {
259
271
  * Extract module-level comment from Svelte script content.
260
272
  *
261
273
  * Parses the script content as TypeScript and delegates to `extractModuleComment`
262
- * for the shared `@module` tag detection logic.
274
+ * for the shared `@module` tag detection logic. Works on either script's
275
+ * content — instance `<script>` and `<script module>` (see
276
+ * `extractScriptContent`/`extractModuleScriptContent`).
263
277
  *
264
- * @param scriptContent - the content of the `<script>` tag
278
+ * @param scriptContent - the content of a `<script>` or `<script module>` tag
265
279
  * @returns the cleaned module comment text, or undefined if none found
266
280
  */
267
281
  export const extractSvelteModuleComment = (scriptContent) => {
@@ -726,8 +740,13 @@ export const analyzeSvelteModule = (sourceFile, modulePath, checker, options, di
726
740
  });
727
741
  return undefined;
728
742
  }
729
- // 1. Use analyzeExports for full checker-backed analysis (same as .ts files)
730
- const { declarations: rawDeclarations, reExports, starExports, externalReExports, externalStarExports, moduleComment: scriptModuleComment, } = analyzeExports(virtualTsSource, checker, options, diagnostics);
743
+ // 1. Use analyzeExports for full checker-backed analysis (same as .ts files).
744
+ // Its `moduleComment` is undefined for virtuals — the `<script module>`
745
+ // comment is extracted from the original source in step 4, because svelte2tsx
746
+ // hoists instance-script imports (with their leading JSDoc) to the virtual's
747
+ // top level, where an instance `@module` comment would masquerade as a
748
+ // `<script module>` one.
749
+ const { declarations: rawDeclarations, reExports, starExports, externalReExports, externalStarExports, } = analyzeExports(virtualTsSource, checker, options, diagnostics);
731
750
  // 2. Filter internal svelte2tsx symbols and the default export (generated component class),
732
751
  // and reclassify exported snippets from 'function' to 'snippet'
733
752
  const moduleDeclarations = [];
@@ -903,11 +922,15 @@ export const analyzeSvelteModule = (sourceFile, modulePath, checker, options, di
903
922
  const instanceModuleComment = scriptContent
904
923
  ? extractSvelteModuleComment(scriptContent)
905
924
  : undefined;
925
+ const moduleScriptContent = extractModuleScriptContent(sourceFile.content);
926
+ const scriptModuleComment = moduleScriptContent
927
+ ? extractSvelteModuleComment(moduleScriptContent)
928
+ : undefined;
906
929
  const htmlModuleComment = extractHtmlModuleComment(sourceFile.content);
907
930
  const moduleComment = instanceModuleComment ?? scriptModuleComment ?? htmlModuleComment;
908
- // @nodocs has no module-level meaning — warn per misplaced comment. The
909
- // <script module> source is covered by analyzeExports on the virtual above.
931
+ // @nodocs has no module-level meaning — warn per misplaced comment
910
932
  warnModuleCommentNodocs(instanceModuleComment, modulePath, diagnostics);
933
+ warnModuleCommentNodocs(scriptModuleComment, modulePath, diagnostics);
911
934
  warnModuleCommentNodocs(htmlModuleComment, modulePath, diagnostics);
912
935
  // Warn if multiple @module sources exist
913
936
  const moduleCommentSources = [
@@ -40,7 +40,8 @@ export declare const analyzeTypescriptModule: (sourceFileInfo: SourceFileInfo &
40
40
  /**
41
41
  * Analyze all exports from a TypeScript source file.
42
42
  *
43
- * Extracts the module-level comment via `extractModuleComment`, star exports via
43
+ * Extracts the module-level comment via `extractModuleComment` (skipped for
44
+ * svelte2tsx virtual files — see the inline note), star exports via
44
45
  * `extractStarExports`, and all exported declarations with complete metadata.
45
46
  * Handles re-exports by:
46
47
  * - Same-name re-exports: tracked in `reExports` for `alsoExportedFrom` building
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-exports.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/typescript-exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EACX,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EAErB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACN,KAAK,cAAc,EAInB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,mBAAmB,EAIxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,KAAK,cAAc,EAAuB,MAAM,yBAAyB,CAAC;AAMlF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GACnC,gBAAgB,cAAc,GAAG;IAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAC,EACrE,cAAc,EAAE,CAAC,UAAU,EAC3B,YAAY,MAAM,EAClB,SAAS,EAAE,CAAC,WAAW,EACvB,SAAS,mBAAmB,EAC5B,aAAa,KAAK,CAAC,UAAU,CAAC,KAC5B,cAyBF,CAAC;AA+QF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,c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AC,CAAA;CAAC,EACrE,cAAc,EAAE,CAAC,UAAU,EAC3B,YAAY,MAAM,EAClB,SAAS,EAAE,CAAC,WAAW,EACvB,SAAS,mBAAmB,EAC5B,aAAa,KAAK,CAAC,UAAU,CAAC,KAC5B,cAyBF,CAAC;AA+QF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,cAAc,GAC1B,YAAY,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,CAAC,WAAW,EACvB,SAAS,mBAAmB,EAC5B,aAAa,KAAK,CAAC,UAAU,CAAC,KAC5B,qBAgVF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,GAC9B,QAAQ,EAAE,CAAC,MAAM,EACjB,YAAY,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,CAAC,WAAW,EACvB,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,gBAAgB,cAAc,KAC5B,mBA+CF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAI,YAAY,EAAE,CAAC,UAAU,KAAG,MAAM,GAAG,SAqCzE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GACnC,eAAe,MAAM,GAAG,SAAS,EACjC,MAAM,MAAM,EACZ,aAAa,KAAK,CAAC,UAAU,CAAC,KAC5B,IAUF,CAAC"}
@@ -266,7 +266,8 @@ const synthesizeCrossFileAlias = (publicName, aliasedSymbol, originalSource, ori
266
266
  /**
267
267
  * Analyze all exports from a TypeScript source file.
268
268
  *
269
- * Extracts the module-level comment via `extractModuleComment`, star exports via
269
+ * Extracts the module-level comment via `extractModuleComment` (skipped for
270
+ * svelte2tsx virtual files — see the inline note), star exports via
270
271
  * `extractStarExports`, and all exported declarations with complete metadata.
271
272
  * Handles re-exports by:
272
273
  * - Same-name re-exports: tracked in `reExports` for `alsoExportedFrom` building
@@ -290,13 +291,17 @@ export const analyzeExports = (sourceFile, checker, options, diagnostics) => {
290
291
  const reExports = [];
291
292
  const externalReExports = [];
292
293
  const isExternalFile = createIsExternalFile(options);
293
- // Extract module-level comment
294
- const moduleComment = extractModuleComment(sourceFile);
295
294
  // Extract star exports (export * from './module' / 'pkg')
296
295
  const { starExports, externalStarExports } = extractStarExports(sourceFile, checker, options);
297
296
  // Normalize virtual paths once (e.g., Foo.svelte.__svelte2tsx__.ts → Foo.svelte)
298
297
  // so re-export tracking matches real module paths
299
298
  const currentFileName = stripVirtualSuffix(sourceFile.fileName);
299
+ // Extract module-level comment — skipped for svelte2tsx virtuals, where
300
+ // hoisted instance-script comments would read as module comments;
301
+ // `analyzeSvelteModule` extracts the `<script module>` comment from the
302
+ // original source instead (and owns its `@nodocs` warning)
303
+ const isVirtual = currentFileName !== sourceFile.fileName;
304
+ const moduleComment = isVirtual ? undefined : extractModuleComment(sourceFile);
300
305
  warnModuleCommentNodocs(moduleComment, currentFileName, diagnostics);
301
306
  // 1-based line of a node in this file. Virtual coordinates for Svelte
302
307
  // `<script module>` sources — remapped in `analyzeSvelteModule`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-docinfo",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "static analysis for TypeScript and Svelte",
5
5
  "glyph": "📜",
6
6
  "logo": "logo.svg",