@fuzdev/fuz_ui 0.198.0 → 0.199.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 (108) hide show
  1. package/README.md +5 -3
  2. package/dist/ApiIndex.svelte +2 -2
  3. package/dist/ApiModule.svelte +1 -1
  4. package/dist/LibraryDetail.svelte +14 -16
  5. package/dist/LibraryDetail.svelte.d.ts.map +1 -1
  6. package/dist/LibrarySummary.svelte +12 -12
  7. package/dist/Mdz.svelte +2 -2
  8. package/dist/MdzNodeView.svelte +8 -6
  9. package/dist/MdzNodeView.svelte.d.ts.map +1 -1
  10. package/dist/MdzRoot.svelte +30 -0
  11. package/dist/MdzRoot.svelte.d.ts +12 -0
  12. package/dist/MdzRoot.svelte.d.ts.map +1 -0
  13. package/dist/MdzStream.svelte +32 -0
  14. package/dist/MdzStream.svelte.d.ts +12 -0
  15. package/dist/MdzStream.svelte.d.ts.map +1 -0
  16. package/dist/MdzStreamNodeView.svelte +106 -0
  17. package/dist/MdzStreamNodeView.svelte.d.ts +9 -0
  18. package/dist/MdzStreamNodeView.svelte.d.ts.map +1 -0
  19. package/dist/ProjectLinks.svelte +2 -0
  20. package/dist/ProjectLinks.svelte.d.ts.map +1 -1
  21. package/dist/declaration.svelte.js +2 -2
  22. package/dist/library.svelte.d.ts +9 -70
  23. package/dist/library.svelte.d.ts.map +1 -1
  24. package/dist/library.svelte.js +24 -18
  25. package/dist/library_helpers.d.ts +3 -3
  26. package/dist/library_helpers.js +3 -3
  27. package/dist/logos.d.ts +7 -0
  28. package/dist/logos.d.ts.map +1 -1
  29. package/dist/logos.js +9 -0
  30. package/dist/mdz.d.ts.map +1 -1
  31. package/dist/mdz.js +37 -29
  32. package/dist/mdz_components.d.ts +37 -23
  33. package/dist/mdz_components.d.ts.map +1 -1
  34. package/dist/mdz_components.js +16 -4
  35. package/dist/mdz_helpers.d.ts +46 -14
  36. package/dist/mdz_helpers.d.ts.map +1 -1
  37. package/dist/mdz_helpers.js +189 -56
  38. package/dist/mdz_lexer.d.ts.map +1 -1
  39. package/dist/mdz_lexer.js +18 -22
  40. package/dist/mdz_opcodes.d.ts +174 -0
  41. package/dist/mdz_opcodes.d.ts.map +1 -0
  42. package/dist/mdz_opcodes.js +14 -0
  43. package/dist/mdz_opcodes_to_nodes.d.ts +20 -0
  44. package/dist/mdz_opcodes_to_nodes.d.ts.map +1 -0
  45. package/dist/mdz_opcodes_to_nodes.js +332 -0
  46. package/dist/mdz_stream_parser.d.ts +80 -0
  47. package/dist/mdz_stream_parser.d.ts.map +1 -0
  48. package/dist/mdz_stream_parser.js +354 -0
  49. package/dist/mdz_stream_parser_block.d.ts +76 -0
  50. package/dist/mdz_stream_parser_block.d.ts.map +1 -0
  51. package/dist/mdz_stream_parser_block.js +458 -0
  52. package/dist/mdz_stream_parser_inline.d.ts +52 -0
  53. package/dist/mdz_stream_parser_inline.d.ts.map +1 -0
  54. package/dist/mdz_stream_parser_inline.js +378 -0
  55. package/dist/mdz_stream_parser_link.d.ts +22 -0
  56. package/dist/mdz_stream_parser_link.d.ts.map +1 -0
  57. package/dist/mdz_stream_parser_link.js +215 -0
  58. package/dist/mdz_stream_parser_state.d.ts +187 -0
  59. package/dist/mdz_stream_parser_state.d.ts.map +1 -0
  60. package/dist/mdz_stream_parser_state.js +398 -0
  61. package/dist/mdz_stream_parser_text.d.ts +14 -0
  62. package/dist/mdz_stream_parser_text.d.ts.map +1 -0
  63. package/dist/mdz_stream_parser_text.js +50 -0
  64. package/dist/mdz_stream_parser_url.d.ts +60 -0
  65. package/dist/mdz_stream_parser_url.d.ts.map +1 -0
  66. package/dist/mdz_stream_parser_url.js +307 -0
  67. package/dist/mdz_stream_state.svelte.d.ts +44 -0
  68. package/dist/mdz_stream_state.svelte.d.ts.map +1 -0
  69. package/dist/mdz_stream_state.svelte.js +357 -0
  70. package/dist/mdz_token_parser.d.ts.map +1 -1
  71. package/dist/mdz_token_parser.js +8 -39
  72. package/dist/module.svelte.js +1 -1
  73. package/dist/site.svelte.d.ts +13 -0
  74. package/dist/site.svelte.d.ts.map +1 -1
  75. package/dist/site.svelte.js +8 -2
  76. package/dist/tsdoc_mdz.d.ts +2 -2
  77. package/dist/tsdoc_mdz.js +2 -2
  78. package/dist/vite_plugin_pkg_json.d.ts +63 -0
  79. package/dist/vite_plugin_pkg_json.d.ts.map +1 -0
  80. package/dist/vite_plugin_pkg_json.js +126 -0
  81. package/package.json +6 -5
  82. package/src/lib/declaration.svelte.ts +2 -2
  83. package/src/lib/library.svelte.ts +37 -20
  84. package/src/lib/library_helpers.ts +3 -3
  85. package/src/lib/logos.ts +10 -0
  86. package/src/lib/mdz.ts +38 -29
  87. package/src/lib/mdz_components.ts +40 -19
  88. package/src/lib/mdz_helpers.ts +199 -56
  89. package/src/lib/mdz_lexer.ts +18 -20
  90. package/src/lib/mdz_opcodes.ts +205 -0
  91. package/src/lib/mdz_opcodes_to_nodes.ts +375 -0
  92. package/src/lib/mdz_stream_parser.ts +415 -0
  93. package/src/lib/mdz_stream_parser_block.ts +532 -0
  94. package/src/lib/mdz_stream_parser_inline.ts +414 -0
  95. package/src/lib/mdz_stream_parser_link.ts +271 -0
  96. package/src/lib/mdz_stream_parser_state.ts +539 -0
  97. package/src/lib/mdz_stream_parser_text.ts +77 -0
  98. package/src/lib/mdz_stream_parser_url.ts +365 -0
  99. package/src/lib/mdz_stream_state.svelte.ts +387 -0
  100. package/src/lib/mdz_token_parser.ts +13 -40
  101. package/src/lib/module.svelte.ts +1 -1
  102. package/src/lib/site.svelte.ts +17 -2
  103. package/src/lib/tsdoc_mdz.ts +2 -2
  104. package/src/lib/vite_plugin_pkg_json.ts +142 -0
  105. package/dist/package_helpers.d.ts +0 -150
  106. package/dist/package_helpers.d.ts.map +0 -1
  107. package/dist/package_helpers.js +0 -179
  108. package/src/lib/package_helpers.ts +0 -186
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Auto-URL and auto-path handlers (text-first scanning) for the streaming
3
+ * mdz parser. Operates in two phases:
4
+ *
5
+ * 1. Speculative prefix matching: chars stream as visible text while we
6
+ * verify a `https://` / `http://` prefix.
7
+ * 2. Confirmed mode: chars stream as text and on terminator a `wrap`
8
+ * opcode retroactively wraps the text node in a Link.
9
+ *
10
+ * Paths (`/...`, `./...`, `../...`) skip phase 1 — their prefix is validated
11
+ * by hold (require enough lookahead).
12
+ *
13
+ * @module
14
+ */
15
+ import { type MdzStreamParserState, type TryResult } from './mdz_stream_parser_state.js';
16
+ /**
17
+ * Forced-mode URL detection: the full prefix must be in the buffer.
18
+ * Used at EOF when speculative prefix matching isn't needed.
19
+ * Scheme match is case-insensitive (RFC 3986).
20
+ */
21
+ export declare const try_auto_url_forced: (state: MdzStreamParserState) => TryResult;
22
+ export declare const try_auto_path_absolute: (state: MdzStreamParserState, forced?: boolean) => TryResult;
23
+ export declare const try_auto_path_relative: (state: MdzStreamParserState, forced?: boolean) => TryResult;
24
+ /**
25
+ * Start confirmed text-first mode for paths. Prefix already validated by hold.
26
+ * Flushes prior text, resets active_text_id, sets pending_url with confirmed=true.
27
+ */
28
+ export declare const start_pending_url: (state: MdzStreamParserState, link_type: "external" | "internal") => void;
29
+ /**
30
+ * Start speculative text-first mode for URL prefixes.
31
+ * Chars stream as visible text while we verify `https://` or `http://`.
32
+ * Cancels if prefix doesn't match (text stays as plain text).
33
+ */
34
+ export declare const start_speculative_url: (state: MdzStreamParserState) => void;
35
+ /**
36
+ * Speculative URL prefix matching. Checks each char against viable prefixes,
37
+ * streaming as text. Confirms on full match, cancels on mismatch.
38
+ *
39
+ * Scheme letters (`h`, `t`, `p`, `s`) are matched case-insensitively (RFC 3986);
40
+ * the `:` and `//` portion remains literal. Original casing is preserved in
41
+ * the emitted reference.
42
+ */
43
+ export declare const process_url_prefix: (state: MdzStreamParserState) => void;
44
+ /**
45
+ * Process URL/path chars in text-first mode. Scans path chars,
46
+ * accumulates as visible text. Terminates on space/newline/non-path-char
47
+ * and emits a `wrap` opcode.
48
+ */
49
+ export declare const process_url_content: (state: MdzStreamParserState, forced: boolean) => void;
50
+ /**
51
+ * Complete a pending URL: compute reference with trimmed punctuation,
52
+ * emit a `wrap` opcode to retroactively wrap the text node in a Link.
53
+ */
54
+ export declare const complete_pending_url: (state: MdzStreamParserState) => void;
55
+ /**
56
+ * Forced-mode auto-link: scan the full URL/path inline (no streaming needed
57
+ * at EOF). Used when forced=true — the entire URL must be in the buffer.
58
+ */
59
+ export declare const scan_auto_link_forced: (state: MdzStreamParserState, link_type: "external" | "internal") => TryResult;
60
+ //# sourceMappingURL=mdz_stream_parser_url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mdz_stream_parser_url.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_stream_parser_url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAcH,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,SAAS,EAOd,MAAM,8BAA8B,CAAC;AAKtC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,oBAAoB,KAAG,SAYjE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,OAAO,oBAAoB,EAAE,gBAAc,KAAG,SAqBpF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,OAAO,oBAAoB,EAAE,gBAAc,KAAG,SAyCpF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC7B,OAAO,oBAAoB,EAC3B,WAAW,UAAU,GAAG,UAAU,KAChC,IAaF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,oBAAoB,KAAG,IAYnE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,oBAAoB,KAAG,IAwChE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,oBAAoB,EAAE,QAAQ,OAAO,KAAG,IAoClF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,oBAAoB,KAAG,IAgDlE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GACjC,OAAO,oBAAoB,EAC3B,WAAW,UAAU,GAAG,UAAU,KAChC,SA2CF,CAAC"}
@@ -0,0 +1,307 @@
1
+ /**
2
+ * Auto-URL and auto-path handlers (text-first scanning) for the streaming
3
+ * mdz parser. Operates in two phases:
4
+ *
5
+ * 1. Speculative prefix matching: chars stream as visible text while we
6
+ * verify a `https://` / `http://` prefix.
7
+ * 2. Confirmed mode: chars stream as text and on terminator a `wrap`
8
+ * opcode retroactively wraps the text node in a Link.
9
+ *
10
+ * Paths (`/...`, `./...`, `../...`) skip phase 1 — their prefix is validated
11
+ * by hold (require enough lookahead).
12
+ *
13
+ * @module
14
+ */
15
+ import { NEWLINE, SPACE, TAB, PERIOD, SLASH, ascii_to_lower, is_valid_path_char, is_word_char, match_url_prefix_case_insensitive, trim_trailing_punctuation, } from './mdz_helpers.js';
16
+ import { accumulate_text, alloc_id, emit, ensure_paragraph, flush_text, offset, } from './mdz_stream_parser_state.js';
17
+ const HTTPS_PREFIX = 'https://';
18
+ const HTTP_PREFIX = 'http://';
19
+ /**
20
+ * Forced-mode URL detection: the full prefix must be in the buffer.
21
+ * Used at EOF when speculative prefix matching isn't needed.
22
+ * Scheme match is case-insensitive (RFC 3986).
23
+ */
24
+ export const try_auto_url_forced = (state) => {
25
+ if (state.prev_char !== -1 && is_word_char(state.prev_char))
26
+ return 'not_match';
27
+ const prefix_len = match_url_prefix_case_insensitive(state.buffer, state.pos);
28
+ if (prefix_len === 0)
29
+ return 'not_match';
30
+ // must have content after protocol
31
+ if (state.pos + prefix_len >= state.buffer.length)
32
+ return 'not_match';
33
+ const after = state.buffer.charCodeAt(state.pos + prefix_len);
34
+ if (after === SPACE || after === NEWLINE)
35
+ return 'not_match';
36
+ return scan_auto_link_forced(state, 'external');
37
+ };
38
+ export const try_auto_path_absolute = (state, forced = false) => {
39
+ // must be at word boundary (preceded by space/newline/start)
40
+ if (state.prev_char !== -1 &&
41
+ state.prev_char !== SPACE &&
42
+ state.prev_char !== NEWLINE &&
43
+ state.prev_char !== TAB) {
44
+ return 'not_match';
45
+ }
46
+ // reject // and /space
47
+ if (state.pos + 1 >= state.buffer.length)
48
+ return forced ? 'not_match' : 'need_more';
49
+ const next = state.buffer.charCodeAt(state.pos + 1);
50
+ if (next === SLASH || next === SPACE || next === NEWLINE || next === TAB) {
51
+ return 'not_match';
52
+ }
53
+ if (forced)
54
+ return scan_auto_link_forced(state, 'internal');
55
+ start_pending_url(state, 'internal');
56
+ return 'consumed';
57
+ };
58
+ export const try_auto_path_relative = (state, forced = false) => {
59
+ if (state.prev_char !== -1 &&
60
+ state.prev_char !== SPACE &&
61
+ state.prev_char !== NEWLINE &&
62
+ state.prev_char !== TAB) {
63
+ return 'not_match';
64
+ }
65
+ // check for ./ or ../
66
+ const remaining = state.buffer.length - state.pos;
67
+ if (remaining < 3)
68
+ return forced ? 'not_match' : 'need_more';
69
+ if (state.buffer.charCodeAt(state.pos + 1) === PERIOD &&
70
+ state.buffer.charCodeAt(state.pos + 2) === SLASH) {
71
+ // ../
72
+ if (remaining < 4)
73
+ return forced ? 'not_match' : 'need_more';
74
+ const after = state.buffer.charCodeAt(state.pos + 3);
75
+ if (after === SPACE || after === NEWLINE || after === TAB || after === SLASH) {
76
+ return 'not_match';
77
+ }
78
+ if (forced)
79
+ return scan_auto_link_forced(state, 'internal');
80
+ start_pending_url(state, 'internal');
81
+ return 'consumed';
82
+ }
83
+ if (state.buffer.charCodeAt(state.pos + 1) === SLASH) {
84
+ // ./
85
+ const after = state.buffer.charCodeAt(state.pos + 2);
86
+ if (after === SPACE || after === NEWLINE || after === TAB || after === SLASH) {
87
+ return 'not_match';
88
+ }
89
+ if (forced)
90
+ return scan_auto_link_forced(state, 'internal');
91
+ start_pending_url(state, 'internal');
92
+ return 'consumed';
93
+ }
94
+ return 'not_match';
95
+ };
96
+ /**
97
+ * Start confirmed text-first mode for paths. Prefix already validated by hold.
98
+ * Flushes prior text, resets active_text_id, sets pending_url with confirmed=true.
99
+ */
100
+ export const start_pending_url = (state, link_type) => {
101
+ flush_text(state);
102
+ ensure_paragraph(state);
103
+ state.active_text_id = null;
104
+ state.pending_url = {
105
+ url_text: '',
106
+ start: offset(state),
107
+ link_type,
108
+ confirmed: true,
109
+ viable_https: false,
110
+ viable_http: false,
111
+ };
112
+ // don't advance pos — URL chars start at current position, handled by process_url_content
113
+ };
114
+ /**
115
+ * Start speculative text-first mode for URL prefixes.
116
+ * Chars stream as visible text while we verify `https://` or `http://`.
117
+ * Cancels if prefix doesn't match (text stays as plain text).
118
+ */
119
+ export const start_speculative_url = (state) => {
120
+ flush_text(state);
121
+ ensure_paragraph(state);
122
+ state.active_text_id = null;
123
+ state.pending_url = {
124
+ url_text: '',
125
+ start: offset(state),
126
+ link_type: 'external',
127
+ confirmed: false,
128
+ viable_https: true,
129
+ viable_http: true,
130
+ };
131
+ };
132
+ /**
133
+ * Speculative URL prefix matching. Checks each char against viable prefixes,
134
+ * streaming as text. Confirms on full match, cancels on mismatch.
135
+ *
136
+ * Scheme letters (`h`, `t`, `p`, `s`) are matched case-insensitively (RFC 3986);
137
+ * the `:` and `//` portion remains literal. Original casing is preserved in
138
+ * the emitted reference.
139
+ */
140
+ export const process_url_prefix = (state) => {
141
+ const pu = state.pending_url;
142
+ const char_code = state.buffer.charCodeAt(state.pos);
143
+ const pos = pu.url_text.length;
144
+ // scheme letters (positions 0-4) match case-insensitively;
145
+ // `:` and `/` (positions 5-7 for https, 4-6 for http) are literal.
146
+ const cmp_code = pos < 5 ? ascii_to_lower(char_code) : char_code;
147
+ // narrow viable prefixes
148
+ if (pu.viable_https &&
149
+ (pos >= HTTPS_PREFIX.length || cmp_code !== HTTPS_PREFIX.charCodeAt(pos))) {
150
+ pu.viable_https = false;
151
+ }
152
+ if (pu.viable_http && (pos >= HTTP_PREFIX.length || cmp_code !== HTTP_PREFIX.charCodeAt(pos))) {
153
+ pu.viable_http = false;
154
+ }
155
+ if (!pu.viable_https && !pu.viable_http) {
156
+ // no viable prefix — cancel speculation, don't consume char
157
+ state.pending_url = null;
158
+ return;
159
+ }
160
+ // char matches — accumulate as text
161
+ accumulate_text(state, state.buffer[state.pos], offset(state));
162
+ pu.url_text += state.buffer[state.pos];
163
+ state.pos++;
164
+ state.column++;
165
+ state.prev_char = char_code;
166
+ // check if a prefix is fully confirmed
167
+ if ((pu.viable_https && pos + 1 === HTTPS_PREFIX.length) ||
168
+ (pu.viable_http && pos + 1 === HTTP_PREFIX.length)) {
169
+ pu.confirmed = true;
170
+ }
171
+ };
172
+ /**
173
+ * Process URL/path chars in text-first mode. Scans path chars,
174
+ * accumulates as visible text. Terminates on space/newline/non-path-char
175
+ * and emits a `wrap` opcode.
176
+ */
177
+ export const process_url_content = (state, forced) => {
178
+ // speculative prefix matching phase
179
+ if (!state.pending_url.confirmed) {
180
+ process_url_prefix(state);
181
+ return;
182
+ }
183
+ const char_code = state.buffer.charCodeAt(state.pos);
184
+ // URL terminator
185
+ if (char_code === SPACE || char_code === NEWLINE || !is_valid_path_char(char_code)) {
186
+ flush_text(state);
187
+ complete_pending_url(state);
188
+ // don't consume terminator — outer loop handles it
189
+ return;
190
+ }
191
+ // scan URL chars
192
+ const start = state.pos;
193
+ state.pos++;
194
+ while (state.pos < state.buffer.length) {
195
+ const c = state.buffer.charCodeAt(state.pos);
196
+ if (c === SPACE || c === NEWLINE || !is_valid_path_char(c))
197
+ break;
198
+ state.pos++;
199
+ }
200
+ const text = state.buffer.slice(start, state.pos);
201
+ accumulate_text(state, text, offset(state, start));
202
+ state.pending_url.url_text += text;
203
+ state.prev_char = state.buffer.charCodeAt(state.pos - 1);
204
+ state.column += state.pos - start;
205
+ // at EOF in forced mode, finalize the URL
206
+ if (state.pos >= state.buffer.length && forced) {
207
+ flush_text(state);
208
+ complete_pending_url(state);
209
+ }
210
+ };
211
+ /**
212
+ * Complete a pending URL: compute reference with trimmed punctuation,
213
+ * emit a `wrap` opcode to retroactively wrap the text node in a Link.
214
+ */
215
+ export const complete_pending_url = (state) => {
216
+ const pu = state.pending_url;
217
+ state.pending_url = null;
218
+ const reference = trim_trailing_punctuation(pu.url_text);
219
+ if (reference.length === 0)
220
+ return; // empty after trimming — text stays as plain text
221
+ // for external URLs, must have content after protocol prefix
222
+ if (pu.link_type === 'external') {
223
+ const prefix_len = match_url_prefix_case_insensitive(reference, 0);
224
+ if (reference.length < prefix_len + 1)
225
+ return; // just protocol, no content
226
+ }
227
+ const text_id = state.active_text_id;
228
+ if (text_id === null)
229
+ return; // no text node to wrap (shouldn't happen)
230
+ const trim_end = pu.url_text.length - reference.length;
231
+ const wrap_id = alloc_id(state);
232
+ const url_end = pu.start + reference.length;
233
+ if (trim_end > 0) {
234
+ const trim_id = alloc_id(state);
235
+ emit(state, {
236
+ type: 'wrap',
237
+ id: wrap_id,
238
+ node_type: 'Link',
239
+ target_id: text_id,
240
+ reference,
241
+ link_type: pu.link_type,
242
+ start: pu.start,
243
+ end: url_end,
244
+ trim_end,
245
+ trim_id,
246
+ });
247
+ state.active_text_id = trim_id;
248
+ }
249
+ else {
250
+ emit(state, {
251
+ type: 'wrap',
252
+ id: wrap_id,
253
+ node_type: 'Link',
254
+ target_id: text_id,
255
+ reference,
256
+ link_type: pu.link_type,
257
+ start: pu.start,
258
+ end: url_end,
259
+ });
260
+ state.active_text_id = null;
261
+ }
262
+ };
263
+ /**
264
+ * Forced-mode auto-link: scan the full URL/path inline (no streaming needed
265
+ * at EOF). Used when forced=true — the entire URL must be in the buffer.
266
+ */
267
+ export const scan_auto_link_forced = (state, link_type) => {
268
+ let i = state.pos;
269
+ while (i < state.buffer.length) {
270
+ const c = state.buffer.charCodeAt(i);
271
+ if (c === SPACE || c === NEWLINE || !is_valid_path_char(c))
272
+ break;
273
+ i++;
274
+ }
275
+ let reference = state.buffer.slice(state.pos, i);
276
+ reference = trim_trailing_punctuation(reference);
277
+ if (reference.length === 0)
278
+ return 'not_match';
279
+ // for external URLs, must have content after protocol prefix
280
+ if (link_type === 'external') {
281
+ const prefix_len = match_url_prefix_case_insensitive(reference, 0);
282
+ if (reference.length < prefix_len + 1)
283
+ return 'not_match';
284
+ }
285
+ const end_pos = state.pos + reference.length;
286
+ const link_start = offset(state);
287
+ const link_end = offset(state, end_pos);
288
+ flush_text(state);
289
+ ensure_paragraph(state);
290
+ const link_id = alloc_id(state);
291
+ emit(state, { type: 'open', id: link_id, node_type: 'Link', start: link_start });
292
+ const text_id = alloc_id(state);
293
+ emit(state, {
294
+ type: 'text',
295
+ id: text_id,
296
+ content: reference,
297
+ text_type: 'Text',
298
+ start: link_start,
299
+ end: link_end,
300
+ });
301
+ emit(state, { type: 'close', id: link_id, end: link_end, reference, link_type });
302
+ state.active_text_id = null;
303
+ state.column += end_pos - state.pos;
304
+ state.prev_char = reference.charCodeAt(reference.length - 1);
305
+ state.pos = end_pos;
306
+ return 'consumed';
307
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Reactive state for the mdz streaming renderer.
3
+ *
4
+ * Maintains a reactive tree of `MdzStreamNode` objects that Svelte 5 can
5
+ * efficiently update. Opcodes from `MdzStreamParser` are applied via
6
+ * `apply()` or `apply_batch()`, mutating the tree in place.
7
+ *
8
+ * @module
9
+ */
10
+ import type { MdzNodeId, MdzNodeType, MdzOpcode } from './mdz_opcodes.js';
11
+ /**
12
+ * A reactive node in the stream renderer tree.
13
+ * Fields are `$state` so Svelte re-renders only what changes.
14
+ */
15
+ export declare class MdzStreamNode {
16
+ id: MdzNodeId;
17
+ type: MdzNodeType;
18
+ content: string;
19
+ children: Array<MdzStreamNode>;
20
+ level?: number;
21
+ reference?: string;
22
+ link_type?: string;
23
+ name?: string;
24
+ lang?: string | null;
25
+ heading_id?: string;
26
+ constructor(id: MdzNodeId, type: MdzNodeType);
27
+ }
28
+ /**
29
+ * Reactive state manager for streaming mdz content.
30
+ * Apply opcodes to incrementally build and update the render tree.
31
+ */
32
+ export declare class MdzStreamState {
33
+ #private;
34
+ root: Array<MdzStreamNode>;
35
+ /**
36
+ * Apply a single opcode.
37
+ */
38
+ apply(opcode: MdzOpcode): void;
39
+ /**
40
+ * Apply a batch of opcodes.
41
+ */
42
+ apply_batch(opcodes: Array<MdzOpcode>): void;
43
+ }
44
+ //# sourceMappingURL=mdz_stream_state.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mdz_stream_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_stream_state.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAExE;;;GAGG;AACH,qBAAa,aAAa;IACzB,EAAE,EAAE,SAAS,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAc;IAC7B,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,CAAc;IAE5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAY;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAY;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAY;gBAEnB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW;CAI5C;AAED;;;GAGG;AACH,qBAAa,cAAc;;IAC1B,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,CAAc;IA8BxC;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IA+S9B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI;CAK5C"}