@gmb/bitmark-parser 6.2.0 → 6.3.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.
Binary file
@@ -22,21 +22,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22
22
  // src/browser/index.ts
23
23
  var index_exports = {};
24
24
  __export(index_exports, {
25
+ bitmarkToObjects: () => bitmarkToObjects,
25
26
  breakscapeText: () => breakscapeText,
26
27
  canonicalize: () => canonicalize2,
27
28
  convert: () => convert2,
28
29
  countBits: () => countBits,
29
- expand: () => expand,
30
- fullize: () => fullize2,
31
- generateBits: () => generateBits,
32
30
  info: () => info2,
33
31
  init: () => init,
34
32
  initSync: () => initSync,
35
33
  legacy: () => legacy_exports,
36
34
  lex: () => lex2,
37
- optimize: () => optimize2,
38
- parse: () => parse2,
39
- parseBits: () => parseBits,
35
+ objectsToBitmark: () => objectsToBitmark,
40
36
  patchEntry: () => patchEntry,
41
37
  splitBits: () => splitBits,
42
38
  transform: () => transform2,
@@ -59,13 +55,10 @@ __export(bitmark_wasm_exports, {
59
55
  convert_text: () => convert_text,
60
56
  count_bits: () => count_bits,
61
57
  default: () => bitmark_wasm_default,
62
- fullize: () => fullize,
63
58
  info: () => info,
64
59
  initSync: () => initSync,
65
60
  is_bitmark: () => is_bitmark,
66
61
  lex: () => lex,
67
- optimize: () => optimize,
68
- parse: () => parse,
69
62
  prettify: () => prettify,
70
63
  split_bits: () => split_bits,
71
64
  split_json_bits: () => split_json_bits,
@@ -161,26 +154,6 @@ function lex(input, stage) {
161
154
  wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
162
155
  }
163
156
  }
164
- function parse(input, mode) {
165
- let deferred3_0;
166
- let deferred3_1;
167
- try {
168
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
169
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
170
- const len0 = WASM_VECTOR_LEN;
171
- const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
172
- const len1 = WASM_VECTOR_LEN;
173
- wasm.parse(retptr, ptr0, len0, ptr1, len1);
174
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
175
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
176
- deferred3_0 = r0;
177
- deferred3_1 = r1;
178
- return getStringFromWasm0(r0, r1);
179
- } finally {
180
- wasm.__wbindgen_add_to_stack_pointer(16);
181
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
182
- }
183
- }
184
157
  function breakscape_text(input, format, location) {
185
158
  let deferred4_0;
186
159
  let deferred4_1;
@@ -225,64 +198,26 @@ function unbreakscape_text(input, format, location) {
225
198
  wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
226
199
  }
227
200
  }
228
- function split_json_bits(input) {
229
- let deferred2_0;
230
- let deferred2_1;
231
- try {
232
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
233
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
234
- const len0 = WASM_VECTOR_LEN;
235
- wasm.split_json_bits(retptr, ptr0, len0);
236
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
237
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
238
- deferred2_0 = r0;
239
- deferred2_1 = r1;
240
- return getStringFromWasm0(r0, r1);
241
- } finally {
242
- wasm.__wbindgen_add_to_stack_pointer(16);
243
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
244
- }
245
- }
246
- function prettify(json, indent) {
247
- let deferred2_0;
248
- let deferred2_1;
249
- try {
250
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
251
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
252
- const len0 = WASM_VECTOR_LEN;
253
- wasm.prettify(retptr, ptr0, len0, indent);
254
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
255
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
256
- deferred2_0 = r0;
257
- deferred2_1 = r1;
258
- return getStringFromWasm0(r0, r1);
259
- } finally {
260
- wasm.__wbindgen_add_to_stack_pointer(16);
261
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
262
- }
263
- }
264
- function convert_text(input, direction, format, location) {
265
- let deferred5_0;
266
- let deferred5_1;
201
+ function info(info_type, format, bit, pretty, indent) {
202
+ let deferred4_0;
203
+ let deferred4_1;
267
204
  try {
268
205
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
269
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
206
+ const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
270
207
  const len0 = WASM_VECTOR_LEN;
271
- const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
208
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
272
209
  const len1 = WASM_VECTOR_LEN;
273
- const ptr2 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
210
+ const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
274
211
  const len2 = WASM_VECTOR_LEN;
275
- const ptr3 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
276
- const len3 = WASM_VECTOR_LEN;
277
- wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
212
+ wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
278
213
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
279
214
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
280
- deferred5_0 = r0;
281
- deferred5_1 = r1;
215
+ deferred4_0 = r0;
216
+ deferred4_1 = r1;
282
217
  return getStringFromWasm0(r0, r1);
283
218
  } finally {
284
219
  wasm.__wbindgen_add_to_stack_pointer(16);
285
- wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
220
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
286
221
  }
287
222
  }
288
223
  function transform(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
@@ -311,29 +246,7 @@ function transform(input, input_format_sel, output_format_sel, mode, patch_json,
311
246
  wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
312
247
  }
313
248
  }
314
- function info(info_type, format, bit, pretty, indent) {
315
- let deferred4_0;
316
- let deferred4_1;
317
- try {
318
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
319
- const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
320
- const len0 = WASM_VECTOR_LEN;
321
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
322
- const len1 = WASM_VECTOR_LEN;
323
- const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
324
- const len2 = WASM_VECTOR_LEN;
325
- wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
326
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
327
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
328
- deferred4_0 = r0;
329
- deferred4_1 = r1;
330
- return getStringFromWasm0(r0, r1);
331
- } finally {
332
- wasm.__wbindgen_add_to_stack_pointer(16);
333
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
334
- }
335
- }
336
- function convert(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values) {
249
+ function convert(input, input_format_sel, output_format_sel, mode, pretty, indent, spaces_around_values, include_unknown_properties) {
337
250
  let deferred5_0;
338
251
  let deferred5_1;
339
252
  try {
@@ -346,7 +259,7 @@ function convert(input, input_format_sel, output_format_sel, mode, pretty, inden
346
259
  const len2 = WASM_VECTOR_LEN;
347
260
  const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
348
261
  const len3 = WASM_VECTOR_LEN;
349
- wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values);
262
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pretty, indent, spaces_around_values, include_unknown_properties);
350
263
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
351
264
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
352
265
  deferred5_0 = r0;
@@ -357,76 +270,78 @@ function convert(input, input_format_sel, output_format_sel, mode, pretty, inden
357
270
  wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
358
271
  }
359
272
  }
360
- function optimize(input, input_format_sel, pretty, indent) {
361
- let deferred3_0;
362
- let deferred3_1;
273
+ function canonicalize(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
274
+ let deferred4_0;
275
+ let deferred4_1;
363
276
  try {
364
277
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
365
278
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
366
279
  const len0 = WASM_VECTOR_LEN;
367
280
  const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
368
281
  const len1 = WASM_VECTOR_LEN;
369
- wasm.optimize(retptr, ptr0, len0, ptr1, len1, pretty, indent);
282
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
283
+ const len2 = WASM_VECTOR_LEN;
284
+ wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
370
285
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
371
286
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
372
- deferred3_0 = r0;
373
- deferred3_1 = r1;
287
+ deferred4_0 = r0;
288
+ deferred4_1 = r1;
374
289
  return getStringFromWasm0(r0, r1);
375
290
  } finally {
376
291
  wasm.__wbindgen_add_to_stack_pointer(16);
377
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
292
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
378
293
  }
379
294
  }
380
- function fullize(input, input_format_sel, pretty, indent) {
381
- let deferred3_0;
382
- let deferred3_1;
295
+ function count_bits(input) {
296
+ let deferred2_0;
297
+ let deferred2_1;
383
298
  try {
384
299
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
385
300
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
386
301
  const len0 = WASM_VECTOR_LEN;
387
- const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
388
- const len1 = WASM_VECTOR_LEN;
389
- wasm.fullize(retptr, ptr0, len0, ptr1, len1, pretty, indent);
302
+ wasm.count_bits(retptr, ptr0, len0);
390
303
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
391
304
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
392
- deferred3_0 = r0;
393
- deferred3_1 = r1;
305
+ deferred2_0 = r0;
306
+ deferred2_1 = r1;
394
307
  return getStringFromWasm0(r0, r1);
395
308
  } finally {
396
309
  wasm.__wbindgen_add_to_stack_pointer(16);
397
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
310
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
398
311
  }
399
312
  }
400
- function canonicalize(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
401
- let deferred4_0;
402
- let deferred4_1;
313
+ function split_bits(input) {
314
+ let deferred2_0;
315
+ let deferred2_1;
403
316
  try {
404
317
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
405
318
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
406
319
  const len0 = WASM_VECTOR_LEN;
407
- const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
408
- const len1 = WASM_VECTOR_LEN;
409
- const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
410
- const len2 = WASM_VECTOR_LEN;
411
- wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
320
+ wasm.split_bits(retptr, ptr0, len0);
412
321
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
413
322
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
414
- deferred4_0 = r0;
415
- deferred4_1 = r1;
323
+ deferred2_0 = r0;
324
+ deferred2_1 = r1;
416
325
  return getStringFromWasm0(r0, r1);
417
326
  } finally {
418
327
  wasm.__wbindgen_add_to_stack_pointer(16);
419
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
328
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
420
329
  }
421
330
  }
422
- function count_bits(input) {
331
+ function is_bitmark(input) {
332
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
333
+ const len0 = WASM_VECTOR_LEN;
334
+ const ret = wasm.is_bitmark(ptr0, len0);
335
+ return ret !== 0;
336
+ }
337
+ function split_json_bits(input) {
423
338
  let deferred2_0;
424
339
  let deferred2_1;
425
340
  try {
426
341
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
427
342
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
428
343
  const len0 = WASM_VECTOR_LEN;
429
- wasm.count_bits(retptr, ptr0, len0);
344
+ wasm.split_json_bits(retptr, ptr0, len0);
430
345
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
431
346
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
432
347
  deferred2_0 = r0;
@@ -437,14 +352,14 @@ function count_bits(input) {
437
352
  wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
438
353
  }
439
354
  }
440
- function split_bits(input) {
355
+ function prettify(json, indent) {
441
356
  let deferred2_0;
442
357
  let deferred2_1;
443
358
  try {
444
359
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
445
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
360
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
446
361
  const len0 = WASM_VECTOR_LEN;
447
- wasm.split_bits(retptr, ptr0, len0);
362
+ wasm.prettify(retptr, ptr0, len0, indent);
448
363
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
449
364
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
450
365
  deferred2_0 = r0;
@@ -455,11 +370,29 @@ function split_bits(input) {
455
370
  wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
456
371
  }
457
372
  }
458
- function is_bitmark(input) {
459
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
460
- const len0 = WASM_VECTOR_LEN;
461
- const ret = wasm.is_bitmark(ptr0, len0);
462
- return ret !== 0;
373
+ function convert_text(input, direction, format, location) {
374
+ let deferred5_0;
375
+ let deferred5_1;
376
+ try {
377
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
378
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
379
+ const len0 = WASM_VECTOR_LEN;
380
+ const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
381
+ const len1 = WASM_VECTOR_LEN;
382
+ const ptr2 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
383
+ const len2 = WASM_VECTOR_LEN;
384
+ const ptr3 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
385
+ const len3 = WASM_VECTOR_LEN;
386
+ wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
387
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
388
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
389
+ deferred5_0 = r0;
390
+ deferred5_1 = r1;
391
+ return getStringFromWasm0(r0, r1);
392
+ } finally {
393
+ wasm.__wbindgen_add_to_stack_pointer(16);
394
+ wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
395
+ }
463
396
  }
464
397
  async function __wbg_load(module2, imports) {
465
398
  if (typeof Response === "function" && module2 instanceof Response) {
@@ -541,7 +474,7 @@ var bitmark_wasm_default = __wbg_init;
541
474
  // src/generated/package_info.ts
542
475
  var PACKAGE_INFO = {
543
476
  "name": "@gmb/bitmark-parser",
544
- "version": "6.2.0",
477
+ "version": "6.3.0",
545
478
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
546
479
  "license": "ISC",
547
480
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -811,16 +744,14 @@ function validateVersionOptions(opts) {
811
744
  }
812
745
  function validateBitmarkOptions(o) {
813
746
  if (o.explicitTextFormat) unsupportedOption("bitmarkOptions.explicitTextFormat");
814
- if (o.prettifyJson !== void 0 && o.prettifyJson !== false) {
815
- unsupportedOption("bitmarkOptions.prettifyJson", "embedded-JSON body prettification is not supported");
747
+ if (o.cardSetVersion === 1) {
748
+ unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
816
749
  }
817
- if (o.cardSetVersion === 1) unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
818
750
  if (o.debugGenerationInline) unsupportedOption("bitmarkOptions.debugGenerationInline");
819
751
  if (o.noBreakscaping) unsupportedOption("bitmarkOptions.noBreakscaping");
820
752
  }
821
753
  function validateJsonOptions(o) {
822
754
  if (o.textAsPlainText) unsupportedOption("jsonOptions.textAsPlainText", V3_ONLY);
823
- if (o.excludeUnknownProperties) unsupportedOption("jsonOptions.excludeUnknownProperties");
824
755
  if (o.debugGenerationInline) unsupportedOption("jsonOptions.debugGenerationInline");
825
756
  }
826
757
  function prettyIndent(prettify2) {
@@ -856,6 +787,14 @@ function isPseudoAst(v) {
856
787
  return v !== null && typeof v === "object" && (PSEUDO_AST_MARKER in v || Array.isArray(v.bits));
857
788
  }
858
789
 
790
+ // src/legacy/generated/resource-collection-keys.ts
791
+ var RESOURCE_COLLECTION_KEYS = {
792
+ "extractor-image": { key: "images", resourceType: "image" },
793
+ "extractor-image-collapsible": { key: "images", resourceType: "image" },
794
+ "images-logo-grave": { key: "logos", resourceType: "image" },
795
+ "prototype-images": { key: "images", resourceType: "image" }
796
+ };
797
+
859
798
  // src/legacy/builder.ts
860
799
  var BUILT_BIT_PARSER = /* @__PURE__ */ Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser");
861
800
  var DATA_KEY_TO_JSON_KEY = {
@@ -900,10 +839,14 @@ var Builder = class {
900
839
  * NOTE (documented divergences from bpg):
901
840
  * - the return value is bit JSON, not bpg's internal AST node model;
902
841
  * - `resourceType` (an inference hint in bpg) is not carried into the
903
- * JSON — the attached `resource` object is authoritative;
904
- * - more than one entry in `resources` passes through under a
905
- * `resources` key (kept visible, not silently dropped) — the canonical
906
- * single attachment is `resource`.
842
+ * JSON — the attached `resource` object is authoritative.
843
+ *
844
+ * `resources` follows bpg's JsonGenerator routing: on a bit whose config
845
+ * maps a repeatable resource tag group onto a collection key (e.g.
846
+ * `images` / `logos` — see the generated RESOURCE_COLLECTION_KEYS), the
847
+ * matching-type entries land under that key; on every other bit the first
848
+ * entry becomes the canonical single `resource` (as bpg: "if there is
849
+ * more than one resource, use the first one").
907
850
  */
908
851
  buildBit(data, _options) {
909
852
  const wasm2 = getLegacyWasm();
@@ -939,12 +882,15 @@ var Builder = class {
939
882
  delete src.__isDefaultExample;
940
883
  }
941
884
  const resources = src.resources;
942
- if (resources !== void 0) {
943
- if (Array.isArray(resources)) {
944
- if (resources.length === 1) bit.resource = resources[0];
945
- else if (resources.length > 1) bit.resources = resources;
946
- } else {
947
- bit.resource = resources;
885
+ if (resources !== void 0 && bitType !== void 0) {
886
+ const list = Array.isArray(resources) ? resources : [resources];
887
+ const collection = RESOURCE_COLLECTION_KEYS[bitType];
888
+ if (collection) {
889
+ bit[collection.key] = list.filter(
890
+ (r) => r !== null && typeof r === "object" && r.type === collection.resourceType
891
+ );
892
+ } else if (list.length >= 1) {
893
+ bit.resource = list[0];
948
894
  }
949
895
  delete src.resources;
950
896
  }
@@ -962,7 +908,7 @@ var Builder = class {
962
908
  }
963
909
  }
964
910
  this.parseStringTexts(bit);
965
- const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1);
911
+ const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false);
966
912
  if (out.startsWith("error:")) {
967
913
  throw new Error(out.slice("error:".length).trim());
968
914
  }
@@ -1086,8 +1032,10 @@ var BitmarkParserGenerator = class {
1086
1032
  const outputFormat = opts.outputFormat ?? (isBitmark ? "json" : "bitmark");
1087
1033
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
1088
1034
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1035
+ const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
1089
1036
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1090
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", pretty, indent, spaces);
1037
+ const includeUnknown = !jsonOptions.excludeUnknownProperties;
1038
+ const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown);
1091
1039
  this.throwOnError(out);
1092
1040
  if (outputFormat === "bitmark" || outputFormat === "text") {
1093
1041
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1117,7 +1065,9 @@ var BitmarkParserGenerator = class {
1117
1065
  this.checkBrowserFileWrite(opts.outputFile);
1118
1066
  const wasm2 = getLegacyWasm();
1119
1067
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1120
- const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1068
+ const { pretty, indent } = prettyIndent(
1069
+ isBitmark ? bitmarkOptions.prettifyJson : jsonOptions.prettify
1070
+ );
1121
1071
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1122
1072
  const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
1123
1073
  this.throwOnError(out);
@@ -1169,7 +1119,7 @@ var BitmarkParserGenerator = class {
1169
1119
  const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
1170
1120
  if (!isHtmlInput) {
1171
1121
  const { source, isBitmark } = this.resolveInput(input, void 0);
1172
- const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1);
1122
+ const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false);
1173
1123
  this.throwOnError(out2);
1174
1124
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
1175
1125
  }
@@ -1179,12 +1129,12 @@ var BitmarkParserGenerator = class {
1179
1129
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1180
1130
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1181
1131
  if (outputFormat === "html") {
1182
- const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1);
1132
+ const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false);
1183
1133
  this.throwOnError(out2);
1184
1134
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
1185
1135
  }
1186
1136
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
1187
- const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces);
1137
+ const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false);
1188
1138
  this.throwOnError(out);
1189
1139
  if (outputFormat === "bitmark" || outputFormat === "text") {
1190
1140
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1209,7 +1159,7 @@ var BitmarkParserGenerator = class {
1209
1159
  const opts = Object.assign({}, options);
1210
1160
  const wasm2 = getLegacyWasm();
1211
1161
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1212
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1);
1162
+ const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true);
1213
1163
  this.throwOnError(out);
1214
1164
  return makePseudoAst(JSON.parse(out));
1215
1165
  }
@@ -1316,7 +1266,7 @@ var BitmarkParserGenerator = class {
1316
1266
  }
1317
1267
  }
1318
1268
  const { source, isBitmark } = this.resolveInput(input, void 0);
1319
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1);
1269
+ const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false);
1320
1270
  this.throwOnError(out);
1321
1271
  return out;
1322
1272
  }
@@ -1807,19 +1757,25 @@ function version() {
1807
1757
  function lex2(input, options = {}) {
1808
1758
  return lex(input, options.stage ?? "lex");
1809
1759
  }
1810
- function parse2(input, options = {}) {
1811
- return parse(input, options.mode ?? "optimized");
1812
- }
1813
- function parseBits(input, options = {}) {
1814
- const out = convert(input, "auto", "json", options.mode ?? "optimized", false, 2, 1);
1760
+ function bitmarkToObjects(input, options = {}) {
1761
+ const out = convert(
1762
+ input,
1763
+ "bitmark",
1764
+ "json",
1765
+ options.mode ?? "optimized",
1766
+ false,
1767
+ 2,
1768
+ 1,
1769
+ options.includeUnknownProperties ?? false
1770
+ );
1815
1771
  if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1816
1772
  return JSON.parse(out);
1817
1773
  }
1818
- function generateBits(bits, options = {}) {
1774
+ function objectsToBitmark(bits, options = {}) {
1819
1775
  const entries = bits.map(
1820
1776
  (b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
1821
1777
  );
1822
- const out = convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1);
1778
+ const out = convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1, false);
1823
1779
  if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1824
1780
  return out;
1825
1781
  }
@@ -1831,16 +1787,10 @@ function convert2(input, options = {}) {
1831
1787
  options.mode ?? "optimized",
1832
1788
  options.pretty ?? false,
1833
1789
  options.indent ?? 2,
1834
- options.spacesAroundValues ?? 1
1790
+ options.spacesAroundValues ?? 1,
1791
+ options.includeUnknownProperties ?? false
1835
1792
  );
1836
1793
  }
1837
- function optimize2(input, options = {}) {
1838
- return optimize(input, options.inputFormat ?? "auto", options.pretty ?? false, options.indent ?? 2);
1839
- }
1840
- function fullize2(input, options = {}) {
1841
- return fullize(input, options.inputFormat ?? "auto", options.pretty ?? false, options.indent ?? 2);
1842
- }
1843
- var expand = fullize2;
1844
1794
  function canonicalize2(input, options = {}) {
1845
1795
  return canonicalize(
1846
1796
  input,
@@ -1898,21 +1848,17 @@ function info2(options = {}) {
1898
1848
  }
1899
1849
  // Annotate the CommonJS export names for ESM import in node:
1900
1850
  0 && (module.exports = {
1851
+ bitmarkToObjects,
1901
1852
  breakscapeText,
1902
1853
  canonicalize,
1903
1854
  convert,
1904
1855
  countBits,
1905
- expand,
1906
- fullize,
1907
- generateBits,
1908
1856
  info,
1909
1857
  init,
1910
1858
  initSync,
1911
1859
  legacy,
1912
1860
  lex,
1913
- optimize,
1914
- parse,
1915
- parseBits,
1861
+ objectsToBitmark,
1916
1862
  patchEntry,
1917
1863
  splitBits,
1918
1864
  transform,