@fuzdev/fuz_ui 0.174.0 → 0.176.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Alert.svelte +2 -0
- package/dist/Alert.svelte.d.ts.map +1 -1
- package/dist/ApiModule.svelte +5 -6
- package/dist/ApiModule.svelte.d.ts.map +1 -1
- package/dist/DeclarationDetail.svelte +2 -1
- package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
- package/dist/Details.svelte +2 -0
- package/dist/Details.svelte.d.ts.map +1 -1
- package/dist/EcosystemLinks.svelte +3 -3
- package/dist/EcosystemLinks.svelte.d.ts +1 -1
- package/dist/EcosystemLinks.svelte.d.ts.map +1 -1
- package/dist/Themed.svelte +2 -0
- package/dist/Themed.svelte.d.ts.map +1 -1
- package/dist/analysis_context.d.ts +195 -0
- package/dist/analysis_context.d.ts.map +1 -0
- package/dist/analysis_context.js +134 -0
- package/dist/library_analysis.d.ts +112 -0
- package/dist/library_analysis.d.ts.map +1 -0
- package/dist/library_analysis.js +106 -0
- package/dist/library_gen.d.ts +73 -5
- package/dist/library_gen.d.ts.map +1 -1
- package/dist/library_gen.js +130 -68
- package/dist/library_gen_helpers.d.ts +81 -72
- package/dist/library_gen_helpers.d.ts.map +1 -1
- package/dist/library_gen_helpers.js +115 -156
- package/dist/library_gen_output.d.ts +34 -0
- package/dist/library_gen_output.d.ts.map +1 -0
- package/dist/library_gen_output.js +40 -0
- package/dist/mdz.d.ts +3 -0
- package/dist/mdz.d.ts.map +1 -1
- package/dist/mdz.js +12 -3
- package/dist/module_helpers.d.ts +246 -24
- package/dist/module_helpers.d.ts.map +1 -1
- package/dist/module_helpers.js +250 -42
- package/dist/svelte_helpers.d.ts +65 -10
- package/dist/svelte_helpers.d.ts.map +1 -1
- package/dist/svelte_helpers.js +171 -49
- package/dist/ts_helpers.d.ts +132 -61
- package/dist/ts_helpers.d.ts.map +1 -1
- package/dist/ts_helpers.js +423 -282
- package/dist/tsdoc_helpers.d.ts +11 -0
- package/dist/tsdoc_helpers.d.ts.map +1 -1
- package/dist/tsdoc_helpers.js +22 -47
- package/dist/tsdoc_mdz.d.ts +36 -0
- package/dist/tsdoc_mdz.d.ts.map +1 -0
- package/dist/tsdoc_mdz.js +56 -0
- package/dist/vite_plugin_library_well_known.js +5 -5
- package/package.json +12 -7
- package/src/lib/analysis_context.ts +250 -0
- package/src/lib/library_analysis.ts +168 -0
- package/src/lib/library_gen.ts +199 -83
- package/src/lib/library_gen_helpers.ts +148 -215
- package/src/lib/library_gen_output.ts +63 -0
- package/src/lib/mdz.ts +13 -4
- package/src/lib/module_helpers.ts +392 -47
- package/src/lib/svelte_helpers.ts +291 -55
- package/src/lib/ts_helpers.ts +538 -338
- package/src/lib/tsdoc_helpers.ts +24 -49
- package/src/lib/tsdoc_mdz.ts +62 -0
- package/src/lib/vite_plugin_library_well_known.ts +5 -5
package/src/lib/tsdoc_helpers.ts
CHANGED
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
* - TS API strips URL protocols from `@see` tag text; we use `getText()` to preserve original format including `{@link}` syntax
|
|
36
36
|
*
|
|
37
37
|
* All functions are prefixed with `tsdoc_` for clarity.
|
|
38
|
+
*
|
|
39
|
+
* @module
|
|
38
40
|
*/
|
|
39
41
|
|
|
40
42
|
import ts from 'typescript';
|
|
@@ -66,53 +68,6 @@ export interface TsdocParsedComment {
|
|
|
66
68
|
nodocs?: boolean;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
/**
|
|
70
|
-
* Convert TSDoc link syntax to mdz-compatible format.
|
|
71
|
-
*
|
|
72
|
-
* Conversions:
|
|
73
|
-
* - `{@link url|text}` → `[text](url)` (markdown link)
|
|
74
|
-
* - `{@link https://...}` → `https://...` (bare URL)
|
|
75
|
-
* - `{@link identifier}` → `` `identifier` `` (backticks)
|
|
76
|
-
* - `@see` variants follow same rules
|
|
77
|
-
*
|
|
78
|
-
* @param content The @see tag content to convert
|
|
79
|
-
*/
|
|
80
|
-
const tsdoc_convert_link_to_mdz = (content: string): string => {
|
|
81
|
-
// Check for {@link ...} or {@see ...} syntax
|
|
82
|
-
const link_match = /^\{@(?:link|see)\s+([^}]+)\}$/.exec(content.trim());
|
|
83
|
-
if (link_match) {
|
|
84
|
-
const inner = link_match[1]!.trim();
|
|
85
|
-
|
|
86
|
-
// Check for pipe separator (custom display text)
|
|
87
|
-
const pipe_index = inner.indexOf('|');
|
|
88
|
-
if (pipe_index !== -1) {
|
|
89
|
-
const reference = inner.slice(0, pipe_index).trim();
|
|
90
|
-
const display_text = inner.slice(pipe_index + 1).trim();
|
|
91
|
-
// Convert to markdown link: [text](url)
|
|
92
|
-
return `[${display_text}](${reference})`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// No pipe - check if it's a URL or declaration
|
|
96
|
-
if (inner.startsWith('https://') || inner.startsWith('http://')) {
|
|
97
|
-
// Bare URL - return as-is
|
|
98
|
-
return inner;
|
|
99
|
-
} else {
|
|
100
|
-
// Declaration or module - wrap in backticks
|
|
101
|
-
return `\`${inner}\``;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// No {@link} or {@see} syntax - check if it's a bare URL or declaration
|
|
106
|
-
const trimmed = content.trim();
|
|
107
|
-
if (trimmed.startsWith('https://') || trimmed.startsWith('http://')) {
|
|
108
|
-
// Already a bare URL - return as-is
|
|
109
|
-
return trimmed;
|
|
110
|
-
} else {
|
|
111
|
-
// Declaration or module - wrap in backticks
|
|
112
|
-
return `\`${trimmed}\``;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
71
|
/**
|
|
117
72
|
* Parse JSDoc comment from a TypeScript node.
|
|
118
73
|
*
|
|
@@ -193,11 +148,11 @@ export const tsdoc_parse = (
|
|
|
193
148
|
const see_content = full_tag_text
|
|
194
149
|
.replace(/^@see\s+/, '') // remove @see prefix
|
|
195
150
|
.replace(/\n\s*\*\s*/g, ' ') // remove JSDoc line continuations
|
|
151
|
+
.replace(/\s*\*\s*$/, '') // remove trailing asterisk artifacts
|
|
196
152
|
.trim();
|
|
197
153
|
|
|
198
154
|
if (see_content) {
|
|
199
|
-
|
|
200
|
-
see_also.push(tsdoc_convert_link_to_mdz(see_content));
|
|
155
|
+
see_also.push(see_content);
|
|
201
156
|
}
|
|
202
157
|
} else if (tag_name === 'since' && tag_text) {
|
|
203
158
|
since = tag_text.trim();
|
|
@@ -257,3 +212,23 @@ export const tsdoc_apply_to_declaration = (
|
|
|
257
212
|
declaration.since = tsdoc.since;
|
|
258
213
|
}
|
|
259
214
|
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Clean raw JSDoc comment text by removing comment markers and leading asterisks.
|
|
218
|
+
*
|
|
219
|
+
* Transforms `/** ... *\/` style comments into clean text.
|
|
220
|
+
*
|
|
221
|
+
* @param comment_text The raw comment text including `/**` and `*\/` markers
|
|
222
|
+
* @returns Cleaned comment text, or undefined if empty after cleaning
|
|
223
|
+
*/
|
|
224
|
+
export const tsdoc_clean_comment = (comment_text: string): string | undefined => {
|
|
225
|
+
const text = comment_text
|
|
226
|
+
.replace(/^\/\*\*/, '')
|
|
227
|
+
.replace(/\*\/$/, '')
|
|
228
|
+
.split('\n')
|
|
229
|
+
.map((line) => line.replace(/^\s*\*\s?/, ''))
|
|
230
|
+
.join('\n')
|
|
231
|
+
.trim();
|
|
232
|
+
|
|
233
|
+
return text || undefined;
|
|
234
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge between TSDoc format and mdz for rendering.
|
|
3
|
+
*
|
|
4
|
+
* This module converts raw TSDoc syntax (from the analysis library) to mdz format
|
|
5
|
+
* (Fuz's documentation rendering dialect). It lives in fuz_ui, not the extracted
|
|
6
|
+
* analysis library, to keep that library format-agnostic.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {mdz_is_url} from './mdz.js';
|
|
12
|
+
|
|
13
|
+
/** Format a reference as mdz: URLs pass through, identifiers get backticks. */
|
|
14
|
+
const format_reference = (ref: string): string => (mdz_is_url(ref) ? ref : `\`${ref}\``);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Convert raw TSDoc `@see` content to mdz format for rendering.
|
|
18
|
+
*
|
|
19
|
+
* Handles TSDoc link syntax:
|
|
20
|
+
* - `{@link url|text}` → `[text](url)` (markdown link)
|
|
21
|
+
* - `{@link https://...}` → `https://...` (bare URL, auto-linked by mdz)
|
|
22
|
+
* - `{@link identifier}` → `` `identifier` `` (code formatting)
|
|
23
|
+
* - Bare URLs → returned as-is
|
|
24
|
+
* - Bare identifiers → wrapped in backticks
|
|
25
|
+
*
|
|
26
|
+
* @param content Raw `@see` tag content in TSDoc format
|
|
27
|
+
* @returns mdz-formatted string ready for `<Mdz>` component
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* tsdoc_see_to_mdz('{@link https://fuz.dev|API Docs}')
|
|
32
|
+
* // → '[API Docs](https://fuz.dev)'
|
|
33
|
+
*
|
|
34
|
+
* tsdoc_see_to_mdz('{@link SomeType}')
|
|
35
|
+
* // → '`SomeType`'
|
|
36
|
+
*
|
|
37
|
+
* tsdoc_see_to_mdz('https://example.com')
|
|
38
|
+
* // → 'https://example.com'
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export const tsdoc_see_to_mdz = (content: string): string => {
|
|
42
|
+
const trimmed = content.trim();
|
|
43
|
+
if (!trimmed) return '';
|
|
44
|
+
|
|
45
|
+
// Check for {@link ...} or {@see ...} syntax
|
|
46
|
+
const link_match = /^\{@(?:link|see)\s+([^}]+)\}$/.exec(trimmed);
|
|
47
|
+
if (link_match) {
|
|
48
|
+
const inner = link_match[1]!.trim();
|
|
49
|
+
|
|
50
|
+
// Check for pipe separator (custom display text)
|
|
51
|
+
const pipe_index = inner.indexOf('|');
|
|
52
|
+
if (pipe_index !== -1) {
|
|
53
|
+
const reference = inner.slice(0, pipe_index).trim();
|
|
54
|
+
const display_text = inner.slice(pipe_index + 1).trim();
|
|
55
|
+
return `[${display_text}](${reference})`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return format_reference(inner);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return format_reference(trimmed);
|
|
62
|
+
};
|
|
@@ -75,22 +75,22 @@ export const vite_plugin_library_well_known = (
|
|
|
75
75
|
let json_content: string;
|
|
76
76
|
try {
|
|
77
77
|
json_content = await readFile(resolved_path, 'utf-8');
|
|
78
|
-
} catch (
|
|
78
|
+
} catch (error) {
|
|
79
79
|
throw new Error(
|
|
80
80
|
`vite_plugin_library_well_known: failed to read library.json from "${library_path}"\n` +
|
|
81
81
|
`Resolved to: ${resolved_path}\n` +
|
|
82
82
|
`Make sure you've run \`gro gen\` to generate the library metadata.\n` +
|
|
83
|
-
`Error: ${
|
|
83
|
+
`Error: ${error}`,
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
let raw: unknown;
|
|
88
88
|
try {
|
|
89
89
|
raw = JSON.parse(json_content);
|
|
90
|
-
} catch (
|
|
90
|
+
} catch (error) {
|
|
91
91
|
throw new Error(
|
|
92
92
|
`vite_plugin_library_well_known: failed to parse library.json from "${library_path}"\n` +
|
|
93
|
-
`Error: ${
|
|
93
|
+
`Error: ${error}`,
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -146,7 +146,7 @@ export const vite_plugin_library_well_known = (
|
|
|
146
146
|
try {
|
|
147
147
|
if (!ready_promise) throw new Error('not initialized');
|
|
148
148
|
await ready_promise;
|
|
149
|
-
} catch {
|
|
149
|
+
} catch (_error) {
|
|
150
150
|
res.statusCode = 503;
|
|
151
151
|
respond_json(res, JSON.stringify({error: 'Library not ready'}));
|
|
152
152
|
return;
|