@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/cli/main.js CHANGED
@@ -1176,6 +1176,7 @@ var propertyKeys = {
1176
1176
  property_availableClassifications: "@availableClassifications",
1177
1177
  property_brandColor: "@brandColor",
1178
1178
  property_brandColorName: "@brandColorName",
1179
+ property_backgroundImage: "@backgroundImage",
1179
1180
  property_blockId: "@blockId",
1180
1181
  property_book: "@book",
1181
1182
  property_bookAlias: "@bookAlias",
@@ -1469,7 +1470,8 @@ var resourceKeys = {
1469
1470
  resource_imagePlaceholder: "&imagePlaceholder",
1470
1471
  resource_previewImage: "&previewImage",
1471
1472
  resource_previewVideo: "&previewVideo",
1472
- resource_coverImage: "&coverImage"
1473
+ resource_coverImage: "&coverImage",
1474
+ resource_backgroundImage: "&backgroundImage"
1473
1475
  };
1474
1476
 
1475
1477
  // src/utils/StringUtils.ts
@@ -1696,7 +1698,8 @@ var ResourceType = {
1696
1698
  platformBackgroundImage: "platformBackgroundImage",
1697
1699
  previewImage: "previewImage",
1698
1700
  previewVideo: "previewVideo",
1699
- coverImage: "coverImage"
1701
+ coverImage: "coverImage",
1702
+ backgroundImage: "backgroundImage"
1700
1703
  };
1701
1704
  function resourceTypeToConfigKey(type) {
1702
1705
  return `&${stringUtils.kebabToCamel(type)}`;
@@ -3735,6 +3738,22 @@ var GROUPS = {
3735
3738
  }
3736
3739
  ]
3737
3740
  },
3741
+ {
3742
+ key: ConfigKey.property_backgroundImage,
3743
+ description: "The background image(s) of the book",
3744
+ format: TagFormat.plainText,
3745
+ maxCount: Count.infinity
3746
+ },
3747
+ {
3748
+ key: ConfigKey.resource_backgroundImage,
3749
+ description: "The background image of the book",
3750
+ chain: [
3751
+ {
3752
+ key: ConfigKey.group_resourceImageCommon,
3753
+ description: "Common image properties for the background image resource"
3754
+ }
3755
+ ]
3756
+ },
3738
3757
  {
3739
3758
  key: ConfigKey.property_coverColor,
3740
3759
  description: "The cover color of the book",
@@ -10857,7 +10876,7 @@ var instance2 = new Config();
10857
10876
  // src/generated/package_info.ts
10858
10877
  var PACKAGE_INFO = {
10859
10878
  "name": "@gmb/bitmark-parser-generator",
10860
- "version": "5.14.0",
10879
+ "version": "5.15.0",
10861
10880
  "license": "ISC"};
10862
10881
  var Environment = {
10863
10882
  unknown: "",
@@ -11215,6 +11234,8 @@ var NodeType = {
11215
11234
  avatarImage: "avatarImage",
11216
11235
  backgroundWallpaper: "backgroundWallpaper",
11217
11236
  backgroundWallpaperValue: "backgroundWallpaperValue",
11237
+ backgroundImage: "backgroundImage",
11238
+ backgroundImageValue: "backgroundImageValue",
11218
11239
  bitLevel: "bitLevel",
11219
11240
  // bit level
11220
11241
  bitmarkAst: "bitmarkAst",
@@ -23339,6 +23360,7 @@ var ResourceBuilder = class extends BaseBuilder {
23339
23360
  case ResourceType.platformBackgroundImage:
23340
23361
  case ResourceType.previewImage:
23341
23362
  case ResourceType.coverImage:
23363
+ case ResourceType.backgroundImage:
23342
23364
  node = this.imageResource(context, finalData, type);
23343
23365
  break;
23344
23366
  // case ResourceType.imageResponsive: {
@@ -24614,6 +24636,12 @@ var Builder = class extends BaseBuilder {
24614
24636
  data.coverColor,
24615
24637
  options
24616
24638
  ),
24639
+ backgroundImage: typeof data.backgroundImage === "string" || Array.isArray(data.backgroundImage) ? this.toAstProperty(
24640
+ bitType,
24641
+ ConfigKey.property_backgroundImage,
24642
+ instance4.asArray(data.backgroundImage),
24643
+ options
24644
+ ) : this.toImageResource(context, data.backgroundImage),
24617
24645
  publications: this.toAstProperty(
24618
24646
  bitType,
24619
24647
  ConfigKey.property_publications,
@@ -28671,6 +28699,62 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
28671
28699
  ignoreTrue: propertyConfig.defaultValue === "true"
28672
28700
  });
28673
28701
  }
28702
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage (when it's a resource object or property array)
28703
+ enter_backgroundImage(node, route) {
28704
+ const value = node.value;
28705
+ if (value && typeof value === "object" && !Array.isArray(value) && "type" in value) {
28706
+ const resource = value;
28707
+ this.writeNL();
28708
+ this.writePropertyStyleResource(node.key, resource);
28709
+ return true;
28710
+ }
28711
+ if (Array.isArray(value)) {
28712
+ if (value == null) return true;
28713
+ const parent = this.getParentNode(route);
28714
+ if (parent?.key !== NodeType.bitsValue) return true;
28715
+ const bitType = this.getBitType(route);
28716
+ if (!bitType) return true;
28717
+ const config = instance2.getBitConfig(bitType);
28718
+ const propertyConfig = instance2.getTagConfigForTag(
28719
+ config.tags,
28720
+ ConfigKey.property_backgroundImage
28721
+ );
28722
+ if (!propertyConfig) return true;
28723
+ this.writeNL_IfNotChain(route);
28724
+ this.writeProperty(propertyConfig.tag, value, route, {
28725
+ format: propertyConfig.format ?? TagFormat.plainText,
28726
+ array: propertyConfig.array ?? false,
28727
+ writeEmpty: true,
28728
+ ignoreFalse: propertyConfig.defaultValue === "false",
28729
+ ignoreTrue: propertyConfig.defaultValue === "true"
28730
+ });
28731
+ }
28732
+ return true;
28733
+ }
28734
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage (when it's a property string)
28735
+ // This is called when backgroundImage is a simple string value
28736
+ leaf_backgroundImage(node, route) {
28737
+ const value = node.value;
28738
+ if (value == null) return;
28739
+ const parent = this.getParentNode(route);
28740
+ if (parent?.key !== NodeType.bitsValue) return;
28741
+ const bitType = this.getBitType(route);
28742
+ if (!bitType) return;
28743
+ const config = instance2.getBitConfig(bitType);
28744
+ const propertyConfig = instance2.getTagConfigForTag(
28745
+ config.tags,
28746
+ ConfigKey.property_backgroundImage
28747
+ );
28748
+ if (!propertyConfig) return;
28749
+ this.writeNL_IfNotChain(route);
28750
+ this.writeProperty(propertyConfig.tag, node.value, route, {
28751
+ format: propertyConfig.format ?? TagFormat.plainText,
28752
+ array: propertyConfig.array ?? false,
28753
+ writeEmpty: true,
28754
+ ignoreFalse: propertyConfig.defaultValue === "false",
28755
+ ignoreTrue: propertyConfig.defaultValue === "true"
28756
+ });
28757
+ }
28674
28758
  exit_imagePlaceholder(_node, _route) {
28675
28759
  }
28676
28760
  // bitmarkAst -> bits -> bitsValue -> posterImage
@@ -30277,6 +30361,12 @@ var JsonGenerator = class extends AstWalkerGenerator {
30277
30361
  array: Array.isArray(node.value)
30278
30362
  });
30279
30363
  }
30364
+ // bitmarkAst -> bits -> bitsValue -> backgroundImage
30365
+ enter_backgroundImage(node, route) {
30366
+ return this.standardHandler(node, route, NodeType.bitsValue, {
30367
+ array: Array.isArray(node.value)
30368
+ });
30369
+ }
30280
30370
  // bitmarkAst -> bits -> bitsValue -> resources
30281
30371
  enter_resources(node, route) {
30282
30372
  const resources = node.value;
@@ -34645,7 +34735,7 @@ function resourceContentProcessor(context, _contentDepth, tagsConfig, content, t
34645
34735
  ...tags2
34646
34736
  });
34647
34737
  if (resource) {
34648
- 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) {
34738
+ 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) {
34649
34739
  if (target.propertyStyleResources) {
34650
34740
  if (target.propertyStyleResources[resourceType]) {
34651
34741
  if (!Array.isArray(target.propertyStyleResources[resourceType])) {