@gmb/bitmark-parser-generator 4.3.0 → 4.5.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.
@@ -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
  }
@@ -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
  }
@@ -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",
@@ -6262,15 +6263,15 @@ var BITS = {
6262
6263
  description: "Extractor configuration bit, used to configure extractors in articles or books",
6263
6264
  textFormatDefault: TextFormat2.plainText
6264
6265
  },
6265
- [BitType.extractorEmbeddedImage]: {
6266
+ [BitType.extractorImage]: {
6266
6267
  since: "4.3.0",
6267
6268
  baseBitType: BitType.image,
6268
6269
  description: "Extractor embedded image bit, used for embedded images extracted from PDFs",
6269
6270
  textFormatDefault: TextFormat2.plainText
6270
6271
  },
6271
- [BitType.extractorEmbeddedImageCollapsible]: {
6272
+ [BitType.extractorImageCollapsible]: {
6272
6273
  since: "4.3.0",
6273
- baseBitType: BitType.extractorEmbeddedImage,
6274
+ baseBitType: BitType.extractorImage,
6274
6275
  description: "Collapsible extractor embedded image bit, used for embedded images extracted from PDFs",
6275
6276
  textFormatDefault: TextFormat2.plainText
6276
6277
  },
@@ -7510,6 +7511,11 @@ var BITS = {
7510
7511
  baseBitType: BitType.page,
7511
7512
  description: "Page cover image bit, used to create cover images for pages"
7512
7513
  },
7514
+ [BitType.advertisingAdvertorialPage]: {
7515
+ since: "4.5.0",
7516
+ baseBitType: BitType.page,
7517
+ description: "Advertorial Page bit, used to create advertorial pages"
7518
+ },
7513
7519
  [BitType.pageBuyButton]: {
7514
7520
  since: "1.4.3",
7515
7521
  baseBitType: BitType._standard,
@@ -9057,7 +9063,7 @@ var instance2 = new Config();
9057
9063
  // src/generated/package_info.ts
9058
9064
  var PACKAGE_INFO = {
9059
9065
  "name": "@gmb/bitmark-parser-generator",
9060
- "version": "4.3.0",
9066
+ "version": "4.5.0",
9061
9067
  "author": "Get More Brain Ltd",
9062
9068
  "license": "ISC",
9063
9069
  "description": "A bitmark parser and generator using Peggy.js"
@@ -10464,14 +10470,17 @@ var ArrayUtils = class {
10464
10470
  */
10465
10471
  removeDuplicates(arr, keyFunc) {
10466
10472
  const seen = /* @__PURE__ */ new Set();
10467
- for (const item of arr) {
10473
+ let write = 0;
10474
+ for (let read = 0; read < arr.length; read++) {
10475
+ const item = arr[read];
10468
10476
  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);
10477
+ if (!seen.has(k)) {
10478
+ seen.add(k);
10479
+ if (write !== read) arr[write] = item;
10480
+ write++;
10472
10481
  }
10473
- seen.add(k);
10474
10482
  }
10483
+ if (write < arr.length) arr.length = write;
10475
10484
  return arr;
10476
10485
  }
10477
10486
  };
@@ -27403,22 +27412,9 @@ var JsonGenerator = class extends AstWalkerGenerator {
27403
27412
  const bitType = this.getBitType(route);
27404
27413
  const parent = this.getParentNode(route);
27405
27414
  if (parser2 && bitType) {
27406
- const {
27407
- version,
27408
- excessResources: parserExcessResources,
27409
- warnings,
27410
- errors,
27411
- ...parserRest
27412
- } = parser2;
27415
+ const { version, warnings, errors, ...parserRest } = parser2;
27413
27416
  const bitmarkVersion = `${this.bitmarkVersion}`;
27414
27417
  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
27418
  const internalComments = this.getInternalComments(route);
27423
27419
  if (parent?.key === NodeType.bitsValue) {
27424
27420
  this.bitWrapperJson.parser = {
@@ -27428,8 +27424,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
27428
27424
  internalComments,
27429
27425
  ...parserRest,
27430
27426
  warnings,
27431
- errors,
27432
- excessResources
27427
+ errors
27433
27428
  };
27434
27429
  if (!this.options.enableWarnings) {
27435
27430
  delete this.bitWrapperJson.parser.warnings;
@@ -29413,7 +29408,10 @@ var BitmarkPegParserValidator = class {
29413
29408
  if (warning.invalid || warning.excessResource) {
29414
29409
  warningStr = `${keyStr} is not valid here (incorrectly chained?).${ignoredStr}`;
29415
29410
  } else if (warning.tooMany != null) {
29416
- warningStr = `${keyStr} is included more than ${warning.tooMany} time(s).`;
29411
+ warningStr = `${keyStr} is included more than the required ${warning.tooMany} time(s).`;
29412
+ if (warning.tooMany === 0 && typeKey === TypeKey.Resource) {
29413
+ warningStr += ` Did you forget the '${key}' in the bit header?`;
29414
+ }
29417
29415
  if (warning.tooMany > 0) warningStr += " The earlier ones will be ignored";
29418
29416
  } else if (warning.extraProperty) {
29419
29417
  warningStr = `${keyStr} is an unknown property. It can be excluded from the output using the 'excludeUnknownProperties' flag`;
@@ -31186,7 +31184,6 @@ function extractAvatarImage(context, resources) {
31186
31184
  }
31187
31185
  }
31188
31186
  if (excessResources.length > 0) {
31189
- context.parser.excessResources = excessResources;
31190
31187
  context.addWarning(
31191
31188
  `${excessResources.length} excess resource(s) present in the [@person] chain.`
31192
31189
  );
@@ -31459,9 +31456,10 @@ function buildResources(context, resourceTypeAttachment, resources) {
31459
31456
  `Resource type [&${resourceTypeAttachment}] is specified in the bit header, but no such resource is present`
31460
31457
  );
31461
31458
  }
31462
- if (excessResources.length > 0) {
31463
- context.parser.excessResources = excessResources;
31464
- }
31459
+ excessResources.forEach((r) => {
31460
+ r.__excessResource = true;
31461
+ filteredResources.push(r);
31462
+ });
31465
31463
  return filteredResources;
31466
31464
  }
31467
31465
  function resourceContentProcessor(context, _contentDepth, tagsConfig, content, target) {