@gmb/bitmark-parser 6.8.0 → 6.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +74 -5
  2. package/dist/browser/bitmark-parser.min.js +4 -4
  3. package/dist/browser/bitmark-parser.min.js.map +1 -1
  4. package/dist/browser/bitmark_json_wasm_bg.wasm +0 -0
  5. package/dist/browser/bitmark_wasm_bg.wasm +0 -0
  6. package/dist/browser/cjs/bitmark_json_wasm_bg.wasm +0 -0
  7. package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
  8. package/dist/browser/cjs/index.cjs +624 -116
  9. package/dist/browser/cjs/index.cjs.map +1 -1
  10. package/dist/browser/cjs/index.d.cts +3423 -3054
  11. package/dist/browser/esm/bitmark_json_wasm_bg.wasm +0 -0
  12. package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
  13. package/dist/browser/esm/index.d.ts +3423 -3054
  14. package/dist/browser/esm/index.js +621 -116
  15. package/dist/browser/esm/index.js.map +1 -1
  16. package/dist/browser/esm/worker-entry.js +704 -7
  17. package/dist/browser/esm/worker-entry.js.map +1 -1
  18. package/dist/index.cjs +158 -86
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1209 -879
  21. package/dist/index.d.ts +1209 -879
  22. package/dist/index.js +153 -86
  23. package/dist/index.js.map +1 -1
  24. package/dist/legacy.cjs +13 -13
  25. package/dist/legacy.cjs.map +1 -1
  26. package/dist/legacy.d.cts +3 -1
  27. package/dist/legacy.d.ts +3 -1
  28. package/dist/legacy.js +13 -13
  29. package/dist/legacy.js.map +1 -1
  30. package/dist/worker-entry.cjs +6 -1
  31. package/dist/worker-entry.cjs.map +1 -1
  32. package/package.json +8 -7
  33. package/schema/bitmark.schema.json +3778 -2828
  34. package/wasm/bitmark_wasm.d.ts +6 -1
  35. package/wasm/bitmark_wasm.js +10 -2
  36. package/wasm/bitmark_wasm_bg.wasm +0 -0
  37. package/wasm/bitmark_wasm_bg.wasm.d.ts +1 -1
  38. package/wasm/package.json +1 -1
  39. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +99 -0
  40. package/wasm-bitmark-json/bitmark_json_wasm.js +491 -0
  41. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  42. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +19 -0
  43. package/wasm-bitmark-json/package.json +20 -0
@@ -31,8 +31,13 @@ export function unbreakscape_text(input: string, format: string, location: strin
31
31
  * `bit`: bit name (required when `info_type` is `"bit"`)
32
32
  * `pretty`: whether to pretty-print JSON output
33
33
  * `indent`: indent size for pretty-printing (default: 2)
34
+ * `include_deprecated`: include deprecated bits in `list`/`all` (PLAN-149)
35
+ * `only_deprecated`: restrict `list`/`all` to deprecated bits (wins over
36
+ * `include_deprecated`)
37
+ * `full`: complete outline for `bit`/`all` (default is the compact
38
+ * one-line-per-tag view)
34
39
  */
35
- export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number): string;
40
+ export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number, include_deprecated: boolean, only_deprecated: boolean, full: boolean): string;
36
41
  /**
37
42
  * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
38
43
  *
@@ -191,14 +191,22 @@ module.exports.unbreakscape_text = function(input, format, location) {
191
191
  * `bit`: bit name (required when `info_type` is `"bit"`)
192
192
  * `pretty`: whether to pretty-print JSON output
193
193
  * `indent`: indent size for pretty-printing (default: 2)
194
+ * `include_deprecated`: include deprecated bits in `list`/`all` (PLAN-149)
195
+ * `only_deprecated`: restrict `list`/`all` to deprecated bits (wins over
196
+ * `include_deprecated`)
197
+ * `full`: complete outline for `bit`/`all` (default is the compact
198
+ * one-line-per-tag view)
194
199
  * @param {string} info_type
195
200
  * @param {string} format
196
201
  * @param {string} bit
197
202
  * @param {boolean} pretty
198
203
  * @param {number} indent
204
+ * @param {boolean} include_deprecated
205
+ * @param {boolean} only_deprecated
206
+ * @param {boolean} full
199
207
  * @returns {string}
200
208
  */
201
- module.exports.info = function(info_type, format, bit, pretty, indent) {
209
+ module.exports.info = function(info_type, format, bit, pretty, indent, include_deprecated, only_deprecated, full) {
202
210
  let deferred4_0;
203
211
  let deferred4_1;
204
212
  try {
@@ -209,7 +217,7 @@ module.exports.info = function(info_type, format, bit, pretty, indent) {
209
217
  const len1 = WASM_VECTOR_LEN;
210
218
  const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
211
219
  const len2 = WASM_VECTOR_LEN;
212
- wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
220
+ wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, include_deprecated, only_deprecated, full);
213
221
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
214
222
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
215
223
  deferred4_0 = r0;
Binary file
@@ -6,7 +6,7 @@ export const canonicalize: (a: number, b: number, c: number, d: number, e: numbe
6
6
  export const convert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number) => void;
7
7
  export const convert_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
8
8
  export const count_bits: (a: number, b: number, c: number) => void;
9
- export const info: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
9
+ export const info: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
10
10
  export const is_bitmark: (a: number, b: number) => number;
11
11
  export const lex: (a: number, b: number, c: number, d: number, e: number) => void;
12
12
  export const prettify: (a: number, b: number, c: number, d: number) => void;
package/wasm/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "Get More Brain Ltd <info@getmorebrain.com>"
5
5
  ],
6
6
  "description": "WebAssembly bindings for the bitmark parser",
7
- "version": "6.8.0",
7
+ "version": "6.10.0",
8
8
  "license": "ISC",
9
9
  "repository": {
10
10
  "type": "git",
@@ -0,0 +1,99 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Breakscape text (escape bitmark special characters).
5
+ *
6
+ * `format`: `"bitmark++"` (default) or `"plainText"`
7
+ * `location`: `"body"` (default) or `"tag"`
8
+ */
9
+ export function breakscape_text(input: string, format: string, location: string): string;
10
+ /**
11
+ * Unbreakscape text (unescape bitmark special characters).
12
+ *
13
+ * `format`: `"bitmark++"` (default) or `"plainText"`
14
+ * `location`: `"body"` (default) or `"tag"`
15
+ */
16
+ export function unbreakscape_text(input: string, format: string, location: string): string;
17
+ /**
18
+ * Query information about supported bit types.
19
+ *
20
+ * `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
21
+ * `format`: `"text"` or `"json"`
22
+ * `bit`: bit name (required when `info_type` is `"bit"`)
23
+ * `pretty`: whether to pretty-print JSON output
24
+ * `indent`: indent size for pretty-printing (default: 2)
25
+ * `include_deprecated`: include deprecated bits in `list`/`all` (PLAN-149)
26
+ * `only_deprecated`: restrict `list`/`all` to deprecated bits (wins over
27
+ * `include_deprecated`)
28
+ * `full`: complete outline for `bit`/`all` (default is the compact
29
+ * one-line-per-tag view)
30
+ */
31
+ export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number, include_deprecated: boolean, only_deprecated: boolean, full: boolean): string;
32
+ /**
33
+ * Convert between bitmark and JSON with explicit input/output formats + mode.
34
+ *
35
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
36
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
37
+ * `mode`: `"optimized"` (default) | `"full"`.
38
+ * `mapping_report`: replace the output with a human-readable report of the
39
+ * input→output mappings, including inputs that are NOT mapped (PLAN-147).
40
+ * Returns the converted text/JSON, or a string prefixed `error:` on failure.
41
+ */
42
+ 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;
43
+ /**
44
+ * Re-emit input in its own format in canonical form at `mode`.
45
+ *
46
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"` | any config
47
+ * mapping id (`html`, `xml`, …). The output is re-emitted in this same format.
48
+ */
49
+ export function canonicalize(input: string, input_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number): string;
50
+ /**
51
+ * Count the bits in `input` (auto-detecting bitmark vs JSON).
52
+ * Returns the count as a decimal string, or `error: …`.
53
+ */
54
+ export function count_bits(input: string): string;
55
+ /**
56
+ * Split a bitmark document into per-bit source slices.
57
+ *
58
+ * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
59
+ * caller chunk a document at bit boundaries (e.g. to feed a worker pool).
60
+ */
61
+ export function split_bits(input: string): string;
62
+ /**
63
+ * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
64
+ * used across the API so a JS caller can resolve `"auto"` consistently.
65
+ */
66
+ export function is_bitmark(input: string): boolean;
67
+ /**
68
+ * Split a JSON document (a top-level array of bit envelopes) into its per-bit
69
+ * envelope objects, returned as a JSON array string. Lets a JS caller iterate
70
+ * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
71
+ * Returns `error: …` if the input is not a JSON array of bits.
72
+ */
73
+ export function split_json_bits(input: string): string;
74
+ /**
75
+ * Pretty-print a compact JSON string with the given indent. Used to format a
76
+ * document recombined on the JS side (the per-bit hook path) so its output
77
+ * matches the in-Rust recombination byte-for-byte.
78
+ */
79
+ export function prettify(json: string, indent: number): string;
80
+ /**
81
+ * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).
82
+ *
83
+ * `direction`: `"textToAst"` | `"astToText"` | `"astToPlainText"`.
84
+ * `format`: a bitmark text format (`"bitmark++"`, `"bitmark+"`) parses
85
+ * inline marks; anything else is treated as plain text (textToAst only).
86
+ * `location`: `"body"` (default) or `"tag"`.
87
+ * Returns the converted fragment, or `error: …`.
88
+ */
89
+ export function convert_text(input: string, direction: string, format: string, location: string): string;
90
+ /**
91
+ * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
92
+ *
93
+ * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
94
+ * `output_format_sel`: `"bitmark"` | `"json"` (default json).
95
+ * `patch_json`: the patch entry array (empty string = no patches, i.e. a
96
+ * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
97
+ * runs sequentially. Returns the document text/JSON, or `error: …`.
98
+ */
99
+ 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;
@@ -0,0 +1,491 @@
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
+ * Breakscape text (escape bitmark special characters).
90
+ *
91
+ * `format`: `"bitmark++"` (default) or `"plainText"`
92
+ * `location`: `"body"` (default) or `"tag"`
93
+ * @param {string} input
94
+ * @param {string} format
95
+ * @param {string} location
96
+ * @returns {string}
97
+ */
98
+ module.exports.breakscape_text = function(input, format, location) {
99
+ let deferred4_0;
100
+ let deferred4_1;
101
+ try {
102
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
103
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
106
+ const len1 = WASM_VECTOR_LEN;
107
+ const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
108
+ const len2 = WASM_VECTOR_LEN;
109
+ wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
110
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
111
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
112
+ deferred4_0 = r0;
113
+ deferred4_1 = r1;
114
+ return getStringFromWasm0(r0, r1);
115
+ } finally {
116
+ wasm.__wbindgen_add_to_stack_pointer(16);
117
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
118
+ }
119
+ };
120
+
121
+ /**
122
+ * Unbreakscape text (unescape bitmark special characters).
123
+ *
124
+ * `format`: `"bitmark++"` (default) or `"plainText"`
125
+ * `location`: `"body"` (default) or `"tag"`
126
+ * @param {string} input
127
+ * @param {string} format
128
+ * @param {string} location
129
+ * @returns {string}
130
+ */
131
+ module.exports.unbreakscape_text = function(input, format, location) {
132
+ let deferred4_0;
133
+ let deferred4_1;
134
+ try {
135
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
136
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
137
+ const len0 = WASM_VECTOR_LEN;
138
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
139
+ const len1 = WASM_VECTOR_LEN;
140
+ const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
141
+ const len2 = WASM_VECTOR_LEN;
142
+ wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
143
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
144
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
145
+ deferred4_0 = r0;
146
+ deferred4_1 = r1;
147
+ return getStringFromWasm0(r0, r1);
148
+ } finally {
149
+ wasm.__wbindgen_add_to_stack_pointer(16);
150
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
151
+ }
152
+ };
153
+
154
+ /**
155
+ * Query information about supported bit types.
156
+ *
157
+ * `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
158
+ * `format`: `"text"` or `"json"`
159
+ * `bit`: bit name (required when `info_type` is `"bit"`)
160
+ * `pretty`: whether to pretty-print JSON output
161
+ * `indent`: indent size for pretty-printing (default: 2)
162
+ * `include_deprecated`: include deprecated bits in `list`/`all` (PLAN-149)
163
+ * `only_deprecated`: restrict `list`/`all` to deprecated bits (wins over
164
+ * `include_deprecated`)
165
+ * `full`: complete outline for `bit`/`all` (default is the compact
166
+ * one-line-per-tag view)
167
+ * @param {string} info_type
168
+ * @param {string} format
169
+ * @param {string} bit
170
+ * @param {boolean} pretty
171
+ * @param {number} indent
172
+ * @param {boolean} include_deprecated
173
+ * @param {boolean} only_deprecated
174
+ * @param {boolean} full
175
+ * @returns {string}
176
+ */
177
+ module.exports.info = function(info_type, format, bit, pretty, indent, include_deprecated, only_deprecated, full) {
178
+ let deferred4_0;
179
+ let deferred4_1;
180
+ try {
181
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
182
+ const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
183
+ const len0 = WASM_VECTOR_LEN;
184
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
185
+ const len1 = WASM_VECTOR_LEN;
186
+ const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
187
+ const len2 = WASM_VECTOR_LEN;
188
+ wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, include_deprecated, only_deprecated, full);
189
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
190
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
191
+ deferred4_0 = r0;
192
+ deferred4_1 = r1;
193
+ return getStringFromWasm0(r0, r1);
194
+ } finally {
195
+ wasm.__wbindgen_add_to_stack_pointer(16);
196
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
197
+ }
198
+ };
199
+
200
+ /**
201
+ * Convert between bitmark and JSON with explicit input/output formats + mode.
202
+ *
203
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
204
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
205
+ * `mode`: `"optimized"` (default) | `"full"`.
206
+ * `mapping_report`: replace the output with a human-readable report of the
207
+ * input→output mappings, including inputs that are NOT mapped (PLAN-147).
208
+ * Returns the converted text/JSON, or a string prefixed `error:` on failure.
209
+ * @param {string} input
210
+ * @param {string} input_format_sel
211
+ * @param {string} output_format_sel
212
+ * @param {string} mode
213
+ * @param {boolean} pretty
214
+ * @param {number} indent
215
+ * @param {number} spaces_around_values
216
+ * @param {boolean} include_unknown_properties
217
+ * @param {boolean} mapping_report
218
+ * @returns {string}
219
+ */
220
+ module.exports.convert = function(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report) {
221
+ let deferred5_0;
222
+ let deferred5_1;
223
+ try {
224
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
225
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
226
+ const len0 = WASM_VECTOR_LEN;
227
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
228
+ const len1 = WASM_VECTOR_LEN;
229
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
230
+ const len2 = WASM_VECTOR_LEN;
231
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
232
+ const len3 = WASM_VECTOR_LEN;
233
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties, mapping_report);
234
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
235
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
236
+ deferred5_0 = r0;
237
+ deferred5_1 = r1;
238
+ return getStringFromWasm0(r0, r1);
239
+ } finally {
240
+ wasm.__wbindgen_add_to_stack_pointer(16);
241
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
242
+ }
243
+ };
244
+
245
+ /**
246
+ * Re-emit input in its own format in canonical form at `mode`.
247
+ *
248
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"` | any config
249
+ * mapping id (`html`, `xml`, …). The output is re-emitted in this same format.
250
+ * @param {string} input
251
+ * @param {string} input_format_sel
252
+ * @param {string} mode
253
+ * @param {boolean} pretty
254
+ * @param {number} indent
255
+ * @param {number} spaces_around_values
256
+ * @returns {string}
257
+ */
258
+ module.exports.canonicalize = function(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
259
+ let deferred4_0;
260
+ let deferred4_1;
261
+ try {
262
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
263
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
264
+ const len0 = WASM_VECTOR_LEN;
265
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
266
+ const len1 = WASM_VECTOR_LEN;
267
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
268
+ const len2 = WASM_VECTOR_LEN;
269
+ wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
270
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
271
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
272
+ deferred4_0 = r0;
273
+ deferred4_1 = r1;
274
+ return getStringFromWasm0(r0, r1);
275
+ } finally {
276
+ wasm.__wbindgen_add_to_stack_pointer(16);
277
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
278
+ }
279
+ };
280
+
281
+ /**
282
+ * Count the bits in `input` (auto-detecting bitmark vs JSON).
283
+ * Returns the count as a decimal string, or `error: …`.
284
+ * @param {string} input
285
+ * @returns {string}
286
+ */
287
+ module.exports.count_bits = function(input) {
288
+ let deferred2_0;
289
+ let deferred2_1;
290
+ try {
291
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
292
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
293
+ const len0 = WASM_VECTOR_LEN;
294
+ wasm.count_bits(retptr, ptr0, len0);
295
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
296
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
297
+ deferred2_0 = r0;
298
+ deferred2_1 = r1;
299
+ return getStringFromWasm0(r0, r1);
300
+ } finally {
301
+ wasm.__wbindgen_add_to_stack_pointer(16);
302
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
303
+ }
304
+ };
305
+
306
+ /**
307
+ * Split a bitmark document into per-bit source slices.
308
+ *
309
+ * Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
310
+ * caller chunk a document at bit boundaries (e.g. to feed a worker pool).
311
+ * @param {string} input
312
+ * @returns {string}
313
+ */
314
+ module.exports.split_bits = function(input) {
315
+ let deferred2_0;
316
+ let deferred2_1;
317
+ try {
318
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
319
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
320
+ const len0 = WASM_VECTOR_LEN;
321
+ wasm.split_bits(retptr, ptr0, len0);
322
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
323
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
324
+ deferred2_0 = r0;
325
+ deferred2_1 = r1;
326
+ return getStringFromWasm0(r0, r1);
327
+ } finally {
328
+ wasm.__wbindgen_add_to_stack_pointer(16);
329
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
330
+ }
331
+ };
332
+
333
+ /**
334
+ * Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
335
+ * used across the API so a JS caller can resolve `"auto"` consistently.
336
+ * @param {string} input
337
+ * @returns {boolean}
338
+ */
339
+ module.exports.is_bitmark = function(input) {
340
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
341
+ const len0 = WASM_VECTOR_LEN;
342
+ const ret = wasm.is_bitmark(ptr0, len0);
343
+ return ret !== 0;
344
+ };
345
+
346
+ /**
347
+ * Split a JSON document (a top-level array of bit envelopes) into its per-bit
348
+ * envelope objects, returned as a JSON array string. Lets a JS caller iterate
349
+ * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
350
+ * Returns `error: …` if the input is not a JSON array of bits.
351
+ * @param {string} input
352
+ * @returns {string}
353
+ */
354
+ module.exports.split_json_bits = function(input) {
355
+ let deferred2_0;
356
+ let deferred2_1;
357
+ try {
358
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
359
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
360
+ const len0 = WASM_VECTOR_LEN;
361
+ wasm.split_json_bits(retptr, ptr0, len0);
362
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
363
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
364
+ deferred2_0 = r0;
365
+ deferred2_1 = r1;
366
+ return getStringFromWasm0(r0, r1);
367
+ } finally {
368
+ wasm.__wbindgen_add_to_stack_pointer(16);
369
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
370
+ }
371
+ };
372
+
373
+ /**
374
+ * Pretty-print a compact JSON string with the given indent. Used to format a
375
+ * document recombined on the JS side (the per-bit hook path) so its output
376
+ * matches the in-Rust recombination byte-for-byte.
377
+ * @param {string} json
378
+ * @param {number} indent
379
+ * @returns {string}
380
+ */
381
+ module.exports.prettify = function(json, indent) {
382
+ let deferred2_0;
383
+ let deferred2_1;
384
+ try {
385
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
386
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
387
+ const len0 = WASM_VECTOR_LEN;
388
+ wasm.prettify(retptr, ptr0, len0, indent);
389
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
390
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
391
+ deferred2_0 = r0;
392
+ deferred2_1 = r1;
393
+ return getStringFromWasm0(r0, r1);
394
+ } finally {
395
+ wasm.__wbindgen_add_to_stack_pointer(16);
396
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
397
+ }
398
+ };
399
+
400
+ /**
401
+ * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).
402
+ *
403
+ * `direction`: `"textToAst"` | `"astToText"` | `"astToPlainText"`.
404
+ * `format`: a bitmark text format (`"bitmark++"`, `"bitmark+"`) parses
405
+ * inline marks; anything else is treated as plain text (textToAst only).
406
+ * `location`: `"body"` (default) or `"tag"`.
407
+ * Returns the converted fragment, or `error: …`.
408
+ * @param {string} input
409
+ * @param {string} direction
410
+ * @param {string} format
411
+ * @param {string} location
412
+ * @returns {string}
413
+ */
414
+ module.exports.convert_text = function(input, direction, format, location) {
415
+ let deferred5_0;
416
+ let deferred5_1;
417
+ try {
418
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
419
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
420
+ const len0 = WASM_VECTOR_LEN;
421
+ const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
422
+ const len1 = WASM_VECTOR_LEN;
423
+ const ptr2 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
424
+ const len2 = WASM_VECTOR_LEN;
425
+ const ptr3 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
426
+ const len3 = WASM_VECTOR_LEN;
427
+ wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
428
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
429
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
430
+ deferred5_0 = r0;
431
+ deferred5_1 = r1;
432
+ return getStringFromWasm0(r0, r1);
433
+ } finally {
434
+ wasm.__wbindgen_add_to_stack_pointer(16);
435
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
436
+ }
437
+ };
438
+
439
+ /**
440
+ * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
441
+ *
442
+ * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
443
+ * `output_format_sel`: `"bitmark"` | `"json"` (default json).
444
+ * `patch_json`: the patch entry array (empty string = no patches, i.e. a
445
+ * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
446
+ * runs sequentially. Returns the document text/JSON, or `error: …`.
447
+ * @param {string} input
448
+ * @param {string} input_format_sel
449
+ * @param {string} output_format_sel
450
+ * @param {string} mode
451
+ * @param {string} patch_json
452
+ * @param {boolean} pretty
453
+ * @param {number} indent
454
+ * @param {number} spaces_around_values
455
+ * @returns {string}
456
+ */
457
+ module.exports.transform = function(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
458
+ let deferred6_0;
459
+ let deferred6_1;
460
+ try {
461
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
462
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
463
+ const len0 = WASM_VECTOR_LEN;
464
+ const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
465
+ const len1 = WASM_VECTOR_LEN;
466
+ const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
467
+ const len2 = WASM_VECTOR_LEN;
468
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
469
+ const len3 = WASM_VECTOR_LEN;
470
+ const ptr4 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
471
+ const len4 = WASM_VECTOR_LEN;
472
+ wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
473
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
474
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
475
+ deferred6_0 = r0;
476
+ deferred6_1 = r1;
477
+ return getStringFromWasm0(r0, r1);
478
+ } finally {
479
+ wasm.__wbindgen_add_to_stack_pointer(16);
480
+ wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
481
+ }
482
+ };
483
+
484
+ const path = require('path').join(__dirname, 'bitmark_json_wasm_bg.wasm');
485
+ const bytes = require('fs').readFileSync(path);
486
+
487
+ const wasmModule = new WebAssembly.Module(bytes);
488
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
489
+ wasm = wasmInstance.exports;
490
+ module.exports.__wasm = wasm;
491
+
@@ -0,0 +1,19 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const breakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
5
+ export const canonicalize: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
6
+ export const convert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number) => void;
7
+ export const convert_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
8
+ export const count_bits: (a: number, b: number, c: number) => void;
9
+ export const info: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
10
+ export const is_bitmark: (a: number, b: number) => number;
11
+ export const prettify: (a: number, b: number, c: number, d: number) => void;
12
+ export const split_bits: (a: number, b: number, c: number) => void;
13
+ export const split_json_bits: (a: number, b: number, c: number) => void;
14
+ export const transform: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number) => void;
15
+ export const unbreakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
16
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
17
+ export const __wbindgen_export_0: (a: number, b: number) => number;
18
+ export const __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
19
+ export const __wbindgen_export_2: (a: number, b: number, c: number) => void;