@gmb/bitmark-parser-generator 5.3.2 → 5.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.
package/dist/index.d.cts CHANGED
@@ -419,6 +419,7 @@ declare const BitType: {
419
419
  readonly pageHero: "page-hero";
420
420
  readonly pageOpenBook: "page-open-book";
421
421
  readonly pageOpenBookList: "page-open-book-list";
422
+ readonly printBook: "print-book";
422
423
  readonly openBookChapter: "open-book-chapter";
423
424
  readonly pagePerson: "page-person";
424
425
  readonly pageProduct: "page-product";
@@ -447,6 +448,9 @@ declare const BitType: {
447
448
  readonly platformSectionInput: "platform-section-input";
448
449
  readonly platformSystemIcon: "platform-system-icon";
449
450
  readonly preparationNote: "preparation-note";
451
+ readonly printThisBook: "print-this-book";
452
+ readonly printThisChapter: "print-this-chapter";
453
+ readonly printPageBreak: "print-page-break";
450
454
  readonly pronunciationTable: "pronunciation-table";
451
455
  readonly prototypeImages: "prototype-images";
452
456
  readonly qAndA: "q-and-a";
@@ -813,6 +817,7 @@ declare const ConfigKey: {
813
817
  readonly property_internalPrintPdf: "@internalPrintPdf";
814
818
  readonly property_hasPrintRestriction: "@hasPrintRestriction";
815
819
  readonly property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput";
820
+ readonly property_extractorExtractionTimestamp: "@extractorExtractionTimestamp";
816
821
  readonly property_isCaseSensitive: "@isCaseSensitive";
817
822
  readonly property_isInfoOnly: "@isInfoOnly";
818
823
  readonly property_isPublic: "@isPublic";
@@ -850,6 +855,7 @@ declare const ConfigKey: {
850
855
  readonly property_mute: "@mute";
851
856
  readonly property_padletId: "@padletId";
852
857
  readonly property_page: "@page";
858
+ readonly property_printParentChapterLevel: "@printParentChapterLevel";
853
859
  readonly property_pageNo: "@pageNo";
854
860
  readonly property_partialAnswer: "@partialAnswer";
855
861
  readonly property_partner: "@partner";
@@ -1788,10 +1794,12 @@ interface BitJson {
1788
1794
  maxCreatedBits: number;
1789
1795
  maxDisplayLevel: number;
1790
1796
  maxTocChapterLevel: number;
1797
+ printParentChapterLevel: number;
1791
1798
  sourceDocument: string;
1792
1799
  internalPrintPdf: string;
1793
1800
  hasPrintRestriction: boolean;
1794
1801
  enforceUpdateOverUserInput: boolean;
1802
+ extractorExtractionTimestamp: string[];
1795
1803
  tocResource: string | string[];
1796
1804
  tocContent: string | string[];
1797
1805
  page: string;
@@ -2405,9 +2413,11 @@ interface Bit {
2405
2413
  internalPrintPdf?: Property;
2406
2414
  hasPrintRestriction?: Property;
2407
2415
  enforceUpdateOverUserInput?: Property;
2416
+ extractorExtractionTimestamp?: Property;
2408
2417
  tocResource?: Property;
2409
2418
  tocContent?: Property;
2410
2419
  page?: Property;
2420
+ printParentChapterLevel?: Property;
2411
2421
  platformBrandTarget?: Property;
2412
2422
  platformName?: Property;
2413
2423
  platformIcon?: ImageResourceWrapperJson;
@@ -2813,6 +2823,8 @@ declare const NodeType: {
2813
2823
  readonly hasPrintRestrictionValue: "hasPrintRestrictionValue";
2814
2824
  readonly enforceUpdateOverUserInput: "enforceUpdateOverUserInput";
2815
2825
  readonly enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue";
2826
+ readonly extractorExtractionTimestamp: "extractorExtractionTimestamp";
2827
+ readonly extractorExtractionTimestampValue: "extractorExtractionTimestampValue";
2816
2828
  readonly isCaseSensitive: "isCaseSensitive";
2817
2829
  readonly isCommented: "isCommented";
2818
2830
  readonly isCorrect: "isCorrect";
@@ -2915,6 +2927,8 @@ declare const NodeType: {
2915
2927
  readonly pageNumber: "pageNumber";
2916
2928
  readonly pageNumberValue: "pageNumberValue";
2917
2929
  readonly pageValue: "pageValue";
2930
+ readonly printParentChapterLevel: "printParentChapterLevel";
2931
+ readonly printParentChapterLevelValue: "printParentChapterLevelValue";
2918
2932
  readonly pairs: "pairs";
2919
2933
  readonly pairsValue: "pairsValue";
2920
2934
  readonly parent: "parent";
@@ -4211,9 +4225,11 @@ declare class Builder extends BaseBuilder {
4211
4225
  internalPrintPdf?: string;
4212
4226
  hasPrintRestriction?: boolean;
4213
4227
  enforceUpdateOverUserInput?: boolean;
4228
+ extractorExtractionTimestamp?: string[];
4214
4229
  tocResource?: string | string[];
4215
4230
  tocContent?: string | string[];
4216
4231
  page?: string | string[];
4232
+ printParentChapterLevel?: number;
4217
4233
  platformBrandTarget?: string;
4218
4234
  platformName?: string;
4219
4235
  platformIcon?: Partial<ImageResourceWrapperJson>;
package/dist/index.d.ts CHANGED
@@ -419,6 +419,7 @@ declare const BitType: {
419
419
  readonly pageHero: "page-hero";
420
420
  readonly pageOpenBook: "page-open-book";
421
421
  readonly pageOpenBookList: "page-open-book-list";
422
+ readonly printBook: "print-book";
422
423
  readonly openBookChapter: "open-book-chapter";
423
424
  readonly pagePerson: "page-person";
424
425
  readonly pageProduct: "page-product";
@@ -447,6 +448,9 @@ declare const BitType: {
447
448
  readonly platformSectionInput: "platform-section-input";
448
449
  readonly platformSystemIcon: "platform-system-icon";
449
450
  readonly preparationNote: "preparation-note";
451
+ readonly printThisBook: "print-this-book";
452
+ readonly printThisChapter: "print-this-chapter";
453
+ readonly printPageBreak: "print-page-break";
450
454
  readonly pronunciationTable: "pronunciation-table";
451
455
  readonly prototypeImages: "prototype-images";
452
456
  readonly qAndA: "q-and-a";
@@ -813,6 +817,7 @@ declare const ConfigKey: {
813
817
  readonly property_internalPrintPdf: "@internalPrintPdf";
814
818
  readonly property_hasPrintRestriction: "@hasPrintRestriction";
815
819
  readonly property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput";
820
+ readonly property_extractorExtractionTimestamp: "@extractorExtractionTimestamp";
816
821
  readonly property_isCaseSensitive: "@isCaseSensitive";
817
822
  readonly property_isInfoOnly: "@isInfoOnly";
818
823
  readonly property_isPublic: "@isPublic";
@@ -850,6 +855,7 @@ declare const ConfigKey: {
850
855
  readonly property_mute: "@mute";
851
856
  readonly property_padletId: "@padletId";
852
857
  readonly property_page: "@page";
858
+ readonly property_printParentChapterLevel: "@printParentChapterLevel";
853
859
  readonly property_pageNo: "@pageNo";
854
860
  readonly property_partialAnswer: "@partialAnswer";
855
861
  readonly property_partner: "@partner";
@@ -1788,10 +1794,12 @@ interface BitJson {
1788
1794
  maxCreatedBits: number;
1789
1795
  maxDisplayLevel: number;
1790
1796
  maxTocChapterLevel: number;
1797
+ printParentChapterLevel: number;
1791
1798
  sourceDocument: string;
1792
1799
  internalPrintPdf: string;
1793
1800
  hasPrintRestriction: boolean;
1794
1801
  enforceUpdateOverUserInput: boolean;
1802
+ extractorExtractionTimestamp: string[];
1795
1803
  tocResource: string | string[];
1796
1804
  tocContent: string | string[];
1797
1805
  page: string;
@@ -2405,9 +2413,11 @@ interface Bit {
2405
2413
  internalPrintPdf?: Property;
2406
2414
  hasPrintRestriction?: Property;
2407
2415
  enforceUpdateOverUserInput?: Property;
2416
+ extractorExtractionTimestamp?: Property;
2408
2417
  tocResource?: Property;
2409
2418
  tocContent?: Property;
2410
2419
  page?: Property;
2420
+ printParentChapterLevel?: Property;
2411
2421
  platformBrandTarget?: Property;
2412
2422
  platformName?: Property;
2413
2423
  platformIcon?: ImageResourceWrapperJson;
@@ -2813,6 +2823,8 @@ declare const NodeType: {
2813
2823
  readonly hasPrintRestrictionValue: "hasPrintRestrictionValue";
2814
2824
  readonly enforceUpdateOverUserInput: "enforceUpdateOverUserInput";
2815
2825
  readonly enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue";
2826
+ readonly extractorExtractionTimestamp: "extractorExtractionTimestamp";
2827
+ readonly extractorExtractionTimestampValue: "extractorExtractionTimestampValue";
2816
2828
  readonly isCaseSensitive: "isCaseSensitive";
2817
2829
  readonly isCommented: "isCommented";
2818
2830
  readonly isCorrect: "isCorrect";
@@ -2915,6 +2927,8 @@ declare const NodeType: {
2915
2927
  readonly pageNumber: "pageNumber";
2916
2928
  readonly pageNumberValue: "pageNumberValue";
2917
2929
  readonly pageValue: "pageValue";
2930
+ readonly printParentChapterLevel: "printParentChapterLevel";
2931
+ readonly printParentChapterLevelValue: "printParentChapterLevelValue";
2918
2932
  readonly pairs: "pairs";
2919
2933
  readonly pairsValue: "pairsValue";
2920
2934
  readonly parent: "parent";
@@ -4211,9 +4225,11 @@ declare class Builder extends BaseBuilder {
4211
4225
  internalPrintPdf?: string;
4212
4226
  hasPrintRestriction?: boolean;
4213
4227
  enforceUpdateOverUserInput?: boolean;
4228
+ extractorExtractionTimestamp?: string[];
4214
4229
  tocResource?: string | string[];
4215
4230
  tocContent?: string | string[];
4216
4231
  page?: string | string[];
4232
+ printParentChapterLevel?: number;
4217
4233
  platformBrandTarget?: string;
4218
4234
  platformName?: string;
4219
4235
  platformIcon?: Partial<ImageResourceWrapperJson>;
package/dist/index.js CHANGED
@@ -428,6 +428,7 @@ var BitType = {
428
428
  pageHero: "page-hero",
429
429
  pageOpenBook: "page-open-book",
430
430
  pageOpenBookList: "page-open-book-list",
431
+ printBook: "print-book",
431
432
  openBookChapter: "open-book-chapter",
432
433
  pagePerson: "page-person",
433
434
  pageProduct: "page-product",
@@ -456,6 +457,9 @@ var BitType = {
456
457
  platformSectionInput: "platform-section-input",
457
458
  platformSystemIcon: "platform-system-icon",
458
459
  preparationNote: "preparation-note",
460
+ printThisBook: "print-this-book",
461
+ printThisChapter: "print-this-chapter",
462
+ printPageBreak: "print-page-break",
459
463
  pronunciationTable: "pronunciation-table",
460
464
  prototypeImages: "prototype-images",
461
465
  qAndA: "q-and-a",
@@ -1238,6 +1242,7 @@ var propertyKeys = {
1238
1242
  property_internalPrintPdf: "@internalPrintPdf",
1239
1243
  property_hasPrintRestriction: "@hasPrintRestriction",
1240
1244
  property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput",
1245
+ property_extractorExtractionTimestamp: "@extractorExtractionTimestamp",
1241
1246
  property_isCaseSensitive: "@isCaseSensitive",
1242
1247
  property_isInfoOnly: "@isInfoOnly",
1243
1248
  property_isPublic: "@isPublic",
@@ -1275,6 +1280,7 @@ var propertyKeys = {
1275
1280
  property_mute: "@mute",
1276
1281
  property_padletId: "@padletId",
1277
1282
  property_page: "@page",
1283
+ property_printParentChapterLevel: "@printParentChapterLevel",
1278
1284
  property_pageNo: "@pageNo",
1279
1285
  property_partialAnswer: "@partialAnswer",
1280
1286
  property_partner: "@partner",
@@ -3414,6 +3420,12 @@ var GROUPS = {
3414
3420
  description: "If true, prioritize new content over legacy content from the instance API",
3415
3421
  format: TagFormat.boolean,
3416
3422
  defaultValue: "false"
3423
+ },
3424
+ {
3425
+ key: ConfigKey.property_extractorExtractionTimestamp,
3426
+ description: "Extraction timestamps for book conversion",
3427
+ format: TagFormat.plainText,
3428
+ maxCount: Count.infinity
3417
3429
  }
3418
3430
  ]
3419
3431
  },
@@ -6789,6 +6801,41 @@ var BITS = {
6789
6801
  baseBitType: BitType.article,
6790
6802
  description: "Preparation note bit, used to provide preparation notes in articles or books"
6791
6803
  },
6804
+ [BitType.printThisBook]: {
6805
+ since: "5.4.0",
6806
+ baseBitType: BitType._standard,
6807
+ description: "Print this book bit, used to create a button that prints the entire book",
6808
+ tags: [
6809
+ {
6810
+ key: ConfigKey.property_buttonCaption,
6811
+ description: "The caption of the print button",
6812
+ format: TagFormat.plainText
6813
+ }
6814
+ ]
6815
+ },
6816
+ [BitType.printThisChapter]: {
6817
+ since: "5.4.0",
6818
+ baseBitType: BitType._standard,
6819
+ description: "Print this chapter bit, used to create a button that prints the current chapter",
6820
+ tags: [
6821
+ {
6822
+ key: ConfigKey.property_buttonCaption,
6823
+ description: "The caption of the print button",
6824
+ format: TagFormat.plainText
6825
+ },
6826
+ {
6827
+ key: ConfigKey.property_printParentChapterLevel,
6828
+ description: "The parent chapter level to print",
6829
+ format: TagFormat.number,
6830
+ defaultValue: "-1"
6831
+ }
6832
+ ]
6833
+ },
6834
+ [BitType.printPageBreak]: {
6835
+ since: "5.4.0",
6836
+ baseBitType: BitType.separator,
6837
+ description: "Print page break bit, used to create page breaks for printing in articles or books"
6838
+ },
6792
6839
  [BitType.releaseNotesSummary]: {
6793
6840
  since: "1.3.0",
6794
6841
  baseBitType: BitType.article,
@@ -7361,6 +7408,39 @@ var BITS = {
7361
7408
  }
7362
7409
  ]
7363
7410
  },
7411
+ [BitType.printBook]: {
7412
+ since: "5.5.0",
7413
+ baseBitType: BitType.article,
7414
+ description: "Print book bit, used to create pages that open books without author information in articles or books",
7415
+ tags: [
7416
+ {
7417
+ key: ConfigKey.property_slug,
7418
+ description: "Slug for the book, used to identify the book in the system",
7419
+ format: TagFormat.plainText
7420
+ },
7421
+ {
7422
+ key: ConfigKey.property_book,
7423
+ description: "Book reference for the page, used to link to a specific book",
7424
+ format: TagFormat.plainText,
7425
+ chain: [
7426
+ {
7427
+ key: ConfigKey.tag_reference,
7428
+ description: "Reference tag for the book, used to link to the book in the system",
7429
+ maxCount: 2
7430
+ }
7431
+ ]
7432
+ },
7433
+ {
7434
+ /* Allow incorrectly chained reference tag */
7435
+ key: ConfigKey.tag_reference,
7436
+ description: "Reference tag for the book, used to link to the book in the system"
7437
+ },
7438
+ {
7439
+ key: ConfigKey.property_buttonCaption,
7440
+ description: "Caption for the button, used to define the text displayed on the button"
7441
+ }
7442
+ ]
7443
+ },
7364
7444
  [BitType.openBookChapter]: {
7365
7445
  since: "4.16.0",
7366
7446
  baseBitType: BitType.pageOpenBook,
@@ -10256,7 +10336,7 @@ var instance2 = new Config();
10256
10336
  // src/generated/package_info.ts
10257
10337
  var PACKAGE_INFO = {
10258
10338
  "name": "@gmb/bitmark-parser-generator",
10259
- "version": "5.3.2",
10339
+ "version": "5.5.0",
10260
10340
  "author": "Get More Brain Ltd",
10261
10341
  "license": "ISC",
10262
10342
  "description": "A bitmark parser and generator using Peggy.js"
@@ -10879,6 +10959,8 @@ var NodeType = {
10879
10959
  hasPrintRestrictionValue: "hasPrintRestrictionValue",
10880
10960
  enforceUpdateOverUserInput: "enforceUpdateOverUserInput",
10881
10961
  enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue",
10962
+ extractorExtractionTimestamp: "extractorExtractionTimestamp",
10963
+ extractorExtractionTimestampValue: "extractorExtractionTimestampValue",
10882
10964
  isCaseSensitive: "isCaseSensitive",
10883
10965
  isCommented: "isCommented",
10884
10966
  isCorrect: "isCorrect",
@@ -10982,6 +11064,8 @@ var NodeType = {
10982
11064
  pageNumber: "pageNumber",
10983
11065
  pageNumberValue: "pageNumberValue",
10984
11066
  pageValue: "pageValue",
11067
+ printParentChapterLevel: "printParentChapterLevel",
11068
+ printParentChapterLevelValue: "printParentChapterLevelValue",
10985
11069
  pairs: "pairs",
10986
11070
  pairsValue: "pairsValue",
10987
11071
  parent: "parent",
@@ -24761,6 +24845,12 @@ var Builder = class extends BaseBuilder {
24761
24845
  data.enforceUpdateOverUserInput,
24762
24846
  options
24763
24847
  ),
24848
+ extractorExtractionTimestamp: this.toAstProperty(
24849
+ bitType,
24850
+ ConfigKey.property_extractorExtractionTimestamp,
24851
+ data.extractorExtractionTimestamp,
24852
+ options
24853
+ ),
24764
24854
  tocResource: this.toAstProperty(
24765
24855
  bitType,
24766
24856
  ConfigKey.property_tocResource,
@@ -24774,6 +24864,12 @@ var Builder = class extends BaseBuilder {
24774
24864
  options
24775
24865
  ),
24776
24866
  page: this.toAstProperty(bitType, ConfigKey.property_page, data.page, options),
24867
+ printParentChapterLevel: this.toAstProperty(
24868
+ bitType,
24869
+ ConfigKey.property_printParentChapterLevel,
24870
+ data.printParentChapterLevel,
24871
+ options
24872
+ ),
24777
24873
  platformBrandTarget: this.toAstProperty(
24778
24874
  bitType,
24779
24875
  ConfigKey.property_platformBrandTarget,
@@ -30444,6 +30540,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
30444
30540
  BitType.pageFooter,
30445
30541
  BitType.pageOpenBook,
30446
30542
  BitType.pagePerson,
30543
+ BitType.printBook,
30447
30544
  BitType.pageProduct,
30448
30545
  BitType.pageProductList,
30449
30546
  BitType.pageProductVideo,
@@ -30464,6 +30561,9 @@ var JsonGenerator = class extends AstWalkerGenerator {
30464
30561
  if (instance2.isOfBitType(bitType, BitType.tocContent)) {
30465
30562
  if (bitJson.tocContent == null) bitJson.tocContent = [];
30466
30563
  }
30564
+ if (instance2.isOfBitType(bitType, BitType.printThisChapter)) {
30565
+ if (bitJson.printParentChapterLevel == null) bitJson.printParentChapterLevel = -1;
30566
+ }
30467
30567
  if (instance2.isOfBitType(bitType, BitType.book)) {
30468
30568
  if (bitJson.maxTocChapterLevel == null) bitJson.maxTocChapterLevel = -1;
30469
30569
  if (bitJson.hasPrintRestriction == null) bitJson.hasPrintRestriction = true;
@@ -38935,6 +39035,7 @@ var JsonFileGenerator = class {
38935
39035
  import path3 from "path";
38936
39036
  import { Enum as Enum22 } from "@ncoderz/superenum";
38937
39037
  import fs3 from "fs-extra";
39038
+ var normalizeCardKey = (cardSetKey) => stringUtils.camelToKebab(cardSetKey);
38938
39039
  var ConfigBuilder = class {
38939
39040
  build(options) {
38940
39041
  const opts = Object.assign({}, options);
@@ -38975,8 +39076,10 @@ var ConfigBuilder = class {
38975
39076
  const outputFolder = opts.outputDir ?? "assets/config";
38976
39077
  const outputFolderBits = path3.join(outputFolder, "bits");
38977
39078
  const outputFolderGroups = path3.join(outputFolder, "partials");
39079
+ const outputFolderCards = path3.join(outputFolder, "cards");
38978
39080
  fs3.ensureDirSync(outputFolderBits);
38979
39081
  fs3.ensureDirSync(outputFolderGroups);
39082
+ fs3.ensureDirSync(outputFolderCards);
38980
39083
  const bitsFiles = fs3.readdirSync(outputFolderBits).filter((f) => f.endsWith(".jsonc"));
38981
39084
  for (const file of bitsFiles) {
38982
39085
  fs3.removeSync(path3.join(outputFolderBits, file));
@@ -38985,7 +39088,18 @@ var ConfigBuilder = class {
38985
39088
  for (const file of partialsFiles) {
38986
39089
  fs3.removeSync(path3.join(outputFolderGroups, file));
38987
39090
  }
39091
+ const cardsFiles = fs3.readdirSync(outputFolderCards).filter((f) => f.endsWith(".jsonc"));
39092
+ for (const file of cardsFiles) {
39093
+ fs3.removeSync(path3.join(outputFolderCards, file));
39094
+ }
38988
39095
  const fileWrites = [];
39096
+ const tagEntriesTypeOrder = [
39097
+ BitTagConfigKeyType.tag,
39098
+ BitTagConfigKeyType.property,
39099
+ BitTagConfigKeyType.resource,
39100
+ BitTagConfigKeyType.group,
39101
+ BitTagConfigKeyType.unknown
39102
+ ];
38989
39103
  const resolveGroupReferences = (groupKey) => {
38990
39104
  if (squashedGroups.has(groupKey)) {
38991
39105
  const replacements = squashedGroups.get(groupKey);
@@ -39090,6 +39204,38 @@ var ConfigBuilder = class {
39090
39204
  tags2.push(t);
39091
39205
  return tags2;
39092
39206
  };
39207
+ const serializeCardSet = (cardSetKey) => {
39208
+ const cardSetConfig = CARDSETS[cardSetKey];
39209
+ if (!cardSetConfig) return void 0;
39210
+ const normalizedKey = normalizeCardKey(cardSetKey);
39211
+ const sides = cardSetConfig.variants.map((variantList) => {
39212
+ const variants = variantList.map((variant) => {
39213
+ const variantTags = [];
39214
+ const variantTagEntries = Object.entries(variant.tags ?? []).sort((a, b) => {
39215
+ const tagA = a[1];
39216
+ const tagB = b[1];
39217
+ const typeA = typeFromConfigKey(tagA.key);
39218
+ const typeB = typeFromConfigKey(tagB.key);
39219
+ const typeOrder = tagEntriesTypeOrder.indexOf(typeA) - tagEntriesTypeOrder.indexOf(typeB);
39220
+ return typeOrder;
39221
+ });
39222
+ for (const [, variantTag] of variantTagEntries) {
39223
+ variantTags.push(...processTagEntries(variantTag, []));
39224
+ }
39225
+ return {
39226
+ tags: variantTags,
39227
+ repeatCount: variant.repeatCount ?? 1,
39228
+ bodyAllowed: variant.bodyAllowed ?? true,
39229
+ bodyRequired: variant.bodyRequired ?? false
39230
+ };
39231
+ });
39232
+ return { variants };
39233
+ });
39234
+ return {
39235
+ key: normalizedKey,
39236
+ sides
39237
+ };
39238
+ };
39093
39239
  for (const bt of bitGroupConfigKeys) {
39094
39240
  const bitType = instance2.getBitType(bt);
39095
39241
  const _bitConfig = BITS[bitType];
@@ -39122,13 +39268,6 @@ var ConfigBuilder = class {
39122
39268
  for (const b of bitConfigs) {
39123
39269
  const resolvedBitConfig = instance2.getBitConfig(b.bitType);
39124
39270
  const tags2 = [];
39125
- const tagEntriesTypeOrder = [
39126
- BitTagConfigKeyType.tag,
39127
- BitTagConfigKeyType.property,
39128
- BitTagConfigKeyType.resource,
39129
- BitTagConfigKeyType.group,
39130
- BitTagConfigKeyType.unknown
39131
- ];
39132
39271
  const tagEntries = Object.entries(b.tags ?? []).sort((a, b2) => {
39133
39272
  const tagA = a[1];
39134
39273
  const tagB = b2[1];
@@ -39160,6 +39299,10 @@ var ConfigBuilder = class {
39160
39299
  tags2.push(...processTagEntries(tag, []));
39161
39300
  }
39162
39301
  }
39302
+ let cardRef;
39303
+ if (b.cardSet && CARDSETS[b.cardSet]) {
39304
+ cardRef = normalizeCardKey(b.cardSet);
39305
+ }
39163
39306
  const bitJson = {
39164
39307
  name: b.bitType,
39165
39308
  description: b.description ?? "",
@@ -39177,7 +39320,8 @@ var ConfigBuilder = class {
39177
39320
  footerAllowed: resolvedBitConfig.footerAllowed ?? true,
39178
39321
  footerRequired: resolvedBitConfig.footerRequired ?? false,
39179
39322
  resourceAttachmentAllowed: resolvedBitConfig.resourceAttachmentAllowed ?? true,
39180
- tags: tags2
39323
+ tags: tags2,
39324
+ ...cardRef ? { card: cardRef } : {}
39181
39325
  };
39182
39326
  const output = path3.join(outputFolderBits, `${b.bitType}.jsonc`);
39183
39327
  const str = JSON.stringify(bitJson, null, 2);
@@ -39187,7 +39331,7 @@ var ConfigBuilder = class {
39187
39331
  for (const g of groupConfigs2) {
39188
39332
  const tags2 = [];
39189
39333
  const groupKey = stringUtils.camelToKebab(g.key);
39190
- const tagEntriesTypeOrder = [
39334
+ const tagEntriesTypeOrder2 = [
39191
39335
  BitTagConfigKeyType.tag,
39192
39336
  BitTagConfigKeyType.property,
39193
39337
  BitTagConfigKeyType.resource,
@@ -39196,7 +39340,7 @@ var ConfigBuilder = class {
39196
39340
  const tagEntries = Object.entries(g.tags ?? []).sort((a, b) => {
39197
39341
  const tagA = a[1];
39198
39342
  const tagB = b[1];
39199
- const typeOrder = tagEntriesTypeOrder.indexOf(tagA.type) - tagEntriesTypeOrder.indexOf(tagB.type);
39343
+ const typeOrder = tagEntriesTypeOrder2.indexOf(tagA.type) - tagEntriesTypeOrder2.indexOf(tagB.type);
39200
39344
  return typeOrder;
39201
39345
  });
39202
39346
  for (const [_tagKey, tag] of tagEntries) {
@@ -39244,6 +39388,15 @@ var ConfigBuilder = class {
39244
39388
  }
39245
39389
  };
39246
39390
  writeGroupConfigs(groupConfigs);
39391
+ const writeCardConfigs = () => {
39392
+ for (const cardSetKey of Object.keys(CARDSETS)) {
39393
+ const cardJson = serializeCardSet(cardSetKey);
39394
+ if (!cardJson) continue;
39395
+ const output = path3.join(outputFolderCards, `${cardJson.key}.jsonc`);
39396
+ const str = JSON.stringify(cardJson, null, 2);
39397
+ fileWrites.push(fs3.writeFile(output, str));
39398
+ }
39399
+ };
39247
39400
  const writeBitsAsGroupConfigs = (bitsAsGroupConfigs) => {
39248
39401
  for (const b of bitsAsGroupConfigs) {
39249
39402
  const groupKey = `group-${b.bitType}`;
@@ -39260,13 +39413,6 @@ var ConfigBuilder = class {
39260
39413
  });
39261
39414
  }
39262
39415
  }
39263
- const tagEntriesTypeOrder = [
39264
- BitTagConfigKeyType.tag,
39265
- BitTagConfigKeyType.property,
39266
- BitTagConfigKeyType.resource,
39267
- BitTagConfigKeyType.group,
39268
- BitTagConfigKeyType.unknown
39269
- ];
39270
39416
  const tagEntries = Object.entries(b.tags ?? []).sort((a, b2) => {
39271
39417
  const tagA = a[1];
39272
39418
  const tagB = b2[1];
@@ -39297,6 +39443,7 @@ var ConfigBuilder = class {
39297
39443
  }
39298
39444
  };
39299
39445
  writeBitsAsGroupConfigs(bitGroupConfigs);
39446
+ writeCardConfigs();
39300
39447
  Promise.all(fileWrites).then(() => {
39301
39448
  const validationErrors = this.validateConfigTree(outputFolder);
39302
39449
  if (validationErrors.length > 0) {
@@ -39322,6 +39469,7 @@ var ConfigBuilder = class {
39322
39469
  const errors = [];
39323
39470
  const outputFolderBits = path3.join(outputFolder, "bits");
39324
39471
  const outputFolderGroups = path3.join(outputFolder, "partials");
39472
+ const outputFolderCards = path3.join(outputFolder, "cards");
39325
39473
  const availableGroups = /* @__PURE__ */ new Set();
39326
39474
  if (fs3.existsSync(outputFolderGroups)) {
39327
39475
  const groupFiles = fs3.readdirSync(outputFolderGroups).filter((f) => f.endsWith(".jsonc"));
@@ -39330,16 +39478,22 @@ var ConfigBuilder = class {
39330
39478
  availableGroups.add(groupName);
39331
39479
  }
39332
39480
  }
39481
+ const availableCards = /* @__PURE__ */ new Set();
39482
+ const cardFiles = fs3.existsSync(outputFolderCards) ? fs3.readdirSync(outputFolderCards).filter((f) => f.endsWith(".jsonc")) : [];
39483
+ for (const file of cardFiles) {
39484
+ const cardName = file.replace(".jsonc", "");
39485
+ availableCards.add(cardName);
39486
+ }
39333
39487
  const checkTags = (tags2, filePath, lineOffset) => {
39334
39488
  for (let i = 0; i < tags2.length; i++) {
39335
39489
  const tag = tags2[i];
39336
- if (tag.type === "group") {
39490
+ if (tag?.type === "group" && tag.key) {
39337
39491
  if (!availableGroups.has(tag.key)) {
39338
39492
  const line = lineOffset + i + 1;
39339
39493
  errors.push(`Missing group reference '${tag.key}' in ${filePath}:${line}`);
39340
39494
  }
39341
39495
  }
39342
- if (tag.tags && Array.isArray(tag.tags)) {
39496
+ if (Array.isArray(tag?.tags)) {
39343
39497
  checkTags(tag.tags, filePath, lineOffset + i + 1);
39344
39498
  }
39345
39499
  }
@@ -39354,6 +39508,27 @@ var ConfigBuilder = class {
39354
39508
  if (config.tags && Array.isArray(config.tags)) {
39355
39509
  checkTags(config.tags, `bits/${file}`, 15);
39356
39510
  }
39511
+ if (typeof config.card === "string") {
39512
+ if (!availableCards.has(config.card)) {
39513
+ errors.push(`Missing card file '${config.card}' referenced in bits/${file}`);
39514
+ }
39515
+ } else if (config.card?.sides && Array.isArray(config.card.sides)) {
39516
+ config.card.sides.forEach((side, sideIdx) => {
39517
+ const variants = side.variants;
39518
+ if (Array.isArray(variants)) {
39519
+ variants.forEach((variant, variantIdx) => {
39520
+ const variantTags = variant.tags;
39521
+ if (Array.isArray(variantTags)) {
39522
+ checkTags(
39523
+ variantTags,
39524
+ `bits/${file} (card side ${sideIdx}, variant ${variantIdx})`,
39525
+ 15
39526
+ );
39527
+ }
39528
+ });
39529
+ }
39530
+ });
39531
+ }
39357
39532
  } catch (err) {
39358
39533
  errors.push(`Failed to parse ${file}: ${err}`);
39359
39534
  }
@@ -39374,6 +39549,38 @@ var ConfigBuilder = class {
39374
39549
  }
39375
39550
  }
39376
39551
  }
39552
+ if (cardFiles.length > 0) {
39553
+ for (const file of cardFiles) {
39554
+ const filePath = path3.join(outputFolderCards, file);
39555
+ try {
39556
+ const content = fs3.readFileSync(filePath, "utf-8");
39557
+ const config = JSON.parse(content);
39558
+ const expectedKey = file.replace(".jsonc", "");
39559
+ if (config.key && config.key !== expectedKey) {
39560
+ errors.push(`Card key mismatch in cards/${file}: expected '${expectedKey}'`);
39561
+ }
39562
+ if (Array.isArray(config.sides)) {
39563
+ config.sides.forEach((side, sideIdx) => {
39564
+ const variants = side.variants;
39565
+ if (Array.isArray(variants)) {
39566
+ variants.forEach((variant, variantIdx) => {
39567
+ const variantTags = variant.tags;
39568
+ if (Array.isArray(variantTags)) {
39569
+ checkTags(
39570
+ variantTags,
39571
+ `cards/${file} (side ${sideIdx}, variant ${variantIdx})`,
39572
+ 10
39573
+ );
39574
+ }
39575
+ });
39576
+ }
39577
+ });
39578
+ }
39579
+ } catch (err) {
39580
+ errors.push(`Failed to parse cards/${file}: ${err}`);
39581
+ }
39582
+ }
39583
+ }
39377
39584
  return errors;
39378
39585
  }
39379
39586
  // Build flat bit configs
@@ -39468,6 +39675,11 @@ var ConfigBuilder = class {
39468
39675
  for (const [_tagKey, tag] of tagEntries) {
39469
39676
  tags2.push(...processTagEntries(tag));
39470
39677
  }
39678
+ let cardRef;
39679
+ const cardSetKey = b.cardSet?.configKey;
39680
+ if (cardSetKey && CARDSETS[cardSetKey]) {
39681
+ cardRef = normalizeCardKey(cardSetKey);
39682
+ }
39471
39683
  const bitJson = {
39472
39684
  name: b.bitType,
39473
39685
  description: "",
@@ -39485,7 +39697,8 @@ var ConfigBuilder = class {
39485
39697
  footerAllowed: b.footerAllowed ?? true,
39486
39698
  footerRequired: b.footerRequired ?? false,
39487
39699
  resourceAttachmentAllowed: b.resourceAttachmentAllowed ?? true,
39488
- tags: tags2
39700
+ tags: tags2,
39701
+ ...cardRef ? { card: cardRef } : {}
39489
39702
  };
39490
39703
  const output = path3.join(outputFolderBits, `${b.bitType}.jsonc`);
39491
39704
  const str = JSON.stringify(bitJson, null, 2);