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