@gmb/bitmark-parser 6.11.1 → 7.1.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.
Files changed (45) hide show
  1. package/README.md +361 -57
  2. package/dist/browser/bitmark-parser.min.js +4 -4
  3. package/dist/browser/bitmark-parser.min.js.map +1 -1
  4. package/dist/browser/cjs/index.cjs +966 -372
  5. package/dist/browser/cjs/index.cjs.map +1 -1
  6. package/dist/browser/cjs/index.d.cts +642 -70
  7. package/dist/browser/esm/index.d.ts +642 -70
  8. package/dist/browser/esm/index.js +958 -371
  9. package/dist/browser/esm/index.js.map +1 -1
  10. package/dist/browser/esm/worker-entry.js +790 -247
  11. package/dist/browser/esm/worker-entry.js.map +1 -1
  12. package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
  13. package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
  14. package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
  15. package/dist/index.cjs +163 -124
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +637 -70
  18. package/dist/index.d.ts +637 -70
  19. package/dist/index.js +155 -123
  20. package/dist/index.js.map +1 -1
  21. package/dist/legacy.cjs +8 -30
  22. package/dist/legacy.cjs.map +1 -1
  23. package/dist/legacy.d.cts +0 -2
  24. package/dist/legacy.d.ts +0 -2
  25. package/dist/legacy.js +8 -30
  26. package/dist/legacy.js.map +1 -1
  27. package/dist/worker-entry.cjs +1 -5
  28. package/dist/worker-entry.cjs.map +1 -1
  29. package/package.json +7 -7
  30. package/schema/bitmark.schema.json +507 -141
  31. package/wasm/bitmark_wasm.d.ts +65 -26
  32. package/wasm/bitmark_wasm.js +348 -116
  33. package/wasm/bitmark_wasm_bg.wasm +0 -0
  34. package/wasm/bitmark_wasm_bg.wasm.d.ts +6 -3
  35. package/wasm/package.json +1 -1
  36. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +56 -15
  37. package/wasm-bitmark-json/bitmark_json_wasm.js +321 -77
  38. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  39. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +5 -2
  40. package/wasm-bitmark-json/package.json +1 -1
  41. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +65 -26
  42. package/wasm-browser-full/bitmark_browser_full_wasm.js +348 -116
  43. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
  44. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +6 -3
  45. package/wasm-browser-full/package.json +1 -1
@@ -1,9 +1,12 @@
1
1
 
2
2
  let imports = {};
3
+ imports['__wbindgen_placeholder__'] = module.exports;
3
4
  let wasm;
4
- const { TextEncoder, TextDecoder } = require(`util`);
5
+ const { TextDecoder, TextEncoder } = require(`util`);
5
6
 
6
- let WASM_VECTOR_LEN = 0;
7
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
8
+
9
+ cachedTextDecoder.decode();
7
10
 
8
11
  let cachedUint8ArrayMemory0 = null;
9
12
 
@@ -14,6 +17,28 @@ function getUint8ArrayMemory0() {
14
17
  return cachedUint8ArrayMemory0;
15
18
  }
16
19
 
20
+ function getStringFromWasm0(ptr, len) {
21
+ ptr = ptr >>> 0;
22
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
23
+ }
24
+
25
+ const heap = new Array(128).fill(undefined);
26
+
27
+ heap.push(undefined, null, true, false);
28
+
29
+ let heap_next = heap.length;
30
+
31
+ function addHeapObject(obj) {
32
+ if (heap_next === heap.length) heap.push(heap.length + 1);
33
+ const idx = heap_next;
34
+ heap_next = heap[idx];
35
+
36
+ heap[idx] = obj;
37
+ return idx;
38
+ }
39
+
40
+ let WASM_VECTOR_LEN = 0;
41
+
17
42
  let cachedTextEncoder = new TextEncoder('utf-8');
18
43
 
19
44
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -76,47 +101,6 @@ function getDataViewMemory0() {
76
101
  }
77
102
  return cachedDataViewMemory0;
78
103
  }
79
-
80
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
81
-
82
- cachedTextDecoder.decode();
83
-
84
- function getStringFromWasm0(ptr, len) {
85
- ptr = ptr >>> 0;
86
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
87
- }
88
- /**
89
- * Lex bitmark input text, returning one line per token in the same format as
90
- * the Rust CLI: `{kind:?} {span:?} "{text}"`.
91
- *
92
- * `stage` selects the lexer pipeline:
93
- * - `"lex"` — combined (default)
94
- * - `"lex-json"` — combined, JSON array output
95
- * @param {string} input
96
- * @param {string} stage
97
- * @returns {string}
98
- */
99
- module.exports.lex = function(input, stage) {
100
- let deferred3_0;
101
- let deferred3_1;
102
- try {
103
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
104
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
105
- const len0 = WASM_VECTOR_LEN;
106
- const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
107
- const len1 = WASM_VECTOR_LEN;
108
- wasm.lex(retptr, ptr0, len0, ptr1, len1);
109
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
110
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
111
- deferred3_0 = r0;
112
- deferred3_1 = r1;
113
- return getStringFromWasm0(r0, r1);
114
- } finally {
115
- wasm.__wbindgen_add_to_stack_pointer(16);
116
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
117
- }
118
- };
119
-
120
104
  /**
121
105
  * Breakscape text (escape bitmark special characters).
122
106
  *
@@ -235,6 +219,31 @@ module.exports.info = function(info_type, format, bit, pretty, indent, include_d
235
219
  }
236
220
  };
237
221
 
222
+ /**
223
+ * Whether this build can render `info` as TEXT (PLAN-192 D6). The export is
224
+ * ABSENT when it cannot — the same "presence is the capability" signal
225
+ * `diff` uses, so a caller tests for the function rather than for a
226
+ * variant name.
227
+ * @returns {boolean}
228
+ */
229
+ module.exports.info_text_supported = function() {
230
+ const ret = wasm.info_text_supported();
231
+ return ret !== 0;
232
+ };
233
+
234
+ function getObject(idx) { return heap[idx]; }
235
+
236
+ function dropObject(idx) {
237
+ if (idx < 132) return;
238
+ heap[idx] = heap_next;
239
+ heap_next = idx;
240
+ }
241
+
242
+ function takeObject(idx) {
243
+ const ret = getObject(idx);
244
+ dropObject(idx);
245
+ return ret;
246
+ }
238
247
  /**
239
248
  * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).
240
249
  *
@@ -242,7 +251,7 @@ module.exports.info = function(info_type, format, bit, pretty, indent, include_d
242
251
  * `format`: a bitmark text format (`"bitmark++"`, `"bitmark+"`) parses
243
252
  * inline marks; anything else is treated as plain text (textToAst only).
244
253
  * `location`: `"body"` (default) or `"tag"`.
245
- * Returns the converted fragment, or `error: …`.
254
+ * Returns the converted fragment; throws on failure.
246
255
  * @param {string} input
247
256
  * @param {string} direction
248
257
  * @param {string} format
@@ -250,8 +259,8 @@ module.exports.info = function(info_type, format, bit, pretty, indent, include_d
250
259
  * @returns {string}
251
260
  */
252
261
  module.exports.convert_text = function(input, direction, format, location) {
253
- let deferred5_0;
254
- let deferred5_1;
262
+ let deferred6_0;
263
+ let deferred6_1;
255
264
  try {
256
265
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
257
266
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -265,12 +274,20 @@ module.exports.convert_text = function(input, direction, format, location) {
265
274
  wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
266
275
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
267
276
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
268
- deferred5_0 = r0;
269
- deferred5_1 = r1;
270
- return getStringFromWasm0(r0, r1);
277
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
278
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
279
+ var ptr5 = r0;
280
+ var len5 = r1;
281
+ if (r3) {
282
+ ptr5 = 0; len5 = 0;
283
+ throw takeObject(r2);
284
+ }
285
+ deferred6_0 = ptr5;
286
+ deferred6_1 = len5;
287
+ return getStringFromWasm0(ptr5, len5);
271
288
  } finally {
272
289
  wasm.__wbindgen_add_to_stack_pointer(16);
273
- wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
290
+ wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
274
291
  }
275
292
  };
276
293
 
@@ -278,10 +295,14 @@ module.exports.convert_text = function(input, direction, format, location) {
278
295
  * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
279
296
  *
280
297
  * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
281
- * `output_format_sel`: `"bitmark"` | `"json"` (default json).
298
+ * `output_format_sel`: the same vocabulary as `convert` — `"bitmark"` |
299
+ * `"json"` | `"text"` | a mapping id (`"html"`, …), `"auto"` (or empty) being
300
+ * the opposite of the resolved input format. The whole-document outputs
301
+ * (`lex`, `semantic-tokens`, `diagnostics`) are not per-bit formats; the
302
+ * pipeline refuses them and that refusal is what throws.
282
303
  * `patch_json`: the patch entry array (empty string = no patches, i.e. a
283
304
  * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
284
- * runs sequentially. Returns the document text/JSON, or `error: …`.
305
+ * runs sequentially. Returns the document text/JSON; throws on failure.
285
306
  * @param {string} input
286
307
  * @param {string} input_format_sel
287
308
  * @param {string} output_format_sel
@@ -293,8 +314,8 @@ module.exports.convert_text = function(input, direction, format, location) {
293
314
  * @returns {string}
294
315
  */
295
316
  module.exports.transform = function(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
296
- let deferred6_0;
297
- let deferred6_1;
317
+ let deferred7_0;
318
+ let deferred7_1;
298
319
  try {
299
320
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
300
321
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -310,12 +331,20 @@ module.exports.transform = function(input, input_format_sel, output_format_sel,
310
331
  wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
311
332
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
312
333
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
313
- deferred6_0 = r0;
314
- deferred6_1 = r1;
315
- return getStringFromWasm0(r0, r1);
334
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
335
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
336
+ var ptr6 = r0;
337
+ var len6 = r1;
338
+ if (r3) {
339
+ ptr6 = 0; len6 = 0;
340
+ throw takeObject(r2);
341
+ }
342
+ deferred7_0 = ptr6;
343
+ deferred7_1 = len6;
344
+ return getStringFromWasm0(ptr6, len6);
316
345
  } finally {
317
346
  wasm.__wbindgen_add_to_stack_pointer(16);
318
- wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
347
+ wasm.__wbindgen_export_2(deferred7_0, deferred7_1, 1);
319
348
  }
320
349
  };
321
350
 
@@ -323,31 +352,45 @@ module.exports.transform = function(input, input_format_sel, output_format_sel,
323
352
  * Resolve a patch document against `input` (bitmark or JSON) into the
324
353
  * ordered output items, so a JS per-bit planner (hooks, worker pool) can
325
354
  * reorder, drop and insert jobs from the one Rust implementation
326
- * (PLAN-179). Returns a JSON array of
355
+ * (PLAN-179). `input_format_sel` is the caller's input-format selector
356
+ * (`"auto"` | `"bitmark"` | `"json"`): the document is split under the SAME
357
+ * selection the planner already resolved, never re-sniffed (PLAN-187 D1).
358
+ * Returns a JSON array of
327
359
  * `{ "source": <original index> | null, "bit": <inner bit> | null,
328
- * "patch": [ … ] }`, or `error: …`.
360
+ * "patch": [ … ] }`; throws on failure.
329
361
  * @param {string} input
362
+ * @param {string} input_format_sel
330
363
  * @param {string} patch_json
331
364
  * @returns {string}
332
365
  */
333
- module.exports.resolve_patch_document = function(input, patch_json) {
334
- let deferred3_0;
335
- let deferred3_1;
366
+ module.exports.resolve_patch_document = function(input, input_format_sel, patch_json) {
367
+ let deferred5_0;
368
+ let deferred5_1;
336
369
  try {
337
370
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
338
371
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
339
372
  const len0 = WASM_VECTOR_LEN;
340
- const ptr1 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
373
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
341
374
  const len1 = WASM_VECTOR_LEN;
342
- wasm.resolve_patch_document(retptr, ptr0, len0, ptr1, len1);
375
+ const ptr2 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
376
+ const len2 = WASM_VECTOR_LEN;
377
+ wasm.resolve_patch_document(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
343
378
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
344
379
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
345
- deferred3_0 = r0;
346
- deferred3_1 = r1;
347
- return getStringFromWasm0(r0, r1);
380
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
381
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
382
+ var ptr4 = r0;
383
+ var len4 = r1;
384
+ if (r3) {
385
+ ptr4 = 0; len4 = 0;
386
+ throw takeObject(r2);
387
+ }
388
+ deferred5_0 = ptr4;
389
+ deferred5_1 = len4;
390
+ return getStringFromWasm0(ptr4, len4);
348
391
  } finally {
349
392
  wasm.__wbindgen_add_to_stack_pointer(16);
350
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
393
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
351
394
  }
352
395
  };
353
396
 
@@ -361,8 +404,8 @@ module.exports.resolve_patch_document = function(input, patch_json) {
361
404
  * - `context`, `locate`, `similarity`, `bbox_tolerance`,
362
405
  * `spaces_around_values` as documented on `DiffOptions`.
363
406
  * Returns the diff (empty text / `[]` of unchanged bits / a patch document
364
- * with no entries when the documents are semantically equal), or
365
- * `error: …`.
407
+ * with no entries when the documents are semantically equal); throws on
408
+ * failure.
366
409
  * @param {string} a
367
410
  * @param {string} b
368
411
  * @param {string} input_format_sel
@@ -375,8 +418,8 @@ module.exports.resolve_patch_document = function(input, patch_json) {
375
418
  * @returns {string}
376
419
  */
377
420
  module.exports.diff = function(a, b, input_format_sel, output_format_sel, context, locate, similarity, bbox_tolerance, spaces_around_values) {
378
- let deferred5_0;
379
- let deferred5_1;
421
+ let deferred6_0;
422
+ let deferred6_1;
380
423
  try {
381
424
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
382
425
  const ptr0 = passStringToWasm0(a, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -390,15 +433,158 @@ module.exports.diff = function(a, b, input_format_sel, output_format_sel, contex
390
433
  wasm.diff(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, context, locate, similarity, bbox_tolerance, spaces_around_values);
391
434
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
392
435
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
393
- deferred5_0 = r0;
394
- deferred5_1 = r1;
395
- return getStringFromWasm0(r0, r1);
436
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
437
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
438
+ var ptr5 = r0;
439
+ var len5 = r1;
440
+ if (r3) {
441
+ ptr5 = 0; len5 = 0;
442
+ throw takeObject(r2);
443
+ }
444
+ deferred6_0 = ptr5;
445
+ deferred6_1 = len5;
446
+ return getStringFromWasm0(ptr5, len5);
447
+ } finally {
448
+ wasm.__wbindgen_add_to_stack_pointer(16);
449
+ wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
450
+ }
451
+ };
452
+
453
+ /**
454
+ * The constructs valid at a position, as an LSP `CompletionList` (PLAN-196
455
+ * D7; contract `API-EDT-editor-services.tsp`). `line` / `character` are
456
+ * 0-based, `character` in `position_encoding` units (`"utf-16"`, the
457
+ * default, or `"utf-8"`); `include_deprecated` offers deprecated bits too;
458
+ * `trigger_character` is the character the editor sent as the trigger (LSP
459
+ * `CompletionContext.triggerCharacter`; empty when invoked explicitly) — a
460
+ * trigger that opens nothing where the cursor is answers the empty list
461
+ * (PLAN-203 D1). ABSENT on a variant built without `editor` — the same
462
+ * "presence is the capability" signal `diff` uses. Throws when the line is
463
+ * past the text.
464
+ * @param {string} input
465
+ * @param {number} line
466
+ * @param {number} character
467
+ * @param {string} position_encoding
468
+ * @param {boolean} include_deprecated
469
+ * @param {string} trigger_character
470
+ * @returns {string}
471
+ */
472
+ module.exports.complete = function(input, line, character, position_encoding, include_deprecated, trigger_character) {
473
+ let deferred5_0;
474
+ let deferred5_1;
475
+ try {
476
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
477
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
478
+ const len0 = WASM_VECTOR_LEN;
479
+ const ptr1 = passStringToWasm0(position_encoding, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
480
+ const len1 = WASM_VECTOR_LEN;
481
+ const ptr2 = passStringToWasm0(trigger_character, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
482
+ const len2 = WASM_VECTOR_LEN;
483
+ wasm.complete(retptr, ptr0, len0, line, character, ptr1, len1, include_deprecated, ptr2, len2);
484
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
485
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
486
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
487
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
488
+ var ptr4 = r0;
489
+ var len4 = r1;
490
+ if (r3) {
491
+ ptr4 = 0; len4 = 0;
492
+ throw takeObject(r2);
493
+ }
494
+ deferred5_0 = ptr4;
495
+ deferred5_1 = len4;
496
+ return getStringFromWasm0(ptr4, len4);
497
+ } finally {
498
+ wasm.__wbindgen_add_to_stack_pointer(16);
499
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
500
+ }
501
+ };
502
+
503
+ /**
504
+ * One item of the list `complete` returns at this position, its Markdown
505
+ * `documentation` filled in — LSP `completionItem/resolve` (PLAN-202):
506
+ * `complete` ships no documentation, an editor asks for the one item it is
507
+ * about to show. `label` and `kind` (the LSP `CompletionItemKind` number)
508
+ * name the item; the JSON `null` when the list has no such item. Arguments
509
+ * otherwise as `complete`.
510
+ * @param {string} input
511
+ * @param {number} line
512
+ * @param {number} character
513
+ * @param {string} position_encoding
514
+ * @param {boolean} include_deprecated
515
+ * @param {string} label
516
+ * @param {number} kind
517
+ * @returns {string}
518
+ */
519
+ module.exports.resolve = function(input, line, character, position_encoding, include_deprecated, label, kind) {
520
+ let deferred5_0;
521
+ let deferred5_1;
522
+ try {
523
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
524
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
525
+ const len0 = WASM_VECTOR_LEN;
526
+ const ptr1 = passStringToWasm0(position_encoding, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
527
+ const len1 = WASM_VECTOR_LEN;
528
+ const ptr2 = passStringToWasm0(label, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
529
+ const len2 = WASM_VECTOR_LEN;
530
+ wasm.resolve(retptr, ptr0, len0, line, character, ptr1, len1, include_deprecated, ptr2, len2, kind);
531
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
532
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
533
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
534
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
535
+ var ptr4 = r0;
536
+ var len4 = r1;
537
+ if (r3) {
538
+ ptr4 = 0; len4 = 0;
539
+ throw takeObject(r2);
540
+ }
541
+ deferred5_0 = ptr4;
542
+ deferred5_1 = len4;
543
+ return getStringFromWasm0(ptr4, len4);
396
544
  } finally {
397
545
  wasm.__wbindgen_add_to_stack_pointer(16);
398
546
  wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
399
547
  }
400
548
  };
401
549
 
550
+ /**
551
+ * The construct at a position, as an LSP `Hover` — or the JSON `null` when
552
+ * there is nothing to show (PLAN-196 D8). Arguments as `complete`.
553
+ * @param {string} input
554
+ * @param {number} line
555
+ * @param {number} character
556
+ * @param {string} position_encoding
557
+ * @returns {string}
558
+ */
559
+ module.exports.hover = function(input, line, character, position_encoding) {
560
+ let deferred4_0;
561
+ let deferred4_1;
562
+ try {
563
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
564
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
565
+ const len0 = WASM_VECTOR_LEN;
566
+ const ptr1 = passStringToWasm0(position_encoding, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
567
+ const len1 = WASM_VECTOR_LEN;
568
+ wasm.hover(retptr, ptr0, len0, line, character, ptr1, len1);
569
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
570
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
571
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
572
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
573
+ var ptr3 = r0;
574
+ var len3 = r1;
575
+ if (r3) {
576
+ ptr3 = 0; len3 = 0;
577
+ throw takeObject(r2);
578
+ }
579
+ deferred4_0 = ptr3;
580
+ deferred4_1 = len3;
581
+ return getStringFromWasm0(ptr3, len3);
582
+ } finally {
583
+ wasm.__wbindgen_add_to_stack_pointer(16);
584
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
585
+ }
586
+ };
587
+
402
588
  /**
403
589
  * Register data with the parser process (PLAN-173 P12).
404
590
  *
@@ -407,18 +593,15 @@ module.exports.diff = function(a, b, input_format_sel, output_format_sel, contex
407
593
  *
408
594
  * `data` is the file's own text. Semantics are REPLACE: a second call
409
595
  * supersedes the first entirely, and the built-in table (where the variant
410
- * bakes one) stays underneath. Returns `""` on success, or an
411
- * `error:`-prefixed message — matching the other string-returning exports.
596
+ * bakes one) stays underneath. Throws on bad data — like every other
597
+ * fallible export (PLAN-192 D1).
412
598
  *
413
599
  * Available in EVERY variant, including those that bake nothing: that is
414
600
  * exactly where a consumer must supply the file themselves.
415
601
  * @param {string} data_type
416
602
  * @param {string} data
417
- * @returns {string}
418
603
  */
419
604
  module.exports.register = function(data_type, data) {
420
- let deferred3_0;
421
- let deferred3_1;
422
605
  try {
423
606
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
424
607
  const ptr0 = passStringToWasm0(data_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -428,24 +611,30 @@ module.exports.register = function(data_type, data) {
428
611
  wasm.register(retptr, ptr0, len0, ptr1, len1);
429
612
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
430
613
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
431
- deferred3_0 = r0;
432
- deferred3_1 = r1;
433
- return getStringFromWasm0(r0, r1);
614
+ if (r1) {
615
+ throw takeObject(r0);
616
+ }
434
617
  } finally {
435
618
  wasm.__wbindgen_add_to_stack_pointer(16);
436
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
437
619
  }
438
620
  };
439
621
 
440
622
  /**
441
623
  * Convert between bitmark and JSON with explicit input/output formats + mode.
442
624
  *
443
- * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
444
- * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
625
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"` | a mapping id.
626
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"` |
627
+ * `"text"` | `"lex"` (the token stream as JSON) | `"semantic-tokens"` |
628
+ * `"diagnostics"` (the last three bitmark input only) | a mapping id.
445
629
  * `mode`: `"optimized"` (default) | `"full"`.
446
630
  * `mapping_report`: replace the output with a human-readable report of the
447
631
  * input→output mappings, including inputs that are NOT mapped (PLAN-147).
448
- * Returns the converted text/JSON, or a string prefixed `error:` on failure.
632
+ * `position_encoding`: `"utf-16"` (default) | `"utf-8"` — the
633
+ * `semantic-tokens` and `diagnostics` outputs' encoding (PLAN-193 /
634
+ * PLAN-196) — and `tokens_layout`: `"lsp"` (default) | `"absolute"` — the
635
+ * `semantic-tokens` layout; `""` means the default, and every other output
636
+ * format ignores them.
637
+ * Returns the converted text/JSON; throws on failure.
449
638
  * @param {string} input
450
639
  * @param {string} input_format_sel
451
640
  * @param {string} output_format_sel
@@ -455,11 +644,13 @@ module.exports.register = function(data_type, data) {
455
644
  * @param {number} spaces_around_values
456
645
  * @param {boolean} include_unknown_properties
457
646
  * @param {boolean} mapping_report
647
+ * @param {string} position_encoding
648
+ * @param {string} tokens_layout
458
649
  * @returns {string}
459
650
  */
460
- module.exports.convert = function(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report) {
461
- let deferred5_0;
462
- let deferred5_1;
651
+ module.exports.convert = function(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report, position_encoding, tokens_layout) {
652
+ let deferred8_0;
653
+ let deferred8_1;
463
654
  try {
464
655
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
465
656
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -470,15 +661,27 @@ module.exports.convert = function(input, input_format_sel, output_format_sel, mo
470
661
  const len2 = WASM_VECTOR_LEN;
471
662
  const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
472
663
  const len3 = WASM_VECTOR_LEN;
473
- wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report);
664
+ const ptr4 = passStringToWasm0(position_encoding, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
665
+ const len4 = WASM_VECTOR_LEN;
666
+ const ptr5 = passStringToWasm0(tokens_layout, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
667
+ const len5 = WASM_VECTOR_LEN;
668
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report, ptr4, len4, ptr5, len5);
474
669
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
475
670
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
476
- deferred5_0 = r0;
477
- deferred5_1 = r1;
478
- return getStringFromWasm0(r0, r1);
671
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
672
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
673
+ var ptr7 = r0;
674
+ var len7 = r1;
675
+ if (r3) {
676
+ ptr7 = 0; len7 = 0;
677
+ throw takeObject(r2);
678
+ }
679
+ deferred8_0 = ptr7;
680
+ deferred8_1 = len7;
681
+ return getStringFromWasm0(ptr7, len7);
479
682
  } finally {
480
683
  wasm.__wbindgen_add_to_stack_pointer(16);
481
- wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
684
+ wasm.__wbindgen_export_2(deferred8_0, deferred8_1, 1);
482
685
  }
483
686
  };
484
687
 
@@ -496,8 +699,8 @@ module.exports.convert = function(input, input_format_sel, output_format_sel, mo
496
699
  * @returns {string}
497
700
  */
498
701
  module.exports.canonicalize = function(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
499
- let deferred4_0;
500
- let deferred4_1;
702
+ let deferred5_0;
703
+ let deferred5_1;
501
704
  try {
502
705
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
503
706
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -509,24 +712,32 @@ module.exports.canonicalize = function(input, input_format_sel, mode, pretty, in
509
712
  wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
510
713
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
511
714
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
512
- deferred4_0 = r0;
513
- deferred4_1 = r1;
514
- return getStringFromWasm0(r0, r1);
715
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
716
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
717
+ var ptr4 = r0;
718
+ var len4 = r1;
719
+ if (r3) {
720
+ ptr4 = 0; len4 = 0;
721
+ throw takeObject(r2);
722
+ }
723
+ deferred5_0 = ptr4;
724
+ deferred5_1 = len4;
725
+ return getStringFromWasm0(ptr4, len4);
515
726
  } finally {
516
727
  wasm.__wbindgen_add_to_stack_pointer(16);
517
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
728
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
518
729
  }
519
730
  };
520
731
 
521
732
  /**
522
733
  * Count the bits in `input` (auto-detecting bitmark vs JSON).
523
- * Returns the count as a decimal string, or `error: …`.
734
+ * Returns the count as a decimal string; throws on failure.
524
735
  * @param {string} input
525
736
  * @returns {string}
526
737
  */
527
738
  module.exports.count_bits = function(input) {
528
- let deferred2_0;
529
- let deferred2_1;
739
+ let deferred3_0;
740
+ let deferred3_1;
530
741
  try {
531
742
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
532
743
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -534,12 +745,20 @@ module.exports.count_bits = function(input) {
534
745
  wasm.count_bits(retptr, ptr0, len0);
535
746
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
536
747
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
537
- deferred2_0 = r0;
538
- deferred2_1 = r1;
539
- return getStringFromWasm0(r0, r1);
748
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
749
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
750
+ var ptr2 = r0;
751
+ var len2 = r1;
752
+ if (r3) {
753
+ ptr2 = 0; len2 = 0;
754
+ throw takeObject(r2);
755
+ }
756
+ deferred3_0 = ptr2;
757
+ deferred3_1 = len2;
758
+ return getStringFromWasm0(ptr2, len2);
540
759
  } finally {
541
760
  wasm.__wbindgen_add_to_stack_pointer(16);
542
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
761
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
543
762
  }
544
763
  };
545
764
 
@@ -587,13 +806,13 @@ module.exports.is_bitmark = function(input) {
587
806
  * Split a JSON document (a top-level array of bit envelopes) into its per-bit
588
807
  * envelope objects, returned as a JSON array string. Lets a JS caller iterate
589
808
  * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
590
- * Returns `error: …` if the input is not a JSON array of bits.
809
+ * Throws if the input is not a JSON array of bits.
591
810
  * @param {string} input
592
811
  * @returns {string}
593
812
  */
594
813
  module.exports.split_json_bits = function(input) {
595
- let deferred2_0;
596
- let deferred2_1;
814
+ let deferred3_0;
815
+ let deferred3_1;
597
816
  try {
598
817
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
599
818
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -601,12 +820,20 @@ module.exports.split_json_bits = function(input) {
601
820
  wasm.split_json_bits(retptr, ptr0, len0);
602
821
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
603
822
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
604
- deferred2_0 = r0;
605
- deferred2_1 = r1;
606
- return getStringFromWasm0(r0, r1);
823
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
824
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
825
+ var ptr2 = r0;
826
+ var len2 = r1;
827
+ if (r3) {
828
+ ptr2 = 0; len2 = 0;
829
+ throw takeObject(r2);
830
+ }
831
+ deferred3_0 = ptr2;
832
+ deferred3_1 = len2;
833
+ return getStringFromWasm0(ptr2, len2);
607
834
  } finally {
608
835
  wasm.__wbindgen_add_to_stack_pointer(16);
609
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
836
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
610
837
  }
611
838
  };
612
839
 
@@ -637,6 +864,11 @@ module.exports.prettify = function(json, indent) {
637
864
  }
638
865
  };
639
866
 
867
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
868
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
869
+ return addHeapObject(ret);
870
+ };
871
+
640
872
  const path = require('path').join(__dirname, 'bitmark_browser_full_wasm_bg.wasm');
641
873
  const bytes = require('fs').readFileSync(path);
642
874