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