@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.d.cts CHANGED
@@ -8,6 +8,7 @@ declare const BitType: Readonly<{
8
8
  _standard: "_standard";
9
9
  advertising: "advertising";
10
10
  advertisingAdvertorial: "advertising-advertorial";
11
+ advertisingAdvertorialPage: "advertising-advertorial-page";
11
12
  advertisingCallToAction: "advertising-call-to-action";
12
13
  advertisingCallToActionMeeting: "advertising-call-to-action-meeting";
13
14
  advertisingBanner: "advertising-banner";
@@ -235,8 +236,8 @@ declare const BitType: Readonly<{
235
236
  extractorAiChat: "extractor-ai-chat";
236
237
  extractorBlock: "extractor-block";
237
238
  extractorConfiguration: "extractor-configuration";
238
- extractorEmbeddedImage: "extractor-embedded-image";
239
- extractorEmbeddedImageCollapsible: "extractor-embedded-image-collapsible";
239
+ extractorImage: "extractor-image";
240
+ extractorImageCollapsible: "extractor-image-collapsible";
240
241
  extractorInformation: "extractor-information";
241
242
  extractorPage: "extractor-page";
242
243
  extractorPageCollapsible: "extractor-page-collapsible";
@@ -600,6 +601,7 @@ declare const BitType: Readonly<{
600
601
  _standard: "_standard";
601
602
  advertising: "advertising";
602
603
  advertisingAdvertorial: "advertising-advertorial";
604
+ advertisingAdvertorialPage: "advertising-advertorial-page";
603
605
  advertisingCallToAction: "advertising-call-to-action";
604
606
  advertisingCallToActionMeeting: "advertising-call-to-action-meeting";
605
607
  advertisingBanner: "advertising-banner";
@@ -827,8 +829,8 @@ declare const BitType: Readonly<{
827
829
  extractorAiChat: "extractor-ai-chat";
828
830
  extractorBlock: "extractor-block";
829
831
  extractorConfiguration: "extractor-configuration";
830
- extractorEmbeddedImage: "extractor-embedded-image";
831
- extractorEmbeddedImageCollapsible: "extractor-embedded-image-collapsible";
832
+ extractorImage: "extractor-image";
833
+ extractorImageCollapsible: "extractor-image-collapsible";
832
834
  extractorInformation: "extractor-information";
833
835
  extractorPage: "extractor-page";
834
836
  extractorPageCollapsible: "extractor-page-collapsible";
@@ -2230,6 +2232,7 @@ interface ResourceWrapperJson {
2230
2232
  __typeAlias: ResourceTypeType;
2231
2233
  __configKey: ConfigKeyType;
2232
2234
  __invalid?: boolean;
2235
+ __excessResource?: boolean;
2233
2236
  }
2234
2237
  interface ImageResourceWrapperJson extends ResourceWrapperJson {
2235
2238
  type: 'image';
@@ -2976,7 +2979,6 @@ interface ParserInfo {
2976
2979
  version?: string;
2977
2980
  bitmarkVersion?: string;
2978
2981
  textParserVersion?: string;
2979
- excessResources?: unknown[];
2980
2982
  warnings?: ParserError[];
2981
2983
  errors?: ParserError[];
2982
2984
  }
@@ -7139,7 +7141,6 @@ interface ParserJson {
7139
7141
  bitmarkVersion?: string;
7140
7142
  commentedBitType?: string;
7141
7143
  internalComments?: string[];
7142
- excessResources?: ResourceJson[];
7143
7144
  warnings?: ParserError[];
7144
7145
  errors?: ParserError[];
7145
7146
  }
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ declare const BitType: Readonly<{
8
8
  _standard: "_standard";
9
9
  advertising: "advertising";
10
10
  advertisingAdvertorial: "advertising-advertorial";
11
+ advertisingAdvertorialPage: "advertising-advertorial-page";
11
12
  advertisingCallToAction: "advertising-call-to-action";
12
13
  advertisingCallToActionMeeting: "advertising-call-to-action-meeting";
13
14
  advertisingBanner: "advertising-banner";
@@ -235,8 +236,8 @@ declare const BitType: Readonly<{
235
236
  extractorAiChat: "extractor-ai-chat";
236
237
  extractorBlock: "extractor-block";
237
238
  extractorConfiguration: "extractor-configuration";
238
- extractorEmbeddedImage: "extractor-embedded-image";
239
- extractorEmbeddedImageCollapsible: "extractor-embedded-image-collapsible";
239
+ extractorImage: "extractor-image";
240
+ extractorImageCollapsible: "extractor-image-collapsible";
240
241
  extractorInformation: "extractor-information";
241
242
  extractorPage: "extractor-page";
242
243
  extractorPageCollapsible: "extractor-page-collapsible";
@@ -600,6 +601,7 @@ declare const BitType: Readonly<{
600
601
  _standard: "_standard";
601
602
  advertising: "advertising";
602
603
  advertisingAdvertorial: "advertising-advertorial";
604
+ advertisingAdvertorialPage: "advertising-advertorial-page";
603
605
  advertisingCallToAction: "advertising-call-to-action";
604
606
  advertisingCallToActionMeeting: "advertising-call-to-action-meeting";
605
607
  advertisingBanner: "advertising-banner";
@@ -827,8 +829,8 @@ declare const BitType: Readonly<{
827
829
  extractorAiChat: "extractor-ai-chat";
828
830
  extractorBlock: "extractor-block";
829
831
  extractorConfiguration: "extractor-configuration";
830
- extractorEmbeddedImage: "extractor-embedded-image";
831
- extractorEmbeddedImageCollapsible: "extractor-embedded-image-collapsible";
832
+ extractorImage: "extractor-image";
833
+ extractorImageCollapsible: "extractor-image-collapsible";
832
834
  extractorInformation: "extractor-information";
833
835
  extractorPage: "extractor-page";
834
836
  extractorPageCollapsible: "extractor-page-collapsible";
@@ -2230,6 +2232,7 @@ interface ResourceWrapperJson {
2230
2232
  __typeAlias: ResourceTypeType;
2231
2233
  __configKey: ConfigKeyType;
2232
2234
  __invalid?: boolean;
2235
+ __excessResource?: boolean;
2233
2236
  }
2234
2237
  interface ImageResourceWrapperJson extends ResourceWrapperJson {
2235
2238
  type: 'image';
@@ -2976,7 +2979,6 @@ interface ParserInfo {
2976
2979
  version?: string;
2977
2980
  bitmarkVersion?: string;
2978
2981
  textParserVersion?: string;
2979
- excessResources?: unknown[];
2980
2982
  warnings?: ParserError[];
2981
2983
  errors?: ParserError[];
2982
2984
  }
@@ -7139,7 +7141,6 @@ interface ParserJson {
7139
7141
  bitmarkVersion?: string;
7140
7142
  commentedBitType?: string;
7141
7143
  internalComments?: string[];
7142
- excessResources?: ResourceJson[];
7143
7144
  warnings?: ParserError[];
7144
7145
  errors?: ParserError[];
7145
7146
  }
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ var BitType = superenum({
13
13
  // Not to be used as a bit, but as a base for other bit types
14
14
  advertising: "advertising",
15
15
  advertisingAdvertorial: "advertising-advertorial",
16
+ advertisingAdvertorialPage: "advertising-advertorial-page",
16
17
  advertisingCallToAction: "advertising-call-to-action",
17
18
  advertisingCallToActionMeeting: "advertising-call-to-action-meeting",
18
19
  advertisingBanner: "advertising-banner",
@@ -240,8 +241,8 @@ var BitType = superenum({
240
241
  extractorAiChat: "extractor-ai-chat",
241
242
  extractorBlock: "extractor-block",
242
243
  extractorConfiguration: "extractor-configuration",
243
- extractorEmbeddedImage: "extractor-embedded-image",
244
- extractorEmbeddedImageCollapsible: "extractor-embedded-image-collapsible",
244
+ extractorImage: "extractor-image",
245
+ extractorImageCollapsible: "extractor-image-collapsible",
245
246
  extractorInformation: "extractor-information",
246
247
  extractorPage: "extractor-page",
247
248
  extractorPageCollapsible: "extractor-page-collapsible",
@@ -3274,6 +3275,12 @@ var GROUPS = {
3274
3275
  description: "If true, the quiz solutions are revealed",
3275
3276
  format: TagFormat.boolean
3276
3277
  // defaultValue: 'false',
3278
+ },
3279
+ {
3280
+ key: ConfigKey.property_additionalSolutions,
3281
+ description: "Additional solutions",
3282
+ format: TagFormat.plainText,
3283
+ maxCount: Count.infinity
3277
3284
  }
3278
3285
  ]
3279
3286
  },
@@ -4892,12 +4899,6 @@ var BITS = {
4892
4899
  description: "If the cloze solutions should be strikethrough",
4893
4900
  format: TagFormat.boolean
4894
4901
  },
4895
- {
4896
- key: ConfigKey.property_additionalSolutions,
4897
- description: "Additional solutions for the cloze quiz",
4898
- format: TagFormat.plainText,
4899
- maxCount: Count.infinity
4900
- },
4901
4902
  {
4902
4903
  key: ConfigKey.group_gap,
4903
4904
  description: "Tags for gaps in cloze bits"
@@ -5425,12 +5426,6 @@ var BITS = {
5425
5426
  description: "Sample solution for the essay, used as a reference answer",
5426
5427
  format: TagFormat.plainText
5427
5428
  },
5428
- {
5429
- key: ConfigKey.property_additionalSolutions,
5430
- description: "Additional solutions for the essay, used for alternative answers",
5431
- format: TagFormat.plainText,
5432
- maxCount: Count.infinity
5433
- },
5434
5429
  {
5435
5430
  key: ConfigKey.property_partialAnswer,
5436
5431
  description: "Partial answer for the essay, used to indicate incomplete answers",
@@ -6262,15 +6257,15 @@ var BITS = {
6262
6257
  description: "Extractor configuration bit, used to configure extractors in articles or books",
6263
6258
  textFormatDefault: TextFormat.plainText
6264
6259
  },
6265
- [BitType.extractorEmbeddedImage]: {
6260
+ [BitType.extractorImage]: {
6266
6261
  since: "4.3.0",
6267
6262
  baseBitType: BitType.image,
6268
6263
  description: "Extractor embedded image bit, used for embedded images extracted from PDFs",
6269
6264
  textFormatDefault: TextFormat.plainText
6270
6265
  },
6271
- [BitType.extractorEmbeddedImageCollapsible]: {
6266
+ [BitType.extractorImageCollapsible]: {
6272
6267
  since: "4.3.0",
6273
- baseBitType: BitType.extractorEmbeddedImage,
6268
+ baseBitType: BitType.extractorImage,
6274
6269
  description: "Collapsible extractor embedded image bit, used for embedded images extracted from PDFs",
6275
6270
  textFormatDefault: TextFormat.plainText
6276
6271
  },
@@ -7510,6 +7505,11 @@ var BITS = {
7510
7505
  baseBitType: BitType.page,
7511
7506
  description: "Page cover image bit, used to create cover images for pages"
7512
7507
  },
7508
+ [BitType.advertisingAdvertorialPage]: {
7509
+ since: "4.5.0",
7510
+ baseBitType: BitType.page,
7511
+ description: "Advertorial Page bit, used to create advertorial pages"
7512
+ },
7513
7513
  [BitType.pageBuyButton]: {
7514
7514
  since: "1.4.3",
7515
7515
  baseBitType: BitType._standard,
@@ -9057,7 +9057,7 @@ var instance2 = new Config();
9057
9057
  // src/generated/package_info.ts
9058
9058
  var PACKAGE_INFO = {
9059
9059
  "name": "@gmb/bitmark-parser-generator",
9060
- "version": "4.3.0",
9060
+ "version": "4.6.0",
9061
9061
  "author": "Get More Brain Ltd",
9062
9062
  "license": "ISC",
9063
9063
  "description": "A bitmark parser and generator using Peggy.js"
@@ -10464,14 +10464,17 @@ var ArrayUtils = class {
10464
10464
  */
10465
10465
  removeDuplicates(arr, keyFunc) {
10466
10466
  const seen = /* @__PURE__ */ new Set();
10467
- for (const item of arr) {
10467
+ let write = 0;
10468
+ for (let read = 0; read < arr.length; read++) {
10469
+ const item = arr[read];
10468
10470
  const k = keyFunc ? keyFunc(item) : item;
10469
- if (seen.has(k)) {
10470
- const index = arr.lastIndexOf(item);
10471
- if (index !== -1) arr.splice(index, 1);
10471
+ if (!seen.has(k)) {
10472
+ seen.add(k);
10473
+ if (write !== read) arr[write] = item;
10474
+ write++;
10472
10475
  }
10473
- seen.add(k);
10474
10476
  }
10477
+ if (write < arr.length) arr.length = write;
10475
10478
  return arr;
10476
10479
  }
10477
10480
  };
@@ -27403,22 +27406,9 @@ var JsonGenerator = class extends AstWalkerGenerator {
27403
27406
  const bitType = this.getBitType(route);
27404
27407
  const parent = this.getParentNode(route);
27405
27408
  if (parser2 && bitType) {
27406
- const {
27407
- version,
27408
- excessResources: parserExcessResources,
27409
- warnings,
27410
- errors,
27411
- ...parserRest
27412
- } = parser2;
27409
+ const { version, warnings, errors, ...parserRest } = parser2;
27413
27410
  const bitmarkVersion = `${this.bitmarkVersion}`;
27414
27411
  const textParserVersion = this.textParserVersion;
27415
- let excessResources;
27416
- if (Array.isArray(parserExcessResources) && parserExcessResources.length > 0) {
27417
- excessResources = [];
27418
- for (const r of parserExcessResources) {
27419
- excessResources.push(r);
27420
- }
27421
- }
27422
27412
  const internalComments = this.getInternalComments(route);
27423
27413
  if (parent?.key === NodeType.bitsValue) {
27424
27414
  this.bitWrapperJson.parser = {
@@ -27428,8 +27418,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
27428
27418
  internalComments,
27429
27419
  ...parserRest,
27430
27420
  warnings,
27431
- errors,
27432
- excessResources
27421
+ errors
27433
27422
  };
27434
27423
  if (!this.options.enableWarnings) {
27435
27424
  delete this.bitWrapperJson.parser.warnings;
@@ -29431,7 +29420,10 @@ var BitmarkPegParserValidator = class {
29431
29420
  if (warning.invalid || warning.excessResource) {
29432
29421
  warningStr = `${keyStr} is not valid here (incorrectly chained?).${ignoredStr}`;
29433
29422
  } else if (warning.tooMany != null) {
29434
- warningStr = `${keyStr} is included more than ${warning.tooMany} time(s).`;
29423
+ warningStr = `${keyStr} is included more than the required ${warning.tooMany} time(s).`;
29424
+ if (warning.tooMany === 0 && typeKey === TypeKey.Resource) {
29425
+ warningStr += ` Did you forget the '${key}' in the bit header?`;
29426
+ }
29435
29427
  if (warning.tooMany > 0) warningStr += " The earlier ones will be ignored";
29436
29428
  } else if (warning.extraProperty) {
29437
29429
  warningStr = `${keyStr} is an unknown property. It can be excluded from the output using the 'excludeUnknownProperties' flag`;
@@ -31204,7 +31196,6 @@ function extractAvatarImage(context, resources) {
31204
31196
  }
31205
31197
  }
31206
31198
  if (excessResources.length > 0) {
31207
- context.parser.excessResources = excessResources;
31208
31199
  context.addWarning(
31209
31200
  `${excessResources.length} excess resource(s) present in the [@person] chain.`
31210
31201
  );
@@ -31477,9 +31468,10 @@ function buildResources(context, resourceTypeAttachment, resources) {
31477
31468
  `Resource type [&${resourceTypeAttachment}] is specified in the bit header, but no such resource is present`
31478
31469
  );
31479
31470
  }
31480
- if (excessResources.length > 0) {
31481
- context.parser.excessResources = excessResources;
31482
- }
31471
+ excessResources.forEach((r) => {
31472
+ r.__excessResource = true;
31473
+ filteredResources.push(r);
31474
+ });
31483
31475
  return filteredResources;
31484
31476
  }
31485
31477
  function resourceContentProcessor(context, _contentDepth, tagsConfig, content, target) {