@gmb/bitmark-parser 6.8.0 → 6.10.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 (43) hide show
  1. package/README.md +74 -5
  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/bitmark_json_wasm_bg.wasm +0 -0
  5. package/dist/browser/bitmark_wasm_bg.wasm +0 -0
  6. package/dist/browser/cjs/bitmark_json_wasm_bg.wasm +0 -0
  7. package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
  8. package/dist/browser/cjs/index.cjs +624 -116
  9. package/dist/browser/cjs/index.cjs.map +1 -1
  10. package/dist/browser/cjs/index.d.cts +3423 -3054
  11. package/dist/browser/esm/bitmark_json_wasm_bg.wasm +0 -0
  12. package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
  13. package/dist/browser/esm/index.d.ts +3423 -3054
  14. package/dist/browser/esm/index.js +621 -116
  15. package/dist/browser/esm/index.js.map +1 -1
  16. package/dist/browser/esm/worker-entry.js +704 -7
  17. package/dist/browser/esm/worker-entry.js.map +1 -1
  18. package/dist/index.cjs +158 -86
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1209 -879
  21. package/dist/index.d.ts +1209 -879
  22. package/dist/index.js +153 -86
  23. package/dist/index.js.map +1 -1
  24. package/dist/legacy.cjs +13 -13
  25. package/dist/legacy.cjs.map +1 -1
  26. package/dist/legacy.d.cts +3 -1
  27. package/dist/legacy.d.ts +3 -1
  28. package/dist/legacy.js +13 -13
  29. package/dist/legacy.js.map +1 -1
  30. package/dist/worker-entry.cjs +6 -1
  31. package/dist/worker-entry.cjs.map +1 -1
  32. package/package.json +8 -7
  33. package/schema/bitmark.schema.json +3778 -2828
  34. package/wasm/bitmark_wasm.d.ts +6 -1
  35. package/wasm/bitmark_wasm.js +10 -2
  36. package/wasm/bitmark_wasm_bg.wasm +0 -0
  37. package/wasm/bitmark_wasm_bg.wasm.d.ts +1 -1
  38. package/wasm/package.json +1 -1
  39. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +99 -0
  40. package/wasm-bitmark-json/bitmark_json_wasm.js +491 -0
  41. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  42. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +19 -0
  43. package/wasm-bitmark-json/package.json +20 -0
@@ -22,22 +22,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22
22
  // src/browser/index.ts
23
23
  var index_exports = {};
24
24
  __export(index_exports, {
25
+ NotInitializedError: () => NotInitializedError,
26
+ UnsupportedFeatureError: () => UnsupportedFeatureError,
25
27
  bitmarkToObjects: () => bitmarkToObjects,
26
28
  breakscapeText: () => breakscapeText,
27
- canonicalize: () => canonicalize2,
28
- convert: () => convert2,
29
+ canonicalize: () => canonicalize3,
30
+ convert: () => convert3,
29
31
  countBits: () => countBits,
30
- info: () => info2,
32
+ info: () => info3,
31
33
  init: () => init,
32
- initSync: () => initSync,
34
+ initSync: () => initSync3,
33
35
  legacy: () => legacy_exports,
34
36
  lex: () => lex2,
35
37
  objectsToBitmark: () => objectsToBitmark,
36
38
  patchEntry: () => patchEntry,
37
39
  splitBits: () => splitBits,
38
- transform: () => transform2,
40
+ transform: () => transform3,
39
41
  transformParallel: () => transformParallel,
40
42
  unbreakscapeText: () => unbreakscapeText,
43
+ variant: () => variant,
41
44
  version: () => version
42
45
  });
43
46
  module.exports = __toCommonJS(index_exports);
@@ -198,7 +201,7 @@ function unbreakscape_text(input, format, location) {
198
201
  wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
199
202
  }
200
203
  }
201
- function info(info_type, format, bit, pretty, indent) {
204
+ function info(info_type, format, bit, pretty, indent, include_deprecated, only_deprecated, full) {
202
205
  let deferred4_0;
203
206
  let deferred4_1;
204
207
  try {
@@ -209,7 +212,7 @@ function info(info_type, format, bit, pretty, indent) {
209
212
  const len1 = WASM_VECTOR_LEN;
210
213
  const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
211
214
  const len2 = WASM_VECTOR_LEN;
212
- wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
215
+ wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, include_deprecated, only_deprecated, full);
213
216
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
214
217
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
215
218
  deferred4_0 = r0;
@@ -471,15 +474,450 @@ async function __wbg_init(module_or_path) {
471
474
  }
472
475
  var bitmark_wasm_default = __wbg_init;
473
476
 
477
+ // wasm-web-bitmark-json/bitmark_json_wasm.js
478
+ var bitmark_json_wasm_exports = {};
479
+ __export(bitmark_json_wasm_exports, {
480
+ breakscape_text: () => breakscape_text2,
481
+ canonicalize: () => canonicalize2,
482
+ convert: () => convert2,
483
+ convert_text: () => convert_text2,
484
+ count_bits: () => count_bits2,
485
+ default: () => bitmark_json_wasm_default,
486
+ info: () => info2,
487
+ initSync: () => initSync2,
488
+ is_bitmark: () => is_bitmark2,
489
+ prettify: () => prettify2,
490
+ split_bits: () => split_bits2,
491
+ split_json_bits: () => split_json_bits2,
492
+ transform: () => transform2,
493
+ unbreakscape_text: () => unbreakscape_text2
494
+ });
495
+ var wasm2;
496
+ var WASM_VECTOR_LEN2 = 0;
497
+ var cachedUint8ArrayMemory02 = null;
498
+ function getUint8ArrayMemory02() {
499
+ if (cachedUint8ArrayMemory02 === null || cachedUint8ArrayMemory02.byteLength === 0) {
500
+ cachedUint8ArrayMemory02 = new Uint8Array(wasm2.memory.buffer);
501
+ }
502
+ return cachedUint8ArrayMemory02;
503
+ }
504
+ var cachedTextEncoder2 = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
505
+ throw Error("TextEncoder not available");
506
+ } };
507
+ var encodeString2 = typeof cachedTextEncoder2.encodeInto === "function" ? function(arg, view) {
508
+ return cachedTextEncoder2.encodeInto(arg, view);
509
+ } : function(arg, view) {
510
+ const buf = cachedTextEncoder2.encode(arg);
511
+ view.set(buf);
512
+ return {
513
+ read: arg.length,
514
+ written: buf.length
515
+ };
516
+ };
517
+ function passStringToWasm02(arg, malloc, realloc) {
518
+ if (realloc === void 0) {
519
+ const buf = cachedTextEncoder2.encode(arg);
520
+ const ptr2 = malloc(buf.length, 1) >>> 0;
521
+ getUint8ArrayMemory02().subarray(ptr2, ptr2 + buf.length).set(buf);
522
+ WASM_VECTOR_LEN2 = buf.length;
523
+ return ptr2;
524
+ }
525
+ let len = arg.length;
526
+ let ptr = malloc(len, 1) >>> 0;
527
+ const mem = getUint8ArrayMemory02();
528
+ let offset = 0;
529
+ for (; offset < len; offset++) {
530
+ const code = arg.charCodeAt(offset);
531
+ if (code > 127) break;
532
+ mem[ptr + offset] = code;
533
+ }
534
+ if (offset !== len) {
535
+ if (offset !== 0) {
536
+ arg = arg.slice(offset);
537
+ }
538
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
539
+ const view = getUint8ArrayMemory02().subarray(ptr + offset, ptr + len);
540
+ const ret = encodeString2(arg, view);
541
+ offset += ret.written;
542
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
543
+ }
544
+ WASM_VECTOR_LEN2 = offset;
545
+ return ptr;
546
+ }
547
+ var cachedDataViewMemory02 = null;
548
+ function getDataViewMemory02() {
549
+ if (cachedDataViewMemory02 === null || cachedDataViewMemory02.buffer.detached === true || cachedDataViewMemory02.buffer.detached === void 0 && cachedDataViewMemory02.buffer !== wasm2.memory.buffer) {
550
+ cachedDataViewMemory02 = new DataView(wasm2.memory.buffer);
551
+ }
552
+ return cachedDataViewMemory02;
553
+ }
554
+ var cachedTextDecoder2 = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
555
+ throw Error("TextDecoder not available");
556
+ } };
557
+ if (typeof TextDecoder !== "undefined") {
558
+ cachedTextDecoder2.decode();
559
+ }
560
+ function getStringFromWasm02(ptr, len) {
561
+ ptr = ptr >>> 0;
562
+ return cachedTextDecoder2.decode(getUint8ArrayMemory02().subarray(ptr, ptr + len));
563
+ }
564
+ function breakscape_text2(input, format, location) {
565
+ let deferred4_0;
566
+ let deferred4_1;
567
+ try {
568
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
569
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
570
+ const len0 = WASM_VECTOR_LEN2;
571
+ const ptr1 = passStringToWasm02(format, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
572
+ const len1 = WASM_VECTOR_LEN2;
573
+ const ptr2 = passStringToWasm02(location, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
574
+ const len2 = WASM_VECTOR_LEN2;
575
+ wasm2.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
576
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
577
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
578
+ deferred4_0 = r0;
579
+ deferred4_1 = r1;
580
+ return getStringFromWasm02(r0, r1);
581
+ } finally {
582
+ wasm2.__wbindgen_add_to_stack_pointer(16);
583
+ wasm2.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
584
+ }
585
+ }
586
+ function unbreakscape_text2(input, format, location) {
587
+ let deferred4_0;
588
+ let deferred4_1;
589
+ try {
590
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
591
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
592
+ const len0 = WASM_VECTOR_LEN2;
593
+ const ptr1 = passStringToWasm02(format, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
594
+ const len1 = WASM_VECTOR_LEN2;
595
+ const ptr2 = passStringToWasm02(location, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
596
+ const len2 = WASM_VECTOR_LEN2;
597
+ wasm2.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
598
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
599
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
600
+ deferred4_0 = r0;
601
+ deferred4_1 = r1;
602
+ return getStringFromWasm02(r0, r1);
603
+ } finally {
604
+ wasm2.__wbindgen_add_to_stack_pointer(16);
605
+ wasm2.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
606
+ }
607
+ }
608
+ function info2(info_type, format, bit, pretty, indent, include_deprecated, only_deprecated, full) {
609
+ let deferred4_0;
610
+ let deferred4_1;
611
+ try {
612
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
613
+ const ptr0 = passStringToWasm02(info_type, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
614
+ const len0 = WASM_VECTOR_LEN2;
615
+ const ptr1 = passStringToWasm02(format, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
616
+ const len1 = WASM_VECTOR_LEN2;
617
+ const ptr2 = passStringToWasm02(bit, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
618
+ const len2 = WASM_VECTOR_LEN2;
619
+ wasm2.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, include_deprecated, only_deprecated, full);
620
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
621
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
622
+ deferred4_0 = r0;
623
+ deferred4_1 = r1;
624
+ return getStringFromWasm02(r0, r1);
625
+ } finally {
626
+ wasm2.__wbindgen_add_to_stack_pointer(16);
627
+ wasm2.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
628
+ }
629
+ }
630
+ function convert2(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report) {
631
+ let deferred5_0;
632
+ let deferred5_1;
633
+ try {
634
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
635
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
636
+ const len0 = WASM_VECTOR_LEN2;
637
+ const ptr1 = passStringToWasm02(input_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
638
+ const len1 = WASM_VECTOR_LEN2;
639
+ const ptr2 = passStringToWasm02(output_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
640
+ const len2 = WASM_VECTOR_LEN2;
641
+ const ptr3 = passStringToWasm02(mode, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
642
+ const len3 = WASM_VECTOR_LEN2;
643
+ wasm2.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report);
644
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
645
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
646
+ deferred5_0 = r0;
647
+ deferred5_1 = r1;
648
+ return getStringFromWasm02(r0, r1);
649
+ } finally {
650
+ wasm2.__wbindgen_add_to_stack_pointer(16);
651
+ wasm2.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
652
+ }
653
+ }
654
+ function canonicalize2(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
655
+ let deferred4_0;
656
+ let deferred4_1;
657
+ try {
658
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
659
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
660
+ const len0 = WASM_VECTOR_LEN2;
661
+ const ptr1 = passStringToWasm02(input_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
662
+ const len1 = WASM_VECTOR_LEN2;
663
+ const ptr2 = passStringToWasm02(mode, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
664
+ const len2 = WASM_VECTOR_LEN2;
665
+ wasm2.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
666
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
667
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
668
+ deferred4_0 = r0;
669
+ deferred4_1 = r1;
670
+ return getStringFromWasm02(r0, r1);
671
+ } finally {
672
+ wasm2.__wbindgen_add_to_stack_pointer(16);
673
+ wasm2.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
674
+ }
675
+ }
676
+ function count_bits2(input) {
677
+ let deferred2_0;
678
+ let deferred2_1;
679
+ try {
680
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
681
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
682
+ const len0 = WASM_VECTOR_LEN2;
683
+ wasm2.count_bits(retptr, ptr0, len0);
684
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
685
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
686
+ deferred2_0 = r0;
687
+ deferred2_1 = r1;
688
+ return getStringFromWasm02(r0, r1);
689
+ } finally {
690
+ wasm2.__wbindgen_add_to_stack_pointer(16);
691
+ wasm2.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
692
+ }
693
+ }
694
+ function split_bits2(input) {
695
+ let deferred2_0;
696
+ let deferred2_1;
697
+ try {
698
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
699
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
700
+ const len0 = WASM_VECTOR_LEN2;
701
+ wasm2.split_bits(retptr, ptr0, len0);
702
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
703
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
704
+ deferred2_0 = r0;
705
+ deferred2_1 = r1;
706
+ return getStringFromWasm02(r0, r1);
707
+ } finally {
708
+ wasm2.__wbindgen_add_to_stack_pointer(16);
709
+ wasm2.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
710
+ }
711
+ }
712
+ function is_bitmark2(input) {
713
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
714
+ const len0 = WASM_VECTOR_LEN2;
715
+ const ret = wasm2.is_bitmark(ptr0, len0);
716
+ return ret !== 0;
717
+ }
718
+ function split_json_bits2(input) {
719
+ let deferred2_0;
720
+ let deferred2_1;
721
+ try {
722
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
723
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
724
+ const len0 = WASM_VECTOR_LEN2;
725
+ wasm2.split_json_bits(retptr, ptr0, len0);
726
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
727
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
728
+ deferred2_0 = r0;
729
+ deferred2_1 = r1;
730
+ return getStringFromWasm02(r0, r1);
731
+ } finally {
732
+ wasm2.__wbindgen_add_to_stack_pointer(16);
733
+ wasm2.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
734
+ }
735
+ }
736
+ function prettify2(json, indent) {
737
+ let deferred2_0;
738
+ let deferred2_1;
739
+ try {
740
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
741
+ const ptr0 = passStringToWasm02(json, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
742
+ const len0 = WASM_VECTOR_LEN2;
743
+ wasm2.prettify(retptr, ptr0, len0, indent);
744
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
745
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
746
+ deferred2_0 = r0;
747
+ deferred2_1 = r1;
748
+ return getStringFromWasm02(r0, r1);
749
+ } finally {
750
+ wasm2.__wbindgen_add_to_stack_pointer(16);
751
+ wasm2.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
752
+ }
753
+ }
754
+ function convert_text2(input, direction, format, location) {
755
+ let deferred5_0;
756
+ let deferred5_1;
757
+ try {
758
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
759
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
760
+ const len0 = WASM_VECTOR_LEN2;
761
+ const ptr1 = passStringToWasm02(direction, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
762
+ const len1 = WASM_VECTOR_LEN2;
763
+ const ptr2 = passStringToWasm02(format, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
764
+ const len2 = WASM_VECTOR_LEN2;
765
+ const ptr3 = passStringToWasm02(location, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
766
+ const len3 = WASM_VECTOR_LEN2;
767
+ wasm2.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
768
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
769
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
770
+ deferred5_0 = r0;
771
+ deferred5_1 = r1;
772
+ return getStringFromWasm02(r0, r1);
773
+ } finally {
774
+ wasm2.__wbindgen_add_to_stack_pointer(16);
775
+ wasm2.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
776
+ }
777
+ }
778
+ function transform2(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
779
+ let deferred6_0;
780
+ let deferred6_1;
781
+ try {
782
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
783
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
784
+ const len0 = WASM_VECTOR_LEN2;
785
+ const ptr1 = passStringToWasm02(input_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
786
+ const len1 = WASM_VECTOR_LEN2;
787
+ const ptr2 = passStringToWasm02(output_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
788
+ const len2 = WASM_VECTOR_LEN2;
789
+ const ptr3 = passStringToWasm02(mode, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
790
+ const len3 = WASM_VECTOR_LEN2;
791
+ const ptr4 = passStringToWasm02(patch_json, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
792
+ const len4 = WASM_VECTOR_LEN2;
793
+ wasm2.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
794
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
795
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
796
+ deferred6_0 = r0;
797
+ deferred6_1 = r1;
798
+ return getStringFromWasm02(r0, r1);
799
+ } finally {
800
+ wasm2.__wbindgen_add_to_stack_pointer(16);
801
+ wasm2.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
802
+ }
803
+ }
804
+ async function __wbg_load2(module2, imports) {
805
+ if (typeof Response === "function" && module2 instanceof Response) {
806
+ if (typeof WebAssembly.instantiateStreaming === "function") {
807
+ try {
808
+ return await WebAssembly.instantiateStreaming(module2, imports);
809
+ } catch (e) {
810
+ if (module2.headers.get("Content-Type") != "application/wasm") {
811
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
812
+ } else {
813
+ throw e;
814
+ }
815
+ }
816
+ }
817
+ const bytes = await module2.arrayBuffer();
818
+ return await WebAssembly.instantiate(bytes, imports);
819
+ } else {
820
+ const instance = await WebAssembly.instantiate(module2, imports);
821
+ if (instance instanceof WebAssembly.Instance) {
822
+ return { instance, module: module2 };
823
+ } else {
824
+ return instance;
825
+ }
826
+ }
827
+ }
828
+ function __wbg_get_imports2() {
829
+ const imports = {};
830
+ imports.wbg = {};
831
+ return imports;
832
+ }
833
+ function __wbg_init_memory2(imports, memory) {
834
+ }
835
+ function __wbg_finalize_init2(instance, module2) {
836
+ wasm2 = instance.exports;
837
+ __wbg_init2.__wbindgen_wasm_module = module2;
838
+ cachedDataViewMemory02 = null;
839
+ cachedUint8ArrayMemory02 = null;
840
+ return wasm2;
841
+ }
842
+ function initSync2(module2) {
843
+ if (wasm2 !== void 0) return wasm2;
844
+ if (typeof module2 !== "undefined") {
845
+ if (Object.getPrototypeOf(module2) === Object.prototype) {
846
+ ({ module: module2 } = module2);
847
+ } else {
848
+ console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
849
+ }
850
+ }
851
+ const imports = __wbg_get_imports2();
852
+ __wbg_init_memory2(imports);
853
+ if (!(module2 instanceof WebAssembly.Module)) {
854
+ module2 = new WebAssembly.Module(module2);
855
+ }
856
+ const instance = new WebAssembly.Instance(module2, imports);
857
+ return __wbg_finalize_init2(instance, module2);
858
+ }
859
+ async function __wbg_init2(module_or_path) {
860
+ if (wasm2 !== void 0) return wasm2;
861
+ if (typeof module_or_path !== "undefined") {
862
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
863
+ ({ module_or_path } = module_or_path);
864
+ } else {
865
+ console.warn("using deprecated parameters for the initialization function; pass a single object instead");
866
+ }
867
+ }
868
+ if (typeof module_or_path === "undefined") {
869
+ module_or_path = new URL("bitmark_json_wasm_bg.wasm", importMetaUrl);
870
+ }
871
+ const imports = __wbg_get_imports2();
872
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
873
+ module_or_path = fetch(module_or_path);
874
+ }
875
+ __wbg_init_memory2(imports);
876
+ const { instance, module: module2 } = await __wbg_load2(await module_or_path, imports);
877
+ return __wbg_finalize_init2(instance, module2);
878
+ }
879
+ var bitmark_json_wasm_default = __wbg_init2;
880
+
474
881
  // src/generated/package_info.ts
475
882
  var PACKAGE_INFO = {
476
883
  "name": "@gmb/bitmark-parser",
477
- "version": "6.8.0",
884
+ "version": "6.10.0",
478
885
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
479
886
  "license": "ISC",
480
887
  "description": "A parser for bitmark text, powered by WebAssembly."
481
888
  };
482
889
 
890
+ // src/core/facade.ts
891
+ var NotInitializedError = class extends Error {
892
+ constructor() {
893
+ super("wasm not initialised: call init() (or init({ feature: \u2026 })) first");
894
+ this.name = "NotInitializedError";
895
+ }
896
+ };
897
+ var UnsupportedFeatureError = class extends Error {
898
+ constructor(what, active2) {
899
+ super(
900
+ `${what} is not available in the loaded wasm module${active2 ? ` (feature: "${active2}")` : ""}; init({ feature: "full" }) to load it`
901
+ );
902
+ this.name = "UnsupportedFeatureError";
903
+ }
904
+ };
905
+ var active;
906
+ var activeFeature;
907
+ var lazyLoader;
908
+ function getActive() {
909
+ if (!active && lazyLoader) lazyLoader();
910
+ if (!active) throw new NotInitializedError();
911
+ return active;
912
+ }
913
+ function setActive(feature, module2) {
914
+ active = module2;
915
+ activeFeature = feature;
916
+ }
917
+ function variant() {
918
+ return activeFeature;
919
+ }
920
+
483
921
  // src/core/hooked-transform.ts
484
922
  function isError(s) {
485
923
  return s.startsWith("error:");
@@ -500,9 +938,9 @@ function normalisePatch(patch) {
500
938
  }
501
939
  return patch;
502
940
  }
503
- function buildUnits(wasm2, input, inputIsBitmark) {
941
+ function buildUnits(wasm3, input, inputIsBitmark) {
504
942
  if (inputIsBitmark) {
505
- const out2 = wasm2.split_bits(input);
943
+ const out2 = wasm3.split_bits(input);
506
944
  if (isError(out2)) throw new Error(out2);
507
945
  const slices = JSON.parse(out2);
508
946
  return slices.map((s) => ({
@@ -510,7 +948,7 @@ function buildUnits(wasm2, input, inputIsBitmark) {
510
948
  source: s.source
511
949
  }));
512
950
  }
513
- const out = wasm2.split_json_bits(input);
951
+ const out = wasm3.split_json_bits(input);
514
952
  if (isError(out)) throw new Error(out);
515
953
  const envelopes = JSON.parse(out);
516
954
  return envelopes.map((env, index) => ({
@@ -519,17 +957,17 @@ function buildUnits(wasm2, input, inputIsBitmark) {
519
957
  source: JSON.stringify([env])
520
958
  }));
521
959
  }
522
- function planTransform(wasm2, input, options) {
960
+ function planTransform(wasm3, input, options) {
523
961
  const mode = options.mode ?? "optimized";
524
962
  const output = options.outputFormat ?? "json";
525
963
  const spacesAroundValues = options.spacesAroundValues ?? 1;
526
964
  const indent = options.indent ?? 2;
527
965
  const pretty = options.pretty ?? false;
528
966
  const sel = options.inputFormat ?? "auto";
529
- const inputIsBitmark = sel === "bitmark" || sel !== "json" && wasm2.is_bitmark(input);
967
+ const inputIsBitmark = sel === "bitmark" || sel !== "json" && wasm3.is_bitmark(input);
530
968
  const inputFormat = inputIsBitmark ? "bitmark" : "json";
531
969
  const staticPatch = normalisePatch(options.patch);
532
- const units = buildUnits(wasm2, input, inputIsBitmark);
970
+ const units = buildUnits(wasm3, input, inputIsBitmark);
533
971
  const total = units.length;
534
972
  const jobs = [];
535
973
  const views = [];
@@ -553,8 +991,8 @@ function planTransform(wasm2, input, options) {
553
991
  }
554
992
  return { jobs, views, output, pretty, indent };
555
993
  }
556
- function computeBit(wasm2, job) {
557
- const out = wasm2.transform(
994
+ function computeBit(wasm3, job) {
995
+ const out = wasm3.transform(
558
996
  job.source,
559
997
  job.inputFormat,
560
998
  job.outputFormat,
@@ -567,33 +1005,33 @@ function computeBit(wasm2, job) {
567
1005
  if (isError(out)) return out;
568
1006
  return job.outputFormat === "json" ? stripArray(out) : out;
569
1007
  }
570
- function recombine(wasm2, elements, output, pretty, indent) {
1008
+ function recombine(wasm3, elements, output, pretty, indent) {
571
1009
  if (output === "bitmark" || output === "text") return elements.join("\n");
572
1010
  const arr = `[${elements.join(",")}]`;
573
- return pretty ? wasm2.prettify(arr, indent) : arr;
1011
+ return pretty ? wasm3.prettify(arr, indent) : arr;
574
1012
  }
575
- function runHookedTransform(wasm2, input, options) {
1013
+ function runHookedTransform(wasm3, input, options) {
576
1014
  let plan;
577
1015
  try {
578
- plan = planTransform(wasm2, input, options);
1016
+ plan = planTransform(wasm3, input, options);
579
1017
  } catch (e) {
580
1018
  return errorString(e);
581
1019
  }
582
1020
  const rendered = [];
583
1021
  for (let i = 0; i < plan.jobs.length; i++) {
584
- const element = computeBit(wasm2, plan.jobs[i]);
1022
+ const element = computeBit(wasm3, plan.jobs[i]);
585
1023
  if (isError(element)) return element;
586
1024
  options.postHook?.(plan.views[i], element);
587
1025
  rendered.push(element);
588
1026
  }
589
- return recombine(wasm2, rendered, plan.output, plan.pretty, plan.indent);
1027
+ return recombine(wasm3, rendered, plan.output, plan.pretty, plan.indent);
590
1028
  }
591
1029
 
592
1030
  // src/core/parallel.ts
593
- async function orchestrateParallel(wasm2, input, options, runJobs) {
1031
+ async function orchestrateParallel(wasm3, input, options, runJobs) {
594
1032
  let plan;
595
1033
  try {
596
- plan = planTransform(wasm2, input, options);
1034
+ plan = planTransform(wasm3, input, options);
597
1035
  } catch (e) {
598
1036
  return errorString(e);
599
1037
  }
@@ -607,11 +1045,29 @@ async function orchestrateParallel(wasm2, input, options, runJobs) {
607
1045
  if (isError(elements[i])) return elements[i];
608
1046
  options.postHook?.(plan.views[i], elements[i]);
609
1047
  }
610
- return recombine(wasm2, elements, plan.output, plan.pretty, plan.indent);
1048
+ return recombine(wasm3, elements, plan.output, plan.pretty, plan.indent);
1049
+ }
1050
+
1051
+ // src/legacy/runtime.ts
1052
+ var wasmProvider;
1053
+ function setLegacyWasmProvider(provider) {
1054
+ wasmProvider = provider;
1055
+ }
1056
+ function getLegacyWasm() {
1057
+ if (!wasmProvider) {
1058
+ throw new Error(
1059
+ "legacy API not initialised: the WASM module has not been provided (browser consumers must call init() first)"
1060
+ );
1061
+ }
1062
+ return wasmProvider();
1063
+ }
1064
+ var fileIo;
1065
+ function getLegacyFileIo() {
1066
+ return fileIo;
611
1067
  }
612
1068
 
613
1069
  // src/browser/pool.ts
614
- function runJobsParallel(jobs, workers) {
1070
+ function runJobsParallel(jobs, workers, feature) {
615
1071
  if (jobs.length === 0) return Promise.resolve([]);
616
1072
  const poolSize = Math.max(1, Math.min(workers, jobs.length));
617
1073
  const workerUrl = new URL("./worker-entry.js", importMetaUrl);
@@ -633,7 +1089,7 @@ function runJobsParallel(jobs, workers) {
633
1089
  const dispatch = (w) => {
634
1090
  if (done || next >= jobs.length) return;
635
1091
  const id = next++;
636
- w.postMessage({ id, job: jobs[id] });
1092
+ w.postMessage({ id, job: jobs[id], feature });
637
1093
  };
638
1094
  for (let i = 0; i < poolSize; i++) {
639
1095
  const w = new Worker(workerUrl, { type: "module" });
@@ -661,24 +1117,6 @@ function runJobsParallel(jobs, workers) {
661
1117
  });
662
1118
  }
663
1119
 
664
- // src/legacy/runtime.ts
665
- var wasmModule;
666
- function setLegacyWasm(wasm2) {
667
- wasmModule = wasm2;
668
- }
669
- function getLegacyWasm() {
670
- if (!wasmModule) {
671
- throw new Error(
672
- "legacy API not initialised: the WASM module has not been provided (browser consumers must call init() first)"
673
- );
674
- }
675
- return wasmModule;
676
- }
677
- var fileIo;
678
- function getLegacyFileIo() {
679
- return fileIo;
680
- }
681
-
682
1120
  // src/legacy/index.ts
683
1121
  var legacy_exports = {};
684
1122
  __export(legacy_exports, {
@@ -754,9 +1192,9 @@ function validateJsonOptions(o) {
754
1192
  if (o.textAsPlainText) unsupportedOption("jsonOptions.textAsPlainText", V3_ONLY);
755
1193
  if (o.debugGenerationInline) unsupportedOption("jsonOptions.debugGenerationInline");
756
1194
  }
757
- function prettyIndent(prettify2) {
758
- if (prettify2 === true) return { pretty: true, indent: 2 };
759
- if (typeof prettify2 === "number" && prettify2 > 0) return { pretty: true, indent: prettify2 };
1195
+ function prettyIndent(prettify3) {
1196
+ if (prettify3 === true) return { pretty: true, indent: 2 };
1197
+ if (typeof prettify3 === "number" && prettify3 > 0) return { pretty: true, indent: prettify3 };
760
1198
  return { pretty: false, indent: 2 };
761
1199
  }
762
1200
  function spacesAround(v) {
@@ -856,7 +1294,7 @@ var Builder = class {
856
1294
  * more than one resource, use the first one").
857
1295
  */
858
1296
  buildBit(data, _options) {
859
- const wasm2 = getLegacyWasm();
1297
+ const wasm3 = getLegacyWasm();
860
1298
  const src = { ...data };
861
1299
  const bitType = src.bitType;
862
1300
  const bitConfig = this.getBitConfig(bitType);
@@ -917,7 +1355,7 @@ var Builder = class {
917
1355
  }
918
1356
  }
919
1357
  this.parseStringTexts(bit);
920
- const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false, false);
1358
+ const out = wasm3.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false, false);
921
1359
  if (out.startsWith("error:")) {
922
1360
  throw new Error(out.slice("error:".length).trim());
923
1361
  }
@@ -973,10 +1411,10 @@ var Builder = class {
973
1411
  * (bpg TextParser.toAst ignores format; only location matters).
974
1412
  */
975
1413
  parseStringTexts(bit) {
976
- const wasm2 = getLegacyWasm();
1414
+ const wasm3 = getLegacyWasm();
977
1415
  const toAst = (s, location) => {
978
1416
  if (s === "") return s;
979
- const out = wasm2.convert_text(s, "textToAst", "bitmark++", location);
1417
+ const out = wasm3.convert_text(s, "textToAst", "bitmark++", location);
980
1418
  try {
981
1419
  return JSON.parse(out);
982
1420
  } catch {
@@ -1006,11 +1444,11 @@ var Builder = class {
1006
1444
  * unknown-bit-type error (`Config.getBitConfig` parity).
1007
1445
  */
1008
1446
  getBitConfig(bitType) {
1009
- const wasm2 = getLegacyWasm();
1447
+ const wasm3 = getLegacyWasm();
1010
1448
  if (bitType !== void 0) {
1011
1449
  try {
1012
- const info3 = JSON.parse(wasm2.info("bit", "json", bitType, false, 2));
1013
- if (info3.error === void 0) return info3;
1450
+ const info4 = JSON.parse(wasm3.info("bit", "json", bitType, false, 2, false, false, true));
1451
+ if (info4.error === void 0) return { bodyFormat: info4.body?.format };
1014
1452
  } catch {
1015
1453
  }
1016
1454
  }
@@ -1049,7 +1487,7 @@ var BitmarkParserGenerator = class {
1049
1487
  validateBitmarkOptions(bitmarkOptions);
1050
1488
  validateJsonOptions(jsonOptions);
1051
1489
  this.checkBrowserFileWrite(opts.outputFile);
1052
- const wasm2 = getLegacyWasm();
1490
+ const wasm3 = getLegacyWasm();
1053
1491
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1054
1492
  const outputFormat = opts.outputFormat ?? (isBitmark ? "json" : "bitmark");
1055
1493
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
@@ -1057,7 +1495,7 @@ var BitmarkParserGenerator = class {
1057
1495
  const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
1058
1496
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1059
1497
  const includeUnknown = !jsonOptions.excludeUnknownProperties;
1060
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown, false);
1498
+ const out = wasm3.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown, false);
1061
1499
  this.throwOnError(out);
1062
1500
  if (outputFormat === "bitmark" || outputFormat === "text") {
1063
1501
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1085,13 +1523,13 @@ var BitmarkParserGenerator = class {
1085
1523
  validateBitmarkOptions(bitmarkOptions);
1086
1524
  validateJsonOptions(jsonOptions);
1087
1525
  this.checkBrowserFileWrite(opts.outputFile);
1088
- const wasm2 = getLegacyWasm();
1526
+ const wasm3 = getLegacyWasm();
1089
1527
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1090
1528
  const { pretty, indent } = prettyIndent(
1091
1529
  isBitmark ? bitmarkOptions.prettifyJson : jsonOptions.prettify
1092
1530
  );
1093
1531
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1094
- const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
1532
+ const out = wasm3.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
1095
1533
  this.throwOnError(out);
1096
1534
  if (isBitmark) return this.deliver(out, opts.outputFile, opts.fileOptions);
1097
1535
  if (opts.outputFile) return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1103,12 +1541,12 @@ var BitmarkParserGenerator = class {
1103
1541
  */
1104
1542
  info(options) {
1105
1543
  const opts = Object.assign({}, options);
1106
- const wasm2 = getLegacyWasm();
1544
+ const wasm3 = getLegacyWasm();
1107
1545
  const type = opts.type ?? "list";
1108
1546
  const format = opts.outputFormat ?? "text";
1109
1547
  const { pretty, indent } = prettyIndent(opts.prettify);
1110
1548
  const coreFormat = format === "pojo" ? "json" : format;
1111
- const out = wasm2.info(type, coreFormat, opts.bit ?? "", pretty, indent);
1549
+ const out = wasm3.info(type, coreFormat, opts.bit ?? "", pretty, indent, false, false, true);
1112
1550
  this.throwOnError(out);
1113
1551
  if (format === "pojo") return JSON.parse(out);
1114
1552
  return out;
@@ -1136,12 +1574,12 @@ var BitmarkParserGenerator = class {
1136
1574
  if (opts.keepUnknownTags) unsupportedOption("keepUnknownTags");
1137
1575
  if (opts.noBreakscaping) unsupportedOption("noBreakscaping");
1138
1576
  this.checkBrowserFileWrite(opts.outputFile);
1139
- const wasm2 = getLegacyWasm();
1577
+ const wasm3 = getLegacyWasm();
1140
1578
  const inStr = typeof input === "string" ? this.maybeReadFile(input, void 0) : "";
1141
1579
  const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
1142
1580
  if (!isHtmlInput) {
1143
1581
  const { source, isBitmark } = this.resolveInput(input, void 0);
1144
- const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false, false);
1582
+ const out2 = wasm3.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false, false);
1145
1583
  this.throwOnError(out2);
1146
1584
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
1147
1585
  }
@@ -1151,12 +1589,12 @@ var BitmarkParserGenerator = class {
1151
1589
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1152
1590
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1153
1591
  if (outputFormat === "html") {
1154
- const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false, false);
1592
+ const out2 = wasm3.convert(wrapped, "html", "html", "optimized", false, 2, 1, false, false);
1155
1593
  this.throwOnError(out2);
1156
1594
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
1157
1595
  }
1158
1596
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
1159
- const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false, false);
1597
+ const out = wasm3.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false, false);
1160
1598
  this.throwOnError(out);
1161
1599
  if (outputFormat === "bitmark" || outputFormat === "text") {
1162
1600
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1179,9 +1617,9 @@ var BitmarkParserGenerator = class {
1179
1617
  */
1180
1618
  createAst(input, options) {
1181
1619
  const opts = Object.assign({}, options);
1182
- const wasm2 = getLegacyWasm();
1620
+ const wasm3 = getLegacyWasm();
1183
1621
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1184
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true, false);
1622
+ const out = wasm3.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true, false);
1185
1623
  this.throwOnError(out);
1186
1624
  return makePseudoAst(JSON.parse(out));
1187
1625
  }
@@ -1192,9 +1630,9 @@ var BitmarkParserGenerator = class {
1192
1630
  if (!input) return input;
1193
1631
  const opts = Object.assign({}, options);
1194
1632
  this.checkBrowserFileWrite(opts.outputFile);
1195
- const wasm2 = getLegacyWasm();
1633
+ const wasm3 = getLegacyWasm();
1196
1634
  const inStr = this.maybeReadFile(input, opts.inputFormat);
1197
- const res = wasm2.breakscape_text(inStr, mapTextFormat(opts.textFormat), opts.textLocation ?? "body");
1635
+ const res = wasm3.breakscape_text(inStr, mapTextFormat(opts.textFormat), opts.textLocation ?? "body");
1198
1636
  return this.deliver(res, opts.outputFile, opts.fileOptions);
1199
1637
  }
1200
1638
  /**
@@ -1204,9 +1642,9 @@ var BitmarkParserGenerator = class {
1204
1642
  if (!input) return input;
1205
1643
  const opts = Object.assign({}, options);
1206
1644
  this.checkBrowserFileWrite(opts.outputFile);
1207
- const wasm2 = getLegacyWasm();
1645
+ const wasm3 = getLegacyWasm();
1208
1646
  const inStr = this.maybeReadFile(input, opts.inputFormat);
1209
- const res = wasm2.unbreakscape_text(inStr, mapTextFormat(opts.textFormat), opts.textLocation ?? "body");
1647
+ const res = wasm3.unbreakscape_text(inStr, mapTextFormat(opts.textFormat), opts.textLocation ?? "body");
1210
1648
  return this.deliver(res, opts.outputFile, opts.fileOptions);
1211
1649
  }
1212
1650
  /**
@@ -1220,7 +1658,7 @@ var BitmarkParserGenerator = class {
1220
1658
  const opts = Object.assign({}, options);
1221
1659
  const jsonOptions = Object.assign({}, opts.jsonOptions);
1222
1660
  this.checkBrowserFileWrite(opts.outputFile);
1223
- const wasm2 = getLegacyWasm();
1661
+ const wasm3 = getLegacyWasm();
1224
1662
  const isBitmarkText = opts.textFormat === void 0 || mapTextFormat(opts.textFormat) === "bitmark++";
1225
1663
  const textLocation = opts.textLocation ?? "body";
1226
1664
  let inStr;
@@ -1233,14 +1671,14 @@ var BitmarkParserGenerator = class {
1233
1671
  ast = Array.isArray(input) ? input : void 0;
1234
1672
  }
1235
1673
  if (ast !== void 0) {
1236
- const out2 = isBitmarkText ? wasm2.convert_text(JSON.stringify(ast), "astToText", "bitmark++", textLocation) : wasm2.convert_text(JSON.stringify(ast), "astToPlainText", "plainText", textLocation);
1674
+ const out2 = isBitmarkText ? wasm3.convert_text(JSON.stringify(ast), "astToText", "bitmark++", textLocation) : wasm3.convert_text(JSON.stringify(ast), "astToPlainText", "plainText", textLocation);
1237
1675
  this.throwOnError(out2);
1238
1676
  return this.deliver(out2, opts.outputFile, opts.fileOptions);
1239
1677
  }
1240
- const out = wasm2.convert_text(inStr, "textToAst", isBitmarkText ? "bitmark++" : "plainText", "body");
1678
+ const out = wasm3.convert_text(inStr, "textToAst", isBitmarkText ? "bitmark++" : "plainText", "body");
1241
1679
  this.throwOnError(out);
1242
1680
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1243
- const outStr = pretty ? wasm2.prettify(out, indent) : out;
1681
+ const outStr = pretty ? wasm3.prettify(out, indent) : out;
1244
1682
  if (opts.outputFile) return this.deliver(outStr, opts.outputFile, opts.fileOptions);
1245
1683
  if (pretty) return outStr;
1246
1684
  return JSON.parse(out);
@@ -1249,8 +1687,8 @@ var BitmarkParserGenerator = class {
1249
1687
  * Convert a text AST to plain text (bpg-compatible `textAstToPlainText`).
1250
1688
  */
1251
1689
  textAstToPlainText(textAst, _options) {
1252
- const wasm2 = getLegacyWasm();
1253
- const out = wasm2.convert_text(
1690
+ const wasm3 = getLegacyWasm();
1691
+ const out = wasm3.convert_text(
1254
1692
  typeof textAst === "string" ? textAst : JSON.stringify(textAst),
1255
1693
  "astToPlainText",
1256
1694
  "bitmark++",
@@ -1264,17 +1702,17 @@ var BitmarkParserGenerator = class {
1264
1702
  */
1265
1703
  extractPlainText(input, options) {
1266
1704
  const inputFormat = options?.inputFormat;
1267
- const wasm2 = getLegacyWasm();
1705
+ const wasm3 = getLegacyWasm();
1268
1706
  if (inputFormat === "plainText") {
1269
1707
  return typeof input === "string" ? String(input) : "";
1270
1708
  }
1271
1709
  if (inputFormat === "bitmarkText") {
1272
- const ast = wasm2.convert_text(String(input), "textToAst", "bitmark++", "body");
1273
- const out2 = wasm2.convert_text(ast, "astToPlainText", "bitmark++", "body");
1710
+ const ast = wasm3.convert_text(String(input), "textToAst", "bitmark++", "body");
1711
+ const out2 = wasm3.convert_text(ast, "astToPlainText", "bitmark++", "body");
1274
1712
  this.throwOnError(out2);
1275
1713
  return out2;
1276
1714
  }
1277
- if (typeof input === "string" && this.parseTextAstString(input) === void 0 && !wasm2.is_bitmark(input)) {
1715
+ if (typeof input === "string" && this.parseTextAstString(input) === void 0 && !wasm3.is_bitmark(input)) {
1278
1716
  const looksJson = (() => {
1279
1717
  try {
1280
1718
  JSON.parse(input);
@@ -1288,7 +1726,7 @@ var BitmarkParserGenerator = class {
1288
1726
  }
1289
1727
  }
1290
1728
  const { source, isBitmark } = this.resolveInput(input, void 0);
1291
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false, false);
1729
+ const out = wasm3.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false, false);
1292
1730
  this.throwOnError(out);
1293
1731
  return out;
1294
1732
  }
@@ -1322,8 +1760,8 @@ var BitmarkParserGenerator = class {
1322
1760
  };
1323
1761
  }
1324
1762
  const inStr = this.maybeReadFile(input, inputFormat);
1325
- const wasm2 = getLegacyWasm();
1326
- if (wasm2.is_bitmark(inStr)) return { source: inStr, isBitmark: true };
1763
+ const wasm3 = getLegacyWasm();
1764
+ if (wasm3.is_bitmark(inStr)) return { source: inStr, isBitmark: true };
1327
1765
  try {
1328
1766
  const parsed = JSON.parse(inStr);
1329
1767
  const entries = this.jsonEntries(parsed);
@@ -1692,8 +2130,8 @@ function bitNameToKey(name) {
1692
2130
  var bitTypeCache;
1693
2131
  function loadBitTypes() {
1694
2132
  if (!bitTypeCache) {
1695
- const wasm2 = getLegacyWasm();
1696
- const all = JSON.parse(wasm2.info("all", "json", "", false, 2));
2133
+ const wasm3 = getLegacyWasm();
2134
+ const all = JSON.parse(wasm3.info("all", "json", "", false, 2, true, false, false));
1697
2135
  const map = { _standard: "_standard" };
1698
2136
  for (const { name } of all) {
1699
2137
  map[bitNameToKey(name)] = name;
@@ -1765,22 +2203,14 @@ function patchEntry(path, op, value) {
1765
2203
  return value === void 0 ? { path, op } : { path, op, value };
1766
2204
  }
1767
2205
 
1768
- // src/browser/index.ts
1769
- setLegacyWasm(bitmark_wasm_exports);
1770
- async function init(module_or_path) {
1771
- if (typeof module_or_path === "undefined") {
1772
- module_or_path = new URL(`bitmark_wasm_bg.wasm?v=${PACKAGE_INFO.version}`, importMetaUrl);
1773
- }
1774
- return bitmark_wasm_default(module_or_path);
1775
- }
1776
- function version() {
1777
- return PACKAGE_INFO.version;
1778
- }
2206
+ // src/core/api.ts
1779
2207
  function lex2(input, options = {}) {
1780
- return lex(input, options.stage ?? "lex");
2208
+ const wasm3 = getActive();
2209
+ if (typeof wasm3.lex !== "function") throw new UnsupportedFeatureError("lex", variant());
2210
+ return wasm3.lex(input, options.stage ?? "lex");
1781
2211
  }
1782
2212
  function bitmarkToObjects(input, options = {}) {
1783
- const out = convert(
2213
+ const out = getActive().convert(
1784
2214
  input,
1785
2215
  "bitmark",
1786
2216
  "json",
@@ -1798,7 +2228,7 @@ function objectsToBitmark(bits, options = {}) {
1798
2228
  const entries = bits.map(
1799
2229
  (b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
1800
2230
  );
1801
- const out = convert(
2231
+ const out = getActive().convert(
1802
2232
  JSON.stringify(entries),
1803
2233
  "json",
1804
2234
  "bitmark",
@@ -1812,8 +2242,8 @@ function objectsToBitmark(bits, options = {}) {
1812
2242
  if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1813
2243
  return out;
1814
2244
  }
1815
- function convert2(input, options = {}) {
1816
- return convert(
2245
+ function convert3(input, options = {}) {
2246
+ return getActive().convert(
1817
2247
  input,
1818
2248
  options.inputFormat ?? "auto",
1819
2249
  options.outputFormat ?? "auto",
@@ -1825,8 +2255,8 @@ function convert2(input, options = {}) {
1825
2255
  options.mappingReport ?? false
1826
2256
  );
1827
2257
  }
1828
- function canonicalize2(input, options = {}) {
1829
- return canonicalize(
2258
+ function canonicalize3(input, options = {}) {
2259
+ return getActive().canonicalize(
1830
2260
  input,
1831
2261
  options.inputFormat ?? "auto",
1832
2262
  options.mode ?? "optimized",
@@ -1836,19 +2266,20 @@ function canonicalize2(input, options = {}) {
1836
2266
  );
1837
2267
  }
1838
2268
  function countBits(input) {
1839
- const out = count_bits(input);
2269
+ const out = getActive().count_bits(input);
1840
2270
  if (out.startsWith("error:")) throw new Error(out);
1841
2271
  return Number.parseInt(out, 10);
1842
2272
  }
1843
2273
  function splitBits(input) {
1844
- return JSON.parse(split_bits(input));
2274
+ return JSON.parse(getActive().split_bits(input));
1845
2275
  }
1846
- function transform2(input, options = {}) {
2276
+ function transform3(input, options = {}) {
2277
+ const wasm3 = getActive();
1847
2278
  if (options.preHook || options.postHook) {
1848
- return runHookedTransform(bitmark_wasm_exports, input, options);
2279
+ return runHookedTransform(wasm3, input, options);
1849
2280
  }
1850
2281
  const patchJson = options.patch === void 0 ? "" : typeof options.patch === "string" ? options.patch : JSON.stringify(options.patch);
1851
- return transform(
2282
+ return wasm3.transform(
1852
2283
  input,
1853
2284
  options.inputFormat ?? "auto",
1854
2285
  options.outputFormat ?? "json",
@@ -1859,29 +2290,105 @@ function transform2(input, options = {}) {
1859
2290
  options.spacesAroundValues ?? 1
1860
2291
  );
1861
2292
  }
1862
- function transformParallel(input, options = {}) {
1863
- return orchestrateParallel(bitmark_wasm_exports, input, options, runJobsParallel);
1864
- }
1865
2293
  function breakscapeText(input, options = {}) {
1866
2294
  const format = options.format ?? "bitmark++";
1867
2295
  const location = options.location ?? "body";
1868
- return breakscape_text(input, format, location);
2296
+ return getActive().breakscape_text(input, format, location);
1869
2297
  }
1870
2298
  function unbreakscapeText(input, options = {}) {
1871
2299
  const format = options.format ?? "bitmark++";
1872
2300
  const location = options.location ?? "body";
1873
- return unbreakscape_text(input, format, location);
2301
+ return getActive().unbreakscape_text(input, format, location);
1874
2302
  }
1875
- function info2(options = {}) {
2303
+ function info3(options = {}) {
1876
2304
  const infoType = options.infoType ?? "list";
1877
2305
  const format = options.format ?? "text";
1878
2306
  const bit = options.bit ?? "";
1879
2307
  const pretty = options.pretty ?? false;
1880
2308
  const indent = options.indent ?? 2;
1881
- return info(infoType, format, bit, pretty, indent);
2309
+ const includeDeprecated = options.includeDeprecated ?? false;
2310
+ const onlyDeprecated = options.onlyDeprecated ?? false;
2311
+ const full = options.full ?? false;
2312
+ return getActive().info(infoType, format, bit, pretty, indent, includeDeprecated, onlyDeprecated, full);
2313
+ }
2314
+
2315
+ // src/browser/index.ts
2316
+ var VARIANTS = {
2317
+ full: {
2318
+ init: bitmark_wasm_default,
2319
+ initSync,
2320
+ ns: bitmark_wasm_exports,
2321
+ wasmFile: "bitmark_wasm_bg.wasm"
2322
+ },
2323
+ "bitmark-json": {
2324
+ init: bitmark_json_wasm_default,
2325
+ initSync: initSync2,
2326
+ ns: bitmark_json_wasm_exports,
2327
+ wasmFile: "bitmark_json_wasm_bg.wasm"
2328
+ }
2329
+ };
2330
+ setLegacyWasmProvider(() => getActive());
2331
+ function normalizeInit(arg) {
2332
+ if (arg !== null && typeof arg === "object" && !(arg instanceof URL) && ("feature" in arg || "module_or_path" in arg)) {
2333
+ const o = arg;
2334
+ return { feature: o.feature ?? "full", module_or_path: o.module_or_path };
2335
+ }
2336
+ return { feature: "full", module_or_path: arg ?? void 0 };
2337
+ }
2338
+ var initSeq = 0;
2339
+ var activeOut;
2340
+ var inflight;
2341
+ async function init(options) {
2342
+ const { feature, module_or_path } = normalizeInit(options);
2343
+ if (module_or_path === void 0) {
2344
+ if (!inflight && variant() === feature) return activeOut;
2345
+ if (inflight?.feature === feature) return inflight.promise;
2346
+ }
2347
+ const mySeq = ++initSeq;
2348
+ const v = VARIANTS[feature];
2349
+ const source = module_or_path ?? new URL(`${v.wasmFile}?v=${PACKAGE_INFO.version}`, importMetaUrl);
2350
+ const promise = (async () => {
2351
+ try {
2352
+ const out = await v.init(source);
2353
+ if (mySeq === initSeq) {
2354
+ setActive(feature, v.ns);
2355
+ activeOut = out;
2356
+ }
2357
+ } finally {
2358
+ if (inflight?.seq === mySeq) inflight = void 0;
2359
+ }
2360
+ while (inflight) await inflight.promise.catch(() => {
2361
+ });
2362
+ return activeOut;
2363
+ })();
2364
+ inflight = { feature, seq: mySeq, promise };
2365
+ return promise;
2366
+ }
2367
+ function initSync3(module2, options = {}) {
2368
+ const feature = options.feature ?? "full";
2369
+ const v = VARIANTS[feature];
2370
+ const out = v.initSync(module2);
2371
+ setActive(feature, v.ns);
2372
+ activeOut = out;
2373
+ return out;
2374
+ }
2375
+ function version() {
2376
+ return PACKAGE_INFO.version;
2377
+ }
2378
+ function transformParallel(input, options = {}) {
2379
+ const wasm3 = getActive();
2380
+ const feature = variant() ?? "full";
2381
+ return orchestrateParallel(
2382
+ wasm3,
2383
+ input,
2384
+ options,
2385
+ (jobs, workers) => runJobsParallel(jobs, workers, feature)
2386
+ );
1882
2387
  }
1883
2388
  // Annotate the CommonJS export names for ESM import in node:
1884
2389
  0 && (module.exports = {
2390
+ NotInitializedError,
2391
+ UnsupportedFeatureError,
1885
2392
  bitmarkToObjects,
1886
2393
  breakscapeText,
1887
2394
  canonicalize,
@@ -1898,6 +2405,7 @@ function info2(options = {}) {
1898
2405
  transform,
1899
2406
  transformParallel,
1900
2407
  unbreakscapeText,
2408
+ variant,
1901
2409
  version
1902
2410
  });
1903
2411
  //# sourceMappingURL=index.cjs.map