@arborium/arborium 1.0.4 → 1.0.6
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 +292 -189
- package/dist/arborium.js.map +1 -1
- package/dist/plugins-manifest.d.ts +2 -14
- package/package.json +3 -2
package/dist/arborium.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
class
|
|
2
|
-
constructor(
|
|
3
|
-
super(
|
|
1
|
+
class U extends Error {
|
|
2
|
+
constructor(r) {
|
|
3
|
+
super(r), this.name = "WasiError";
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
class
|
|
7
|
-
write(
|
|
6
|
+
class j {
|
|
7
|
+
write(r) {
|
|
8
8
|
return BigInt(0);
|
|
9
9
|
}
|
|
10
|
-
blockingWriteAndFlush(
|
|
10
|
+
blockingWriteAndFlush(r) {
|
|
11
11
|
}
|
|
12
12
|
blockingFlush() {
|
|
13
13
|
}
|
|
@@ -17,86 +17,181 @@ class k {
|
|
|
17
17
|
subscribe() {
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
class
|
|
21
|
-
read(
|
|
20
|
+
class E {
|
|
21
|
+
read(r) {
|
|
22
22
|
return new Uint8Array(0);
|
|
23
23
|
}
|
|
24
|
-
blockingRead(
|
|
24
|
+
blockingRead(r) {
|
|
25
25
|
return new Uint8Array(0);
|
|
26
26
|
}
|
|
27
27
|
subscribe() {
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
const s = new
|
|
30
|
+
function T() {
|
|
31
|
+
const s = new j(), r = new j(), t = new E(), e = {
|
|
32
32
|
getEnvironment: () => [],
|
|
33
33
|
getArguments: () => []
|
|
34
|
-
},
|
|
35
|
-
exit: (
|
|
36
|
-
if (
|
|
37
|
-
throw new
|
|
34
|
+
}, n = {
|
|
35
|
+
exit: (o) => {
|
|
36
|
+
if (o.tag === "err")
|
|
37
|
+
throw new U(`WASI exit with error: ${o.val}`);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, a = { getStdin: () => t }, l = { getStdout: () => s }, m = { getStderr: () => r }, d = {
|
|
40
40
|
now: () => {
|
|
41
|
-
const
|
|
41
|
+
const o = Date.now();
|
|
42
42
|
return {
|
|
43
|
-
seconds: BigInt(Math.floor(
|
|
44
|
-
nanoseconds:
|
|
43
|
+
seconds: BigInt(Math.floor(o / 1e3)),
|
|
44
|
+
nanoseconds: o % 1e3 * 1e6
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
47
|
resolution: () => ({ seconds: BigInt(0), nanoseconds: 1e6 })
|
|
48
|
-
},
|
|
48
|
+
}, u = {
|
|
49
49
|
Descriptor: class {
|
|
50
50
|
},
|
|
51
51
|
DirectoryEntryStream: class {
|
|
52
52
|
},
|
|
53
53
|
filesystemErrorCode: () => null
|
|
54
|
-
},
|
|
54
|
+
}, w = {
|
|
55
55
|
getDirectories: () => []
|
|
56
|
-
},
|
|
57
|
-
getRandomBytes: (
|
|
58
|
-
const
|
|
59
|
-
return crypto.getRandomValues(
|
|
56
|
+
}, f = { Error: U }, p = { InputStream: E, OutputStream: j }, i = {
|
|
57
|
+
getRandomBytes: (o) => {
|
|
58
|
+
const b = new Uint8Array(Number(o));
|
|
59
|
+
return crypto.getRandomValues(b), b;
|
|
60
60
|
},
|
|
61
61
|
getRandomU64: () => {
|
|
62
|
-
const
|
|
63
|
-
return crypto.getRandomValues(
|
|
62
|
+
const o = new Uint8Array(8);
|
|
63
|
+
return crypto.getRandomValues(o), new DataView(o.buffer).getBigUint64(0, !0);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
return {
|
|
67
67
|
// Unversioned (used by published grammars)
|
|
68
|
-
"wasi:cli/environment":
|
|
69
|
-
"wasi:cli/exit":
|
|
70
|
-
"wasi:cli/stdin":
|
|
71
|
-
"wasi:cli/stdout":
|
|
72
|
-
"wasi:cli/stderr":
|
|
73
|
-
"wasi:clocks/wall-clock":
|
|
74
|
-
"wasi:filesystem/types":
|
|
75
|
-
"wasi:filesystem/preopens":
|
|
76
|
-
"wasi:io/error":
|
|
68
|
+
"wasi:cli/environment": e,
|
|
69
|
+
"wasi:cli/exit": n,
|
|
70
|
+
"wasi:cli/stdin": a,
|
|
71
|
+
"wasi:cli/stdout": l,
|
|
72
|
+
"wasi:cli/stderr": m,
|
|
73
|
+
"wasi:clocks/wall-clock": d,
|
|
74
|
+
"wasi:filesystem/types": u,
|
|
75
|
+
"wasi:filesystem/preopens": w,
|
|
76
|
+
"wasi:io/error": f,
|
|
77
77
|
"wasi:io/streams": p,
|
|
78
|
-
"wasi:random/random":
|
|
78
|
+
"wasi:random/random": i,
|
|
79
79
|
// Versioned @0.2.3 (for newer builds)
|
|
80
|
-
"wasi:cli/environment@0.2.3":
|
|
81
|
-
"wasi:cli/exit@0.2.3":
|
|
82
|
-
"wasi:cli/stdin@0.2.3":
|
|
83
|
-
"wasi:cli/stdout@0.2.3":
|
|
84
|
-
"wasi:cli/stderr@0.2.3":
|
|
85
|
-
"wasi:clocks/wall-clock@0.2.3":
|
|
86
|
-
"wasi:filesystem/types@0.2.3":
|
|
87
|
-
"wasi:filesystem/preopens@0.2.3":
|
|
88
|
-
"wasi:io/error@0.2.3":
|
|
80
|
+
"wasi:cli/environment@0.2.3": e,
|
|
81
|
+
"wasi:cli/exit@0.2.3": n,
|
|
82
|
+
"wasi:cli/stdin@0.2.3": a,
|
|
83
|
+
"wasi:cli/stdout@0.2.3": l,
|
|
84
|
+
"wasi:cli/stderr@0.2.3": m,
|
|
85
|
+
"wasi:clocks/wall-clock@0.2.3": d,
|
|
86
|
+
"wasi:filesystem/types@0.2.3": u,
|
|
87
|
+
"wasi:filesystem/preopens@0.2.3": w,
|
|
88
|
+
"wasi:io/error@0.2.3": f,
|
|
89
89
|
"wasi:io/streams@0.2.3": p,
|
|
90
|
-
"wasi:random/random@0.2.3":
|
|
90
|
+
"wasi:random/random@0.2.3": i
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
const
|
|
93
|
+
const A = {
|
|
94
94
|
"arborium:grammar/types@0.1.0": {
|
|
95
95
|
// Types are just interfaces, nothing to export
|
|
96
96
|
}
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
}, R = [
|
|
98
|
+
"ada",
|
|
99
|
+
"agda",
|
|
100
|
+
"asciidoc",
|
|
101
|
+
"asm",
|
|
102
|
+
"awk",
|
|
103
|
+
"bash",
|
|
104
|
+
"batch",
|
|
105
|
+
"c",
|
|
106
|
+
"c-sharp",
|
|
107
|
+
"caddy",
|
|
108
|
+
"capnp",
|
|
109
|
+
"clojure",
|
|
110
|
+
"cmake",
|
|
111
|
+
"commonlisp",
|
|
112
|
+
"cpp",
|
|
113
|
+
"css",
|
|
114
|
+
"d",
|
|
115
|
+
"dart",
|
|
116
|
+
"devicetree",
|
|
117
|
+
"diff",
|
|
118
|
+
"dockerfile",
|
|
119
|
+
"dot",
|
|
120
|
+
"elisp",
|
|
121
|
+
"elixir",
|
|
122
|
+
"elm",
|
|
123
|
+
"erlang",
|
|
124
|
+
"fish",
|
|
125
|
+
"fsharp",
|
|
126
|
+
"gleam",
|
|
127
|
+
"glsl",
|
|
128
|
+
"go",
|
|
129
|
+
"graphql",
|
|
130
|
+
"haskell",
|
|
131
|
+
"hcl",
|
|
132
|
+
"hlsl",
|
|
133
|
+
"html",
|
|
134
|
+
"idris",
|
|
135
|
+
"ini",
|
|
136
|
+
"java",
|
|
137
|
+
"javascript",
|
|
138
|
+
"jinja2",
|
|
139
|
+
"jq",
|
|
140
|
+
"json",
|
|
141
|
+
"julia",
|
|
142
|
+
"kdl",
|
|
143
|
+
"kotlin",
|
|
144
|
+
"lean",
|
|
145
|
+
"lua",
|
|
146
|
+
"markdown",
|
|
147
|
+
"matlab",
|
|
148
|
+
"meson",
|
|
149
|
+
"nginx",
|
|
150
|
+
"ninja",
|
|
151
|
+
"nix",
|
|
152
|
+
"objc",
|
|
153
|
+
"ocaml",
|
|
154
|
+
"perl",
|
|
155
|
+
"php",
|
|
156
|
+
"postscript",
|
|
157
|
+
"powershell",
|
|
158
|
+
"prolog",
|
|
159
|
+
"python",
|
|
160
|
+
"query",
|
|
161
|
+
"r",
|
|
162
|
+
"rescript",
|
|
163
|
+
"ron",
|
|
164
|
+
"ruby",
|
|
165
|
+
"rust",
|
|
166
|
+
"scala",
|
|
167
|
+
"scheme",
|
|
168
|
+
"scss",
|
|
169
|
+
"sparql",
|
|
170
|
+
"sql",
|
|
171
|
+
"ssh-config",
|
|
172
|
+
"starlark",
|
|
173
|
+
"svelte",
|
|
174
|
+
"swift",
|
|
175
|
+
"textproto",
|
|
176
|
+
"thrift",
|
|
177
|
+
"tlaplus",
|
|
178
|
+
"toml",
|
|
179
|
+
"tsx",
|
|
180
|
+
"typescript",
|
|
181
|
+
"typst",
|
|
182
|
+
"uiua",
|
|
183
|
+
"vb",
|
|
184
|
+
"verilog",
|
|
185
|
+
"vhdl",
|
|
186
|
+
"vim",
|
|
187
|
+
"vue",
|
|
188
|
+
"x86asm",
|
|
189
|
+
"xml",
|
|
190
|
+
"yaml",
|
|
191
|
+
"yuri",
|
|
192
|
+
"zig",
|
|
193
|
+
"zsh"
|
|
194
|
+
], C = {
|
|
100
195
|
manual: !1,
|
|
101
196
|
theme: "one-dark",
|
|
102
197
|
selector: "pre code",
|
|
@@ -108,176 +203,184 @@ const C = {
|
|
|
108
203
|
hostUrl: ""
|
|
109
204
|
// Empty means use CDN based on version
|
|
110
205
|
};
|
|
111
|
-
let
|
|
112
|
-
const
|
|
113
|
-
let
|
|
206
|
+
let h = null, y = null, c = { ...C };
|
|
207
|
+
const $ = /* @__PURE__ */ new Map(), I = new Set(R);
|
|
208
|
+
let g = null, v = null;
|
|
114
209
|
async function M() {
|
|
115
|
-
if (
|
|
116
|
-
return
|
|
117
|
-
console.debug(`[arborium] Loading plugins manifest from: ${
|
|
118
|
-
const s = await fetch(
|
|
210
|
+
if (c.pluginsUrl)
|
|
211
|
+
return v || (v = (async () => {
|
|
212
|
+
console.debug(`[arborium] Loading local plugins manifest from: ${c.pluginsUrl}`);
|
|
213
|
+
const s = await fetch(c.pluginsUrl);
|
|
119
214
|
if (!s.ok)
|
|
120
215
|
throw new Error(`Failed to load plugins.json: ${s.status}`);
|
|
121
|
-
|
|
122
|
-
})(),
|
|
216
|
+
g = await s.json(), console.debug(`[arborium] Loaded local manifest with ${g?.entries.length} entries`);
|
|
217
|
+
})(), v);
|
|
218
|
+
}
|
|
219
|
+
function _(s) {
|
|
220
|
+
if (g) {
|
|
221
|
+
const e = g.entries.find((n) => n.language === s);
|
|
222
|
+
if (e)
|
|
223
|
+
return e.local_js;
|
|
224
|
+
}
|
|
225
|
+
const r = c.cdn;
|
|
226
|
+
let t;
|
|
227
|
+
return r === "jsdelivr" ? t = "https://cdn.jsdelivr.net/npm" : r === "unpkg" ? t = "https://unpkg.com" : t = r, `${t}/@arborium/${s}@1/grammar.js`;
|
|
123
228
|
}
|
|
124
|
-
async function
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
return console.debug(`[arborium] Grammar '${s}' found in cache`),
|
|
128
|
-
await M()
|
|
129
|
-
|
|
130
|
-
if (!e)
|
|
131
|
-
return console.debug(`[arborium] Grammar '${s}' not found in manifest`), null;
|
|
229
|
+
async function L(s) {
|
|
230
|
+
const r = $.get(s);
|
|
231
|
+
if (r)
|
|
232
|
+
return console.debug(`[arborium] Grammar '${s}' found in cache`), r;
|
|
233
|
+
if (await M(), !I.has(s) && !g?.entries.some((t) => t.language === s))
|
|
234
|
+
return console.debug(`[arborium] Grammar '${s}' not available`), null;
|
|
132
235
|
try {
|
|
133
|
-
const t =
|
|
236
|
+
const t = _(s), e = t.substring(0, t.lastIndexOf("/"));
|
|
134
237
|
console.debug(`[arborium] Loading grammar '${s}' from ${t}`);
|
|
135
|
-
const
|
|
238
|
+
const n = await import(
|
|
136
239
|
/* @vite-ignore */
|
|
137
240
|
t
|
|
138
|
-
),
|
|
139
|
-
const
|
|
140
|
-
if (!
|
|
141
|
-
throw new Error(`Failed to fetch WASM ${
|
|
142
|
-
const
|
|
143
|
-
return WebAssembly.compile(
|
|
144
|
-
},
|
|
145
|
-
...
|
|
146
|
-
...
|
|
147
|
-
},
|
|
148
|
-
if (!
|
|
241
|
+
), a = async (f) => {
|
|
242
|
+
const p = `${e}/${f}`, i = await fetch(p);
|
|
243
|
+
if (!i.ok)
|
|
244
|
+
throw new Error(`Failed to fetch WASM ${f}: ${i.status}`);
|
|
245
|
+
const o = await i.arrayBuffer();
|
|
246
|
+
return WebAssembly.compile(o);
|
|
247
|
+
}, m = {
|
|
248
|
+
...T(),
|
|
249
|
+
...A
|
|
250
|
+
}, d = await n.instantiate(a, m), u = d.plugin || d["arborium:grammar/plugin@0.1.0"];
|
|
251
|
+
if (!u)
|
|
149
252
|
return console.error(`Grammar '${s}' missing plugin interface`), null;
|
|
150
|
-
const
|
|
253
|
+
const w = {
|
|
151
254
|
languageId: s,
|
|
152
|
-
injectionLanguages:
|
|
153
|
-
parse: (
|
|
154
|
-
const
|
|
255
|
+
injectionLanguages: u.injectionLanguages?.() ?? [],
|
|
256
|
+
parse: (f) => {
|
|
257
|
+
const p = u.createSession();
|
|
155
258
|
try {
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
160
|
-
return console.error(`[arborium] Parse error: ${
|
|
259
|
+
u.setText(p, f);
|
|
260
|
+
const i = u.parse(p);
|
|
261
|
+
if (i.tag === "err") {
|
|
262
|
+
const W = i.val;
|
|
263
|
+
return console.error(`[arborium] Parse error: ${W?.message}`), { spans: [], injections: [] };
|
|
161
264
|
}
|
|
162
|
-
const
|
|
163
|
-
if (!
|
|
164
|
-
return console.error("[arborium] Unexpected parse result:",
|
|
165
|
-
const
|
|
265
|
+
const o = i.tag === "ok" ? i.val : i;
|
|
266
|
+
if (!o || typeof o != "object")
|
|
267
|
+
return console.error("[arborium] Unexpected parse result:", i), { spans: [], injections: [] };
|
|
268
|
+
const b = o;
|
|
166
269
|
return {
|
|
167
|
-
spans:
|
|
168
|
-
injections:
|
|
270
|
+
spans: b.spans || [],
|
|
271
|
+
injections: b.injections || []
|
|
169
272
|
};
|
|
170
273
|
} finally {
|
|
171
|
-
|
|
274
|
+
u.freeSession(p);
|
|
172
275
|
}
|
|
173
276
|
}
|
|
174
277
|
};
|
|
175
|
-
return
|
|
278
|
+
return $.set(s, w), console.debug(`[arborium] Grammar '${s}' loaded successfully`), w;
|
|
176
279
|
} catch (t) {
|
|
177
280
|
return console.error(`[arborium] Failed to load grammar '${s}':`, t), null;
|
|
178
281
|
}
|
|
179
282
|
}
|
|
180
|
-
const
|
|
181
|
-
let
|
|
182
|
-
function
|
|
283
|
+
const x = /* @__PURE__ */ new Map();
|
|
284
|
+
let q = 1;
|
|
285
|
+
function F() {
|
|
183
286
|
window.arboriumHost = {
|
|
184
287
|
/** Check if a language is available (sync) */
|
|
185
288
|
isLanguageAvailable(s) {
|
|
186
|
-
return
|
|
289
|
+
return I.has(s) || $.has(s);
|
|
187
290
|
},
|
|
188
291
|
/** Load a grammar and return a handle (async) */
|
|
189
292
|
async loadGrammar(s) {
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
192
|
-
for (const [
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
return
|
|
293
|
+
const r = await L(s);
|
|
294
|
+
if (!r) return 0;
|
|
295
|
+
for (const [e, n] of x)
|
|
296
|
+
if (n === r) return e;
|
|
297
|
+
const t = q++;
|
|
298
|
+
return x.set(t, r), t;
|
|
196
299
|
},
|
|
197
300
|
/** Parse text using a grammar handle (sync) */
|
|
198
|
-
parse(s,
|
|
199
|
-
const
|
|
200
|
-
return
|
|
301
|
+
parse(s, r) {
|
|
302
|
+
const t = x.get(s);
|
|
303
|
+
return t ? t.parse(r) : { spans: [], injections: [] };
|
|
201
304
|
}
|
|
202
305
|
};
|
|
203
306
|
}
|
|
204
|
-
function
|
|
205
|
-
if (
|
|
206
|
-
return
|
|
207
|
-
const s =
|
|
208
|
-
let
|
|
209
|
-
s === "jsdelivr" ?
|
|
210
|
-
const
|
|
211
|
-
return `${
|
|
307
|
+
function P() {
|
|
308
|
+
if (c.hostUrl)
|
|
309
|
+
return c.hostUrl;
|
|
310
|
+
const s = c.cdn, r = c.version;
|
|
311
|
+
let t;
|
|
312
|
+
s === "jsdelivr" ? t = "https://cdn.jsdelivr.net/npm" : s === "unpkg" ? t = "https://unpkg.com" : t = s;
|
|
313
|
+
const e = r === "latest" ? "" : `@${r}`;
|
|
314
|
+
return `${t}/@arborium/arborium${e}/dist`;
|
|
212
315
|
}
|
|
213
|
-
async function
|
|
214
|
-
return
|
|
215
|
-
|
|
216
|
-
const s =
|
|
217
|
-
console.debug(`[arborium] Loading host from ${
|
|
316
|
+
async function B() {
|
|
317
|
+
return h || y || (y = (async () => {
|
|
318
|
+
F();
|
|
319
|
+
const s = P(), r = `${s}/arborium_host.js`, t = `${s}/arborium_host_bg.wasm`;
|
|
320
|
+
console.debug(`[arborium] Loading host from ${r}`);
|
|
218
321
|
try {
|
|
219
|
-
const
|
|
322
|
+
const e = await import(
|
|
220
323
|
/* @vite-ignore */
|
|
221
|
-
|
|
324
|
+
r
|
|
222
325
|
);
|
|
223
|
-
return await
|
|
224
|
-
highlight:
|
|
225
|
-
isLanguageAvailable:
|
|
226
|
-
}, console.debug("[arborium] Host loaded successfully"),
|
|
227
|
-
} catch (
|
|
228
|
-
return console.error("[arborium] Failed to load host:",
|
|
326
|
+
return await e.default(t), h = {
|
|
327
|
+
highlight: e.highlight,
|
|
328
|
+
isLanguageAvailable: e.isLanguageAvailable
|
|
329
|
+
}, console.debug("[arborium] Host loaded successfully"), h;
|
|
330
|
+
} catch (e) {
|
|
331
|
+
return console.error("[arborium] Failed to load host:", e), null;
|
|
229
332
|
}
|
|
230
|
-
})(),
|
|
333
|
+
})(), y);
|
|
231
334
|
}
|
|
232
|
-
async function
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
335
|
+
async function N(s, r, t) {
|
|
336
|
+
const e = await B();
|
|
337
|
+
if (e)
|
|
235
338
|
try {
|
|
236
|
-
return
|
|
237
|
-
} catch (
|
|
238
|
-
console.warn("Host highlight failed, falling back to JS:",
|
|
339
|
+
return e.highlight(s, r);
|
|
340
|
+
} catch (l) {
|
|
341
|
+
console.warn("Host highlight failed, falling back to JS:", l);
|
|
239
342
|
}
|
|
240
|
-
const
|
|
241
|
-
if (!
|
|
242
|
-
return
|
|
243
|
-
const
|
|
244
|
-
return
|
|
343
|
+
const n = await L(s);
|
|
344
|
+
if (!n)
|
|
345
|
+
return k(r);
|
|
346
|
+
const a = n.parse(r);
|
|
347
|
+
return S(r, a.spans);
|
|
245
348
|
}
|
|
246
|
-
async function
|
|
247
|
-
const
|
|
248
|
-
return
|
|
249
|
-
languageId: () =>
|
|
250
|
-
injectionLanguages: () =>
|
|
251
|
-
highlight: async (
|
|
252
|
-
const
|
|
253
|
-
return
|
|
349
|
+
async function z(s, r) {
|
|
350
|
+
const t = await L(s);
|
|
351
|
+
return t ? {
|
|
352
|
+
languageId: () => t.languageId,
|
|
353
|
+
injectionLanguages: () => t.injectionLanguages,
|
|
354
|
+
highlight: async (e) => {
|
|
355
|
+
const n = t.parse(e);
|
|
356
|
+
return S(e, n.spans);
|
|
254
357
|
},
|
|
255
|
-
parse: (
|
|
358
|
+
parse: (e) => t.parse(e),
|
|
256
359
|
dispose: () => {
|
|
257
360
|
}
|
|
258
361
|
} : null;
|
|
259
362
|
}
|
|
260
|
-
function
|
|
261
|
-
const
|
|
262
|
-
let
|
|
263
|
-
for (const
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
363
|
+
function S(s, r) {
|
|
364
|
+
const t = [...r].sort((a, l) => a.start - l.start);
|
|
365
|
+
let e = "", n = 0;
|
|
366
|
+
for (const a of t) {
|
|
367
|
+
if (a.start < n) continue;
|
|
368
|
+
a.start > n && (e += k(s.slice(n, a.start)));
|
|
369
|
+
const l = G(a.capture), m = k(s.slice(a.start, a.end));
|
|
370
|
+
l ? e += `<a-${l}>${m}</a-${l}>` : e += m, n = a.end;
|
|
268
371
|
}
|
|
269
|
-
return
|
|
372
|
+
return n < s.length && (e += k(s.slice(n))), e;
|
|
270
373
|
}
|
|
271
374
|
function G(s) {
|
|
272
375
|
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;
|
|
273
376
|
}
|
|
274
|
-
function
|
|
377
|
+
function k(s) {
|
|
275
378
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
276
379
|
}
|
|
277
|
-
function
|
|
278
|
-
return s ? { ...
|
|
380
|
+
function D(s) {
|
|
381
|
+
return s ? { ...c, ...s } : { ...c };
|
|
279
382
|
}
|
|
280
|
-
const
|
|
383
|
+
const H = [
|
|
281
384
|
[/^#!.*\bpython[23]?\b/, "python"],
|
|
282
385
|
[/^#!.*\bnode\b/, "javascript"],
|
|
283
386
|
[/^#!.*\bdeno\b/, "typescript"],
|
|
@@ -290,7 +393,7 @@ const O = [
|
|
|
290
393
|
[/^#!.*\bsh\b/, "bash"],
|
|
291
394
|
[/^#!.*\blua\b/, "lua"],
|
|
292
395
|
[/^#!.*\bawk\b/, "awk"]
|
|
293
|
-
],
|
|
396
|
+
], O = [
|
|
294
397
|
// Rust - distinctive keywords
|
|
295
398
|
[/\b(fn|impl|trait|pub\s+fn|let\s+mut|&mut|->)\b/, "rust"],
|
|
296
399
|
// Go - distinctive keywords
|
|
@@ -351,22 +454,22 @@ const O = [
|
|
|
351
454
|
[/\b(pub\s+fn|const\s+\w+\s*=|@import\(|comptime)\b/, "zig"]
|
|
352
455
|
];
|
|
353
456
|
function Y(s) {
|
|
354
|
-
const
|
|
457
|
+
const r = s.split(`
|
|
355
458
|
`)[0];
|
|
356
|
-
for (const [
|
|
357
|
-
if (
|
|
358
|
-
return
|
|
359
|
-
for (const [
|
|
360
|
-
if (
|
|
361
|
-
return
|
|
459
|
+
for (const [t, e] of H)
|
|
460
|
+
if (t.test(r))
|
|
461
|
+
return e;
|
|
462
|
+
for (const [t, e] of O)
|
|
463
|
+
if (t.test(s))
|
|
464
|
+
return e;
|
|
362
465
|
return null;
|
|
363
466
|
}
|
|
364
467
|
function V(s) {
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
const
|
|
368
|
-
if (
|
|
369
|
-
const
|
|
468
|
+
const r = s.match(/\blanguage-(\w+)\b/);
|
|
469
|
+
if (r) return r[1];
|
|
470
|
+
const t = s.match(/\blang-(\w+)\b/);
|
|
471
|
+
if (t) return t[1];
|
|
472
|
+
const e = /* @__PURE__ */ new Set([
|
|
370
473
|
"rust",
|
|
371
474
|
"javascript",
|
|
372
475
|
"typescript",
|
|
@@ -402,13 +505,13 @@ function V(s) {
|
|
|
402
505
|
"console",
|
|
403
506
|
"sh"
|
|
404
507
|
]);
|
|
405
|
-
for (const
|
|
406
|
-
if (
|
|
407
|
-
return
|
|
508
|
+
for (const n of s.split(/\s+/))
|
|
509
|
+
if (e.has(n.toLowerCase()))
|
|
510
|
+
return n.toLowerCase();
|
|
408
511
|
return null;
|
|
409
512
|
}
|
|
410
513
|
function J(s) {
|
|
411
|
-
const
|
|
514
|
+
const r = {
|
|
412
515
|
js: "javascript",
|
|
413
516
|
ts: "typescript",
|
|
414
517
|
py: "python",
|
|
@@ -428,16 +531,16 @@ function J(s) {
|
|
|
428
531
|
plaintext: "text",
|
|
429
532
|
plain: "text",
|
|
430
533
|
txt: "text"
|
|
431
|
-
},
|
|
432
|
-
return
|
|
534
|
+
}, t = s.toLowerCase();
|
|
535
|
+
return r[t] || t;
|
|
433
536
|
}
|
|
434
537
|
export {
|
|
435
538
|
Y as detectLanguage,
|
|
436
539
|
V as extractLanguageFromClass,
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
540
|
+
D as getConfig,
|
|
541
|
+
N as highlight,
|
|
542
|
+
z as loadGrammar,
|
|
440
543
|
J as normalizeLanguage,
|
|
441
|
-
|
|
544
|
+
S as spansToHtml
|
|
442
545
|
};
|
|
443
546
|
//# sourceMappingURL=arborium.js.map
|