@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.cjs CHANGED
@@ -1272,6 +1272,7 @@ var propertyKeys = {
1272
1272
  property_availableClassifications: "@availableClassifications",
1273
1273
  property_brandColor: "@brandColor",
1274
1274
  property_brandColorName: "@brandColorName",
1275
+ property_backgroundImage: "@backgroundImage",
1275
1276
  property_blockId: "@blockId",
1276
1277
  property_book: "@book",
1277
1278
  property_bookAlias: "@bookAlias",
@@ -1568,7 +1569,8 @@ var resourceKeys = {
1568
1569
  resource_imagePlaceholder: "&imagePlaceholder",
1569
1570
  resource_previewImage: "&previewImage",
1570
1571
  resource_previewVideo: "&previewVideo",
1571
- resource_coverImage: "&coverImage"
1572
+ resource_coverImage: "&coverImage",
1573
+ resource_backgroundImage: "&backgroundImage"
1572
1574
  };
1573
1575
 
1574
1576
  // src/model/enum/ResourceType.ts
@@ -1798,7 +1800,8 @@ var ResourceType = {
1798
1800
  platformBackgroundImage: "platformBackgroundImage",
1799
1801
  previewImage: "previewImage",
1800
1802
  previewVideo: "previewVideo",
1801
- coverImage: "coverImage"
1803
+ coverImage: "coverImage",
1804
+ backgroundImage: "backgroundImage"
1802
1805
  };
1803
1806
  function resourceTypeToConfigKey(type) {
1804
1807
  return `&${stringUtils.kebabToCamel(type)}`;
@@ -3840,6 +3843,22 @@ var GROUPS = {
3840
3843
  }
3841
3844
  ]
3842
3845
  },
3846
+ {
3847
+ key: ConfigKey.property_backgroundImage,
3848
+ description: "The background image(s) of the book",
3849
+ format: TagFormat.plainText,
3850
+ maxCount: Count.infinity
3851
+ },
3852
+ {
3853
+ key: ConfigKey.resource_backgroundImage,
3854
+ description: "The background image of the book",
3855
+ chain: [
3856
+ {
3857
+ key: ConfigKey.group_resourceImageCommon,
3858
+ description: "Common image properties for the background image resource"
3859
+ }
3860
+ ]
3861
+ },
3843
3862
  {
3844
3863
  key: ConfigKey.property_coverColor,
3845
3864
  description: "The cover color of the book",
@@ -10962,7 +10981,7 @@ var instance2 = new Config();
10962
10981
  // src/generated/package_info.ts
10963
10982
  var PACKAGE_INFO = {
10964
10983
  "name": "@gmb/bitmark-parser-generator",
10965
- "version": "5.14.0",
10984
+ "version": "5.15.0",
10966
10985
  "author": "Get More Brain Ltd",
10967
10986
  "license": "ISC",
10968
10987
  "description": "A bitmark parser and generator using Peggy.js"
@@ -11352,6 +11371,8 @@ var NodeType = {
11352
11371
  avatarImage: "avatarImage",
11353
11372
  backgroundWallpaper: "backgroundWallpaper",
11354
11373
  backgroundWallpaperValue: "backgroundWallpaperValue",
11374
+ backgroundImage: "backgroundImage",
11375
+ backgroundImageValue: "backgroundImageValue",
11355
11376
  bitLevel: "bitLevel",
11356
11377
  // bit level
11357
11378
  bitmarkAst: "bitmarkAst",
@@ -23656,6 +23677,7 @@ var ResourceBuilder = class extends BaseBuilder {
23656
23677
  case ResourceType.platformBackgroundImage:
23657
23678
  case ResourceType.previewImage:
23658
23679
  case ResourceType.coverImage:
23680
+ case ResourceType.backgroundImage:
23659
23681
  node = this.imageResource(context, finalData, type);
23660
23682
  break;
23661
23683
  // case ResourceType.imageResponsive: {
@@ -24935,6 +24957,12 @@ var Builder = class extends BaseBuilder {
24935
24957
  data.coverColor,
24936
24958
  options
24937
24959
  ),
24960
+ backgroundImage: typeof data.backgroundImage === "string" || Array.isArray(data.backgroundImage) ? this.toAstProperty(
24961
+ bitType,
24962
+ ConfigKey.property_backgroundImage,
24963
+ instance4.asArray(data.backgroundImage),
24964
+ options
24965
+ ) : this.toImageResource(context, data.backgroundImage),
24938
24966
  publications: this.toAstProperty(
24939
24967
  bitType,
24940
24968
  ConfigKey.property_publications,
@@ -29008,6 +29036,62 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
29008
29036
  ignoreTrue: propertyConfig.defaultValue === "true"
29009
29037
  });
29010
29038
  }
29039
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage (when it's a resource object or property array)
29040
+ enter_backgroundImage(node, route) {
29041
+ const value = node.value;
29042
+ if (value && typeof value === "object" && !Array.isArray(value) && "type" in value) {
29043
+ const resource = value;
29044
+ this.writeNL();
29045
+ this.writePropertyStyleResource(node.key, resource);
29046
+ return true;
29047
+ }
29048
+ if (Array.isArray(value)) {
29049
+ if (value == null) return true;
29050
+ const parent = this.getParentNode(route);
29051
+ if (parent?.key !== NodeType.bitsValue) return true;
29052
+ const bitType = this.getBitType(route);
29053
+ if (!bitType) return true;
29054
+ const config = instance2.getBitConfig(bitType);
29055
+ const propertyConfig = instance2.getTagConfigForTag(
29056
+ config.tags,
29057
+ ConfigKey.property_backgroundImage
29058
+ );
29059
+ if (!propertyConfig) return true;
29060
+ this.writeNL_IfNotChain(route);
29061
+ this.writeProperty(propertyConfig.tag, value, route, {
29062
+ format: propertyConfig.format ?? TagFormat.plainText,
29063
+ array: propertyConfig.array ?? false,
29064
+ writeEmpty: true,
29065
+ ignoreFalse: propertyConfig.defaultValue === "false",
29066
+ ignoreTrue: propertyConfig.defaultValue === "true"
29067
+ });
29068
+ }
29069
+ return true;
29070
+ }
29071
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage (when it's a property string)
29072
+ // This is called when backgroundImage is a simple string value
29073
+ leaf_backgroundImage(node, route) {
29074
+ const value = node.value;
29075
+ if (value == null) return;
29076
+ const parent = this.getParentNode(route);
29077
+ if (parent?.key !== NodeType.bitsValue) return;
29078
+ const bitType = this.getBitType(route);
29079
+ if (!bitType) return;
29080
+ const config = instance2.getBitConfig(bitType);
29081
+ const propertyConfig = instance2.getTagConfigForTag(
29082
+ config.tags,
29083
+ ConfigKey.property_backgroundImage
29084
+ );
29085
+ if (!propertyConfig) return;
29086
+ this.writeNL_IfNotChain(route);
29087
+ this.writeProperty(propertyConfig.tag, node.value, route, {
29088
+ format: propertyConfig.format ?? TagFormat.plainText,
29089
+ array: propertyConfig.array ?? false,
29090
+ writeEmpty: true,
29091
+ ignoreFalse: propertyConfig.defaultValue === "false",
29092
+ ignoreTrue: propertyConfig.defaultValue === "true"
29093
+ });
29094
+ }
29011
29095
  exit_imagePlaceholder(_node, _route) {
29012
29096
  }
29013
29097
  // bitmarkAst -> bits -> bitsValue -> posterImage
@@ -30621,6 +30705,12 @@ var JsonGenerator = class extends AstWalkerGenerator {
30621
30705
  array: Array.isArray(node.value)
30622
30706
  });
30623
30707
  }
30708
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage
30709
+ enter_backgroundImage(node, route) {
30710
+ return this.standardHandler(node, route, NodeType.bitsValue, {
30711
+ array: Array.isArray(node.value)
30712
+ });
30713
+ }
30624
30714
  // bitmarkAst -> bits -> bitsValue -> resources
30625
30715
  enter_resources(node, route) {
30626
30716
  const resources = node.value;
@@ -35089,7 +35179,7 @@ function resourceContentProcessor(context, _contentDepth, tagsConfig, content, t
35089
35179
  ...tags2
35090
35180
  });
35091
35181
  if (resource) {
35092
- 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) {
35182
+ 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) {
35093
35183
  if (target.propertyStyleResources) {
35094
35184
  if (target.propertyStyleResources[resourceType]) {
35095
35185
  if (!Array.isArray(target.propertyStyleResources[resourceType])) {