@gmb/bitmark-parser-generator 5.14.0 → 5.15.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
@@ -737,6 +737,7 @@ declare const ConfigKey: {
737
737
  readonly property_availableClassifications: "@availableClassifications";
738
738
  readonly property_brandColor: "@brandColor";
739
739
  readonly property_brandColorName: "@brandColorName";
740
+ readonly property_backgroundImage: "@backgroundImage";
740
741
  readonly property_blockId: "@blockId";
741
742
  readonly property_book: "@book";
742
743
  readonly property_bookAlias: "@bookAlias";
@@ -1027,6 +1028,7 @@ declare const ConfigKey: {
1027
1028
  readonly resource_previewImage: "&previewImage";
1028
1029
  readonly resource_previewVideo: "&previewVideo";
1029
1030
  readonly resource_coverImage: "&coverImage";
1031
+ readonly resource_backgroundImage: "&backgroundImage";
1030
1032
  readonly tag_title: "#";
1031
1033
  readonly tag_anchor: "▼";
1032
1034
  readonly tag_reference: "►";
@@ -1079,6 +1081,7 @@ declare const ResourceType: {
1079
1081
  readonly previewImage: "previewImage";
1080
1082
  readonly previewVideo: "previewVideo";
1081
1083
  readonly coverImage: "coverImage";
1084
+ readonly backgroundImage: "backgroundImage";
1082
1085
  };
1083
1086
  type ResourceTypeType = EnumType<typeof ResourceType>;
1084
1087
 
@@ -1688,6 +1691,7 @@ interface BitJson {
1688
1691
  bookDiff: string;
1689
1692
  coverImage: string | string[];
1690
1693
  coverColor: string;
1694
+ backgroundImage: string | string[];
1691
1695
  publisher: string | string[];
1692
1696
  publisherName: string;
1693
1697
  publications: string | string[];
@@ -2300,6 +2304,7 @@ interface Bit {
2300
2304
  bookDiff?: Property;
2301
2305
  coverImage?: Property | ImageResourceWrapperJson;
2302
2306
  coverColor?: Property;
2307
+ backgroundImage?: Property | ImageResourceWrapperJson;
2303
2308
  publications?: Property;
2304
2309
  relatedBook?: Property;
2305
2310
  translationOfBook?: Property;
@@ -2619,6 +2624,8 @@ declare const NodeType: {
2619
2624
  readonly avatarImage: "avatarImage";
2620
2625
  readonly backgroundWallpaper: "backgroundWallpaper";
2621
2626
  readonly backgroundWallpaperValue: "backgroundWallpaperValue";
2627
+ readonly backgroundImage: "backgroundImage";
2628
+ readonly backgroundImageValue: "backgroundImageValue";
2622
2629
  readonly bitLevel: "bitLevel";
2623
2630
  readonly bitmarkAst: "bitmarkAst";
2624
2631
  readonly bitmarkVersion: "bitmarkVersion";
@@ -4165,6 +4172,7 @@ declare class Builder extends BaseBuilder {
4165
4172
  bookDiff?: string;
4166
4173
  coverImage?: string | string[] | Partial<ImageResourceWrapperJson>;
4167
4174
  coverColor?: string;
4175
+ backgroundImage?: string | string[] | Partial<ImageResourceWrapperJson>;
4168
4176
  publications?: string | string[];
4169
4177
  relatedBook?: string | string[];
4170
4178
  translationOfBook?: string;
@@ -5591,6 +5599,8 @@ declare class BitmarkGenerator extends AstWalkerGenerator<BitmarkAst, void> {
5591
5599
  protected enter_platformBackgroundImage(node: NodeInfo, _route: NodeInfo[]): boolean;
5592
5600
  protected enter_coverImage(node: NodeInfo, route: NodeInfo[]): boolean;
5593
5601
  protected leaf_coverImage(node: NodeInfo, route: NodeInfo[]): void;
5602
+ protected enter_backgroundImage(node: NodeInfo, route: NodeInfo[]): boolean;
5603
+ protected leaf_backgroundImage(node: NodeInfo, route: NodeInfo[]): void;
5594
5604
  protected exit_imagePlaceholder(_node: NodeInfo, _route: NodeInfo[]): void;
5595
5605
  protected enter_posterImage(node: NodeInfo, route: NodeInfo[]): boolean;
5596
5606
  protected enter_thumbnails(node: NodeInfo, route: NodeInfo[]): boolean;
@@ -5973,6 +5983,7 @@ declare class JsonGenerator extends AstWalkerGenerator<BitmarkAst, void> {
5973
5983
  protected enter_platformLogo(node: NodeInfo, route: NodeInfo[]): boolean;
5974
5984
  protected enter_platformBackgroundImage(node: NodeInfo, route: NodeInfo[]): boolean;
5975
5985
  protected enter_coverImage(node: NodeInfo, route: NodeInfo[]): boolean;
5986
+ protected enter_backgroundImage(node: NodeInfo, route: NodeInfo[]): boolean;
5976
5987
  protected enter_resources(node: NodeInfo, route: NodeInfo[]): boolean;
5977
5988
  protected leaf_level(node: NodeInfo, route: NodeInfo[]): boolean;
5978
5989
  protected enter_book(node: NodeInfo, route: NodeInfo[]): boolean;
package/dist/index.d.ts CHANGED
@@ -737,6 +737,7 @@ declare const ConfigKey: {
737
737
  readonly property_availableClassifications: "@availableClassifications";
738
738
  readonly property_brandColor: "@brandColor";
739
739
  readonly property_brandColorName: "@brandColorName";
740
+ readonly property_backgroundImage: "@backgroundImage";
740
741
  readonly property_blockId: "@blockId";
741
742
  readonly property_book: "@book";
742
743
  readonly property_bookAlias: "@bookAlias";
@@ -1027,6 +1028,7 @@ declare const ConfigKey: {
1027
1028
  readonly resource_previewImage: "&previewImage";
1028
1029
  readonly resource_previewVideo: "&previewVideo";
1029
1030
  readonly resource_coverImage: "&coverImage";
1031
+ readonly resource_backgroundImage: "&backgroundImage";
1030
1032
  readonly tag_title: "#";
1031
1033
  readonly tag_anchor: "▼";
1032
1034
  readonly tag_reference: "►";
@@ -1079,6 +1081,7 @@ declare const ResourceType: {
1079
1081
  readonly previewImage: "previewImage";
1080
1082
  readonly previewVideo: "previewVideo";
1081
1083
  readonly coverImage: "coverImage";
1084
+ readonly backgroundImage: "backgroundImage";
1082
1085
  };
1083
1086
  type ResourceTypeType = EnumType<typeof ResourceType>;
1084
1087
 
@@ -1688,6 +1691,7 @@ interface BitJson {
1688
1691
  bookDiff: string;
1689
1692
  coverImage: string | string[];
1690
1693
  coverColor: string;
1694
+ backgroundImage: string | string[];
1691
1695
  publisher: string | string[];
1692
1696
  publisherName: string;
1693
1697
  publications: string | string[];
@@ -2300,6 +2304,7 @@ interface Bit {
2300
2304
  bookDiff?: Property;
2301
2305
  coverImage?: Property | ImageResourceWrapperJson;
2302
2306
  coverColor?: Property;
2307
+ backgroundImage?: Property | ImageResourceWrapperJson;
2303
2308
  publications?: Property;
2304
2309
  relatedBook?: Property;
2305
2310
  translationOfBook?: Property;
@@ -2619,6 +2624,8 @@ declare const NodeType: {
2619
2624
  readonly avatarImage: "avatarImage";
2620
2625
  readonly backgroundWallpaper: "backgroundWallpaper";
2621
2626
  readonly backgroundWallpaperValue: "backgroundWallpaperValue";
2627
+ readonly backgroundImage: "backgroundImage";
2628
+ readonly backgroundImageValue: "backgroundImageValue";
2622
2629
  readonly bitLevel: "bitLevel";
2623
2630
  readonly bitmarkAst: "bitmarkAst";
2624
2631
  readonly bitmarkVersion: "bitmarkVersion";
@@ -4165,6 +4172,7 @@ declare class Builder extends BaseBuilder {
4165
4172
  bookDiff?: string;
4166
4173
  coverImage?: string | string[] | Partial<ImageResourceWrapperJson>;
4167
4174
  coverColor?: string;
4175
+ backgroundImage?: string | string[] | Partial<ImageResourceWrapperJson>;
4168
4176
  publications?: string | string[];
4169
4177
  relatedBook?: string | string[];
4170
4178
  translationOfBook?: string;
@@ -5591,6 +5599,8 @@ declare class BitmarkGenerator extends AstWalkerGenerator<BitmarkAst, void> {
5591
5599
  protected enter_platformBackgroundImage(node: NodeInfo, _route: NodeInfo[]): boolean;
5592
5600
  protected enter_coverImage(node: NodeInfo, route: NodeInfo[]): boolean;
5593
5601
  protected leaf_coverImage(node: NodeInfo, route: NodeInfo[]): void;
5602
+ protected enter_backgroundImage(node: NodeInfo, route: NodeInfo[]): boolean;
5603
+ protected leaf_backgroundImage(node: NodeInfo, route: NodeInfo[]): void;
5594
5604
  protected exit_imagePlaceholder(_node: NodeInfo, _route: NodeInfo[]): void;
5595
5605
  protected enter_posterImage(node: NodeInfo, route: NodeInfo[]): boolean;
5596
5606
  protected enter_thumbnails(node: NodeInfo, route: NodeInfo[]): boolean;
@@ -5973,6 +5983,7 @@ declare class JsonGenerator extends AstWalkerGenerator<BitmarkAst, void> {
5973
5983
  protected enter_platformLogo(node: NodeInfo, route: NodeInfo[]): boolean;
5974
5984
  protected enter_platformBackgroundImage(node: NodeInfo, route: NodeInfo[]): boolean;
5975
5985
  protected enter_coverImage(node: NodeInfo, route: NodeInfo[]): boolean;
5986
+ protected enter_backgroundImage(node: NodeInfo, route: NodeInfo[]): boolean;
5976
5987
  protected enter_resources(node: NodeInfo, route: NodeInfo[]): boolean;
5977
5988
  protected leaf_level(node: NodeInfo, route: NodeInfo[]): boolean;
5978
5989
  protected enter_book(node: NodeInfo, route: NodeInfo[]): boolean;
package/dist/index.js CHANGED
@@ -1211,6 +1211,7 @@ var propertyKeys = {
1211
1211
  property_availableClassifications: "@availableClassifications",
1212
1212
  property_brandColor: "@brandColor",
1213
1213
  property_brandColorName: "@brandColorName",
1214
+ property_backgroundImage: "@backgroundImage",
1214
1215
  property_blockId: "@blockId",
1215
1216
  property_book: "@book",
1216
1217
  property_bookAlias: "@bookAlias",
@@ -1507,7 +1508,8 @@ var resourceKeys = {
1507
1508
  resource_imagePlaceholder: "&imagePlaceholder",
1508
1509
  resource_previewImage: "&previewImage",
1509
1510
  resource_previewVideo: "&previewVideo",
1510
- resource_coverImage: "&coverImage"
1511
+ resource_coverImage: "&coverImage",
1512
+ resource_backgroundImage: "&backgroundImage"
1511
1513
  };
1512
1514
 
1513
1515
  // src/model/enum/ResourceType.ts
@@ -1737,7 +1739,8 @@ var ResourceType = {
1737
1739
  platformBackgroundImage: "platformBackgroundImage",
1738
1740
  previewImage: "previewImage",
1739
1741
  previewVideo: "previewVideo",
1740
- coverImage: "coverImage"
1742
+ coverImage: "coverImage",
1743
+ backgroundImage: "backgroundImage"
1741
1744
  };
1742
1745
  function resourceTypeToConfigKey(type) {
1743
1746
  return `&${stringUtils.kebabToCamel(type)}`;
@@ -3779,6 +3782,22 @@ var GROUPS = {
3779
3782
  }
3780
3783
  ]
3781
3784
  },
3785
+ {
3786
+ key: ConfigKey.property_backgroundImage,
3787
+ description: "The background image(s) of the book",
3788
+ format: TagFormat.plainText,
3789
+ maxCount: Count.infinity
3790
+ },
3791
+ {
3792
+ key: ConfigKey.resource_backgroundImage,
3793
+ description: "The background image of the book",
3794
+ chain: [
3795
+ {
3796
+ key: ConfigKey.group_resourceImageCommon,
3797
+ description: "Common image properties for the background image resource"
3798
+ }
3799
+ ]
3800
+ },
3782
3801
  {
3783
3802
  key: ConfigKey.property_coverColor,
3784
3803
  description: "The cover color of the book",
@@ -10901,7 +10920,7 @@ var instance2 = new Config();
10901
10920
  // src/generated/package_info.ts
10902
10921
  var PACKAGE_INFO = {
10903
10922
  "name": "@gmb/bitmark-parser-generator",
10904
- "version": "5.14.0",
10923
+ "version": "5.15.0",
10905
10924
  "author": "Get More Brain Ltd",
10906
10925
  "license": "ISC",
10907
10926
  "description": "A bitmark parser and generator using Peggy.js"
@@ -11291,6 +11310,8 @@ var NodeType = {
11291
11310
  avatarImage: "avatarImage",
11292
11311
  backgroundWallpaper: "backgroundWallpaper",
11293
11312
  backgroundWallpaperValue: "backgroundWallpaperValue",
11313
+ backgroundImage: "backgroundImage",
11314
+ backgroundImageValue: "backgroundImageValue",
11294
11315
  bitLevel: "bitLevel",
11295
11316
  // bit level
11296
11317
  bitmarkAst: "bitmarkAst",
@@ -23595,6 +23616,7 @@ var ResourceBuilder = class extends BaseBuilder {
23595
23616
  case ResourceType.platformBackgroundImage:
23596
23617
  case ResourceType.previewImage:
23597
23618
  case ResourceType.coverImage:
23619
+ case ResourceType.backgroundImage:
23598
23620
  node = this.imageResource(context, finalData, type);
23599
23621
  break;
23600
23622
  // case ResourceType.imageResponsive: {
@@ -24874,6 +24896,12 @@ var Builder = class extends BaseBuilder {
24874
24896
  data.coverColor,
24875
24897
  options
24876
24898
  ),
24899
+ backgroundImage: typeof data.backgroundImage === "string" || Array.isArray(data.backgroundImage) ? this.toAstProperty(
24900
+ bitType,
24901
+ ConfigKey.property_backgroundImage,
24902
+ instance4.asArray(data.backgroundImage),
24903
+ options
24904
+ ) : this.toImageResource(context, data.backgroundImage),
24877
24905
  publications: this.toAstProperty(
24878
24906
  bitType,
24879
24907
  ConfigKey.property_publications,
@@ -28947,6 +28975,62 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28947
28975
  ignoreTrue: propertyConfig.defaultValue === "true"
28948
28976
  });
28949
28977
  }
28978
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage (when it's a resource object or property array)
28979
+ enter_backgroundImage(node, route) {
28980
+ const value = node.value;
28981
+ if (value && typeof value === "object" && !Array.isArray(value) && "type" in value) {
28982
+ const resource = value;
28983
+ this.writeNL();
28984
+ this.writePropertyStyleResource(node.key, resource);
28985
+ return true;
28986
+ }
28987
+ if (Array.isArray(value)) {
28988
+ if (value == null) return true;
28989
+ const parent = this.getParentNode(route);
28990
+ if (parent?.key !== NodeType.bitsValue) return true;
28991
+ const bitType = this.getBitType(route);
28992
+ if (!bitType) return true;
28993
+ const config = instance2.getBitConfig(bitType);
28994
+ const propertyConfig = instance2.getTagConfigForTag(
28995
+ config.tags,
28996
+ ConfigKey.property_backgroundImage
28997
+ );
28998
+ if (!propertyConfig) return true;
28999
+ this.writeNL_IfNotChain(route);
29000
+ this.writeProperty(propertyConfig.tag, value, route, {
29001
+ format: propertyConfig.format ?? TagFormat.plainText,
29002
+ array: propertyConfig.array ?? false,
29003
+ writeEmpty: true,
29004
+ ignoreFalse: propertyConfig.defaultValue === "false",
29005
+ ignoreTrue: propertyConfig.defaultValue === "true"
29006
+ });
29007
+ }
29008
+ return true;
29009
+ }
29010
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage (when it's a property string)
29011
+ // This is called when backgroundImage is a simple string value
29012
+ leaf_backgroundImage(node, route) {
29013
+ const value = node.value;
29014
+ if (value == null) return;
29015
+ const parent = this.getParentNode(route);
29016
+ if (parent?.key !== NodeType.bitsValue) return;
29017
+ const bitType = this.getBitType(route);
29018
+ if (!bitType) return;
29019
+ const config = instance2.getBitConfig(bitType);
29020
+ const propertyConfig = instance2.getTagConfigForTag(
29021
+ config.tags,
29022
+ ConfigKey.property_backgroundImage
29023
+ );
29024
+ if (!propertyConfig) return;
29025
+ this.writeNL_IfNotChain(route);
29026
+ this.writeProperty(propertyConfig.tag, node.value, route, {
29027
+ format: propertyConfig.format ?? TagFormat.plainText,
29028
+ array: propertyConfig.array ?? false,
29029
+ writeEmpty: true,
29030
+ ignoreFalse: propertyConfig.defaultValue === "false",
29031
+ ignoreTrue: propertyConfig.defaultValue === "true"
29032
+ });
29033
+ }
28950
29034
  exit_imagePlaceholder(_node, _route) {
28951
29035
  }
28952
29036
  // bitmarkAst -> bits -> bitsValue -> posterImage
@@ -30560,6 +30644,12 @@ var JsonGenerator = class extends AstWalkerGenerator {
30560
30644
  array: Array.isArray(node.value)
30561
30645
  });
30562
30646
  }
30647
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage
30648
+ enter_backgroundImage(node, route) {
30649
+ return this.standardHandler(node, route, NodeType.bitsValue, {
30650
+ array: Array.isArray(node.value)
30651
+ });
30652
+ }
30563
30653
  // bitmarkAst -> bits -> bitsValue -> resources
30564
30654
  enter_resources(node, route) {
30565
30655
  const resources = node.value;
@@ -35028,7 +35118,7 @@ function resourceContentProcessor(context, _contentDepth, tagsConfig, content, t
35028
35118
  ...tags2
35029
35119
  });
35030
35120
  if (resource) {
35031
- if (configKey === ConfigKey.resource_backgroundWallpaper || configKey === ConfigKey.resource_imagePlaceholder || configKey === ConfigKey.resource_platformIcon || configKey === ConfigKey.resource_platformLogo || configKey === ConfigKey.resource_platformBackgroundImage || configKey === ConfigKey.resource_previewImage || configKey === ConfigKey.resource_previewVideo || configKey === ConfigKey.resource_coverImage) {
35121
+ if (configKey === ConfigKey.resource_backgroundWallpaper || configKey === ConfigKey.resource_imagePlaceholder || configKey === ConfigKey.resource_platformIcon || configKey === ConfigKey.resource_platformLogo || configKey === ConfigKey.resource_platformBackgroundImage || configKey === ConfigKey.resource_previewImage || configKey === ConfigKey.resource_previewVideo || configKey === ConfigKey.resource_coverImage || configKey === ConfigKey.resource_backgroundImage) {
35032
35122
  if (target.propertyStyleResources) {
35033
35123
  if (target.propertyStyleResources[resourceType]) {
35034
35124
  if (!Array.isArray(target.propertyStyleResources[resourceType])) {