@arborium/arborium 2.4.7 → 2.5.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/dist/arborium.d.ts +2 -2
- package/dist/arborium.iife.js +2 -2
- package/dist/arborium.iife.js.map +1 -1
- package/dist/arborium.js +476 -138
- package/dist/arborium.js.map +1 -1
- package/dist/arborium_host.js +9 -9
- package/dist/arborium_host_bg.wasm +0 -0
- package/dist/loader.d.ts +2 -3
- package/dist/loader.test.d.ts +1 -0
- package/dist/plugins-manifest.d.ts +4 -1
- package/dist/types.d.ts +37 -2
- package/dist/utils.d.ts +5 -0
- package/package.json +5 -2
package/dist/arborium.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const x = "2.
|
|
1
|
+
const x = "2.5.0", $ = [
|
|
2
2
|
"ada",
|
|
3
3
|
"agda",
|
|
4
4
|
"asciidoc",
|
|
@@ -97,7 +97,359 @@ const x = "2.4.7", $ = [
|
|
|
97
97
|
"yuri",
|
|
98
98
|
"zig",
|
|
99
99
|
"zsh"
|
|
100
|
-
],
|
|
100
|
+
], R = [
|
|
101
|
+
{
|
|
102
|
+
name: "attribute",
|
|
103
|
+
tag: "at"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "constant",
|
|
107
|
+
tag: "co"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "constant.builtin",
|
|
111
|
+
tag: "co",
|
|
112
|
+
parentTag: "co"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "constructor",
|
|
116
|
+
tag: "cr"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "function.builtin",
|
|
120
|
+
tag: "fb",
|
|
121
|
+
parentTag: "f"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "function",
|
|
125
|
+
tag: "f"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "function.method",
|
|
129
|
+
tag: "f",
|
|
130
|
+
parentTag: "f"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "keyword",
|
|
134
|
+
tag: "k"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "keyword.conditional",
|
|
138
|
+
tag: "k",
|
|
139
|
+
parentTag: "k"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "keyword.coroutine",
|
|
143
|
+
tag: "k",
|
|
144
|
+
parentTag: "k"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "keyword.debug",
|
|
148
|
+
tag: "k",
|
|
149
|
+
parentTag: "k"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "keyword.exception",
|
|
153
|
+
tag: "k",
|
|
154
|
+
parentTag: "k"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "keyword.function",
|
|
158
|
+
tag: "k",
|
|
159
|
+
parentTag: "k"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "keyword.import",
|
|
163
|
+
tag: "k",
|
|
164
|
+
parentTag: "k"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "keyword.operator",
|
|
168
|
+
tag: "o",
|
|
169
|
+
parentTag: "k"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "keyword.repeat",
|
|
173
|
+
tag: "k",
|
|
174
|
+
parentTag: "k"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "keyword.return",
|
|
178
|
+
tag: "k",
|
|
179
|
+
parentTag: "k"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "keyword.type",
|
|
183
|
+
tag: "k",
|
|
184
|
+
parentTag: "k"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "operator",
|
|
188
|
+
tag: "o"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "property",
|
|
192
|
+
tag: "pr"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "punctuation",
|
|
196
|
+
tag: "p"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "punctuation.bracket",
|
|
200
|
+
tag: "p",
|
|
201
|
+
parentTag: "p"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "punctuation.delimiter",
|
|
205
|
+
tag: "p",
|
|
206
|
+
parentTag: "p"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "punctuation.special",
|
|
210
|
+
tag: "p",
|
|
211
|
+
parentTag: "p"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "string",
|
|
215
|
+
tag: "s"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "string.special",
|
|
219
|
+
tag: "s",
|
|
220
|
+
parentTag: "s"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "tag",
|
|
224
|
+
tag: "tg"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "tag.delimiter",
|
|
228
|
+
tag: "tg",
|
|
229
|
+
parentTag: "tg"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "tag.error",
|
|
233
|
+
tag: "err",
|
|
234
|
+
parentTag: "tg"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "type",
|
|
238
|
+
tag: "t"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "type.builtin",
|
|
242
|
+
tag: "t",
|
|
243
|
+
parentTag: "t"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "type.qualifier",
|
|
247
|
+
tag: "t",
|
|
248
|
+
parentTag: "t"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: "variable",
|
|
252
|
+
tag: "v"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: "variable.builtin",
|
|
256
|
+
tag: "v",
|
|
257
|
+
parentTag: "v"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: "variable.parameter",
|
|
261
|
+
tag: "v",
|
|
262
|
+
parentTag: "v"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "comment",
|
|
266
|
+
tag: "c"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: "comment.documentation",
|
|
270
|
+
tag: "c",
|
|
271
|
+
parentTag: "c"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: "macro",
|
|
275
|
+
tag: "m"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: "label",
|
|
279
|
+
tag: "l"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: "diff.addition",
|
|
283
|
+
tag: "da"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: "diff.deletion",
|
|
287
|
+
tag: "dd"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: "number",
|
|
291
|
+
tag: "n"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "text.literal",
|
|
295
|
+
tag: "tl"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "text.emphasis",
|
|
299
|
+
tag: "em"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "text.strong",
|
|
303
|
+
tag: "st"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
name: "text.uri",
|
|
307
|
+
tag: "tu"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "text.reference",
|
|
311
|
+
tag: "tr"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: "string.escape",
|
|
315
|
+
tag: "se",
|
|
316
|
+
parentTag: "s"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: "text.title",
|
|
320
|
+
tag: "tt"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "text.strikethrough",
|
|
324
|
+
tag: "ts"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "spell",
|
|
328
|
+
tag: ""
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
name: "embedded",
|
|
332
|
+
tag: "eb"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "error",
|
|
336
|
+
tag: "err"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: "namespace",
|
|
340
|
+
tag: "ns"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "include",
|
|
344
|
+
tag: "k",
|
|
345
|
+
parentTag: "k"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: "storageclass",
|
|
349
|
+
tag: "k",
|
|
350
|
+
parentTag: "k"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "repeat",
|
|
354
|
+
tag: "k",
|
|
355
|
+
parentTag: "k"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: "conditional",
|
|
359
|
+
tag: "k",
|
|
360
|
+
parentTag: "k"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "exception",
|
|
364
|
+
tag: "k",
|
|
365
|
+
parentTag: "k"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
name: "preproc",
|
|
369
|
+
tag: "pp"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
name: "none",
|
|
373
|
+
tag: ""
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
name: "character",
|
|
377
|
+
tag: "ch",
|
|
378
|
+
parentTag: "s"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "character.special",
|
|
382
|
+
tag: "ch",
|
|
383
|
+
parentTag: "ch"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
name: "variable.member",
|
|
387
|
+
tag: "pr",
|
|
388
|
+
parentTag: "v"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: "function.definition",
|
|
392
|
+
tag: "f",
|
|
393
|
+
parentTag: "f"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
name: "type.definition",
|
|
397
|
+
tag: "t",
|
|
398
|
+
parentTag: "t"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: "function.call",
|
|
402
|
+
tag: "f",
|
|
403
|
+
parentTag: "f"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
name: "keyword.modifier",
|
|
407
|
+
tag: "k",
|
|
408
|
+
parentTag: "k"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: "keyword.directive",
|
|
412
|
+
tag: "k",
|
|
413
|
+
parentTag: "k"
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
name: "string.regexp",
|
|
417
|
+
tag: "sr",
|
|
418
|
+
parentTag: "s"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
name: "nospell",
|
|
422
|
+
tag: ""
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
name: "float",
|
|
426
|
+
tag: "n",
|
|
427
|
+
parentTag: "n"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "boolean",
|
|
431
|
+
tag: "bo",
|
|
432
|
+
parentTag: "co"
|
|
433
|
+
}
|
|
434
|
+
];
|
|
435
|
+
function y(t, e) {
|
|
436
|
+
const a = [...e].sort((r, i) => r.start - i.start);
|
|
437
|
+
let n = "", s = 0;
|
|
438
|
+
for (const r of a) {
|
|
439
|
+
if (r.start < s) continue;
|
|
440
|
+
r.start > s && (n += f(t.slice(s, r.start)));
|
|
441
|
+
const i = L(r.capture), c = f(t.slice(r.start, r.end));
|
|
442
|
+
i ? n += `<a-${i}>${c}</a-${i}>` : n += c, s = r.end;
|
|
443
|
+
}
|
|
444
|
+
return s < t.length && (n += f(t.slice(s))), n;
|
|
445
|
+
}
|
|
446
|
+
function L(t) {
|
|
447
|
+
return t.startsWith("keyword") || t === "include" || t === "conditional" ? "k" : t.startsWith("function") || t.startsWith("method") ? "f" : t.startsWith("string") || t === "character" ? "s" : t.startsWith("comment") ? "c" : t.startsWith("type") ? "t" : t.startsWith("variable") ? "v" : t.startsWith("number") || t === "float" ? "n" : t.startsWith("operator") ? "o" : t.startsWith("punctuation") ? "p" : t.startsWith("tag") ? "tg" : t.startsWith("attribute") ? "at" : null;
|
|
448
|
+
}
|
|
449
|
+
function f(t) {
|
|
450
|
+
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
451
|
+
}
|
|
452
|
+
const v = {
|
|
101
453
|
manual: !1,
|
|
102
454
|
theme: "one-dark",
|
|
103
455
|
selector: "pre code",
|
|
@@ -106,158 +458,160 @@ const x = "2.4.7", $ = [
|
|
|
106
458
|
// Precise version from manifest
|
|
107
459
|
pluginsUrl: "",
|
|
108
460
|
// Empty means use bundled manifest
|
|
109
|
-
hostUrl: ""
|
|
461
|
+
hostUrl: "",
|
|
110
462
|
// Empty means use CDN based on version
|
|
463
|
+
resolveJs: ({ baseUrl: t, path: e }) => import(
|
|
464
|
+
/* @vite-ignore */
|
|
465
|
+
`${t}/${e}`
|
|
466
|
+
),
|
|
467
|
+
resolveWasm: ({ baseUrl: t, path: e }) => fetch(`${t}/${e}`)
|
|
111
468
|
};
|
|
112
|
-
let p = null,
|
|
113
|
-
const
|
|
114
|
-
let l = null,
|
|
469
|
+
let p = null, m = null, o = { ...v };
|
|
470
|
+
const h = /* @__PURE__ */ new Map(), T = new Set($);
|
|
471
|
+
let l = null, u = null;
|
|
115
472
|
async function _() {
|
|
116
473
|
if (o.pluginsUrl)
|
|
117
|
-
return
|
|
474
|
+
return u || (u = (async () => {
|
|
118
475
|
console.debug(`[arborium] Loading local plugins manifest from: ${o.pluginsUrl}`);
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
throw new Error(`Failed to load plugins.json: ${
|
|
122
|
-
l = await
|
|
123
|
-
})(),
|
|
476
|
+
const t = await fetch(o.pluginsUrl);
|
|
477
|
+
if (!t.ok)
|
|
478
|
+
throw new Error(`Failed to load plugins.json: ${t.status}`);
|
|
479
|
+
l = await t.json(), console.debug(`[arborium] Loaded local manifest with ${l?.entries.length} entries`);
|
|
480
|
+
})(), u);
|
|
124
481
|
}
|
|
125
|
-
function U(
|
|
482
|
+
function U(t) {
|
|
126
483
|
if (l) {
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
return
|
|
484
|
+
const s = l.entries.find((r) => r.language === t);
|
|
485
|
+
if (s)
|
|
486
|
+
return s.local_js.substring(0, s.local_js.lastIndexOf("/"));
|
|
130
487
|
}
|
|
131
|
-
const e = o.cdn,
|
|
488
|
+
const e = o.cdn, a = o.version;
|
|
132
489
|
let n;
|
|
133
|
-
return e === "jsdelivr" ? n = "https://cdn.jsdelivr.net/npm" : e === "unpkg" ? n = "https://unpkg.com" : n = e, `${n}/@arborium/${
|
|
490
|
+
return e === "jsdelivr" ? n = "https://cdn.jsdelivr.net/npm" : e === "unpkg" ? n = "https://unpkg.com" : n = e, `${n}/@arborium/${t}@${a}`;
|
|
134
491
|
}
|
|
135
|
-
async function w(
|
|
136
|
-
const e =
|
|
492
|
+
async function w(t) {
|
|
493
|
+
const e = h.get(t);
|
|
137
494
|
if (e)
|
|
138
|
-
return console.debug(`[arborium] Grammar '${
|
|
139
|
-
if (await _(), !
|
|
140
|
-
return console.debug(`[arborium] Grammar '${
|
|
495
|
+
return console.debug(`[arborium] Grammar '${t}' found in cache`), e;
|
|
496
|
+
if (await _(), !T.has(t) && !l?.entries.some((a) => a.language === t))
|
|
497
|
+
return console.debug(`[arborium] Grammar '${t}' not available`), null;
|
|
141
498
|
try {
|
|
142
|
-
const
|
|
143
|
-
console.debug(`[arborium] Loading grammar '${
|
|
144
|
-
const r = await
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
i !== s && console.warn(`[arborium] Language ID mismatch: expected '${s}', got '${i}'`);
|
|
151
|
-
const c = r.injection_languages(), y = {
|
|
152
|
-
languageId: s,
|
|
499
|
+
const a = U(t), n = o.resolveJs === v.resolveJs ? ` from ${a}/grammar.js` : "";
|
|
500
|
+
console.debug(`[arborium] Loading grammar '${t}'${n}`);
|
|
501
|
+
const s = await o.resolveJs({ language: t, baseUrl: a, path: "grammar.js" }), r = await o.resolveWasm({ language: t, baseUrl: a, path: "grammar_bg.wasm" });
|
|
502
|
+
await s.default({ module_or_path: r });
|
|
503
|
+
const i = s.language_id();
|
|
504
|
+
i !== t && console.warn(`[arborium] Language ID mismatch: expected '${t}', got '${i}'`);
|
|
505
|
+
const c = s.injection_languages(), k = {
|
|
506
|
+
languageId: t,
|
|
153
507
|
injectionLanguages: c,
|
|
154
|
-
module:
|
|
155
|
-
parse: (
|
|
156
|
-
const
|
|
508
|
+
module: s,
|
|
509
|
+
parse: (j) => {
|
|
510
|
+
const d = s.create_session();
|
|
157
511
|
try {
|
|
158
|
-
|
|
159
|
-
const
|
|
512
|
+
s.set_text(d, j);
|
|
513
|
+
const g = s.parse(d);
|
|
160
514
|
return {
|
|
161
|
-
spans:
|
|
162
|
-
injections:
|
|
515
|
+
spans: g.spans || [],
|
|
516
|
+
injections: g.injections || []
|
|
163
517
|
};
|
|
164
|
-
} catch (
|
|
165
|
-
return console.error("[arborium] Parse error:",
|
|
518
|
+
} catch (g) {
|
|
519
|
+
return console.error("[arborium] Parse error:", g), { spans: [], injections: [] };
|
|
166
520
|
} finally {
|
|
167
|
-
|
|
521
|
+
s.free_session(d);
|
|
168
522
|
}
|
|
169
523
|
}
|
|
170
524
|
};
|
|
171
|
-
return
|
|
172
|
-
} catch (
|
|
173
|
-
return console.error(`[arborium] Failed to load grammar '${
|
|
525
|
+
return h.set(t, k), console.debug(`[arborium] Grammar '${t}' loaded successfully`), k;
|
|
526
|
+
} catch (a) {
|
|
527
|
+
return console.error(`[arborium] Failed to load grammar '${t}':`, a), null;
|
|
174
528
|
}
|
|
175
529
|
}
|
|
176
|
-
const
|
|
177
|
-
let
|
|
178
|
-
function
|
|
530
|
+
const b = /* @__PURE__ */ new Map();
|
|
531
|
+
let E = 1;
|
|
532
|
+
function W() {
|
|
179
533
|
window.arboriumHost = {
|
|
180
534
|
/** Check if a language is available (sync) */
|
|
181
|
-
isLanguageAvailable(
|
|
182
|
-
return
|
|
535
|
+
isLanguageAvailable(t) {
|
|
536
|
+
return T.has(t) || h.has(t);
|
|
183
537
|
},
|
|
184
538
|
/** Load a grammar and return a handle (async) */
|
|
185
|
-
async loadGrammar(
|
|
186
|
-
const e = await w(
|
|
539
|
+
async loadGrammar(t) {
|
|
540
|
+
const e = await w(t);
|
|
187
541
|
if (!e) return 0;
|
|
188
|
-
for (const [n,
|
|
189
|
-
if (
|
|
190
|
-
const
|
|
191
|
-
return
|
|
542
|
+
for (const [n, s] of b)
|
|
543
|
+
if (s === e) return n;
|
|
544
|
+
const a = E++;
|
|
545
|
+
return b.set(a, e), a;
|
|
192
546
|
},
|
|
193
547
|
/** Parse text using a grammar handle (sync) */
|
|
194
|
-
parse(
|
|
195
|
-
const
|
|
196
|
-
return
|
|
548
|
+
parse(t, e) {
|
|
549
|
+
const a = b.get(t);
|
|
550
|
+
return a ? a.parse(e) : { spans: [], injections: [] };
|
|
197
551
|
}
|
|
198
552
|
};
|
|
199
553
|
}
|
|
200
554
|
function S() {
|
|
201
555
|
if (o.hostUrl)
|
|
202
556
|
return o.hostUrl;
|
|
203
|
-
const
|
|
204
|
-
let
|
|
205
|
-
|
|
557
|
+
const t = o.cdn, e = o.version;
|
|
558
|
+
let a;
|
|
559
|
+
t === "jsdelivr" ? a = "https://cdn.jsdelivr.net/npm" : t === "unpkg" ? a = "https://unpkg.com" : a = t;
|
|
206
560
|
const n = e === "latest" ? "" : `@${e}`;
|
|
207
|
-
return `${
|
|
561
|
+
return `${a}/@arborium/arborium${n}/dist`;
|
|
208
562
|
}
|
|
209
|
-
async function
|
|
210
|
-
return p ||
|
|
211
|
-
|
|
212
|
-
const
|
|
563
|
+
async function q() {
|
|
564
|
+
return p || m || (m = (async () => {
|
|
565
|
+
W();
|
|
566
|
+
const t = S(), e = `${t}/arborium_host.js`, a = `${t}/arborium_host_bg.wasm`;
|
|
213
567
|
console.debug(`[arborium] Loading host from ${e}`);
|
|
214
568
|
try {
|
|
215
569
|
const n = await import(
|
|
216
570
|
/* @vite-ignore */
|
|
217
571
|
e
|
|
218
572
|
);
|
|
219
|
-
return await n.default(
|
|
573
|
+
return await n.default(a), p = {
|
|
220
574
|
highlight: n.highlight,
|
|
221
575
|
isLanguageAvailable: n.isLanguageAvailable
|
|
222
576
|
}, console.debug("[arborium] Host loaded successfully"), p;
|
|
223
577
|
} catch (n) {
|
|
224
578
|
return console.error("[arborium] Failed to load host:", n), null;
|
|
225
579
|
}
|
|
226
|
-
})(),
|
|
580
|
+
})(), m);
|
|
227
581
|
}
|
|
228
|
-
async function
|
|
229
|
-
const n = await
|
|
582
|
+
async function H(t, e, a) {
|
|
583
|
+
const n = await q();
|
|
230
584
|
if (n)
|
|
231
585
|
try {
|
|
232
|
-
return n.highlight(
|
|
586
|
+
return n.highlight(t, e);
|
|
233
587
|
} catch (i) {
|
|
234
588
|
console.warn("Host highlight failed, falling back to JS:", i);
|
|
235
589
|
}
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
238
|
-
return
|
|
239
|
-
const r =
|
|
240
|
-
return
|
|
590
|
+
const s = await w(t);
|
|
591
|
+
if (!s)
|
|
592
|
+
return f(e);
|
|
593
|
+
const r = s.parse(e);
|
|
594
|
+
return y(e, r.spans);
|
|
241
595
|
}
|
|
242
|
-
async function
|
|
243
|
-
const
|
|
244
|
-
if (!
|
|
245
|
-
const { module: n } =
|
|
596
|
+
async function M(t, e) {
|
|
597
|
+
const a = await w(t);
|
|
598
|
+
if (!a) return null;
|
|
599
|
+
const { module: n } = a;
|
|
246
600
|
return {
|
|
247
|
-
languageId: () =>
|
|
248
|
-
injectionLanguages: () =>
|
|
249
|
-
highlight: async (
|
|
250
|
-
const r =
|
|
251
|
-
return
|
|
601
|
+
languageId: () => a.languageId,
|
|
602
|
+
injectionLanguages: () => a.injectionLanguages,
|
|
603
|
+
highlight: async (s) => {
|
|
604
|
+
const r = a.parse(s);
|
|
605
|
+
return y(s, r.spans);
|
|
252
606
|
},
|
|
253
|
-
parse: (
|
|
607
|
+
parse: (s) => a.parse(s),
|
|
254
608
|
createSession: () => {
|
|
255
|
-
const
|
|
609
|
+
const s = n.create_session();
|
|
256
610
|
return {
|
|
257
|
-
setText: (r) => n.set_text(
|
|
611
|
+
setText: (r) => n.set_text(s, r),
|
|
258
612
|
parse: () => {
|
|
259
613
|
try {
|
|
260
|
-
const r = n.parse(
|
|
614
|
+
const r = n.parse(s);
|
|
261
615
|
return {
|
|
262
616
|
spans: r.spans || [],
|
|
263
617
|
injections: r.injections || []
|
|
@@ -266,35 +620,18 @@ async function H(s, e) {
|
|
|
266
620
|
return console.error("[arborium] Session parse error:", r), { spans: [], injections: [] };
|
|
267
621
|
}
|
|
268
622
|
},
|
|
269
|
-
cancel: () => n.cancel(
|
|
270
|
-
free: () => n.free_session(
|
|
623
|
+
cancel: () => n.cancel(s),
|
|
624
|
+
free: () => n.free_session(s)
|
|
271
625
|
};
|
|
272
626
|
},
|
|
273
627
|
dispose: () => {
|
|
274
628
|
}
|
|
275
629
|
};
|
|
276
630
|
}
|
|
277
|
-
function
|
|
278
|
-
|
|
279
|
-
let n = "", a = 0;
|
|
280
|
-
for (const r of t) {
|
|
281
|
-
if (r.start < a) continue;
|
|
282
|
-
r.start > a && (n += h(s.slice(a, r.start)));
|
|
283
|
-
const i = C(r.capture), c = h(s.slice(r.start, r.end));
|
|
284
|
-
i ? n += `<a-${i}>${c}</a-${i}>` : n += c, a = r.end;
|
|
285
|
-
}
|
|
286
|
-
return a < s.length && (n += h(s.slice(a))), n;
|
|
287
|
-
}
|
|
288
|
-
function C(s) {
|
|
289
|
-
return s.startsWith("keyword") || s === "include" || s === "conditional" ? "k" : s.startsWith("function") || s.startsWith("method") ? "f" : s.startsWith("string") || s === "character" ? "s" : s.startsWith("comment") ? "c" : s.startsWith("type") ? "t" : s.startsWith("variable") ? "v" : s.startsWith("number") || s === "float" ? "n" : s.startsWith("operator") ? "o" : s.startsWith("punctuation") ? "p" : s.startsWith("tag") ? "tg" : s.startsWith("attribute") ? "at" : null;
|
|
290
|
-
}
|
|
291
|
-
function h(s) {
|
|
292
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
293
|
-
}
|
|
294
|
-
function M(s) {
|
|
295
|
-
return s ? { ...o, ...s } : { ...o };
|
|
631
|
+
function P(t) {
|
|
632
|
+
return t ? { ...o, ...t } : { ...o };
|
|
296
633
|
}
|
|
297
|
-
const
|
|
634
|
+
const C = [
|
|
298
635
|
[/^#!.*\bpython[23]?\b/, "python"],
|
|
299
636
|
[/^#!.*\bnode\b/, "javascript"],
|
|
300
637
|
[/^#!.*\bdeno\b/, "typescript"],
|
|
@@ -307,7 +644,7 @@ const I = [
|
|
|
307
644
|
[/^#!.*\bsh\b/, "bash"],
|
|
308
645
|
[/^#!.*\blua\b/, "lua"],
|
|
309
646
|
[/^#!.*\bawk\b/, "awk"]
|
|
310
|
-
],
|
|
647
|
+
], I = [
|
|
311
648
|
// Rust - distinctive keywords
|
|
312
649
|
[/\b(fn|impl|trait|pub\s+fn|let\s+mut|&mut|->)\b/, "rust"],
|
|
313
650
|
// Go - distinctive keywords
|
|
@@ -367,22 +704,22 @@ const I = [
|
|
|
367
704
|
// Zig
|
|
368
705
|
[/\b(pub\s+fn|const\s+\w+\s*=|@import\(|comptime)\b/, "zig"]
|
|
369
706
|
];
|
|
370
|
-
function
|
|
371
|
-
const e =
|
|
707
|
+
function A(t) {
|
|
708
|
+
const e = t.split(`
|
|
372
709
|
`)[0];
|
|
373
|
-
for (const [
|
|
374
|
-
if (
|
|
710
|
+
for (const [a, n] of C)
|
|
711
|
+
if (a.test(e))
|
|
375
712
|
return n;
|
|
376
|
-
for (const [
|
|
377
|
-
if (
|
|
713
|
+
for (const [a, n] of I)
|
|
714
|
+
if (a.test(t))
|
|
378
715
|
return n;
|
|
379
716
|
return null;
|
|
380
717
|
}
|
|
381
|
-
function
|
|
382
|
-
const e =
|
|
718
|
+
function G(t) {
|
|
719
|
+
const e = t.match(/\blanguage-(\w+)\b/);
|
|
383
720
|
if (e) return e[1];
|
|
384
|
-
const
|
|
385
|
-
if (
|
|
721
|
+
const a = t.match(/\blang-(\w+)\b/);
|
|
722
|
+
if (a) return a[1];
|
|
386
723
|
const n = /* @__PURE__ */ new Set([
|
|
387
724
|
"rust",
|
|
388
725
|
"javascript",
|
|
@@ -419,12 +756,12 @@ function A(s) {
|
|
|
419
756
|
"console",
|
|
420
757
|
"sh"
|
|
421
758
|
]);
|
|
422
|
-
for (const
|
|
423
|
-
if (n.has(
|
|
424
|
-
return
|
|
759
|
+
for (const s of t.split(/\s+/))
|
|
760
|
+
if (n.has(s.toLowerCase()))
|
|
761
|
+
return s.toLowerCase();
|
|
425
762
|
return null;
|
|
426
763
|
}
|
|
427
|
-
function
|
|
764
|
+
function F(t) {
|
|
428
765
|
const e = {
|
|
429
766
|
js: "javascript",
|
|
430
767
|
ts: "typescript",
|
|
@@ -445,18 +782,19 @@ function G(s) {
|
|
|
445
782
|
plaintext: "text",
|
|
446
783
|
plain: "text",
|
|
447
784
|
txt: "text"
|
|
448
|
-
},
|
|
449
|
-
return e[
|
|
785
|
+
}, a = t.toLowerCase();
|
|
786
|
+
return e[a] || a;
|
|
450
787
|
}
|
|
451
788
|
export {
|
|
452
789
|
$ as availableLanguages,
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
790
|
+
A as detectLanguage,
|
|
791
|
+
G as extractLanguageFromClass,
|
|
792
|
+
P as getConfig,
|
|
793
|
+
H as highlight,
|
|
794
|
+
R as highlights,
|
|
795
|
+
M as loadGrammar,
|
|
796
|
+
F as normalizeLanguage,
|
|
459
797
|
x as pluginVersion,
|
|
460
|
-
|
|
798
|
+
y as spansToHtml
|
|
461
799
|
};
|
|
462
800
|
//# sourceMappingURL=arborium.js.map
|