@gmb/bitmark-parser 6.9.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 (38) hide show
  1. package/README.md +55 -3
  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 +619 -114
  9. package/dist/browser/cjs/index.cjs.map +1 -1
  10. package/dist/browser/cjs/index.d.cts +2432 -3280
  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 +2432 -3280
  14. package/dist/browser/esm/index.js +616 -114
  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 +154 -85
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +81 -968
  21. package/dist/index.d.ts +81 -968
  22. package/dist/index.js +149 -85
  23. package/dist/index.js.map +1 -1
  24. package/dist/legacy.cjs +9 -9
  25. package/dist/legacy.cjs.map +1 -1
  26. package/dist/legacy.js +9 -9
  27. package/dist/legacy.js.map +1 -1
  28. package/dist/worker-entry.cjs +6 -1
  29. package/dist/worker-entry.cjs.map +1 -1
  30. package/package.json +8 -7
  31. package/schema/bitmark.schema.json +823 -4064
  32. package/wasm/bitmark_wasm_bg.wasm +0 -0
  33. package/wasm/package.json +1 -1
  34. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +99 -0
  35. package/wasm-bitmark-json/bitmark_json_wasm.js +491 -0
  36. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  37. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +19 -0
  38. package/wasm-bitmark-json/package.json +20 -0
@@ -431,15 +431,450 @@ async function __wbg_init(module_or_path) {
431
431
  }
432
432
  var bitmark_wasm_default = __wbg_init;
433
433
 
434
+ // wasm-web-bitmark-json/bitmark_json_wasm.js
435
+ var bitmark_json_wasm_exports = {};
436
+ __export(bitmark_json_wasm_exports, {
437
+ breakscape_text: () => breakscape_text2,
438
+ canonicalize: () => canonicalize2,
439
+ convert: () => convert2,
440
+ convert_text: () => convert_text2,
441
+ count_bits: () => count_bits2,
442
+ default: () => bitmark_json_wasm_default,
443
+ info: () => info2,
444
+ initSync: () => initSync2,
445
+ is_bitmark: () => is_bitmark2,
446
+ prettify: () => prettify2,
447
+ split_bits: () => split_bits2,
448
+ split_json_bits: () => split_json_bits2,
449
+ transform: () => transform2,
450
+ unbreakscape_text: () => unbreakscape_text2
451
+ });
452
+ var wasm2;
453
+ var WASM_VECTOR_LEN2 = 0;
454
+ var cachedUint8ArrayMemory02 = null;
455
+ function getUint8ArrayMemory02() {
456
+ if (cachedUint8ArrayMemory02 === null || cachedUint8ArrayMemory02.byteLength === 0) {
457
+ cachedUint8ArrayMemory02 = new Uint8Array(wasm2.memory.buffer);
458
+ }
459
+ return cachedUint8ArrayMemory02;
460
+ }
461
+ var cachedTextEncoder2 = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
462
+ throw Error("TextEncoder not available");
463
+ } };
464
+ var encodeString2 = typeof cachedTextEncoder2.encodeInto === "function" ? function(arg, view) {
465
+ return cachedTextEncoder2.encodeInto(arg, view);
466
+ } : function(arg, view) {
467
+ const buf = cachedTextEncoder2.encode(arg);
468
+ view.set(buf);
469
+ return {
470
+ read: arg.length,
471
+ written: buf.length
472
+ };
473
+ };
474
+ function passStringToWasm02(arg, malloc, realloc) {
475
+ if (realloc === void 0) {
476
+ const buf = cachedTextEncoder2.encode(arg);
477
+ const ptr2 = malloc(buf.length, 1) >>> 0;
478
+ getUint8ArrayMemory02().subarray(ptr2, ptr2 + buf.length).set(buf);
479
+ WASM_VECTOR_LEN2 = buf.length;
480
+ return ptr2;
481
+ }
482
+ let len = arg.length;
483
+ let ptr = malloc(len, 1) >>> 0;
484
+ const mem = getUint8ArrayMemory02();
485
+ let offset = 0;
486
+ for (; offset < len; offset++) {
487
+ const code = arg.charCodeAt(offset);
488
+ if (code > 127) break;
489
+ mem[ptr + offset] = code;
490
+ }
491
+ if (offset !== len) {
492
+ if (offset !== 0) {
493
+ arg = arg.slice(offset);
494
+ }
495
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
496
+ const view = getUint8ArrayMemory02().subarray(ptr + offset, ptr + len);
497
+ const ret = encodeString2(arg, view);
498
+ offset += ret.written;
499
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
500
+ }
501
+ WASM_VECTOR_LEN2 = offset;
502
+ return ptr;
503
+ }
504
+ var cachedDataViewMemory02 = null;
505
+ function getDataViewMemory02() {
506
+ if (cachedDataViewMemory02 === null || cachedDataViewMemory02.buffer.detached === true || cachedDataViewMemory02.buffer.detached === void 0 && cachedDataViewMemory02.buffer !== wasm2.memory.buffer) {
507
+ cachedDataViewMemory02 = new DataView(wasm2.memory.buffer);
508
+ }
509
+ return cachedDataViewMemory02;
510
+ }
511
+ var cachedTextDecoder2 = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
512
+ throw Error("TextDecoder not available");
513
+ } };
514
+ if (typeof TextDecoder !== "undefined") {
515
+ cachedTextDecoder2.decode();
516
+ }
517
+ function getStringFromWasm02(ptr, len) {
518
+ ptr = ptr >>> 0;
519
+ return cachedTextDecoder2.decode(getUint8ArrayMemory02().subarray(ptr, ptr + len));
520
+ }
521
+ function breakscape_text2(input, format, location) {
522
+ let deferred4_0;
523
+ let deferred4_1;
524
+ try {
525
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
526
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
527
+ const len0 = WASM_VECTOR_LEN2;
528
+ const ptr1 = passStringToWasm02(format, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
529
+ const len1 = WASM_VECTOR_LEN2;
530
+ const ptr2 = passStringToWasm02(location, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
531
+ const len2 = WASM_VECTOR_LEN2;
532
+ wasm2.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
533
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
534
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
535
+ deferred4_0 = r0;
536
+ deferred4_1 = r1;
537
+ return getStringFromWasm02(r0, r1);
538
+ } finally {
539
+ wasm2.__wbindgen_add_to_stack_pointer(16);
540
+ wasm2.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
541
+ }
542
+ }
543
+ function unbreakscape_text2(input, format, location) {
544
+ let deferred4_0;
545
+ let deferred4_1;
546
+ try {
547
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
548
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
549
+ const len0 = WASM_VECTOR_LEN2;
550
+ const ptr1 = passStringToWasm02(format, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
551
+ const len1 = WASM_VECTOR_LEN2;
552
+ const ptr2 = passStringToWasm02(location, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
553
+ const len2 = WASM_VECTOR_LEN2;
554
+ wasm2.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
555
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
556
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
557
+ deferred4_0 = r0;
558
+ deferred4_1 = r1;
559
+ return getStringFromWasm02(r0, r1);
560
+ } finally {
561
+ wasm2.__wbindgen_add_to_stack_pointer(16);
562
+ wasm2.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
563
+ }
564
+ }
565
+ function info2(info_type, format, bit, pretty, indent, include_deprecated, only_deprecated, full) {
566
+ let deferred4_0;
567
+ let deferred4_1;
568
+ try {
569
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
570
+ const ptr0 = passStringToWasm02(info_type, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
571
+ const len0 = WASM_VECTOR_LEN2;
572
+ const ptr1 = passStringToWasm02(format, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
573
+ const len1 = WASM_VECTOR_LEN2;
574
+ const ptr2 = passStringToWasm02(bit, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
575
+ const len2 = WASM_VECTOR_LEN2;
576
+ wasm2.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, include_deprecated, only_deprecated, full);
577
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
578
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
579
+ deferred4_0 = r0;
580
+ deferred4_1 = r1;
581
+ return getStringFromWasm02(r0, r1);
582
+ } finally {
583
+ wasm2.__wbindgen_add_to_stack_pointer(16);
584
+ wasm2.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
585
+ }
586
+ }
587
+ function convert2(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report) {
588
+ let deferred5_0;
589
+ let deferred5_1;
590
+ try {
591
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
592
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
593
+ const len0 = WASM_VECTOR_LEN2;
594
+ const ptr1 = passStringToWasm02(input_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
595
+ const len1 = WASM_VECTOR_LEN2;
596
+ const ptr2 = passStringToWasm02(output_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
597
+ const len2 = WASM_VECTOR_LEN2;
598
+ const ptr3 = passStringToWasm02(mode, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
599
+ const len3 = WASM_VECTOR_LEN2;
600
+ wasm2.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report);
601
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
602
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
603
+ deferred5_0 = r0;
604
+ deferred5_1 = r1;
605
+ return getStringFromWasm02(r0, r1);
606
+ } finally {
607
+ wasm2.__wbindgen_add_to_stack_pointer(16);
608
+ wasm2.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
609
+ }
610
+ }
611
+ function canonicalize2(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
612
+ let deferred4_0;
613
+ let deferred4_1;
614
+ try {
615
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
616
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
617
+ const len0 = WASM_VECTOR_LEN2;
618
+ const ptr1 = passStringToWasm02(input_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
619
+ const len1 = WASM_VECTOR_LEN2;
620
+ const ptr2 = passStringToWasm02(mode, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
621
+ const len2 = WASM_VECTOR_LEN2;
622
+ wasm2.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
623
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
624
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
625
+ deferred4_0 = r0;
626
+ deferred4_1 = r1;
627
+ return getStringFromWasm02(r0, r1);
628
+ } finally {
629
+ wasm2.__wbindgen_add_to_stack_pointer(16);
630
+ wasm2.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
631
+ }
632
+ }
633
+ function count_bits2(input) {
634
+ let deferred2_0;
635
+ let deferred2_1;
636
+ try {
637
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
638
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
639
+ const len0 = WASM_VECTOR_LEN2;
640
+ wasm2.count_bits(retptr, ptr0, len0);
641
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
642
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
643
+ deferred2_0 = r0;
644
+ deferred2_1 = r1;
645
+ return getStringFromWasm02(r0, r1);
646
+ } finally {
647
+ wasm2.__wbindgen_add_to_stack_pointer(16);
648
+ wasm2.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
649
+ }
650
+ }
651
+ function split_bits2(input) {
652
+ let deferred2_0;
653
+ let deferred2_1;
654
+ try {
655
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
656
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
657
+ const len0 = WASM_VECTOR_LEN2;
658
+ wasm2.split_bits(retptr, ptr0, len0);
659
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
660
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
661
+ deferred2_0 = r0;
662
+ deferred2_1 = r1;
663
+ return getStringFromWasm02(r0, r1);
664
+ } finally {
665
+ wasm2.__wbindgen_add_to_stack_pointer(16);
666
+ wasm2.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
667
+ }
668
+ }
669
+ function is_bitmark2(input) {
670
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
671
+ const len0 = WASM_VECTOR_LEN2;
672
+ const ret = wasm2.is_bitmark(ptr0, len0);
673
+ return ret !== 0;
674
+ }
675
+ function split_json_bits2(input) {
676
+ let deferred2_0;
677
+ let deferred2_1;
678
+ try {
679
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
680
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
681
+ const len0 = WASM_VECTOR_LEN2;
682
+ wasm2.split_json_bits(retptr, ptr0, len0);
683
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
684
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
685
+ deferred2_0 = r0;
686
+ deferred2_1 = r1;
687
+ return getStringFromWasm02(r0, r1);
688
+ } finally {
689
+ wasm2.__wbindgen_add_to_stack_pointer(16);
690
+ wasm2.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
691
+ }
692
+ }
693
+ function prettify2(json, indent) {
694
+ let deferred2_0;
695
+ let deferred2_1;
696
+ try {
697
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
698
+ const ptr0 = passStringToWasm02(json, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
699
+ const len0 = WASM_VECTOR_LEN2;
700
+ wasm2.prettify(retptr, ptr0, len0, indent);
701
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
702
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
703
+ deferred2_0 = r0;
704
+ deferred2_1 = r1;
705
+ return getStringFromWasm02(r0, r1);
706
+ } finally {
707
+ wasm2.__wbindgen_add_to_stack_pointer(16);
708
+ wasm2.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
709
+ }
710
+ }
711
+ function convert_text2(input, direction, format, location) {
712
+ let deferred5_0;
713
+ let deferred5_1;
714
+ try {
715
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
716
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
717
+ const len0 = WASM_VECTOR_LEN2;
718
+ const ptr1 = passStringToWasm02(direction, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
719
+ const len1 = WASM_VECTOR_LEN2;
720
+ const ptr2 = passStringToWasm02(format, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
721
+ const len2 = WASM_VECTOR_LEN2;
722
+ const ptr3 = passStringToWasm02(location, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
723
+ const len3 = WASM_VECTOR_LEN2;
724
+ wasm2.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
725
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
726
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
727
+ deferred5_0 = r0;
728
+ deferred5_1 = r1;
729
+ return getStringFromWasm02(r0, r1);
730
+ } finally {
731
+ wasm2.__wbindgen_add_to_stack_pointer(16);
732
+ wasm2.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
733
+ }
734
+ }
735
+ function transform2(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
736
+ let deferred6_0;
737
+ let deferred6_1;
738
+ try {
739
+ const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
740
+ const ptr0 = passStringToWasm02(input, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
741
+ const len0 = WASM_VECTOR_LEN2;
742
+ const ptr1 = passStringToWasm02(input_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
743
+ const len1 = WASM_VECTOR_LEN2;
744
+ const ptr2 = passStringToWasm02(output_format_sel, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
745
+ const len2 = WASM_VECTOR_LEN2;
746
+ const ptr3 = passStringToWasm02(mode, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
747
+ const len3 = WASM_VECTOR_LEN2;
748
+ const ptr4 = passStringToWasm02(patch_json, wasm2.__wbindgen_export_0, wasm2.__wbindgen_export_1);
749
+ const len4 = WASM_VECTOR_LEN2;
750
+ wasm2.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
751
+ var r0 = getDataViewMemory02().getInt32(retptr + 4 * 0, true);
752
+ var r1 = getDataViewMemory02().getInt32(retptr + 4 * 1, true);
753
+ deferred6_0 = r0;
754
+ deferred6_1 = r1;
755
+ return getStringFromWasm02(r0, r1);
756
+ } finally {
757
+ wasm2.__wbindgen_add_to_stack_pointer(16);
758
+ wasm2.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
759
+ }
760
+ }
761
+ async function __wbg_load2(module, imports) {
762
+ if (typeof Response === "function" && module instanceof Response) {
763
+ if (typeof WebAssembly.instantiateStreaming === "function") {
764
+ try {
765
+ return await WebAssembly.instantiateStreaming(module, imports);
766
+ } catch (e) {
767
+ if (module.headers.get("Content-Type") != "application/wasm") {
768
+ 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);
769
+ } else {
770
+ throw e;
771
+ }
772
+ }
773
+ }
774
+ const bytes = await module.arrayBuffer();
775
+ return await WebAssembly.instantiate(bytes, imports);
776
+ } else {
777
+ const instance = await WebAssembly.instantiate(module, imports);
778
+ if (instance instanceof WebAssembly.Instance) {
779
+ return { instance, module };
780
+ } else {
781
+ return instance;
782
+ }
783
+ }
784
+ }
785
+ function __wbg_get_imports2() {
786
+ const imports = {};
787
+ imports.wbg = {};
788
+ return imports;
789
+ }
790
+ function __wbg_init_memory2(imports, memory) {
791
+ }
792
+ function __wbg_finalize_init2(instance, module) {
793
+ wasm2 = instance.exports;
794
+ __wbg_init2.__wbindgen_wasm_module = module;
795
+ cachedDataViewMemory02 = null;
796
+ cachedUint8ArrayMemory02 = null;
797
+ return wasm2;
798
+ }
799
+ function initSync2(module) {
800
+ if (wasm2 !== void 0) return wasm2;
801
+ if (typeof module !== "undefined") {
802
+ if (Object.getPrototypeOf(module) === Object.prototype) {
803
+ ({ module } = module);
804
+ } else {
805
+ console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
806
+ }
807
+ }
808
+ const imports = __wbg_get_imports2();
809
+ __wbg_init_memory2(imports);
810
+ if (!(module instanceof WebAssembly.Module)) {
811
+ module = new WebAssembly.Module(module);
812
+ }
813
+ const instance = new WebAssembly.Instance(module, imports);
814
+ return __wbg_finalize_init2(instance, module);
815
+ }
816
+ async function __wbg_init2(module_or_path) {
817
+ if (wasm2 !== void 0) return wasm2;
818
+ if (typeof module_or_path !== "undefined") {
819
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
820
+ ({ module_or_path } = module_or_path);
821
+ } else {
822
+ console.warn("using deprecated parameters for the initialization function; pass a single object instead");
823
+ }
824
+ }
825
+ if (typeof module_or_path === "undefined") {
826
+ module_or_path = new URL("bitmark_json_wasm_bg.wasm", import.meta.url);
827
+ }
828
+ const imports = __wbg_get_imports2();
829
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
830
+ module_or_path = fetch(module_or_path);
831
+ }
832
+ __wbg_init_memory2(imports);
833
+ const { instance, module } = await __wbg_load2(await module_or_path, imports);
834
+ return __wbg_finalize_init2(instance, module);
835
+ }
836
+ var bitmark_json_wasm_default = __wbg_init2;
837
+
434
838
  // src/generated/package_info.ts
435
839
  var PACKAGE_INFO = {
436
840
  "name": "@gmb/bitmark-parser",
437
- "version": "6.9.0",
841
+ "version": "6.10.0",
438
842
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
439
843
  "license": "ISC",
440
844
  "description": "A parser for bitmark text, powered by WebAssembly."
441
845
  };
442
846
 
847
+ // src/core/facade.ts
848
+ var NotInitializedError = class extends Error {
849
+ constructor() {
850
+ super("wasm not initialised: call init() (or init({ feature: \u2026 })) first");
851
+ this.name = "NotInitializedError";
852
+ }
853
+ };
854
+ var UnsupportedFeatureError = class extends Error {
855
+ constructor(what, active2) {
856
+ super(
857
+ `${what} is not available in the loaded wasm module${active2 ? ` (feature: "${active2}")` : ""}; init({ feature: "full" }) to load it`
858
+ );
859
+ this.name = "UnsupportedFeatureError";
860
+ }
861
+ };
862
+ var active;
863
+ var activeFeature;
864
+ var lazyLoader;
865
+ function getActive() {
866
+ if (!active && lazyLoader) lazyLoader();
867
+ if (!active) throw new NotInitializedError();
868
+ return active;
869
+ }
870
+ function setActive(feature, module) {
871
+ active = module;
872
+ activeFeature = feature;
873
+ }
874
+ function variant() {
875
+ return activeFeature;
876
+ }
877
+
443
878
  // src/core/hooked-transform.ts
444
879
  function isError(s) {
445
880
  return s.startsWith("error:");
@@ -460,9 +895,9 @@ function normalisePatch(patch) {
460
895
  }
461
896
  return patch;
462
897
  }
463
- function buildUnits(wasm2, input, inputIsBitmark) {
898
+ function buildUnits(wasm3, input, inputIsBitmark) {
464
899
  if (inputIsBitmark) {
465
- const out2 = wasm2.split_bits(input);
900
+ const out2 = wasm3.split_bits(input);
466
901
  if (isError(out2)) throw new Error(out2);
467
902
  const slices = JSON.parse(out2);
468
903
  return slices.map((s) => ({
@@ -470,7 +905,7 @@ function buildUnits(wasm2, input, inputIsBitmark) {
470
905
  source: s.source
471
906
  }));
472
907
  }
473
- const out = wasm2.split_json_bits(input);
908
+ const out = wasm3.split_json_bits(input);
474
909
  if (isError(out)) throw new Error(out);
475
910
  const envelopes = JSON.parse(out);
476
911
  return envelopes.map((env, index) => ({
@@ -479,17 +914,17 @@ function buildUnits(wasm2, input, inputIsBitmark) {
479
914
  source: JSON.stringify([env])
480
915
  }));
481
916
  }
482
- function planTransform(wasm2, input, options) {
917
+ function planTransform(wasm3, input, options) {
483
918
  const mode = options.mode ?? "optimized";
484
919
  const output = options.outputFormat ?? "json";
485
920
  const spacesAroundValues = options.spacesAroundValues ?? 1;
486
921
  const indent = options.indent ?? 2;
487
922
  const pretty = options.pretty ?? false;
488
923
  const sel = options.inputFormat ?? "auto";
489
- const inputIsBitmark = sel === "bitmark" || sel !== "json" && wasm2.is_bitmark(input);
924
+ const inputIsBitmark = sel === "bitmark" || sel !== "json" && wasm3.is_bitmark(input);
490
925
  const inputFormat = inputIsBitmark ? "bitmark" : "json";
491
926
  const staticPatch = normalisePatch(options.patch);
492
- const units = buildUnits(wasm2, input, inputIsBitmark);
927
+ const units = buildUnits(wasm3, input, inputIsBitmark);
493
928
  const total = units.length;
494
929
  const jobs = [];
495
930
  const views = [];
@@ -513,8 +948,8 @@ function planTransform(wasm2, input, options) {
513
948
  }
514
949
  return { jobs, views, output, pretty, indent };
515
950
  }
516
- function computeBit(wasm2, job) {
517
- const out = wasm2.transform(
951
+ function computeBit(wasm3, job) {
952
+ const out = wasm3.transform(
518
953
  job.source,
519
954
  job.inputFormat,
520
955
  job.outputFormat,
@@ -527,33 +962,33 @@ function computeBit(wasm2, job) {
527
962
  if (isError(out)) return out;
528
963
  return job.outputFormat === "json" ? stripArray(out) : out;
529
964
  }
530
- function recombine(wasm2, elements, output, pretty, indent) {
965
+ function recombine(wasm3, elements, output, pretty, indent) {
531
966
  if (output === "bitmark" || output === "text") return elements.join("\n");
532
967
  const arr = `[${elements.join(",")}]`;
533
- return pretty ? wasm2.prettify(arr, indent) : arr;
968
+ return pretty ? wasm3.prettify(arr, indent) : arr;
534
969
  }
535
- function runHookedTransform(wasm2, input, options) {
970
+ function runHookedTransform(wasm3, input, options) {
536
971
  let plan;
537
972
  try {
538
- plan = planTransform(wasm2, input, options);
973
+ plan = planTransform(wasm3, input, options);
539
974
  } catch (e) {
540
975
  return errorString(e);
541
976
  }
542
977
  const rendered = [];
543
978
  for (let i = 0; i < plan.jobs.length; i++) {
544
- const element = computeBit(wasm2, plan.jobs[i]);
979
+ const element = computeBit(wasm3, plan.jobs[i]);
545
980
  if (isError(element)) return element;
546
981
  options.postHook?.(plan.views[i], element);
547
982
  rendered.push(element);
548
983
  }
549
- return recombine(wasm2, rendered, plan.output, plan.pretty, plan.indent);
984
+ return recombine(wasm3, rendered, plan.output, plan.pretty, plan.indent);
550
985
  }
551
986
 
552
987
  // src/core/parallel.ts
553
- async function orchestrateParallel(wasm2, input, options, runJobs) {
988
+ async function orchestrateParallel(wasm3, input, options, runJobs) {
554
989
  let plan;
555
990
  try {
556
- plan = planTransform(wasm2, input, options);
991
+ plan = planTransform(wasm3, input, options);
557
992
  } catch (e) {
558
993
  return errorString(e);
559
994
  }
@@ -567,11 +1002,29 @@ async function orchestrateParallel(wasm2, input, options, runJobs) {
567
1002
  if (isError(elements[i])) return elements[i];
568
1003
  options.postHook?.(plan.views[i], elements[i]);
569
1004
  }
570
- return recombine(wasm2, elements, plan.output, plan.pretty, plan.indent);
1005
+ return recombine(wasm3, elements, plan.output, plan.pretty, plan.indent);
1006
+ }
1007
+
1008
+ // src/legacy/runtime.ts
1009
+ var wasmProvider;
1010
+ function setLegacyWasmProvider(provider) {
1011
+ wasmProvider = provider;
1012
+ }
1013
+ function getLegacyWasm() {
1014
+ if (!wasmProvider) {
1015
+ throw new Error(
1016
+ "legacy API not initialised: the WASM module has not been provided (browser consumers must call init() first)"
1017
+ );
1018
+ }
1019
+ return wasmProvider();
1020
+ }
1021
+ var fileIo;
1022
+ function getLegacyFileIo() {
1023
+ return fileIo;
571
1024
  }
572
1025
 
573
1026
  // src/browser/pool.ts
574
- function runJobsParallel(jobs, workers) {
1027
+ function runJobsParallel(jobs, workers, feature) {
575
1028
  if (jobs.length === 0) return Promise.resolve([]);
576
1029
  const poolSize = Math.max(1, Math.min(workers, jobs.length));
577
1030
  const workerUrl = new URL("./worker-entry.js", import.meta.url);
@@ -593,7 +1046,7 @@ function runJobsParallel(jobs, workers) {
593
1046
  const dispatch = (w) => {
594
1047
  if (done || next >= jobs.length) return;
595
1048
  const id = next++;
596
- w.postMessage({ id, job: jobs[id] });
1049
+ w.postMessage({ id, job: jobs[id], feature });
597
1050
  };
598
1051
  for (let i = 0; i < poolSize; i++) {
599
1052
  const w = new Worker(workerUrl, { type: "module" });
@@ -621,24 +1074,6 @@ function runJobsParallel(jobs, workers) {
621
1074
  });
622
1075
  }
623
1076
 
624
- // src/legacy/runtime.ts
625
- var wasmModule;
626
- function setLegacyWasm(wasm2) {
627
- wasmModule = wasm2;
628
- }
629
- function getLegacyWasm() {
630
- if (!wasmModule) {
631
- throw new Error(
632
- "legacy API not initialised: the WASM module has not been provided (browser consumers must call init() first)"
633
- );
634
- }
635
- return wasmModule;
636
- }
637
- var fileIo;
638
- function getLegacyFileIo() {
639
- return fileIo;
640
- }
641
-
642
1077
  // src/legacy/index.ts
643
1078
  var legacy_exports = {};
644
1079
  __export(legacy_exports, {
@@ -714,9 +1149,9 @@ function validateJsonOptions(o) {
714
1149
  if (o.textAsPlainText) unsupportedOption("jsonOptions.textAsPlainText", V3_ONLY);
715
1150
  if (o.debugGenerationInline) unsupportedOption("jsonOptions.debugGenerationInline");
716
1151
  }
717
- function prettyIndent(prettify2) {
718
- if (prettify2 === true) return { pretty: true, indent: 2 };
719
- if (typeof prettify2 === "number" && prettify2 > 0) return { pretty: true, indent: prettify2 };
1152
+ function prettyIndent(prettify3) {
1153
+ if (prettify3 === true) return { pretty: true, indent: 2 };
1154
+ if (typeof prettify3 === "number" && prettify3 > 0) return { pretty: true, indent: prettify3 };
720
1155
  return { pretty: false, indent: 2 };
721
1156
  }
722
1157
  function spacesAround(v) {
@@ -816,7 +1251,7 @@ var Builder = class {
816
1251
  * more than one resource, use the first one").
817
1252
  */
818
1253
  buildBit(data, _options) {
819
- const wasm2 = getLegacyWasm();
1254
+ const wasm3 = getLegacyWasm();
820
1255
  const src = { ...data };
821
1256
  const bitType = src.bitType;
822
1257
  const bitConfig = this.getBitConfig(bitType);
@@ -877,7 +1312,7 @@ var Builder = class {
877
1312
  }
878
1313
  }
879
1314
  this.parseStringTexts(bit);
880
- const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false, false);
1315
+ const out = wasm3.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false, false);
881
1316
  if (out.startsWith("error:")) {
882
1317
  throw new Error(out.slice("error:".length).trim());
883
1318
  }
@@ -933,10 +1368,10 @@ var Builder = class {
933
1368
  * (bpg TextParser.toAst ignores format; only location matters).
934
1369
  */
935
1370
  parseStringTexts(bit) {
936
- const wasm2 = getLegacyWasm();
1371
+ const wasm3 = getLegacyWasm();
937
1372
  const toAst = (s, location) => {
938
1373
  if (s === "") return s;
939
- const out = wasm2.convert_text(s, "textToAst", "bitmark++", location);
1374
+ const out = wasm3.convert_text(s, "textToAst", "bitmark++", location);
940
1375
  try {
941
1376
  return JSON.parse(out);
942
1377
  } catch {
@@ -966,11 +1401,11 @@ var Builder = class {
966
1401
  * unknown-bit-type error (`Config.getBitConfig` parity).
967
1402
  */
968
1403
  getBitConfig(bitType) {
969
- const wasm2 = getLegacyWasm();
1404
+ const wasm3 = getLegacyWasm();
970
1405
  if (bitType !== void 0) {
971
1406
  try {
972
- const info3 = JSON.parse(wasm2.info("bit", "json", bitType, false, 2, false, false, true));
973
- if (info3.error === void 0) return { bodyFormat: info3.body?.format };
1407
+ const info4 = JSON.parse(wasm3.info("bit", "json", bitType, false, 2, false, false, true));
1408
+ if (info4.error === void 0) return { bodyFormat: info4.body?.format };
974
1409
  } catch {
975
1410
  }
976
1411
  }
@@ -1009,7 +1444,7 @@ var BitmarkParserGenerator = class {
1009
1444
  validateBitmarkOptions(bitmarkOptions);
1010
1445
  validateJsonOptions(jsonOptions);
1011
1446
  this.checkBrowserFileWrite(opts.outputFile);
1012
- const wasm2 = getLegacyWasm();
1447
+ const wasm3 = getLegacyWasm();
1013
1448
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1014
1449
  const outputFormat = opts.outputFormat ?? (isBitmark ? "json" : "bitmark");
1015
1450
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
@@ -1017,7 +1452,7 @@ var BitmarkParserGenerator = class {
1017
1452
  const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
1018
1453
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1019
1454
  const includeUnknown = !jsonOptions.excludeUnknownProperties;
1020
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown, false);
1455
+ const out = wasm3.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown, false);
1021
1456
  this.throwOnError(out);
1022
1457
  if (outputFormat === "bitmark" || outputFormat === "text") {
1023
1458
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1045,13 +1480,13 @@ var BitmarkParserGenerator = class {
1045
1480
  validateBitmarkOptions(bitmarkOptions);
1046
1481
  validateJsonOptions(jsonOptions);
1047
1482
  this.checkBrowserFileWrite(opts.outputFile);
1048
- const wasm2 = getLegacyWasm();
1483
+ const wasm3 = getLegacyWasm();
1049
1484
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1050
1485
  const { pretty, indent } = prettyIndent(
1051
1486
  isBitmark ? bitmarkOptions.prettifyJson : jsonOptions.prettify
1052
1487
  );
1053
1488
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1054
- const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
1489
+ const out = wasm3.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
1055
1490
  this.throwOnError(out);
1056
1491
  if (isBitmark) return this.deliver(out, opts.outputFile, opts.fileOptions);
1057
1492
  if (opts.outputFile) return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1063,12 +1498,12 @@ var BitmarkParserGenerator = class {
1063
1498
  */
1064
1499
  info(options) {
1065
1500
  const opts = Object.assign({}, options);
1066
- const wasm2 = getLegacyWasm();
1501
+ const wasm3 = getLegacyWasm();
1067
1502
  const type = opts.type ?? "list";
1068
1503
  const format = opts.outputFormat ?? "text";
1069
1504
  const { pretty, indent } = prettyIndent(opts.prettify);
1070
1505
  const coreFormat = format === "pojo" ? "json" : format;
1071
- const out = wasm2.info(type, coreFormat, opts.bit ?? "", pretty, indent, false, false, true);
1506
+ const out = wasm3.info(type, coreFormat, opts.bit ?? "", pretty, indent, false, false, true);
1072
1507
  this.throwOnError(out);
1073
1508
  if (format === "pojo") return JSON.parse(out);
1074
1509
  return out;
@@ -1096,12 +1531,12 @@ var BitmarkParserGenerator = class {
1096
1531
  if (opts.keepUnknownTags) unsupportedOption("keepUnknownTags");
1097
1532
  if (opts.noBreakscaping) unsupportedOption("noBreakscaping");
1098
1533
  this.checkBrowserFileWrite(opts.outputFile);
1099
- const wasm2 = getLegacyWasm();
1534
+ const wasm3 = getLegacyWasm();
1100
1535
  const inStr = typeof input === "string" ? this.maybeReadFile(input, void 0) : "";
1101
1536
  const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
1102
1537
  if (!isHtmlInput) {
1103
1538
  const { source, isBitmark } = this.resolveInput(input, void 0);
1104
- const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false, false);
1539
+ const out2 = wasm3.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false, false);
1105
1540
  this.throwOnError(out2);
1106
1541
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
1107
1542
  }
@@ -1111,12 +1546,12 @@ var BitmarkParserGenerator = class {
1111
1546
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1112
1547
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1113
1548
  if (outputFormat === "html") {
1114
- const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false, false);
1549
+ const out2 = wasm3.convert(wrapped, "html", "html", "optimized", false, 2, 1, false, false);
1115
1550
  this.throwOnError(out2);
1116
1551
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
1117
1552
  }
1118
1553
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
1119
- const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false, false);
1554
+ const out = wasm3.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false, false);
1120
1555
  this.throwOnError(out);
1121
1556
  if (outputFormat === "bitmark" || outputFormat === "text") {
1122
1557
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1139,9 +1574,9 @@ var BitmarkParserGenerator = class {
1139
1574
  */
1140
1575
  createAst(input, options) {
1141
1576
  const opts = Object.assign({}, options);
1142
- const wasm2 = getLegacyWasm();
1577
+ const wasm3 = getLegacyWasm();
1143
1578
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1144
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true, false);
1579
+ const out = wasm3.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true, false);
1145
1580
  this.throwOnError(out);
1146
1581
  return makePseudoAst(JSON.parse(out));
1147
1582
  }
@@ -1152,9 +1587,9 @@ var BitmarkParserGenerator = class {
1152
1587
  if (!input) return input;
1153
1588
  const opts = Object.assign({}, options);
1154
1589
  this.checkBrowserFileWrite(opts.outputFile);
1155
- const wasm2 = getLegacyWasm();
1590
+ const wasm3 = getLegacyWasm();
1156
1591
  const inStr = this.maybeReadFile(input, opts.inputFormat);
1157
- const res = wasm2.breakscape_text(inStr, mapTextFormat(opts.textFormat), opts.textLocation ?? "body");
1592
+ const res = wasm3.breakscape_text(inStr, mapTextFormat(opts.textFormat), opts.textLocation ?? "body");
1158
1593
  return this.deliver(res, opts.outputFile, opts.fileOptions);
1159
1594
  }
1160
1595
  /**
@@ -1164,9 +1599,9 @@ var BitmarkParserGenerator = class {
1164
1599
  if (!input) return input;
1165
1600
  const opts = Object.assign({}, options);
1166
1601
  this.checkBrowserFileWrite(opts.outputFile);
1167
- const wasm2 = getLegacyWasm();
1602
+ const wasm3 = getLegacyWasm();
1168
1603
  const inStr = this.maybeReadFile(input, opts.inputFormat);
1169
- const res = wasm2.unbreakscape_text(inStr, mapTextFormat(opts.textFormat), opts.textLocation ?? "body");
1604
+ const res = wasm3.unbreakscape_text(inStr, mapTextFormat(opts.textFormat), opts.textLocation ?? "body");
1170
1605
  return this.deliver(res, opts.outputFile, opts.fileOptions);
1171
1606
  }
1172
1607
  /**
@@ -1180,7 +1615,7 @@ var BitmarkParserGenerator = class {
1180
1615
  const opts = Object.assign({}, options);
1181
1616
  const jsonOptions = Object.assign({}, opts.jsonOptions);
1182
1617
  this.checkBrowserFileWrite(opts.outputFile);
1183
- const wasm2 = getLegacyWasm();
1618
+ const wasm3 = getLegacyWasm();
1184
1619
  const isBitmarkText = opts.textFormat === void 0 || mapTextFormat(opts.textFormat) === "bitmark++";
1185
1620
  const textLocation = opts.textLocation ?? "body";
1186
1621
  let inStr;
@@ -1193,14 +1628,14 @@ var BitmarkParserGenerator = class {
1193
1628
  ast = Array.isArray(input) ? input : void 0;
1194
1629
  }
1195
1630
  if (ast !== void 0) {
1196
- const out2 = isBitmarkText ? wasm2.convert_text(JSON.stringify(ast), "astToText", "bitmark++", textLocation) : wasm2.convert_text(JSON.stringify(ast), "astToPlainText", "plainText", textLocation);
1631
+ const out2 = isBitmarkText ? wasm3.convert_text(JSON.stringify(ast), "astToText", "bitmark++", textLocation) : wasm3.convert_text(JSON.stringify(ast), "astToPlainText", "plainText", textLocation);
1197
1632
  this.throwOnError(out2);
1198
1633
  return this.deliver(out2, opts.outputFile, opts.fileOptions);
1199
1634
  }
1200
- const out = wasm2.convert_text(inStr, "textToAst", isBitmarkText ? "bitmark++" : "plainText", "body");
1635
+ const out = wasm3.convert_text(inStr, "textToAst", isBitmarkText ? "bitmark++" : "plainText", "body");
1201
1636
  this.throwOnError(out);
1202
1637
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1203
- const outStr = pretty ? wasm2.prettify(out, indent) : out;
1638
+ const outStr = pretty ? wasm3.prettify(out, indent) : out;
1204
1639
  if (opts.outputFile) return this.deliver(outStr, opts.outputFile, opts.fileOptions);
1205
1640
  if (pretty) return outStr;
1206
1641
  return JSON.parse(out);
@@ -1209,8 +1644,8 @@ var BitmarkParserGenerator = class {
1209
1644
  * Convert a text AST to plain text (bpg-compatible `textAstToPlainText`).
1210
1645
  */
1211
1646
  textAstToPlainText(textAst, _options) {
1212
- const wasm2 = getLegacyWasm();
1213
- const out = wasm2.convert_text(
1647
+ const wasm3 = getLegacyWasm();
1648
+ const out = wasm3.convert_text(
1214
1649
  typeof textAst === "string" ? textAst : JSON.stringify(textAst),
1215
1650
  "astToPlainText",
1216
1651
  "bitmark++",
@@ -1224,17 +1659,17 @@ var BitmarkParserGenerator = class {
1224
1659
  */
1225
1660
  extractPlainText(input, options) {
1226
1661
  const inputFormat = options?.inputFormat;
1227
- const wasm2 = getLegacyWasm();
1662
+ const wasm3 = getLegacyWasm();
1228
1663
  if (inputFormat === "plainText") {
1229
1664
  return typeof input === "string" ? String(input) : "";
1230
1665
  }
1231
1666
  if (inputFormat === "bitmarkText") {
1232
- const ast = wasm2.convert_text(String(input), "textToAst", "bitmark++", "body");
1233
- const out2 = wasm2.convert_text(ast, "astToPlainText", "bitmark++", "body");
1667
+ const ast = wasm3.convert_text(String(input), "textToAst", "bitmark++", "body");
1668
+ const out2 = wasm3.convert_text(ast, "astToPlainText", "bitmark++", "body");
1234
1669
  this.throwOnError(out2);
1235
1670
  return out2;
1236
1671
  }
1237
- if (typeof input === "string" && this.parseTextAstString(input) === void 0 && !wasm2.is_bitmark(input)) {
1672
+ if (typeof input === "string" && this.parseTextAstString(input) === void 0 && !wasm3.is_bitmark(input)) {
1238
1673
  const looksJson = (() => {
1239
1674
  try {
1240
1675
  JSON.parse(input);
@@ -1248,7 +1683,7 @@ var BitmarkParserGenerator = class {
1248
1683
  }
1249
1684
  }
1250
1685
  const { source, isBitmark } = this.resolveInput(input, void 0);
1251
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false, false);
1686
+ const out = wasm3.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false, false);
1252
1687
  this.throwOnError(out);
1253
1688
  return out;
1254
1689
  }
@@ -1282,8 +1717,8 @@ var BitmarkParserGenerator = class {
1282
1717
  };
1283
1718
  }
1284
1719
  const inStr = this.maybeReadFile(input, inputFormat);
1285
- const wasm2 = getLegacyWasm();
1286
- if (wasm2.is_bitmark(inStr)) return { source: inStr, isBitmark: true };
1720
+ const wasm3 = getLegacyWasm();
1721
+ if (wasm3.is_bitmark(inStr)) return { source: inStr, isBitmark: true };
1287
1722
  try {
1288
1723
  const parsed = JSON.parse(inStr);
1289
1724
  const entries = this.jsonEntries(parsed);
@@ -1652,8 +2087,8 @@ function bitNameToKey(name) {
1652
2087
  var bitTypeCache;
1653
2088
  function loadBitTypes() {
1654
2089
  if (!bitTypeCache) {
1655
- const wasm2 = getLegacyWasm();
1656
- const all = JSON.parse(wasm2.info("all", "json", "", false, 2, true, false, false));
2090
+ const wasm3 = getLegacyWasm();
2091
+ const all = JSON.parse(wasm3.info("all", "json", "", false, 2, true, false, false));
1657
2092
  const map = { _standard: "_standard" };
1658
2093
  for (const { name } of all) {
1659
2094
  map[bitNameToKey(name)] = name;
@@ -1725,22 +2160,14 @@ function patchEntry(path, op, value) {
1725
2160
  return value === void 0 ? { path, op } : { path, op, value };
1726
2161
  }
1727
2162
 
1728
- // src/browser/index.ts
1729
- setLegacyWasm(bitmark_wasm_exports);
1730
- async function init(module_or_path) {
1731
- if (typeof module_or_path === "undefined") {
1732
- module_or_path = new URL(`bitmark_wasm_bg.wasm?v=${PACKAGE_INFO.version}`, import.meta.url);
1733
- }
1734
- return bitmark_wasm_default(module_or_path);
1735
- }
1736
- function version() {
1737
- return PACKAGE_INFO.version;
1738
- }
2163
+ // src/core/api.ts
1739
2164
  function lex2(input, options = {}) {
1740
- return lex(input, options.stage ?? "lex");
2165
+ const wasm3 = getActive();
2166
+ if (typeof wasm3.lex !== "function") throw new UnsupportedFeatureError("lex", variant());
2167
+ return wasm3.lex(input, options.stage ?? "lex");
1741
2168
  }
1742
2169
  function bitmarkToObjects(input, options = {}) {
1743
- const out = convert(
2170
+ const out = getActive().convert(
1744
2171
  input,
1745
2172
  "bitmark",
1746
2173
  "json",
@@ -1758,7 +2185,7 @@ function objectsToBitmark(bits, options = {}) {
1758
2185
  const entries = bits.map(
1759
2186
  (b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
1760
2187
  );
1761
- const out = convert(
2188
+ const out = getActive().convert(
1762
2189
  JSON.stringify(entries),
1763
2190
  "json",
1764
2191
  "bitmark",
@@ -1772,8 +2199,8 @@ function objectsToBitmark(bits, options = {}) {
1772
2199
  if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1773
2200
  return out;
1774
2201
  }
1775
- function convert2(input, options = {}) {
1776
- return convert(
2202
+ function convert3(input, options = {}) {
2203
+ return getActive().convert(
1777
2204
  input,
1778
2205
  options.inputFormat ?? "auto",
1779
2206
  options.outputFormat ?? "auto",
@@ -1785,8 +2212,8 @@ function convert2(input, options = {}) {
1785
2212
  options.mappingReport ?? false
1786
2213
  );
1787
2214
  }
1788
- function canonicalize2(input, options = {}) {
1789
- return canonicalize(
2215
+ function canonicalize3(input, options = {}) {
2216
+ return getActive().canonicalize(
1790
2217
  input,
1791
2218
  options.inputFormat ?? "auto",
1792
2219
  options.mode ?? "optimized",
@@ -1796,19 +2223,20 @@ function canonicalize2(input, options = {}) {
1796
2223
  );
1797
2224
  }
1798
2225
  function countBits(input) {
1799
- const out = count_bits(input);
2226
+ const out = getActive().count_bits(input);
1800
2227
  if (out.startsWith("error:")) throw new Error(out);
1801
2228
  return Number.parseInt(out, 10);
1802
2229
  }
1803
2230
  function splitBits(input) {
1804
- return JSON.parse(split_bits(input));
2231
+ return JSON.parse(getActive().split_bits(input));
1805
2232
  }
1806
- function transform2(input, options = {}) {
2233
+ function transform3(input, options = {}) {
2234
+ const wasm3 = getActive();
1807
2235
  if (options.preHook || options.postHook) {
1808
- return runHookedTransform(bitmark_wasm_exports, input, options);
2236
+ return runHookedTransform(wasm3, input, options);
1809
2237
  }
1810
2238
  const patchJson = options.patch === void 0 ? "" : typeof options.patch === "string" ? options.patch : JSON.stringify(options.patch);
1811
- return transform(
2239
+ return wasm3.transform(
1812
2240
  input,
1813
2241
  options.inputFormat ?? "auto",
1814
2242
  options.outputFormat ?? "json",
@@ -1819,20 +2247,17 @@ function transform2(input, options = {}) {
1819
2247
  options.spacesAroundValues ?? 1
1820
2248
  );
1821
2249
  }
1822
- function transformParallel(input, options = {}) {
1823
- return orchestrateParallel(bitmark_wasm_exports, input, options, runJobsParallel);
1824
- }
1825
2250
  function breakscapeText(input, options = {}) {
1826
2251
  const format = options.format ?? "bitmark++";
1827
2252
  const location = options.location ?? "body";
1828
- return breakscape_text(input, format, location);
2253
+ return getActive().breakscape_text(input, format, location);
1829
2254
  }
1830
2255
  function unbreakscapeText(input, options = {}) {
1831
2256
  const format = options.format ?? "bitmark++";
1832
2257
  const location = options.location ?? "body";
1833
- return unbreakscape_text(input, format, location);
2258
+ return getActive().unbreakscape_text(input, format, location);
1834
2259
  }
1835
- function info2(options = {}) {
2260
+ function info3(options = {}) {
1836
2261
  const infoType = options.infoType ?? "list";
1837
2262
  const format = options.format ?? "text";
1838
2263
  const bit = options.bit ?? "";
@@ -1841,25 +2266,102 @@ function info2(options = {}) {
1841
2266
  const includeDeprecated = options.includeDeprecated ?? false;
1842
2267
  const onlyDeprecated = options.onlyDeprecated ?? false;
1843
2268
  const full = options.full ?? false;
1844
- return info(infoType, format, bit, pretty, indent, includeDeprecated, onlyDeprecated, full);
2269
+ return getActive().info(infoType, format, bit, pretty, indent, includeDeprecated, onlyDeprecated, full);
2270
+ }
2271
+
2272
+ // src/browser/index.ts
2273
+ var VARIANTS = {
2274
+ full: {
2275
+ init: bitmark_wasm_default,
2276
+ initSync,
2277
+ ns: bitmark_wasm_exports,
2278
+ wasmFile: "bitmark_wasm_bg.wasm"
2279
+ },
2280
+ "bitmark-json": {
2281
+ init: bitmark_json_wasm_default,
2282
+ initSync: initSync2,
2283
+ ns: bitmark_json_wasm_exports,
2284
+ wasmFile: "bitmark_json_wasm_bg.wasm"
2285
+ }
2286
+ };
2287
+ setLegacyWasmProvider(() => getActive());
2288
+ function normalizeInit(arg) {
2289
+ if (arg !== null && typeof arg === "object" && !(arg instanceof URL) && ("feature" in arg || "module_or_path" in arg)) {
2290
+ const o = arg;
2291
+ return { feature: o.feature ?? "full", module_or_path: o.module_or_path };
2292
+ }
2293
+ return { feature: "full", module_or_path: arg ?? void 0 };
2294
+ }
2295
+ var initSeq = 0;
2296
+ var activeOut;
2297
+ var inflight;
2298
+ async function init(options) {
2299
+ const { feature, module_or_path } = normalizeInit(options);
2300
+ if (module_or_path === void 0) {
2301
+ if (!inflight && variant() === feature) return activeOut;
2302
+ if (inflight?.feature === feature) return inflight.promise;
2303
+ }
2304
+ const mySeq = ++initSeq;
2305
+ const v = VARIANTS[feature];
2306
+ const source = module_or_path ?? new URL(`${v.wasmFile}?v=${PACKAGE_INFO.version}`, import.meta.url);
2307
+ const promise = (async () => {
2308
+ try {
2309
+ const out = await v.init(source);
2310
+ if (mySeq === initSeq) {
2311
+ setActive(feature, v.ns);
2312
+ activeOut = out;
2313
+ }
2314
+ } finally {
2315
+ if (inflight?.seq === mySeq) inflight = void 0;
2316
+ }
2317
+ while (inflight) await inflight.promise.catch(() => {
2318
+ });
2319
+ return activeOut;
2320
+ })();
2321
+ inflight = { feature, seq: mySeq, promise };
2322
+ return promise;
2323
+ }
2324
+ function initSync3(module, options = {}) {
2325
+ const feature = options.feature ?? "full";
2326
+ const v = VARIANTS[feature];
2327
+ const out = v.initSync(module);
2328
+ setActive(feature, v.ns);
2329
+ activeOut = out;
2330
+ return out;
2331
+ }
2332
+ function version() {
2333
+ return PACKAGE_INFO.version;
2334
+ }
2335
+ function transformParallel(input, options = {}) {
2336
+ const wasm3 = getActive();
2337
+ const feature = variant() ?? "full";
2338
+ return orchestrateParallel(
2339
+ wasm3,
2340
+ input,
2341
+ options,
2342
+ (jobs, workers) => runJobsParallel(jobs, workers, feature)
2343
+ );
1845
2344
  }
1846
2345
  export {
2346
+ NotInitializedError,
2347
+ UnsupportedFeatureError,
1847
2348
  bitmarkToObjects,
1848
2349
  breakscapeText,
1849
- canonicalize2 as canonicalize,
1850
- convert2 as convert,
2350
+ canonicalize3 as canonicalize,
2351
+ convert3 as convert,
1851
2352
  countBits,
1852
- info2 as info,
2353
+ info3 as info,
1853
2354
  init,
1854
- initSync,
2355
+ initSync3 as initSync,
1855
2356
  legacy_exports as legacy,
1856
2357
  lex2 as lex,
1857
2358
  objectsToBitmark,
1858
2359
  patchEntry,
1859
2360
  splitBits,
1860
- transform2 as transform,
2361
+ transform3 as transform,
1861
2362
  transformParallel,
1862
2363
  unbreakscapeText,
2364
+ variant,
1863
2365
  version
1864
2366
  };
1865
2367
  //# sourceMappingURL=index.js.map