@gmb/bitmark-parser 6.2.0 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -58
- package/dist/browser/bitmark-parser.min.js +4 -4
- package/dist/browser/bitmark-parser.min.js.map +1 -1
- package/dist/browser/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/index.cjs +161 -193
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +157 -119
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +157 -119
- package/dist/browser/esm/index.js +159 -187
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/esm/worker-entry.js.map +1 -1
- package/dist/index.cjs +92 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1921 -300
- package/dist/index.d.ts +1921 -300
- package/dist/index.js +90 -59
- package/dist/index.js.map +1 -1
- package/dist/legacy.cjs +73 -34
- package/dist/legacy.cjs.map +1 -1
- package/dist/legacy.d.cts +43 -16
- package/dist/legacy.d.ts +43 -16
- package/dist/legacy.js +73 -34
- package/dist/legacy.js.map +1 -1
- package/package.json +8 -7
- package/wasm/bitmark_wasm.d.ts +31 -53
- package/wasm/bitmark_wasm.js +115 -209
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +1 -4
- package/wasm/package.json +1 -1
|
@@ -15,13 +15,10 @@ __export(bitmark_wasm_exports, {
|
|
|
15
15
|
convert_text: () => convert_text,
|
|
16
16
|
count_bits: () => count_bits,
|
|
17
17
|
default: () => bitmark_wasm_default,
|
|
18
|
-
fullize: () => fullize,
|
|
19
18
|
info: () => info,
|
|
20
19
|
initSync: () => initSync,
|
|
21
20
|
is_bitmark: () => is_bitmark,
|
|
22
21
|
lex: () => lex,
|
|
23
|
-
optimize: () => optimize,
|
|
24
|
-
parse: () => parse,
|
|
25
22
|
prettify: () => prettify,
|
|
26
23
|
split_bits: () => split_bits,
|
|
27
24
|
split_json_bits: () => split_json_bits,
|
|
@@ -117,26 +114,6 @@ function lex(input, stage) {
|
|
|
117
114
|
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
|
-
function parse(input, mode) {
|
|
121
|
-
let deferred3_0;
|
|
122
|
-
let deferred3_1;
|
|
123
|
-
try {
|
|
124
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
125
|
-
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
126
|
-
const len0 = WASM_VECTOR_LEN;
|
|
127
|
-
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
128
|
-
const len1 = WASM_VECTOR_LEN;
|
|
129
|
-
wasm.parse(retptr, ptr0, len0, ptr1, len1);
|
|
130
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
131
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
132
|
-
deferred3_0 = r0;
|
|
133
|
-
deferred3_1 = r1;
|
|
134
|
-
return getStringFromWasm0(r0, r1);
|
|
135
|
-
} finally {
|
|
136
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
137
|
-
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
117
|
function breakscape_text(input, format, location) {
|
|
141
118
|
let deferred4_0;
|
|
142
119
|
let deferred4_1;
|
|
@@ -181,64 +158,26 @@ function unbreakscape_text(input, format, location) {
|
|
|
181
158
|
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
182
159
|
}
|
|
183
160
|
}
|
|
184
|
-
function
|
|
185
|
-
let
|
|
186
|
-
let
|
|
187
|
-
try {
|
|
188
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
189
|
-
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
190
|
-
const len0 = WASM_VECTOR_LEN;
|
|
191
|
-
wasm.split_json_bits(retptr, ptr0, len0);
|
|
192
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
193
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
194
|
-
deferred2_0 = r0;
|
|
195
|
-
deferred2_1 = r1;
|
|
196
|
-
return getStringFromWasm0(r0, r1);
|
|
197
|
-
} finally {
|
|
198
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
199
|
-
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function prettify(json, indent) {
|
|
203
|
-
let deferred2_0;
|
|
204
|
-
let deferred2_1;
|
|
205
|
-
try {
|
|
206
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
207
|
-
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
208
|
-
const len0 = WASM_VECTOR_LEN;
|
|
209
|
-
wasm.prettify(retptr, ptr0, len0, indent);
|
|
210
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
211
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
212
|
-
deferred2_0 = r0;
|
|
213
|
-
deferred2_1 = r1;
|
|
214
|
-
return getStringFromWasm0(r0, r1);
|
|
215
|
-
} finally {
|
|
216
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
217
|
-
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function convert_text(input, direction, format, location) {
|
|
221
|
-
let deferred5_0;
|
|
222
|
-
let deferred5_1;
|
|
161
|
+
function info(info_type, format, bit, pretty, indent) {
|
|
162
|
+
let deferred4_0;
|
|
163
|
+
let deferred4_1;
|
|
223
164
|
try {
|
|
224
165
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
225
|
-
const ptr0 = passStringToWasm0(
|
|
166
|
+
const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
226
167
|
const len0 = WASM_VECTOR_LEN;
|
|
227
|
-
const ptr1 = passStringToWasm0(
|
|
168
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
228
169
|
const len1 = WASM_VECTOR_LEN;
|
|
229
|
-
const ptr2 = passStringToWasm0(
|
|
170
|
+
const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
230
171
|
const len2 = WASM_VECTOR_LEN;
|
|
231
|
-
|
|
232
|
-
const len3 = WASM_VECTOR_LEN;
|
|
233
|
-
wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
172
|
+
wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
|
|
234
173
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
235
174
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
236
|
-
|
|
237
|
-
|
|
175
|
+
deferred4_0 = r0;
|
|
176
|
+
deferred4_1 = r1;
|
|
238
177
|
return getStringFromWasm0(r0, r1);
|
|
239
178
|
} finally {
|
|
240
179
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
241
|
-
wasm.__wbindgen_export_2(
|
|
180
|
+
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
242
181
|
}
|
|
243
182
|
}
|
|
244
183
|
function transform(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
|
|
@@ -267,29 +206,7 @@ function transform(input, input_format_sel, output_format_sel, mode, patch_json,
|
|
|
267
206
|
wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
|
|
268
207
|
}
|
|
269
208
|
}
|
|
270
|
-
function
|
|
271
|
-
let deferred4_0;
|
|
272
|
-
let deferred4_1;
|
|
273
|
-
try {
|
|
274
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
275
|
-
const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
276
|
-
const len0 = WASM_VECTOR_LEN;
|
|
277
|
-
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
278
|
-
const len1 = WASM_VECTOR_LEN;
|
|
279
|
-
const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
280
|
-
const len2 = WASM_VECTOR_LEN;
|
|
281
|
-
wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
|
|
282
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
283
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
284
|
-
deferred4_0 = r0;
|
|
285
|
-
deferred4_1 = r1;
|
|
286
|
-
return getStringFromWasm0(r0, r1);
|
|
287
|
-
} finally {
|
|
288
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
289
|
-
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function convert(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values) {
|
|
209
|
+
function convert(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties) {
|
|
293
210
|
let deferred5_0;
|
|
294
211
|
let deferred5_1;
|
|
295
212
|
try {
|
|
@@ -302,7 +219,7 @@ function convert(input, input_format_sel, output_format_sel, mode, pretty, inden
|
|
|
302
219
|
const len2 = WASM_VECTOR_LEN;
|
|
303
220
|
const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
304
221
|
const len3 = WASM_VECTOR_LEN;
|
|
305
|
-
wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values);
|
|
222
|
+
wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties);
|
|
306
223
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
307
224
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
308
225
|
deferred5_0 = r0;
|
|
@@ -313,76 +230,78 @@ function convert(input, input_format_sel, output_format_sel, mode, pretty, inden
|
|
|
313
230
|
wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
|
|
314
231
|
}
|
|
315
232
|
}
|
|
316
|
-
function
|
|
317
|
-
let
|
|
318
|
-
let
|
|
233
|
+
function canonicalize(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
|
|
234
|
+
let deferred4_0;
|
|
235
|
+
let deferred4_1;
|
|
319
236
|
try {
|
|
320
237
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
321
238
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
322
239
|
const len0 = WASM_VECTOR_LEN;
|
|
323
240
|
const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
324
241
|
const len1 = WASM_VECTOR_LEN;
|
|
325
|
-
|
|
242
|
+
const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
243
|
+
const len2 = WASM_VECTOR_LEN;
|
|
244
|
+
wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
|
|
326
245
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
327
246
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
328
|
-
|
|
329
|
-
|
|
247
|
+
deferred4_0 = r0;
|
|
248
|
+
deferred4_1 = r1;
|
|
330
249
|
return getStringFromWasm0(r0, r1);
|
|
331
250
|
} finally {
|
|
332
251
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
333
|
-
wasm.__wbindgen_export_2(
|
|
252
|
+
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
334
253
|
}
|
|
335
254
|
}
|
|
336
|
-
function
|
|
337
|
-
let
|
|
338
|
-
let
|
|
255
|
+
function count_bits(input) {
|
|
256
|
+
let deferred2_0;
|
|
257
|
+
let deferred2_1;
|
|
339
258
|
try {
|
|
340
259
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
341
260
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
342
261
|
const len0 = WASM_VECTOR_LEN;
|
|
343
|
-
|
|
344
|
-
const len1 = WASM_VECTOR_LEN;
|
|
345
|
-
wasm.fullize(retptr, ptr0, len0, ptr1, len1, pretty, indent);
|
|
262
|
+
wasm.count_bits(retptr, ptr0, len0);
|
|
346
263
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
347
264
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
348
|
-
|
|
349
|
-
|
|
265
|
+
deferred2_0 = r0;
|
|
266
|
+
deferred2_1 = r1;
|
|
350
267
|
return getStringFromWasm0(r0, r1);
|
|
351
268
|
} finally {
|
|
352
269
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
353
|
-
wasm.__wbindgen_export_2(
|
|
270
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
354
271
|
}
|
|
355
272
|
}
|
|
356
|
-
function
|
|
357
|
-
let
|
|
358
|
-
let
|
|
273
|
+
function split_bits(input) {
|
|
274
|
+
let deferred2_0;
|
|
275
|
+
let deferred2_1;
|
|
359
276
|
try {
|
|
360
277
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
361
278
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
362
279
|
const len0 = WASM_VECTOR_LEN;
|
|
363
|
-
|
|
364
|
-
const len1 = WASM_VECTOR_LEN;
|
|
365
|
-
const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
366
|
-
const len2 = WASM_VECTOR_LEN;
|
|
367
|
-
wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
|
|
280
|
+
wasm.split_bits(retptr, ptr0, len0);
|
|
368
281
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
369
282
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
370
|
-
|
|
371
|
-
|
|
283
|
+
deferred2_0 = r0;
|
|
284
|
+
deferred2_1 = r1;
|
|
372
285
|
return getStringFromWasm0(r0, r1);
|
|
373
286
|
} finally {
|
|
374
287
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
375
|
-
wasm.__wbindgen_export_2(
|
|
288
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
376
289
|
}
|
|
377
290
|
}
|
|
378
|
-
function
|
|
291
|
+
function is_bitmark(input) {
|
|
292
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
293
|
+
const len0 = WASM_VECTOR_LEN;
|
|
294
|
+
const ret = wasm.is_bitmark(ptr0, len0);
|
|
295
|
+
return ret !== 0;
|
|
296
|
+
}
|
|
297
|
+
function split_json_bits(input) {
|
|
379
298
|
let deferred2_0;
|
|
380
299
|
let deferred2_1;
|
|
381
300
|
try {
|
|
382
301
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
383
302
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
384
303
|
const len0 = WASM_VECTOR_LEN;
|
|
385
|
-
wasm.
|
|
304
|
+
wasm.split_json_bits(retptr, ptr0, len0);
|
|
386
305
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
387
306
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
388
307
|
deferred2_0 = r0;
|
|
@@ -393,14 +312,14 @@ function count_bits(input) {
|
|
|
393
312
|
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
394
313
|
}
|
|
395
314
|
}
|
|
396
|
-
function
|
|
315
|
+
function prettify(json, indent) {
|
|
397
316
|
let deferred2_0;
|
|
398
317
|
let deferred2_1;
|
|
399
318
|
try {
|
|
400
319
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
401
|
-
const ptr0 = passStringToWasm0(
|
|
320
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
402
321
|
const len0 = WASM_VECTOR_LEN;
|
|
403
|
-
wasm.
|
|
322
|
+
wasm.prettify(retptr, ptr0, len0, indent);
|
|
404
323
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
405
324
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
406
325
|
deferred2_0 = r0;
|
|
@@ -411,11 +330,29 @@ function split_bits(input) {
|
|
|
411
330
|
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
412
331
|
}
|
|
413
332
|
}
|
|
414
|
-
function
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
333
|
+
function convert_text(input, direction, format, location) {
|
|
334
|
+
let deferred5_0;
|
|
335
|
+
let deferred5_1;
|
|
336
|
+
try {
|
|
337
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
338
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
339
|
+
const len0 = WASM_VECTOR_LEN;
|
|
340
|
+
const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
341
|
+
const len1 = WASM_VECTOR_LEN;
|
|
342
|
+
const ptr2 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
343
|
+
const len2 = WASM_VECTOR_LEN;
|
|
344
|
+
const ptr3 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
345
|
+
const len3 = WASM_VECTOR_LEN;
|
|
346
|
+
wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
347
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
348
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
349
|
+
deferred5_0 = r0;
|
|
350
|
+
deferred5_1 = r1;
|
|
351
|
+
return getStringFromWasm0(r0, r1);
|
|
352
|
+
} finally {
|
|
353
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
354
|
+
wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
|
|
355
|
+
}
|
|
419
356
|
}
|
|
420
357
|
async function __wbg_load(module, imports) {
|
|
421
358
|
if (typeof Response === "function" && module instanceof Response) {
|
|
@@ -497,7 +434,7 @@ var bitmark_wasm_default = __wbg_init;
|
|
|
497
434
|
// src/generated/package_info.ts
|
|
498
435
|
var PACKAGE_INFO = {
|
|
499
436
|
"name": "@gmb/bitmark-parser",
|
|
500
|
-
"version": "6.
|
|
437
|
+
"version": "6.3.1",
|
|
501
438
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
502
439
|
"license": "ISC",
|
|
503
440
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -767,16 +704,14 @@ function validateVersionOptions(opts) {
|
|
|
767
704
|
}
|
|
768
705
|
function validateBitmarkOptions(o) {
|
|
769
706
|
if (o.explicitTextFormat) unsupportedOption("bitmarkOptions.explicitTextFormat");
|
|
770
|
-
if (o.
|
|
771
|
-
unsupportedOption("bitmarkOptions.
|
|
707
|
+
if (o.cardSetVersion === 1) {
|
|
708
|
+
unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
|
|
772
709
|
}
|
|
773
|
-
if (o.cardSetVersion === 1) unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
|
|
774
710
|
if (o.debugGenerationInline) unsupportedOption("bitmarkOptions.debugGenerationInline");
|
|
775
711
|
if (o.noBreakscaping) unsupportedOption("bitmarkOptions.noBreakscaping");
|
|
776
712
|
}
|
|
777
713
|
function validateJsonOptions(o) {
|
|
778
714
|
if (o.textAsPlainText) unsupportedOption("jsonOptions.textAsPlainText", V3_ONLY);
|
|
779
|
-
if (o.excludeUnknownProperties) unsupportedOption("jsonOptions.excludeUnknownProperties");
|
|
780
715
|
if (o.debugGenerationInline) unsupportedOption("jsonOptions.debugGenerationInline");
|
|
781
716
|
}
|
|
782
717
|
function prettyIndent(prettify2) {
|
|
@@ -812,6 +747,14 @@ function isPseudoAst(v) {
|
|
|
812
747
|
return v !== null && typeof v === "object" && (PSEUDO_AST_MARKER in v || Array.isArray(v.bits));
|
|
813
748
|
}
|
|
814
749
|
|
|
750
|
+
// src/legacy/generated/resource-collection-keys.ts
|
|
751
|
+
var RESOURCE_COLLECTION_KEYS = {
|
|
752
|
+
"extractor-image": { key: "images", resourceType: "image" },
|
|
753
|
+
"extractor-image-collapsible": { key: "images", resourceType: "image" },
|
|
754
|
+
"images-logo-grave": { key: "logos", resourceType: "image" },
|
|
755
|
+
"prototype-images": { key: "images", resourceType: "image" }
|
|
756
|
+
};
|
|
757
|
+
|
|
815
758
|
// src/legacy/builder.ts
|
|
816
759
|
var BUILT_BIT_PARSER = /* @__PURE__ */ Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser");
|
|
817
760
|
var DATA_KEY_TO_JSON_KEY = {
|
|
@@ -824,6 +767,13 @@ var DEPRECATED_TEXT_FORMATS = {
|
|
|
824
767
|
"bitmark--": "bitmark++",
|
|
825
768
|
"bitmark+": "bitmark++"
|
|
826
769
|
};
|
|
770
|
+
var CONFIG_BODY_FORMAT_TO_TEXT_FORMAT = {
|
|
771
|
+
bitmark: "bitmark++",
|
|
772
|
+
text: "text",
|
|
773
|
+
json: "json",
|
|
774
|
+
latex: "latex",
|
|
775
|
+
xml: "xml"
|
|
776
|
+
};
|
|
827
777
|
var TAG_TEXT_KEYS = [
|
|
828
778
|
"title",
|
|
829
779
|
"subtitle",
|
|
@@ -856,16 +806,20 @@ var Builder = class {
|
|
|
856
806
|
* NOTE (documented divergences from bpg):
|
|
857
807
|
* - the return value is bit JSON, not bpg's internal AST node model;
|
|
858
808
|
* - `resourceType` (an inference hint in bpg) is not carried into the
|
|
859
|
-
* JSON — the attached `resource` object is authoritative
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
*
|
|
809
|
+
* JSON — the attached `resource` object is authoritative.
|
|
810
|
+
*
|
|
811
|
+
* `resources` follows bpg's JsonGenerator routing: on a bit whose config
|
|
812
|
+
* maps a repeatable resource tag group onto a collection key (e.g.
|
|
813
|
+
* `images` / `logos` — see the generated RESOURCE_COLLECTION_KEYS), the
|
|
814
|
+
* matching-type entries land under that key; on every other bit the first
|
|
815
|
+
* entry becomes the canonical single `resource` (as bpg: "if there is
|
|
816
|
+
* more than one resource, use the first one").
|
|
863
817
|
*/
|
|
864
818
|
buildBit(data, _options) {
|
|
865
819
|
const wasm2 = getLegacyWasm();
|
|
866
820
|
const src = { ...data };
|
|
867
821
|
const bitType = src.bitType;
|
|
868
|
-
this.
|
|
822
|
+
const bitConfig = this.getBitConfig(bitType);
|
|
869
823
|
const bit = {};
|
|
870
824
|
bit.type = bitType;
|
|
871
825
|
if (src.isCommented) {
|
|
@@ -878,6 +832,8 @@ var Builder = class {
|
|
|
878
832
|
if (textFormat !== void 0) {
|
|
879
833
|
bit.format = DEPRECATED_TEXT_FORMATS[textFormat] ?? textFormat;
|
|
880
834
|
delete src.textFormat;
|
|
835
|
+
} else {
|
|
836
|
+
bit.format = CONFIG_BODY_FORMAT_TO_TEXT_FORMAT[bitConfig.bodyFormat ?? ""] ?? "bitmark++";
|
|
881
837
|
}
|
|
882
838
|
delete src.resourceType;
|
|
883
839
|
const body = src.body;
|
|
@@ -895,12 +851,15 @@ var Builder = class {
|
|
|
895
851
|
delete src.__isDefaultExample;
|
|
896
852
|
}
|
|
897
853
|
const resources = src.resources;
|
|
898
|
-
if (resources !== void 0) {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
854
|
+
if (resources !== void 0 && bitType !== void 0) {
|
|
855
|
+
const list = Array.isArray(resources) ? resources : [resources];
|
|
856
|
+
const collection = RESOURCE_COLLECTION_KEYS[bitType];
|
|
857
|
+
if (collection) {
|
|
858
|
+
bit[collection.key] = list.filter(
|
|
859
|
+
(r) => r !== null && typeof r === "object" && r.type === collection.resourceType
|
|
860
|
+
);
|
|
861
|
+
} else if (list.length >= 1) {
|
|
862
|
+
bit.resource = list[0];
|
|
904
863
|
}
|
|
905
864
|
delete src.resources;
|
|
906
865
|
}
|
|
@@ -918,7 +877,7 @@ var Builder = class {
|
|
|
918
877
|
}
|
|
919
878
|
}
|
|
920
879
|
this.parseStringTexts(bit);
|
|
921
|
-
const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1);
|
|
880
|
+
const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false);
|
|
922
881
|
if (out.startsWith("error:")) {
|
|
923
882
|
throw new Error(out.slice("error:".length).trim());
|
|
924
883
|
}
|
|
@@ -966,6 +925,12 @@ var Builder = class {
|
|
|
966
925
|
* (inline marks become TextAst marks); the composer would otherwise treat
|
|
967
926
|
* them as literal text. Converts top-level JsonText fields in place.
|
|
968
927
|
* Nested (card-content) strings are left literal — documented divergence.
|
|
928
|
+
*
|
|
929
|
+
* A string body is dispatched on the bit's resolved text format, as bpg's
|
|
930
|
+
* buildBody: bitmark text is parsed to TextAst, `json` is JSON.parsed
|
|
931
|
+
* (unparseable → null), and plain-text formats (text/latex/xml) stay
|
|
932
|
+
* verbatim. Tag texts are always bitmark text, independent of body format
|
|
933
|
+
* (bpg TextParser.toAst ignores format; only location matters).
|
|
969
934
|
*/
|
|
970
935
|
parseStringTexts(bit) {
|
|
971
936
|
const wasm2 = getLegacyWasm();
|
|
@@ -980,29 +945,36 @@ var Builder = class {
|
|
|
980
945
|
};
|
|
981
946
|
const format = bit.format;
|
|
982
947
|
const bitmarkBody = format === void 0 || format === "bitmark++" || format === "bitmark+";
|
|
983
|
-
if (typeof bit.body === "string"
|
|
984
|
-
|
|
948
|
+
if (typeof bit.body === "string") {
|
|
949
|
+
if (format === "json") {
|
|
950
|
+
try {
|
|
951
|
+
bit.body = JSON.parse(bit.body);
|
|
952
|
+
} catch {
|
|
953
|
+
bit.body = null;
|
|
954
|
+
}
|
|
955
|
+
} else if (bitmarkBody) {
|
|
956
|
+
bit.body = toAst(bit.body, "body");
|
|
957
|
+
}
|
|
985
958
|
}
|
|
986
959
|
for (const key of TAG_TEXT_KEYS) {
|
|
987
960
|
const v = bit[key];
|
|
988
961
|
if (typeof v === "string") bit[key] = toAst(v, "tag");
|
|
989
962
|
}
|
|
990
963
|
}
|
|
991
|
-
/**
|
|
992
|
-
|
|
964
|
+
/**
|
|
965
|
+
* Look up the bit's config (`wasm.info`); throws bpg's exact
|
|
966
|
+
* unknown-bit-type error (`Config.getBitConfig` parity).
|
|
967
|
+
*/
|
|
968
|
+
getBitConfig(bitType) {
|
|
993
969
|
const wasm2 = getLegacyWasm();
|
|
994
|
-
let known = false;
|
|
995
970
|
if (bitType !== void 0) {
|
|
996
971
|
try {
|
|
997
972
|
const info3 = JSON.parse(wasm2.info("bit", "json", bitType, false, 2));
|
|
998
|
-
|
|
973
|
+
if (info3.error === void 0) return info3;
|
|
999
974
|
} catch {
|
|
1000
|
-
known = false;
|
|
1001
975
|
}
|
|
1002
976
|
}
|
|
1003
|
-
|
|
1004
|
-
throw new Error(`No config found for bit: ${bitType}`);
|
|
1005
|
-
}
|
|
977
|
+
throw new Error(`No config found for bit: ${bitType}`);
|
|
1006
978
|
}
|
|
1007
979
|
};
|
|
1008
980
|
function stripUndefined(src, exclude) {
|
|
@@ -1042,8 +1014,10 @@ var BitmarkParserGenerator = class {
|
|
|
1042
1014
|
const outputFormat = opts.outputFormat ?? (isBitmark ? "json" : "bitmark");
|
|
1043
1015
|
const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
|
|
1044
1016
|
const { pretty, indent } = prettyIndent(jsonOptions.prettify);
|
|
1017
|
+
const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
|
|
1045
1018
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
1046
|
-
const
|
|
1019
|
+
const includeUnknown = !jsonOptions.excludeUnknownProperties;
|
|
1020
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown);
|
|
1047
1021
|
this.throwOnError(out);
|
|
1048
1022
|
if (outputFormat === "bitmark" || outputFormat === "text") {
|
|
1049
1023
|
return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
@@ -1073,7 +1047,9 @@ var BitmarkParserGenerator = class {
|
|
|
1073
1047
|
this.checkBrowserFileWrite(opts.outputFile);
|
|
1074
1048
|
const wasm2 = getLegacyWasm();
|
|
1075
1049
|
const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
|
|
1076
|
-
const { pretty, indent } = prettyIndent(
|
|
1050
|
+
const { pretty, indent } = prettyIndent(
|
|
1051
|
+
isBitmark ? bitmarkOptions.prettifyJson : jsonOptions.prettify
|
|
1052
|
+
);
|
|
1077
1053
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
1078
1054
|
const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
|
|
1079
1055
|
this.throwOnError(out);
|
|
@@ -1125,7 +1101,7 @@ var BitmarkParserGenerator = class {
|
|
|
1125
1101
|
const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
|
|
1126
1102
|
if (!isHtmlInput) {
|
|
1127
1103
|
const { source, isBitmark } = this.resolveInput(input, void 0);
|
|
1128
|
-
const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1);
|
|
1104
|
+
const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false);
|
|
1129
1105
|
this.throwOnError(out2);
|
|
1130
1106
|
return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
|
|
1131
1107
|
}
|
|
@@ -1135,12 +1111,12 @@ var BitmarkParserGenerator = class {
|
|
|
1135
1111
|
const { pretty, indent } = prettyIndent(jsonOptions.prettify);
|
|
1136
1112
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
1137
1113
|
if (outputFormat === "html") {
|
|
1138
|
-
const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1);
|
|
1114
|
+
const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false);
|
|
1139
1115
|
this.throwOnError(out2);
|
|
1140
1116
|
return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
|
|
1141
1117
|
}
|
|
1142
1118
|
const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
|
|
1143
|
-
const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces);
|
|
1119
|
+
const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false);
|
|
1144
1120
|
this.throwOnError(out);
|
|
1145
1121
|
if (outputFormat === "bitmark" || outputFormat === "text") {
|
|
1146
1122
|
return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
@@ -1165,7 +1141,7 @@ var BitmarkParserGenerator = class {
|
|
|
1165
1141
|
const opts = Object.assign({}, options);
|
|
1166
1142
|
const wasm2 = getLegacyWasm();
|
|
1167
1143
|
const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
|
|
1168
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1);
|
|
1144
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true);
|
|
1169
1145
|
this.throwOnError(out);
|
|
1170
1146
|
return makePseudoAst(JSON.parse(out));
|
|
1171
1147
|
}
|
|
@@ -1272,7 +1248,7 @@ var BitmarkParserGenerator = class {
|
|
|
1272
1248
|
}
|
|
1273
1249
|
}
|
|
1274
1250
|
const { source, isBitmark } = this.resolveInput(input, void 0);
|
|
1275
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1);
|
|
1251
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false);
|
|
1276
1252
|
this.throwOnError(out);
|
|
1277
1253
|
return out;
|
|
1278
1254
|
}
|
|
@@ -1763,19 +1739,25 @@ function version() {
|
|
|
1763
1739
|
function lex2(input, options = {}) {
|
|
1764
1740
|
return lex(input, options.stage ?? "lex");
|
|
1765
1741
|
}
|
|
1766
|
-
function
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1742
|
+
function bitmarkToObjects(input, options = {}) {
|
|
1743
|
+
const out = convert(
|
|
1744
|
+
input,
|
|
1745
|
+
"bitmark",
|
|
1746
|
+
"json",
|
|
1747
|
+
options.mode ?? "optimized",
|
|
1748
|
+
false,
|
|
1749
|
+
2,
|
|
1750
|
+
1,
|
|
1751
|
+
options.includeUnknownProperties ?? false
|
|
1752
|
+
);
|
|
1771
1753
|
if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
|
|
1772
1754
|
return JSON.parse(out);
|
|
1773
1755
|
}
|
|
1774
|
-
function
|
|
1756
|
+
function objectsToBitmark(bits, options = {}) {
|
|
1775
1757
|
const entries = bits.map(
|
|
1776
1758
|
(b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
|
|
1777
1759
|
);
|
|
1778
|
-
const out = convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1);
|
|
1760
|
+
const out = convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1, false);
|
|
1779
1761
|
if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
|
|
1780
1762
|
return out;
|
|
1781
1763
|
}
|
|
@@ -1787,16 +1769,10 @@ function convert2(input, options = {}) {
|
|
|
1787
1769
|
options.mode ?? "optimized",
|
|
1788
1770
|
options.pretty ?? false,
|
|
1789
1771
|
options.indent ?? 2,
|
|
1790
|
-
options.spacesAroundValues ?? 1
|
|
1772
|
+
options.spacesAroundValues ?? 1,
|
|
1773
|
+
options.includeUnknownProperties ?? false
|
|
1791
1774
|
);
|
|
1792
1775
|
}
|
|
1793
|
-
function optimize2(input, options = {}) {
|
|
1794
|
-
return optimize(input, options.inputFormat ?? "auto", options.pretty ?? false, options.indent ?? 2);
|
|
1795
|
-
}
|
|
1796
|
-
function fullize2(input, options = {}) {
|
|
1797
|
-
return fullize(input, options.inputFormat ?? "auto", options.pretty ?? false, options.indent ?? 2);
|
|
1798
|
-
}
|
|
1799
|
-
var expand = fullize2;
|
|
1800
1776
|
function canonicalize2(input, options = {}) {
|
|
1801
1777
|
return canonicalize(
|
|
1802
1778
|
input,
|
|
@@ -1853,21 +1829,17 @@ function info2(options = {}) {
|
|
|
1853
1829
|
return info(infoType, format, bit, pretty, indent);
|
|
1854
1830
|
}
|
|
1855
1831
|
export {
|
|
1832
|
+
bitmarkToObjects,
|
|
1856
1833
|
breakscapeText,
|
|
1857
1834
|
canonicalize2 as canonicalize,
|
|
1858
1835
|
convert2 as convert,
|
|
1859
1836
|
countBits,
|
|
1860
|
-
expand,
|
|
1861
|
-
fullize2 as fullize,
|
|
1862
|
-
generateBits,
|
|
1863
1837
|
info2 as info,
|
|
1864
1838
|
init,
|
|
1865
1839
|
initSync,
|
|
1866
1840
|
legacy_exports as legacy,
|
|
1867
1841
|
lex2 as lex,
|
|
1868
|
-
|
|
1869
|
-
parse2 as parse,
|
|
1870
|
-
parseBits,
|
|
1842
|
+
objectsToBitmark,
|
|
1871
1843
|
patchEntry,
|
|
1872
1844
|
splitBits,
|
|
1873
1845
|
transform2 as transform,
|