@arborium/just 2.17.0 → 2.18.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/grammar.js +201 -3
- package/grammar_bg.wasm +0 -0
- package/package.json +25 -22
- package/README.md +0 -65
package/grammar.js
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
/* @ts-self-types="./arborium_just_plugin.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Applies an incremental edit to a session and re-parses its tree incrementally.
|
|
5
|
+
*
|
|
6
|
+
* `new_text` is the full text after the edit; `edit` is an `arborium_wire::Edit`
|
|
7
|
+
* (UTF-8 byte offsets + row/col points). Call `parse` / `parse_utf16` afterwards
|
|
8
|
+
* to read the updated spans — this is what makes editor highlighting fast, since
|
|
9
|
+
* tree-sitter reuses the unchanged parts of the previous tree.
|
|
10
|
+
* @param {number} session
|
|
11
|
+
* @param {string} new_text
|
|
12
|
+
* @param {any} edit
|
|
13
|
+
*/
|
|
14
|
+
export function apply_edit(session, new_text, edit) {
|
|
15
|
+
try {
|
|
16
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
17
|
+
const ptr0 = passStringToWasm0(new_text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
18
|
+
const len0 = WASM_VECTOR_LEN;
|
|
19
|
+
wasm.apply_edit(retptr, session, ptr0, len0, addHeapObject(edit));
|
|
20
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
21
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
22
|
+
if (r1) {
|
|
23
|
+
throw takeObject(r0);
|
|
24
|
+
}
|
|
25
|
+
} finally {
|
|
26
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
3
30
|
/**
|
|
4
31
|
* Cancels an ongoing parse operation.
|
|
5
32
|
* @param {number} session
|
|
@@ -37,7 +64,7 @@ export function injection_languages() {
|
|
|
37
64
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
38
65
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
39
66
|
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
40
|
-
wasm.
|
|
67
|
+
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
41
68
|
return v1;
|
|
42
69
|
} finally {
|
|
43
70
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -61,7 +88,7 @@ export function language_id() {
|
|
|
61
88
|
return getStringFromWasm0(r0, r1);
|
|
62
89
|
} finally {
|
|
63
90
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
64
|
-
wasm.
|
|
91
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
65
92
|
}
|
|
66
93
|
}
|
|
67
94
|
|
|
@@ -119,7 +146,7 @@ export function parse_utf16(session) {
|
|
|
119
146
|
* @param {string} text
|
|
120
147
|
*/
|
|
121
148
|
export function set_text(session, text) {
|
|
122
|
-
const ptr0 = passStringToWasm0(text, wasm.
|
|
149
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
123
150
|
const len0 = WASM_VECTOR_LEN;
|
|
124
151
|
wasm.set_text(session, ptr0, len0);
|
|
125
152
|
}
|
|
@@ -127,9 +154,103 @@ export function set_text(session, text) {
|
|
|
127
154
|
function __wbg_get_imports() {
|
|
128
155
|
const import0 = {
|
|
129
156
|
__proto__: null,
|
|
157
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
158
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
159
|
+
return addHeapObject(ret);
|
|
160
|
+
},
|
|
161
|
+
__wbg_Number_a5a435bd7bbec835: function(arg0) {
|
|
162
|
+
const ret = Number(getObject(arg0));
|
|
163
|
+
return ret;
|
|
164
|
+
},
|
|
165
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
166
|
+
const ret = String(getObject(arg1));
|
|
167
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
168
|
+
const len1 = WASM_VECTOR_LEN;
|
|
169
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
170
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
171
|
+
},
|
|
172
|
+
__wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) {
|
|
173
|
+
const v = getObject(arg0);
|
|
174
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
175
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
176
|
+
},
|
|
177
|
+
__wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
|
|
178
|
+
const ret = debugString(getObject(arg1));
|
|
179
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
180
|
+
const len1 = WASM_VECTOR_LEN;
|
|
181
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
182
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
183
|
+
},
|
|
184
|
+
__wbg___wbindgen_in_41dbb8413020e076: function(arg0, arg1) {
|
|
185
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
186
|
+
return ret;
|
|
187
|
+
},
|
|
188
|
+
__wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
|
|
189
|
+
const val = getObject(arg0);
|
|
190
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
191
|
+
return ret;
|
|
192
|
+
},
|
|
193
|
+
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
194
|
+
const ret = getObject(arg0) === undefined;
|
|
195
|
+
return ret;
|
|
196
|
+
},
|
|
197
|
+
__wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b: function(arg0, arg1) {
|
|
198
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
199
|
+
return ret;
|
|
200
|
+
},
|
|
201
|
+
__wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
|
|
202
|
+
const obj = getObject(arg1);
|
|
203
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
204
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
205
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
206
|
+
},
|
|
207
|
+
__wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
|
|
208
|
+
const obj = getObject(arg1);
|
|
209
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
210
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
211
|
+
var len1 = WASM_VECTOR_LEN;
|
|
212
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
213
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
214
|
+
},
|
|
130
215
|
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
131
216
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
132
217
|
},
|
|
218
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
219
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
220
|
+
return addHeapObject(ret);
|
|
221
|
+
},
|
|
222
|
+
__wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
|
|
223
|
+
let result;
|
|
224
|
+
try {
|
|
225
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
226
|
+
} catch (_) {
|
|
227
|
+
result = false;
|
|
228
|
+
}
|
|
229
|
+
const ret = result;
|
|
230
|
+
return ret;
|
|
231
|
+
},
|
|
232
|
+
__wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
|
|
233
|
+
let result;
|
|
234
|
+
try {
|
|
235
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
236
|
+
} catch (_) {
|
|
237
|
+
result = false;
|
|
238
|
+
}
|
|
239
|
+
const ret = result;
|
|
240
|
+
return ret;
|
|
241
|
+
},
|
|
242
|
+
__wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
|
|
243
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
244
|
+
return ret;
|
|
245
|
+
},
|
|
246
|
+
__wbg_length_ea16607d7b61445b: function(arg0) {
|
|
247
|
+
const ret = getObject(arg0).length;
|
|
248
|
+
return ret;
|
|
249
|
+
},
|
|
250
|
+
__wbg_new_5f486cdf45a04d78: function(arg0) {
|
|
251
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
252
|
+
return addHeapObject(ret);
|
|
253
|
+
},
|
|
133
254
|
__wbg_new_a70fbab9066b301f: function() {
|
|
134
255
|
const ret = new Array();
|
|
135
256
|
return addHeapObject(ret);
|
|
@@ -138,6 +259,9 @@ function __wbg_get_imports() {
|
|
|
138
259
|
const ret = new Object();
|
|
139
260
|
return addHeapObject(ret);
|
|
140
261
|
},
|
|
262
|
+
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
263
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
264
|
+
},
|
|
141
265
|
__wbg_set_282384002438957f: function(arg0, arg1, arg2) {
|
|
142
266
|
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
143
267
|
},
|
|
@@ -177,6 +301,71 @@ function addHeapObject(obj) {
|
|
|
177
301
|
return idx;
|
|
178
302
|
}
|
|
179
303
|
|
|
304
|
+
function debugString(val) {
|
|
305
|
+
// primitive types
|
|
306
|
+
const type = typeof val;
|
|
307
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
308
|
+
return `${val}`;
|
|
309
|
+
}
|
|
310
|
+
if (type == 'string') {
|
|
311
|
+
return `"${val}"`;
|
|
312
|
+
}
|
|
313
|
+
if (type == 'symbol') {
|
|
314
|
+
const description = val.description;
|
|
315
|
+
if (description == null) {
|
|
316
|
+
return 'Symbol';
|
|
317
|
+
} else {
|
|
318
|
+
return `Symbol(${description})`;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (type == 'function') {
|
|
322
|
+
const name = val.name;
|
|
323
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
324
|
+
return `Function(${name})`;
|
|
325
|
+
} else {
|
|
326
|
+
return 'Function';
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// objects
|
|
330
|
+
if (Array.isArray(val)) {
|
|
331
|
+
const length = val.length;
|
|
332
|
+
let debug = '[';
|
|
333
|
+
if (length > 0) {
|
|
334
|
+
debug += debugString(val[0]);
|
|
335
|
+
}
|
|
336
|
+
for(let i = 1; i < length; i++) {
|
|
337
|
+
debug += ', ' + debugString(val[i]);
|
|
338
|
+
}
|
|
339
|
+
debug += ']';
|
|
340
|
+
return debug;
|
|
341
|
+
}
|
|
342
|
+
// Test for built-in
|
|
343
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
344
|
+
let className;
|
|
345
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
346
|
+
className = builtInMatches[1];
|
|
347
|
+
} else {
|
|
348
|
+
// Failed to match the standard '[object ClassName]'
|
|
349
|
+
return toString.call(val);
|
|
350
|
+
}
|
|
351
|
+
if (className == 'Object') {
|
|
352
|
+
// we're a user defined class or Object
|
|
353
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
354
|
+
// easier than looping through ownProperties of `val`.
|
|
355
|
+
try {
|
|
356
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
357
|
+
} catch (_) {
|
|
358
|
+
return 'Object';
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// errors
|
|
362
|
+
if (val instanceof Error) {
|
|
363
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
364
|
+
}
|
|
365
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
366
|
+
return className;
|
|
367
|
+
}
|
|
368
|
+
|
|
180
369
|
function dropObject(idx) {
|
|
181
370
|
if (idx < 1028) return;
|
|
182
371
|
heap[idx] = heap_next;
|
|
@@ -193,6 +382,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
193
382
|
return result;
|
|
194
383
|
}
|
|
195
384
|
|
|
385
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
386
|
+
ptr = ptr >>> 0;
|
|
387
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
388
|
+
}
|
|
389
|
+
|
|
196
390
|
let cachedDataViewMemory0 = null;
|
|
197
391
|
function getDataViewMemory0() {
|
|
198
392
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -221,6 +415,10 @@ heap.push(undefined, null, true, false);
|
|
|
221
415
|
|
|
222
416
|
let heap_next = heap.length;
|
|
223
417
|
|
|
418
|
+
function isLikeNone(x) {
|
|
419
|
+
return x === undefined || x === null;
|
|
420
|
+
}
|
|
421
|
+
|
|
224
422
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
225
423
|
if (realloc === undefined) {
|
|
226
424
|
const buf = cachedTextEncoder.encode(arg);
|
package/grammar_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
2
|
+
"author": "Amos Wenger <amos@bearcove.eu>",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/bearcove/arborium/issues"
|
|
5
|
+
},
|
|
4
6
|
"description": "Syntax highlighting for Just, powered by WebAssembly",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18"
|
|
9
|
+
},
|
|
8
10
|
"exports": {
|
|
9
11
|
".": "./grammar.js",
|
|
10
12
|
"./grammar.js": "./grammar.js",
|
|
11
13
|
"./grammar_bg.wasm": "./grammar_bg.wasm"
|
|
12
14
|
},
|
|
13
|
-
"files": [
|
|
14
|
-
|
|
15
|
+
"files": [
|
|
16
|
+
"grammar.js",
|
|
17
|
+
"grammar_bg.wasm"
|
|
18
|
+
],
|
|
19
|
+
"funding": {
|
|
20
|
+
"type": "github",
|
|
21
|
+
"url": "https://github.com/sponsors/fasterthanlime"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/bearcove/arborium",
|
|
15
24
|
"keywords": [
|
|
16
25
|
"arborium",
|
|
17
26
|
"syntax-highlighting",
|
|
@@ -20,24 +29,18 @@
|
|
|
20
29
|
"Just",
|
|
21
30
|
"wasm"
|
|
22
31
|
],
|
|
23
|
-
"author": "Amos Wenger <amos@bearcove.eu>",
|
|
24
32
|
"license": "MIT",
|
|
33
|
+
"main": "./grammar.js",
|
|
34
|
+
"module": "./grammar.js",
|
|
35
|
+
"name": "@arborium/just",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
25
39
|
"repository": {
|
|
26
40
|
"type": "git",
|
|
27
41
|
"url": "https://github.com/bearcove/arborium"
|
|
28
42
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
"funding": {
|
|
34
|
-
"type": "github",
|
|
35
|
-
"url": "https://github.com/sponsors/fasterthanlime"
|
|
36
|
-
},
|
|
37
|
-
"engines": {
|
|
38
|
-
"node": ">=18"
|
|
39
|
-
},
|
|
40
|
-
"publishConfig": {
|
|
41
|
-
"access": "public"
|
|
42
|
-
}
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"type": "module",
|
|
45
|
+
"version": "2.18.0"
|
|
43
46
|
}
|
package/README.md
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# @arborium/just
|
|
2
|
-
|
|
3
|
-
[](https://github.com/bearcove/arborium)
|
|
4
|
-
[](https://www.npmjs.com/package/@arborium/just)
|
|
5
|
-
[](https://github.com/bearcove/arborium)
|
|
6
|
-
|
|
7
|
-
Syntax highlighting for [Just](https://just.systems/), powered by WebAssembly and [tree-sitter](https://tree-sitter.github.io/).
|
|
8
|
-
|
|
9
|
-
> Just a command runner.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
| | |
|
|
13
|
-
|---|---|
|
|
14
|
-
| **Inventor** | Casey Rodarmor |
|
|
15
|
-
| **Year** | 2016 |
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install @arborium/just
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
```javascript
|
|
26
|
-
import { createHighlighter } from '@arborium/arborium';
|
|
27
|
-
import * as grammar from '@arborium/just';
|
|
28
|
-
|
|
29
|
-
const highlighter = await createHighlighter();
|
|
30
|
-
await highlighter.loadGrammar(grammar);
|
|
31
|
-
|
|
32
|
-
const html = highlighter.highlight(code, 'just');
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## What's included
|
|
36
|
-
|
|
37
|
-
This package contains:
|
|
38
|
-
|
|
39
|
-
- `grammar.js` - ES module that loads the WebAssembly grammar
|
|
40
|
-
- `grammar.d.ts` - TypeScript type definitions
|
|
41
|
-
- `grammar_bg.wasm` - The tree-sitter grammar compiled to WebAssembly
|
|
42
|
-
|
|
43
|
-
## About Arborium
|
|
44
|
-
|
|
45
|
-
This package is part of [**Arborium**](https://github.com/bearcove/arborium), a collection of tree-sitter grammars for syntax highlighting, maintained by [Amos Wenger](https://fasterthanli.me).
|
|
46
|
-
|
|
47
|
-
Arborium provides:
|
|
48
|
-
- **98+ language grammars** compiled to WebAssembly
|
|
49
|
-
- **Browser and Node.js support** via ES modules
|
|
50
|
-
- **TypeScript definitions** for all packages
|
|
51
|
-
- **Consistent API** across all grammars
|
|
52
|
-
|
|
53
|
-
## Related packages
|
|
54
|
-
|
|
55
|
-
- [`@arborium/arborium`](https://www.npmjs.com/package/@arborium/arborium) - Core highlighter library
|
|
56
|
-
- [All @arborium packages](https://www.npmjs.com/org/arborium)
|
|
57
|
-
|
|
58
|
-
## License
|
|
59
|
-
|
|
60
|
-
MIT OR Apache-2.0
|
|
61
|
-
|
|
62
|
-
## Links
|
|
63
|
-
|
|
64
|
-
- [GitHub](https://github.com/bearcove/arborium)
|
|
65
|
-
- [Issues](https://github.com/bearcove/arborium/issues)
|