@gmb/bitmark-parser 6.11.0 → 7.0.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 +311 -51
  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 +696 -312
  5. package/dist/browser/cjs/index.cjs.map +1 -1
  6. package/dist/browser/cjs/index.d.cts +487 -74
  7. package/dist/browser/esm/index.d.ts +487 -74
  8. package/dist/browser/esm/index.js +693 -311
  9. package/dist/browser/esm/index.js.map +1 -1
  10. package/dist/browser/esm/worker-entry.js +578 -210
  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 +119 -107
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +487 -74
  18. package/dist/index.d.ts +487 -74
  19. package/dist/index.js +116 -106
  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 +496 -139
  31. package/wasm/bitmark_wasm.d.ts +47 -20
  32. package/wasm/bitmark_wasm.js +262 -96
  33. package/wasm/bitmark_wasm_bg.wasm +0 -0
  34. package/wasm/bitmark_wasm_bg.wasm.d.ts +4 -2
  35. package/wasm/package.json +1 -1
  36. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +26 -11
  37. package/wasm-bitmark-json/bitmark_json_wasm.js +195 -65
  38. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  39. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +2 -1
  40. package/wasm-bitmark-json/package.json +1 -1
  41. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +47 -20
  42. package/wasm-browser-full/bitmark_browser_full_wasm.js +262 -96
  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 +4 -2
  45. package/wasm-browser-full/package.json +1 -1
@@ -1,14 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Lex bitmark input text, returning one line per token in the same format as
5
- * the Rust CLI: `{kind:?} {span:?} "{text}"`.
6
- *
7
- * `stage` selects the lexer pipeline:
8
- * - `"lex"` — combined (default)
9
- * - `"lex-json"` — combined, JSON array output
10
- */
11
- export function lex(input: string, stage: string): string;
12
3
  /**
13
4
  * Breakscape text (escape bitmark special characters).
14
5
  *
@@ -41,6 +32,13 @@ export function unbreakscape_text(input: string, format: string, location: strin
41
32
  * several (adds a `titles` map), `"all"` for every resolvable language
42
33
  */
43
34
  export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number, include_deprecated: boolean, only_deprecated: boolean, full: boolean, language: string): string;
35
+ /**
36
+ * Whether this build can render `info` as TEXT (PLAN-192 D6). The export is
37
+ * ABSENT when it cannot — the same "presence is the capability" signal
38
+ * `diff` uses, so a caller tests for the function rather than for a
39
+ * variant name.
40
+ */
41
+ export function info_text_supported(): boolean;
44
42
  /**
45
43
  * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).
46
44
  *
@@ -48,7 +46,7 @@ export function info(info_type: string, format: string, bit: string, pretty: boo
48
46
  * `format`: a bitmark text format (`"bitmark++"`, `"bitmark+"`) parses
49
47
  * inline marks; anything else is treated as plain text (textToAst only).
50
48
  * `location`: `"body"` (default) or `"tag"`.
51
- * Returns the converted fragment, or `error: …`.
49
+ * Returns the converted fragment; throws on failure.
52
50
  */
53
51
  export function convert_text(input: string, direction: string, format: string, location: string): string;
54
52
  /**
@@ -58,9 +56,32 @@ export function convert_text(input: string, direction: string, format: string, l
58
56
  * `output_format_sel`: `"bitmark"` | `"json"` (default json).
59
57
  * `patch_json`: the patch entry array (empty string = no patches, i.e. a
60
58
  * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
61
- * runs sequentially. Returns the document text/JSON, or `error: …`.
59
+ * runs sequentially. Returns the document text/JSON; throws on failure.
62
60
  */
63
61
  export function transform(input: string, input_format_sel: string, output_format_sel: string, mode: string, patch_json: string, pretty: boolean, indent: number, spaces_around_values: number): string;
62
+ /**
63
+ * Resolve a patch document against `input` (bitmark or JSON) into the
64
+ * ordered output items, so a JS per-bit planner (hooks, worker pool) can
65
+ * reorder, drop and insert jobs from the one Rust implementation
66
+ * (PLAN-179). Returns a JSON array of
67
+ * `{ "source": <original index> | null, "bit": <inner bit> | null,
68
+ * "patch": [ … ] }`; throws on failure.
69
+ */
70
+ export function resolve_patch_document(input: string, patch_json: string): string;
71
+ /**
72
+ * Semantic diff of two documents (PLAN-179). Flat arguments like every
73
+ * other export:
74
+ * - `input_format`: `"auto"` | `"bitmark"` | `"json"` | a mapping id,
75
+ * applied to both sides;
76
+ * - `output_format`: `"bitmark"` (unified-style text) | `"json"` |
77
+ * `"patch"`;
78
+ * - `context`, `locate`, `similarity`, `bbox_tolerance`,
79
+ * `spaces_around_values` as documented on `DiffOptions`.
80
+ * Returns the diff (empty text / `[]` of unchanged bits / a patch document
81
+ * with no entries when the documents are semantically equal); throws on
82
+ * failure.
83
+ */
84
+ export function diff(a: string, b: string, input_format_sel: string, output_format_sel: string, context: number, locate: boolean, similarity: number, bbox_tolerance: number, spaces_around_values: number): string;
64
85
  /**
65
86
  * Register data with the parser process (PLAN-173 P12).
66
87
  *
@@ -69,24 +90,30 @@ export function transform(input: string, input_format_sel: string, output_format
69
90
  *
70
91
  * `data` is the file's own text. Semantics are REPLACE: a second call
71
92
  * supersedes the first entirely, and the built-in table (where the variant
72
- * bakes one) stays underneath. Returns `""` on success, or an
73
- * `error:`-prefixed message — matching the other string-returning exports.
93
+ * bakes one) stays underneath. Throws on bad data — like every other
94
+ * fallible export (PLAN-192 D1).
74
95
  *
75
96
  * Available in EVERY variant, including those that bake nothing: that is
76
97
  * exactly where a consumer must supply the file themselves.
77
98
  */
78
- export function register(data_type: string, data: string): string;
99
+ export function register(data_type: string, data: string): void;
79
100
  /**
80
101
  * Convert between bitmark and JSON with explicit input/output formats + mode.
81
102
  *
82
- * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
83
- * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
103
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"` | a mapping id.
104
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"` |
105
+ * `"text"` | `"lex"` (the token stream as JSON, bitmark input only) | a
106
+ * mapping id.
84
107
  * `mode`: `"optimized"` (default) | `"full"`.
85
108
  * `mapping_report`: replace the output with a human-readable report of the
86
109
  * input→output mappings, including inputs that are NOT mapped (PLAN-147).
87
- * Returns the converted text/JSON, or a string prefixed `error:` on failure.
110
+ * `position_encoding`: `"utf-16"` (default) | `"utf-8"` and `tokens_layout`:
111
+ * `"lsp"` (default) | `"absolute"` — the `semantic-tokens` output's two
112
+ * options (PLAN-193); `""` means the default, and every other output
113
+ * format ignores them.
114
+ * Returns the converted text/JSON; throws on failure.
88
115
  */
89
- export function convert(input: string, input_format_sel: string, output_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number, include_unknown_properties: boolean, mapping_report: boolean): string;
116
+ export function convert(input: string, input_format_sel: string, output_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number, include_unknown_properties: boolean, mapping_report: boolean, position_encoding: string, tokens_layout: string): string;
90
117
  /**
91
118
  * Re-emit input in its own format in canonical form at `mode`.
92
119
  *
@@ -96,7 +123,7 @@ export function convert(input: string, input_format_sel: string, output_format_s
96
123
  export function canonicalize(input: string, input_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number): string;
97
124
  /**
98
125
  * Count the bits in `input` (auto-detecting bitmark vs JSON).
99
- * Returns the count as a decimal string, or `error: …`.
126
+ * Returns the count as a decimal string; throws on failure.
100
127
  */
101
128
  export function count_bits(input: string): string;
102
129
  /**
@@ -115,7 +142,7 @@ export function is_bitmark(input: string): boolean;
115
142
  * Split a JSON document (a top-level array of bit envelopes) into its per-bit
116
143
  * envelope objects, returned as a JSON array string. Lets a JS caller iterate
117
144
  * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
118
- * Returns `error: …` if the input is not a JSON array of bits.
145
+ * Throws if the input is not a JSON array of bits.
119
146
  */
120
147
  export function split_json_bits(input: string): string;
121
148
  /**
@@ -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
 
@@ -281,7 +298,7 @@ module.exports.convert_text = function(input, direction, format, location) {
281
298
  * `output_format_sel`: `"bitmark"` | `"json"` (default json).
282
299
  * `patch_json`: the patch entry array (empty string = no patches, i.e. a
283
300
  * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
284
- * runs sequentially. Returns the document text/JSON, or `error: …`.
301
+ * runs sequentially. Returns the document text/JSON; throws on failure.
285
302
  * @param {string} input
286
303
  * @param {string} input_format_sel
287
304
  * @param {string} output_format_sel
@@ -293,8 +310,8 @@ module.exports.convert_text = function(input, direction, format, location) {
293
310
  * @returns {string}
294
311
  */
295
312
  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;
313
+ let deferred7_0;
314
+ let deferred7_1;
298
315
  try {
299
316
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
300
317
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -310,9 +327,113 @@ module.exports.transform = function(input, input_format_sel, output_format_sel,
310
327
  wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
311
328
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
312
329
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
313
- deferred6_0 = r0;
314
- deferred6_1 = r1;
315
- return getStringFromWasm0(r0, r1);
330
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
331
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
332
+ var ptr6 = r0;
333
+ var len6 = r1;
334
+ if (r3) {
335
+ ptr6 = 0; len6 = 0;
336
+ throw takeObject(r2);
337
+ }
338
+ deferred7_0 = ptr6;
339
+ deferred7_1 = len6;
340
+ return getStringFromWasm0(ptr6, len6);
341
+ } finally {
342
+ wasm.__wbindgen_add_to_stack_pointer(16);
343
+ wasm.__wbindgen_export_2(deferred7_0, deferred7_1, 1);
344
+ }
345
+ };
346
+
347
+ /**
348
+ * Resolve a patch document against `input` (bitmark or JSON) into the
349
+ * ordered output items, so a JS per-bit planner (hooks, worker pool) can
350
+ * reorder, drop and insert jobs from the one Rust implementation
351
+ * (PLAN-179). Returns a JSON array of
352
+ * `{ "source": <original index> | null, "bit": <inner bit> | null,
353
+ * "patch": [ … ] }`; throws on failure.
354
+ * @param {string} input
355
+ * @param {string} patch_json
356
+ * @returns {string}
357
+ */
358
+ module.exports.resolve_patch_document = function(input, patch_json) {
359
+ let deferred4_0;
360
+ let deferred4_1;
361
+ try {
362
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
363
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
364
+ const len0 = WASM_VECTOR_LEN;
365
+ const ptr1 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
366
+ const len1 = WASM_VECTOR_LEN;
367
+ wasm.resolve_patch_document(retptr, ptr0, len0, ptr1, len1);
368
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
369
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
370
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
371
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
372
+ var ptr3 = r0;
373
+ var len3 = r1;
374
+ if (r3) {
375
+ ptr3 = 0; len3 = 0;
376
+ throw takeObject(r2);
377
+ }
378
+ deferred4_0 = ptr3;
379
+ deferred4_1 = len3;
380
+ return getStringFromWasm0(ptr3, len3);
381
+ } finally {
382
+ wasm.__wbindgen_add_to_stack_pointer(16);
383
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
384
+ }
385
+ };
386
+
387
+ /**
388
+ * Semantic diff of two documents (PLAN-179). Flat arguments like every
389
+ * other export:
390
+ * - `input_format`: `"auto"` | `"bitmark"` | `"json"` | a mapping id,
391
+ * applied to both sides;
392
+ * - `output_format`: `"bitmark"` (unified-style text) | `"json"` |
393
+ * `"patch"`;
394
+ * - `context`, `locate`, `similarity`, `bbox_tolerance`,
395
+ * `spaces_around_values` as documented on `DiffOptions`.
396
+ * Returns the diff (empty text / `[]` of unchanged bits / a patch document
397
+ * with no entries when the documents are semantically equal); throws on
398
+ * failure.
399
+ * @param {string} a
400
+ * @param {string} b
401
+ * @param {string} input_format_sel
402
+ * @param {string} output_format_sel
403
+ * @param {number} context
404
+ * @param {boolean} locate
405
+ * @param {number} similarity
406
+ * @param {number} bbox_tolerance
407
+ * @param {number} spaces_around_values
408
+ * @returns {string}
409
+ */
410
+ module.exports.diff = function(a, b, input_format_sel, output_format_sel, context, locate, similarity, bbox_tolerance, spaces_around_values) {
411
+ let deferred6_0;
412
+ let deferred6_1;
413
+ try {
414
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
415
+ const ptr0 = passStringToWasm0(a, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
416
+ const len0 = WASM_VECTOR_LEN;
417
+ const ptr1 = passStringToWasm0(b, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
418
+ const len1 = WASM_VECTOR_LEN;
419
+ const ptr2 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
420
+ const len2 = WASM_VECTOR_LEN;
421
+ const ptr3 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
422
+ const len3 = WASM_VECTOR_LEN;
423
+ wasm.diff(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, context, locate, similarity, bbox_tolerance, spaces_around_values);
424
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
425
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
426
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
427
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
428
+ var ptr5 = r0;
429
+ var len5 = r1;
430
+ if (r3) {
431
+ ptr5 = 0; len5 = 0;
432
+ throw takeObject(r2);
433
+ }
434
+ deferred6_0 = ptr5;
435
+ deferred6_1 = len5;
436
+ return getStringFromWasm0(ptr5, len5);
316
437
  } finally {
317
438
  wasm.__wbindgen_add_to_stack_pointer(16);
318
439
  wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
@@ -327,18 +448,15 @@ module.exports.transform = function(input, input_format_sel, output_format_sel,
327
448
  *
328
449
  * `data` is the file's own text. Semantics are REPLACE: a second call
329
450
  * supersedes the first entirely, and the built-in table (where the variant
330
- * bakes one) stays underneath. Returns `""` on success, or an
331
- * `error:`-prefixed message — matching the other string-returning exports.
451
+ * bakes one) stays underneath. Throws on bad data — like every other
452
+ * fallible export (PLAN-192 D1).
332
453
  *
333
454
  * Available in EVERY variant, including those that bake nothing: that is
334
455
  * exactly where a consumer must supply the file themselves.
335
456
  * @param {string} data_type
336
457
  * @param {string} data
337
- * @returns {string}
338
458
  */
339
459
  module.exports.register = function(data_type, data) {
340
- let deferred3_0;
341
- let deferred3_1;
342
460
  try {
343
461
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
344
462
  const ptr0 = passStringToWasm0(data_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -348,24 +466,29 @@ module.exports.register = function(data_type, data) {
348
466
  wasm.register(retptr, ptr0, len0, ptr1, len1);
349
467
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
350
468
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
351
- deferred3_0 = r0;
352
- deferred3_1 = r1;
353
- return getStringFromWasm0(r0, r1);
469
+ if (r1) {
470
+ throw takeObject(r0);
471
+ }
354
472
  } finally {
355
473
  wasm.__wbindgen_add_to_stack_pointer(16);
356
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
357
474
  }
358
475
  };
359
476
 
360
477
  /**
361
478
  * Convert between bitmark and JSON with explicit input/output formats + mode.
362
479
  *
363
- * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
364
- * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
480
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"` | a mapping id.
481
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"` |
482
+ * `"text"` | `"lex"` (the token stream as JSON, bitmark input only) | a
483
+ * mapping id.
365
484
  * `mode`: `"optimized"` (default) | `"full"`.
366
485
  * `mapping_report`: replace the output with a human-readable report of the
367
486
  * input→output mappings, including inputs that are NOT mapped (PLAN-147).
368
- * Returns the converted text/JSON, or a string prefixed `error:` on failure.
487
+ * `position_encoding`: `"utf-16"` (default) | `"utf-8"` and `tokens_layout`:
488
+ * `"lsp"` (default) | `"absolute"` — the `semantic-tokens` output's two
489
+ * options (PLAN-193); `""` means the default, and every other output
490
+ * format ignores them.
491
+ * Returns the converted text/JSON; throws on failure.
369
492
  * @param {string} input
370
493
  * @param {string} input_format_sel
371
494
  * @param {string} output_format_sel
@@ -375,11 +498,13 @@ module.exports.register = function(data_type, data) {
375
498
  * @param {number} spaces_around_values
376
499
  * @param {boolean} include_unknown_properties
377
500
  * @param {boolean} mapping_report
501
+ * @param {string} position_encoding
502
+ * @param {string} tokens_layout
378
503
  * @returns {string}
379
504
  */
380
- module.exports.convert = function(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report) {
381
- let deferred5_0;
382
- let deferred5_1;
505
+ 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) {
506
+ let deferred8_0;
507
+ let deferred8_1;
383
508
  try {
384
509
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
385
510
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -390,15 +515,27 @@ module.exports.convert = function(input, input_format_sel, output_format_sel, mo
390
515
  const len2 = WASM_VECTOR_LEN;
391
516
  const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
392
517
  const len3 = WASM_VECTOR_LEN;
393
- wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report);
518
+ const ptr4 = passStringToWasm0(position_encoding, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
519
+ const len4 = WASM_VECTOR_LEN;
520
+ const ptr5 = passStringToWasm0(tokens_layout, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
521
+ const len5 = WASM_VECTOR_LEN;
522
+ 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);
394
523
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
395
524
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
396
- deferred5_0 = r0;
397
- deferred5_1 = r1;
398
- return getStringFromWasm0(r0, r1);
525
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
526
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
527
+ var ptr7 = r0;
528
+ var len7 = r1;
529
+ if (r3) {
530
+ ptr7 = 0; len7 = 0;
531
+ throw takeObject(r2);
532
+ }
533
+ deferred8_0 = ptr7;
534
+ deferred8_1 = len7;
535
+ return getStringFromWasm0(ptr7, len7);
399
536
  } finally {
400
537
  wasm.__wbindgen_add_to_stack_pointer(16);
401
- wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
538
+ wasm.__wbindgen_export_2(deferred8_0, deferred8_1, 1);
402
539
  }
403
540
  };
404
541
 
@@ -416,8 +553,8 @@ module.exports.convert = function(input, input_format_sel, output_format_sel, mo
416
553
  * @returns {string}
417
554
  */
418
555
  module.exports.canonicalize = function(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
419
- let deferred4_0;
420
- let deferred4_1;
556
+ let deferred5_0;
557
+ let deferred5_1;
421
558
  try {
422
559
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
423
560
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -429,24 +566,32 @@ module.exports.canonicalize = function(input, input_format_sel, mode, pretty, in
429
566
  wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
430
567
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
431
568
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
432
- deferred4_0 = r0;
433
- deferred4_1 = r1;
434
- return getStringFromWasm0(r0, r1);
569
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
570
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
571
+ var ptr4 = r0;
572
+ var len4 = r1;
573
+ if (r3) {
574
+ ptr4 = 0; len4 = 0;
575
+ throw takeObject(r2);
576
+ }
577
+ deferred5_0 = ptr4;
578
+ deferred5_1 = len4;
579
+ return getStringFromWasm0(ptr4, len4);
435
580
  } finally {
436
581
  wasm.__wbindgen_add_to_stack_pointer(16);
437
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
582
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
438
583
  }
439
584
  };
440
585
 
441
586
  /**
442
587
  * Count the bits in `input` (auto-detecting bitmark vs JSON).
443
- * Returns the count as a decimal string, or `error: …`.
588
+ * Returns the count as a decimal string; throws on failure.
444
589
  * @param {string} input
445
590
  * @returns {string}
446
591
  */
447
592
  module.exports.count_bits = function(input) {
448
- let deferred2_0;
449
- let deferred2_1;
593
+ let deferred3_0;
594
+ let deferred3_1;
450
595
  try {
451
596
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
452
597
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -454,12 +599,20 @@ module.exports.count_bits = function(input) {
454
599
  wasm.count_bits(retptr, ptr0, len0);
455
600
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
456
601
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
457
- deferred2_0 = r0;
458
- deferred2_1 = r1;
459
- return getStringFromWasm0(r0, r1);
602
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
603
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
604
+ var ptr2 = r0;
605
+ var len2 = r1;
606
+ if (r3) {
607
+ ptr2 = 0; len2 = 0;
608
+ throw takeObject(r2);
609
+ }
610
+ deferred3_0 = ptr2;
611
+ deferred3_1 = len2;
612
+ return getStringFromWasm0(ptr2, len2);
460
613
  } finally {
461
614
  wasm.__wbindgen_add_to_stack_pointer(16);
462
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
615
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
463
616
  }
464
617
  };
465
618
 
@@ -507,13 +660,13 @@ module.exports.is_bitmark = function(input) {
507
660
  * Split a JSON document (a top-level array of bit envelopes) into its per-bit
508
661
  * envelope objects, returned as a JSON array string. Lets a JS caller iterate
509
662
  * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
510
- * Returns `error: …` if the input is not a JSON array of bits.
663
+ * Throws if the input is not a JSON array of bits.
511
664
  * @param {string} input
512
665
  * @returns {string}
513
666
  */
514
667
  module.exports.split_json_bits = function(input) {
515
- let deferred2_0;
516
- let deferred2_1;
668
+ let deferred3_0;
669
+ let deferred3_1;
517
670
  try {
518
671
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
519
672
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -521,12 +674,20 @@ module.exports.split_json_bits = function(input) {
521
674
  wasm.split_json_bits(retptr, ptr0, len0);
522
675
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
523
676
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
524
- deferred2_0 = r0;
525
- deferred2_1 = r1;
526
- return getStringFromWasm0(r0, r1);
677
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
678
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
679
+ var ptr2 = r0;
680
+ var len2 = r1;
681
+ if (r3) {
682
+ ptr2 = 0; len2 = 0;
683
+ throw takeObject(r2);
684
+ }
685
+ deferred3_0 = ptr2;
686
+ deferred3_1 = len2;
687
+ return getStringFromWasm0(ptr2, len2);
527
688
  } finally {
528
689
  wasm.__wbindgen_add_to_stack_pointer(16);
529
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
690
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
530
691
  }
531
692
  };
532
693
 
@@ -557,6 +718,11 @@ module.exports.prettify = function(json, indent) {
557
718
  }
558
719
  };
559
720
 
721
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
722
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
723
+ return addHeapObject(ret);
724
+ };
725
+
560
726
  const path = require('path').join(__dirname, 'bitmark_wasm_bg.wasm');
561
727
  const bytes = require('fs').readFileSync(path);
562
728
 
Binary file