@arborium/arborium 0.700.0 → 0.900.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/package.json +1 -1
- package/dist/arborium.iife.js +0 -3
- package/dist/arborium.iife.js.map +0 -1
- package/dist/arborium.js +0 -395
- package/dist/arborium.js.map +0 -1
- package/dist/arborium_host.js +0 -482
- package/dist/arborium_host_bg.wasm +0 -0
- package/dist/detect.d.ts +0 -17
- package/dist/iife.d.ts +0 -11
- package/dist/index.d.ts +0 -8
- package/dist/loader.d.ts +0 -24
- package/dist/themes/github-light.css +0 -123
- package/dist/themes/tokyo-night.css +0 -122
- package/dist/types.d.ts +0 -55
- package/dist/wasi-shims.d.ts +0 -130
package/dist/arborium_host.js
DELETED
|
@@ -1,482 +0,0 @@
|
|
|
1
|
-
let wasm;
|
|
2
|
-
|
|
3
|
-
function addToExternrefTable0(obj) {
|
|
4
|
-
const idx = wasm.__externref_table_alloc();
|
|
5
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
6
|
-
return idx;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function _assertClass(instance, klass) {
|
|
10
|
-
if (!(instance instanceof klass)) {
|
|
11
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
16
|
-
? { register: () => {}, unregister: () => {} }
|
|
17
|
-
: new FinalizationRegistry(state => state.dtor(state.a, state.b));
|
|
18
|
-
|
|
19
|
-
let cachedDataViewMemory0 = null;
|
|
20
|
-
function getDataViewMemory0() {
|
|
21
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
22
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
23
|
-
}
|
|
24
|
-
return cachedDataViewMemory0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function getStringFromWasm0(ptr, len) {
|
|
28
|
-
ptr = ptr >>> 0;
|
|
29
|
-
return decodeText(ptr, len);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let cachedUint8ArrayMemory0 = null;
|
|
33
|
-
function getUint8ArrayMemory0() {
|
|
34
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
35
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
36
|
-
}
|
|
37
|
-
return cachedUint8ArrayMemory0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function handleError(f, args) {
|
|
41
|
-
try {
|
|
42
|
-
return f.apply(this, args);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
const idx = addToExternrefTable0(e);
|
|
45
|
-
wasm.__wbindgen_exn_store(idx);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function isLikeNone(x) {
|
|
50
|
-
return x === undefined || x === null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
54
|
-
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
55
|
-
const real = (...args) => {
|
|
56
|
-
|
|
57
|
-
// First up with a closure we increment the internal reference
|
|
58
|
-
// count. This ensures that the Rust closure environment won't
|
|
59
|
-
// be deallocated while we're invoking it.
|
|
60
|
-
state.cnt++;
|
|
61
|
-
const a = state.a;
|
|
62
|
-
state.a = 0;
|
|
63
|
-
try {
|
|
64
|
-
return f(a, state.b, ...args);
|
|
65
|
-
} finally {
|
|
66
|
-
state.a = a;
|
|
67
|
-
real._wbg_cb_unref();
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
real._wbg_cb_unref = () => {
|
|
71
|
-
if (--state.cnt === 0) {
|
|
72
|
-
state.dtor(state.a, state.b);
|
|
73
|
-
state.a = 0;
|
|
74
|
-
CLOSURE_DTORS.unregister(state);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
CLOSURE_DTORS.register(real, state, state);
|
|
78
|
-
return real;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
82
|
-
if (realloc === undefined) {
|
|
83
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
84
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
85
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
86
|
-
WASM_VECTOR_LEN = buf.length;
|
|
87
|
-
return ptr;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
let len = arg.length;
|
|
91
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
92
|
-
|
|
93
|
-
const mem = getUint8ArrayMemory0();
|
|
94
|
-
|
|
95
|
-
let offset = 0;
|
|
96
|
-
|
|
97
|
-
for (; offset < len; offset++) {
|
|
98
|
-
const code = arg.charCodeAt(offset);
|
|
99
|
-
if (code > 0x7F) break;
|
|
100
|
-
mem[ptr + offset] = code;
|
|
101
|
-
}
|
|
102
|
-
if (offset !== len) {
|
|
103
|
-
if (offset !== 0) {
|
|
104
|
-
arg = arg.slice(offset);
|
|
105
|
-
}
|
|
106
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
107
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
108
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
109
|
-
|
|
110
|
-
offset += ret.written;
|
|
111
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
WASM_VECTOR_LEN = offset;
|
|
115
|
-
return ptr;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
119
|
-
cachedTextDecoder.decode();
|
|
120
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
121
|
-
let numBytesDecoded = 0;
|
|
122
|
-
function decodeText(ptr, len) {
|
|
123
|
-
numBytesDecoded += len;
|
|
124
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
125
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
126
|
-
cachedTextDecoder.decode();
|
|
127
|
-
numBytesDecoded = len;
|
|
128
|
-
}
|
|
129
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const cachedTextEncoder = new TextEncoder();
|
|
133
|
-
|
|
134
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
135
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
136
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
137
|
-
view.set(buf);
|
|
138
|
-
return {
|
|
139
|
-
read: arg.length,
|
|
140
|
-
written: buf.length
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
let WASM_VECTOR_LEN = 0;
|
|
146
|
-
|
|
147
|
-
function wasm_bindgen__convert__closures_____invoke__hdf270ce0da308ff1(arg0, arg1, arg2) {
|
|
148
|
-
wasm.wasm_bindgen__convert__closures_____invoke__hdf270ce0da308ff1(arg0, arg1, arg2);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function wasm_bindgen__convert__closures_____invoke__h089a09d160a6520b(arg0, arg1, arg2, arg3) {
|
|
152
|
-
wasm.wasm_bindgen__convert__closures_____invoke__h089a09d160a6520b(arg0, arg1, arg2, arg3);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const HighlightConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
156
|
-
? { register: () => {}, unregister: () => {} }
|
|
157
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_highlightconfig_free(ptr >>> 0, 1));
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Configuration for highlighting.
|
|
161
|
-
*/
|
|
162
|
-
export class HighlightConfig {
|
|
163
|
-
__destroy_into_raw() {
|
|
164
|
-
const ptr = this.__wbg_ptr;
|
|
165
|
-
this.__wbg_ptr = 0;
|
|
166
|
-
HighlightConfigFinalization.unregister(this);
|
|
167
|
-
return ptr;
|
|
168
|
-
}
|
|
169
|
-
free() {
|
|
170
|
-
const ptr = this.__destroy_into_raw();
|
|
171
|
-
wasm.__wbg_highlightconfig_free(ptr, 0);
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* @param {number} depth
|
|
175
|
-
*/
|
|
176
|
-
setMaxInjectionDepth(depth) {
|
|
177
|
-
wasm.highlightconfig_setMaxInjectionDepth(this.__wbg_ptr, depth);
|
|
178
|
-
}
|
|
179
|
-
constructor() {
|
|
180
|
-
const ret = wasm.highlightconfig_new();
|
|
181
|
-
this.__wbg_ptr = ret >>> 0;
|
|
182
|
-
HighlightConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
183
|
-
return this;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (Symbol.dispose) HighlightConfig.prototype[Symbol.dispose] = HighlightConfig.prototype.free;
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Highlight source code, resolving injections recursively.
|
|
190
|
-
*
|
|
191
|
-
* This uses the shared `AsyncHighlighter` from `arborium_highlight`,
|
|
192
|
-
* ensuring the same injection handling logic as Rust native.
|
|
193
|
-
* @param {string} language
|
|
194
|
-
* @param {string} source
|
|
195
|
-
* @returns {Promise<string>}
|
|
196
|
-
*/
|
|
197
|
-
export function highlight(language, source) {
|
|
198
|
-
const ptr0 = passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
199
|
-
const len0 = WASM_VECTOR_LEN;
|
|
200
|
-
const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
201
|
-
const len1 = WASM_VECTOR_LEN;
|
|
202
|
-
const ret = wasm.highlight(ptr0, len0, ptr1, len1);
|
|
203
|
-
return ret;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Highlight with custom configuration.
|
|
208
|
-
* @param {string} language
|
|
209
|
-
* @param {string} source
|
|
210
|
-
* @param {HighlightConfig} config
|
|
211
|
-
* @returns {Promise<string>}
|
|
212
|
-
*/
|
|
213
|
-
export function highlightWithConfig(language, source, config) {
|
|
214
|
-
const ptr0 = passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
215
|
-
const len0 = WASM_VECTOR_LEN;
|
|
216
|
-
const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
217
|
-
const len1 = WASM_VECTOR_LEN;
|
|
218
|
-
_assertClass(config, HighlightConfig);
|
|
219
|
-
var ptr2 = config.__destroy_into_raw();
|
|
220
|
-
const ret = wasm.highlightWithConfig(ptr0, len0, ptr1, len1, ptr2);
|
|
221
|
-
return ret;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Check if a language is available for highlighting.
|
|
226
|
-
* @param {string} language
|
|
227
|
-
* @returns {boolean}
|
|
228
|
-
*/
|
|
229
|
-
export function isLanguageAvailable(language) {
|
|
230
|
-
const ptr0 = passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
231
|
-
const len0 = WASM_VECTOR_LEN;
|
|
232
|
-
const ret = wasm.isLanguageAvailable(ptr0, len0);
|
|
233
|
-
return ret !== 0;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
237
|
-
|
|
238
|
-
async function __wbg_load(module, imports) {
|
|
239
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
240
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
241
|
-
try {
|
|
242
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
243
|
-
} catch (e) {
|
|
244
|
-
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
245
|
-
|
|
246
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
247
|
-
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
248
|
-
|
|
249
|
-
} else {
|
|
250
|
-
throw e;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const bytes = await module.arrayBuffer();
|
|
256
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
257
|
-
} else {
|
|
258
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
259
|
-
|
|
260
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
261
|
-
return { instance, module };
|
|
262
|
-
} else {
|
|
263
|
-
return instance;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function __wbg_get_imports() {
|
|
269
|
-
const imports = {};
|
|
270
|
-
imports.wbg = {};
|
|
271
|
-
imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
|
|
272
|
-
const v = arg0;
|
|
273
|
-
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
274
|
-
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
275
|
-
};
|
|
276
|
-
imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
|
277
|
-
const ret = typeof(arg0) === 'function';
|
|
278
|
-
return ret;
|
|
279
|
-
};
|
|
280
|
-
imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
|
|
281
|
-
const ret = arg0 === null;
|
|
282
|
-
return ret;
|
|
283
|
-
};
|
|
284
|
-
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
285
|
-
const ret = arg0 === undefined;
|
|
286
|
-
return ret;
|
|
287
|
-
};
|
|
288
|
-
imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
|
|
289
|
-
const obj = arg1;
|
|
290
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
291
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
292
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
293
|
-
};
|
|
294
|
-
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
295
|
-
const obj = arg1;
|
|
296
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
297
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
298
|
-
var len1 = WASM_VECTOR_LEN;
|
|
299
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
300
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
301
|
-
};
|
|
302
|
-
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
303
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
304
|
-
};
|
|
305
|
-
imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
|
|
306
|
-
arg0._wbg_cb_unref();
|
|
307
|
-
};
|
|
308
|
-
imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
309
|
-
const ret = arg0.call(arg1, arg2);
|
|
310
|
-
return ret;
|
|
311
|
-
}, arguments) };
|
|
312
|
-
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
|
313
|
-
const ret = arg0.call(arg1);
|
|
314
|
-
return ret;
|
|
315
|
-
}, arguments) };
|
|
316
|
-
imports.wbg.__wbg_from_29a8414a7a7cd19d = function(arg0) {
|
|
317
|
-
const ret = Array.from(arg0);
|
|
318
|
-
return ret;
|
|
319
|
-
};
|
|
320
|
-
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
321
|
-
const ret = arg0[arg1 >>> 0];
|
|
322
|
-
return ret;
|
|
323
|
-
};
|
|
324
|
-
imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
|
|
325
|
-
const ret = Reflect.get(arg0, arg1);
|
|
326
|
-
return ret;
|
|
327
|
-
}, arguments) };
|
|
328
|
-
imports.wbg.__wbg_isLanguageAvailable_4c54f1a0e6d0f988 = function(arg0, arg1) {
|
|
329
|
-
const ret = arboriumHost.isLanguageAvailable(getStringFromWasm0(arg0, arg1));
|
|
330
|
-
return ret;
|
|
331
|
-
};
|
|
332
|
-
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
333
|
-
const ret = arg0.length;
|
|
334
|
-
return ret;
|
|
335
|
-
};
|
|
336
|
-
imports.wbg.__wbg_loadGrammar_ed5aea14822a78db = function() { return handleError(function (arg0, arg1) {
|
|
337
|
-
const ret = arboriumHost.loadGrammar(getStringFromWasm0(arg0, arg1));
|
|
338
|
-
return ret;
|
|
339
|
-
}, arguments) };
|
|
340
|
-
imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
|
|
341
|
-
try {
|
|
342
|
-
var state0 = {a: arg0, b: arg1};
|
|
343
|
-
var cb0 = (arg0, arg1) => {
|
|
344
|
-
const a = state0.a;
|
|
345
|
-
state0.a = 0;
|
|
346
|
-
try {
|
|
347
|
-
return wasm_bindgen__convert__closures_____invoke__h089a09d160a6520b(a, state0.b, arg0, arg1);
|
|
348
|
-
} finally {
|
|
349
|
-
state0.a = a;
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
const ret = new Promise(cb0);
|
|
353
|
-
return ret;
|
|
354
|
-
} finally {
|
|
355
|
-
state0.a = state0.b = 0;
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
359
|
-
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
360
|
-
return ret;
|
|
361
|
-
};
|
|
362
|
-
imports.wbg.__wbg_parse_98cc2457c24f4b01 = function(arg0, arg1, arg2) {
|
|
363
|
-
const ret = arboriumHost.parse(arg0 >>> 0, getStringFromWasm0(arg1, arg2));
|
|
364
|
-
return ret;
|
|
365
|
-
};
|
|
366
|
-
imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
|
|
367
|
-
const ret = arg0.queueMicrotask;
|
|
368
|
-
return ret;
|
|
369
|
-
};
|
|
370
|
-
imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
|
|
371
|
-
queueMicrotask(arg0);
|
|
372
|
-
};
|
|
373
|
-
imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
|
|
374
|
-
const ret = Promise.resolve(arg0);
|
|
375
|
-
return ret;
|
|
376
|
-
};
|
|
377
|
-
imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
|
378
|
-
const ret = typeof global === 'undefined' ? null : global;
|
|
379
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
380
|
-
};
|
|
381
|
-
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
382
|
-
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
383
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
384
|
-
};
|
|
385
|
-
imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
386
|
-
const ret = typeof self === 'undefined' ? null : self;
|
|
387
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
388
|
-
};
|
|
389
|
-
imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
|
390
|
-
const ret = typeof window === 'undefined' ? null : window;
|
|
391
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
392
|
-
};
|
|
393
|
-
imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) {
|
|
394
|
-
const ret = arg0.then(arg1, arg2);
|
|
395
|
-
return ret;
|
|
396
|
-
};
|
|
397
|
-
imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
|
|
398
|
-
const ret = arg0.then(arg1);
|
|
399
|
-
return ret;
|
|
400
|
-
};
|
|
401
|
-
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
402
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
403
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
404
|
-
return ret;
|
|
405
|
-
};
|
|
406
|
-
imports.wbg.__wbindgen_cast_3b1a32895b770b74 = function(arg0, arg1) {
|
|
407
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 10, function: Function { arguments: [Externref], shim_idx: 11, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
408
|
-
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hd7b7e163837b9c9e, wasm_bindgen__convert__closures_____invoke__hdf270ce0da308ff1);
|
|
409
|
-
return ret;
|
|
410
|
-
};
|
|
411
|
-
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
412
|
-
const table = wasm.__wbindgen_externrefs;
|
|
413
|
-
const offset = table.grow(4);
|
|
414
|
-
table.set(0, undefined);
|
|
415
|
-
table.set(offset + 0, undefined);
|
|
416
|
-
table.set(offset + 1, null);
|
|
417
|
-
table.set(offset + 2, true);
|
|
418
|
-
table.set(offset + 3, false);
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
return imports;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
function __wbg_finalize_init(instance, module) {
|
|
425
|
-
wasm = instance.exports;
|
|
426
|
-
__wbg_init.__wbindgen_wasm_module = module;
|
|
427
|
-
cachedDataViewMemory0 = null;
|
|
428
|
-
cachedUint8ArrayMemory0 = null;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
wasm.__wbindgen_start();
|
|
432
|
-
return wasm;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
function initSync(module) {
|
|
436
|
-
if (wasm !== undefined) return wasm;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (typeof module !== 'undefined') {
|
|
440
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
441
|
-
({module} = module)
|
|
442
|
-
} else {
|
|
443
|
-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
const imports = __wbg_get_imports();
|
|
448
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
449
|
-
module = new WebAssembly.Module(module);
|
|
450
|
-
}
|
|
451
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
452
|
-
return __wbg_finalize_init(instance, module);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
async function __wbg_init(module_or_path) {
|
|
456
|
-
if (wasm !== undefined) return wasm;
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (typeof module_or_path !== 'undefined') {
|
|
460
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
461
|
-
({module_or_path} = module_or_path)
|
|
462
|
-
} else {
|
|
463
|
-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (typeof module_or_path === 'undefined') {
|
|
468
|
-
module_or_path = new URL('arborium_host_bg.wasm', import.meta.url);
|
|
469
|
-
}
|
|
470
|
-
const imports = __wbg_get_imports();
|
|
471
|
-
|
|
472
|
-
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
473
|
-
module_or_path = fetch(module_or_path);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
477
|
-
|
|
478
|
-
return __wbg_finalize_init(instance, module);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
export { initSync };
|
|
482
|
-
export default __wbg_init;
|
|
Binary file
|
package/dist/detect.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple language detection heuristics.
|
|
3
|
-
* Not meant to be comprehensive - just catches common cases.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Detect the language of a code snippet.
|
|
7
|
-
* Returns null if detection fails.
|
|
8
|
-
*/
|
|
9
|
-
export declare function detectLanguage(source: string): string | null;
|
|
10
|
-
/**
|
|
11
|
-
* Extract language from class name (e.g., "language-rust" -> "rust")
|
|
12
|
-
*/
|
|
13
|
-
export declare function extractLanguageFromClass(className: string): string | null;
|
|
14
|
-
/**
|
|
15
|
-
* Normalize language identifier (handle aliases)
|
|
16
|
-
*/
|
|
17
|
-
export declare function normalizeLanguage(lang: string): string;
|
package/dist/iife.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @arborium/arborium IIFE bundle
|
|
3
|
-
*
|
|
4
|
-
* Drop-in auto-highlighter that runs on page load.
|
|
5
|
-
* Configuration via data attributes or window.Arborium object.
|
|
6
|
-
*/
|
|
7
|
-
import type { ArboriumConfig } from './types.js';
|
|
8
|
-
/** Public API for manual highlighting */
|
|
9
|
-
export declare function highlightAll(config?: ArboriumConfig): Promise<void>;
|
|
10
|
-
/** Public API for highlighting a specific element */
|
|
11
|
-
export declare function highlightElement(element: HTMLElement, language?: string, config?: ArboriumConfig): Promise<void>;
|
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @arborium/arborium - High-performance syntax highlighting
|
|
3
|
-
*
|
|
4
|
-
* ESM entry point for programmatic usage.
|
|
5
|
-
*/
|
|
6
|
-
export { loadGrammar, highlight, spansToHtml, getConfig } from './loader.js';
|
|
7
|
-
export { detectLanguage, extractLanguageFromClass, normalizeLanguage } from './detect.js';
|
|
8
|
-
export type { Grammar, Span, Injection, ParseResult, ArboriumConfig, } from './types.js';
|
package/dist/loader.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Arborium loader - loads grammar plugins and highlights code.
|
|
3
|
-
*
|
|
4
|
-
* Architecture:
|
|
5
|
-
* 1. Fetch plugins.json from arborium.bearcove.eu to get grammar CDN URLs
|
|
6
|
-
* 2. Load grammar WIT components on demand from @arborium/<lang> packages
|
|
7
|
-
* 3. Parse and highlight using the grammar's tree-sitter parser
|
|
8
|
-
*/
|
|
9
|
-
import type { ArboriumConfig, Grammar, Span } from './types.js';
|
|
10
|
-
export declare const defaultConfig: Required<ArboriumConfig>;
|
|
11
|
-
/** Highlight source code */
|
|
12
|
-
export declare function highlight(language: string, source: string, _config?: ArboriumConfig): Promise<string>;
|
|
13
|
-
/** Load a grammar for direct use */
|
|
14
|
-
export declare function loadGrammar(language: string, _config?: ArboriumConfig): Promise<Grammar | null>;
|
|
15
|
-
/** Convert spans to HTML */
|
|
16
|
-
export declare function spansToHtml(source: string, spans: Span[]): string;
|
|
17
|
-
/** Get current config, optionally merging with overrides */
|
|
18
|
-
export declare function getConfig(overrides?: Partial<ArboriumConfig>): Required<ArboriumConfig>;
|
|
19
|
-
/** Set/merge config */
|
|
20
|
-
export declare function setConfig(newConfig: Partial<ArboriumConfig>): void;
|
|
21
|
-
/** Check if a language is available */
|
|
22
|
-
export declare function isLanguageAvailable(language: string): Promise<boolean>;
|
|
23
|
-
/** Get list of available languages */
|
|
24
|
-
export declare function getAvailableLanguages(): Promise<string[]>;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitHub Light theme for Arborium
|
|
3
|
-
* Based on https://github.com/primer/github-syntax-light
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/* Code block styling */
|
|
7
|
-
pre:has(code[data-highlighted]) {
|
|
8
|
-
background-color: #f6f8fa;
|
|
9
|
-
color: #24292e;
|
|
10
|
-
padding: 1em;
|
|
11
|
-
border-radius: 6px;
|
|
12
|
-
overflow-x: auto;
|
|
13
|
-
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
14
|
-
font-size: 0.9em;
|
|
15
|
-
line-height: 1.5;
|
|
16
|
-
border: 1px solid #e1e4e8;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
code[data-highlighted] {
|
|
20
|
-
background: transparent;
|
|
21
|
-
font-family: inherit;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/* Keywords: if, else, for, while, fn, let, const, etc. */
|
|
25
|
-
a-k {
|
|
26
|
-
color: #d73a49;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Strings */
|
|
30
|
-
a-s {
|
|
31
|
-
color: #032f62;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/* Comments */
|
|
35
|
-
a-c {
|
|
36
|
-
color: #6a737d;
|
|
37
|
-
font-style: italic;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/* Functions */
|
|
41
|
-
a-f {
|
|
42
|
-
color: #6f42c1;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/* Types */
|
|
46
|
-
a-t {
|
|
47
|
-
color: #6f42c1;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* Variables */
|
|
51
|
-
a-v {
|
|
52
|
-
color: #24292e;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/* Built-in variables (self, this, etc.) */
|
|
56
|
-
a-vb {
|
|
57
|
-
color: #005cc5;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* Numbers */
|
|
61
|
-
a-n {
|
|
62
|
-
color: #005cc5;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/* Operators */
|
|
66
|
-
a-o {
|
|
67
|
-
color: #d73a49;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* Punctuation (brackets, delimiters) */
|
|
71
|
-
a-p {
|
|
72
|
-
color: #24292e;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/* Constants */
|
|
76
|
-
a-ct {
|
|
77
|
-
color: #005cc5;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* Built-in constants (true, false, null, etc.) */
|
|
81
|
-
a-cb {
|
|
82
|
-
color: #005cc5;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/* Properties */
|
|
86
|
-
a-pr {
|
|
87
|
-
color: #005cc5;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/* Attributes (HTML/XML attributes, decorators) */
|
|
91
|
-
a-at {
|
|
92
|
-
color: #6f42c1;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/* Tags (HTML/XML tags) */
|
|
96
|
-
a-tg {
|
|
97
|
-
color: #22863a;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/* Namespaces */
|
|
101
|
-
a-ns {
|
|
102
|
-
color: #6f42c1;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/* Labels */
|
|
106
|
-
a-lb {
|
|
107
|
-
color: #e36209;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* Escape sequences */
|
|
111
|
-
a-e {
|
|
112
|
-
color: #005cc5;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/* Embedded code */
|
|
116
|
-
a-em {
|
|
117
|
-
color: #24292e;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/* Unknown/fallback */
|
|
121
|
-
a-x {
|
|
122
|
-
color: #24292e;
|
|
123
|
-
}
|