@arborium/arborium 2.8.0 → 2.10.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.iife.js +2 -2
- package/dist/arborium.iife.js.map +1 -1
- package/dist/arborium.js +267 -238
- package/dist/arborium.js.map +1 -1
- package/dist/arborium_host.js +3 -3
- package/dist/arborium_host_bg.wasm +0 -0
- package/dist/plugins-manifest.d.ts +1 -1
- package/dist/themes/alabaster.css +41 -8
- package/dist/themes/ayu-dark.css +40 -9
- package/dist/themes/ayu-light.css +40 -9
- package/dist/themes/base-rustdoc.css +39 -4
- package/dist/themes/base.css +156 -16
- package/dist/themes/catppuccin-frappe.css +41 -8
- package/dist/themes/catppuccin-latte.css +41 -8
- package/dist/themes/catppuccin-macchiato.css +41 -8
- package/dist/themes/catppuccin-mocha.css +41 -8
- package/dist/themes/cobalt2.css +42 -8
- package/dist/themes/dayfox.css +41 -8
- package/dist/themes/desert256.css +61 -9
- package/dist/themes/dracula.css +40 -7
- package/dist/themes/ef-melissa-dark.css +42 -8
- package/dist/themes/github-dark.css +40 -7
- package/dist/themes/github-light.css +40 -7
- package/dist/themes/gruvbox-dark.css +41 -8
- package/dist/themes/gruvbox-light.css +41 -8
- package/dist/themes/kanagawa-dragon.css +40 -7
- package/dist/themes/light-owl.css +63 -9
- package/dist/themes/lucius-light.css +41 -7
- package/dist/themes/melange-dark.css +41 -7
- package/dist/themes/melange-light.css +41 -7
- package/dist/themes/monokai.css +40 -7
- package/dist/themes/nord.css +40 -7
- package/dist/themes/one-dark.css +41 -8
- package/dist/themes/rose-pine-moon.css +42 -8
- package/dist/themes/rustdoc-ayu.css +39 -6
- package/dist/themes/rustdoc-dark.css +39 -6
- package/dist/themes/rustdoc-light.css +39 -6
- package/dist/themes/solarized-dark.css +42 -8
- package/dist/themes/solarized-light.css +42 -8
- package/dist/themes/tokyo-night.css +41 -8
- package/dist/themes/zenburn.css +41 -8
- package/dist/utils.d.ts +11 -0
- package/package.json +1 -1
package/dist/arborium.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const U = "2.10.0", _ = [
|
|
2
2
|
"ada",
|
|
3
3
|
"agda",
|
|
4
4
|
"asciidoc",
|
|
@@ -10,6 +10,8 @@ const L = "2.8.0", _ = [
|
|
|
10
10
|
"c-sharp",
|
|
11
11
|
"caddy",
|
|
12
12
|
"capnp",
|
|
13
|
+
"cedar",
|
|
14
|
+
"cedarschema",
|
|
13
15
|
"clojure",
|
|
14
16
|
"cmake",
|
|
15
17
|
"cobol",
|
|
@@ -98,7 +100,7 @@ const L = "2.8.0", _ = [
|
|
|
98
100
|
"yuri",
|
|
99
101
|
"zig",
|
|
100
102
|
"zsh"
|
|
101
|
-
],
|
|
103
|
+
], H = [
|
|
102
104
|
{
|
|
103
105
|
name: "attribute",
|
|
104
106
|
tag: "at"
|
|
@@ -109,8 +111,8 @@ const L = "2.8.0", _ = [
|
|
|
109
111
|
},
|
|
110
112
|
{
|
|
111
113
|
name: "constant.builtin",
|
|
112
|
-
tag: "
|
|
113
|
-
parentTag: "
|
|
114
|
+
tag: "cb",
|
|
115
|
+
parentTag: "constant"
|
|
114
116
|
},
|
|
115
117
|
{
|
|
116
118
|
name: "constructor",
|
|
@@ -119,7 +121,7 @@ const L = "2.8.0", _ = [
|
|
|
119
121
|
{
|
|
120
122
|
name: "function.builtin",
|
|
121
123
|
tag: "fb",
|
|
122
|
-
parentTag: "
|
|
124
|
+
parentTag: "function"
|
|
123
125
|
},
|
|
124
126
|
{
|
|
125
127
|
name: "function",
|
|
@@ -127,8 +129,8 @@ const L = "2.8.0", _ = [
|
|
|
127
129
|
},
|
|
128
130
|
{
|
|
129
131
|
name: "function.method",
|
|
130
|
-
tag: "
|
|
131
|
-
parentTag: "
|
|
132
|
+
tag: "fm",
|
|
133
|
+
parentTag: "function"
|
|
132
134
|
},
|
|
133
135
|
{
|
|
134
136
|
name: "keyword",
|
|
@@ -136,53 +138,53 @@ const L = "2.8.0", _ = [
|
|
|
136
138
|
},
|
|
137
139
|
{
|
|
138
140
|
name: "keyword.conditional",
|
|
139
|
-
tag: "
|
|
140
|
-
parentTag: "
|
|
141
|
+
tag: "kc",
|
|
142
|
+
parentTag: "keyword"
|
|
141
143
|
},
|
|
142
144
|
{
|
|
143
145
|
name: "keyword.coroutine",
|
|
144
|
-
tag: "
|
|
145
|
-
parentTag: "
|
|
146
|
+
tag: "ko",
|
|
147
|
+
parentTag: "keyword"
|
|
146
148
|
},
|
|
147
149
|
{
|
|
148
150
|
name: "keyword.debug",
|
|
149
|
-
tag: "
|
|
150
|
-
parentTag: "
|
|
151
|
+
tag: "kd",
|
|
152
|
+
parentTag: "keyword"
|
|
151
153
|
},
|
|
152
154
|
{
|
|
153
155
|
name: "keyword.exception",
|
|
154
|
-
tag: "
|
|
155
|
-
parentTag: "
|
|
156
|
+
tag: "ke",
|
|
157
|
+
parentTag: "keyword"
|
|
156
158
|
},
|
|
157
159
|
{
|
|
158
160
|
name: "keyword.function",
|
|
159
|
-
tag: "
|
|
160
|
-
parentTag: "
|
|
161
|
+
tag: "kf",
|
|
162
|
+
parentTag: "keyword"
|
|
161
163
|
},
|
|
162
164
|
{
|
|
163
165
|
name: "keyword.import",
|
|
164
|
-
tag: "
|
|
165
|
-
parentTag: "
|
|
166
|
+
tag: "ki",
|
|
167
|
+
parentTag: "keyword"
|
|
166
168
|
},
|
|
167
169
|
{
|
|
168
170
|
name: "keyword.operator",
|
|
169
|
-
tag: "
|
|
170
|
-
parentTag: "
|
|
171
|
+
tag: "kp",
|
|
172
|
+
parentTag: "keyword"
|
|
171
173
|
},
|
|
172
174
|
{
|
|
173
175
|
name: "keyword.repeat",
|
|
174
|
-
tag: "
|
|
175
|
-
parentTag: "
|
|
176
|
+
tag: "kr",
|
|
177
|
+
parentTag: "keyword"
|
|
176
178
|
},
|
|
177
179
|
{
|
|
178
180
|
name: "keyword.return",
|
|
179
|
-
tag: "
|
|
180
|
-
parentTag: "
|
|
181
|
+
tag: "kt",
|
|
182
|
+
parentTag: "keyword"
|
|
181
183
|
},
|
|
182
184
|
{
|
|
183
185
|
name: "keyword.type",
|
|
184
|
-
tag: "
|
|
185
|
-
parentTag: "
|
|
186
|
+
tag: "ky",
|
|
187
|
+
parentTag: "keyword"
|
|
186
188
|
},
|
|
187
189
|
{
|
|
188
190
|
name: "operator",
|
|
@@ -198,18 +200,18 @@ const L = "2.8.0", _ = [
|
|
|
198
200
|
},
|
|
199
201
|
{
|
|
200
202
|
name: "punctuation.bracket",
|
|
201
|
-
tag: "
|
|
202
|
-
parentTag: "
|
|
203
|
+
tag: "pb",
|
|
204
|
+
parentTag: "punctuation"
|
|
203
205
|
},
|
|
204
206
|
{
|
|
205
207
|
name: "punctuation.delimiter",
|
|
206
|
-
tag: "
|
|
207
|
-
parentTag: "
|
|
208
|
+
tag: "pd",
|
|
209
|
+
parentTag: "punctuation"
|
|
208
210
|
},
|
|
209
211
|
{
|
|
210
212
|
name: "punctuation.special",
|
|
211
|
-
tag: "
|
|
212
|
-
parentTag: "
|
|
213
|
+
tag: "ps",
|
|
214
|
+
parentTag: "punctuation"
|
|
213
215
|
},
|
|
214
216
|
{
|
|
215
217
|
name: "string",
|
|
@@ -217,8 +219,8 @@ const L = "2.8.0", _ = [
|
|
|
217
219
|
},
|
|
218
220
|
{
|
|
219
221
|
name: "string.special",
|
|
220
|
-
tag: "
|
|
221
|
-
parentTag: "
|
|
222
|
+
tag: "ss",
|
|
223
|
+
parentTag: "string"
|
|
222
224
|
},
|
|
223
225
|
{
|
|
224
226
|
name: "tag",
|
|
@@ -226,13 +228,13 @@ const L = "2.8.0", _ = [
|
|
|
226
228
|
},
|
|
227
229
|
{
|
|
228
230
|
name: "tag.delimiter",
|
|
229
|
-
tag: "
|
|
230
|
-
parentTag: "
|
|
231
|
+
tag: "td",
|
|
232
|
+
parentTag: "tag"
|
|
231
233
|
},
|
|
232
234
|
{
|
|
233
235
|
name: "tag.error",
|
|
234
|
-
tag: "
|
|
235
|
-
parentTag: "
|
|
236
|
+
tag: "te",
|
|
237
|
+
parentTag: "tag"
|
|
236
238
|
},
|
|
237
239
|
{
|
|
238
240
|
name: "type",
|
|
@@ -240,13 +242,13 @@ const L = "2.8.0", _ = [
|
|
|
240
242
|
},
|
|
241
243
|
{
|
|
242
244
|
name: "type.builtin",
|
|
243
|
-
tag: "
|
|
244
|
-
parentTag: "
|
|
245
|
+
tag: "tb",
|
|
246
|
+
parentTag: "type"
|
|
245
247
|
},
|
|
246
248
|
{
|
|
247
249
|
name: "type.qualifier",
|
|
248
|
-
tag: "
|
|
249
|
-
parentTag: "
|
|
250
|
+
tag: "tq",
|
|
251
|
+
parentTag: "type"
|
|
250
252
|
},
|
|
251
253
|
{
|
|
252
254
|
name: "variable",
|
|
@@ -254,13 +256,13 @@ const L = "2.8.0", _ = [
|
|
|
254
256
|
},
|
|
255
257
|
{
|
|
256
258
|
name: "variable.builtin",
|
|
257
|
-
tag: "
|
|
258
|
-
parentTag: "
|
|
259
|
+
tag: "vb",
|
|
260
|
+
parentTag: "variable"
|
|
259
261
|
},
|
|
260
262
|
{
|
|
261
263
|
name: "variable.parameter",
|
|
262
|
-
tag: "
|
|
263
|
-
parentTag: "
|
|
264
|
+
tag: "vp",
|
|
265
|
+
parentTag: "variable"
|
|
264
266
|
},
|
|
265
267
|
{
|
|
266
268
|
name: "comment",
|
|
@@ -268,8 +270,8 @@ const L = "2.8.0", _ = [
|
|
|
268
270
|
},
|
|
269
271
|
{
|
|
270
272
|
name: "comment.documentation",
|
|
271
|
-
tag: "
|
|
272
|
-
parentTag: "
|
|
273
|
+
tag: "cd",
|
|
274
|
+
parentTag: "comment"
|
|
273
275
|
},
|
|
274
276
|
{
|
|
275
277
|
name: "macro",
|
|
@@ -314,7 +316,7 @@ const L = "2.8.0", _ = [
|
|
|
314
316
|
{
|
|
315
317
|
name: "string.escape",
|
|
316
318
|
tag: "se",
|
|
317
|
-
parentTag: "
|
|
319
|
+
parentTag: "string"
|
|
318
320
|
},
|
|
319
321
|
{
|
|
320
322
|
name: "text.title",
|
|
@@ -322,11 +324,11 @@ const L = "2.8.0", _ = [
|
|
|
322
324
|
},
|
|
323
325
|
{
|
|
324
326
|
name: "text.strikethrough",
|
|
325
|
-
tag: "
|
|
327
|
+
tag: "tx"
|
|
326
328
|
},
|
|
327
329
|
{
|
|
328
330
|
name: "spell",
|
|
329
|
-
tag: ""
|
|
331
|
+
tag: "sp"
|
|
330
332
|
},
|
|
331
333
|
{
|
|
332
334
|
name: "embedded",
|
|
@@ -334,7 +336,7 @@ const L = "2.8.0", _ = [
|
|
|
334
336
|
},
|
|
335
337
|
{
|
|
336
338
|
name: "error",
|
|
337
|
-
tag: "
|
|
339
|
+
tag: "er"
|
|
338
340
|
},
|
|
339
341
|
{
|
|
340
342
|
name: "namespace",
|
|
@@ -342,32 +344,33 @@ const L = "2.8.0", _ = [
|
|
|
342
344
|
},
|
|
343
345
|
{
|
|
344
346
|
name: "include",
|
|
345
|
-
tag: "
|
|
346
|
-
parentTag: "
|
|
347
|
+
tag: "in",
|
|
348
|
+
parentTag: "keyword"
|
|
347
349
|
},
|
|
348
350
|
{
|
|
349
351
|
name: "storageclass",
|
|
350
|
-
tag: "
|
|
351
|
-
parentTag: "
|
|
352
|
+
tag: "sc",
|
|
353
|
+
parentTag: "keyword"
|
|
352
354
|
},
|
|
353
355
|
{
|
|
354
356
|
name: "repeat",
|
|
355
|
-
tag: "
|
|
356
|
-
parentTag: "
|
|
357
|
+
tag: "rp",
|
|
358
|
+
parentTag: "keyword"
|
|
357
359
|
},
|
|
358
360
|
{
|
|
359
361
|
name: "conditional",
|
|
360
|
-
tag: "
|
|
361
|
-
parentTag: "
|
|
362
|
+
tag: "cn",
|
|
363
|
+
parentTag: "keyword"
|
|
362
364
|
},
|
|
363
365
|
{
|
|
364
366
|
name: "exception",
|
|
365
|
-
tag: "
|
|
366
|
-
parentTag: "
|
|
367
|
+
tag: "ex",
|
|
368
|
+
parentTag: "keyword"
|
|
367
369
|
},
|
|
368
370
|
{
|
|
369
371
|
name: "preproc",
|
|
370
|
-
tag: "pp"
|
|
372
|
+
tag: "pp",
|
|
373
|
+
parentTag: "keyword"
|
|
371
374
|
},
|
|
372
375
|
{
|
|
373
376
|
name: "none",
|
|
@@ -376,47 +379,47 @@ const L = "2.8.0", _ = [
|
|
|
376
379
|
{
|
|
377
380
|
name: "character",
|
|
378
381
|
tag: "ch",
|
|
379
|
-
parentTag: "
|
|
382
|
+
parentTag: "string"
|
|
380
383
|
},
|
|
381
384
|
{
|
|
382
385
|
name: "character.special",
|
|
383
|
-
tag: "
|
|
384
|
-
parentTag: "
|
|
386
|
+
tag: "cs",
|
|
387
|
+
parentTag: "string"
|
|
385
388
|
},
|
|
386
389
|
{
|
|
387
390
|
name: "variable.member",
|
|
388
|
-
tag: "
|
|
389
|
-
parentTag: "
|
|
391
|
+
tag: "vm",
|
|
392
|
+
parentTag: "variable"
|
|
390
393
|
},
|
|
391
394
|
{
|
|
392
395
|
name: "function.definition",
|
|
393
|
-
tag: "
|
|
394
|
-
parentTag: "
|
|
396
|
+
tag: "fd",
|
|
397
|
+
parentTag: "function"
|
|
395
398
|
},
|
|
396
399
|
{
|
|
397
400
|
name: "type.definition",
|
|
398
|
-
tag: "
|
|
399
|
-
parentTag: "
|
|
401
|
+
tag: "tf",
|
|
402
|
+
parentTag: "type"
|
|
400
403
|
},
|
|
401
404
|
{
|
|
402
405
|
name: "function.call",
|
|
403
|
-
tag: "
|
|
404
|
-
parentTag: "
|
|
406
|
+
tag: "fc",
|
|
407
|
+
parentTag: "function"
|
|
405
408
|
},
|
|
406
409
|
{
|
|
407
410
|
name: "keyword.modifier",
|
|
408
|
-
tag: "
|
|
409
|
-
parentTag: "
|
|
411
|
+
tag: "km",
|
|
412
|
+
parentTag: "keyword"
|
|
410
413
|
},
|
|
411
414
|
{
|
|
412
415
|
name: "keyword.directive",
|
|
413
|
-
tag: "
|
|
414
|
-
parentTag: "
|
|
416
|
+
tag: "dr",
|
|
417
|
+
parentTag: "keyword"
|
|
415
418
|
},
|
|
416
419
|
{
|
|
417
420
|
name: "string.regexp",
|
|
418
|
-
tag: "
|
|
419
|
-
parentTag: "
|
|
421
|
+
tag: "rx",
|
|
422
|
+
parentTag: "string"
|
|
420
423
|
},
|
|
421
424
|
{
|
|
422
425
|
name: "nospell",
|
|
@@ -424,195 +427,221 @@ const L = "2.8.0", _ = [
|
|
|
424
427
|
},
|
|
425
428
|
{
|
|
426
429
|
name: "float",
|
|
427
|
-
tag: "n"
|
|
428
|
-
parentTag: "n"
|
|
430
|
+
tag: "n"
|
|
429
431
|
},
|
|
430
432
|
{
|
|
431
433
|
name: "boolean",
|
|
432
|
-
tag: "
|
|
433
|
-
parentTag: "co"
|
|
434
|
+
tag: "cb"
|
|
434
435
|
}
|
|
435
|
-
];
|
|
436
|
-
function
|
|
437
|
-
const
|
|
438
|
-
let
|
|
439
|
-
for (const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
436
|
+
], T = new TextEncoder();
|
|
437
|
+
function E(t) {
|
|
438
|
+
const e = T.encode(t), a = new Uint32Array(e.length + 1);
|
|
439
|
+
let s = 0, n = 0;
|
|
440
|
+
for (const r of t) {
|
|
441
|
+
a[s] = n;
|
|
442
|
+
const o = T.encode(r).length;
|
|
443
|
+
for (let i = 1; i < o; i++)
|
|
444
|
+
a[s + i] = n;
|
|
445
|
+
s += o, n += r.codePointAt(0) >= 65536 ? 2 : 1;
|
|
444
446
|
}
|
|
445
|
-
return s
|
|
447
|
+
return a[s] = n, a;
|
|
446
448
|
}
|
|
447
|
-
function
|
|
449
|
+
function x(t, e) {
|
|
450
|
+
const a = E(t), n = [...e.map((i) => ({
|
|
451
|
+
...i,
|
|
452
|
+
start: a[i.start] ?? i.start,
|
|
453
|
+
end: a[i.end] ?? i.end
|
|
454
|
+
}))].sort((i, l) => i.start - l.start);
|
|
455
|
+
let r = "", o = 0;
|
|
456
|
+
for (const i of n) {
|
|
457
|
+
if (i.start < o) continue;
|
|
458
|
+
i.start > o && (r += f(t.slice(o, i.start)));
|
|
459
|
+
const l = S(i.capture), m = f(t.slice(i.start, i.end));
|
|
460
|
+
l ? r += `<a-${l}>${m}</a-${l}>` : r += m, o = i.end;
|
|
461
|
+
}
|
|
462
|
+
return o < t.length && (r += f(t.slice(o))), r;
|
|
463
|
+
}
|
|
464
|
+
function S(t) {
|
|
448
465
|
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;
|
|
449
466
|
}
|
|
450
|
-
function
|
|
467
|
+
function f(t) {
|
|
451
468
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
452
469
|
}
|
|
453
|
-
const
|
|
470
|
+
const j = {
|
|
454
471
|
manual: !1,
|
|
455
472
|
theme: "one-dark",
|
|
456
473
|
selector: "pre code",
|
|
457
474
|
cdn: "jsdelivr",
|
|
458
|
-
version:
|
|
475
|
+
version: U,
|
|
459
476
|
// Precise version from manifest
|
|
460
477
|
pluginsUrl: "",
|
|
461
478
|
// Empty means use bundled manifest
|
|
462
479
|
hostUrl: "",
|
|
463
480
|
// Empty means use CDN based on version
|
|
464
|
-
resolveJs: ({ baseUrl: t, path:
|
|
481
|
+
resolveJs: ({ baseUrl: t, path: e }) => import(
|
|
465
482
|
/* @vite-ignore */
|
|
466
|
-
`${t}/${
|
|
483
|
+
`${t}/${e}`
|
|
467
484
|
),
|
|
468
|
-
resolveWasm: ({ baseUrl: t, path:
|
|
485
|
+
resolveWasm: ({ baseUrl: t, path: e }) => fetch(`${t}/${e}`)
|
|
469
486
|
};
|
|
470
|
-
let
|
|
471
|
-
const
|
|
472
|
-
let
|
|
473
|
-
async function
|
|
487
|
+
let u = null, g = null, b = { ...j };
|
|
488
|
+
const k = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map(), $ = new Set(_);
|
|
489
|
+
let c = null, d = null;
|
|
490
|
+
async function W(t) {
|
|
474
491
|
if (t.pluginsUrl)
|
|
475
|
-
return
|
|
492
|
+
return d || (d = (async () => {
|
|
476
493
|
console.debug(`[arborium] Loading local plugins manifest from: ${t.pluginsUrl}`);
|
|
477
|
-
const
|
|
478
|
-
if (!
|
|
479
|
-
throw new Error(`Failed to load plugins.json: ${
|
|
480
|
-
|
|
481
|
-
})(),
|
|
494
|
+
const e = await fetch(t.pluginsUrl);
|
|
495
|
+
if (!e.ok)
|
|
496
|
+
throw new Error(`Failed to load plugins.json: ${e.status}`);
|
|
497
|
+
c = await e.json(), console.debug(`[arborium] Loaded local manifest with ${c?.entries.length} entries`);
|
|
498
|
+
})(), d);
|
|
482
499
|
}
|
|
483
|
-
function
|
|
484
|
-
if (
|
|
485
|
-
const
|
|
486
|
-
if (
|
|
487
|
-
return
|
|
500
|
+
function C(t, e) {
|
|
501
|
+
if (c) {
|
|
502
|
+
const r = c.entries.find((o) => o.language === t);
|
|
503
|
+
if (r)
|
|
504
|
+
return r.local_js.substring(0, r.local_js.lastIndexOf("/"));
|
|
488
505
|
}
|
|
489
|
-
const
|
|
490
|
-
let
|
|
491
|
-
return
|
|
506
|
+
const a = e.cdn, s = e.version;
|
|
507
|
+
let n;
|
|
508
|
+
return a === "jsdelivr" ? n = "https://cdn.jsdelivr.net/npm" : a === "unpkg" ? n = "https://unpkg.com" : n = a, `${n}/@arborium/${t}@${s}`;
|
|
492
509
|
}
|
|
493
|
-
async function
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
return console.debug(`[arborium] Grammar '${t}' found in cache`),
|
|
497
|
-
|
|
510
|
+
async function v(t, e) {
|
|
511
|
+
const a = k.get(t);
|
|
512
|
+
if (a)
|
|
513
|
+
return console.debug(`[arborium] Grammar '${t}' found in cache`), a;
|
|
514
|
+
const s = w.get(t);
|
|
515
|
+
if (s)
|
|
516
|
+
return console.debug(`[arborium] Grammar '${t}' already loading, waiting...`), s;
|
|
517
|
+
const n = I(t, e);
|
|
518
|
+
w.set(t, n);
|
|
519
|
+
try {
|
|
520
|
+
return await n;
|
|
521
|
+
} finally {
|
|
522
|
+
w.delete(t);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
async function I(t, e) {
|
|
526
|
+
if (await W(e), !$.has(t) && !c?.entries.some((a) => a.language === t))
|
|
498
527
|
return console.debug(`[arborium] Grammar '${t}' not available`), null;
|
|
499
528
|
try {
|
|
500
|
-
const
|
|
529
|
+
const a = C(t, e), s = e.resolveJs === j.resolveJs ? ` from ${a}/grammar.js` : "";
|
|
501
530
|
console.debug(`[arborium] Loading grammar '${t}'${s}`);
|
|
502
|
-
const n = await
|
|
503
|
-
await n.default({ module_or_path:
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
const
|
|
531
|
+
const n = await e.resolveJs({ language: t, baseUrl: a, path: "grammar.js" }), r = await e.resolveWasm({ language: t, baseUrl: a, path: "grammar_bg.wasm" });
|
|
532
|
+
await n.default({ module_or_path: r });
|
|
533
|
+
const o = n.language_id();
|
|
534
|
+
o !== t && console.warn(`[arborium] Language ID mismatch: expected '${t}', got '${o}'`);
|
|
535
|
+
const i = n.injection_languages(), l = {
|
|
507
536
|
languageId: t,
|
|
508
|
-
injectionLanguages:
|
|
537
|
+
injectionLanguages: i,
|
|
509
538
|
module: n,
|
|
510
|
-
parse: (
|
|
511
|
-
const
|
|
539
|
+
parse: (m) => {
|
|
540
|
+
const h = n.create_session();
|
|
512
541
|
try {
|
|
513
|
-
n.set_text(
|
|
514
|
-
const
|
|
542
|
+
n.set_text(h, m);
|
|
543
|
+
const p = n.parse(h);
|
|
515
544
|
return {
|
|
516
|
-
spans:
|
|
517
|
-
injections:
|
|
545
|
+
spans: p.spans || [],
|
|
546
|
+
injections: p.injections || []
|
|
518
547
|
};
|
|
519
|
-
} catch (
|
|
520
|
-
return console.error("[arborium] Parse error:",
|
|
548
|
+
} catch (p) {
|
|
549
|
+
return console.error("[arborium] Parse error:", p), { spans: [], injections: [] };
|
|
521
550
|
} finally {
|
|
522
|
-
n.free_session(
|
|
551
|
+
n.free_session(h);
|
|
523
552
|
}
|
|
524
553
|
}
|
|
525
554
|
};
|
|
526
|
-
return
|
|
527
|
-
} catch (
|
|
528
|
-
return console.error(`[arborium] Failed to load grammar '${t}':`,
|
|
555
|
+
return k.set(t, l), console.debug(`[arborium] Grammar '${t}' loaded successfully`), l;
|
|
556
|
+
} catch (a) {
|
|
557
|
+
return console.error(`[arborium] Failed to load grammar '${t}':`, a), null;
|
|
529
558
|
}
|
|
530
559
|
}
|
|
531
|
-
const
|
|
532
|
-
let
|
|
533
|
-
function
|
|
560
|
+
const y = /* @__PURE__ */ new Map();
|
|
561
|
+
let P = 1;
|
|
562
|
+
function q(t) {
|
|
534
563
|
window.arboriumHost = {
|
|
535
564
|
/** Check if a language is available (sync) */
|
|
536
|
-
isLanguageAvailable(
|
|
537
|
-
return
|
|
565
|
+
isLanguageAvailable(e) {
|
|
566
|
+
return $.has(e) || k.has(e);
|
|
538
567
|
},
|
|
539
568
|
/** Load a grammar and return a handle (async) */
|
|
540
|
-
async loadGrammar(
|
|
541
|
-
const
|
|
542
|
-
if (!
|
|
543
|
-
for (const [
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
546
|
-
return
|
|
569
|
+
async loadGrammar(e) {
|
|
570
|
+
const a = await v(e, t);
|
|
571
|
+
if (!a) return 0;
|
|
572
|
+
for (const [n, r] of y)
|
|
573
|
+
if (r === a) return n;
|
|
574
|
+
const s = P++;
|
|
575
|
+
return y.set(s, a), s;
|
|
547
576
|
},
|
|
548
577
|
/** Parse text using a grammar handle (sync) */
|
|
549
|
-
parse(
|
|
550
|
-
const
|
|
551
|
-
return
|
|
578
|
+
parse(e, a) {
|
|
579
|
+
const s = y.get(e);
|
|
580
|
+
return s ? s.parse(a) : { spans: [], injections: [] };
|
|
552
581
|
}
|
|
553
582
|
};
|
|
554
583
|
}
|
|
555
|
-
function
|
|
584
|
+
function M(t) {
|
|
556
585
|
if (t.hostUrl)
|
|
557
586
|
return t.hostUrl;
|
|
558
|
-
const
|
|
559
|
-
let
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
return `${
|
|
587
|
+
const e = t.cdn, a = t.version;
|
|
588
|
+
let s;
|
|
589
|
+
e === "jsdelivr" ? s = "https://cdn.jsdelivr.net/npm" : e === "unpkg" ? s = "https://unpkg.com" : s = e;
|
|
590
|
+
const n = a === "latest" ? "" : `@${a}`;
|
|
591
|
+
return `${s}/@arborium/arborium${n}/dist`;
|
|
563
592
|
}
|
|
564
|
-
async function
|
|
565
|
-
return
|
|
566
|
-
|
|
567
|
-
const
|
|
568
|
-
console.debug(`[arborium] Loading host from ${
|
|
593
|
+
async function A(t) {
|
|
594
|
+
return u || g || (g = (async () => {
|
|
595
|
+
q(t);
|
|
596
|
+
const e = M(t), a = `${e}/arborium_host.js`, s = `${e}/arborium_host_bg.wasm`;
|
|
597
|
+
console.debug(`[arborium] Loading host from ${a}`);
|
|
569
598
|
try {
|
|
570
|
-
const
|
|
599
|
+
const n = await import(
|
|
571
600
|
/* @vite-ignore */
|
|
572
|
-
|
|
601
|
+
a
|
|
573
602
|
);
|
|
574
|
-
return await
|
|
575
|
-
highlight:
|
|
576
|
-
isLanguageAvailable:
|
|
577
|
-
}, console.debug("[arborium] Host loaded successfully"),
|
|
578
|
-
} catch (
|
|
579
|
-
return console.error("[arborium] Failed to load host:",
|
|
603
|
+
return await n.default(s), u = {
|
|
604
|
+
highlight: n.highlight,
|
|
605
|
+
isLanguageAvailable: n.isLanguageAvailable
|
|
606
|
+
}, console.debug("[arborium] Host loaded successfully"), u;
|
|
607
|
+
} catch (n) {
|
|
608
|
+
return console.error("[arborium] Failed to load host:", n), null;
|
|
580
609
|
}
|
|
581
610
|
})(), g);
|
|
582
611
|
}
|
|
583
|
-
async function
|
|
584
|
-
const
|
|
585
|
-
if (
|
|
612
|
+
async function F(t, e, a) {
|
|
613
|
+
const s = L(a), n = await A(s);
|
|
614
|
+
if (n)
|
|
586
615
|
try {
|
|
587
|
-
return
|
|
616
|
+
return n.highlight(t, e);
|
|
588
617
|
} catch (i) {
|
|
589
618
|
console.warn("Host highlight failed, falling back to JS:", i);
|
|
590
619
|
}
|
|
591
|
-
const
|
|
592
|
-
if (!
|
|
593
|
-
return
|
|
594
|
-
const o =
|
|
595
|
-
return
|
|
620
|
+
const r = await v(t, s);
|
|
621
|
+
if (!r)
|
|
622
|
+
return f(e);
|
|
623
|
+
const o = r.parse(e);
|
|
624
|
+
return x(e, o.spans);
|
|
596
625
|
}
|
|
597
|
-
async function
|
|
598
|
-
const
|
|
599
|
-
if (!
|
|
600
|
-
const { module:
|
|
626
|
+
async function O(t, e) {
|
|
627
|
+
const a = L(e), s = await v(t, a);
|
|
628
|
+
if (!s) return null;
|
|
629
|
+
const { module: n } = s;
|
|
601
630
|
return {
|
|
602
|
-
languageId: () =>
|
|
603
|
-
injectionLanguages: () =>
|
|
604
|
-
highlight: async (
|
|
605
|
-
const o =
|
|
606
|
-
return
|
|
631
|
+
languageId: () => s.languageId,
|
|
632
|
+
injectionLanguages: () => s.injectionLanguages,
|
|
633
|
+
highlight: async (r) => {
|
|
634
|
+
const o = s.parse(r);
|
|
635
|
+
return x(r, o.spans);
|
|
607
636
|
},
|
|
608
|
-
parse: (
|
|
637
|
+
parse: (r) => s.parse(r),
|
|
609
638
|
createSession: () => {
|
|
610
|
-
const
|
|
639
|
+
const r = n.create_session();
|
|
611
640
|
return {
|
|
612
|
-
setText: (o) =>
|
|
641
|
+
setText: (o) => n.set_text(r, o),
|
|
613
642
|
parse: () => {
|
|
614
643
|
try {
|
|
615
|
-
const o =
|
|
644
|
+
const o = n.parse(r);
|
|
616
645
|
return {
|
|
617
646
|
spans: o.spans || [],
|
|
618
647
|
injections: o.injections || []
|
|
@@ -621,21 +650,21 @@ async function A(t, a) {
|
|
|
621
650
|
return console.error("[arborium] Session parse error:", o), { spans: [], injections: [] };
|
|
622
651
|
}
|
|
623
652
|
},
|
|
624
|
-
cancel: () =>
|
|
625
|
-
free: () =>
|
|
653
|
+
cancel: () => n.cancel(r),
|
|
654
|
+
free: () => n.free_session(r)
|
|
626
655
|
};
|
|
627
656
|
},
|
|
628
657
|
dispose: () => {
|
|
629
658
|
}
|
|
630
659
|
};
|
|
631
660
|
}
|
|
632
|
-
function
|
|
633
|
-
return t ? { ...
|
|
661
|
+
function L(t) {
|
|
662
|
+
return t ? { ...b, ...t } : { ...b };
|
|
634
663
|
}
|
|
635
|
-
function
|
|
636
|
-
|
|
664
|
+
function z(t) {
|
|
665
|
+
b = { ...b, ...t };
|
|
637
666
|
}
|
|
638
|
-
const
|
|
667
|
+
const G = [
|
|
639
668
|
[/^#!.*\bpython[23]?\b/, "python"],
|
|
640
669
|
[/^#!.*\bnode\b/, "javascript"],
|
|
641
670
|
[/^#!.*\bdeno\b/, "typescript"],
|
|
@@ -648,7 +677,7 @@ const R = [
|
|
|
648
677
|
[/^#!.*\bsh\b/, "bash"],
|
|
649
678
|
[/^#!.*\blua\b/, "lua"],
|
|
650
679
|
[/^#!.*\bawk\b/, "awk"]
|
|
651
|
-
],
|
|
680
|
+
], R = [
|
|
652
681
|
// Rust - distinctive keywords
|
|
653
682
|
[/\b(fn|impl|trait|pub\s+fn|let\s+mut|&mut|->)\b/, "rust"],
|
|
654
683
|
// Go - distinctive keywords
|
|
@@ -708,23 +737,23 @@ const R = [
|
|
|
708
737
|
// Zig
|
|
709
738
|
[/\b(pub\s+fn|const\s+\w+\s*=|@import\(|comptime)\b/, "zig"]
|
|
710
739
|
];
|
|
711
|
-
function
|
|
712
|
-
const
|
|
740
|
+
function N(t) {
|
|
741
|
+
const e = t.split(`
|
|
713
742
|
`)[0];
|
|
714
|
-
for (const [
|
|
715
|
-
if (
|
|
716
|
-
return
|
|
717
|
-
for (const [
|
|
718
|
-
if (
|
|
719
|
-
return
|
|
743
|
+
for (const [a, s] of G)
|
|
744
|
+
if (a.test(e))
|
|
745
|
+
return s;
|
|
746
|
+
for (const [a, s] of R)
|
|
747
|
+
if (a.test(t))
|
|
748
|
+
return s;
|
|
720
749
|
return null;
|
|
721
750
|
}
|
|
722
|
-
function
|
|
723
|
-
const
|
|
751
|
+
function B(t) {
|
|
752
|
+
const e = t.match(/\blanguage-(\w+)\b/);
|
|
753
|
+
if (e) return e[1];
|
|
754
|
+
const a = t.match(/\blang-(\w+)\b/);
|
|
724
755
|
if (a) return a[1];
|
|
725
|
-
const
|
|
726
|
-
if (r) return r[1];
|
|
727
|
-
const e = /* @__PURE__ */ new Set([
|
|
756
|
+
const s = /* @__PURE__ */ new Set([
|
|
728
757
|
"rust",
|
|
729
758
|
"javascript",
|
|
730
759
|
"typescript",
|
|
@@ -760,13 +789,13 @@ function O(t) {
|
|
|
760
789
|
"console",
|
|
761
790
|
"sh"
|
|
762
791
|
]);
|
|
763
|
-
for (const
|
|
764
|
-
if (
|
|
765
|
-
return
|
|
792
|
+
for (const n of t.split(/\s+/))
|
|
793
|
+
if (s.has(n.toLowerCase()))
|
|
794
|
+
return n.toLowerCase();
|
|
766
795
|
return null;
|
|
767
796
|
}
|
|
768
|
-
function
|
|
769
|
-
const
|
|
797
|
+
function J(t) {
|
|
798
|
+
const e = {
|
|
770
799
|
js: "javascript",
|
|
771
800
|
ts: "typescript",
|
|
772
801
|
py: "python",
|
|
@@ -786,20 +815,20 @@ function z(t) {
|
|
|
786
815
|
plaintext: "text",
|
|
787
816
|
plain: "text",
|
|
788
817
|
txt: "text"
|
|
789
|
-
},
|
|
790
|
-
return a
|
|
818
|
+
}, a = t.toLowerCase();
|
|
819
|
+
return e[a] || a;
|
|
791
820
|
}
|
|
792
821
|
export {
|
|
793
822
|
_ as availableLanguages,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
823
|
+
N as detectLanguage,
|
|
824
|
+
B as extractLanguageFromClass,
|
|
825
|
+
L as getConfig,
|
|
826
|
+
F as highlight,
|
|
827
|
+
H as highlights,
|
|
828
|
+
O as loadGrammar,
|
|
829
|
+
J as normalizeLanguage,
|
|
830
|
+
U as pluginVersion,
|
|
831
|
+
z as setConfig,
|
|
832
|
+
x as spansToHtml
|
|
804
833
|
};
|
|
805
834
|
//# sourceMappingURL=arborium.js.map
|