@gmb/bitmark-parser-generator 4.3.0 → 4.6.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.
package/dist/index.cjs CHANGED
@@ -72,6 +72,7 @@ var BitType = (0, import_superenum.superenum)({
72
72
  // Not to be used as a bit, but as a base for other bit types
73
73
  advertising: "advertising",
74
74
  advertisingAdvertorial: "advertising-advertorial",
75
+ advertisingAdvertorialPage: "advertising-advertorial-page",
75
76
  advertisingCallToAction: "advertising-call-to-action",
76
77
  advertisingCallToActionMeeting: "advertising-call-to-action-meeting",
77
78
  advertisingBanner: "advertising-banner",
@@ -299,8 +300,8 @@ var BitType = (0, import_superenum.superenum)({
299
300
  extractorAiChat: "extractor-ai-chat",
300
301
  extractorBlock: "extractor-block",
301
302
  extractorConfiguration: "extractor-configuration",
302
- extractorEmbeddedImage: "extractor-embedded-image",
303
- extractorEmbeddedImageCollapsible: "extractor-embedded-image-collapsible",
303
+ extractorImage: "extractor-image",
304
+ extractorImageCollapsible: "extractor-image-collapsible",
304
305
  extractorInformation: "extractor-information",
305
306
  extractorPage: "extractor-page",
306
307
  extractorPageCollapsible: "extractor-page-collapsible",
@@ -3333,6 +3334,12 @@ var GROUPS = {
3333
3334
  description: "If true, the quiz solutions are revealed",
3334
3335
  format: TagFormat.boolean
3335
3336
  // defaultValue: 'false',
3337
+ },
3338
+ {
3339
+ key: ConfigKey.property_additionalSolutions,
3340
+ description: "Additional solutions",
3341
+ format: TagFormat.plainText,
3342
+ maxCount: Count.infinity
3336
3343
  }
3337
3344
  ]
3338
3345
  },
@@ -4951,12 +4958,6 @@ var BITS = {
4951
4958
  description: "If the cloze solutions should be strikethrough",
4952
4959
  format: TagFormat.boolean
4953
4960
  },
4954
- {
4955
- key: ConfigKey.property_additionalSolutions,
4956
- description: "Additional solutions for the cloze quiz",
4957
- format: TagFormat.plainText,
4958
- maxCount: Count.infinity
4959
- },
4960
4961
  {
4961
4962
  key: ConfigKey.group_gap,
4962
4963
  description: "Tags for gaps in cloze bits"
@@ -5484,12 +5485,6 @@ var BITS = {
5484
5485
  description: "Sample solution for the essay, used as a reference answer",
5485
5486
  format: TagFormat.plainText
5486
5487
  },
5487
- {
5488
- key: ConfigKey.property_additionalSolutions,
5489
- description: "Additional solutions for the essay, used for alternative answers",
5490
- format: TagFormat.plainText,
5491
- maxCount: Count.infinity
5492
- },
5493
5488
  {
5494
5489
  key: ConfigKey.property_partialAnswer,
5495
5490
  description: "Partial answer for the essay, used to indicate incomplete answers",
@@ -6321,15 +6316,15 @@ var BITS = {
6321
6316
  description: "Extractor configuration bit, used to configure extractors in articles or books",
6322
6317
  textFormatDefault: TextFormat.plainText
6323
6318
  },
6324
- [BitType.extractorEmbeddedImage]: {
6319
+ [BitType.extractorImage]: {
6325
6320
  since: "4.3.0",
6326
6321
  baseBitType: BitType.image,
6327
6322
  description: "Extractor embedded image bit, used for embedded images extracted from PDFs",
6328
6323
  textFormatDefault: TextFormat.plainText
6329
6324
  },
6330
- [BitType.extractorEmbeddedImageCollapsible]: {
6325
+ [BitType.extractorImageCollapsible]: {
6331
6326
  since: "4.3.0",
6332
- baseBitType: BitType.extractorEmbeddedImage,
6327
+ baseBitType: BitType.extractorImage,
6333
6328
  description: "Collapsible extractor embedded image bit, used for embedded images extracted from PDFs",
6334
6329
  textFormatDefault: TextFormat.plainText
6335
6330
  },
@@ -7569,6 +7564,11 @@ var BITS = {
7569
7564
  baseBitType: BitType.page,
7570
7565
  description: "Page cover image bit, used to create cover images for pages"
7571
7566
  },
7567
+ [BitType.advertisingAdvertorialPage]: {
7568
+ since: "4.5.0",
7569
+ baseBitType: BitType.page,
7570
+ description: "Advertorial Page bit, used to create advertorial pages"
7571
+ },
7572
7572
  [BitType.pageBuyButton]: {
7573
7573
  since: "1.4.3",
7574
7574
  baseBitType: BitType._standard,
@@ -9116,7 +9116,7 @@ var instance2 = new Config();
9116
9116
  // src/generated/package_info.ts
9117
9117
  var PACKAGE_INFO = {
9118
9118
  "name": "@gmb/bitmark-parser-generator",
9119
- "version": "4.3.0",
9119
+ "version": "4.6.0",
9120
9120
  "author": "Get More Brain Ltd",
9121
9121
  "license": "ISC",
9122
9122
  "description": "A bitmark parser and generator using Peggy.js"
@@ -10523,14 +10523,17 @@ var ArrayUtils = class {
10523
10523
  */
10524
10524
  removeDuplicates(arr, keyFunc) {
10525
10525
  const seen = /* @__PURE__ */ new Set();
10526
- for (const item of arr) {
10526
+ let write = 0;
10527
+ for (let read = 0; read < arr.length; read++) {
10528
+ const item = arr[read];
10527
10529
  const k = keyFunc ? keyFunc(item) : item;
10528
- if (seen.has(k)) {
10529
- const index = arr.lastIndexOf(item);
10530
- if (index !== -1) arr.splice(index, 1);
10530
+ if (!seen.has(k)) {
10531
+ seen.add(k);
10532
+ if (write !== read) arr[write] = item;
10533
+ write++;
10531
10534
  }
10532
- seen.add(k);
10533
10535
  }
10536
+ if (write < arr.length) arr.length = write;
10534
10537
  return arr;
10535
10538
  }
10536
10539
  };
@@ -27462,22 +27465,9 @@ var JsonGenerator = class extends AstWalkerGenerator {
27462
27465
  const bitType = this.getBitType(route);
27463
27466
  const parent = this.getParentNode(route);
27464
27467
  if (parser2 && bitType) {
27465
- const {
27466
- version,
27467
- excessResources: parserExcessResources,
27468
- warnings,
27469
- errors,
27470
- ...parserRest
27471
- } = parser2;
27468
+ const { version, warnings, errors, ...parserRest } = parser2;
27472
27469
  const bitmarkVersion = `${this.bitmarkVersion}`;
27473
27470
  const textParserVersion = this.textParserVersion;
27474
- let excessResources;
27475
- if (Array.isArray(parserExcessResources) && parserExcessResources.length > 0) {
27476
- excessResources = [];
27477
- for (const r of parserExcessResources) {
27478
- excessResources.push(r);
27479
- }
27480
- }
27481
27471
  const internalComments = this.getInternalComments(route);
27482
27472
  if (parent?.key === NodeType.bitsValue) {
27483
27473
  this.bitWrapperJson.parser = {
@@ -27487,8 +27477,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
27487
27477
  internalComments,
27488
27478
  ...parserRest,
27489
27479
  warnings,
27490
- errors,
27491
- excessResources
27480
+ errors
27492
27481
  };
27493
27482
  if (!this.options.enableWarnings) {
27494
27483
  delete this.bitWrapperJson.parser.warnings;
@@ -29490,7 +29479,10 @@ var BitmarkPegParserValidator = class {
29490
29479
  if (warning.invalid || warning.excessResource) {
29491
29480
  warningStr = `${keyStr} is not valid here (incorrectly chained?).${ignoredStr}`;
29492
29481
  } else if (warning.tooMany != null) {
29493
- warningStr = `${keyStr} is included more than ${warning.tooMany} time(s).`;
29482
+ warningStr = `${keyStr} is included more than the required ${warning.tooMany} time(s).`;
29483
+ if (warning.tooMany === 0 && typeKey === TypeKey.Resource) {
29484
+ warningStr += ` Did you forget the '${key}' in the bit header?`;
29485
+ }
29494
29486
  if (warning.tooMany > 0) warningStr += " The earlier ones will be ignored";
29495
29487
  } else if (warning.extraProperty) {
29496
29488
  warningStr = `${keyStr} is an unknown property. It can be excluded from the output using the 'excludeUnknownProperties' flag`;
@@ -31263,7 +31255,6 @@ function extractAvatarImage(context, resources) {
31263
31255
  }
31264
31256
  }
31265
31257
  if (excessResources.length > 0) {
31266
- context.parser.excessResources = excessResources;
31267
31258
  context.addWarning(
31268
31259
  `${excessResources.length} excess resource(s) present in the [@person] chain.`
31269
31260
  );
@@ -31536,9 +31527,10 @@ function buildResources(context, resourceTypeAttachment, resources) {
31536
31527
  `Resource type [&${resourceTypeAttachment}] is specified in the bit header, but no such resource is present`
31537
31528
  );
31538
31529
  }
31539
- if (excessResources.length > 0) {
31540
- context.parser.excessResources = excessResources;
31541
- }
31530
+ excessResources.forEach((r) => {
31531
+ r.__excessResource = true;
31532
+ filteredResources.push(r);
31533
+ });
31542
31534
  return filteredResources;
31543
31535
  }
31544
31536
  function resourceContentProcessor(context, _contentDepth, tagsConfig, content, target) {