@mdsvex/render 0.0.0 → 1.0.0-next.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/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ ## 1.0.0-next.0
2
+
3
+ ### Major Changes
4
+
5
+ - [#795](https://github.com/pngwn/MDsveX/pull/795) [`6ac3826`](https://github.com/pngwn/MDsveX/commit/6ac382615eb410230e8423d5ca4202005588869e) Thanks [@pngwn](https://github.com/pngwn)! - Add new PFM parser, renderers
6
+
7
+ ### Minor Changes
8
+
9
+ - [#798](https://github.com/pngwn/MDsveX/pull/798) [`e5b7abe`](https://github.com/pngwn/MDsveX/commit/e5b7abe1ebf868b1df1e934fb96e1e363696f3e9) Thanks [@pngwn](https://github.com/pngwn)! - Add plugin system and autolink plugin
10
+
11
+ - [#799](https://github.com/pngwn/MDsveX/pull/799) [`5b54692`](https://github.com/pngwn/MDsveX/commit/5b54692d6c895f02c947ce620a46c7a9beb856e9) Thanks [@pngwn](https://github.com/pngwn)! - Add language tools
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`6ac3826`](https://github.com/pngwn/MDsveX/commit/6ac382615eb410230e8423d5ca4202005588869e), [`46f655f`](https://github.com/pngwn/MDsveX/commit/46f655f90a838726eda34e1b07667e86fa61e7cb), [`e5b7abe`](https://github.com/pngwn/MDsveX/commit/e5b7abe1ebf868b1df1e934fb96e1e363696f3e9), [`5b54692`](https://github.com/pngwn/MDsveX/commit/5b54692d6c895f02c947ce620a46c7a9beb856e9)]:
16
+ - @mdsvex/parse@1.0.0-next.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 pngwn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ class r {
2
+ constructor() {
3
+ this.blocks = [], this.buf = null, this.source = "", this.closed = /* @__PURE__ */ new Set();
4
+ }
5
+ update(t, c) {
6
+ this.buf = t, this.source = c;
7
+ let e = 0, i = !1, s = t._children_starts[0];
8
+ for (; s !== 4294967295; ) {
9
+ const o = t._kinds[s], l = t._next_siblings[s], h = l !== 4294967295 && t._parents[l] === 0;
10
+ if (o !== 6) {
11
+ const n = t._ends[s] !== 4294967295;
12
+ e >= this.blocks.length ? (this.blocks.push({ idx: s, v: 0 }), i = !0) : this.closed.has(s) || (this.blocks[e].v++, i = !0), n && !this.closed.has(s) && this.closed.add(s), e++;
13
+ }
14
+ s = h ? l : 4294967295;
15
+ }
16
+ return i ? this.blocks = [...this.blocks] : this.blocks;
17
+ }
18
+ reset() {
19
+ this.blocks = [], this.buf = null, this.source = "", this.closed.clear();
20
+ }
21
+ }
22
+ export {
23
+ r as ComponentRenderer
24
+ };
@@ -0,0 +1,510 @@
1
+ import { Cursor as S } from "@mdsvex/parse/cursor";
2
+ import { CI_SVELTE as b, CI_TEXT as f, CI_CODE as k, CI_STRUCTURE as x } from "./mappings.js";
3
+ const N = /[&<>"]/, m = /[&<>"]/g, w = {
4
+ "&": "&amp;",
5
+ "<": "&lt;",
6
+ ">": "&gt;",
7
+ '"': "&quot;"
8
+ };
9
+ function M(s) {
10
+ return w[s];
11
+ }
12
+ function o(s) {
13
+ return N.test(s) ? s.replace(m, M) : s;
14
+ }
15
+ const B = 0, R = 1, y = 2, P = 3, D = 5, T = 6, U = 7, G = 8, j = 9, V = 10, q = 11, F = 12, X = 13, Q = 14, W = 15, v = 16, Y = 17, z = 18, J = 19, Z = 20, $ = 21, u = 22, nn = 23, sn = 24, en = 25, hn = 26, ln = 27, tn = 28, an = 29, gn = 4, xn = 33, En = 34, O = 4294967295;
16
+ function r(s, n, h, t, e, l) {
17
+ h > n && t !== O && s.push({
18
+ out_idx: n,
19
+ out_count: h - n,
20
+ source_offset: t,
21
+ source_length: e > t ? e - t : 0,
22
+ data: l
23
+ });
24
+ }
25
+ function p(s, n, h, t, e, l, a) {
26
+ const i = l.index, g = l.start, d = l.end, K = l.value_start, I = l.value_end, A = I > K;
27
+ r(s, n, e, g, d, { ...a, nodeIndex: i, role: "node" }), r(s, n, h, g, A ? K : g, { ...x, nodeIndex: i, role: "open_syntax" }), r(s, t, e, A ? I : d, d, { ...x, nodeIndex: i, role: "close_syntax" });
28
+ }
29
+ const pn = ["", "</h1>", "</h2>", "</h3>", "</h4>", "</h5>", "</h6>"], cn = /* @__PURE__ */ new Set([
30
+ // list semantics
31
+ "ordered",
32
+ "tight",
33
+ "start",
34
+ // code fence info (transformed into class="language-X")
35
+ "info",
36
+ "info_start",
37
+ "info_end",
38
+ // raw html node internals
39
+ "tag",
40
+ "attributes",
41
+ "self_closing",
42
+ // table internals
43
+ "alignments",
44
+ "col_count",
45
+ // image src (handled specially with alt ordering)
46
+ "src"
47
+ ]);
48
+ function _(s, n, h) {
49
+ const t = s.meta();
50
+ if (t)
51
+ for (const e in t) {
52
+ if (cn.has(e) || h !== void 0 && h.has(e)) continue;
53
+ const l = t[e];
54
+ l === !0 ? n.push(" ", e) : l !== !1 && l != null && (typeof l == "object" && l.type === "expression" ? n.push(" ", e, "={", l.value, "}") : n.push(" ", e, '="', o(String(l)), '"'));
55
+ }
56
+ }
57
+ const _n = /* @__PURE__ */ new Set(["href", "title"]), fn = /* @__PURE__ */ new Set(["title"]);
58
+ function c(s, n, h) {
59
+ if (s.goto_first_child()) {
60
+ do
61
+ if (s.kind === R) {
62
+ const t = s.value_start, e = s.value_end;
63
+ h && t !== O && e > t && r(
64
+ h,
65
+ n.length,
66
+ n.length + 1,
67
+ t,
68
+ e,
69
+ { ...f, nodeIndex: s.index, role: "content" }
70
+ ), n.push(o(s.text()));
71
+ } else
72
+ E(s, n, h);
73
+ while (s.goto_next_sibling());
74
+ s.goto_parent();
75
+ }
76
+ }
77
+ function H(s) {
78
+ if (!s.goto_first_child()) return "";
79
+ let n = "";
80
+ do
81
+ s.kind === R ? n += s.text() : n += H(s);
82
+ while (s.goto_next_sibling());
83
+ return s.goto_parent(), n;
84
+ }
85
+ function E(s, n, h) {
86
+ switch (s.kind) {
87
+ case B:
88
+ c(s, n, h);
89
+ break;
90
+ case P: {
91
+ const t = n.length;
92
+ n.push("<h", String(s.extra)), _(s, n), n.push(">");
93
+ const e = n.length;
94
+ c(s, n, h);
95
+ const l = n.length;
96
+ n.push(pn[s.extra]), h && p(h, t, e, l, n.length, s, f);
97
+ break;
98
+ }
99
+ case U:
100
+ if (s.pending && s.parent_kind === v)
101
+ c(s, n, h);
102
+ else {
103
+ const t = n.length;
104
+ n.push("<p"), _(s, n), n.push(">");
105
+ const e = n.length;
106
+ c(s, n, h);
107
+ const l = n.length;
108
+ n.push("</p>"), h && p(h, t, e, l, n.length, s, f);
109
+ }
110
+ break;
111
+ case j: {
112
+ const t = n.length;
113
+ n.push("<em"), _(s, n), n.push(">");
114
+ const e = n.length;
115
+ c(s, n, h);
116
+ const l = n.length;
117
+ n.push("</em>"), h && p(h, t, e, l, n.length, s, f);
118
+ break;
119
+ }
120
+ case V: {
121
+ const t = n.length;
122
+ n.push("<strong"), _(s, n), n.push(">");
123
+ const e = n.length;
124
+ c(s, n, h);
125
+ const l = n.length;
126
+ n.push("</strong>"), h && p(h, t, e, l, n.length, s, f);
127
+ break;
128
+ }
129
+ case G: {
130
+ const t = n.length;
131
+ n.push("<code"), _(s, n), n.push(">");
132
+ const e = n.length;
133
+ h && r(
134
+ h,
135
+ n.length,
136
+ n.length + 1,
137
+ s.value_start,
138
+ s.value_end,
139
+ { ...k, nodeIndex: s.index, role: "content" }
140
+ ), n.push(o(s.text()).replace(/\n/g, " "));
141
+ const l = n.length;
142
+ n.push("</code>"), h && p(h, t, e, l, n.length, s, k);
143
+ break;
144
+ }
145
+ case D: {
146
+ const t = n.length, e = s.meta();
147
+ let l = e == null ? void 0 : e.info;
148
+ if (!l) {
149
+ const g = e == null ? void 0 : e.info_start, d = e == null ? void 0 : e.info_end;
150
+ g != null && d != null && (l = s.slice(g, d));
151
+ }
152
+ n.push("<pre><code"), l && n.push(' class="language-', o(l), '"'), _(s, n), n.push(">");
153
+ const a = n.length;
154
+ h && r(
155
+ h,
156
+ n.length,
157
+ n.length + 1,
158
+ s.value_start,
159
+ s.value_end,
160
+ { ...k, nodeIndex: s.index, role: "content" }
161
+ ), n.push(o(s.text()));
162
+ const i = n.length;
163
+ n.push("</code></pre>"), h && p(h, t, a, i, n.length, s, k);
164
+ break;
165
+ }
166
+ case Q: {
167
+ const t = n.length;
168
+ n.push("<blockquote"), _(s, n), n.push(`>
169
+ `);
170
+ const e = n.length;
171
+ c(s, n, h);
172
+ const l = n.length;
173
+ n.push(`
174
+ </blockquote>`), h && p(h, t, e, l, n.length, s, f);
175
+ break;
176
+ }
177
+ case F: {
178
+ const t = n.length, e = s.meta();
179
+ n.push("<a"), e != null && e.href && n.push(' href="', o(e.href), '"'), e != null && e.title && n.push(' title="', o(e.title), '"'), _(s, n, _n), n.push(">");
180
+ const l = n.length;
181
+ c(s, n, h);
182
+ const a = n.length;
183
+ n.push("</a>"), h && p(h, t, l, a, n.length, s, f);
184
+ break;
185
+ }
186
+ case X: {
187
+ const t = n.length, e = s.meta();
188
+ n.push("<img"), e != null && e.src && n.push(' src="', o(e.src), '"'), n.push(' alt="', o(H(s)), '"'), e != null && e.title && n.push(' title="', o(e.title), '"'), _(s, n, fn), n.push(" />"), h && p(h, t, t, n.length, n.length, s, f);
189
+ break;
190
+ }
191
+ case W: {
192
+ const t = n.length, e = s.meta(), l = !!(e != null && e.ordered), a = l ? "ol" : "ul", i = e == null ? void 0 : e.start;
193
+ n.push("<", a), l && i != null && i !== 1 && n.push(' start="', String(i), '"'), _(s, n), n.push(`>
194
+ `);
195
+ const g = n.length;
196
+ c(s, n, h);
197
+ const d = n.length;
198
+ n.push(`
199
+ </`, a, ">"), h && p(h, t, g, d, n.length, s, x);
200
+ break;
201
+ }
202
+ case v: {
203
+ const t = n.length;
204
+ n.push("<li"), _(s, n), n.push(">");
205
+ const e = n.length;
206
+ c(s, n, h);
207
+ const l = n.length;
208
+ n.push(`</li>
209
+ `), h && p(h, t, e, l, n.length, s, f);
210
+ break;
211
+ }
212
+ case q: {
213
+ const t = n.length;
214
+ n.push("<hr />"), h && p(h, t, n.length, n.length, n.length, s, x);
215
+ break;
216
+ }
217
+ case Y:
218
+ n.push(`<br />
219
+ `);
220
+ break;
221
+ case z:
222
+ n.push(`
223
+ `);
224
+ break;
225
+ case J: {
226
+ const t = n.length;
227
+ n.push("<del"), _(s, n), n.push(">");
228
+ const e = n.length;
229
+ c(s, n, h);
230
+ const l = n.length;
231
+ n.push("</del>"), h && p(h, t, e, l, n.length, s, f);
232
+ break;
233
+ }
234
+ case Z: {
235
+ const t = n.length;
236
+ n.push("<sup"), _(s, n), n.push(">");
237
+ const e = n.length;
238
+ c(s, n, h);
239
+ const l = n.length;
240
+ n.push("</sup>"), h && p(h, t, e, l, n.length, s, f);
241
+ break;
242
+ }
243
+ case $: {
244
+ const t = n.length;
245
+ n.push("<sub"), _(s, n), n.push(">");
246
+ const e = n.length;
247
+ c(s, n, h);
248
+ const l = n.length;
249
+ n.push("</sub>"), h && p(h, t, e, l, n.length, s, f);
250
+ break;
251
+ }
252
+ case y: {
253
+ const t = n.length, e = s.meta(), l = e == null ? void 0 : e.tag, a = e == null ? void 0 : e.attributes;
254
+ if (n.push("<", l), a)
255
+ for (const i in a) {
256
+ const g = a[i];
257
+ g === !0 ? n.push(" ", i) : typeof g == "object" && g.type === "expression" ? n.push(" ", i, "={", g.value, "}") : n.push(" ", i, '="', o(g), '"');
258
+ }
259
+ if (e != null && e.self_closing) {
260
+ const i = s.end > s.start ? s.slice(s.start, s.end) : "";
261
+ i ? (n.length = t, n.push(i)) : n.push(" />"), h && r(
262
+ h,
263
+ t,
264
+ n.length,
265
+ s.start,
266
+ s.end,
267
+ { ...b, nodeIndex: s.index, role: "content" }
268
+ );
269
+ } else {
270
+ n.push(">");
271
+ const i = n.length;
272
+ l === "script" || l === "style" ? (h && r(
273
+ h,
274
+ n.length,
275
+ n.length + 1,
276
+ s.value_start,
277
+ s.value_end,
278
+ { ...b, nodeIndex: s.index, role: "content" }
279
+ ), n.push(s.text())) : c(s, n, h);
280
+ const g = n.length;
281
+ n.push("</", l, ">"), h && p(h, t, i, g, n.length, s, f);
282
+ }
283
+ break;
284
+ }
285
+ case hn: {
286
+ const t = n.length;
287
+ n.push("<!--");
288
+ const e = n.length;
289
+ h && r(
290
+ h,
291
+ n.length,
292
+ n.length + 1,
293
+ s.value_start,
294
+ s.value_end,
295
+ { ...f, nodeIndex: s.index, role: "content" }
296
+ ), n.push(s.text());
297
+ const l = n.length;
298
+ n.push("-->"), h && p(h, t, e, l, n.length, s, f);
299
+ break;
300
+ }
301
+ case gn: {
302
+ const t = n.length;
303
+ n.push("{");
304
+ const e = n.length;
305
+ h && r(
306
+ h,
307
+ n.length,
308
+ n.length + 1,
309
+ s.value_start,
310
+ s.value_end,
311
+ { ...b, nodeIndex: s.index, role: "content" }
312
+ ), n.push(s.text());
313
+ const l = n.length;
314
+ n.push("}"), h && p(h, t, e, l, n.length, s, b);
315
+ break;
316
+ }
317
+ case ln: {
318
+ const t = n.length, e = s.meta(), l = e == null ? void 0 : e.tag, a = s.text();
319
+ n.push("{@", l), a && n.push(" ");
320
+ const i = n.length;
321
+ a && h && r(
322
+ h,
323
+ n.length,
324
+ n.length + 1,
325
+ s.value_start,
326
+ s.value_end,
327
+ { ...b, nodeIndex: s.index, role: "content" }
328
+ ), a && n.push(a);
329
+ const g = n.length;
330
+ n.push("}"), h && p(h, t, i, g, n.length, s, b);
331
+ break;
332
+ }
333
+ case tn: {
334
+ const t = n.length, e = s.meta(), l = e == null ? void 0 : e.tag;
335
+ if (s.goto_first_child()) {
336
+ let a = !0;
337
+ do
338
+ if (s.kind === an) {
339
+ const i = s.meta(), g = i == null ? void 0 : i.tag, d = s.text();
340
+ a ? (n.push("{#", l), d && (n.push(" "), h && r(
341
+ h,
342
+ n.length,
343
+ n.length + 1,
344
+ s.value_start,
345
+ s.value_end,
346
+ { ...b, nodeIndex: s.index, role: "content" }
347
+ ), n.push(d)), n.push(`}
348
+ `), a = !1) : (n.push("{:", g), d && (n.push(" "), h && r(
349
+ h,
350
+ n.length,
351
+ n.length + 1,
352
+ s.value_start,
353
+ s.value_end,
354
+ { ...b, nodeIndex: s.index, role: "content" }
355
+ ), n.push(d)), n.push(`}
356
+ `)), c(s, n, h);
357
+ } else s.kind !== T && E(s, n, h);
358
+ while (s.goto_next_sibling());
359
+ s.goto_parent();
360
+ }
361
+ if (n.push("{/", l, "}"), h) {
362
+ const a = s.index, i = s.start, g = s.end;
363
+ r(h, t, n.length, i, g, { ...b, nodeIndex: a, role: "node" });
364
+ }
365
+ break;
366
+ }
367
+ case u: {
368
+ const t = n.length;
369
+ n.push("<table"), _(s, n), n.push(`>
370
+ `);
371
+ const e = n.length;
372
+ rn(s, n, h);
373
+ const l = n.length;
374
+ n.push(`
375
+ </table>`), h && p(h, t, e, l, n.length, s, x);
376
+ break;
377
+ }
378
+ case T:
379
+ break;
380
+ default:
381
+ c(s, n, h);
382
+ break;
383
+ }
384
+ }
385
+ function rn(s, n, h) {
386
+ const t = s.meta(), e = (t == null ? void 0 : t.alignments) ?? [];
387
+ let l = !1;
388
+ if (s.goto_first_child()) {
389
+ do
390
+ s.kind === nn ? (n.push(`<thead>
391
+ <tr>
392
+ `), L(s, "th", e, n, h), n.push(`</tr>
393
+ </thead>
394
+ `)) : s.kind === sn && (l || (n.push(`<tbody>
395
+ `), l = !0), n.push(`<tr>
396
+ `), L(s, "td", e, n, h), n.push(`</tr>
397
+ `));
398
+ while (s.goto_next_sibling());
399
+ s.goto_parent(), l && n.push("</tbody>");
400
+ }
401
+ }
402
+ function L(s, n, h, t, e) {
403
+ let l = 0;
404
+ if (s.goto_first_child()) {
405
+ do
406
+ if (s.kind === en) {
407
+ const a = h[l];
408
+ a && a !== "none" ? t.push("<", n, ' align="', a, '">') : t.push("<", n, ">"), c(s, t, e), t.push("</", n, `>
409
+ `), l++;
410
+ }
411
+ while (s.goto_next_sibling());
412
+ s.goto_parent();
413
+ }
414
+ }
415
+ function dn(s, n) {
416
+ const h = new Uint32Array(s.length + 1);
417
+ for (let e = 0; e < s.length; e++)
418
+ h[e + 1] = h[e] + s[e].length;
419
+ const t = [];
420
+ for (let e = 0; e < n.length; e++) {
421
+ const l = n[e], a = h[l.out_idx], i = h[l.out_idx + l.out_count] - a, g = {
422
+ sourceOffsets: [l.source_offset],
423
+ generatedOffsets: [a],
424
+ lengths: [l.source_length],
425
+ data: l.data
426
+ };
427
+ i !== l.source_length && (g.generatedLengths = [i]), t.push(g);
428
+ }
429
+ return t;
430
+ }
431
+ function C(s) {
432
+ const n = [];
433
+ return E(s, n), n.join("");
434
+ }
435
+ class kn {
436
+ constructor(n) {
437
+ this.blocks = [], this.html = "", this.closed = null, this.cursor = null, this.cache = (n == null ? void 0 : n.cache) ?? !0, this.cache && (this.closed = /* @__PURE__ */ new Set());
438
+ }
439
+ update(n, h) {
440
+ this.cursor ? this.cursor.reinit(n, h) : this.cursor = new S(n, h);
441
+ const t = this.cursor;
442
+ if (t.reset(), !this.cache) {
443
+ const l = [];
444
+ return E(t, l), this.html = l.join(""), this.blocks;
445
+ }
446
+ if (!t.goto_first_child()) return this.blocks;
447
+ let e = 0;
448
+ do {
449
+ if (t.kind === T) continue;
450
+ const l = t.index;
451
+ e >= this.blocks.length ? (this.blocks.push({ idx: l, html: C(t) }), t.closed && this.closed.add(l)) : this.closed.has(l) || (this.blocks[e].html = C(t), t.closed && this.closed.add(l)), e++;
452
+ } while (t.goto_next_sibling());
453
+ return t.goto_parent(), this.html = this.blocks.map((l) => l.html).join(""), this.blocks;
454
+ }
455
+ /** render with source mapping. always full render (no caching). */
456
+ update_mapped(n, h) {
457
+ this.cursor ? this.cursor.reinit(n, h) : this.cursor = new S(n, h);
458
+ const t = this.cursor;
459
+ t.reset();
460
+ const e = [], l = [];
461
+ E(t, e, l), this.html = e.join("");
462
+ const a = dn(e, l);
463
+ return { blocks: this.blocks, mappings: a };
464
+ }
465
+ reset() {
466
+ var n;
467
+ this.blocks.length = 0, (n = this.closed) == null || n.clear(), this.html = "";
468
+ }
469
+ }
470
+ export {
471
+ kn as CursorHTMLRenderer,
472
+ Q as K_BLOCK_QUOTE,
473
+ D as K_CODE_FENCE,
474
+ G as K_CODE_SPAN,
475
+ j as K_EMPHASIS,
476
+ xn as K_FRONTMATTER,
477
+ Y as K_HARD_BREAK,
478
+ P as K_HEADING,
479
+ y as K_HTML,
480
+ hn as K_HTML_COMMENT,
481
+ X as K_IMAGE,
482
+ En as K_IMPORT_STATEMENT,
483
+ T as K_LINE_BREAK,
484
+ F as K_LINK,
485
+ W as K_LIST,
486
+ v as K_LIST_ITEM,
487
+ gn as K_MUSTACHE,
488
+ U as K_PARAGRAPH,
489
+ B as K_ROOT,
490
+ z as K_SOFT_BREAK,
491
+ J as K_STRIKETHROUGH,
492
+ V as K_STRONG,
493
+ $ as K_SUBSCRIPT,
494
+ Z as K_SUPERSCRIPT,
495
+ tn as K_SVELTE_BLOCK,
496
+ an as K_SVELTE_BRANCH,
497
+ ln as K_SVELTE_TAG,
498
+ u as K_TABLE,
499
+ en as K_TABLE_CELL,
500
+ nn as K_TABLE_HEADER,
501
+ sn as K_TABLE_ROW,
502
+ R as K_TEXT,
503
+ q as K_THEMATIC_BREAK,
504
+ O as NONE,
505
+ c as _children,
506
+ r as _emit,
507
+ E as _node,
508
+ dn as _resolve_mappings,
509
+ o as escape
510
+ };
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import { CursorHTMLRenderer as o, K_FRONTMATTER as r, K_HTML as T, K_IMPORT_STATEMENT as t, K_LINE_BREAK as E, K_ROOT as p, K_TEXT as n, NONE as s, _children as R, _emit as i, _node as m, _resolve_mappings as C, escape as K } from "./html_cursor.js";
2
+ import { ComponentRenderer as I } from "./component.js";
3
+ import { CI_CODE as d, CI_STRUCTURE as M, CI_SVELTE as N, CI_TEXT as a } from "./mappings.js";
4
+ import { build_line_starts as x, mappings_to_v3 as L, offset_to_position as A } from "./sourcemap.js";
5
+ export {
6
+ d as CI_CODE,
7
+ M as CI_STRUCTURE,
8
+ N as CI_SVELTE,
9
+ a as CI_TEXT,
10
+ I as ComponentRenderer,
11
+ o as CursorHTMLRenderer,
12
+ r as K_FRONTMATTER,
13
+ T as K_HTML,
14
+ t as K_IMPORT_STATEMENT,
15
+ E as K_LINE_BREAK,
16
+ p as K_ROOT,
17
+ n as K_TEXT,
18
+ s as NONE,
19
+ R as _children,
20
+ i as _emit,
21
+ m as _node,
22
+ C as _resolve_mappings,
23
+ x as build_line_starts,
24
+ K as escape,
25
+ L as mappings_to_v3,
26
+ A as offset_to_position
27
+ };
@@ -0,0 +1,23 @@
1
+ const t = {
2
+ verification: !0,
3
+ semantic: !0,
4
+ navigation: !0
5
+ }, e = {
6
+ semantic: !0,
7
+ navigation: !0
8
+ }, r = {
9
+ verification: !0,
10
+ completion: !0,
11
+ semantic: !0,
12
+ navigation: !0,
13
+ structure: !0,
14
+ format: !0
15
+ }, i = {
16
+ structure: !0
17
+ };
18
+ export {
19
+ e as CI_CODE,
20
+ i as CI_STRUCTURE,
21
+ r as CI_SVELTE,
22
+ t as CI_TEXT
23
+ };
@@ -0,0 +1,78 @@
1
+ function x(s) {
2
+ const n = [0];
3
+ for (let e = 0; e < s.length; e++)
4
+ s.charCodeAt(e) === 10 && n.push(e + 1);
5
+ return new Uint32Array(n);
6
+ }
7
+ function y(s, n) {
8
+ let e = 0, l = s.length;
9
+ for (; e < l; ) {
10
+ const _ = e + l >>> 1;
11
+ s[_] <= n ? e = _ + 1 : l = _;
12
+ }
13
+ const h = e - 1;
14
+ return [h, n - s[h]];
15
+ }
16
+ const C = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
17
+ function u(s) {
18
+ let n = s < 0 ? -s << 1 | 1 : s << 1, e = "";
19
+ do {
20
+ let l = n & 31;
21
+ n >>>= 5, n > 0 && (l |= 32), e += C[l];
22
+ } while (n > 0);
23
+ return e;
24
+ }
25
+ function O(s, n, e, l) {
26
+ const h = x(n), _ = x(e), g = [];
27
+ for (const t of s) {
28
+ const f = t.data.role;
29
+ if (!(f === "open_syntax" || f === "close_syntax"))
30
+ for (let r = 0; r < t.sourceOffsets.length; r++) {
31
+ const c = t.generatedOffsets[r], i = t.sourceOffsets[r];
32
+ if (f === "node")
33
+ g.push({ gen_offset: c, src_offset: i });
34
+ else {
35
+ const L = t.generatedLengths ? t.generatedLengths[r] : t.lengths[r], A = t.lengths[r];
36
+ if (!t.generatedLengths && A === L)
37
+ for (let p = 0; p < L; p++)
38
+ g.push({
39
+ gen_offset: c + p,
40
+ src_offset: i + p
41
+ });
42
+ else
43
+ g.push({
44
+ gen_offset: c,
45
+ src_offset: i
46
+ });
47
+ }
48
+ }
49
+ }
50
+ g.sort((t, f) => t.gen_offset - f.gen_offset);
51
+ let a = 0, d = 0, m = 0, v = 0, o = "";
52
+ for (const t of g) {
53
+ const [f, r] = y(
54
+ _,
55
+ t.gen_offset
56
+ ), [c, i] = y(
57
+ h,
58
+ t.src_offset
59
+ );
60
+ for (; v < f; )
61
+ o += ";", v++, a = 0;
62
+ o.length > 0 && o[o.length - 1] !== ";" && (o += ","), o += u(r - a), o += u(0), o += u(c - d), o += u(i - m), a = r, d = c, m = i;
63
+ }
64
+ const w = l ? l.split(/[/\\]/).pop() : "input.md";
65
+ return {
66
+ version: 3,
67
+ file: w,
68
+ sources: [w],
69
+ sourcesContent: [n],
70
+ names: [],
71
+ mappings: o
72
+ };
73
+ }
74
+ export {
75
+ x as build_line_starts,
76
+ O as mappings_to_v3,
77
+ y as offset_to_position
78
+ };