@gmb/bitmark-parser 6.1.4 → 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,19 +22,18 @@ 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
30
  info: () => info2,
32
31
  init: () => init,
33
32
  initSync: () => initSync,
34
33
  legacy: () => legacy_exports,
35
34
  lex: () => lex2,
36
- optimize: () => optimize2,
37
- parse: () => parse2,
35
+ objectsToBitmark: () => objectsToBitmark,
36
+ patchEntry: () => patchEntry,
38
37
  splitBits: () => splitBits,
39
38
  transform: () => transform2,
40
39
  transformParallel: () => transformParallel,
@@ -56,13 +55,10 @@ __export(bitmark_wasm_exports, {
56
55
  convert_text: () => convert_text,
57
56
  count_bits: () => count_bits,
58
57
  default: () => bitmark_wasm_default,
59
- fullize: () => fullize,
60
58
  info: () => info,
61
59
  initSync: () => initSync,
62
60
  is_bitmark: () => is_bitmark,
63
61
  lex: () => lex,
64
- optimize: () => optimize,
65
- parse: () => parse,
66
62
  prettify: () => prettify,
67
63
  split_bits: () => split_bits,
68
64
  split_json_bits: () => split_json_bits,
@@ -158,26 +154,6 @@ function lex(input, stage) {
158
154
  wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
159
155
  }
160
156
  }
161
- function parse(input, mode) {
162
- let deferred3_0;
163
- let deferred3_1;
164
- try {
165
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
166
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
167
- const len0 = WASM_VECTOR_LEN;
168
- const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
169
- const len1 = WASM_VECTOR_LEN;
170
- wasm.parse(retptr, ptr0, len0, ptr1, len1);
171
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
172
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
173
- deferred3_0 = r0;
174
- deferred3_1 = r1;
175
- return getStringFromWasm0(r0, r1);
176
- } finally {
177
- wasm.__wbindgen_add_to_stack_pointer(16);
178
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
179
- }
180
- }
181
157
  function breakscape_text(input, format, location) {
182
158
  let deferred4_0;
183
159
  let deferred4_1;
@@ -222,64 +198,26 @@ function unbreakscape_text(input, format, location) {
222
198
  wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
223
199
  }
224
200
  }
225
- function split_json_bits(input) {
226
- let deferred2_0;
227
- let deferred2_1;
228
- try {
229
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
230
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
231
- const len0 = WASM_VECTOR_LEN;
232
- wasm.split_json_bits(retptr, ptr0, len0);
233
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
234
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
235
- deferred2_0 = r0;
236
- deferred2_1 = r1;
237
- return getStringFromWasm0(r0, r1);
238
- } finally {
239
- wasm.__wbindgen_add_to_stack_pointer(16);
240
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
241
- }
242
- }
243
- function prettify(json, indent) {
244
- let deferred2_0;
245
- let deferred2_1;
246
- try {
247
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
248
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
249
- const len0 = WASM_VECTOR_LEN;
250
- wasm.prettify(retptr, ptr0, len0, indent);
251
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
252
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
253
- deferred2_0 = r0;
254
- deferred2_1 = r1;
255
- return getStringFromWasm0(r0, r1);
256
- } finally {
257
- wasm.__wbindgen_add_to_stack_pointer(16);
258
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
259
- }
260
- }
261
- function convert_text(input, direction, format, location) {
262
- let deferred5_0;
263
- let deferred5_1;
201
+ function info(info_type, format, bit, pretty, indent) {
202
+ let deferred4_0;
203
+ let deferred4_1;
264
204
  try {
265
205
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
266
- 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);
267
207
  const len0 = WASM_VECTOR_LEN;
268
- 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);
269
209
  const len1 = WASM_VECTOR_LEN;
270
- 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);
271
211
  const len2 = WASM_VECTOR_LEN;
272
- const ptr3 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
273
- const len3 = WASM_VECTOR_LEN;
274
- wasm.convert_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
212
+ wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
275
213
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
276
214
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
277
- deferred5_0 = r0;
278
- deferred5_1 = r1;
215
+ deferred4_0 = r0;
216
+ deferred4_1 = r1;
279
217
  return getStringFromWasm0(r0, r1);
280
218
  } finally {
281
219
  wasm.__wbindgen_add_to_stack_pointer(16);
282
- wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
220
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
283
221
  }
284
222
  }
285
223
  function transform(input, input_format_sel, output_format_sel, mode, patch_json, pretty, indent, spaces_around_values) {
@@ -308,29 +246,7 @@ function transform(input, input_format_sel, output_format_sel, mode, patch_json,
308
246
  wasm.__wbindgen_export_2(deferred6_0, deferred6_1, 1);
309
247
  }
310
248
  }
311
- function info(info_type, format, bit, pretty, indent) {
312
- let deferred4_0;
313
- let deferred4_1;
314
- try {
315
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
316
- const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
317
- const len0 = WASM_VECTOR_LEN;
318
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
319
- const len1 = WASM_VECTOR_LEN;
320
- const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
321
- const len2 = WASM_VECTOR_LEN;
322
- wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
323
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
324
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
325
- deferred4_0 = r0;
326
- deferred4_1 = r1;
327
- return getStringFromWasm0(r0, r1);
328
- } finally {
329
- wasm.__wbindgen_add_to_stack_pointer(16);
330
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
331
- }
332
- }
333
- 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) {
334
250
  let deferred5_0;
335
251
  let deferred5_1;
336
252
  try {
@@ -343,7 +259,7 @@ function convert(input, input_format_sel, output_format_sel, mode, pretty, inden
343
259
  const len2 = WASM_VECTOR_LEN;
344
260
  const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
345
261
  const len3 = WASM_VECTOR_LEN;
346
- 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);
347
263
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
348
264
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
349
265
  deferred5_0 = r0;
@@ -354,76 +270,78 @@ function convert(input, input_format_sel, output_format_sel, mode, pretty, inden
354
270
  wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
355
271
  }
356
272
  }
357
- function optimize(input, input_format_sel, pretty, indent) {
358
- let deferred3_0;
359
- let deferred3_1;
273
+ function canonicalize(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
274
+ let deferred4_0;
275
+ let deferred4_1;
360
276
  try {
361
277
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
362
278
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
363
279
  const len0 = WASM_VECTOR_LEN;
364
280
  const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
365
281
  const len1 = WASM_VECTOR_LEN;
366
- 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);
367
285
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
368
286
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
369
- deferred3_0 = r0;
370
- deferred3_1 = r1;
287
+ deferred4_0 = r0;
288
+ deferred4_1 = r1;
371
289
  return getStringFromWasm0(r0, r1);
372
290
  } finally {
373
291
  wasm.__wbindgen_add_to_stack_pointer(16);
374
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
292
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
375
293
  }
376
294
  }
377
- function fullize(input, input_format_sel, pretty, indent) {
378
- let deferred3_0;
379
- let deferred3_1;
295
+ function count_bits(input) {
296
+ let deferred2_0;
297
+ let deferred2_1;
380
298
  try {
381
299
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
382
300
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
383
301
  const len0 = WASM_VECTOR_LEN;
384
- const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
385
- const len1 = WASM_VECTOR_LEN;
386
- wasm.fullize(retptr, ptr0, len0, ptr1, len1, pretty, indent);
302
+ wasm.count_bits(retptr, ptr0, len0);
387
303
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
388
304
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
389
- deferred3_0 = r0;
390
- deferred3_1 = r1;
305
+ deferred2_0 = r0;
306
+ deferred2_1 = r1;
391
307
  return getStringFromWasm0(r0, r1);
392
308
  } finally {
393
309
  wasm.__wbindgen_add_to_stack_pointer(16);
394
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
310
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
395
311
  }
396
312
  }
397
- function canonicalize(input, input_format_sel, mode, pretty, indent, spaces_around_values) {
398
- let deferred4_0;
399
- let deferred4_1;
313
+ function split_bits(input) {
314
+ let deferred2_0;
315
+ let deferred2_1;
400
316
  try {
401
317
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
402
318
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
403
319
  const len0 = WASM_VECTOR_LEN;
404
- const ptr1 = passStringToWasm0(input_format_sel, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
405
- const len1 = WASM_VECTOR_LEN;
406
- const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
407
- const len2 = WASM_VECTOR_LEN;
408
- wasm.canonicalize(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent, spaces_around_values);
320
+ wasm.split_bits(retptr, ptr0, len0);
409
321
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
410
322
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
411
- deferred4_0 = r0;
412
- deferred4_1 = r1;
323
+ deferred2_0 = r0;
324
+ deferred2_1 = r1;
413
325
  return getStringFromWasm0(r0, r1);
414
326
  } finally {
415
327
  wasm.__wbindgen_add_to_stack_pointer(16);
416
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
328
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
417
329
  }
418
330
  }
419
- 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) {
420
338
  let deferred2_0;
421
339
  let deferred2_1;
422
340
  try {
423
341
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
424
342
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
425
343
  const len0 = WASM_VECTOR_LEN;
426
- wasm.count_bits(retptr, ptr0, len0);
344
+ wasm.split_json_bits(retptr, ptr0, len0);
427
345
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
428
346
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
429
347
  deferred2_0 = r0;
@@ -434,14 +352,14 @@ function count_bits(input) {
434
352
  wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
435
353
  }
436
354
  }
437
- function split_bits(input) {
355
+ function prettify(json, indent) {
438
356
  let deferred2_0;
439
357
  let deferred2_1;
440
358
  try {
441
359
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
442
- 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);
443
361
  const len0 = WASM_VECTOR_LEN;
444
- wasm.split_bits(retptr, ptr0, len0);
362
+ wasm.prettify(retptr, ptr0, len0, indent);
445
363
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
446
364
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
447
365
  deferred2_0 = r0;
@@ -452,11 +370,29 @@ function split_bits(input) {
452
370
  wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
453
371
  }
454
372
  }
455
- function is_bitmark(input) {
456
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
457
- const len0 = WASM_VECTOR_LEN;
458
- const ret = wasm.is_bitmark(ptr0, len0);
459
- 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
+ }
460
396
  }
461
397
  async function __wbg_load(module2, imports) {
462
398
  if (typeof Response === "function" && module2 instanceof Response) {
@@ -538,7 +474,7 @@ var bitmark_wasm_default = __wbg_init;
538
474
  // src/generated/package_info.ts
539
475
  var PACKAGE_INFO = {
540
476
  "name": "@gmb/bitmark-parser",
541
- "version": "6.1.4",
477
+ "version": "6.3.0",
542
478
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
543
479
  "license": "ISC",
544
480
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -578,7 +514,7 @@ function buildUnits(wasm2, input, inputIsBitmark) {
578
514
  if (isError(out)) throw new Error(out);
579
515
  const envelopes = JSON.parse(out);
580
516
  return envelopes.map((env, index) => ({
581
- view: { format: "json", index, total: envelopes.length, bit: env.bit },
517
+ view: { format: "json", index, total: envelopes.length, bit: env.bit ?? {} },
582
518
  // Per-bit transform consumes a one-bit JSON document.
583
519
  source: JSON.stringify([env])
584
520
  }));
@@ -808,16 +744,14 @@ function validateVersionOptions(opts) {
808
744
  }
809
745
  function validateBitmarkOptions(o) {
810
746
  if (o.explicitTextFormat) unsupportedOption("bitmarkOptions.explicitTextFormat");
811
- if (o.prettifyJson !== void 0 && o.prettifyJson !== false) {
812
- unsupportedOption("bitmarkOptions.prettifyJson", "embedded-JSON body prettification is not supported");
747
+ if (o.cardSetVersion === 1) {
748
+ unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
813
749
  }
814
- if (o.cardSetVersion === 1) unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
815
750
  if (o.debugGenerationInline) unsupportedOption("bitmarkOptions.debugGenerationInline");
816
751
  if (o.noBreakscaping) unsupportedOption("bitmarkOptions.noBreakscaping");
817
752
  }
818
753
  function validateJsonOptions(o) {
819
754
  if (o.textAsPlainText) unsupportedOption("jsonOptions.textAsPlainText", V3_ONLY);
820
- if (o.excludeUnknownProperties) unsupportedOption("jsonOptions.excludeUnknownProperties");
821
755
  if (o.debugGenerationInline) unsupportedOption("jsonOptions.debugGenerationInline");
822
756
  }
823
757
  function prettyIndent(prettify2) {
@@ -853,6 +787,14 @@ function isPseudoAst(v) {
853
787
  return v !== null && typeof v === "object" && (PSEUDO_AST_MARKER in v || Array.isArray(v.bits));
854
788
  }
855
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
+
856
798
  // src/legacy/builder.ts
857
799
  var BUILT_BIT_PARSER = /* @__PURE__ */ Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser");
858
800
  var DATA_KEY_TO_JSON_KEY = {
@@ -897,10 +839,14 @@ var Builder = class {
897
839
  * NOTE (documented divergences from bpg):
898
840
  * - the return value is bit JSON, not bpg's internal AST node model;
899
841
  * - `resourceType` (an inference hint in bpg) is not carried into the
900
- * JSON — the attached `resource` object is authoritative;
901
- * - more than one entry in `resources` passes through under a
902
- * `resources` key (kept visible, not silently dropped) — the canonical
903
- * 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").
904
850
  */
905
851
  buildBit(data, _options) {
906
852
  const wasm2 = getLegacyWasm();
@@ -936,12 +882,15 @@ var Builder = class {
936
882
  delete src.__isDefaultExample;
937
883
  }
938
884
  const resources = src.resources;
939
- if (resources !== void 0) {
940
- if (Array.isArray(resources)) {
941
- if (resources.length === 1) bit.resource = resources[0];
942
- else if (resources.length > 1) bit.resources = resources;
943
- } else {
944
- 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];
945
894
  }
946
895
  delete src.resources;
947
896
  }
@@ -959,7 +908,7 @@ var Builder = class {
959
908
  }
960
909
  }
961
910
  this.parseStringTexts(bit);
962
- 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);
963
912
  if (out.startsWith("error:")) {
964
913
  throw new Error(out.slice("error:".length).trim());
965
914
  }
@@ -1083,8 +1032,10 @@ var BitmarkParserGenerator = class {
1083
1032
  const outputFormat = opts.outputFormat ?? (isBitmark ? "json" : "bitmark");
1084
1033
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
1085
1034
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1035
+ const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
1086
1036
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1087
- 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);
1088
1039
  this.throwOnError(out);
1089
1040
  if (outputFormat === "bitmark" || outputFormat === "text") {
1090
1041
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1114,7 +1065,9 @@ var BitmarkParserGenerator = class {
1114
1065
  this.checkBrowserFileWrite(opts.outputFile);
1115
1066
  const wasm2 = getLegacyWasm();
1116
1067
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1117
- const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1068
+ const { pretty, indent } = prettyIndent(
1069
+ isBitmark ? bitmarkOptions.prettifyJson : jsonOptions.prettify
1070
+ );
1118
1071
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1119
1072
  const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
1120
1073
  this.throwOnError(out);
@@ -1166,7 +1119,7 @@ var BitmarkParserGenerator = class {
1166
1119
  const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
1167
1120
  if (!isHtmlInput) {
1168
1121
  const { source, isBitmark } = this.resolveInput(input, void 0);
1169
- 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);
1170
1123
  this.throwOnError(out2);
1171
1124
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
1172
1125
  }
@@ -1176,12 +1129,12 @@ var BitmarkParserGenerator = class {
1176
1129
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
1177
1130
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
1178
1131
  if (outputFormat === "html") {
1179
- const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1);
1132
+ const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false);
1180
1133
  this.throwOnError(out2);
1181
1134
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
1182
1135
  }
1183
1136
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
1184
- const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces);
1137
+ const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false);
1185
1138
  this.throwOnError(out);
1186
1139
  if (outputFormat === "bitmark" || outputFormat === "text") {
1187
1140
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -1206,7 +1159,7 @@ var BitmarkParserGenerator = class {
1206
1159
  const opts = Object.assign({}, options);
1207
1160
  const wasm2 = getLegacyWasm();
1208
1161
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
1209
- 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);
1210
1163
  this.throwOnError(out);
1211
1164
  return makePseudoAst(JSON.parse(out));
1212
1165
  }
@@ -1313,7 +1266,7 @@ var BitmarkParserGenerator = class {
1313
1266
  }
1314
1267
  }
1315
1268
  const { source, isBitmark } = this.resolveInput(input, void 0);
1316
- 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);
1317
1270
  this.throwOnError(out);
1318
1271
  return out;
1319
1272
  }
@@ -1785,6 +1738,11 @@ var StringWriter = stubClass("StringWriter", INTERNAL_REASON);
1785
1738
  var FileWriter = stubClass("FileWriter", INTERNAL_REASON);
1786
1739
  var StreamWriter = stubClass("StreamWriter", INTERNAL_REASON);
1787
1740
 
1741
+ // src/types.ts
1742
+ function patchEntry(path, op, value) {
1743
+ return value === void 0 ? { path, op } : { path, op, value };
1744
+ }
1745
+
1788
1746
  // src/browser/index.ts
1789
1747
  setLegacyWasm(bitmark_wasm_exports);
1790
1748
  async function init(module_or_path) {
@@ -1799,8 +1757,27 @@ function version() {
1799
1757
  function lex2(input, options = {}) {
1800
1758
  return lex(input, options.stage ?? "lex");
1801
1759
  }
1802
- function parse2(input, options = {}) {
1803
- return parse(input, options.mode ?? "optimized");
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
+ );
1771
+ if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1772
+ return JSON.parse(out);
1773
+ }
1774
+ function objectsToBitmark(bits, options = {}) {
1775
+ const entries = bits.map(
1776
+ (b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
1777
+ );
1778
+ const out = convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1, false);
1779
+ if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1780
+ return out;
1804
1781
  }
1805
1782
  function convert2(input, options = {}) {
1806
1783
  return convert(
@@ -1810,16 +1787,10 @@ function convert2(input, options = {}) {
1810
1787
  options.mode ?? "optimized",
1811
1788
  options.pretty ?? false,
1812
1789
  options.indent ?? 2,
1813
- options.spacesAroundValues ?? 1
1790
+ options.spacesAroundValues ?? 1,
1791
+ options.includeUnknownProperties ?? false
1814
1792
  );
1815
1793
  }
1816
- function optimize2(input, options = {}) {
1817
- return optimize(input, options.inputFormat ?? "auto", options.pretty ?? false, options.indent ?? 2);
1818
- }
1819
- function fullize2(input, options = {}) {
1820
- return fullize(input, options.inputFormat ?? "auto", options.pretty ?? false, options.indent ?? 2);
1821
- }
1822
- var expand = fullize2;
1823
1794
  function canonicalize2(input, options = {}) {
1824
1795
  return canonicalize(
1825
1796
  input,
@@ -1877,19 +1848,18 @@ function info2(options = {}) {
1877
1848
  }
1878
1849
  // Annotate the CommonJS export names for ESM import in node:
1879
1850
  0 && (module.exports = {
1851
+ bitmarkToObjects,
1880
1852
  breakscapeText,
1881
1853
  canonicalize,
1882
1854
  convert,
1883
1855
  countBits,
1884
- expand,
1885
- fullize,
1886
1856
  info,
1887
1857
  init,
1888
1858
  initSync,
1889
1859
  legacy,
1890
1860
  lex,
1891
- optimize,
1892
- parse,
1861
+ objectsToBitmark,
1862
+ patchEntry,
1893
1863
  splitBits,
1894
1864
  transform,
1895
1865
  transformParallel,