@gmb/bitmark-parser 6.0.1 → 6.1.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/dist/browser/bitmark-parser.min.js +2 -1
- 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 +458 -26
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +155 -2
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +155 -2
- package/dist/browser/esm/index.js +456 -26
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/esm/worker-entry.d.ts +2 -0
- package/dist/browser/esm/worker-entry.js +191 -0
- package/dist/browser/esm/worker-entry.js.map +1 -0
- package/dist/cli.js +219 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +265 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +167 -4
- package/dist/index.d.ts +167 -4
- package/dist/index.js +257 -4
- package/dist/index.js.map +1 -1
- package/dist/worker-entry.cjs +39 -0
- package/dist/worker-entry.cjs.map +1 -0
- package/package.json +3 -2
- package/wasm/bitmark_wasm.d.ts +70 -22
- package/wasm/bitmark_wasm.js +302 -55
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +10 -1
- package/wasm/package.json +2 -2
package/wasm/bitmark_wasm.d.ts
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* Unbreakscape text (unescape bitmark special characters).
|
|
5
|
-
*
|
|
6
|
-
* `format`: `"bitmark++"` (default) or `"plainText"`
|
|
7
|
-
* `location`: `"body"` (default) or `"tag"`
|
|
8
|
-
*/
|
|
9
|
-
export function unbreakscape_text(input: string, format: string, location: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Auto-detect input format and convert between bitmark and JSON.
|
|
12
|
-
*
|
|
13
|
-
* `mode`: `"optimized"` (default) or `"full"`
|
|
14
|
-
* `warnings`: whether to include validation warnings (default: false)
|
|
15
|
-
* `plain_text`: output text as plain text — debug mode (default: false)
|
|
16
|
-
* `pretty`: prettify JSON output (default: false)
|
|
17
|
-
* `indent`: indent size for pretty-printing (default: 2)
|
|
18
|
-
*
|
|
19
|
-
* Returns JSON if input is bitmark, or an error message if input is JSON
|
|
20
|
-
* (generator not yet implemented).
|
|
21
|
-
*/
|
|
22
|
-
export function convert(input: string, mode: string, warnings: boolean, plain_text: boolean, pretty: boolean, indent: number): string;
|
|
23
3
|
/**
|
|
24
4
|
* Lex bitmark input text, returning one line per token in the same format as
|
|
25
5
|
* the Rust CLI: `{kind:?} {span:?} "{text}"`.
|
|
@@ -30,12 +10,18 @@ export function convert(input: string, mode: string, warnings: boolean, plain_te
|
|
|
30
10
|
*/
|
|
31
11
|
export function lex(input: string, stage: string): string;
|
|
32
12
|
/**
|
|
33
|
-
*
|
|
13
|
+
* Pretty-print a compact JSON string with the given indent. Used to format a
|
|
14
|
+
* document recombined on the JS side (the per-bit hook path) so its output
|
|
15
|
+
* matches the in-Rust recombination byte-for-byte.
|
|
16
|
+
*/
|
|
17
|
+
export function prettify(json: string, indent: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Unbreakscape text (unescape bitmark special characters).
|
|
34
20
|
*
|
|
35
21
|
* `format`: `"bitmark++"` (default) or `"plainText"`
|
|
36
22
|
* `location`: `"body"` (default) or `"tag"`
|
|
37
23
|
*/
|
|
38
|
-
export function
|
|
24
|
+
export function unbreakscape_text(input: string, format: string, location: string): string;
|
|
39
25
|
/**
|
|
40
26
|
* Query information about supported bit types.
|
|
41
27
|
*
|
|
@@ -46,6 +32,52 @@ export function breakscape_text(input: string, format: string, location: string)
|
|
|
46
32
|
* `indent`: indent size for pretty-printing (default: 2)
|
|
47
33
|
*/
|
|
48
34
|
export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number): string;
|
|
35
|
+
/**
|
|
36
|
+
* Apply a patch (a JSON array of patch entries) to every bit and re-emit.
|
|
37
|
+
*
|
|
38
|
+
* `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
|
|
39
|
+
* `output_format_sel`: `"bitmark"` | `"json"` (default json).
|
|
40
|
+
* `patch_json`: the patch entry array (empty string = no patches, i.e. a
|
|
41
|
+
* canonicalizing pass). Parallelism is a JS-side concern (web workers); this
|
|
42
|
+
* runs sequentially. Returns the document text/JSON, or `error: …`.
|
|
43
|
+
*/
|
|
44
|
+
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;
|
|
45
|
+
/**
|
|
46
|
+
* Re-emit input in its own format in canonical form at `mode`.
|
|
47
|
+
*/
|
|
48
|
+
export function canonicalize(input: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number): string;
|
|
49
|
+
/**
|
|
50
|
+
* Split a JSON document (a top-level array of bit envelopes) into its per-bit
|
|
51
|
+
* envelope objects, returned as a JSON array string. Lets a JS caller iterate
|
|
52
|
+
* JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
|
|
53
|
+
* Returns `error: …` if the input is not a JSON array of bits.
|
|
54
|
+
*/
|
|
55
|
+
export function split_json_bits(input: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Re-emit input in its own format at full mode (all keys).
|
|
58
|
+
*/
|
|
59
|
+
export function fullize(input: string, pretty: boolean, indent: number): string;
|
|
60
|
+
/**
|
|
61
|
+
* Convert between bitmark and JSON with explicit input/output formats + mode.
|
|
62
|
+
*
|
|
63
|
+
* `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
|
|
64
|
+
* `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
|
|
65
|
+
* `mode`: `"optimized"` (default) | `"full"`.
|
|
66
|
+
* Returns the converted text/JSON, or a string prefixed `error:` on failure.
|
|
67
|
+
*/
|
|
68
|
+
export function convert(input: string, input_format_sel: string, output_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number): string;
|
|
69
|
+
/**
|
|
70
|
+
* Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
|
|
71
|
+
* used across the API so a JS caller can resolve `"auto"` consistently.
|
|
72
|
+
*/
|
|
73
|
+
export function is_bitmark(input: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Breakscape text (escape bitmark special characters).
|
|
76
|
+
*
|
|
77
|
+
* `format`: `"bitmark++"` (default) or `"plainText"`
|
|
78
|
+
* `location`: `"body"` (default) or `"tag"`
|
|
79
|
+
*/
|
|
80
|
+
export function breakscape_text(input: string, format: string, location: string): string;
|
|
49
81
|
/**
|
|
50
82
|
* Parse bitmark input text and return the reference JSON format.
|
|
51
83
|
*
|
|
@@ -54,3 +86,19 @@ export function info(info_type: string, format: string, bit: string, pretty: boo
|
|
|
54
86
|
* `mode`: `"optimized"` (default) or `"full"`
|
|
55
87
|
*/
|
|
56
88
|
export function parse(input: string, mode: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Re-emit input in its own format at optimized mode (omit natural defaults).
|
|
91
|
+
*/
|
|
92
|
+
export function optimize(input: string, pretty: boolean, indent: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* Count the bits in `input` (auto-detecting bitmark vs JSON).
|
|
95
|
+
* Returns the count as a decimal string, or `error: …`.
|
|
96
|
+
*/
|
|
97
|
+
export function count_bits(input: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* Split a bitmark document into per-bit source slices.
|
|
100
|
+
*
|
|
101
|
+
* Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
|
|
102
|
+
* caller chunk a document at bit boundaries (e.g. to feed a worker pool).
|
|
103
|
+
*/
|
|
104
|
+
export function split_bits(input: string): string;
|
package/wasm/bitmark_wasm.js
CHANGED
|
@@ -85,6 +85,65 @@ function getStringFromWasm0(ptr, len) {
|
|
|
85
85
|
ptr = ptr >>> 0;
|
|
86
86
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
87
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
|
+
* Pretty-print a compact JSON string with the given indent. Used to format a
|
|
122
|
+
* document recombined on the JS side (the per-bit hook path) so its output
|
|
123
|
+
* matches the in-Rust recombination byte-for-byte.
|
|
124
|
+
* @param {string} json
|
|
125
|
+
* @param {number} indent
|
|
126
|
+
* @returns {string}
|
|
127
|
+
*/
|
|
128
|
+
module.exports.prettify = function(json, indent) {
|
|
129
|
+
let deferred2_0;
|
|
130
|
+
let deferred2_1;
|
|
131
|
+
try {
|
|
132
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
133
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
134
|
+
const len0 = WASM_VECTOR_LEN;
|
|
135
|
+
wasm.prettify(retptr, ptr0, len0, indent);
|
|
136
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
137
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
138
|
+
deferred2_0 = r0;
|
|
139
|
+
deferred2_1 = r1;
|
|
140
|
+
return getStringFromWasm0(r0, r1);
|
|
141
|
+
} finally {
|
|
142
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
143
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
88
147
|
/**
|
|
89
148
|
* Unbreakscape text (unescape bitmark special characters).
|
|
90
149
|
*
|
|
@@ -119,66 +178,107 @@ module.exports.unbreakscape_text = function(input, format, location) {
|
|
|
119
178
|
};
|
|
120
179
|
|
|
121
180
|
/**
|
|
122
|
-
*
|
|
181
|
+
* Query information about supported bit types.
|
|
123
182
|
*
|
|
124
|
-
* `
|
|
125
|
-
* `
|
|
126
|
-
* `
|
|
127
|
-
* `pretty`:
|
|
183
|
+
* `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
|
|
184
|
+
* `format`: `"text"` or `"json"`
|
|
185
|
+
* `bit`: bit name (required when `info_type` is `"bit"`)
|
|
186
|
+
* `pretty`: whether to pretty-print JSON output
|
|
128
187
|
* `indent`: indent size for pretty-printing (default: 2)
|
|
188
|
+
* @param {string} info_type
|
|
189
|
+
* @param {string} format
|
|
190
|
+
* @param {string} bit
|
|
191
|
+
* @param {boolean} pretty
|
|
192
|
+
* @param {number} indent
|
|
193
|
+
* @returns {string}
|
|
194
|
+
*/
|
|
195
|
+
module.exports.info = function(info_type, format, bit, pretty, indent) {
|
|
196
|
+
let deferred4_0;
|
|
197
|
+
let deferred4_1;
|
|
198
|
+
try {
|
|
199
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
200
|
+
const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
201
|
+
const len0 = WASM_VECTOR_LEN;
|
|
202
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
203
|
+
const len1 = WASM_VECTOR_LEN;
|
|
204
|
+
const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
205
|
+
const len2 = WASM_VECTOR_LEN;
|
|
206
|
+
wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
|
|
207
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
208
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
209
|
+
deferred4_0 = r0;
|
|
210
|
+
deferred4_1 = r1;
|
|
211
|
+
return getStringFromWasm0(r0, r1);
|
|
212
|
+
} finally {
|
|
213
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
214
|
+
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Apply a patch (a JSON array of patch entries) to every bit and re-emit.
|
|
129
220
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
221
|
+
* `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
|
|
222
|
+
* `output_format_sel`: `"bitmark"` | `"json"` (default json).
|
|
223
|
+
* `patch_json`: the patch entry array (empty string = no patches, i.e. a
|
|
224
|
+
* canonicalizing pass). Parallelism is a JS-side concern (web workers); this
|
|
225
|
+
* runs sequentially. Returns the document text/JSON, or `error: …`.
|
|
132
226
|
* @param {string} input
|
|
227
|
+
* @param {string} input_format_sel
|
|
228
|
+
* @param {string} output_format_sel
|
|
133
229
|
* @param {string} mode
|
|
134
|
-
* @param {
|
|
135
|
-
* @param {boolean} plain_text
|
|
230
|
+
* @param {string} patch_json
|
|
136
231
|
* @param {boolean} pretty
|
|
137
232
|
* @param {number} indent
|
|
233
|
+
* @param {number} spaces_around_values
|
|
138
234
|
* @returns {string}
|
|
139
235
|
*/
|
|
140
|
-
module.exports.
|
|
141
|
-
let
|
|
142
|
-
let
|
|
236
|
+
module.exports.transform = function(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
|
|
237
|
+
let deferred6_0;
|
|
238
|
+
let deferred6_1;
|
|
143
239
|
try {
|
|
144
240
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
145
241
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
146
242
|
const len0 = WASM_VECTOR_LEN;
|
|
147
|
-
const ptr1 = passStringToWasm0(
|
|
243
|
+
const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
148
244
|
const len1 = WASM_VECTOR_LEN;
|
|
149
|
-
|
|
245
|
+
const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
246
|
+
const len2 = WASM_VECTOR_LEN;
|
|
247
|
+
const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
248
|
+
const len3 = WASM_VECTOR_LEN;
|
|
249
|
+
const ptr4 = passStringToWasm0(patch_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
250
|
+
const len4 = WASM_VECTOR_LEN;
|
|
251
|
+
wasm.transform(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, pretty, indent, spaces_around_values);
|
|
150
252
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
151
253
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
152
|
-
|
|
153
|
-
|
|
254
|
+
deferred6_0 = r0;
|
|
255
|
+
deferred6_1 = r1;
|
|
154
256
|
return getStringFromWasm0(r0, r1);
|
|
155
257
|
} finally {
|
|
156
258
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
157
|
-
wasm.__wbindgen_export_2(
|
|
259
|
+
wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
|
|
158
260
|
}
|
|
159
261
|
};
|
|
160
262
|
|
|
161
263
|
/**
|
|
162
|
-
*
|
|
163
|
-
* the Rust CLI: `{kind:?} {span:?} "{text}"`.
|
|
164
|
-
*
|
|
165
|
-
* `stage` selects the lexer pipeline:
|
|
166
|
-
* - `"lex"` — combined (default)
|
|
167
|
-
* - `"lex-json"` — combined, JSON array output
|
|
264
|
+
* Re-emit input in its own format in canonical form at `mode`.
|
|
168
265
|
* @param {string} input
|
|
169
|
-
* @param {string}
|
|
266
|
+
* @param {string} mode
|
|
267
|
+
* @param {boolean} pretty
|
|
268
|
+
* @param {number} indent
|
|
269
|
+
* @param {number} spaces_around_values
|
|
170
270
|
* @returns {string}
|
|
171
271
|
*/
|
|
172
|
-
module.exports.
|
|
272
|
+
module.exports.canonicalize = function(input, mode, pretty, indent, spaces_around_values) {
|
|
173
273
|
let deferred3_0;
|
|
174
274
|
let deferred3_1;
|
|
175
275
|
try {
|
|
176
276
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
177
277
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
178
278
|
const len0 = WASM_VECTOR_LEN;
|
|
179
|
-
const ptr1 = passStringToWasm0(
|
|
279
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
180
280
|
const len1 = WASM_VECTOR_LEN;
|
|
181
|
-
wasm.
|
|
281
|
+
wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, pretty, indent, spaces_around_values);
|
|
182
282
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
183
283
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
184
284
|
deferred3_0 = r0;
|
|
@@ -191,65 +291,134 @@ module.exports.lex = function(input, stage) {
|
|
|
191
291
|
};
|
|
192
292
|
|
|
193
293
|
/**
|
|
194
|
-
*
|
|
294
|
+
* Split a JSON document (a top-level array of bit envelopes) into its per-bit
|
|
295
|
+
* envelope objects, returned as a JSON array string. Lets a JS caller iterate
|
|
296
|
+
* JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
|
|
297
|
+
* Returns `error: …` if the input is not a JSON array of bits.
|
|
298
|
+
* @param {string} input
|
|
299
|
+
* @returns {string}
|
|
300
|
+
*/
|
|
301
|
+
module.exports.split_json_bits = function(input) {
|
|
302
|
+
let deferred2_0;
|
|
303
|
+
let deferred2_1;
|
|
304
|
+
try {
|
|
305
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
306
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
307
|
+
const len0 = WASM_VECTOR_LEN;
|
|
308
|
+
wasm.split_json_bits(retptr, ptr0, len0);
|
|
309
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
310
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
311
|
+
deferred2_0 = r0;
|
|
312
|
+
deferred2_1 = r1;
|
|
313
|
+
return getStringFromWasm0(r0, r1);
|
|
314
|
+
} finally {
|
|
315
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
316
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Re-emit input in its own format at full mode (all keys).
|
|
322
|
+
* @param {string} input
|
|
323
|
+
* @param {boolean} pretty
|
|
324
|
+
* @param {number} indent
|
|
325
|
+
* @returns {string}
|
|
326
|
+
*/
|
|
327
|
+
module.exports.fullize = function(input, pretty, indent) {
|
|
328
|
+
let deferred2_0;
|
|
329
|
+
let deferred2_1;
|
|
330
|
+
try {
|
|
331
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
332
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
333
|
+
const len0 = WASM_VECTOR_LEN;
|
|
334
|
+
wasm.fullize(retptr, ptr0, len0, pretty, indent);
|
|
335
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
336
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
337
|
+
deferred2_0 = r0;
|
|
338
|
+
deferred2_1 = r1;
|
|
339
|
+
return getStringFromWasm0(r0, r1);
|
|
340
|
+
} finally {
|
|
341
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
342
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Convert between bitmark and JSON with explicit input/output formats + mode.
|
|
195
348
|
*
|
|
196
|
-
* `
|
|
197
|
-
* `
|
|
349
|
+
* `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
|
|
350
|
+
* `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
|
|
351
|
+
* `mode`: `"optimized"` (default) | `"full"`.
|
|
352
|
+
* Returns the converted text/JSON, or a string prefixed `error:` on failure.
|
|
198
353
|
* @param {string} input
|
|
199
|
-
* @param {string}
|
|
200
|
-
* @param {string}
|
|
354
|
+
* @param {string} input_format_sel
|
|
355
|
+
* @param {string} output_format_sel
|
|
356
|
+
* @param {string} mode
|
|
357
|
+
* @param {boolean} pretty
|
|
358
|
+
* @param {number} indent
|
|
359
|
+
* @param {number} spaces_around_values
|
|
201
360
|
* @returns {string}
|
|
202
361
|
*/
|
|
203
|
-
module.exports.
|
|
204
|
-
let
|
|
205
|
-
let
|
|
362
|
+
module.exports.convert = function(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values) {
|
|
363
|
+
let deferred5_0;
|
|
364
|
+
let deferred5_1;
|
|
206
365
|
try {
|
|
207
366
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
208
367
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
209
368
|
const len0 = WASM_VECTOR_LEN;
|
|
210
|
-
const ptr1 = passStringToWasm0(
|
|
369
|
+
const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
211
370
|
const len1 = WASM_VECTOR_LEN;
|
|
212
|
-
const ptr2 = passStringToWasm0(
|
|
371
|
+
const ptr2 = passStringToWasm0(output_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
213
372
|
const len2 = WASM_VECTOR_LEN;
|
|
214
|
-
|
|
373
|
+
const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
374
|
+
const len3 = WASM_VECTOR_LEN;
|
|
375
|
+
wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values);
|
|
215
376
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
216
377
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
217
|
-
|
|
218
|
-
|
|
378
|
+
deferred5_0 = r0;
|
|
379
|
+
deferred5_1 = r1;
|
|
219
380
|
return getStringFromWasm0(r0, r1);
|
|
220
381
|
} finally {
|
|
221
382
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
222
|
-
wasm.__wbindgen_export_2(
|
|
383
|
+
wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
|
|
223
384
|
}
|
|
224
385
|
};
|
|
225
386
|
|
|
226
387
|
/**
|
|
227
|
-
*
|
|
388
|
+
* Whether `input` looks like bitmark (vs JSON). Mirrors the auto-detection
|
|
389
|
+
* used across the API so a JS caller can resolve `"auto"` consistently.
|
|
390
|
+
* @param {string} input
|
|
391
|
+
* @returns {boolean}
|
|
392
|
+
*/
|
|
393
|
+
module.exports.is_bitmark = function(input) {
|
|
394
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
395
|
+
const len0 = WASM_VECTOR_LEN;
|
|
396
|
+
const ret = wasm.is_bitmark(ptr0, len0);
|
|
397
|
+
return ret !== 0;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Breakscape text (escape bitmark special characters).
|
|
228
402
|
*
|
|
229
|
-
* `
|
|
230
|
-
* `
|
|
231
|
-
*
|
|
232
|
-
* `pretty`: whether to pretty-print JSON output
|
|
233
|
-
* `indent`: indent size for pretty-printing (default: 2)
|
|
234
|
-
* @param {string} info_type
|
|
403
|
+
* `format`: `"bitmark++"` (default) or `"plainText"`
|
|
404
|
+
* `location`: `"body"` (default) or `"tag"`
|
|
405
|
+
* @param {string} input
|
|
235
406
|
* @param {string} format
|
|
236
|
-
* @param {string}
|
|
237
|
-
* @param {boolean} pretty
|
|
238
|
-
* @param {number} indent
|
|
407
|
+
* @param {string} location
|
|
239
408
|
* @returns {string}
|
|
240
409
|
*/
|
|
241
|
-
module.exports.
|
|
410
|
+
module.exports.breakscape_text = function(input, format, location) {
|
|
242
411
|
let deferred4_0;
|
|
243
412
|
let deferred4_1;
|
|
244
413
|
try {
|
|
245
414
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
246
|
-
const ptr0 = passStringToWasm0(
|
|
415
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
247
416
|
const len0 = WASM_VECTOR_LEN;
|
|
248
417
|
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
249
418
|
const len1 = WASM_VECTOR_LEN;
|
|
250
|
-
const ptr2 = passStringToWasm0(
|
|
419
|
+
const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
251
420
|
const len2 = WASM_VECTOR_LEN;
|
|
252
|
-
wasm.
|
|
421
|
+
wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
253
422
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
254
423
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
255
424
|
deferred4_0 = r0;
|
|
@@ -292,6 +461,84 @@ module.exports.parse = function(input, mode) {
|
|
|
292
461
|
}
|
|
293
462
|
};
|
|
294
463
|
|
|
464
|
+
/**
|
|
465
|
+
* Re-emit input in its own format at optimized mode (omit natural defaults).
|
|
466
|
+
* @param {string} input
|
|
467
|
+
* @param {boolean} pretty
|
|
468
|
+
* @param {number} indent
|
|
469
|
+
* @returns {string}
|
|
470
|
+
*/
|
|
471
|
+
module.exports.optimize = function(input, pretty, indent) {
|
|
472
|
+
let deferred2_0;
|
|
473
|
+
let deferred2_1;
|
|
474
|
+
try {
|
|
475
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
476
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
477
|
+
const len0 = WASM_VECTOR_LEN;
|
|
478
|
+
wasm.optimize(retptr, ptr0, len0, pretty, indent);
|
|
479
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
480
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
481
|
+
deferred2_0 = r0;
|
|
482
|
+
deferred2_1 = r1;
|
|
483
|
+
return getStringFromWasm0(r0, r1);
|
|
484
|
+
} finally {
|
|
485
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
486
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Count the bits in `input` (auto-detecting bitmark vs JSON).
|
|
492
|
+
* Returns the count as a decimal string, or `error: …`.
|
|
493
|
+
* @param {string} input
|
|
494
|
+
* @returns {string}
|
|
495
|
+
*/
|
|
496
|
+
module.exports.count_bits = function(input) {
|
|
497
|
+
let deferred2_0;
|
|
498
|
+
let deferred2_1;
|
|
499
|
+
try {
|
|
500
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
501
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
502
|
+
const len0 = WASM_VECTOR_LEN;
|
|
503
|
+
wasm.count_bits(retptr, ptr0, len0);
|
|
504
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
505
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
506
|
+
deferred2_0 = r0;
|
|
507
|
+
deferred2_1 = r1;
|
|
508
|
+
return getStringFromWasm0(r0, r1);
|
|
509
|
+
} finally {
|
|
510
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
511
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Split a bitmark document into per-bit source slices.
|
|
517
|
+
*
|
|
518
|
+
* Returns a JSON array of `{ index, byteStart, byteEnd, source }`. Lets a JS
|
|
519
|
+
* caller chunk a document at bit boundaries (e.g. to feed a worker pool).
|
|
520
|
+
* @param {string} input
|
|
521
|
+
* @returns {string}
|
|
522
|
+
*/
|
|
523
|
+
module.exports.split_bits = function(input) {
|
|
524
|
+
let deferred2_0;
|
|
525
|
+
let deferred2_1;
|
|
526
|
+
try {
|
|
527
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
528
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
529
|
+
const len0 = WASM_VECTOR_LEN;
|
|
530
|
+
wasm.split_bits(retptr, ptr0, len0);
|
|
531
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
532
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
533
|
+
deferred2_0 = r0;
|
|
534
|
+
deferred2_1 = r1;
|
|
535
|
+
return getStringFromWasm0(r0, r1);
|
|
536
|
+
} finally {
|
|
537
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
538
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
|
|
295
542
|
const path = require('path').join(__dirname, 'bitmark_wasm_bg.wasm');
|
|
296
543
|
const bytes = require('fs').readFileSync(path);
|
|
297
544
|
|
|
Binary file
|
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const breakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
5
|
-
export const
|
|
5
|
+
export const canonicalize: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: 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) => void;
|
|
7
|
+
export const count_bits: (a: number, b: number, c: number) => void;
|
|
8
|
+
export const fullize: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
6
9
|
export const info: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
10
|
+
export const is_bitmark: (a: number, b: number) => number;
|
|
7
11
|
export const lex: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
12
|
+
export const optimize: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
13
|
export const parse: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
14
|
+
export const prettify: (a: number, b: number, c: number, d: number) => void;
|
|
15
|
+
export const split_bits: (a: number, b: number, c: number) => void;
|
|
16
|
+
export const split_json_bits: (a: number, b: number, c: number) => void;
|
|
17
|
+
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;
|
|
9
18
|
export const unbreakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
10
19
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
11
20
|
export const __wbindgen_export_0: (a: number, b: number) => number;
|
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.0
|
|
7
|
+
"version": "6.1.0",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
],
|
|
18
18
|
"main": "bitmark_wasm.js",
|
|
19
19
|
"types": "bitmark_wasm.d.ts"
|
|
20
|
-
}
|
|
20
|
+
}
|