@gmb/bitmark-parser-generator 4.6.0 → 4.8.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
@@ -1169,6 +1169,7 @@ var propertyKeys = {
1169
1169
  property_bookDiff: "@bookDiff",
1170
1170
  property_bot: "@bot",
1171
1171
  property_bubbleTag: "@bubbleTag",
1172
+ property_extractorTag: "@extractorTag",
1172
1173
  property_buttonCaption: "@buttonCaption",
1173
1174
  property_callToActionUrl: "@callToActionUrl",
1174
1175
  property_caption: "@caption",
@@ -1296,6 +1297,7 @@ var propertyKeys = {
1296
1297
  property_reference: "@reference",
1297
1298
  property_refPublicationYear: "@refPublicationYear",
1298
1299
  property_refPublisher: "@refPublisher",
1300
+ property_relatedBook: "@relatedBook",
1299
1301
  property_releaseDate: "@releaseDate",
1300
1302
  property_releaseKind: "@releaseKind",
1301
1303
  property_releaseVersion: "@releaseVersion",
@@ -1319,6 +1321,7 @@ var propertyKeys = {
1319
1321
  property_src2x: "@src2x",
1320
1322
  property_src3x: "@src3x",
1321
1323
  property_src4x: "@src4x",
1324
+ property_srcAlt: "@srcAlt",
1322
1325
  property_stripePricingTableId: "@stripePricingTableId",
1323
1326
  property_stripePublishableKey: "@stripePublishableKey",
1324
1327
  property_subject: "@subject",
@@ -1570,6 +1573,16 @@ var StringUtils = class {
1570
1573
  if (!str) return str;
1571
1574
  return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
1572
1575
  }
1576
+ /**
1577
+ * Convert a camelCase string to kebab-case.
1578
+ *
1579
+ * @param str the string to convert
1580
+ * @returns the kebab-case version of the string
1581
+ */
1582
+ camelToKebab(str) {
1583
+ if (!str) return str;
1584
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
1585
+ }
1573
1586
  };
1574
1587
  var stringUtils = new StringUtils();
1575
1588
 
@@ -2781,6 +2794,12 @@ var GROUPS = {
2781
2794
  format: TagFormat.plainText,
2782
2795
  maxCount: Count.infinity
2783
2796
  },
2797
+ {
2798
+ key: ConfigKey.property_extractorTag,
2799
+ description: "The extractor tag(s) for the bit",
2800
+ format: TagFormat.plainText,
2801
+ maxCount: Count.infinity
2802
+ },
2784
2803
  {
2785
2804
  key: ConfigKey.property_levelCEFRp,
2786
2805
  description: "The CEFRp level for the bit",
@@ -3238,6 +3257,12 @@ var GROUPS = {
3238
3257
  format: TagFormat.plainText,
3239
3258
  maxCount: Count.infinity
3240
3259
  },
3260
+ {
3261
+ key: ConfigKey.property_relatedBook,
3262
+ description: "Books related to this book",
3263
+ format: TagFormat.plainText,
3264
+ maxCount: Count.infinity
3265
+ },
3241
3266
  {
3242
3267
  key: ConfigKey.property_duration,
3243
3268
  description: "The duration of the book",
@@ -3395,6 +3420,12 @@ var GROUPS = {
3395
3420
  key: ConfigKey.property_search,
3396
3421
  description: "The search text for the resource",
3397
3422
  format: TagFormat.plainText
3423
+ },
3424
+ {
3425
+ key: ConfigKey.property_srcAlt,
3426
+ description: "An alternative source for the resource",
3427
+ format: TagFormat.plainText,
3428
+ maxCount: Count.infinity
3398
3429
  }
3399
3430
  ]
3400
3431
  },
@@ -9116,7 +9147,7 @@ var instance2 = new Config();
9116
9147
  // src/generated/package_info.ts
9117
9148
  var PACKAGE_INFO = {
9118
9149
  "name": "@gmb/bitmark-parser-generator",
9119
- "version": "4.6.0",
9150
+ "version": "4.8.0",
9120
9151
  "author": "Get More Brain Ltd",
9121
9152
  "license": "ISC",
9122
9153
  "description": "A bitmark parser and generator using Peggy.js"
@@ -9524,6 +9555,8 @@ var NodeType = (0, import_superenum20.superenum)({
9524
9555
  botValue: "botValue",
9525
9556
  bubbleTag: "bubbleTag",
9526
9557
  bubbleTagValue: "bubbleTagValue",
9558
+ extractorTag: "extractorTag",
9559
+ extractorTagValue: "extractorTagValue",
9527
9560
  buttonCaption: "buttonCaption",
9528
9561
  buttonCaptionValue: "buttonCaptionValue",
9529
9562
  callToActionUrl: "callToActionUrl",
@@ -9858,6 +9891,8 @@ var NodeType = (0, import_superenum20.superenum)({
9858
9891
  referencePropertyValue: "referencePropertyValue",
9859
9892
  refPublicationYear: "refPublicationYear",
9860
9893
  refPublisher: "refPublisher",
9894
+ relatedBook: "relatedBook",
9895
+ relatedBookValue: "relatedBookValue",
9861
9896
  releaseDate: "releaseDate",
9862
9897
  releaseDateValue: "releaseDateValue",
9863
9898
  releaseKind: "releaseKind",
@@ -9904,6 +9939,8 @@ var NodeType = (0, import_superenum20.superenum)({
9904
9939
  spaceId: "spaceId",
9905
9940
  spaceIdValue: "spaceIdValue",
9906
9941
  src: "src",
9942
+ srcAlt: "srcAlt",
9943
+ srcAltValue: "srcAltValue",
9907
9944
  src1x: "src1x",
9908
9945
  src2x: "src2x",
9909
9946
  src3x: "src3x",
@@ -21086,6 +21123,8 @@ var ResourceBuilder = class extends BaseBuilder {
21086
21123
  type,
21087
21124
  // Generic (except Article / Document)
21088
21125
  value: url,
21126
+ // Alternative source
21127
+ srcAlt: data.srcAlt,
21089
21128
  // ImageLikeResource / AudioLikeResource / VideoLikeResource / Article / Document
21090
21129
  format: data.format,
21091
21130
  // ImageLikeResource
@@ -21260,6 +21299,7 @@ var ResourceBuilder = class extends BaseBuilder {
21260
21299
  imageResource(context, data, __typeAlias) {
21261
21300
  const {
21262
21301
  value,
21302
+ srcAlt,
21263
21303
  src1x,
21264
21304
  src2x,
21265
21305
  src3x,
@@ -21292,6 +21332,7 @@ var ResourceBuilder = class extends BaseBuilder {
21292
21332
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21293
21333
  provider: instance8.domainFromUrl(value) ?? void 0,
21294
21334
  src: value ?? "",
21335
+ srcAlt: srcAlt ?? void 0,
21295
21336
  src1x: src1x ?? void 0,
21296
21337
  src2x: src2x ?? void 0,
21297
21338
  src3x: src3x ?? void 0,
@@ -21324,6 +21365,7 @@ var ResourceBuilder = class extends BaseBuilder {
21324
21365
  imageLinkResource(context, data) {
21325
21366
  const {
21326
21367
  value,
21368
+ srcAlt,
21327
21369
  src1x,
21328
21370
  src2x,
21329
21371
  src3x,
@@ -21347,6 +21389,7 @@ var ResourceBuilder = class extends BaseBuilder {
21347
21389
  provider: instance8.domainFromUrl(value) ?? void 0,
21348
21390
  // src: value ?? '',
21349
21391
  url: value ?? "",
21392
+ srcAlt: srcAlt ?? void 0,
21350
21393
  src1x: src1x ?? void 0,
21351
21394
  src2x: src2x ?? void 0,
21352
21395
  src3x: src3x ?? void 0,
@@ -21378,7 +21421,18 @@ var ResourceBuilder = class extends BaseBuilder {
21378
21421
  * @returns
21379
21422
  */
21380
21423
  audioResource(context, data) {
21381
- const { value, duration, mute, autoplay, license, copyright, showInIndex, caption, search } = data;
21424
+ const {
21425
+ value,
21426
+ srcAlt,
21427
+ duration,
21428
+ mute,
21429
+ autoplay,
21430
+ license,
21431
+ copyright,
21432
+ showInIndex,
21433
+ caption,
21434
+ search
21435
+ } = data;
21382
21436
  const node = {
21383
21437
  type: ResourceType.audio,
21384
21438
  __typeAlias: ResourceType.audio,
@@ -21387,6 +21441,7 @@ var ResourceBuilder = class extends BaseBuilder {
21387
21441
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21388
21442
  provider: instance8.domainFromUrl(value) ?? void 0,
21389
21443
  src: value ?? "",
21444
+ srcAlt: srcAlt ?? void 0,
21390
21445
  duration: duration ?? void 0,
21391
21446
  mute: mute ?? void 0,
21392
21447
  autoplay: autoplay ?? void 0,
@@ -21411,7 +21466,18 @@ var ResourceBuilder = class extends BaseBuilder {
21411
21466
  * @returns
21412
21467
  */
21413
21468
  audioEmbedResource(context, data) {
21414
- const { value, duration, mute, autoplay, license, copyright, showInIndex, caption, search } = data;
21469
+ const {
21470
+ value,
21471
+ srcAlt,
21472
+ duration,
21473
+ mute,
21474
+ autoplay,
21475
+ license,
21476
+ copyright,
21477
+ showInIndex,
21478
+ caption,
21479
+ search
21480
+ } = data;
21415
21481
  const node = {
21416
21482
  type: ResourceType.audioEmbed,
21417
21483
  __typeAlias: ResourceType.audioEmbed,
@@ -21420,6 +21486,7 @@ var ResourceBuilder = class extends BaseBuilder {
21420
21486
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21421
21487
  provider: instance8.domainFromUrl(value) ?? void 0,
21422
21488
  src: value ?? "",
21489
+ srcAlt: srcAlt ?? void 0,
21423
21490
  duration: duration ?? void 0,
21424
21491
  mute: mute ?? void 0,
21425
21492
  autoplay: autoplay ?? void 0,
@@ -21449,7 +21516,18 @@ var ResourceBuilder = class extends BaseBuilder {
21449
21516
  * @returns
21450
21517
  */
21451
21518
  audioLinkResource(context, data) {
21452
- const { value, duration, mute, autoplay, license, copyright, showInIndex, caption, search } = data;
21519
+ const {
21520
+ value,
21521
+ srcAlt,
21522
+ duration,
21523
+ mute,
21524
+ autoplay,
21525
+ license,
21526
+ copyright,
21527
+ showInIndex,
21528
+ caption,
21529
+ search
21530
+ } = data;
21453
21531
  const node = {
21454
21532
  type: ResourceType.audioLink,
21455
21533
  __typeAlias: ResourceType.audioLink,
@@ -21459,6 +21537,7 @@ var ResourceBuilder = class extends BaseBuilder {
21459
21537
  provider: instance8.domainFromUrl(value) ?? void 0,
21460
21538
  // src: value ?? '',
21461
21539
  url: value ?? "",
21540
+ srcAlt: srcAlt ?? void 0,
21462
21541
  duration: duration ?? void 0,
21463
21542
  mute: mute ?? void 0,
21464
21543
  autoplay: autoplay ?? void 0,
@@ -21487,6 +21566,7 @@ var ResourceBuilder = class extends BaseBuilder {
21487
21566
  videoResource(context, data) {
21488
21567
  const {
21489
21568
  value,
21569
+ srcAlt,
21490
21570
  width,
21491
21571
  height,
21492
21572
  duration,
@@ -21511,6 +21591,7 @@ var ResourceBuilder = class extends BaseBuilder {
21511
21591
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21512
21592
  provider: instance8.domainFromUrl(value) ?? void 0,
21513
21593
  src: value ?? "",
21594
+ srcAlt: srcAlt ?? void 0,
21514
21595
  width: width ?? null,
21515
21596
  height: height ?? null,
21516
21597
  duration: duration ?? void 0,
@@ -21551,6 +21632,7 @@ var ResourceBuilder = class extends BaseBuilder {
21551
21632
  videoEmbedResource(context, data) {
21552
21633
  const {
21553
21634
  value,
21635
+ srcAlt,
21554
21636
  width,
21555
21637
  height,
21556
21638
  duration,
@@ -21576,6 +21658,7 @@ var ResourceBuilder = class extends BaseBuilder {
21576
21658
  provider: instance8.domainFromUrl(value) ?? void 0,
21577
21659
  // src: value ?? '',
21578
21660
  url: value ?? "",
21661
+ srcAlt: srcAlt ?? void 0,
21579
21662
  width: width ?? null,
21580
21663
  height: height ?? null,
21581
21664
  duration: duration ?? void 0,
@@ -21615,6 +21698,7 @@ var ResourceBuilder = class extends BaseBuilder {
21615
21698
  videoLinkResource(context, data) {
21616
21699
  const {
21617
21700
  value,
21701
+ srcAlt,
21618
21702
  width,
21619
21703
  height,
21620
21704
  duration,
@@ -21640,6 +21724,7 @@ var ResourceBuilder = class extends BaseBuilder {
21640
21724
  provider: instance8.domainFromUrl(value) ?? void 0,
21641
21725
  // src: value ?? '',
21642
21726
  url: value ?? "",
21727
+ srcAlt: srcAlt ?? void 0,
21643
21728
  width: width ?? null,
21644
21729
  height: height ?? null,
21645
21730
  duration: duration ?? void 0,
@@ -21699,6 +21784,7 @@ var ResourceBuilder = class extends BaseBuilder {
21699
21784
  stillImageFilmEmbedResource(context, data) {
21700
21785
  const {
21701
21786
  value,
21787
+ srcAlt,
21702
21788
  width,
21703
21789
  height,
21704
21790
  duration,
@@ -21724,6 +21810,7 @@ var ResourceBuilder = class extends BaseBuilder {
21724
21810
  provider: instance8.domainFromUrl(value) ?? void 0,
21725
21811
  // src: value ?? '',
21726
21812
  url: value ?? "",
21813
+ srcAlt: srcAlt ?? void 0,
21727
21814
  width: width ?? null,
21728
21815
  height: height ?? null,
21729
21816
  duration: duration ?? void 0,
@@ -21763,6 +21850,7 @@ var ResourceBuilder = class extends BaseBuilder {
21763
21850
  stillImageFilmLinkResource(context, data) {
21764
21851
  const {
21765
21852
  value,
21853
+ srcAlt,
21766
21854
  width,
21767
21855
  height,
21768
21856
  duration,
@@ -21788,6 +21876,7 @@ var ResourceBuilder = class extends BaseBuilder {
21788
21876
  provider: instance8.domainFromUrl(value) ?? void 0,
21789
21877
  // src: value ?? '',
21790
21878
  url: value ?? "",
21879
+ srcAlt: srcAlt ?? void 0,
21791
21880
  width: width ?? null,
21792
21881
  height: height ?? null,
21793
21882
  duration: duration ?? void 0,
@@ -21825,7 +21914,7 @@ var ResourceBuilder = class extends BaseBuilder {
21825
21914
  * @returns
21826
21915
  */
21827
21916
  articleResource(context, data) {
21828
- const { value, license, copyright, showInIndex, caption, search } = data;
21917
+ const { value, srcAlt, license, copyright, showInIndex, caption, search } = data;
21829
21918
  const node = {
21830
21919
  type: ResourceType.article,
21831
21920
  __typeAlias: ResourceType.article,
@@ -21834,6 +21923,7 @@ var ResourceBuilder = class extends BaseBuilder {
21834
21923
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21835
21924
  provider: instance8.domainFromUrl(value) ?? void 0,
21836
21925
  body: value ?? "",
21926
+ srcAlt: srcAlt ?? void 0,
21837
21927
  license: license ?? "",
21838
21928
  copyright: copyright ?? "",
21839
21929
  showInIndex: showInIndex ?? false,
@@ -21854,7 +21944,7 @@ var ResourceBuilder = class extends BaseBuilder {
21854
21944
  * @returns
21855
21945
  */
21856
21946
  documentResource(context, data) {
21857
- const { value, license, copyright, showInIndex, caption, search } = data;
21947
+ const { value, srcAlt, license, copyright, showInIndex, caption, search } = data;
21858
21948
  const node = {
21859
21949
  type: ResourceType.document,
21860
21950
  __typeAlias: ResourceType.document,
@@ -21863,6 +21953,7 @@ var ResourceBuilder = class extends BaseBuilder {
21863
21953
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21864
21954
  provider: instance8.domainFromUrl(value) ?? void 0,
21865
21955
  url: value ?? "",
21956
+ srcAlt: srcAlt ?? void 0,
21866
21957
  license: license ?? "",
21867
21958
  copyright: copyright ?? "",
21868
21959
  showInIndex: showInIndex ?? false,
@@ -21884,7 +21975,7 @@ var ResourceBuilder = class extends BaseBuilder {
21884
21975
  * @returns
21885
21976
  */
21886
21977
  documentEmbedResource(context, data) {
21887
- const { value, license, copyright, showInIndex, caption, search } = data;
21978
+ const { value, srcAlt, license, copyright, showInIndex, caption, search } = data;
21888
21979
  const node = {
21889
21980
  type: ResourceType.documentEmbed,
21890
21981
  __typeAlias: ResourceType.documentEmbed,
@@ -21893,6 +21984,7 @@ var ResourceBuilder = class extends BaseBuilder {
21893
21984
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21894
21985
  provider: instance8.domainFromUrl(value) ?? void 0,
21895
21986
  url: value ?? "",
21987
+ srcAlt: srcAlt ?? void 0,
21896
21988
  license: license ?? "",
21897
21989
  copyright: copyright ?? "",
21898
21990
  showInIndex: showInIndex ?? false,
@@ -21914,7 +22006,7 @@ var ResourceBuilder = class extends BaseBuilder {
21914
22006
  * @returns
21915
22007
  */
21916
22008
  documentLinkResource(context, data) {
21917
- const { value, license, copyright, showInIndex, caption, search } = data;
22009
+ const { value, srcAlt, license, copyright, showInIndex, caption, search } = data;
21918
22010
  const node = {
21919
22011
  type: ResourceType.documentLink,
21920
22012
  __typeAlias: ResourceType.documentLink,
@@ -21923,6 +22015,7 @@ var ResourceBuilder = class extends BaseBuilder {
21923
22015
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21924
22016
  provider: instance8.domainFromUrl(value) ?? void 0,
21925
22017
  url: value ?? "",
22018
+ srcAlt: srcAlt ?? void 0,
21926
22019
  license: license ?? "",
21927
22020
  copyright: copyright ?? "",
21928
22021
  showInIndex: showInIndex ?? false,
@@ -21944,7 +22037,7 @@ var ResourceBuilder = class extends BaseBuilder {
21944
22037
  * @returns
21945
22038
  */
21946
22039
  documentDownloadResource(context, data) {
21947
- const { value, license, copyright, showInIndex, caption, search } = data;
22040
+ const { value, srcAlt, license, copyright, showInIndex, caption, search } = data;
21948
22041
  const node = {
21949
22042
  type: ResourceType.documentDownload,
21950
22043
  __typeAlias: ResourceType.documentDownload,
@@ -21953,6 +22046,7 @@ var ResourceBuilder = class extends BaseBuilder {
21953
22046
  format: instance8.fileExtensionFromUrl(value) ?? void 0,
21954
22047
  provider: instance8.domainFromUrl(value) ?? void 0,
21955
22048
  url: value ?? "",
22049
+ srcAlt: srcAlt ?? void 0,
21956
22050
  license: license ?? "",
21957
22051
  copyright: copyright ?? "",
21958
22052
  showInIndex: showInIndex ?? false,
@@ -21974,7 +22068,7 @@ var ResourceBuilder = class extends BaseBuilder {
21974
22068
  * @returns
21975
22069
  */
21976
22070
  appLinkResource(context, data) {
21977
- const { value, license, copyright, showInIndex, caption, search } = data;
22071
+ const { value, srcAlt, license, copyright, showInIndex, caption, search } = data;
21978
22072
  const node = {
21979
22073
  type: ResourceType.appLink,
21980
22074
  __typeAlias: ResourceType.appLink,
@@ -21984,6 +22078,7 @@ var ResourceBuilder = class extends BaseBuilder {
21984
22078
  // provider: (UrlUtils.domainFromUrl(value) ?? undefined) as string,
21985
22079
  provider: void 0,
21986
22080
  url: value ?? "",
22081
+ srcAlt: srcAlt ?? void 0,
21987
22082
  license: license ?? "",
21988
22083
  copyright: copyright ?? "",
21989
22084
  showInIndex: showInIndex ?? false,
@@ -22012,6 +22107,7 @@ var ResourceBuilder = class extends BaseBuilder {
22012
22107
  websiteLinkResource(context, data) {
22013
22108
  const {
22014
22109
  value,
22110
+ srcAlt,
22015
22111
  /*siteName,*/
22016
22112
  license,
22017
22113
  copyright,
@@ -22027,6 +22123,7 @@ var ResourceBuilder = class extends BaseBuilder {
22027
22123
  // provider: (UrlUtils.domainFromUrl(value) ?? undefined) as string,
22028
22124
  provider: void 0,
22029
22125
  url: value ?? "",
22126
+ srcAlt: srcAlt ?? void 0,
22030
22127
  // siteName,
22031
22128
  license: license ?? "",
22032
22129
  copyright: copyright ?? "",
@@ -22274,6 +22371,12 @@ var Builder = class extends BaseBuilder {
22274
22371
  options
22275
22372
  ),
22276
22373
  bubbleTag: this.toAstProperty(bitType, ConfigKey.property_bubbleTag, data.bubbleTag, options),
22374
+ extractorTag: this.toAstProperty(
22375
+ bitType,
22376
+ ConfigKey.property_extractorTag,
22377
+ data.extractorTag,
22378
+ options
22379
+ ),
22277
22380
  levelCEFRp: this.toAstProperty(
22278
22381
  bitType,
22279
22382
  ConfigKey.property_levelCEFRp,
@@ -22318,6 +22421,12 @@ var Builder = class extends BaseBuilder {
22318
22421
  data.publications,
22319
22422
  options
22320
22423
  ),
22424
+ relatedBook: this.toAstProperty(
22425
+ bitType,
22426
+ ConfigKey.property_relatedBook,
22427
+ data.relatedBook,
22428
+ options
22429
+ ),
22321
22430
  author: this.toAstProperty(bitType, ConfigKey.property_author, data.author, options),
22322
22431
  subject: this.toAstProperty(bitType, ConfigKey.property_subject, data.subject, options),
22323
22432
  date: this.toAstProperty(bitType, ConfigKey.property_date, data.date, options),
@@ -26185,7 +26294,12 @@ var BitmarkGenerator = class extends AstWalkerGenerator {
26185
26294
  // bitmarkAst -> bits -> bitsValue -> resource -> ...
26186
26295
  // bitmarkAst -> bits -> bitsValue -> resource -> posterImage -> ...
26187
26296
  // bitmarkAst -> bits -> bitsValue -> resource -> thumbnails -> thumbnailsValue -> ...
26188
- // [src1x,src2x,src3x,src4x,width,height,alt,zoomDisabled,caption]
26297
+ // [srcAlt,src1x,src2x,src3x,src4x,width,height,alt,zoomDisabled,caption]
26298
+ leaf_srcAltValue(node, route) {
26299
+ this.writeProperty("srcAlt", node.value, route, {
26300
+ format: TagFormat.plainText
26301
+ });
26302
+ }
26189
26303
  leaf_src1x(node, route) {
26190
26304
  this.writeProperty("src1x", node.value, route, {
26191
26305
  format: TagFormat.plainText
@@ -35723,6 +35837,264 @@ var ConfigBuilder = class {
35723
35837
  build(options) {
35724
35838
  const opts = Object.assign({}, options);
35725
35839
  this.buildFlat(opts);
35840
+ const bitConfigs = [];
35841
+ const groupConfigs = [];
35842
+ for (const bt of BitType.values()) {
35843
+ const bitType = instance2.getBitType(bt);
35844
+ const _bitConfig = BITS[bitType];
35845
+ if (_bitConfig) {
35846
+ _bitConfig.bitType = bitType;
35847
+ bitConfigs.push(_bitConfig);
35848
+ }
35849
+ }
35850
+ for (const [k, g] of Object.entries(GROUPS)) {
35851
+ const g2 = g;
35852
+ let k2 = k;
35853
+ if (k.startsWith("group_")) k2 = k2.substring(6);
35854
+ k2 = /*'_' +*/
35855
+ stringUtils.camelToKebab(k2);
35856
+ g2.key = k2;
35857
+ groupConfigs.push(g2);
35858
+ }
35859
+ const outputFolder = opts.outputDir ?? "assets/config";
35860
+ const outputFolderBits = import_node_path3.default.join(outputFolder, "bits");
35861
+ const outputFolderGroups = import_node_path3.default.join(outputFolder, "partials");
35862
+ import_fs_extra3.default.ensureDirSync(outputFolderBits);
35863
+ import_fs_extra3.default.ensureDirSync(outputFolderGroups);
35864
+ const fileWrites = [];
35865
+ for (const b of bitConfigs) {
35866
+ const inherits = [];
35867
+ const tags2 = [];
35868
+ const tagEntriesTypeOrder = [
35869
+ BitTagConfigKeyType.tag,
35870
+ BitTagConfigKeyType.property,
35871
+ BitTagConfigKeyType.resource,
35872
+ BitTagConfigKeyType.group,
35873
+ BitTagConfigKeyType.unknown
35874
+ ];
35875
+ const tagEntries = Object.entries(b.tags ?? []).sort((a, b2) => {
35876
+ const tagA = a[1];
35877
+ const tagB = b2[1];
35878
+ const typeA = typeFromConfigKey(tagA.key);
35879
+ const typeB = typeFromConfigKey(tagB.key);
35880
+ const typeOrder = tagEntriesTypeOrder.indexOf(typeA) - tagEntriesTypeOrder.indexOf(typeB);
35881
+ return typeOrder;
35882
+ });
35883
+ if (b.baseBitType) inherits.push(b.baseBitType);
35884
+ for (const [_tagKey, tag] of tagEntries) {
35885
+ const tagName = tag.key;
35886
+ let format = "";
35887
+ let chain = void 0;
35888
+ const tagType = typeFromConfigKey(tag.key);
35889
+ if (tagType === BitTagConfigKeyType.tag) {
35890
+ if (tagName === "%") {
35891
+ chain = {
35892
+ key: "%",
35893
+ format,
35894
+ min: tag.minCount,
35895
+ max: tag.maxCount,
35896
+ description: "Lead",
35897
+ chain: {
35898
+ key: "%",
35899
+ format,
35900
+ min: tag.minCount,
35901
+ max: tag.maxCount,
35902
+ description: "Page number",
35903
+ chain: {
35904
+ key: "%",
35905
+ format,
35906
+ min: tag.minCount,
35907
+ max: tag.maxCount,
35908
+ description: "Margin number"
35909
+ }
35910
+ }
35911
+ };
35912
+ }
35913
+ format = "bitmark--";
35914
+ } else if (tagType === BitTagConfigKeyType.property) {
35915
+ if (tag.format === TagFormat.plainText) {
35916
+ format = "string";
35917
+ } else if (tag.format === TagFormat.boolean) {
35918
+ format = "bool";
35919
+ } else if (tag.format === TagFormat.bitmarkText) {
35920
+ format = "bitmark";
35921
+ } else if (tag.format === TagFormat.number) {
35922
+ format = "number";
35923
+ }
35924
+ } else if (tagType === BitTagConfigKeyType.resource) {
35925
+ } else if (tagType === BitTagConfigKeyType.group) {
35926
+ let k = tag.key;
35927
+ if (k.startsWith("group_")) k = k.substring(6);
35928
+ k = "_" + k;
35929
+ inherits.push(k);
35930
+ continue;
35931
+ }
35932
+ const t = {
35933
+ key: tagName,
35934
+ format,
35935
+ default: null,
35936
+ alwaysInclude: false,
35937
+ min: tag.minCount == null ? 0 : tag.minCount,
35938
+ max: tag.maxCount == null ? 1 : tag.maxCount,
35939
+ description: tag.description ?? "",
35940
+ chain
35941
+ // raw: {
35942
+ // ...tag,
35943
+ // },
35944
+ };
35945
+ tags2.push(t);
35946
+ }
35947
+ const bitJson = {
35948
+ name: b.bitType,
35949
+ description: b.description ?? "",
35950
+ since: b.since,
35951
+ deprecated: b.deprecated,
35952
+ history: [
35953
+ {
35954
+ version: b.since,
35955
+ changes: ["Initial version"]
35956
+ }
35957
+ ],
35958
+ format: b.textFormatDefault ?? "bitmark--",
35959
+ bodyAllowed: b.bodyAllowed ?? true,
35960
+ bodyRequired: b.bodyRequired ?? false,
35961
+ footerAllowed: b.footerAllowed ?? true,
35962
+ footerRequired: b.footerRequired ?? false,
35963
+ resourceAttachmentAllowed: b.resourceAttachmentAllowed ?? true,
35964
+ inherits,
35965
+ tags: tags2
35966
+ };
35967
+ const output = import_node_path3.default.join(outputFolderBits, `${b.bitType}.jsonc`);
35968
+ const str = JSON.stringify(bitJson, null, 2);
35969
+ fileWrites.push(import_fs_extra3.default.writeFile(output, str));
35970
+ }
35971
+ const writeGroupConfigs = (groupConfigs2) => {
35972
+ for (const g of groupConfigs2) {
35973
+ const inherits = [];
35974
+ const tags2 = [];
35975
+ const groupKey = stringUtils.camelToKebab(g.key);
35976
+ const tagEntriesTypeOrder = [
35977
+ BitTagConfigKeyType.tag,
35978
+ BitTagConfigKeyType.property,
35979
+ BitTagConfigKeyType.resource,
35980
+ BitTagConfigKeyType.group
35981
+ ];
35982
+ const tagEntries = Object.entries(g.tags ?? []).sort((a, b) => {
35983
+ const tagA = a[1];
35984
+ const tagB = b[1];
35985
+ const typeOrder = tagEntriesTypeOrder.indexOf(tagA.type) - tagEntriesTypeOrder.indexOf(tagB.type);
35986
+ return typeOrder;
35987
+ });
35988
+ for (const [_tagKey, tag] of tagEntries) {
35989
+ let tagName = tag.key;
35990
+ const tagType = typeFromConfigKey(tag.key);
35991
+ let format = "";
35992
+ let chain = void 0;
35993
+ if (tagType === BitTagConfigKeyType.tag) {
35994
+ tagName = tag.name;
35995
+ if (tagName === "%") {
35996
+ chain = {
35997
+ key: "%",
35998
+ format,
35999
+ min: tag.minCount,
36000
+ max: tag.maxCount,
36001
+ description: "Lead",
36002
+ chain: {
36003
+ key: "%",
36004
+ format,
36005
+ min: tag.minCount,
36006
+ max: tag.maxCount,
36007
+ description: "Page number",
36008
+ chain: {
36009
+ key: "%",
36010
+ format,
36011
+ min: tag.minCount,
36012
+ max: tag.maxCount,
36013
+ description: "Margin number"
36014
+ }
36015
+ }
36016
+ };
36017
+ }
36018
+ format = "bitmark--";
36019
+ } else if (tagType === BitTagConfigKeyType.property) {
36020
+ tagName = tag.key;
36021
+ if (tag.format === TagFormat.plainText) {
36022
+ format = "string";
36023
+ } else if (tag.format === TagFormat.boolean) {
36024
+ format = "bool";
36025
+ } else if (tag.format === TagFormat.bitmarkText) {
36026
+ format = "bitmark";
36027
+ } else if (tag.format === TagFormat.number) {
36028
+ format = "number";
36029
+ }
36030
+ } else if (tagType === BitTagConfigKeyType.resource) {
36031
+ format = "string";
36032
+ } else if (tagType === BitTagConfigKeyType.group) {
36033
+ let k = tag.key;
36034
+ if (k.startsWith("group_")) k = k.substring(6);
36035
+ k = /*'_' +*/
36036
+ stringUtils.camelToKebab(k);
36037
+ inherits.push(k);
36038
+ continue;
36039
+ }
36040
+ const t = {
36041
+ key: tagName,
36042
+ format,
36043
+ default: null,
36044
+ alwaysInclude: false,
36045
+ min: tag.minCount == null ? 0 : tag.minCount,
36046
+ max: tag.maxCount == null ? 1 : tag.maxCount,
36047
+ description: tag.description ?? "",
36048
+ chain
36049
+ // raw: {
36050
+ // ...tag,
36051
+ // },
36052
+ };
36053
+ tags2.push(t);
36054
+ }
36055
+ const bitJson = {
36056
+ name: groupKey,
36057
+ description: g.description ?? "",
36058
+ since: "UNKNOWN",
36059
+ deprecated: g.deprecated,
36060
+ history: [
36061
+ {
36062
+ version: "UNKNOWN",
36063
+ changes: ["Initial version"]
36064
+ }
36065
+ ],
36066
+ inherits,
36067
+ tags: tags2
36068
+ // cards: [
36069
+ // {
36070
+ // card: null,
36071
+ // side: 1,
36072
+ // variant: null,
36073
+ // description: '',
36074
+ // tags: [],
36075
+ // },
36076
+ // {
36077
+ // card: null,
36078
+ // side: 2,
36079
+ // variant: 1,
36080
+ // description: '',
36081
+ // tags: [],
36082
+ // },
36083
+ // {
36084
+ // card: null,
36085
+ // side: 2,
36086
+ // variant: null,
36087
+ // description: '',
36088
+ // tags: [],
36089
+ // },
36090
+ // ],
36091
+ };
36092
+ const output = import_node_path3.default.join(outputFolderGroups, `${groupKey}.jsonc`);
36093
+ const str = JSON.stringify(bitJson, null, 2);
36094
+ import_fs_extra3.default.writeFileSync(output, str);
36095
+ }
36096
+ };
36097
+ writeGroupConfigs(groupConfigs);
35726
36098
  }
35727
36099
  buildFlat(options) {
35728
36100
  const opts = Object.assign({}, options);