@gmb/bitmark-parser 6.0.0 → 6.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.
@@ -9,6 +9,19 @@
9
9
  * - `"lex-json"` — combined, JSON array output
10
10
  */
11
11
  export function lex(input: string, stage: string): string;
12
+ /**
13
+ * Pretty-print a compact JSON string with the given indent. Used to format a
14
+ * document recombined on the JS side (the per-bit hook path) so its output
15
+ * matches the in-Rust recombination byte-for-byte.
16
+ */
17
+ export function prettify(json: string, indent: number): string;
18
+ /**
19
+ * Unbreakscape text (unescape bitmark special characters).
20
+ *
21
+ * `format`: `"bitmark++"` (default) or `"plainText"`
22
+ * `location`: `"body"` (default) or `"tag"`
23
+ */
24
+ export function unbreakscape_text(input: string, format: string, location: string): string;
12
25
  /**
13
26
  * Query information about supported bit types.
14
27
  *
@@ -20,12 +33,51 @@ export function lex(input: string, stage: string): string;
20
33
  */
21
34
  export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number): string;
22
35
  /**
23
- * Unbreakscape text (unescape bitmark special characters).
36
+ * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
37
+ *
38
+ * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
39
+ * `output_format_sel`: `"bitmark"` | `"json"` (default json).
40
+ * `patch_json`: the patch entry array (empty string = no patches, i.e. a
41
+ * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
42
+ * runs sequentially. Returns the document text/JSON, or `error: …`.
43
+ */
44
+ 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;
45
+ /**
46
+ * Re-emit input in its own format in canonical form at `mode`.
47
+ */
48
+ export function canonicalize(input: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number): string;
49
+ /**
50
+ * Split a JSON document (a top-level array of bit envelopes) into its per-bit
51
+ * envelope objects, returned as a JSON array string. Lets a JS caller iterate
52
+ * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
53
+ * Returns `error: …` if the input is not a JSON array of bits.
54
+ */
55
+ export function split_json_bits(input: string): string;
56
+ /**
57
+ * Re-emit input in its own format at full mode (all keys).
58
+ */
59
+ export function fullize(input: string, pretty: boolean, indent: number): string;
60
+ /**
61
+ * Convert between bitmark and JSON with explicit input/output formats + mode.
62
+ *
63
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
64
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
65
+ * `mode`: `"optimized"` (default) | `"full"`.
66
+ * Returns the converted text/JSON, or a string prefixed `error:` on failure.
67
+ */
68
+ export function convert(input: string, input_format_sel: string, output_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number): string;
69
+ /**
70
+ * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
71
+ * used across the API so a JS caller can resolve `"auto"` consistently.
72
+ */
73
+ export function is_bitmark(input: string): boolean;
74
+ /**
75
+ * Breakscape text (escape bitmark special characters).
24
76
  *
25
77
  * `format`: `"bitmark++"` (default) or `"plainText"`
26
78
  * `location`: `"body"` (default) or `"tag"`
27
79
  */
28
- export function unbreakscape_text(input: string, format: string, location: string): string;
80
+ export function breakscape_text(input: string, format: string, location: string): string;
29
81
  /**
30
82
  * Parse bitmark input text and return the reference JSON format.
31
83
  *
@@ -35,22 +87,18 @@ export function unbreakscape_text(input: string, format: string, location: strin
35
87
  */
36
88
  export function parse(input: string, mode: string): string;
37
89
  /**
38
- * Auto-detect input format and convert between bitmark and JSON.
39
- *
40
- * `mode`: `"optimized"` (default) or `"full"`
41
- * `warnings`: whether to include validation warnings (default: false)
42
- * `plain_text`: output text as plain text — debug mode (default: false)
43
- * `pretty`: prettify JSON output (default: false)
44
- * `indent`: indent size for pretty-printing (default: 2)
45
- *
46
- * Returns JSON if input is bitmark, or an error message if input is JSON
47
- * (generator not yet implemented).
90
+ * Re-emit input in its own format at optimized mode (omit natural defaults).
48
91
  */
49
- export function convert(input: string, mode: string, warnings: boolean, plain_text: boolean, pretty: boolean, indent: number): string;
92
+ export function optimize(input: string, pretty: boolean, indent: number): string;
50
93
  /**
51
- * Breakscape text (escape bitmark special characters).
94
+ * Count the bits in `input` (auto-detecting bitmark vs JSON).
95
+ * Returns the count as a decimal string, or `error: …`.
96
+ */
97
+ export function count_bits(input: string): string;
98
+ /**
99
+ * Split a bitmark document into per-bit source slices.
52
100
  *
53
- * `format`: `"bitmark++"` (default) or `"plainText"`
54
- * `location`: `"body"` (default) or `"tag"`
101
+ * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
102
+ * caller chunk a document at bit boundaries (e.g. to feed a worker pool).
55
103
  */
56
- export function breakscape_text(input: string, format: string, location: string): string;
104
+ export function split_bits(input: string): string;
@@ -117,6 +117,66 @@ module.exports.lex = function(input, stage) {
117
117
  }
118
118
  };
119
119
 
120
+ /**
121
+ * Pretty-print a compact JSON string with the given indent. Used to format a
122
+ * document recombined on the JS side (the per-bit hook path) so its output
123
+ * matches the in-Rust recombination byte-for-byte.
124
+ * @param {string} json
125
+ * @param {number} indent
126
+ * @returns {string}
127
+ */
128
+ module.exports.prettify = function(json, indent) {
129
+ let deferred2_0;
130
+ let deferred2_1;
131
+ try {
132
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
133
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
134
+ const len0 = WASM_VECTOR_LEN;
135
+ wasm.prettify(retptr, ptr0, len0, indent);
136
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
137
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
138
+ deferred2_0 = r0;
139
+ deferred2_1 = r1;
140
+ return getStringFromWasm0(r0, r1);
141
+ } finally {
142
+ wasm.__wbindgen_add_to_stack_pointer(16);
143
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
144
+ }
145
+ };
146
+
147
+ /**
148
+ * Unbreakscape text (unescape bitmark special characters).
149
+ *
150
+ * `format`: `"bitmark++"` (default) or `"plainText"`
151
+ * `location`: `"body"` (default) or `"tag"`
152
+ * @param {string} input
153
+ * @param {string} format
154
+ * @param {string} location
155
+ * @returns {string}
156
+ */
157
+ module.exports.unbreakscape_text = function(input, format, location) {
158
+ let deferred4_0;
159
+ let deferred4_1;
160
+ try {
161
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
162
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
163
+ const len0 = WASM_VECTOR_LEN;
164
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
165
+ const len1 = WASM_VECTOR_LEN;
166
+ const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
167
+ const len2 = WASM_VECTOR_LEN;
168
+ wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
169
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
170
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
171
+ deferred4_0 = r0;
172
+ deferred4_1 = r1;
173
+ return getStringFromWasm0(r0, r1);
174
+ } finally {
175
+ wasm.__wbindgen_add_to_stack_pointer(16);
176
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
177
+ }
178
+ };
179
+
120
180
  /**
121
181
  * Query information about supported bit types.
122
182
  *
@@ -156,49 +216,60 @@ module.exports.info = function(info_type, format, bit, pretty, indent) {
156
216
  };
157
217
 
158
218
  /**
159
- * Unbreakscape text (unescape bitmark special characters).
219
+ * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
160
220
  *
161
- * `format`: `"bitmark++"` (default) or `"plainText"`
162
- * `location`: `"body"` (default) or `"tag"`
221
+ * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
222
+ * `output_format_sel`: `"bitmark"` | `"json"` (default json).
223
+ * `patch_json`: the patch entry array (empty string = no patches, i.e. a
224
+ * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
225
+ * runs sequentially. Returns the document text/JSON, or `error: …`.
163
226
  * @param {string} input
164
- * @param {string} format
165
- * @param {string} location
227
+ * @param {string} input_format_sel
228
+ * @param {string} output_format_sel
229
+ * @param {string} mode
230
+ * @param {string} patch_json
231
+ * @param {boolean} pretty
232
+ * @param {number} indent
233
+ * @param {number} spaces_around_values
166
234
  * @returns {string}
167
235
  */
168
- module.exports.unbreakscape_text = function(input, format, location) {
169
- let deferred4_0;
170
- let deferred4_1;
236
+ module.exports.transform = function(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
237
+ let deferred6_0;
238
+ let deferred6_1;
171
239
  try {
172
240
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
173
241
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
174
242
  const len0 = WASM_VECTOR_LEN;
175
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
243
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
176
244
  const len1 = WASM_VECTOR_LEN;
177
- const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
245
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
178
246
  const len2 = WASM_VECTOR_LEN;
179
- wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
247
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
248
+ const len3 = WASM_VECTOR_LEN;
249
+ const ptr4 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
250
+ const len4 = WASM_VECTOR_LEN;
251
+ wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
180
252
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
181
253
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
182
- deferred4_0 = r0;
183
- deferred4_1 = r1;
254
+ deferred6_0 = r0;
255
+ deferred6_1 = r1;
184
256
  return getStringFromWasm0(r0, r1);
185
257
  } finally {
186
258
  wasm.__wbindgen_add_to_stack_pointer(16);
187
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
259
+ wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
188
260
  }
189
261
  };
190
262
 
191
263
  /**
192
- * Parse bitmark input text and return the reference JSON format.
193
- *
194
- * Uses the full pipeline: parse → validate → serialize.
195
- *
196
- * `mode`: `"optimized"` (default) or `"full"`
264
+ * Re-emit input in its own format in canonical form at `mode`.
197
265
  * @param {string} input
198
266
  * @param {string} mode
267
+ * @param {boolean} pretty
268
+ * @param {number} indent
269
+ * @param {number} spaces_around_values
199
270
  * @returns {string}
200
271
  */
201
- module.exports.parse = function(input, mode) {
272
+ module.exports.canonicalize = function(input, mode, pretty, indent, spaces_around_values) {
202
273
  let deferred3_0;
203
274
  let deferred3_1;
204
275
  try {
@@ -207,7 +278,7 @@ module.exports.parse = function(input, mode) {
207
278
  const len0 = WASM_VECTOR_LEN;
208
279
  const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
209
280
  const len1 = WASM_VECTOR_LEN;
210
- wasm.parse(retptr, ptr0, len0, ptr1, len1);
281
+ wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, pretty, indent, spaces_around_values);
211
282
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
212
283
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
213
284
  deferred3_0 = r0;
@@ -220,45 +291,112 @@ module.exports.parse = function(input, mode) {
220
291
  };
221
292
 
222
293
  /**
223
- * Auto-detect input format and convert between bitmark and JSON.
224
- *
225
- * `mode`: `"optimized"` (default) or `"full"`
226
- * `warnings`: whether to include validation warnings (default: false)
227
- * `plain_text`: output text as plain text — debug mode (default: false)
228
- * `pretty`: prettify JSON output (default: false)
229
- * `indent`: indent size for pretty-printing (default: 2)
294
+ * Split a JSON document (a top-level array of bit envelopes) into its per-bit
295
+ * envelope objects, returned as a JSON array string. Lets a JS caller iterate
296
+ * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
297
+ * Returns `error: …` if the input is not a JSON array of bits.
298
+ * @param {string} input
299
+ * @returns {string}
300
+ */
301
+ module.exports.split_json_bits = function(input) {
302
+ let deferred2_0;
303
+ let deferred2_1;
304
+ try {
305
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
306
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
307
+ const len0 = WASM_VECTOR_LEN;
308
+ wasm.split_json_bits(retptr, ptr0, len0);
309
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
310
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
311
+ deferred2_0 = r0;
312
+ deferred2_1 = r1;
313
+ return getStringFromWasm0(r0, r1);
314
+ } finally {
315
+ wasm.__wbindgen_add_to_stack_pointer(16);
316
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
317
+ }
318
+ };
319
+
320
+ /**
321
+ * Re-emit input in its own format at full mode (all keys).
322
+ * @param {string} input
323
+ * @param {boolean} pretty
324
+ * @param {number} indent
325
+ * @returns {string}
326
+ */
327
+ module.exports.fullize = function(input, pretty, indent) {
328
+ let deferred2_0;
329
+ let deferred2_1;
330
+ try {
331
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
332
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
333
+ const len0 = WASM_VECTOR_LEN;
334
+ wasm.fullize(retptr, ptr0, len0, pretty, indent);
335
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
336
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
337
+ deferred2_0 = r0;
338
+ deferred2_1 = r1;
339
+ return getStringFromWasm0(r0, r1);
340
+ } finally {
341
+ wasm.__wbindgen_add_to_stack_pointer(16);
342
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
343
+ }
344
+ };
345
+
346
+ /**
347
+ * Convert between bitmark and JSON with explicit input/output formats + mode.
230
348
  *
231
- * Returns JSON if input is bitmark, or an error message if input is JSON
232
- * (generator not yet implemented).
349
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
350
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
351
+ * `mode`: `"optimized"` (default) | `"full"`.
352
+ * Returns the converted text/JSON, or a string prefixed `error:` on failure.
233
353
  * @param {string} input
354
+ * @param {string} input_format_sel
355
+ * @param {string} output_format_sel
234
356
  * @param {string} mode
235
- * @param {boolean} warnings
236
- * @param {boolean} plain_text
237
357
  * @param {boolean} pretty
238
358
  * @param {number} indent
359
+ * @param {number} spaces_around_values
239
360
  * @returns {string}
240
361
  */
241
- module.exports.convert = function(input, mode, warnings, plain_text, pretty, indent) {
242
- let deferred3_0;
243
- let deferred3_1;
362
+ module.exports.convert = function(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values) {
363
+ let deferred5_0;
364
+ let deferred5_1;
244
365
  try {
245
366
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
246
367
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
247
368
  const len0 = WASM_VECTOR_LEN;
248
- const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
369
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
249
370
  const len1 = WASM_VECTOR_LEN;
250
- wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);
371
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
372
+ const len2 = WASM_VECTOR_LEN;
373
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
374
+ const len3 = WASM_VECTOR_LEN;
375
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values);
251
376
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
252
377
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
253
- deferred3_0 = r0;
254
- deferred3_1 = r1;
378
+ deferred5_0 = r0;
379
+ deferred5_1 = r1;
255
380
  return getStringFromWasm0(r0, r1);
256
381
  } finally {
257
382
  wasm.__wbindgen_add_to_stack_pointer(16);
258
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
383
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
259
384
  }
260
385
  };
261
386
 
387
+ /**
388
+ * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
389
+ * used across the API so a JS caller can resolve `"auto"` consistently.
390
+ * @param {string} input
391
+ * @returns {boolean}
392
+ */
393
+ module.exports.is_bitmark = function(input) {
394
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
395
+ const len0 = WASM_VECTOR_LEN;
396
+ const ret = wasm.is_bitmark(ptr0, len0);
397
+ return ret !== 0;
398
+ };
399
+
262
400
  /**
263
401
  * Breakscape text (escape bitmark special characters).
264
402
  *
@@ -292,6 +430,115 @@ module.exports.breakscape_text = function(input, format, location) {
292
430
  }
293
431
  };
294
432
 
433
+ /**
434
+ * Parse bitmark input text and return the reference JSON format.
435
+ *
436
+ * Uses the full pipeline: parse → validate → serialize.
437
+ *
438
+ * `mode`: `"optimized"` (default) or `"full"`
439
+ * @param {string} input
440
+ * @param {string} mode
441
+ * @returns {string}
442
+ */
443
+ module.exports.parse = function(input, mode) {
444
+ let deferred3_0;
445
+ let deferred3_1;
446
+ try {
447
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
448
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
449
+ const len0 = WASM_VECTOR_LEN;
450
+ const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
451
+ const len1 = WASM_VECTOR_LEN;
452
+ wasm.parse(retptr, ptr0, len0, ptr1, len1);
453
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
454
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
455
+ deferred3_0 = r0;
456
+ deferred3_1 = r1;
457
+ return getStringFromWasm0(r0, r1);
458
+ } finally {
459
+ wasm.__wbindgen_add_to_stack_pointer(16);
460
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
461
+ }
462
+ };
463
+
464
+ /**
465
+ * Re-emit input in its own format at optimized mode (omit natural defaults).
466
+ * @param {string} input
467
+ * @param {boolean} pretty
468
+ * @param {number} indent
469
+ * @returns {string}
470
+ */
471
+ module.exports.optimize = function(input, pretty, indent) {
472
+ let deferred2_0;
473
+ let deferred2_1;
474
+ try {
475
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
476
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
477
+ const len0 = WASM_VECTOR_LEN;
478
+ wasm.optimize(retptr, ptr0, len0, pretty, indent);
479
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
480
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
481
+ deferred2_0 = r0;
482
+ deferred2_1 = r1;
483
+ return getStringFromWasm0(r0, r1);
484
+ } finally {
485
+ wasm.__wbindgen_add_to_stack_pointer(16);
486
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
487
+ }
488
+ };
489
+
490
+ /**
491
+ * Count the bits in `input` (auto-detecting bitmark vs JSON).
492
+ * Returns the count as a decimal string, or `error: …`.
493
+ * @param {string} input
494
+ * @returns {string}
495
+ */
496
+ module.exports.count_bits = function(input) {
497
+ let deferred2_0;
498
+ let deferred2_1;
499
+ try {
500
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
501
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
502
+ const len0 = WASM_VECTOR_LEN;
503
+ wasm.count_bits(retptr, ptr0, len0);
504
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
505
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
506
+ deferred2_0 = r0;
507
+ deferred2_1 = r1;
508
+ return getStringFromWasm0(r0, r1);
509
+ } finally {
510
+ wasm.__wbindgen_add_to_stack_pointer(16);
511
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
512
+ }
513
+ };
514
+
515
+ /**
516
+ * Split a bitmark document into per-bit source slices.
517
+ *
518
+ * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
519
+ * caller chunk a document at bit boundaries (e.g. to feed a worker pool).
520
+ * @param {string} input
521
+ * @returns {string}
522
+ */
523
+ module.exports.split_bits = function(input) {
524
+ let deferred2_0;
525
+ let deferred2_1;
526
+ try {
527
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
528
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
529
+ const len0 = WASM_VECTOR_LEN;
530
+ wasm.split_bits(retptr, ptr0, len0);
531
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
532
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
533
+ deferred2_0 = r0;
534
+ deferred2_1 = r1;
535
+ return getStringFromWasm0(r0, r1);
536
+ } finally {
537
+ wasm.__wbindgen_add_to_stack_pointer(16);
538
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
539
+ }
540
+ };
541
+
295
542
  const path = require('path').join(__dirname, 'bitmark_wasm_bg.wasm');
296
543
  const bytes = require('fs').readFileSync(path);
297
544
 
Binary file
@@ -2,10 +2,19 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const breakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
5
- export const convert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
5
+ export const canonicalize: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
6
+ export const convert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
7
+ export const count_bits: (a: number, b: number, c: number) => void;
8
+ export const fullize: (a: number, b: number, c: number, d: number, e: number) => void;
6
9
  export const info: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
10
+ export const is_bitmark: (a: number, b: number) => number;
7
11
  export const lex: (a: number, b: number, c: number, d: number, e: number) => void;
12
+ export const optimize: (a: number, b: number, c: number, d: number, e: number) => void;
8
13
  export const parse: (a: number, b: number, c: number, d: number, e: number) => void;
14
+ export const prettify: (a: number, b: number, c: number, d: number) => void;
15
+ export const split_bits: (a: number, b: number, c: number) => void;
16
+ export const split_json_bits: (a: number, b: number, c: number) => void;
17
+ export const transform: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number) => void;
9
18
  export const unbreakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
10
19
  export const __wbindgen_add_to_stack_pointer: (a: number) => number;
11
20
  export const __wbindgen_export_0: (a: number, b: number) => number;
package/wasm/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "Get More Brain Ltd <info@getmorebrain.com>"
5
5
  ],
6
6
  "description": "WebAssembly bindings for the bitmark parser",
7
- "version": "6.0.0",
7
+ "version": "6.1.0",
8
8
  "license": "ISC",
9
9
  "repository": {
10
10
  "type": "git",
@@ -17,4 +17,4 @@
17
17
  ],
18
18
  "main": "bitmark_wasm.js",
19
19
  "types": "bitmark_wasm.d.ts"
20
- }
20
+ }