@gmb/bitmark-parser 6.2.0 → 6.3.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.
- package/README.md +105 -54
- package/dist/browser/bitmark-parser.min.js +4 -4
- package/dist/browser/bitmark-parser.min.js.map +1 -1
- package/dist/browser/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/index.cjs +128 -182
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +146 -117
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +146 -117
- package/dist/browser/esm/index.js +126 -176
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/esm/worker-entry.js.map +1 -1
- package/dist/index.cjs +59 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1912 -300
- package/dist/index.d.ts +1912 -300
- package/dist/index.js +57 -48
- package/dist/index.js.map +1 -1
- package/dist/legacy.cjs +40 -23
- package/dist/legacy.cjs.map +1 -1
- package/dist/legacy.d.cts +32 -14
- package/dist/legacy.d.ts +32 -14
- package/dist/legacy.js +40 -23
- package/dist/legacy.js.map +1 -1
- package/package.json +8 -7
- package/wasm/bitmark_wasm.d.ts +31 -53
- package/wasm/bitmark_wasm.js +115 -209
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +1 -4
- package/wasm/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../wasm-web/bitmark_wasm.js","../../../src/browser/worker-entry.ts"],"sourcesContent":["let wasm;\n\nlet WASM_VECTOR_LEN = 0;\n\nlet cachedUint8ArrayMemory0 = null;\n\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nconst cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachedDataViewMemory0 = null;\n\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nconst cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );\n\nif (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n/**\n * Lex bitmark input text, returning one line per token in the same format as\n * the Rust CLI: `{kind:?} {span:?} \"{text}\"`.\n *\n * `stage` selects the lexer pipeline:\n * - `\"lex\"` — combined (default)\n * - `\"lex-json\"` — combined, JSON array output\n * @param {string} input\n * @param {string} stage\n * @returns {string}\n */\nexport function lex(input, stage) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.lex(retptr, ptr0, len0, ptr1, len1);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Parse bitmark input text and return the reference JSON format.\n *\n * Uses the full pipeline: parse → validate → serialize.\n *\n * `mode`: `\"optimized\"` (default) or `\"full\"`\n * @param {string} input\n * @param {string} mode\n * @returns {string}\n */\nexport function parse(input, mode) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.parse(retptr, ptr0, len0, ptr1, len1);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * `format`: `\"bitmark++\"` (default) or `\"plainText\"`\n * `location`: `\"body\"` (default) or `\"tag\"`\n * @param {string} input\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function breakscape_text(input, format, location) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Unbreakscape text (unescape bitmark special characters).\n *\n * `format`: `\"bitmark++\"` (default) or `\"plainText\"`\n * `location`: `\"body\"` (default) or `\"tag\"`\n * @param {string} input\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function unbreakscape_text(input, format, location) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Split a JSON document (a top-level array of bit envelopes) into its per-bit\n * envelope objects, returned as a JSON array string. Lets a JS caller iterate\n * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).\n * Returns `error: …` if the input is not a JSON array of bits.\n * @param {string} input\n * @returns {string}\n */\nexport function split_json_bits(input) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n wasm.split_json_bits(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);\n }\n}\n\n/**\n * Pretty-print a compact JSON string with the given indent. Used to format a\n * document recombined on the JS side (the per-bit hook path) so its output\n * matches the in-Rust recombination byte-for-byte.\n * @param {string} json\n * @param {number} indent\n * @returns {string}\n */\nexport function prettify(json, indent) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n wasm.prettify(retptr, ptr0, len0, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);\n }\n}\n\n/**\n * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).\n *\n * `direction`: `\"textToAst\"` | `\"astToText\"` | `\"astToPlainText\"`.\n * `format`: a bitmark text format (`\"bitmark++\"`, `\"bitmark+\"`) parses\n * inline marks; anything else is treated as plain text (textToAst only).\n * `location`: `\"body\"` (default) or `\"tag\"`.\n * Returns the converted fragment, or `error: …`.\n * @param {string} input\n * @param {string} direction\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function convert_text(input, direction, format, location) {\n let deferred5_0;\n let deferred5_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len3 = WASM_VECTOR_LEN;\n wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred5_0 = r0;\n deferred5_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);\n }\n}\n\n/**\n * Apply a patch (a JSON array of patch entries) to every bit and re-emit.\n *\n * `input_format_sel`: `\"auto\"` | `\"bitmark\"` | `\"json\"`.\n * `output_format_sel`: `\"bitmark\"` | `\"json\"` (default json).\n * `patch_json`: the patch entry array (empty string = no patches, i.e. a\n * canonicalizing pass). Parallelism is a JS-side concern (web workers); this\n * runs sequentially. Returns the document text/JSON, or `error: …`.\n * @param {string} input\n * @param {string} input_format_sel\n * @param {string} output_format_sel\n * @param {string} mode\n * @param {string} patch_json\n * @param {boolean} pretty\n * @param {number} indent\n * @param {number} spaces_around_values\n * @returns {string}\n */\nexport function transform(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {\n let deferred6_0;\n let deferred6_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len3 = WASM_VECTOR_LEN;\n const ptr4 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len4 = WASM_VECTOR_LEN;\n wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred6_0 = r0;\n deferred6_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);\n }\n}\n\n/**\n * Query information about supported bit types.\n *\n * `info_type`: `\"list\"`, `\"bit\"`, `\"all\"`, or `\"deprecated\"`\n * `format`: `\"text\"` or `\"json\"`\n * `bit`: bit name (required when `info_type` is `\"bit\"`)\n * `pretty`: whether to pretty-print JSON output\n * `indent`: indent size for pretty-printing (default: 2)\n * @param {string} info_type\n * @param {string} format\n * @param {string} bit\n * @param {boolean} pretty\n * @param {number} indent\n * @returns {string}\n */\nexport function info(info_type, format, bit, pretty, indent) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Convert between bitmark and JSON with explicit input/output formats + mode.\n *\n * `input_format`: `\"auto\"` (default) | `\"bitmark\"` | `\"json\"`.\n * `output_format`: `\"auto\"` (opposite of input) | `\"bitmark\"` | `\"json\"`.\n * `mode`: `\"optimized\"` (default) | `\"full\"`.\n * Returns the converted text/JSON, or a string prefixed `error:` on failure.\n * @param {string} input\n * @param {string} input_format_sel\n * @param {string} output_format_sel\n * @param {string} mode\n * @param {boolean} pretty\n * @param {number} indent\n * @param {number} spaces_around_values\n * @returns {string}\n */\nexport function convert(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values) {\n let deferred5_0;\n let deferred5_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len3 = WASM_VECTOR_LEN;\n wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred5_0 = r0;\n deferred5_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);\n }\n}\n\n/**\n * Re-emit input in its own format at optimized mode (omit natural defaults).\n *\n * `input_format`: `\"auto\"` (default) | `\"bitmark\"` | `\"json\"` | any config\n * mapping id (`html`, `xml`, …). The output is re-emitted in this same format.\n * @param {string} input\n * @param {string} input_format_sel\n * @param {boolean} pretty\n * @param {number} indent\n * @returns {string}\n */\nexport function optimize(input, input_format_sel, pretty, indent) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.optimize(retptr, ptr0, len0, ptr1, len1, pretty, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Re-emit input in its own format at full mode (all keys).\n *\n * `input_format`: `\"auto\"` (default) | `\"bitmark\"` | `\"json\"` | any config\n * mapping id (`html`, `xml`, …). The output is re-emitted in this same format.\n * @param {string} input\n * @param {string} input_format_sel\n * @param {boolean} pretty\n * @param {number} indent\n * @returns {string}\n */\nexport function fullize(input, input_format_sel, pretty, indent) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.fullize(retptr, ptr0, len0, ptr1, len1, pretty, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Re-emit input in its own format in canonical form at `mode`.\n *\n * `input_format`: `\"auto\"` (default) | `\"bitmark\"` | `\"json\"` | any config\n * mapping id (`html`, `xml`, …). The output is re-emitted in this same format.\n * @param {string} input\n * @param {string} input_format_sel\n * @param {string} mode\n * @param {boolean} pretty\n * @param {number} indent\n * @param {number} spaces_around_values\n * @returns {string}\n */\nexport function canonicalize(input, input_format_sel, mode, pretty, indent, spaces_around_values) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Count the bits in `input` (auto-detecting bitmark vs JSON).\n * Returns the count as a decimal string, or `error: …`.\n * @param {string} input\n * @returns {string}\n */\nexport function count_bits(input) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n wasm.count_bits(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);\n }\n}\n\n/**\n * Split a bitmark document into per-bit source slices.\n *\n * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS\n * caller chunk a document at bit boundaries (e.g. to feed a worker pool).\n * @param {string} input\n * @returns {string}\n */\nexport function split_bits(input) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n wasm.split_bits(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);\n }\n}\n\n/**\n * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection\n * used across the API so a JS caller can resolve `\"auto\"` consistently.\n * @param {string} input\n * @returns {boolean}\n */\nexport function is_bitmark(input) {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.is_bitmark(ptr0, len0);\n return ret !== 0;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n 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);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n\n\n\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module !== 'undefined') {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module_or_path !== 'undefined') {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (typeof module_or_path === 'undefined') {\n module_or_path = new URL('bitmark_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync };\nexport default __wbg_init;\n","// @zen-component: TS-BrowserWorkerEntry\n//\n// Browser Worker entry for the parallel transform pool. Each module worker\n// loads its own WASM instance (lazily, on the first job) and computes one bit\n// at a time from a data-only job. Hooks (JS closures) never reach here — they\n// run on the main thread.\n\nimport wasmInit, * as wasm from \"../../wasm-web/bitmark_wasm.js\";\nimport type { BitJob } from \"../core/hooked-transform.js\";\n\n// Minimal dedicated-worker scope (avoids needing the WebWorker tsconfig lib).\nconst ctx = self as unknown as {\n postMessage(message: unknown): void;\n addEventListener(type: \"message\", listener: (ev: { data: unknown }) => void): void;\n};\n\nlet ready: Promise<unknown> | null = null;\nfunction ensureReady(): Promise<unknown> {\n // The .wasm is copied beside this bundle (see tsup config).\n if (!ready) ready = wasmInit(new URL(\"bitmark_wasm_bg.wasm\", import.meta.url));\n return ready;\n}\n\nfunction stripArray(doc: string): string {\n const t = doc.trim();\n return t.startsWith(\"[\") && t.endsWith(\"]\") ? t.slice(1, -1) : doc;\n}\n\nctx.addEventListener(\"message\", (ev) => {\n const { id, job } = ev.data as { id: number; job: BitJob };\n ensureReady()\n .then(() => {\n const out = wasm.transform(\n job.source,\n job.inputFormat,\n job.outputFormat,\n job.mode,\n job.patchJson,\n false,\n 2,\n job.spacesAroundValues,\n );\n if (out.startsWith(\"error:\")) {\n ctx.postMessage({ id, ok: false, error: out });\n return;\n }\n const element = job.outputFormat === \"json\" ? stripArray(out) : out;\n ctx.postMessage({ id, ok: true, element });\n })\n .catch((e: unknown) => {\n ctx.postMessage({ id, ok: false, error: `error: ${String(e)}` });\n });\n});\n"],"mappings":";AAAA,IAAI;AAEJ,IAAI,kBAAkB;AAEtB,IAAI,0BAA0B;AAE9B,SAAS,uBAAuB;AAC5B,MAAI,4BAA4B,QAAQ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A,MACJ,IAAI;AAAA,MACJ;AAAA,MACA;AAAA,MACA,IAAI;AAAA,IACN;AACA,QAAI,IAAI,WAAW,QAAQ,GAAG;AAC5B,UAAI,YAAY,EAAE,IAAI,IAAI,OAAO,OAAO,IAAI,CAAC;AAC7C;AAAA,IACF;AACA,UAAM,UAAU,IAAI,iBAAiB,SAAS,WAAW,GAAG,IAAI;AAChE,QAAI,YAAY,EAAE,IAAI,IAAI,MAAM,QAAQ,CAAC;AAAA,EAC3C,CAAC,EACA,MAAM,CAAC,MAAe;AACrB,QAAI,YAAY,EAAE,IAAI,IAAI,OAAO,OAAO,UAAU,OAAO,CAAC,CAAC,GAAG,CAAC;AAAA,EACjE,CAAC;AACL,CAAC;","names":["ptr"]}
|
|
1
|
+
{"version":3,"sources":["../../../wasm-web/bitmark_wasm.js","../../../src/browser/worker-entry.ts"],"sourcesContent":["let wasm;\n\nlet WASM_VECTOR_LEN = 0;\n\nlet cachedUint8ArrayMemory0 = null;\n\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nconst cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachedDataViewMemory0 = null;\n\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nconst cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );\n\nif (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n/**\n * Lex bitmark input text, returning one line per token in the same format as\n * the Rust CLI: `{kind:?} {span:?} \"{text}\"`.\n *\n * `stage` selects the lexer pipeline:\n * - `\"lex\"` — combined (default)\n * - `\"lex-json\"` — combined, JSON array output\n * @param {string} input\n * @param {string} stage\n * @returns {string}\n */\nexport function lex(input, stage) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.lex(retptr, ptr0, len0, ptr1, len1);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * `format`: `\"bitmark++\"` (default) or `\"plainText\"`\n * `location`: `\"body\"` (default) or `\"tag\"`\n * @param {string} input\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function breakscape_text(input, format, location) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Unbreakscape text (unescape bitmark special characters).\n *\n * `format`: `\"bitmark++\"` (default) or `\"plainText\"`\n * `location`: `\"body\"` (default) or `\"tag\"`\n * @param {string} input\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function unbreakscape_text(input, format, location) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Query information about supported bit types.\n *\n * `info_type`: `\"list\"`, `\"bit\"`, `\"all\"`, or `\"deprecated\"`\n * `format`: `\"text\"` or `\"json\"`\n * `bit`: bit name (required when `info_type` is `\"bit\"`)\n * `pretty`: whether to pretty-print JSON output\n * `indent`: indent size for pretty-printing (default: 2)\n * @param {string} info_type\n * @param {string} format\n * @param {string} bit\n * @param {boolean} pretty\n * @param {number} indent\n * @returns {string}\n */\nexport function info(info_type, format, bit, pretty, indent) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Apply a patch (a JSON array of patch entries) to every bit and re-emit.\n *\n * `input_format_sel`: `\"auto\"` | `\"bitmark\"` | `\"json\"`.\n * `output_format_sel`: `\"bitmark\"` | `\"json\"` (default json).\n * `patch_json`: the patch entry array (empty string = no patches, i.e. a\n * canonicalizing pass). Parallelism is a JS-side concern (web workers); this\n * runs sequentially. Returns the document text/JSON, or `error: …`.\n * @param {string} input\n * @param {string} input_format_sel\n * @param {string} output_format_sel\n * @param {string} mode\n * @param {string} patch_json\n * @param {boolean} pretty\n * @param {number} indent\n * @param {number} spaces_around_values\n * @returns {string}\n */\nexport function transform(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {\n let deferred6_0;\n let deferred6_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len3 = WASM_VECTOR_LEN;\n const ptr4 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len4 = WASM_VECTOR_LEN;\n wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred6_0 = r0;\n deferred6_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);\n }\n}\n\n/**\n * Convert between bitmark and JSON with explicit input/output formats + mode.\n *\n * `input_format`: `\"auto\"` (default) | `\"bitmark\"` | `\"json\"`.\n * `output_format`: `\"auto\"` (opposite of input) | `\"bitmark\"` | `\"json\"`.\n * `mode`: `\"optimized\"` (default) | `\"full\"`.\n * Returns the converted text/JSON, or a string prefixed `error:` on failure.\n * @param {string} input\n * @param {string} input_format_sel\n * @param {string} output_format_sel\n * @param {string} mode\n * @param {boolean} pretty\n * @param {number} indent\n * @param {number} spaces_around_values\n * @param {boolean} include_unknown_properties\n * @returns {string}\n */\nexport function convert(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties) {\n let deferred5_0;\n let deferred5_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len3 = WASM_VECTOR_LEN;\n wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred5_0 = r0;\n deferred5_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);\n }\n}\n\n/**\n * Re-emit input in its own format in canonical form at `mode`.\n *\n * `input_format`: `\"auto\"` (default) | `\"bitmark\"` | `\"json\"` | any config\n * mapping id (`html`, `xml`, …). The output is re-emitted in this same format.\n * @param {string} input\n * @param {string} input_format_sel\n * @param {string} mode\n * @param {boolean} pretty\n * @param {number} indent\n * @param {number} spaces_around_values\n * @returns {string}\n */\nexport function canonicalize(input, input_format_sel, mode, pretty, indent, spaces_around_values) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Count the bits in `input` (auto-detecting bitmark vs JSON).\n * Returns the count as a decimal string, or `error: …`.\n * @param {string} input\n * @returns {string}\n */\nexport function count_bits(input) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n wasm.count_bits(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);\n }\n}\n\n/**\n * Split a bitmark document into per-bit source slices.\n *\n * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS\n * caller chunk a document at bit boundaries (e.g. to feed a worker pool).\n * @param {string} input\n * @returns {string}\n */\nexport function split_bits(input) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n wasm.split_bits(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);\n }\n}\n\n/**\n * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection\n * used across the API so a JS caller can resolve `\"auto\"` consistently.\n * @param {string} input\n * @returns {boolean}\n */\nexport function is_bitmark(input) {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.is_bitmark(ptr0, len0);\n return ret !== 0;\n}\n\n/**\n * Split a JSON document (a top-level array of bit envelopes) into its per-bit\n * envelope objects, returned as a JSON array string. Lets a JS caller iterate\n * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).\n * Returns `error: …` if the input is not a JSON array of bits.\n * @param {string} input\n * @returns {string}\n */\nexport function split_json_bits(input) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n wasm.split_json_bits(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);\n }\n}\n\n/**\n * Pretty-print a compact JSON string with the given indent. Used to format a\n * document recombined on the JS side (the per-bit hook path) so its output\n * matches the in-Rust recombination byte-for-byte.\n * @param {string} json\n * @param {number} indent\n * @returns {string}\n */\nexport function prettify(json, indent) {\n let deferred2_0;\n let deferred2_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n wasm.prettify(retptr, ptr0, len0, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);\n }\n}\n\n/**\n * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).\n *\n * `direction`: `\"textToAst\"` | `\"astToText\"` | `\"astToPlainText\"`.\n * `format`: a bitmark text format (`\"bitmark++\"`, `\"bitmark+\"`) parses\n * inline marks; anything else is treated as plain text (textToAst only).\n * `location`: `\"body\"` (default) or `\"tag\"`.\n * Returns the converted fragment, or `error: …`.\n * @param {string} input\n * @param {string} direction\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function convert_text(input, direction, format, location) {\n let deferred5_0;\n let deferred5_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len3 = WASM_VECTOR_LEN;\n wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred5_0 = r0;\n deferred5_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);\n }\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n 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);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n\n\n\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module !== 'undefined') {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module_or_path !== 'undefined') {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (typeof module_or_path === 'undefined') {\n module_or_path = new URL('bitmark_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync };\nexport default __wbg_init;\n","// @zen-component: TS-BrowserWorkerEntry\n//\n// Browser Worker entry for the parallel transform pool. Each module worker\n// loads its own WASM instance (lazily, on the first job) and computes one bit\n// at a time from a data-only job. Hooks (JS closures) never reach here — they\n// run on the main thread.\n\nimport wasmInit, * as wasm from \"../../wasm-web/bitmark_wasm.js\";\nimport type { BitJob } from \"../core/hooked-transform.js\";\n\n// Minimal dedicated-worker scope (avoids needing the WebWorker tsconfig lib).\nconst ctx = self as unknown as {\n postMessage(message: unknown): void;\n addEventListener(type: \"message\", listener: (ev: { data: unknown }) => void): void;\n};\n\nlet ready: Promise<unknown> | null = null;\nfunction ensureReady(): Promise<unknown> {\n // The .wasm is copied beside this bundle (see tsup config).\n if (!ready) ready = wasmInit(new URL(\"bitmark_wasm_bg.wasm\", import.meta.url));\n return ready;\n}\n\nfunction stripArray(doc: string): string {\n const t = doc.trim();\n return t.startsWith(\"[\") && t.endsWith(\"]\") ? t.slice(1, -1) : doc;\n}\n\nctx.addEventListener(\"message\", (ev) => {\n const { id, job } = ev.data as { id: number; job: BitJob };\n ensureReady()\n .then(() => {\n const out = wasm.transform(\n job.source,\n job.inputFormat,\n job.outputFormat,\n job.mode,\n job.patchJson,\n false,\n 2,\n job.spacesAroundValues,\n );\n if (out.startsWith(\"error:\")) {\n ctx.postMessage({ id, ok: false, error: out });\n return;\n }\n const element = job.outputFormat === \"json\" ? stripArray(out) : out;\n ctx.postMessage({ id, ok: true, element });\n })\n .catch((e: unknown) => {\n ctx.postMessage({ id, ok: false, error: `error: ${String(e)}` });\n });\n});\n"],"mappings":";AAAA,IAAI;AAEJ,IAAI,kBAAkB;AAEtB,IAAI,0BAA0B;AAE9B,SAAS,uBAAuB;AAC5B,MAAI,4BAA4B,QAAQ,wBAAwB,eAAe,GAAG;AAC9E,8BAA0B,IAAI,WAAW,KAAK,OAAO,MAAM;AAAA,EAC/D;AACA,SAAO;AACX;AAEA,IAAM,oBAAqB,OAAO,gBAAgB,cAAc,IAAI,YA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AO,IAAI,CAAC;AAC7C;AAAA,IACF;AACA,UAAM,UAAU,IAAI,iBAAiB,SAAS,WAAW,GAAG,IAAI;AAChE,QAAI,YAAY,EAAE,IAAI,IAAI,MAAM,QAAQ,CAAC;AAAA,EAC3C,CAAC,EACA,MAAM,CAAC,MAAe;AACrB,QAAI,YAAY,EAAE,IAAI,IAAI,OAAO,OAAO,UAAU,OAAO,CAAC,CAAC,GAAG,CAAC;AAAA,EACjE,CAAC;AACL,CAAC;","names":["ptr"]}
|
package/dist/index.cjs
CHANGED
|
@@ -30,20 +30,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
bitmarkToObjects: () => bitmarkToObjects,
|
|
33
34
|
breakscapeText: () => breakscapeText,
|
|
34
35
|
canonicalize: () => canonicalize,
|
|
35
36
|
convert: () => convert,
|
|
36
37
|
countBits: () => countBits,
|
|
37
|
-
expand: () => expand,
|
|
38
|
-
fullize: () => fullize,
|
|
39
|
-
generate: () => generate,
|
|
40
|
-
generateBits: () => generateBits,
|
|
41
38
|
info: () => info,
|
|
42
39
|
legacy: () => legacy_exports,
|
|
43
40
|
lex: () => lex,
|
|
44
|
-
|
|
45
|
-
parse: () => parse,
|
|
46
|
-
parseBits: () => parseBits,
|
|
41
|
+
objectsToBitmark: () => objectsToBitmark,
|
|
47
42
|
patchEntry: () => patchEntry,
|
|
48
43
|
splitBits: () => splitBits,
|
|
49
44
|
transform: () => transform,
|
|
@@ -63,7 +58,7 @@ var import_node_module = require("module");
|
|
|
63
58
|
// src/generated/package_info.ts
|
|
64
59
|
var PACKAGE_INFO = {
|
|
65
60
|
"name": "@gmb/bitmark-parser",
|
|
66
|
-
"version": "6.
|
|
61
|
+
"version": "6.3.0",
|
|
67
62
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
68
63
|
"license": "ISC",
|
|
69
64
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -369,16 +364,14 @@ function validateVersionOptions(opts) {
|
|
|
369
364
|
}
|
|
370
365
|
function validateBitmarkOptions(o) {
|
|
371
366
|
if (o.explicitTextFormat) unsupportedOption("bitmarkOptions.explicitTextFormat");
|
|
372
|
-
if (o.
|
|
373
|
-
unsupportedOption("bitmarkOptions.
|
|
367
|
+
if (o.cardSetVersion === 1) {
|
|
368
|
+
unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
|
|
374
369
|
}
|
|
375
|
-
if (o.cardSetVersion === 1) unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
|
|
376
370
|
if (o.debugGenerationInline) unsupportedOption("bitmarkOptions.debugGenerationInline");
|
|
377
371
|
if (o.noBreakscaping) unsupportedOption("bitmarkOptions.noBreakscaping");
|
|
378
372
|
}
|
|
379
373
|
function validateJsonOptions(o) {
|
|
380
374
|
if (o.textAsPlainText) unsupportedOption("jsonOptions.textAsPlainText", V3_ONLY);
|
|
381
|
-
if (o.excludeUnknownProperties) unsupportedOption("jsonOptions.excludeUnknownProperties");
|
|
382
375
|
if (o.debugGenerationInline) unsupportedOption("jsonOptions.debugGenerationInline");
|
|
383
376
|
}
|
|
384
377
|
function prettyIndent(prettify) {
|
|
@@ -414,6 +407,14 @@ function isPseudoAst(v) {
|
|
|
414
407
|
return v !== null && typeof v === "object" && (PSEUDO_AST_MARKER in v || Array.isArray(v.bits));
|
|
415
408
|
}
|
|
416
409
|
|
|
410
|
+
// src/legacy/generated/resource-collection-keys.ts
|
|
411
|
+
var RESOURCE_COLLECTION_KEYS = {
|
|
412
|
+
"extractor-image": { key: "images", resourceType: "image" },
|
|
413
|
+
"extractor-image-collapsible": { key: "images", resourceType: "image" },
|
|
414
|
+
"images-logo-grave": { key: "logos", resourceType: "image" },
|
|
415
|
+
"prototype-images": { key: "images", resourceType: "image" }
|
|
416
|
+
};
|
|
417
|
+
|
|
417
418
|
// src/legacy/builder.ts
|
|
418
419
|
var BUILT_BIT_PARSER = /* @__PURE__ */ Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser");
|
|
419
420
|
var DATA_KEY_TO_JSON_KEY = {
|
|
@@ -458,10 +459,14 @@ var Builder = class {
|
|
|
458
459
|
* NOTE (documented divergences from bpg):
|
|
459
460
|
* - the return value is bit JSON, not bpg's internal AST node model;
|
|
460
461
|
* - `resourceType` (an inference hint in bpg) is not carried into the
|
|
461
|
-
* JSON — the attached `resource` object is authoritative
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
462
|
+
* JSON — the attached `resource` object is authoritative.
|
|
463
|
+
*
|
|
464
|
+
* `resources` follows bpg's JsonGenerator routing: on a bit whose config
|
|
465
|
+
* maps a repeatable resource tag group onto a collection key (e.g.
|
|
466
|
+
* `images` / `logos` — see the generated RESOURCE_COLLECTION_KEYS), the
|
|
467
|
+
* matching-type entries land under that key; on every other bit the first
|
|
468
|
+
* entry becomes the canonical single `resource` (as bpg: "if there is
|
|
469
|
+
* more than one resource, use the first one").
|
|
465
470
|
*/
|
|
466
471
|
buildBit(data, _options) {
|
|
467
472
|
const wasm2 = getLegacyWasm();
|
|
@@ -497,12 +502,15 @@ var Builder = class {
|
|
|
497
502
|
delete src.__isDefaultExample;
|
|
498
503
|
}
|
|
499
504
|
const resources = src.resources;
|
|
500
|
-
if (resources !== void 0) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
505
|
+
if (resources !== void 0 && bitType !== void 0) {
|
|
506
|
+
const list = Array.isArray(resources) ? resources : [resources];
|
|
507
|
+
const collection = RESOURCE_COLLECTION_KEYS[bitType];
|
|
508
|
+
if (collection) {
|
|
509
|
+
bit[collection.key] = list.filter(
|
|
510
|
+
(r) => r !== null && typeof r === "object" && r.type === collection.resourceType
|
|
511
|
+
);
|
|
512
|
+
} else if (list.length >= 1) {
|
|
513
|
+
bit.resource = list[0];
|
|
506
514
|
}
|
|
507
515
|
delete src.resources;
|
|
508
516
|
}
|
|
@@ -520,7 +528,7 @@ var Builder = class {
|
|
|
520
528
|
}
|
|
521
529
|
}
|
|
522
530
|
this.parseStringTexts(bit);
|
|
523
|
-
const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1);
|
|
531
|
+
const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false);
|
|
524
532
|
if (out.startsWith("error:")) {
|
|
525
533
|
throw new Error(out.slice("error:".length).trim());
|
|
526
534
|
}
|
|
@@ -644,8 +652,10 @@ var BitmarkParserGenerator = class {
|
|
|
644
652
|
const outputFormat = opts.outputFormat ?? (isBitmark ? "json" : "bitmark");
|
|
645
653
|
const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
|
|
646
654
|
const { pretty, indent } = prettyIndent(jsonOptions.prettify);
|
|
655
|
+
const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
|
|
647
656
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
648
|
-
const
|
|
657
|
+
const includeUnknown = !jsonOptions.excludeUnknownProperties;
|
|
658
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown);
|
|
649
659
|
this.throwOnError(out);
|
|
650
660
|
if (outputFormat === "bitmark" || outputFormat === "text") {
|
|
651
661
|
return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
@@ -675,7 +685,9 @@ var BitmarkParserGenerator = class {
|
|
|
675
685
|
this.checkBrowserFileWrite(opts.outputFile);
|
|
676
686
|
const wasm2 = getLegacyWasm();
|
|
677
687
|
const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
|
|
678
|
-
const { pretty, indent } = prettyIndent(
|
|
688
|
+
const { pretty, indent } = prettyIndent(
|
|
689
|
+
isBitmark ? bitmarkOptions.prettifyJson : jsonOptions.prettify
|
|
690
|
+
);
|
|
679
691
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
680
692
|
const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
|
|
681
693
|
this.throwOnError(out);
|
|
@@ -727,7 +739,7 @@ var BitmarkParserGenerator = class {
|
|
|
727
739
|
const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
|
|
728
740
|
if (!isHtmlInput) {
|
|
729
741
|
const { source, isBitmark } = this.resolveInput(input, void 0);
|
|
730
|
-
const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1);
|
|
742
|
+
const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false);
|
|
731
743
|
this.throwOnError(out2);
|
|
732
744
|
return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
|
|
733
745
|
}
|
|
@@ -737,12 +749,12 @@ var BitmarkParserGenerator = class {
|
|
|
737
749
|
const { pretty, indent } = prettyIndent(jsonOptions.prettify);
|
|
738
750
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
739
751
|
if (outputFormat === "html") {
|
|
740
|
-
const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1);
|
|
752
|
+
const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false);
|
|
741
753
|
this.throwOnError(out2);
|
|
742
754
|
return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
|
|
743
755
|
}
|
|
744
756
|
const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
|
|
745
|
-
const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces);
|
|
757
|
+
const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false);
|
|
746
758
|
this.throwOnError(out);
|
|
747
759
|
if (outputFormat === "bitmark" || outputFormat === "text") {
|
|
748
760
|
return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
@@ -767,7 +779,7 @@ var BitmarkParserGenerator = class {
|
|
|
767
779
|
const opts = Object.assign({}, options);
|
|
768
780
|
const wasm2 = getLegacyWasm();
|
|
769
781
|
const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
|
|
770
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1);
|
|
782
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true);
|
|
771
783
|
this.throwOnError(out);
|
|
772
784
|
return makePseudoAst(JSON.parse(out));
|
|
773
785
|
}
|
|
@@ -874,7 +886,7 @@ var BitmarkParserGenerator = class {
|
|
|
874
886
|
}
|
|
875
887
|
}
|
|
876
888
|
const { source, isBitmark } = this.resolveInput(input, void 0);
|
|
877
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1);
|
|
889
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false);
|
|
878
890
|
this.throwOnError(out);
|
|
879
891
|
return out;
|
|
880
892
|
}
|
|
@@ -1359,19 +1371,25 @@ function version() {
|
|
|
1359
1371
|
function lex(input, options = {}) {
|
|
1360
1372
|
return wasm.lex(input, options.stage ?? "lex");
|
|
1361
1373
|
}
|
|
1362
|
-
function
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1374
|
+
function bitmarkToObjects(input, options = {}) {
|
|
1375
|
+
const out = wasm.convert(
|
|
1376
|
+
input,
|
|
1377
|
+
"bitmark",
|
|
1378
|
+
"json",
|
|
1379
|
+
options.mode ?? "optimized",
|
|
1380
|
+
false,
|
|
1381
|
+
2,
|
|
1382
|
+
1,
|
|
1383
|
+
options.includeUnknownProperties ?? false
|
|
1384
|
+
);
|
|
1367
1385
|
if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
|
|
1368
1386
|
return JSON.parse(out);
|
|
1369
1387
|
}
|
|
1370
|
-
function
|
|
1388
|
+
function objectsToBitmark(bits, options = {}) {
|
|
1371
1389
|
const entries = bits.map(
|
|
1372
1390
|
(b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
|
|
1373
1391
|
);
|
|
1374
|
-
const out = wasm.convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1);
|
|
1392
|
+
const out = wasm.convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1, false);
|
|
1375
1393
|
if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
|
|
1376
1394
|
return out;
|
|
1377
1395
|
}
|
|
@@ -1383,16 +1401,10 @@ function convert(input, options = {}) {
|
|
|
1383
1401
|
options.mode ?? "optimized",
|
|
1384
1402
|
options.pretty ?? false,
|
|
1385
1403
|
options.indent ?? 2,
|
|
1386
|
-
options.spacesAroundValues ?? 1
|
|
1404
|
+
options.spacesAroundValues ?? 1,
|
|
1405
|
+
options.includeUnknownProperties ?? false
|
|
1387
1406
|
);
|
|
1388
1407
|
}
|
|
1389
|
-
function optimize(input, options = {}) {
|
|
1390
|
-
return wasm.optimize(input, options.inputFormat ?? "auto", options.pretty ?? false, options.indent ?? 2);
|
|
1391
|
-
}
|
|
1392
|
-
function fullize(input, options = {}) {
|
|
1393
|
-
return wasm.fullize(input, options.inputFormat ?? "auto", options.pretty ?? false, options.indent ?? 2);
|
|
1394
|
-
}
|
|
1395
|
-
var expand = fullize;
|
|
1396
1408
|
function canonicalize(input, options = {}) {
|
|
1397
1409
|
return wasm.canonicalize(
|
|
1398
1410
|
input,
|
|
@@ -1448,25 +1460,17 @@ function info(options = {}) {
|
|
|
1448
1460
|
const indent = options.indent ?? 2;
|
|
1449
1461
|
return wasm.info(infoType, format, bit, pretty, indent);
|
|
1450
1462
|
}
|
|
1451
|
-
function generate(input, options = {}) {
|
|
1452
|
-
return wasm.convert(input, "json", "bitmark", options.mode ?? "optimized", false, 2, 1);
|
|
1453
|
-
}
|
|
1454
1463
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1455
1464
|
0 && (module.exports = {
|
|
1465
|
+
bitmarkToObjects,
|
|
1456
1466
|
breakscapeText,
|
|
1457
1467
|
canonicalize,
|
|
1458
1468
|
convert,
|
|
1459
1469
|
countBits,
|
|
1460
|
-
expand,
|
|
1461
|
-
fullize,
|
|
1462
|
-
generate,
|
|
1463
|
-
generateBits,
|
|
1464
1470
|
info,
|
|
1465
1471
|
legacy,
|
|
1466
1472
|
lex,
|
|
1467
|
-
|
|
1468
|
-
parse,
|
|
1469
|
-
parseBits,
|
|
1473
|
+
objectsToBitmark,
|
|
1470
1474
|
patchEntry,
|
|
1471
1475
|
splitBits,
|
|
1472
1476
|
transform,
|