@gmb/bitmark-parser-generator 4.2.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,6 +236,8 @@ declare const BitType: Readonly<{
235
236
  extractorAiChat: "extractor-ai-chat";
236
237
  extractorBlock: "extractor-block";
237
238
  extractorConfiguration: "extractor-configuration";
239
+ extractorImage: "extractor-image";
240
+ extractorImageCollapsible: "extractor-image-collapsible";
238
241
  extractorInformation: "extractor-information";
239
242
  extractorPage: "extractor-page";
240
243
  extractorPageCollapsible: "extractor-page-collapsible";
@@ -598,6 +601,7 @@ declare const BitType: Readonly<{
598
601
  _standard: "_standard";
599
602
  advertising: "advertising";
600
603
  advertisingAdvertorial: "advertising-advertorial";
604
+ advertisingAdvertorialPage: "advertising-advertorial-page";
601
605
  advertisingCallToAction: "advertising-call-to-action";
602
606
  advertisingCallToActionMeeting: "advertising-call-to-action-meeting";
603
607
  advertisingBanner: "advertising-banner";
@@ -825,6 +829,8 @@ declare const BitType: Readonly<{
825
829
  extractorAiChat: "extractor-ai-chat";
826
830
  extractorBlock: "extractor-block";
827
831
  extractorConfiguration: "extractor-configuration";
832
+ extractorImage: "extractor-image";
833
+ extractorImageCollapsible: "extractor-image-collapsible";
828
834
  extractorInformation: "extractor-information";
829
835
  extractorPage: "extractor-page";
830
836
  extractorPageCollapsible: "extractor-page-collapsible";
@@ -2226,6 +2232,7 @@ interface ResourceWrapperJson {
2226
2232
  __typeAlias: ResourceTypeType;
2227
2233
  __configKey: ConfigKeyType;
2228
2234
  __invalid?: boolean;
2235
+ __excessResource?: boolean;
2229
2236
  }
2230
2237
  interface ImageResourceWrapperJson extends ResourceWrapperJson {
2231
2238
  type: 'image';
@@ -2972,7 +2979,6 @@ interface ParserInfo {
2972
2979
  version?: string;
2973
2980
  bitmarkVersion?: string;
2974
2981
  textParserVersion?: string;
2975
- excessResources?: unknown[];
2976
2982
  warnings?: ParserError[];
2977
2983
  errors?: ParserError[];
2978
2984
  }
@@ -7135,7 +7141,6 @@ interface ParserJson {
7135
7141
  bitmarkVersion?: string;
7136
7142
  commentedBitType?: string;
7137
7143
  internalComments?: string[];
7138
- excessResources?: ResourceJson[];
7139
7144
  warnings?: ParserError[];
7140
7145
  errors?: ParserError[];
7141
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,6 +236,8 @@ declare const BitType: Readonly<{
235
236
  extractorAiChat: "extractor-ai-chat";
236
237
  extractorBlock: "extractor-block";
237
238
  extractorConfiguration: "extractor-configuration";
239
+ extractorImage: "extractor-image";
240
+ extractorImageCollapsible: "extractor-image-collapsible";
238
241
  extractorInformation: "extractor-information";
239
242
  extractorPage: "extractor-page";
240
243
  extractorPageCollapsible: "extractor-page-collapsible";
@@ -598,6 +601,7 @@ declare const BitType: Readonly<{
598
601
  _standard: "_standard";
599
602
  advertising: "advertising";
600
603
  advertisingAdvertorial: "advertising-advertorial";
604
+ advertisingAdvertorialPage: "advertising-advertorial-page";
601
605
  advertisingCallToAction: "advertising-call-to-action";
602
606
  advertisingCallToActionMeeting: "advertising-call-to-action-meeting";
603
607
  advertisingBanner: "advertising-banner";
@@ -825,6 +829,8 @@ declare const BitType: Readonly<{
825
829
  extractorAiChat: "extractor-ai-chat";
826
830
  extractorBlock: "extractor-block";
827
831
  extractorConfiguration: "extractor-configuration";
832
+ extractorImage: "extractor-image";
833
+ extractorImageCollapsible: "extractor-image-collapsible";
828
834
  extractorInformation: "extractor-information";
829
835
  extractorPage: "extractor-page";
830
836
  extractorPageCollapsible: "extractor-page-collapsible";
@@ -2226,6 +2232,7 @@ interface ResourceWrapperJson {
2226
2232
  __typeAlias: ResourceTypeType;
2227
2233
  __configKey: ConfigKeyType;
2228
2234
  __invalid?: boolean;
2235
+ __excessResource?: boolean;
2229
2236
  }
2230
2237
  interface ImageResourceWrapperJson extends ResourceWrapperJson {
2231
2238
  type: 'image';
@@ -2972,7 +2979,6 @@ interface ParserInfo {
2972
2979
  version?: string;
2973
2980
  bitmarkVersion?: string;
2974
2981
  textParserVersion?: string;
2975
- excessResources?: unknown[];
2976
2982
  warnings?: ParserError[];
2977
2983
  errors?: ParserError[];
2978
2984
  }
@@ -7135,7 +7141,6 @@ interface ParserJson {
7135
7141
  bitmarkVersion?: string;
7136
7142
  commentedBitType?: string;
7137
7143
  internalComments?: string[];
7138
- excessResources?: ResourceJson[];
7139
7144
  warnings?: ParserError[];
7140
7145
  errors?: ParserError[];
7141
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,6 +241,8 @@ var BitType = superenum({
240
241
  extractorAiChat: "extractor-ai-chat",
241
242
  extractorBlock: "extractor-block",
242
243
  extractorConfiguration: "extractor-configuration",
244
+ extractorImage: "extractor-image",
245
+ extractorImageCollapsible: "extractor-image-collapsible",
243
246
  extractorInformation: "extractor-information",
244
247
  extractorPage: "extractor-page",
245
248
  extractorPageCollapsible: "extractor-page-collapsible",
@@ -6260,6 +6263,18 @@ var BITS = {
6260
6263
  description: "Extractor configuration bit, used to configure extractors in articles or books",
6261
6264
  textFormatDefault: TextFormat2.plainText
6262
6265
  },
6266
+ [BitType.extractorImage]: {
6267
+ since: "4.3.0",
6268
+ baseBitType: BitType.image,
6269
+ description: "Extractor embedded image bit, used for embedded images extracted from PDFs",
6270
+ textFormatDefault: TextFormat2.plainText
6271
+ },
6272
+ [BitType.extractorImageCollapsible]: {
6273
+ since: "4.3.0",
6274
+ baseBitType: BitType.extractorImage,
6275
+ description: "Collapsible extractor embedded image bit, used for embedded images extracted from PDFs",
6276
+ textFormatDefault: TextFormat2.plainText
6277
+ },
6263
6278
  [BitType.extractorInformation]: {
6264
6279
  since: "3.8.0",
6265
6280
  baseBitType: BitType._standard,
@@ -7496,6 +7511,11 @@ var BITS = {
7496
7511
  baseBitType: BitType.page,
7497
7512
  description: "Page cover image bit, used to create cover images for pages"
7498
7513
  },
7514
+ [BitType.advertisingAdvertorialPage]: {
7515
+ since: "4.5.0",
7516
+ baseBitType: BitType.page,
7517
+ description: "Advertorial Page bit, used to create advertorial pages"
7518
+ },
7499
7519
  [BitType.pageBuyButton]: {
7500
7520
  since: "1.4.3",
7501
7521
  baseBitType: BitType._standard,
@@ -9043,7 +9063,7 @@ var instance2 = new Config();
9043
9063
  // src/generated/package_info.ts
9044
9064
  var PACKAGE_INFO = {
9045
9065
  "name": "@gmb/bitmark-parser-generator",
9046
- "version": "4.2.0",
9066
+ "version": "4.5.0",
9047
9067
  "author": "Get More Brain Ltd",
9048
9068
  "license": "ISC",
9049
9069
  "description": "A bitmark parser and generator using Peggy.js"
@@ -10450,14 +10470,17 @@ var ArrayUtils = class {
10450
10470
  */
10451
10471
  removeDuplicates(arr, keyFunc) {
10452
10472
  const seen = /* @__PURE__ */ new Set();
10453
- for (const item of arr) {
10473
+ let write = 0;
10474
+ for (let read = 0; read < arr.length; read++) {
10475
+ const item = arr[read];
10454
10476
  const k = keyFunc ? keyFunc(item) : item;
10455
- if (seen.has(k)) {
10456
- const index = arr.lastIndexOf(item);
10457
- 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++;
10458
10481
  }
10459
- seen.add(k);
10460
10482
  }
10483
+ if (write < arr.length) arr.length = write;
10461
10484
  return arr;
10462
10485
  }
10463
10486
  };
@@ -27389,22 +27412,9 @@ var JsonGenerator = class extends AstWalkerGenerator {
27389
27412
  const bitType = this.getBitType(route);
27390
27413
  const parent = this.getParentNode(route);
27391
27414
  if (parser2 && bitType) {
27392
- const {
27393
- version,
27394
- excessResources: parserExcessResources,
27395
- warnings,
27396
- errors,
27397
- ...parserRest
27398
- } = parser2;
27415
+ const { version, warnings, errors, ...parserRest } = parser2;
27399
27416
  const bitmarkVersion = `${this.bitmarkVersion}`;
27400
27417
  const textParserVersion = this.textParserVersion;
27401
- let excessResources;
27402
- if (Array.isArray(parserExcessResources) && parserExcessResources.length > 0) {
27403
- excessResources = [];
27404
- for (const r of parserExcessResources) {
27405
- excessResources.push(r);
27406
- }
27407
- }
27408
27418
  const internalComments = this.getInternalComments(route);
27409
27419
  if (parent?.key === NodeType.bitsValue) {
27410
27420
  this.bitWrapperJson.parser = {
@@ -27414,8 +27424,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
27414
27424
  internalComments,
27415
27425
  ...parserRest,
27416
27426
  warnings,
27417
- errors,
27418
- excessResources
27427
+ errors
27419
27428
  };
27420
27429
  if (!this.options.enableWarnings) {
27421
27430
  delete this.bitWrapperJson.parser.warnings;
@@ -27734,7 +27743,6 @@ var JsonGenerator = class extends AstWalkerGenerator {
27734
27743
  */
27735
27744
  cleanBitJson(bitJson) {
27736
27745
  const bitType = instance2.getBitType(bitJson.type);
27737
- const bitConfig = instance2.getBitConfig(bitType);
27738
27746
  if (bitJson.originalType == null) bitJson.originalType = void 0;
27739
27747
  if (!bitJson.item) bitJson.item = void 0;
27740
27748
  if (instance2.isOfBitType(bitType, [BitType._error, BitType._comment])) {
@@ -27970,9 +27978,6 @@ var JsonGenerator = class extends AstWalkerGenerator {
27970
27978
  if (instance2.isOfBitType(bitType, BitType.container)) {
27971
27979
  if (bitJson.allowedBit == null) bitJson.allowedBit = [];
27972
27980
  }
27973
- if (bitConfig.quizBit) {
27974
- if (bitJson.revealSolutions == null) bitJson.revealSolutions = false;
27975
- }
27976
27981
  if (instance2.isOfBitType(bitType, BitType.platformPath)) {
27977
27982
  if (bitJson.path == null) bitJson.path = "";
27978
27983
  }
@@ -29403,7 +29408,10 @@ var BitmarkPegParserValidator = class {
29403
29408
  if (warning.invalid || warning.excessResource) {
29404
29409
  warningStr = `${keyStr} is not valid here (incorrectly chained?).${ignoredStr}`;
29405
29410
  } else if (warning.tooMany != null) {
29406
- 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
+ }
29407
29415
  if (warning.tooMany > 0) warningStr += " The earlier ones will be ignored";
29408
29416
  } else if (warning.extraProperty) {
29409
29417
  warningStr = `${keyStr} is an unknown property. It can be excluded from the output using the 'excludeUnknownProperties' flag`;
@@ -31176,7 +31184,6 @@ function extractAvatarImage(context, resources) {
31176
31184
  }
31177
31185
  }
31178
31186
  if (excessResources.length > 0) {
31179
- context.parser.excessResources = excessResources;
31180
31187
  context.addWarning(
31181
31188
  `${excessResources.length} excess resource(s) present in the [@person] chain.`
31182
31189
  );
@@ -31449,9 +31456,10 @@ function buildResources(context, resourceTypeAttachment, resources) {
31449
31456
  `Resource type [&${resourceTypeAttachment}] is specified in the bit header, but no such resource is present`
31450
31457
  );
31451
31458
  }
31452
- if (excessResources.length > 0) {
31453
- context.parser.excessResources = excessResources;
31454
- }
31459
+ excessResources.forEach((r) => {
31460
+ r.__excessResource = true;
31461
+ filteredResources.push(r);
31462
+ });
31455
31463
  return filteredResources;
31456
31464
  }
31457
31465
  function resourceContentProcessor(context, _contentDepth, tagsConfig, content, target) {