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