@gmb/bitmark-parser 6.10.0 → 6.11.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 (50) hide show
  1. package/README.md +194 -20
  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/cjs/index.cjs +726 -180
  5. package/dist/browser/cjs/index.cjs.map +1 -1
  6. package/dist/browser/cjs/index.d.cts +1031 -29
  7. package/dist/browser/esm/index.d.ts +1031 -29
  8. package/dist/browser/esm/index.js +723 -180
  9. package/dist/browser/esm/index.js.map +1 -1
  10. package/dist/browser/esm/worker-entry.js +599 -96
  11. package/dist/browser/esm/worker-entry.js.map +1 -1
  12. package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
  13. package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
  14. package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
  15. package/dist/index.cjs +52 -9
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +1031 -29
  18. package/dist/index.d.ts +1031 -29
  19. package/dist/index.js +49 -9
  20. package/dist/index.js.map +1 -1
  21. package/dist/legacy.cjs +4 -4
  22. package/dist/legacy.cjs.map +1 -1
  23. package/dist/legacy.js +4 -4
  24. package/dist/legacy.js.map +1 -1
  25. package/dist/worker-entry.cjs +7 -1
  26. package/dist/worker-entry.cjs.map +1 -1
  27. package/package.json +14 -8
  28. package/schema/bitmark.schema.json +2746 -573
  29. package/translations/translations.json +2940 -0
  30. package/wasm/bitmark_wasm.d.ts +30 -12
  31. package/wasm/bitmark_wasm.js +91 -47
  32. package/wasm/bitmark_wasm_bg.wasm +0 -0
  33. package/wasm/bitmark_wasm_bg.wasm.d.ts +2 -1
  34. package/wasm/package.json +1 -1
  35. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +30 -12
  36. package/wasm-bitmark-json/bitmark_json_wasm.js +97 -53
  37. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  38. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +2 -1
  39. package/wasm-bitmark-json/package.json +1 -1
  40. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +126 -0
  41. package/wasm-browser-full/bitmark_browser_full_wasm.js +567 -0
  42. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
  43. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +21 -0
  44. package/wasm-browser-full/package.json +20 -0
  45. package/dist/browser/bitmark_json_wasm_bg.wasm +0 -0
  46. package/dist/browser/bitmark_wasm_bg.wasm +0 -0
  47. package/dist/browser/cjs/bitmark_json_wasm_bg.wasm +0 -0
  48. package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
  49. package/dist/browser/esm/bitmark_json_wasm_bg.wasm +0 -0
  50. package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
@@ -0,0 +1,126 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Lex bitmark input text, returning one line per token in the same format as
5
+ * the Rust CLI: `{kind:?} {span:?} "{text}"`.
6
+ *
7
+ * `stage` selects the lexer pipeline:
8
+ * - `"lex"` — combined (default)
9
+ * - `"lex-json"` — combined, JSON array output
10
+ */
11
+ export function lex(input: string, stage: string): string;
12
+ /**
13
+ * Breakscape text (escape bitmark special characters).
14
+ *
15
+ * `format`: `"bitmark++"` (default) or `"plainText"`
16
+ * `location`: `"body"` (default) or `"tag"`
17
+ */
18
+ export function breakscape_text(input: string, format: string, location: string): string;
19
+ /**
20
+ * Unbreakscape text (unescape bitmark special characters).
21
+ *
22
+ * `format`: `"bitmark++"` (default) or `"plainText"`
23
+ * `location`: `"body"` (default) or `"tag"`
24
+ */
25
+ export function unbreakscape_text(input: string, format: string, location: string): string;
26
+ /**
27
+ * Query information about supported bit types.
28
+ *
29
+ * `info_type`: `"list"`, `"bit"`, `"all"`, `"deprecated"`, `"bit-groups"`,
30
+ * or `"resource-groups"`
31
+ * `format`: `"text"` or `"json"`
32
+ * `bit`: bit name (required when `info_type` is `"bit"`)
33
+ * `pretty`: whether to pretty-print JSON output
34
+ * `indent`: indent size for pretty-printing (default: 2)
35
+ * `include_deprecated`: include deprecated bits in `list`/`all` (PLAN-149)
36
+ * `only_deprecated`: restrict `list`/`all` to deprecated bits (wins over
37
+ * `include_deprecated`)
38
+ * `full`: complete outline for `bit`/`all` (default is the compact
39
+ * one-line-per-tag view)
40
+ * `language`: BCP-47 tag(s) for display names — "" = English, `"de,fr"` for
41
+ * several (adds a `titles` map), `"all"` for every resolvable language
42
+ */
43
+ export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number, include_deprecated: boolean, only_deprecated: boolean, full: boolean, language: string): string;
44
+ /**
45
+ * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).
46
+ *
47
+ * `direction`: `"textToAst"` | `"astToText"` | `"astToPlainText"`.
48
+ * `format`: a bitmark text format (`"bitmark++"`, `"bitmark+"`) parses
49
+ * inline marks; anything else is treated as plain text (textToAst only).
50
+ * `location`: `"body"` (default) or `"tag"`.
51
+ * Returns the converted fragment, or `error: …`.
52
+ */
53
+ export function convert_text(input: string, direction: string, format: string, location: string): string;
54
+ /**
55
+ * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
56
+ *
57
+ * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
58
+ * `output_format_sel`: `"bitmark"` | `"json"` (default json).
59
+ * `patch_json`: the patch entry array (empty string = no patches, i.e. a
60
+ * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
61
+ * runs sequentially. Returns the document text/JSON, or `error: …`.
62
+ */
63
+ export function transform(input: string, input_format_sel: string, output_format_sel: string, mode: string, patch_json: string, pretty: boolean, indent: number, spaces_around_values: number): string;
64
+ /**
65
+ * Register data with the parser process (PLAN-173 P12).
66
+ *
67
+ * `data_type`: `"translations"` today. One verb rather than one function per
68
+ * registerable thing — the same discriminated-options idiom as `info`.
69
+ *
70
+ * `data` is the file's own text. Semantics are REPLACE: a second call
71
+ * supersedes the first entirely, and the built-in table (where the variant
72
+ * bakes one) stays underneath. Returns `""` on success, or an
73
+ * `error:`-prefixed message — matching the other string-returning exports.
74
+ *
75
+ * Available in EVERY variant, including those that bake nothing: that is
76
+ * exactly where a consumer must supply the file themselves.
77
+ */
78
+ export function register(data_type: string, data: string): string;
79
+ /**
80
+ * Convert between bitmark and JSON with explicit input/output formats + mode.
81
+ *
82
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
83
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
84
+ * `mode`: `"optimized"` (default) | `"full"`.
85
+ * `mapping_report`: replace the output with a human-readable report of the
86
+ * input→output mappings, including inputs that are NOT mapped (PLAN-147).
87
+ * Returns the converted text/JSON, or a string prefixed `error:` on failure.
88
+ */
89
+ export function convert(input: string, input_format_sel: string, output_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number, include_unknown_properties: boolean, mapping_report: boolean): string;
90
+ /**
91
+ * Re-emit input in its own format in canonical form at `mode`.
92
+ *
93
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"` | any config
94
+ * mapping id (`html`, `xml`, …). The output is re-emitted in this same format.
95
+ */
96
+ export function canonicalize(input: string, input_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number): string;
97
+ /**
98
+ * Count the bits in `input` (auto-detecting bitmark vs JSON).
99
+ * Returns the count as a decimal string, or `error: …`.
100
+ */
101
+ export function count_bits(input: string): string;
102
+ /**
103
+ * Split a bitmark document into per-bit source slices.
104
+ *
105
+ * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
106
+ * caller chunk a document at bit boundaries (e.g. to feed a worker pool).
107
+ */
108
+ export function split_bits(input: string): string;
109
+ /**
110
+ * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
111
+ * used across the API so a JS caller can resolve `"auto"` consistently.
112
+ */
113
+ export function is_bitmark(input: string): boolean;
114
+ /**
115
+ * Split a JSON document (a top-level array of bit envelopes) into its per-bit
116
+ * envelope objects, returned as a JSON array string. Lets a JS caller iterate
117
+ * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
118
+ * Returns `error: …` if the input is not a JSON array of bits.
119
+ */
120
+ export function split_json_bits(input: string): string;
121
+ /**
122
+ * Pretty-print a compact JSON string with the given indent. Used to format a
123
+ * document recombined on the JS side (the per-bit hook path) so its output
124
+ * matches the in-Rust recombination byte-for-byte.
125
+ */
126
+ export function prettify(json: string, indent: number): string;
@@ -0,0 +1,567 @@
1
+
2
+ let imports = {};
3
+ let wasm;
4
+ const { TextEncoder, TextDecoder } = require(`util`);
5
+
6
+ let WASM_VECTOR_LEN = 0;
7
+
8
+ let cachedUint8ArrayMemory0 = null;
9
+
10
+ function getUint8ArrayMemory0() {
11
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
12
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
13
+ }
14
+ return cachedUint8ArrayMemory0;
15
+ }
16
+
17
+ let cachedTextEncoder = new TextEncoder('utf-8');
18
+
19
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
20
+ ? function (arg, view) {
21
+ return cachedTextEncoder.encodeInto(arg, view);
22
+ }
23
+ : function (arg, view) {
24
+ const buf = cachedTextEncoder.encode(arg);
25
+ view.set(buf);
26
+ return {
27
+ read: arg.length,
28
+ written: buf.length
29
+ };
30
+ });
31
+
32
+ function passStringToWasm0(arg, malloc, realloc) {
33
+
34
+ if (realloc === undefined) {
35
+ const buf = cachedTextEncoder.encode(arg);
36
+ const ptr = malloc(buf.length, 1) >>> 0;
37
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
38
+ WASM_VECTOR_LEN = buf.length;
39
+ return ptr;
40
+ }
41
+
42
+ let len = arg.length;
43
+ let ptr = malloc(len, 1) >>> 0;
44
+
45
+ const mem = getUint8ArrayMemory0();
46
+
47
+ let offset = 0;
48
+
49
+ for (; offset < len; offset++) {
50
+ const code = arg.charCodeAt(offset);
51
+ if (code > 0x7F) break;
52
+ mem[ptr + offset] = code;
53
+ }
54
+
55
+ if (offset !== len) {
56
+ if (offset !== 0) {
57
+ arg = arg.slice(offset);
58
+ }
59
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
60
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
61
+ const ret = encodeString(arg, view);
62
+
63
+ offset += ret.written;
64
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
65
+ }
66
+
67
+ WASM_VECTOR_LEN = offset;
68
+ return ptr;
69
+ }
70
+
71
+ let cachedDataViewMemory0 = null;
72
+
73
+ function getDataViewMemory0() {
74
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
75
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
76
+ }
77
+ return cachedDataViewMemory0;
78
+ }
79
+
80
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
81
+
82
+ cachedTextDecoder.decode();
83
+
84
+ function getStringFromWasm0(ptr, len) {
85
+ ptr = ptr >>> 0;
86
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
87
+ }
88
+ /**
89
+ * Lex bitmark input text, returning one line per token in the same format as
90
+ * the Rust CLI: `{kind:?} {span:?} "{text}"`.
91
+ *
92
+ * `stage` selects the lexer pipeline:
93
+ * - `"lex"` — combined (default)
94
+ * - `"lex-json"` — combined, JSON array output
95
+ * @param {string} input
96
+ * @param {string} stage
97
+ * @returns {string}
98
+ */
99
+ module.exports.lex = function(input, stage) {
100
+ let deferred3_0;
101
+ let deferred3_1;
102
+ try {
103
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
104
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
105
+ const len0 = WASM_VECTOR_LEN;
106
+ const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
107
+ const len1 = WASM_VECTOR_LEN;
108
+ wasm.lex(retptr, ptr0, len0, ptr1, len1);
109
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
110
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
111
+ deferred3_0 = r0;
112
+ deferred3_1 = r1;
113
+ return getStringFromWasm0(r0, r1);
114
+ } finally {
115
+ wasm.__wbindgen_add_to_stack_pointer(16);
116
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
117
+ }
118
+ };
119
+
120
+ /**
121
+ * Breakscape text (escape bitmark special characters).
122
+ *
123
+ * `format`: `"bitmark++"` (default) or `"plainText"`
124
+ * `location`: `"body"` (default) or `"tag"`
125
+ * @param {string} input
126
+ * @param {string} format
127
+ * @param {string} location
128
+ * @returns {string}
129
+ */
130
+ module.exports.breakscape_text = function(input, format, location) {
131
+ let deferred4_0;
132
+ let deferred4_1;
133
+ try {
134
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
135
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
136
+ const len0 = WASM_VECTOR_LEN;
137
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
138
+ const len1 = WASM_VECTOR_LEN;
139
+ const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
140
+ const len2 = WASM_VECTOR_LEN;
141
+ wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
142
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
143
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
144
+ deferred4_0 = r0;
145
+ deferred4_1 = r1;
146
+ return getStringFromWasm0(r0, r1);
147
+ } finally {
148
+ wasm.__wbindgen_add_to_stack_pointer(16);
149
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
150
+ }
151
+ };
152
+
153
+ /**
154
+ * Unbreakscape text (unescape bitmark special characters).
155
+ *
156
+ * `format`: `"bitmark++"` (default) or `"plainText"`
157
+ * `location`: `"body"` (default) or `"tag"`
158
+ * @param {string} input
159
+ * @param {string} format
160
+ * @param {string} location
161
+ * @returns {string}
162
+ */
163
+ module.exports.unbreakscape_text = function(input, format, location) {
164
+ let deferred4_0;
165
+ let deferred4_1;
166
+ try {
167
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
168
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
169
+ const len0 = WASM_VECTOR_LEN;
170
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
171
+ const len1 = WASM_VECTOR_LEN;
172
+ const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
173
+ const len2 = WASM_VECTOR_LEN;
174
+ wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
175
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
176
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
177
+ deferred4_0 = r0;
178
+ deferred4_1 = r1;
179
+ return getStringFromWasm0(r0, r1);
180
+ } finally {
181
+ wasm.__wbindgen_add_to_stack_pointer(16);
182
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
183
+ }
184
+ };
185
+
186
+ /**
187
+ * Query information about supported bit types.
188
+ *
189
+ * `info_type`: `"list"`, `"bit"`, `"all"`, `"deprecated"`, `"bit-groups"`,
190
+ * or `"resource-groups"`
191
+ * `format`: `"text"` or `"json"`
192
+ * `bit`: bit name (required when `info_type` is `"bit"`)
193
+ * `pretty`: whether to pretty-print JSON output
194
+ * `indent`: indent size for pretty-printing (default: 2)
195
+ * `include_deprecated`: include deprecated bits in `list`/`all` (PLAN-149)
196
+ * `only_deprecated`: restrict `list`/`all` to deprecated bits (wins over
197
+ * `include_deprecated`)
198
+ * `full`: complete outline for `bit`/`all` (default is the compact
199
+ * one-line-per-tag view)
200
+ * `language`: BCP-47 tag(s) for display names — "" = English, `"de,fr"` for
201
+ * several (adds a `titles` map), `"all"` for every resolvable language
202
+ * @param {string} info_type
203
+ * @param {string} format
204
+ * @param {string} bit
205
+ * @param {boolean} pretty
206
+ * @param {number} indent
207
+ * @param {boolean} include_deprecated
208
+ * @param {boolean} only_deprecated
209
+ * @param {boolean} full
210
+ * @param {string} language
211
+ * @returns {string}
212
+ */
213
+ module.exports.info = function(info_type, format, bit, pretty, indent, include_deprecated, only_deprecated, full, language) {
214
+ let deferred5_0;
215
+ let deferred5_1;
216
+ try {
217
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
218
+ const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
219
+ const len0 = WASM_VECTOR_LEN;
220
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
221
+ const len1 = WASM_VECTOR_LEN;
222
+ const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
223
+ const len2 = WASM_VECTOR_LEN;
224
+ const ptr3 = passStringToWasm0(language, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
225
+ const len3 = WASM_VECTOR_LEN;
226
+ wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, include_deprecated, only_deprecated, full, ptr3, len3);
227
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
228
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
229
+ deferred5_0 = r0;
230
+ deferred5_1 = r1;
231
+ return getStringFromWasm0(r0, r1);
232
+ } finally {
233
+ wasm.__wbindgen_add_to_stack_pointer(16);
234
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
235
+ }
236
+ };
237
+
238
+ /**
239
+ * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).
240
+ *
241
+ * `direction`: `"textToAst"` | `"astToText"` | `"astToPlainText"`.
242
+ * `format`: a bitmark text format (`"bitmark++"`, `"bitmark+"`) parses
243
+ * inline marks; anything else is treated as plain text (textToAst only).
244
+ * `location`: `"body"` (default) or `"tag"`.
245
+ * Returns the converted fragment, or `error: …`.
246
+ * @param {string} input
247
+ * @param {string} direction
248
+ * @param {string} format
249
+ * @param {string} location
250
+ * @returns {string}
251
+ */
252
+ module.exports.convert_text = function(input, direction, format, location) {
253
+ let deferred5_0;
254
+ let deferred5_1;
255
+ try {
256
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
257
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
258
+ const len0 = WASM_VECTOR_LEN;
259
+ const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
260
+ const len1 = WASM_VECTOR_LEN;
261
+ const ptr2 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
262
+ const len2 = WASM_VECTOR_LEN;
263
+ const ptr3 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
264
+ const len3 = WASM_VECTOR_LEN;
265
+ wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
266
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
267
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
268
+ deferred5_0 = r0;
269
+ deferred5_1 = r1;
270
+ return getStringFromWasm0(r0, r1);
271
+ } finally {
272
+ wasm.__wbindgen_add_to_stack_pointer(16);
273
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
274
+ }
275
+ };
276
+
277
+ /**
278
+ * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
279
+ *
280
+ * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
281
+ * `output_format_sel`: `"bitmark"` | `"json"` (default json).
282
+ * `patch_json`: the patch entry array (empty string = no patches, i.e. a
283
+ * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
284
+ * runs sequentially. Returns the document text/JSON, or `error: …`.
285
+ * @param {string} input
286
+ * @param {string} input_format_sel
287
+ * @param {string} output_format_sel
288
+ * @param {string} mode
289
+ * @param {string} patch_json
290
+ * @param {boolean} pretty
291
+ * @param {number} indent
292
+ * @param {number} spaces_around_values
293
+ * @returns {string}
294
+ */
295
+ module.exports.transform = function(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
296
+ let deferred6_0;
297
+ let deferred6_1;
298
+ try {
299
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
300
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
301
+ const len0 = WASM_VECTOR_LEN;
302
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
303
+ const len1 = WASM_VECTOR_LEN;
304
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
305
+ const len2 = WASM_VECTOR_LEN;
306
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
307
+ const len3 = WASM_VECTOR_LEN;
308
+ const ptr4 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
309
+ const len4 = WASM_VECTOR_LEN;
310
+ wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
311
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
312
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
313
+ deferred6_0 = r0;
314
+ deferred6_1 = r1;
315
+ return getStringFromWasm0(r0, r1);
316
+ } finally {
317
+ wasm.__wbindgen_add_to_stack_pointer(16);
318
+ wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
319
+ }
320
+ };
321
+
322
+ /**
323
+ * Register data with the parser process (PLAN-173 P12).
324
+ *
325
+ * `data_type`: `"translations"` today. One verb rather than one function per
326
+ * registerable thing — the same discriminated-options idiom as `info`.
327
+ *
328
+ * `data` is the file's own text. Semantics are REPLACE: a second call
329
+ * supersedes the first entirely, and the built-in table (where the variant
330
+ * bakes one) stays underneath. Returns `""` on success, or an
331
+ * `error:`-prefixed message — matching the other string-returning exports.
332
+ *
333
+ * Available in EVERY variant, including those that bake nothing: that is
334
+ * exactly where a consumer must supply the file themselves.
335
+ * @param {string} data_type
336
+ * @param {string} data
337
+ * @returns {string}
338
+ */
339
+ module.exports.register = function(data_type, data) {
340
+ let deferred3_0;
341
+ let deferred3_1;
342
+ try {
343
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
344
+ const ptr0 = passStringToWasm0(data_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
345
+ const len0 = WASM_VECTOR_LEN;
346
+ const ptr1 = passStringToWasm0(data, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
347
+ const len1 = WASM_VECTOR_LEN;
348
+ wasm.register(retptr, ptr0, len0, ptr1, len1);
349
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
350
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
351
+ deferred3_0 = r0;
352
+ deferred3_1 = r1;
353
+ return getStringFromWasm0(r0, r1);
354
+ } finally {
355
+ wasm.__wbindgen_add_to_stack_pointer(16);
356
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
357
+ }
358
+ };
359
+
360
+ /**
361
+ * Convert between bitmark and JSON with explicit input/output formats + mode.
362
+ *
363
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
364
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
365
+ * `mode`: `"optimized"` (default) | `"full"`.
366
+ * `mapping_report`: replace the output with a human-readable report of the
367
+ * input→output mappings, including inputs that are NOT mapped (PLAN-147).
368
+ * Returns the converted text/JSON, or a string prefixed `error:` on failure.
369
+ * @param {string} input
370
+ * @param {string} input_format_sel
371
+ * @param {string} output_format_sel
372
+ * @param {string} mode
373
+ * @param {boolean} pretty
374
+ * @param {number} indent
375
+ * @param {number} spaces_around_values
376
+ * @param {boolean} include_unknown_properties
377
+ * @param {boolean} mapping_report
378
+ * @returns {string}
379
+ */
380
+ module.exports.convert = function(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report) {
381
+ let deferred5_0;
382
+ let deferred5_1;
383
+ try {
384
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
385
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
386
+ const len0 = WASM_VECTOR_LEN;
387
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
388
+ const len1 = WASM_VECTOR_LEN;
389
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
390
+ const len2 = WASM_VECTOR_LEN;
391
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
392
+ const len3 = WASM_VECTOR_LEN;
393
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report);
394
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
395
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
396
+ deferred5_0 = r0;
397
+ deferred5_1 = r1;
398
+ return getStringFromWasm0(r0, r1);
399
+ } finally {
400
+ wasm.__wbindgen_add_to_stack_pointer(16);
401
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
402
+ }
403
+ };
404
+
405
+ /**
406
+ * Re-emit input in its own format in canonical form at `mode`.
407
+ *
408
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"` | any config
409
+ * mapping id (`html`, `xml`, …). The output is re-emitted in this same format.
410
+ * @param {string} input
411
+ * @param {string} input_format_sel
412
+ * @param {string} mode
413
+ * @param {boolean} pretty
414
+ * @param {number} indent
415
+ * @param {number} spaces_around_values
416
+ * @returns {string}
417
+ */
418
+ module.exports.canonicalize = function(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
419
+ let deferred4_0;
420
+ let deferred4_1;
421
+ try {
422
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
423
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
424
+ const len0 = WASM_VECTOR_LEN;
425
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
426
+ const len1 = WASM_VECTOR_LEN;
427
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
428
+ const len2 = WASM_VECTOR_LEN;
429
+ wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
430
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
431
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
432
+ deferred4_0 = r0;
433
+ deferred4_1 = r1;
434
+ return getStringFromWasm0(r0, r1);
435
+ } finally {
436
+ wasm.__wbindgen_add_to_stack_pointer(16);
437
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
438
+ }
439
+ };
440
+
441
+ /**
442
+ * Count the bits in `input` (auto-detecting bitmark vs JSON).
443
+ * Returns the count as a decimal string, or `error: …`.
444
+ * @param {string} input
445
+ * @returns {string}
446
+ */
447
+ module.exports.count_bits = function(input) {
448
+ let deferred2_0;
449
+ let deferred2_1;
450
+ try {
451
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
452
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
453
+ const len0 = WASM_VECTOR_LEN;
454
+ wasm.count_bits(retptr, ptr0, len0);
455
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
456
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
457
+ deferred2_0 = r0;
458
+ deferred2_1 = r1;
459
+ return getStringFromWasm0(r0, r1);
460
+ } finally {
461
+ wasm.__wbindgen_add_to_stack_pointer(16);
462
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
463
+ }
464
+ };
465
+
466
+ /**
467
+ * Split a bitmark document into per-bit source slices.
468
+ *
469
+ * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
470
+ * caller chunk a document at bit boundaries (e.g. to feed a worker pool).
471
+ * @param {string} input
472
+ * @returns {string}
473
+ */
474
+ module.exports.split_bits = function(input) {
475
+ let deferred2_0;
476
+ let deferred2_1;
477
+ try {
478
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
479
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
480
+ const len0 = WASM_VECTOR_LEN;
481
+ wasm.split_bits(retptr, ptr0, len0);
482
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
483
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
484
+ deferred2_0 = r0;
485
+ deferred2_1 = r1;
486
+ return getStringFromWasm0(r0, r1);
487
+ } finally {
488
+ wasm.__wbindgen_add_to_stack_pointer(16);
489
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
490
+ }
491
+ };
492
+
493
+ /**
494
+ * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
495
+ * used across the API so a JS caller can resolve `"auto"` consistently.
496
+ * @param {string} input
497
+ * @returns {boolean}
498
+ */
499
+ module.exports.is_bitmark = function(input) {
500
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
501
+ const len0 = WASM_VECTOR_LEN;
502
+ const ret = wasm.is_bitmark(ptr0, len0);
503
+ return ret !== 0;
504
+ };
505
+
506
+ /**
507
+ * Split a JSON document (a top-level array of bit envelopes) into its per-bit
508
+ * envelope objects, returned as a JSON array string. Lets a JS caller iterate
509
+ * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
510
+ * Returns `error: …` if the input is not a JSON array of bits.
511
+ * @param {string} input
512
+ * @returns {string}
513
+ */
514
+ module.exports.split_json_bits = function(input) {
515
+ let deferred2_0;
516
+ let deferred2_1;
517
+ try {
518
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
519
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
520
+ const len0 = WASM_VECTOR_LEN;
521
+ wasm.split_json_bits(retptr, ptr0, len0);
522
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
523
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
524
+ deferred2_0 = r0;
525
+ deferred2_1 = r1;
526
+ return getStringFromWasm0(r0, r1);
527
+ } finally {
528
+ wasm.__wbindgen_add_to_stack_pointer(16);
529
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
530
+ }
531
+ };
532
+
533
+ /**
534
+ * Pretty-print a compact JSON string with the given indent. Used to format a
535
+ * document recombined on the JS side (the per-bit hook path) so its output
536
+ * matches the in-Rust recombination byte-for-byte.
537
+ * @param {string} json
538
+ * @param {number} indent
539
+ * @returns {string}
540
+ */
541
+ module.exports.prettify = function(json, indent) {
542
+ let deferred2_0;
543
+ let deferred2_1;
544
+ try {
545
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
546
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
547
+ const len0 = WASM_VECTOR_LEN;
548
+ wasm.prettify(retptr, ptr0, len0, indent);
549
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
550
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
551
+ deferred2_0 = r0;
552
+ deferred2_1 = r1;
553
+ return getStringFromWasm0(r0, r1);
554
+ } finally {
555
+ wasm.__wbindgen_add_to_stack_pointer(16);
556
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
557
+ }
558
+ };
559
+
560
+ const path = require('path').join(__dirname, 'bitmark_browser_full_wasm_bg.wasm');
561
+ const bytes = require('fs').readFileSync(path);
562
+
563
+ const wasmModule = new WebAssembly.Module(bytes);
564
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
565
+ wasm = wasmInstance.exports;
566
+ module.exports.__wasm = wasm;
567
+