@gmb/bitmark-parser 6.1.0 → 6.1.1

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.
@@ -86,26 +86,24 @@ function getStringFromWasm0(ptr, len) {
86
86
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
87
87
  }
88
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
89
+ * Re-emit input in its own format in canonical form at `mode`.
95
90
  * @param {string} input
96
- * @param {string} stage
91
+ * @param {string} mode
92
+ * @param {boolean} pretty
93
+ * @param {number} indent
94
+ * @param {number} spaces_around_values
97
95
  * @returns {string}
98
96
  */
99
- module.exports.lex = function(input, stage) {
97
+ module.exports.canonicalize = function(input, mode, pretty, indent, spaces_around_values) {
100
98
  let deferred3_0;
101
99
  let deferred3_1;
102
100
  try {
103
101
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
104
102
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
105
103
  const len0 = WASM_VECTOR_LEN;
106
- const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
104
+ const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
107
105
  const len1 = WASM_VECTOR_LEN;
108
- wasm.lex(retptr, ptr0, len0, ptr1, len1);
106
+ wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, pretty, indent, spaces_around_values);
109
107
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
110
108
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
111
109
  deferred3_0 = r0;
@@ -118,21 +116,20 @@ module.exports.lex = function(input, stage) {
118
116
  };
119
117
 
120
118
  /**
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
119
+ * Re-emit input in its own format at full mode (all keys).
120
+ * @param {string} input
121
+ * @param {boolean} pretty
125
122
  * @param {number} indent
126
123
  * @returns {string}
127
124
  */
128
- module.exports.prettify = function(json, indent) {
125
+ module.exports.fullize = function(input, pretty, indent) {
129
126
  let deferred2_0;
130
127
  let deferred2_1;
131
128
  try {
132
129
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
133
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
130
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
134
131
  const len0 = WASM_VECTOR_LEN;
135
- wasm.prettify(retptr, ptr0, len0, indent);
132
+ wasm.fullize(retptr, ptr0, len0, pretty, indent);
136
133
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
137
134
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
138
135
  deferred2_0 = r0;
@@ -145,140 +142,131 @@ module.exports.prettify = function(json, indent) {
145
142
  };
146
143
 
147
144
  /**
148
- * Unbreakscape text (unescape bitmark special characters).
145
+ * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
149
146
  *
150
- * `format`: `"bitmark++"` (default) or `"plainText"`
151
- * `location`: `"body"` (default) or `"tag"`
147
+ * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
148
+ * `output_format_sel`: `"bitmark"` | `"json"` (default json).
149
+ * `patch_json`: the patch entry array (empty string = no patches, i.e. a
150
+ * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
151
+ * runs sequentially. Returns the document text/JSON, or `error: …`.
152
152
  * @param {string} input
153
- * @param {string} format
154
- * @param {string} location
153
+ * @param {string} input_format_sel
154
+ * @param {string} output_format_sel
155
+ * @param {string} mode
156
+ * @param {string} patch_json
157
+ * @param {boolean} pretty
158
+ * @param {number} indent
159
+ * @param {number} spaces_around_values
155
160
  * @returns {string}
156
161
  */
157
- module.exports.unbreakscape_text = function(input, format, location) {
158
- let deferred4_0;
159
- let deferred4_1;
162
+ module.exports.transform = function(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
163
+ let deferred6_0;
164
+ let deferred6_1;
160
165
  try {
161
166
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
162
167
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
163
168
  const len0 = WASM_VECTOR_LEN;
164
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
169
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
165
170
  const len1 = WASM_VECTOR_LEN;
166
- const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
171
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
167
172
  const len2 = WASM_VECTOR_LEN;
168
- wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
173
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
174
+ const len3 = WASM_VECTOR_LEN;
175
+ const ptr4 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
176
+ const len4 = WASM_VECTOR_LEN;
177
+ wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
169
178
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
170
179
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
171
- deferred4_0 = r0;
172
- deferred4_1 = r1;
180
+ deferred6_0 = r0;
181
+ deferred6_1 = r1;
173
182
  return getStringFromWasm0(r0, r1);
174
183
  } finally {
175
184
  wasm.__wbindgen_add_to_stack_pointer(16);
176
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
185
+ wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
177
186
  }
178
187
  };
179
188
 
180
189
  /**
181
- * Query information about supported bit types.
190
+ * Split a bitmark document into per-bit source slices.
182
191
  *
183
- * `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
184
- * `format`: `"text"` or `"json"`
185
- * `bit`: bit name (required when `info_type` is `"bit"`)
186
- * `pretty`: whether to pretty-print JSON output
187
- * `indent`: indent size for pretty-printing (default: 2)
188
- * @param {string} info_type
189
- * @param {string} format
190
- * @param {string} bit
191
- * @param {boolean} pretty
192
- * @param {number} indent
192
+ * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
193
+ * caller chunk a document at bit boundaries (e.g. to feed a worker pool).
194
+ * @param {string} input
193
195
  * @returns {string}
194
196
  */
195
- module.exports.info = function(info_type, format, bit, pretty, indent) {
196
- let deferred4_0;
197
- let deferred4_1;
197
+ module.exports.split_bits = function(input) {
198
+ let deferred2_0;
199
+ let deferred2_1;
198
200
  try {
199
201
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
200
- const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
202
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
201
203
  const len0 = WASM_VECTOR_LEN;
202
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
203
- const len1 = WASM_VECTOR_LEN;
204
- const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
205
- const len2 = WASM_VECTOR_LEN;
206
- wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
204
+ wasm.split_bits(retptr, ptr0, len0);
207
205
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
208
206
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
209
- deferred4_0 = r0;
210
- deferred4_1 = r1;
207
+ deferred2_0 = r0;
208
+ deferred2_1 = r1;
211
209
  return getStringFromWasm0(r0, r1);
212
210
  } finally {
213
211
  wasm.__wbindgen_add_to_stack_pointer(16);
214
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
212
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
215
213
  }
216
214
  };
217
215
 
218
216
  /**
219
- * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
217
+ * Breakscape text (escape bitmark special characters).
220
218
  *
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: …`.
219
+ * `format`: `"bitmark++"` (default) or `"plainText"`
220
+ * `location`: `"body"` (default) or `"tag"`
226
221
  * @param {string} input
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
222
+ * @param {string} format
223
+ * @param {string} location
234
224
  * @returns {string}
235
225
  */
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;
226
+ module.exports.breakscape_text = function(input, format, location) {
227
+ let deferred4_0;
228
+ let deferred4_1;
239
229
  try {
240
230
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
241
231
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
242
232
  const len0 = WASM_VECTOR_LEN;
243
- const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
233
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
244
234
  const len1 = WASM_VECTOR_LEN;
245
- const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
235
+ const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
246
236
  const len2 = WASM_VECTOR_LEN;
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);
237
+ wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
252
238
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
253
239
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
254
- deferred6_0 = r0;
255
- deferred6_1 = r1;
240
+ deferred4_0 = r0;
241
+ deferred4_1 = r1;
256
242
  return getStringFromWasm0(r0, r1);
257
243
  } finally {
258
244
  wasm.__wbindgen_add_to_stack_pointer(16);
259
- wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
245
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
260
246
  }
261
247
  };
262
248
 
263
249
  /**
264
- * Re-emit input in its own format in canonical form at `mode`.
250
+ * Lex bitmark input text, returning one line per token in the same format as
251
+ * the Rust CLI: `{kind:?} {span:?} "{text}"`.
252
+ *
253
+ * `stage` selects the lexer pipeline:
254
+ * - `"lex"` — combined (default)
255
+ * - `"lex-json"` — combined, JSON array output
265
256
  * @param {string} input
266
- * @param {string} mode
267
- * @param {boolean} pretty
268
- * @param {number} indent
269
- * @param {number} spaces_around_values
257
+ * @param {string} stage
270
258
  * @returns {string}
271
259
  */
272
- module.exports.canonicalize = function(input, mode, pretty, indent, spaces_around_values) {
260
+ module.exports.lex = function(input, stage) {
273
261
  let deferred3_0;
274
262
  let deferred3_1;
275
263
  try {
276
264
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
277
265
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
278
266
  const len0 = WASM_VECTOR_LEN;
279
- const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
267
+ const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
280
268
  const len1 = WASM_VECTOR_LEN;
281
- wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, pretty, indent, spaces_around_values);
269
+ wasm.lex(retptr, ptr0, len0, ptr1, len1);
282
270
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
283
271
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
284
272
  deferred3_0 = r0;
@@ -318,20 +306,52 @@ module.exports.split_json_bits = function(input) {
318
306
  };
319
307
 
320
308
  /**
321
- * Re-emit input in its own format at full mode (all keys).
309
+ * Unbreakscape text (unescape bitmark special characters).
310
+ *
311
+ * `format`: `"bitmark++"` (default) or `"plainText"`
312
+ * `location`: `"body"` (default) or `"tag"`
322
313
  * @param {string} input
323
- * @param {boolean} pretty
324
- * @param {number} indent
314
+ * @param {string} format
315
+ * @param {string} location
325
316
  * @returns {string}
326
317
  */
327
- module.exports.fullize = function(input, pretty, indent) {
318
+ module.exports.unbreakscape_text = function(input, format, location) {
319
+ let deferred4_0;
320
+ let deferred4_1;
321
+ try {
322
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
323
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
324
+ const len0 = WASM_VECTOR_LEN;
325
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
326
+ const len1 = WASM_VECTOR_LEN;
327
+ const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
328
+ const len2 = WASM_VECTOR_LEN;
329
+ wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
330
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
331
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
332
+ deferred4_0 = r0;
333
+ deferred4_1 = r1;
334
+ return getStringFromWasm0(r0, r1);
335
+ } finally {
336
+ wasm.__wbindgen_add_to_stack_pointer(16);
337
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
338
+ }
339
+ };
340
+
341
+ /**
342
+ * Count the bits in `input` (auto-detecting bitmark vs JSON).
343
+ * Returns the count as a decimal string, or `error: …`.
344
+ * @param {string} input
345
+ * @returns {string}
346
+ */
347
+ module.exports.count_bits = function(input) {
328
348
  let deferred2_0;
329
349
  let deferred2_1;
330
350
  try {
331
351
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
332
352
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
333
353
  const len0 = WASM_VECTOR_LEN;
334
- wasm.fullize(retptr, ptr0, len0, pretty, indent);
354
+ wasm.count_bits(retptr, ptr0, len0);
335
355
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
336
356
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
337
357
  deferred2_0 = r0;
@@ -344,81 +364,58 @@ module.exports.fullize = function(input, pretty, indent) {
344
364
  };
345
365
 
346
366
  /**
347
- * Convert between bitmark and JSON with explicit input/output formats + mode.
348
- *
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.
367
+ * Re-emit input in its own format at optimized mode (omit natural defaults).
353
368
  * @param {string} input
354
- * @param {string} input_format_sel
355
- * @param {string} output_format_sel
356
- * @param {string} mode
357
369
  * @param {boolean} pretty
358
370
  * @param {number} indent
359
- * @param {number} spaces_around_values
360
371
  * @returns {string}
361
372
  */
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;
373
+ module.exports.optimize = function(input, pretty, indent) {
374
+ let deferred2_0;
375
+ let deferred2_1;
365
376
  try {
366
377
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
367
378
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
368
379
  const len0 = WASM_VECTOR_LEN;
369
- const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
370
- const len1 = WASM_VECTOR_LEN;
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);
380
+ wasm.optimize(retptr, ptr0, len0, pretty, indent);
376
381
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
377
382
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
378
- deferred5_0 = r0;
379
- deferred5_1 = r1;
383
+ deferred2_0 = r0;
384
+ deferred2_1 = r1;
380
385
  return getStringFromWasm0(r0, r1);
381
386
  } finally {
382
387
  wasm.__wbindgen_add_to_stack_pointer(16);
383
- wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
388
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
384
389
  }
385
390
  };
386
391
 
387
392
  /**
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
-
400
- /**
401
- * Breakscape text (escape bitmark special characters).
393
+ * Query information about supported bit types.
402
394
  *
403
- * `format`: `"bitmark++"` (default) or `"plainText"`
404
- * `location`: `"body"` (default) or `"tag"`
405
- * @param {string} input
395
+ * `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
396
+ * `format`: `"text"` or `"json"`
397
+ * `bit`: bit name (required when `info_type` is `"bit"`)
398
+ * `pretty`: whether to pretty-print JSON output
399
+ * `indent`: indent size for pretty-printing (default: 2)
400
+ * @param {string} info_type
406
401
  * @param {string} format
407
- * @param {string} location
402
+ * @param {string} bit
403
+ * @param {boolean} pretty
404
+ * @param {number} indent
408
405
  * @returns {string}
409
406
  */
410
- module.exports.breakscape_text = function(input, format, location) {
407
+ module.exports.info = function(info_type, format, bit, pretty, indent) {
411
408
  let deferred4_0;
412
409
  let deferred4_1;
413
410
  try {
414
411
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
415
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
412
+ const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
416
413
  const len0 = WASM_VECTOR_LEN;
417
414
  const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
418
415
  const len1 = WASM_VECTOR_LEN;
419
- const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
416
+ const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
420
417
  const len2 = WASM_VECTOR_LEN;
421
- wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
418
+ wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
422
419
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
423
420
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
424
421
  deferred4_0 = r0;
@@ -462,45 +459,34 @@ module.exports.parse = function(input, mode) {
462
459
  };
463
460
 
464
461
  /**
465
- * Re-emit input in its own format at optimized mode (omit natural defaults).
462
+ * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
463
+ * used across the API so a JS caller can resolve `"auto"` consistently.
466
464
  * @param {string} input
467
- * @param {boolean} pretty
468
- * @param {number} indent
469
- * @returns {string}
465
+ * @returns {boolean}
470
466
  */
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
- }
467
+ module.exports.is_bitmark = function(input) {
468
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
469
+ const len0 = WASM_VECTOR_LEN;
470
+ const ret = wasm.is_bitmark(ptr0, len0);
471
+ return ret !== 0;
488
472
  };
489
473
 
490
474
  /**
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
475
+ * Pretty-print a compact JSON string with the given indent. Used to format a
476
+ * document recombined on the JS side (the per-bit hook path) so its output
477
+ * matches the in-Rust recombination byte-for-byte.
478
+ * @param {string} json
479
+ * @param {number} indent
494
480
  * @returns {string}
495
481
  */
496
- module.exports.count_bits = function(input) {
482
+ module.exports.prettify = function(json, indent) {
497
483
  let deferred2_0;
498
484
  let deferred2_1;
499
485
  try {
500
486
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
501
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
487
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
502
488
  const len0 = WASM_VECTOR_LEN;
503
- wasm.count_bits(retptr, ptr0, len0);
489
+ wasm.prettify(retptr, ptr0, len0, indent);
504
490
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
505
491
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
506
492
  deferred2_0 = r0;
@@ -513,29 +499,43 @@ module.exports.count_bits = function(input) {
513
499
  };
514
500
 
515
501
  /**
516
- * Split a bitmark document into per-bit source slices.
502
+ * Convert between bitmark and JSON with explicit input/output formats + mode.
517
503
  *
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).
504
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
505
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
506
+ * `mode`: `"optimized"` (default) | `"full"`.
507
+ * Returns the converted text/JSON, or a string prefixed `error:` on failure.
520
508
  * @param {string} input
509
+ * @param {string} input_format_sel
510
+ * @param {string} output_format_sel
511
+ * @param {string} mode
512
+ * @param {boolean} pretty
513
+ * @param {number} indent
514
+ * @param {number} spaces_around_values
521
515
  * @returns {string}
522
516
  */
523
- module.exports.split_bits = function(input) {
524
- let deferred2_0;
525
- let deferred2_1;
517
+ module.exports.convert = function(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values) {
518
+ let deferred5_0;
519
+ let deferred5_1;
526
520
  try {
527
521
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
528
522
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
529
523
  const len0 = WASM_VECTOR_LEN;
530
- wasm.split_bits(retptr, ptr0, len0);
524
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
525
+ const len1 = WASM_VECTOR_LEN;
526
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
527
+ const len2 = WASM_VECTOR_LEN;
528
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
529
+ const len3 = WASM_VECTOR_LEN;
530
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values);
531
531
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
532
532
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
533
- deferred2_0 = r0;
534
- deferred2_1 = r1;
533
+ deferred5_0 = r0;
534
+ deferred5_1 = r1;
535
535
  return getStringFromWasm0(r0, r1);
536
536
  } finally {
537
537
  wasm.__wbindgen_add_to_stack_pointer(16);
538
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
538
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
539
539
  }
540
540
  };
541
541
 
Binary file
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.1.0",
7
+ "version": "6.1.1",
8
8
  "license": "ISC",
9
9
  "repository": {
10
10
  "type": "git",