@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/dist/legacy.d.ts CHANGED
@@ -77,21 +77,32 @@ interface FileOptions {
77
77
  }
78
78
  /** Options for bitmark generation */
79
79
  interface BitmarkOptions {
80
- explicitTextFormat?: boolean;
80
+ /** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
81
+ explicitTextFormat?: false;
81
82
  prettifyJson?: boolean | number;
82
- cardSetVersion?: CardSetVersionType;
83
+ /** bitmark v3 only — card set version `1` throws `LegacyUnsupportedError` at runtime. */
84
+ cardSetVersion?: typeof CardSetVersion.v2;
83
85
  spacesAroundValues?: number | boolean;
84
- debugGenerationInline?: boolean;
85
- noBreakscaping?: boolean;
86
+ /** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
87
+ debugGenerationInline?: false;
88
+ /** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
89
+ noBreakscaping?: false;
86
90
  }
87
91
  /** Options for JSON generation */
88
92
  interface JsonOptions {
89
93
  enableWarnings?: boolean | number;
90
94
  prettify?: boolean | number;
91
95
  stringify?: boolean;
92
- textAsPlainText?: boolean;
96
+ /** bitmark v3 only — `true` throws `LegacyUnsupportedError` at runtime. */
97
+ textAsPlainText?: false;
98
+ /**
99
+ * Exclude unknown properties from the JSON output (default: `false` —
100
+ * unknown properties are included, as bpg). The parser's warning text
101
+ * references the new API's inverse flag (`includeUnknownProperties`).
102
+ */
93
103
  excludeUnknownProperties?: boolean;
94
- debugGenerationInline?: boolean;
104
+ /** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
105
+ debugGenerationInline?: false;
95
106
  }
96
107
  /** Options for bitmark text JSON generation */
97
108
  interface TextJsonOptions {
@@ -106,7 +117,8 @@ interface InfoOptions {
106
117
  }
107
118
  /** Conversion options for bitmark / JSON conversion */
108
119
  interface ConvertOptions {
109
- bitmarkVersion?: BitmarkVersionType;
120
+ /** bitmark v3 only — version `2` throws `LegacyUnsupportedError` at runtime. */
121
+ bitmarkVersion?: typeof BitmarkVersion.v3;
110
122
  bitmarkParserType?: BitmarkParserTypeType;
111
123
  inputFormat?: InputType;
112
124
  outputFormat?: OutputType;
@@ -117,7 +129,8 @@ interface ConvertOptions {
117
129
  }
118
130
  /** Prettify options for bitmark / JSON prettify / validate */
119
131
  interface UpgradeOptions {
120
- bitmarkVersion?: BitmarkVersionType;
132
+ /** bitmark v3 only — version `2` throws `LegacyUnsupportedError` at runtime. */
133
+ bitmarkVersion?: typeof BitmarkVersion.v3;
121
134
  bitmarkParserType?: BitmarkParserTypeType;
122
135
  inputFormat?: InputType;
123
136
  outputFile?: string;
@@ -147,7 +160,8 @@ interface ConvertHtmlTableOptions {
147
160
  outputFormat?: OutputType | "html";
148
161
  tableFormat?: string;
149
162
  keepUnknownTags?: boolean;
150
- noBreakscaping?: boolean;
163
+ /** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
164
+ noBreakscaping?: false;
151
165
  outputFile?: string;
152
166
  fileOptions?: FileOptions;
153
167
  bitmarkOptions?: BitmarkOptions;
@@ -343,10 +357,14 @@ declare class Builder {
343
357
  * NOTE (documented divergences from bpg):
344
358
  * - the return value is bit JSON, not bpg's internal AST node model;
345
359
  * - `resourceType` (an inference hint in bpg) is not carried into the
346
- * JSON — the attached `resource` object is authoritative;
347
- * - more than one entry in `resources` passes through under a
348
- * `resources` key (kept visible, not silently dropped) — the canonical
349
- * single attachment is `resource`.
360
+ * JSON — the attached `resource` object is authoritative.
361
+ *
362
+ * `resources` follows bpg's JsonGenerator routing: on a bit whose config
363
+ * maps a repeatable resource tag group onto a collection key (e.g.
364
+ * `images` / `logos` — see the generated RESOURCE_COLLECTION_KEYS), the
365
+ * matching-type entries land under that key; on every other bit the first
366
+ * entry becomes the canonical single `resource` (as bpg: "if there is
367
+ * more than one resource, use the first one").
350
368
  */
351
369
  buildBit(data: Record<string, unknown>, _options?: BuildBitOptions): Record<string, unknown>;
352
370
  /**
@@ -359,10 +377,19 @@ declare class Builder {
359
377
  * (inline marks become TextAst marks); the composer would otherwise treat
360
378
  * them as literal text. Converts top-level JsonText fields in place.
361
379
  * Nested (card-content) strings are left literal — documented divergence.
380
+ *
381
+ * A string body is dispatched on the bit's resolved text format, as bpg's
382
+ * buildBody: bitmark text is parsed to TextAst, `json` is JSON.parsed
383
+ * (unparseable → null), and plain-text formats (text/latex/xml) stay
384
+ * verbatim. Tag texts are always bitmark text, independent of body format
385
+ * (bpg TextParser.toAst ignores format; only location matters).
362
386
  */
363
387
  private parseStringTexts;
364
- /** Throw bpg's exact unknown-bit-type error (`Config.getBitConfig` parity). */
365
- private assertKnownBitType;
388
+ /**
389
+ * Look up the bit's config (`wasm.info`); throws bpg's exact
390
+ * unknown-bit-type error (`Config.getBitConfig` parity).
391
+ */
392
+ private getBitConfig;
366
393
  }
367
394
 
368
395
  type ResourceMethod = (context: unknown, data: Record<string, unknown> | undefined, __typeAlias?: string) => Record<string, unknown> | undefined;
@@ -1566,4 +1593,4 @@ interface BitWrapperJson {
1566
1593
  parser?: ParserJson;
1567
1594
  }
1568
1595
 
1569
- export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type BaseBodyBitJson, type BaseResourceJson, type BitJson, BitType, type BitTypeType, type BitWrapperJson, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type BodyBitJson, type BodyBitsJson, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, BoundingBoxIndex, type BreakscapeOptions, type BuildBitOptions, Builder, CardSetVersion, type CardSetVersionType, type ChoiceJson, type CodeBlockTextNode, type CodeBlockTextNodeAttributes, type CommentMark, type ConvertHtmlTableOptions, type ConvertOptions, type ConvertTextOptions, type CreateAstOptions, type DefinitionListItemJson, type DocumentDownloadResourceJson, type DocumentDownloadResourceWrapperJson, type DocumentEmbedResourceJson, type DocumentEmbedResourceWrapperJson, type DocumentLinkResourceJson, type DocumentLinkResourceWrapperJson, type DocumentResourceJson, type DocumentResourceWrapperJson, type ExampleJson, type ExtRefMark, type ExtRefMarkAttibutes, type ExtractPlainTextOptions, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type FootnoteAttibutes, type FootnoteMark, type GapJson, type GroupTagJson, type HeadingJson, type HeadingTextNode, type HeadingTextNodeAttributes, type HighlightJson, type HighlightTextJson, HtmlTableGenerator, HtmlTableParser, type ImageInlineTextNode, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageResponsiveResourceJson, type ImageResponsiveResourceWrapperJson, type ImageSourceJson, type ImageTextNode, type ImageTextNodeAttributes, InfoFormat, type InfoFormatType, type InfoOptions, InfoType, type InfoTypeType, type IngredientJson, Input, InputFormat, type InputFormatType, type InputType, JsonFileGenerator, JsonGenerator, type JsonOptions, JsonParser, JsonStringGenerator, type JsonText, type LatexTextNode, type LatexTextNodeAttributes, type LegacyPseudoAst, LegacyUnsupportedError, type LinkMark, type LinkMarkAttibutes, type ListItemJson, type ListTextNode, type ListTextNodeAttributes, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type MediaAttributes, NodeType, Output, type OutputType, type PairJson, type ParserError, type ParserInfo, type ParserJson, type ParserLocation, type PersonJson, type PronunciationTableCellJson, type PronunciationTableJson, type QuestionJson, type QuizJson, type RatingLevelStartEndJson, type RefMark, type RefMarkAttibutes, ResourceBuilder, type ResourceDataJson, type ResourceJson, type ResourceMethod, type ResourceTypeType, type ResourceWrapperJson, type ResponseJson, type SectionTextNode, type SelectJson, type SelectOptionJson, type ServingsJson, type StatementJson, type StillImageFilmEmbedResourceJson, type StillImageFilmEmbedResourceWrapperJson, type StillImageFilmLinkResourceJson, type StillImageFilmLinkResourceWrapperJson, type StillImageFilmResourceJson, type StillImageFilmResourceWrapperJson, StreamWriter, StringWriter, type SymbolMark, type SymbolMarkAttibutes, type TableCellJson, type TableExtendedJson, type TableJson, type TableRowJson, type TableSectionJson, type TaskItemTextNode, type TaskItemTextNodeAttributes, type TechnicalTermJson, type TextAndIconJson, type TextAst, type TextFormatType, type TextJsonOptions, TextLocation, type TextLocationType, type TextMark, type TextMarkAttibutes, TextMarkType, type TextMarkTypeType, type TextNode, type TextNodeAttibutes, TextNodeType, type TextNodeTypeType, type UnbreakscapeOptions, type UpgradeOptions, type VideoEmbedResourceJson, type VideoEmbedResourceWrapperJson, type VideoLinkResourceJson, type VideoLinkResourceWrapperJson, type VideoResourceJson, type VideoResourceWrapperJson, type WebsiteLinkResourceJson, type WebsiteLinkResourceWrapperJson, type XRefMark, type XRefMarkAttibutes, bitmarkTextParse, isPseudoAst };
1596
+ export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type BaseBodyBitJson, type BaseResourceJson, type BitJson, BitType, type BitTypeType, type BitWrapperJson, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type BodyBitJson, type BodyBitsJson, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, BoundingBoxIndex, type BreakscapeOptions, type BuildBitOptions, Builder, CardSetVersion, type CardSetVersionType, type ChoiceJson, type CodeBlockTextNode, type CodeBlockTextNodeAttributes, type CommentMark, type ConvertHtmlTableOptions, type ConvertOptions, type ConvertTextOptions, type CreateAstOptions, type DefinitionListItemJson, type DocumentDownloadResourceJson, type DocumentDownloadResourceWrapperJson, type DocumentEmbedResourceJson, type DocumentEmbedResourceWrapperJson, type DocumentLinkResourceJson, type DocumentLinkResourceWrapperJson, type DocumentResourceJson, type DocumentResourceWrapperJson, type ExampleJson, type ExtRefMark, type ExtRefMarkAttibutes, type ExtractPlainTextOptions, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type FootnoteAttibutes, type FootnoteMark, type GapJson, type GroupTagJson, type HeadingJson, type HeadingTextNode, type HeadingTextNodeAttributes, type HighlightJson, type HighlightTextJson, HtmlTableGenerator, HtmlTableParser, type ImageInlineTextNode, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageResponsiveResourceJson, type ImageResponsiveResourceWrapperJson, type ImageSourceJson, type ImageTextNode, type ImageTextNodeAttributes, InfoFormat, type InfoFormatType, type InfoOptions, InfoType, type InfoTypeType, type IngredientJson, Input, InputFormat, type InputFormatType, type InputType, JsonFileGenerator, JsonGenerator, type JsonOptions, JsonParser, JsonStringGenerator, type JsonText, type LatexTextNode, type LatexTextNodeAttributes, type LegacyPseudoAst, LegacyUnsupportedError, type LinkMark, type LinkMarkAttibutes, type ListItemJson, type ListTextNode, type ListTextNodeAttributes, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type MediaAttributes, NodeType, Output, type OutputType, type PairJson, type ParserError, type ParserInfo, type ParserJson, type ParserLocation, type PersonJson, type PronunciationTableCellJson, type PronunciationTableJson, type QuestionJson, type QuizJson, type RatingLevelStartEndJson, type RefMark, type RefMarkAttibutes, ResourceBuilder, type ResourceDataJson, type ResourceJson, type ResourceMethod, type ResourceTypeType, type ResourceWrapperJson, type ResponseJson, type SectionTextNode, type SelectJson, type SelectOptionJson, type ServingsJson, type StatementJson, type StillImageFilmEmbedResourceJson, type StillImageFilmEmbedResourceWrapperJson, type StillImageFilmLinkResourceJson, type StillImageFilmLinkResourceWrapperJson, type StillImageFilmResourceJson, type StillImageFilmResourceWrapperJson, StreamWriter, StringWriter, type SymbolMark, type SymbolMarkAttibutes, type TableCellJson, type TableExtendedJson, type TableJson, type TableRowJson, type TableSectionJson, type TaskItemTextNode, type TaskItemTextNodeAttributes, type TechnicalTermJson, type JsonText as Text, type TextAndIconJson, type TextAst, type TextFormatType, type TextJsonOptions, TextLocation, type TextLocationType, type TextMark, type TextMarkAttibutes, TextMarkType, type TextMarkTypeType, type TextNode, type TextNodeAttibutes, TextNodeType, type TextNodeTypeType, type UnbreakscapeOptions, type UpgradeOptions, type VideoEmbedResourceJson, type VideoEmbedResourceWrapperJson, type VideoLinkResourceJson, type VideoLinkResourceWrapperJson, type VideoResourceJson, type VideoResourceWrapperJson, type WebsiteLinkResourceJson, type WebsiteLinkResourceWrapperJson, type XRefMark, type XRefMarkAttibutes, bitmarkTextParse, isPseudoAst };
package/dist/legacy.js CHANGED
@@ -45,7 +45,7 @@ function initLegacyNode(wasm2) {
45
45
  // src/generated/package_info.ts
46
46
  var PACKAGE_INFO = {
47
47
  "name": "@gmb/bitmark-parser",
48
- "version": "6.2.0",
48
+ "version": "6.3.1",
49
49
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
50
50
  "license": "ISC",
51
51
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -76,16 +76,14 @@ function validateVersionOptions(opts) {
76
76
  }
77
77
  function validateBitmarkOptions(o) {
78
78
  if (o.explicitTextFormat) unsupportedOption("bitmarkOptions.explicitTextFormat");
79
- if (o.prettifyJson !== void 0 && o.prettifyJson !== false) {
80
- unsupportedOption("bitmarkOptions.prettifyJson", "embedded-JSON body prettification is not supported");
79
+ if (o.cardSetVersion === 1) {
80
+ unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
81
81
  }
82
- if (o.cardSetVersion === 1) unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
83
82
  if (o.debugGenerationInline) unsupportedOption("bitmarkOptions.debugGenerationInline");
84
83
  if (o.noBreakscaping) unsupportedOption("bitmarkOptions.noBreakscaping");
85
84
  }
86
85
  function validateJsonOptions(o) {
87
86
  if (o.textAsPlainText) unsupportedOption("jsonOptions.textAsPlainText", V3_ONLY);
88
- if (o.excludeUnknownProperties) unsupportedOption("jsonOptions.excludeUnknownProperties");
89
87
  if (o.debugGenerationInline) unsupportedOption("jsonOptions.debugGenerationInline");
90
88
  }
91
89
  function prettyIndent(prettify) {
@@ -121,6 +119,14 @@ function isPseudoAst(v) {
121
119
  return v !== null && typeof v === "object" && (PSEUDO_AST_MARKER in v || Array.isArray(v.bits));
122
120
  }
123
121
 
122
+ // src/legacy/generated/resource-collection-keys.ts
123
+ var RESOURCE_COLLECTION_KEYS = {
124
+ "extractor-image": { key: "images", resourceType: "image" },
125
+ "extractor-image-collapsible": { key: "images", resourceType: "image" },
126
+ "images-logo-grave": { key: "logos", resourceType: "image" },
127
+ "prototype-images": { key: "images", resourceType: "image" }
128
+ };
129
+
124
130
  // src/legacy/builder.ts
125
131
  var BUILT_BIT_PARSER = /* @__PURE__ */ Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser");
126
132
  var DATA_KEY_TO_JSON_KEY = {
@@ -133,6 +139,13 @@ var DEPRECATED_TEXT_FORMATS = {
133
139
  "bitmark--": "bitmark++",
134
140
  "bitmark+": "bitmark++"
135
141
  };
142
+ var CONFIG_BODY_FORMAT_TO_TEXT_FORMAT = {
143
+ bitmark: "bitmark++",
144
+ text: "text",
145
+ json: "json",
146
+ latex: "latex",
147
+ xml: "xml"
148
+ };
136
149
  var TAG_TEXT_KEYS = [
137
150
  "title",
138
151
  "subtitle",
@@ -165,16 +178,20 @@ var Builder = class {
165
178
  * NOTE (documented divergences from bpg):
166
179
  * - the return value is bit JSON, not bpg's internal AST node model;
167
180
  * - `resourceType` (an inference hint in bpg) is not carried into the
168
- * JSON — the attached `resource` object is authoritative;
169
- * - more than one entry in `resources` passes through under a
170
- * `resources` key (kept visible, not silently dropped) — the canonical
171
- * single attachment is `resource`.
181
+ * JSON — the attached `resource` object is authoritative.
182
+ *
183
+ * `resources` follows bpg's JsonGenerator routing: on a bit whose config
184
+ * maps a repeatable resource tag group onto a collection key (e.g.
185
+ * `images` / `logos` — see the generated RESOURCE_COLLECTION_KEYS), the
186
+ * matching-type entries land under that key; on every other bit the first
187
+ * entry becomes the canonical single `resource` (as bpg: "if there is
188
+ * more than one resource, use the first one").
172
189
  */
173
190
  buildBit(data, _options) {
174
191
  const wasm2 = getLegacyWasm();
175
192
  const src = { ...data };
176
193
  const bitType = src.bitType;
177
- this.assertKnownBitType(bitType);
194
+ const bitConfig = this.getBitConfig(bitType);
178
195
  const bit = {};
179
196
  bit.type = bitType;
180
197
  if (src.isCommented) {
@@ -187,6 +204,8 @@ var Builder = class {
187
204
  if (textFormat !== void 0) {
188
205
  bit.format = DEPRECATED_TEXT_FORMATS[textFormat] ?? textFormat;
189
206
  delete src.textFormat;
207
+ } else {
208
+ bit.format = CONFIG_BODY_FORMAT_TO_TEXT_FORMAT[bitConfig.bodyFormat ?? ""] ?? "bitmark++";
190
209
  }
191
210
  delete src.resourceType;
192
211
  const body = src.body;
@@ -204,12 +223,15 @@ var Builder = class {
204
223
  delete src.__isDefaultExample;
205
224
  }
206
225
  const resources = src.resources;
207
- if (resources !== void 0) {
208
- if (Array.isArray(resources)) {
209
- if (resources.length === 1) bit.resource = resources[0];
210
- else if (resources.length > 1) bit.resources = resources;
211
- } else {
212
- bit.resource = resources;
226
+ if (resources !== void 0 && bitType !== void 0) {
227
+ const list = Array.isArray(resources) ? resources : [resources];
228
+ const collection = RESOURCE_COLLECTION_KEYS[bitType];
229
+ if (collection) {
230
+ bit[collection.key] = list.filter(
231
+ (r) => r !== null && typeof r === "object" && r.type === collection.resourceType
232
+ );
233
+ } else if (list.length >= 1) {
234
+ bit.resource = list[0];
213
235
  }
214
236
  delete src.resources;
215
237
  }
@@ -227,7 +249,7 @@ var Builder = class {
227
249
  }
228
250
  }
229
251
  this.parseStringTexts(bit);
230
- const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1);
252
+ const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false);
231
253
  if (out.startsWith("error:")) {
232
254
  throw new Error(out.slice("error:".length).trim());
233
255
  }
@@ -275,6 +297,12 @@ var Builder = class {
275
297
  * (inline marks become TextAst marks); the composer would otherwise treat
276
298
  * them as literal text. Converts top-level JsonText fields in place.
277
299
  * Nested (card-content) strings are left literal — documented divergence.
300
+ *
301
+ * A string body is dispatched on the bit's resolved text format, as bpg's
302
+ * buildBody: bitmark text is parsed to TextAst, `json` is JSON.parsed
303
+ * (unparseable → null), and plain-text formats (text/latex/xml) stay
304
+ * verbatim. Tag texts are always bitmark text, independent of body format
305
+ * (bpg TextParser.toAst ignores format; only location matters).
278
306
  */
279
307
  parseStringTexts(bit) {
280
308
  const wasm2 = getLegacyWasm();
@@ -289,29 +317,36 @@ var Builder = class {
289
317
  };
290
318
  const format = bit.format;
291
319
  const bitmarkBody = format === void 0 || format === "bitmark++" || format === "bitmark+";
292
- if (typeof bit.body === "string" && bitmarkBody) {
293
- bit.body = toAst(bit.body, "body");
320
+ if (typeof bit.body === "string") {
321
+ if (format === "json") {
322
+ try {
323
+ bit.body = JSON.parse(bit.body);
324
+ } catch {
325
+ bit.body = null;
326
+ }
327
+ } else if (bitmarkBody) {
328
+ bit.body = toAst(bit.body, "body");
329
+ }
294
330
  }
295
331
  for (const key of TAG_TEXT_KEYS) {
296
332
  const v = bit[key];
297
333
  if (typeof v === "string") bit[key] = toAst(v, "tag");
298
334
  }
299
335
  }
300
- /** Throw bpg's exact unknown-bit-type error (`Config.getBitConfig` parity). */
301
- assertKnownBitType(bitType) {
336
+ /**
337
+ * Look up the bit's config (`wasm.info`); throws bpg's exact
338
+ * unknown-bit-type error (`Config.getBitConfig` parity).
339
+ */
340
+ getBitConfig(bitType) {
302
341
  const wasm2 = getLegacyWasm();
303
- let known = false;
304
342
  if (bitType !== void 0) {
305
343
  try {
306
344
  const info = JSON.parse(wasm2.info("bit", "json", bitType, false, 2));
307
- known = info.error === void 0;
345
+ if (info.error === void 0) return info;
308
346
  } catch {
309
- known = false;
310
347
  }
311
348
  }
312
- if (!known) {
313
- throw new Error(`No config found for bit: ${bitType}`);
314
- }
349
+ throw new Error(`No config found for bit: ${bitType}`);
315
350
  }
316
351
  };
317
352
  function stripUndefined(src, exclude) {
@@ -351,8 +386,10 @@ var BitmarkParserGenerator = class {
351
386
  const outputFormat = opts.outputFormat ?? (isBitmark ? "json" : "bitmark");
352
387
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
353
388
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
389
+ const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
354
390
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
355
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", pretty, indent, spaces);
391
+ const includeUnknown = !jsonOptions.excludeUnknownProperties;
392
+ const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown);
356
393
  this.throwOnError(out);
357
394
  if (outputFormat === "bitmark" || outputFormat === "text") {
358
395
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -382,7 +419,9 @@ var BitmarkParserGenerator = class {
382
419
  this.checkBrowserFileWrite(opts.outputFile);
383
420
  const wasm2 = getLegacyWasm();
384
421
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
385
- const { pretty, indent } = prettyIndent(jsonOptions.prettify);
422
+ const { pretty, indent } = prettyIndent(
423
+ isBitmark ? bitmarkOptions.prettifyJson : jsonOptions.prettify
424
+ );
386
425
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
387
426
  const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
388
427
  this.throwOnError(out);
@@ -434,7 +473,7 @@ var BitmarkParserGenerator = class {
434
473
  const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
435
474
  if (!isHtmlInput) {
436
475
  const { source, isBitmark } = this.resolveInput(input, void 0);
437
- const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1);
476
+ const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false);
438
477
  this.throwOnError(out2);
439
478
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
440
479
  }
@@ -444,12 +483,12 @@ var BitmarkParserGenerator = class {
444
483
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
445
484
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
446
485
  if (outputFormat === "html") {
447
- const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1);
486
+ const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false);
448
487
  this.throwOnError(out2);
449
488
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
450
489
  }
451
490
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
452
- const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces);
491
+ const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false);
453
492
  this.throwOnError(out);
454
493
  if (outputFormat === "bitmark" || outputFormat === "text") {
455
494
  return this.deliver(out, opts.outputFile, opts.fileOptions);
@@ -474,7 +513,7 @@ var BitmarkParserGenerator = class {
474
513
  const opts = Object.assign({}, options);
475
514
  const wasm2 = getLegacyWasm();
476
515
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
477
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1);
516
+ const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true);
478
517
  this.throwOnError(out);
479
518
  return makePseudoAst(JSON.parse(out));
480
519
  }
@@ -581,7 +620,7 @@ var BitmarkParserGenerator = class {
581
620
  }
582
621
  }
583
622
  const { source, isBitmark } = this.resolveInput(input, void 0);
584
- const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1);
623
+ const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false);
585
624
  this.throwOnError(out);
586
625
  return out;
587
626
  }