@gmb/bitmark-parser 6.0.1 → 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.
@@ -1,4 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // wasm-web/bitmark_wasm.js
8
+ var bitmark_wasm_exports = {};
9
+ __export(bitmark_wasm_exports, {
10
+ breakscape_text: () => breakscape_text,
11
+ canonicalize: () => canonicalize,
12
+ convert: () => convert,
13
+ count_bits: () => count_bits,
14
+ default: () => bitmark_wasm_default,
15
+ fullize: () => fullize,
16
+ info: () => info,
17
+ initSync: () => initSync,
18
+ is_bitmark: () => is_bitmark,
19
+ lex: () => lex,
20
+ optimize: () => optimize,
21
+ parse: () => parse,
22
+ prettify: () => prettify,
23
+ split_bits: () => split_bits,
24
+ split_json_bits: () => split_json_bits,
25
+ transform: () => transform,
26
+ unbreakscape_text: () => unbreakscape_text
27
+ });
2
28
  var wasm;
3
29
  var WASM_VECTOR_LEN = 0;
4
30
  var cachedUint8ArrayMemory0 = null;
@@ -68,7 +94,89 @@ function getStringFromWasm0(ptr, len) {
68
94
  ptr = ptr >>> 0;
69
95
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
70
96
  }
71
- function unbreakscape_text(input, format, location) {
97
+ function canonicalize(input, mode, pretty, indent, spaces_around_values) {
98
+ let deferred3_0;
99
+ let deferred3_1;
100
+ try {
101
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
102
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
103
+ const len0 = WASM_VECTOR_LEN;
104
+ const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
105
+ const len1 = WASM_VECTOR_LEN;
106
+ wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, pretty, indent, spaces_around_values);
107
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
108
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
109
+ deferred3_0 = r0;
110
+ deferred3_1 = r1;
111
+ return getStringFromWasm0(r0, r1);
112
+ } finally {
113
+ wasm.__wbindgen_add_to_stack_pointer(16);
114
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
115
+ }
116
+ }
117
+ function fullize(input, pretty, indent) {
118
+ let deferred2_0;
119
+ let deferred2_1;
120
+ try {
121
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
122
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ wasm.fullize(retptr, ptr0, len0, pretty, indent);
125
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
126
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
127
+ deferred2_0 = r0;
128
+ deferred2_1 = r1;
129
+ return getStringFromWasm0(r0, r1);
130
+ } finally {
131
+ wasm.__wbindgen_add_to_stack_pointer(16);
132
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
133
+ }
134
+ }
135
+ function transform(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
136
+ let deferred6_0;
137
+ let deferred6_1;
138
+ try {
139
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
140
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
141
+ const len0 = WASM_VECTOR_LEN;
142
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
143
+ const len1 = WASM_VECTOR_LEN;
144
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
145
+ const len2 = WASM_VECTOR_LEN;
146
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
147
+ const len3 = WASM_VECTOR_LEN;
148
+ const ptr4 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
149
+ const len4 = WASM_VECTOR_LEN;
150
+ wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
151
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
152
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
153
+ deferred6_0 = r0;
154
+ deferred6_1 = r1;
155
+ return getStringFromWasm0(r0, r1);
156
+ } finally {
157
+ wasm.__wbindgen_add_to_stack_pointer(16);
158
+ wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
159
+ }
160
+ }
161
+ function split_bits(input) {
162
+ let deferred2_0;
163
+ let deferred2_1;
164
+ try {
165
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
166
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
167
+ const len0 = WASM_VECTOR_LEN;
168
+ wasm.split_bits(retptr, ptr0, len0);
169
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
170
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
171
+ deferred2_0 = r0;
172
+ deferred2_1 = r1;
173
+ return getStringFromWasm0(r0, r1);
174
+ } finally {
175
+ wasm.__wbindgen_add_to_stack_pointer(16);
176
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
177
+ }
178
+ }
179
+ function breakscape_text(input, format, location) {
72
180
  let deferred4_0;
73
181
  let deferred4_1;
74
182
  try {
@@ -79,7 +187,7 @@ function unbreakscape_text(input, format, location) {
79
187
  const len1 = WASM_VECTOR_LEN;
80
188
  const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
81
189
  const len2 = WASM_VECTOR_LEN;
82
- wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
190
+ wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
83
191
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
84
192
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
85
193
  deferred4_0 = r0;
@@ -90,16 +198,16 @@ function unbreakscape_text(input, format, location) {
90
198
  wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
91
199
  }
92
200
  }
93
- function convert(input, mode, warnings, plain_text, pretty, indent) {
201
+ function lex(input, stage) {
94
202
  let deferred3_0;
95
203
  let deferred3_1;
96
204
  try {
97
205
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
98
206
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
99
207
  const len0 = WASM_VECTOR_LEN;
100
- const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
208
+ const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
101
209
  const len1 = WASM_VECTOR_LEN;
102
- wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);
210
+ wasm.lex(retptr, ptr0, len0, ptr1, len1);
103
211
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
104
212
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
105
213
  deferred3_0 = r0;
@@ -110,27 +218,25 @@ function convert(input, mode, warnings, plain_text, pretty, indent) {
110
218
  wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
111
219
  }
112
220
  }
113
- function lex(input, stage) {
114
- let deferred3_0;
115
- let deferred3_1;
221
+ function split_json_bits(input) {
222
+ let deferred2_0;
223
+ let deferred2_1;
116
224
  try {
117
225
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
118
226
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
119
227
  const len0 = WASM_VECTOR_LEN;
120
- const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
121
- const len1 = WASM_VECTOR_LEN;
122
- wasm.lex(retptr, ptr0, len0, ptr1, len1);
228
+ wasm.split_json_bits(retptr, ptr0, len0);
123
229
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
124
230
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
125
- deferred3_0 = r0;
126
- deferred3_1 = r1;
231
+ deferred2_0 = r0;
232
+ deferred2_1 = r1;
127
233
  return getStringFromWasm0(r0, r1);
128
234
  } finally {
129
235
  wasm.__wbindgen_add_to_stack_pointer(16);
130
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
236
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
131
237
  }
132
238
  }
133
- function breakscape_text(input, format, location) {
239
+ function unbreakscape_text(input, format, location) {
134
240
  let deferred4_0;
135
241
  let deferred4_1;
136
242
  try {
@@ -141,7 +247,7 @@ function breakscape_text(input, format, location) {
141
247
  const len1 = WASM_VECTOR_LEN;
142
248
  const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
143
249
  const len2 = WASM_VECTOR_LEN;
144
- wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
250
+ wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
145
251
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
146
252
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
147
253
  deferred4_0 = r0;
@@ -152,6 +258,42 @@ function breakscape_text(input, format, location) {
152
258
  wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
153
259
  }
154
260
  }
261
+ function count_bits(input) {
262
+ let deferred2_0;
263
+ let deferred2_1;
264
+ try {
265
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
266
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
267
+ const len0 = WASM_VECTOR_LEN;
268
+ wasm.count_bits(retptr, ptr0, len0);
269
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
270
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
271
+ deferred2_0 = r0;
272
+ deferred2_1 = r1;
273
+ return getStringFromWasm0(r0, r1);
274
+ } finally {
275
+ wasm.__wbindgen_add_to_stack_pointer(16);
276
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
277
+ }
278
+ }
279
+ function optimize(input, pretty, indent) {
280
+ let deferred2_0;
281
+ let deferred2_1;
282
+ try {
283
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
284
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
285
+ const len0 = WASM_VECTOR_LEN;
286
+ wasm.optimize(retptr, ptr0, len0, pretty, indent);
287
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
288
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
289
+ deferred2_0 = r0;
290
+ deferred2_1 = r1;
291
+ return getStringFromWasm0(r0, r1);
292
+ } finally {
293
+ wasm.__wbindgen_add_to_stack_pointer(16);
294
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
295
+ }
296
+ }
155
297
  function info(info_type, format, bit, pretty, indent) {
156
298
  let deferred4_0;
157
299
  let deferred4_1;
@@ -194,6 +336,54 @@ function parse(input, mode) {
194
336
  wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
195
337
  }
196
338
  }
339
+ function is_bitmark(input) {
340
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
341
+ const len0 = WASM_VECTOR_LEN;
342
+ const ret = wasm.is_bitmark(ptr0, len0);
343
+ return ret !== 0;
344
+ }
345
+ function prettify(json, indent) {
346
+ let deferred2_0;
347
+ let deferred2_1;
348
+ try {
349
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
350
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
351
+ const len0 = WASM_VECTOR_LEN;
352
+ wasm.prettify(retptr, ptr0, len0, indent);
353
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
354
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
355
+ deferred2_0 = r0;
356
+ deferred2_1 = r1;
357
+ return getStringFromWasm0(r0, r1);
358
+ } finally {
359
+ wasm.__wbindgen_add_to_stack_pointer(16);
360
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
361
+ }
362
+ }
363
+ function convert(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values) {
364
+ let deferred5_0;
365
+ let deferred5_1;
366
+ try {
367
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
368
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
369
+ const len0 = WASM_VECTOR_LEN;
370
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
371
+ const len1 = WASM_VECTOR_LEN;
372
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
373
+ const len2 = WASM_VECTOR_LEN;
374
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
375
+ const len3 = WASM_VECTOR_LEN;
376
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values);
377
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
378
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
379
+ deferred5_0 = r0;
380
+ deferred5_1 = r1;
381
+ return getStringFromWasm0(r0, r1);
382
+ } finally {
383
+ wasm.__wbindgen_add_to_stack_pointer(16);
384
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
385
+ }
386
+ }
197
387
  async function __wbg_load(module, imports) {
198
388
  if (typeof Response === "function" && module instanceof Response) {
199
389
  if (typeof WebAssembly.instantiateStreaming === "function") {
@@ -274,12 +464,193 @@ var bitmark_wasm_default = __wbg_init;
274
464
  // src/generated/package_info.ts
275
465
  var PACKAGE_INFO = {
276
466
  "name": "@gmb/bitmark-parser",
277
- "version": "6.0.1",
467
+ "version": "6.1.1",
278
468
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
279
469
  "license": "ISC",
280
470
  "description": "A parser for bitmark text, powered by WebAssembly."
281
471
  };
282
472
 
473
+ // src/core/hooked-transform.ts
474
+ function isError(s) {
475
+ return s.startsWith("error:");
476
+ }
477
+ function errorString(e) {
478
+ const m = e instanceof Error ? e.message : String(e);
479
+ return m.startsWith("error:") ? m : `error: ${m}`;
480
+ }
481
+ function stripArray(doc) {
482
+ const t = doc.trim();
483
+ return t.startsWith("[") && t.endsWith("]") ? t.slice(1, -1) : doc;
484
+ }
485
+ function normalisePatch(patch) {
486
+ if (patch === void 0) return [];
487
+ if (typeof patch === "string") {
488
+ const trimmed = patch.trim();
489
+ return trimmed === "" ? [] : JSON.parse(trimmed);
490
+ }
491
+ return patch;
492
+ }
493
+ function buildUnits(wasm2, input, inputIsBitmark) {
494
+ if (inputIsBitmark) {
495
+ const out2 = wasm2.split_bits(input);
496
+ if (isError(out2)) throw new Error(out2);
497
+ const slices = JSON.parse(out2);
498
+ return slices.map((s) => ({
499
+ view: { format: "bitmark", index: s.index, total: slices.length, source: s.source },
500
+ source: s.source
501
+ }));
502
+ }
503
+ const out = wasm2.split_json_bits(input);
504
+ if (isError(out)) throw new Error(out);
505
+ const envelopes = JSON.parse(out);
506
+ return envelopes.map((env, index) => ({
507
+ view: { format: "json", index, total: envelopes.length, bit: env.bit },
508
+ // Per-bit transform consumes a one-bit JSON document.
509
+ source: JSON.stringify([env])
510
+ }));
511
+ }
512
+ function planTransform(wasm2, input, options) {
513
+ const mode = options.mode ?? "optimized";
514
+ const output = options.outputFormat ?? "json";
515
+ const spacesAroundValues = options.spacesAroundValues ?? 1;
516
+ const indent = options.indent ?? 2;
517
+ const pretty = options.pretty ?? false;
518
+ const sel = options.inputFormat ?? "auto";
519
+ const inputIsBitmark = sel === "bitmark" || sel !== "json" && wasm2.is_bitmark(input);
520
+ const inputFormat = inputIsBitmark ? "bitmark" : "json";
521
+ const staticPatch = normalisePatch(options.patch);
522
+ const units = buildUnits(wasm2, input, inputIsBitmark);
523
+ const total = units.length;
524
+ const jobs = [];
525
+ const views = [];
526
+ for (let index = 0; index < total; index++) {
527
+ const { view, source } = units[index];
528
+ view.index = index;
529
+ view.total = total;
530
+ const result = options.preHook ? options.preHook(view) || {} : {};
531
+ if (result.drop) continue;
532
+ const patches = result.patches ? [...staticPatch, ...result.patches] : staticPatch;
533
+ jobs.push({
534
+ index,
535
+ source,
536
+ inputFormat,
537
+ outputFormat: result.outputFormat ?? output,
538
+ mode,
539
+ patchJson: JSON.stringify(patches),
540
+ spacesAroundValues
541
+ });
542
+ views.push(view);
543
+ }
544
+ return { jobs, views, output, pretty, indent };
545
+ }
546
+ function computeBit(wasm2, job) {
547
+ const out = wasm2.transform(
548
+ job.source,
549
+ job.inputFormat,
550
+ job.outputFormat,
551
+ job.mode,
552
+ job.patchJson,
553
+ false,
554
+ 2,
555
+ job.spacesAroundValues
556
+ );
557
+ if (isError(out)) return out;
558
+ return job.outputFormat === "json" ? stripArray(out) : out;
559
+ }
560
+ function recombine(wasm2, elements, output, pretty, indent) {
561
+ if (output === "bitmark" || output === "text") return elements.join("\n");
562
+ const arr = `[${elements.join(",")}]`;
563
+ return pretty ? wasm2.prettify(arr, indent) : arr;
564
+ }
565
+ function runHookedTransform(wasm2, input, options) {
566
+ let plan;
567
+ try {
568
+ plan = planTransform(wasm2, input, options);
569
+ } catch (e) {
570
+ return errorString(e);
571
+ }
572
+ const rendered = [];
573
+ for (let i = 0; i < plan.jobs.length; i++) {
574
+ const element = computeBit(wasm2, plan.jobs[i]);
575
+ if (isError(element)) return element;
576
+ options.postHook?.(plan.views[i], element);
577
+ rendered.push(element);
578
+ }
579
+ return recombine(wasm2, rendered, plan.output, plan.pretty, plan.indent);
580
+ }
581
+
582
+ // src/core/parallel.ts
583
+ async function orchestrateParallel(wasm2, input, options, runJobs) {
584
+ let plan;
585
+ try {
586
+ plan = planTransform(wasm2, input, options);
587
+ } catch (e) {
588
+ return errorString(e);
589
+ }
590
+ let elements;
591
+ try {
592
+ elements = await runJobs(plan.jobs, options.workers ?? 4);
593
+ } catch (e) {
594
+ return errorString(e);
595
+ }
596
+ for (let i = 0; i < elements.length; i++) {
597
+ if (isError(elements[i])) return elements[i];
598
+ options.postHook?.(plan.views[i], elements[i]);
599
+ }
600
+ return recombine(wasm2, elements, plan.output, plan.pretty, plan.indent);
601
+ }
602
+
603
+ // src/browser/pool.ts
604
+ function runJobsParallel(jobs, workers) {
605
+ if (jobs.length === 0) return Promise.resolve([]);
606
+ const poolSize = Math.max(1, Math.min(workers, jobs.length));
607
+ const workerUrl = new URL("./worker-entry.js", import.meta.url);
608
+ return new Promise((resolve, reject) => {
609
+ const results = new Array(jobs.length);
610
+ let next = 0;
611
+ let settled = 0;
612
+ let done = false;
613
+ const pool = [];
614
+ const shutdown = () => {
615
+ for (const w of pool) w.terminate();
616
+ };
617
+ const fail = (err) => {
618
+ if (done) return;
619
+ done = true;
620
+ shutdown();
621
+ reject(err);
622
+ };
623
+ const dispatch = (w) => {
624
+ if (done || next >= jobs.length) return;
625
+ const id = next++;
626
+ w.postMessage({ id, job: jobs[id] });
627
+ };
628
+ for (let i = 0; i < poolSize; i++) {
629
+ const w = new Worker(workerUrl, { type: "module" });
630
+ pool.push(w);
631
+ w.onmessage = (ev) => {
632
+ const res = ev.data;
633
+ if (done) return;
634
+ if (!res.ok) {
635
+ fail(new Error(res.error ?? "worker job failed"));
636
+ return;
637
+ }
638
+ results[res.id] = res.element;
639
+ settled++;
640
+ if (settled === jobs.length) {
641
+ done = true;
642
+ shutdown();
643
+ resolve(results);
644
+ return;
645
+ }
646
+ dispatch(w);
647
+ };
648
+ w.onerror = (e) => fail(new Error(e.message || "worker error"));
649
+ }
650
+ for (const w of pool) dispatch(w);
651
+ });
652
+ }
653
+
283
654
  // src/browser/index.ts
284
655
  async function init(module_or_path) {
285
656
  if (typeof module_or_path === "undefined") {
@@ -297,7 +668,58 @@ function parse2(input, options = {}) {
297
668
  return parse(input, options.mode ?? "optimized");
298
669
  }
299
670
  function convert2(input, options = {}) {
300
- return convert(input, options.mode ?? "optimized", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);
671
+ return convert(
672
+ input,
673
+ options.inputFormat ?? "auto",
674
+ options.outputFormat ?? "auto",
675
+ options.mode ?? "optimized",
676
+ options.pretty ?? false,
677
+ options.indent ?? 2,
678
+ options.spacesAroundValues ?? 1
679
+ );
680
+ }
681
+ function optimize2(input, options = {}) {
682
+ return optimize(input, options.pretty ?? false, options.indent ?? 2);
683
+ }
684
+ function fullize2(input, options = {}) {
685
+ return fullize(input, options.pretty ?? false, options.indent ?? 2);
686
+ }
687
+ var expand = fullize2;
688
+ function canonicalize2(input, options = {}) {
689
+ return canonicalize(
690
+ input,
691
+ options.mode ?? "optimized",
692
+ options.pretty ?? false,
693
+ options.indent ?? 2,
694
+ options.spacesAroundValues ?? 1
695
+ );
696
+ }
697
+ function countBits(input) {
698
+ const out = count_bits(input);
699
+ if (out.startsWith("error:")) throw new Error(out);
700
+ return Number.parseInt(out, 10);
701
+ }
702
+ function splitBits(input) {
703
+ return JSON.parse(split_bits(input));
704
+ }
705
+ function transform2(input, options = {}) {
706
+ if (options.preHook || options.postHook) {
707
+ return runHookedTransform(bitmark_wasm_exports, input, options);
708
+ }
709
+ const patchJson = options.patch === void 0 ? "" : typeof options.patch === "string" ? options.patch : JSON.stringify(options.patch);
710
+ return transform(
711
+ input,
712
+ options.inputFormat ?? "auto",
713
+ options.outputFormat ?? "json",
714
+ options.mode ?? "optimized",
715
+ patchJson,
716
+ options.pretty ?? false,
717
+ options.indent ?? 2,
718
+ options.spacesAroundValues ?? 1
719
+ );
720
+ }
721
+ function transformParallel(input, options = {}) {
722
+ return orchestrateParallel(bitmark_wasm_exports, input, options, runJobsParallel);
301
723
  }
302
724
  function breakscapeText(input, options = {}) {
303
725
  const format = options.format ?? "bitmark++";
@@ -319,12 +741,20 @@ function info2(options = {}) {
319
741
  }
320
742
  export {
321
743
  breakscapeText,
744
+ canonicalize2 as canonicalize,
322
745
  convert2 as convert,
746
+ countBits,
747
+ expand,
748
+ fullize2 as fullize,
323
749
  info2 as info,
324
750
  init,
325
751
  initSync,
326
752
  lex2 as lex,
753
+ optimize2 as optimize,
327
754
  parse2 as parse,
755
+ splitBits,
756
+ transform2 as transform,
757
+ transformParallel,
328
758
  unbreakscapeText,
329
759
  version
330
760
  };