@arborium/postscript 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 CHANGED
@@ -1,5 +1,32 @@
1
1
  /* @ts-self-types="./arborium_postscript_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.__wbindgen_export(r0, r1 * 4, 4);
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.__wbindgen_export(deferred1_0, deferred1_1, 1);
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.__wbindgen_export2, wasm.__wbindgen_export3);
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
@@ -42,5 +42,5 @@
42
42
  },
43
43
  "sideEffects": false,
44
44
  "type": "module",
45
- "version": "2.17.0"
45
+ "version": "2.18.0"
46
46
  }