@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/browser/bitmark-parser-generator.min.js +1 -1
- package/dist/browser/bundle-report.html +2 -2
- package/dist/browser/cjs/index.cjs +101 -1
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +16 -0
- package/dist/browser/esm/index.d.ts +16 -0
- package/dist/browser/esm/index.js +101 -1
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/cli/main.js +234 -21
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +234 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +234 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -489,6 +489,7 @@ var BitType = {
|
|
|
489
489
|
pageHero: "page-hero",
|
|
490
490
|
pageOpenBook: "page-open-book",
|
|
491
491
|
pageOpenBookList: "page-open-book-list",
|
|
492
|
+
printBook: "print-book",
|
|
492
493
|
openBookChapter: "open-book-chapter",
|
|
493
494
|
pagePerson: "page-person",
|
|
494
495
|
pageProduct: "page-product",
|
|
@@ -517,6 +518,9 @@ var BitType = {
|
|
|
517
518
|
platformSectionInput: "platform-section-input",
|
|
518
519
|
platformSystemIcon: "platform-system-icon",
|
|
519
520
|
preparationNote: "preparation-note",
|
|
521
|
+
printThisBook: "print-this-book",
|
|
522
|
+
printThisChapter: "print-this-chapter",
|
|
523
|
+
printPageBreak: "print-page-break",
|
|
520
524
|
pronunciationTable: "pronunciation-table",
|
|
521
525
|
prototypeImages: "prototype-images",
|
|
522
526
|
qAndA: "q-and-a",
|
|
@@ -1299,6 +1303,7 @@ var propertyKeys = {
|
|
|
1299
1303
|
property_internalPrintPdf: "@internalPrintPdf",
|
|
1300
1304
|
property_hasPrintRestriction: "@hasPrintRestriction",
|
|
1301
1305
|
property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput",
|
|
1306
|
+
property_extractorExtractionTimestamp: "@extractorExtractionTimestamp",
|
|
1302
1307
|
property_isCaseSensitive: "@isCaseSensitive",
|
|
1303
1308
|
property_isInfoOnly: "@isInfoOnly",
|
|
1304
1309
|
property_isPublic: "@isPublic",
|
|
@@ -1336,6 +1341,7 @@ var propertyKeys = {
|
|
|
1336
1341
|
property_mute: "@mute",
|
|
1337
1342
|
property_padletId: "@padletId",
|
|
1338
1343
|
property_page: "@page",
|
|
1344
|
+
property_printParentChapterLevel: "@printParentChapterLevel",
|
|
1339
1345
|
property_pageNo: "@pageNo",
|
|
1340
1346
|
property_partialAnswer: "@partialAnswer",
|
|
1341
1347
|
property_partner: "@partner",
|
|
@@ -3475,6 +3481,12 @@ var GROUPS = {
|
|
|
3475
3481
|
description: "If true, prioritize new content over legacy content from the instance API",
|
|
3476
3482
|
format: TagFormat.boolean,
|
|
3477
3483
|
defaultValue: "false"
|
|
3484
|
+
},
|
|
3485
|
+
{
|
|
3486
|
+
key: ConfigKey.property_extractorExtractionTimestamp,
|
|
3487
|
+
description: "Extraction timestamps for book conversion",
|
|
3488
|
+
format: TagFormat.plainText,
|
|
3489
|
+
maxCount: Count.infinity
|
|
3478
3490
|
}
|
|
3479
3491
|
]
|
|
3480
3492
|
},
|
|
@@ -6850,6 +6862,41 @@ var BITS = {
|
|
|
6850
6862
|
baseBitType: BitType.article,
|
|
6851
6863
|
description: "Preparation note bit, used to provide preparation notes in articles or books"
|
|
6852
6864
|
},
|
|
6865
|
+
[BitType.printThisBook]: {
|
|
6866
|
+
since: "5.4.0",
|
|
6867
|
+
baseBitType: BitType._standard,
|
|
6868
|
+
description: "Print this book bit, used to create a button that prints the entire book",
|
|
6869
|
+
tags: [
|
|
6870
|
+
{
|
|
6871
|
+
key: ConfigKey.property_buttonCaption,
|
|
6872
|
+
description: "The caption of the print button",
|
|
6873
|
+
format: TagFormat.plainText
|
|
6874
|
+
}
|
|
6875
|
+
]
|
|
6876
|
+
},
|
|
6877
|
+
[BitType.printThisChapter]: {
|
|
6878
|
+
since: "5.4.0",
|
|
6879
|
+
baseBitType: BitType._standard,
|
|
6880
|
+
description: "Print this chapter bit, used to create a button that prints the current chapter",
|
|
6881
|
+
tags: [
|
|
6882
|
+
{
|
|
6883
|
+
key: ConfigKey.property_buttonCaption,
|
|
6884
|
+
description: "The caption of the print button",
|
|
6885
|
+
format: TagFormat.plainText
|
|
6886
|
+
},
|
|
6887
|
+
{
|
|
6888
|
+
key: ConfigKey.property_printParentChapterLevel,
|
|
6889
|
+
description: "The parent chapter level to print",
|
|
6890
|
+
format: TagFormat.number,
|
|
6891
|
+
defaultValue: "-1"
|
|
6892
|
+
}
|
|
6893
|
+
]
|
|
6894
|
+
},
|
|
6895
|
+
[BitType.printPageBreak]: {
|
|
6896
|
+
since: "5.4.0",
|
|
6897
|
+
baseBitType: BitType.separator,
|
|
6898
|
+
description: "Print page break bit, used to create page breaks for printing in articles or books"
|
|
6899
|
+
},
|
|
6853
6900
|
[BitType.releaseNotesSummary]: {
|
|
6854
6901
|
since: "1.3.0",
|
|
6855
6902
|
baseBitType: BitType.article,
|
|
@@ -7422,6 +7469,39 @@ var BITS = {
|
|
|
7422
7469
|
}
|
|
7423
7470
|
]
|
|
7424
7471
|
},
|
|
7472
|
+
[BitType.printBook]: {
|
|
7473
|
+
since: "5.5.0",
|
|
7474
|
+
baseBitType: BitType.article,
|
|
7475
|
+
description: "Print book bit, used to create pages that open books without author information in articles or books",
|
|
7476
|
+
tags: [
|
|
7477
|
+
{
|
|
7478
|
+
key: ConfigKey.property_slug,
|
|
7479
|
+
description: "Slug for the book, used to identify the book in the system",
|
|
7480
|
+
format: TagFormat.plainText
|
|
7481
|
+
},
|
|
7482
|
+
{
|
|
7483
|
+
key: ConfigKey.property_book,
|
|
7484
|
+
description: "Book reference for the page, used to link to a specific book",
|
|
7485
|
+
format: TagFormat.plainText,
|
|
7486
|
+
chain: [
|
|
7487
|
+
{
|
|
7488
|
+
key: ConfigKey.tag_reference,
|
|
7489
|
+
description: "Reference tag for the book, used to link to the book in the system",
|
|
7490
|
+
maxCount: 2
|
|
7491
|
+
}
|
|
7492
|
+
]
|
|
7493
|
+
},
|
|
7494
|
+
{
|
|
7495
|
+
/* Allow incorrectly chained reference tag */
|
|
7496
|
+
key: ConfigKey.tag_reference,
|
|
7497
|
+
description: "Reference tag for the book, used to link to the book in the system"
|
|
7498
|
+
},
|
|
7499
|
+
{
|
|
7500
|
+
key: ConfigKey.property_buttonCaption,
|
|
7501
|
+
description: "Caption for the button, used to define the text displayed on the button"
|
|
7502
|
+
}
|
|
7503
|
+
]
|
|
7504
|
+
},
|
|
7425
7505
|
[BitType.openBookChapter]: {
|
|
7426
7506
|
since: "4.16.0",
|
|
7427
7507
|
baseBitType: BitType.pageOpenBook,
|
|
@@ -10317,7 +10397,7 @@ var instance2 = new Config();
|
|
|
10317
10397
|
// src/generated/package_info.ts
|
|
10318
10398
|
var PACKAGE_INFO = {
|
|
10319
10399
|
"name": "@gmb/bitmark-parser-generator",
|
|
10320
|
-
"version": "5.
|
|
10400
|
+
"version": "5.5.0",
|
|
10321
10401
|
"author": "Get More Brain Ltd",
|
|
10322
10402
|
"license": "ISC",
|
|
10323
10403
|
"description": "A bitmark parser and generator using Peggy.js"
|
|
@@ -10940,6 +11020,8 @@ var NodeType = {
|
|
|
10940
11020
|
hasPrintRestrictionValue: "hasPrintRestrictionValue",
|
|
10941
11021
|
enforceUpdateOverUserInput: "enforceUpdateOverUserInput",
|
|
10942
11022
|
enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue",
|
|
11023
|
+
extractorExtractionTimestamp: "extractorExtractionTimestamp",
|
|
11024
|
+
extractorExtractionTimestampValue: "extractorExtractionTimestampValue",
|
|
10943
11025
|
isCaseSensitive: "isCaseSensitive",
|
|
10944
11026
|
isCommented: "isCommented",
|
|
10945
11027
|
isCorrect: "isCorrect",
|
|
@@ -11043,6 +11125,8 @@ var NodeType = {
|
|
|
11043
11125
|
pageNumber: "pageNumber",
|
|
11044
11126
|
pageNumberValue: "pageNumberValue",
|
|
11045
11127
|
pageValue: "pageValue",
|
|
11128
|
+
printParentChapterLevel: "printParentChapterLevel",
|
|
11129
|
+
printParentChapterLevelValue: "printParentChapterLevelValue",
|
|
11046
11130
|
pairs: "pairs",
|
|
11047
11131
|
pairsValue: "pairsValue",
|
|
11048
11132
|
parent: "parent",
|
|
@@ -24822,6 +24906,12 @@ var Builder = class extends BaseBuilder {
|
|
|
24822
24906
|
data.enforceUpdateOverUserInput,
|
|
24823
24907
|
options
|
|
24824
24908
|
),
|
|
24909
|
+
extractorExtractionTimestamp: this.toAstProperty(
|
|
24910
|
+
bitType,
|
|
24911
|
+
ConfigKey.property_extractorExtractionTimestamp,
|
|
24912
|
+
data.extractorExtractionTimestamp,
|
|
24913
|
+
options
|
|
24914
|
+
),
|
|
24825
24915
|
tocResource: this.toAstProperty(
|
|
24826
24916
|
bitType,
|
|
24827
24917
|
ConfigKey.property_tocResource,
|
|
@@ -24835,6 +24925,12 @@ var Builder = class extends BaseBuilder {
|
|
|
24835
24925
|
options
|
|
24836
24926
|
),
|
|
24837
24927
|
page: this.toAstProperty(bitType, ConfigKey.property_page, data.page, options),
|
|
24928
|
+
printParentChapterLevel: this.toAstProperty(
|
|
24929
|
+
bitType,
|
|
24930
|
+
ConfigKey.property_printParentChapterLevel,
|
|
24931
|
+
data.printParentChapterLevel,
|
|
24932
|
+
options
|
|
24933
|
+
),
|
|
24838
24934
|
platformBrandTarget: this.toAstProperty(
|
|
24839
24935
|
bitType,
|
|
24840
24936
|
ConfigKey.property_platformBrandTarget,
|
|
@@ -30505,6 +30601,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
|
|
|
30505
30601
|
BitType.pageFooter,
|
|
30506
30602
|
BitType.pageOpenBook,
|
|
30507
30603
|
BitType.pagePerson,
|
|
30604
|
+
BitType.printBook,
|
|
30508
30605
|
BitType.pageProduct,
|
|
30509
30606
|
BitType.pageProductList,
|
|
30510
30607
|
BitType.pageProductVideo,
|
|
@@ -30525,6 +30622,9 @@ var JsonGenerator = class extends AstWalkerGenerator {
|
|
|
30525
30622
|
if (instance2.isOfBitType(bitType, BitType.tocContent)) {
|
|
30526
30623
|
if (bitJson.tocContent == null) bitJson.tocContent = [];
|
|
30527
30624
|
}
|
|
30625
|
+
if (instance2.isOfBitType(bitType, BitType.printThisChapter)) {
|
|
30626
|
+
if (bitJson.printParentChapterLevel == null) bitJson.printParentChapterLevel = -1;
|
|
30627
|
+
}
|
|
30528
30628
|
if (instance2.isOfBitType(bitType, BitType.book)) {
|
|
30529
30629
|
if (bitJson.maxTocChapterLevel == null) bitJson.maxTocChapterLevel = -1;
|
|
30530
30630
|
if (bitJson.hasPrintRestriction == null) bitJson.hasPrintRestriction = true;
|
|
@@ -38996,6 +39096,7 @@ var JsonFileGenerator = class {
|
|
|
38996
39096
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
38997
39097
|
var import_superenum50 = require("@ncoderz/superenum");
|
|
38998
39098
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
39099
|
+
var normalizeCardKey = (cardSetKey) => stringUtils.camelToKebab(cardSetKey);
|
|
38999
39100
|
var ConfigBuilder = class {
|
|
39000
39101
|
build(options) {
|
|
39001
39102
|
const opts = Object.assign({}, options);
|
|
@@ -39036,8 +39137,10 @@ var ConfigBuilder = class {
|
|
|
39036
39137
|
const outputFolder = opts.outputDir ?? "assets/config";
|
|
39037
39138
|
const outputFolderBits = import_node_path3.default.join(outputFolder, "bits");
|
|
39038
39139
|
const outputFolderGroups = import_node_path3.default.join(outputFolder, "partials");
|
|
39140
|
+
const outputFolderCards = import_node_path3.default.join(outputFolder, "cards");
|
|
39039
39141
|
import_fs_extra3.default.ensureDirSync(outputFolderBits);
|
|
39040
39142
|
import_fs_extra3.default.ensureDirSync(outputFolderGroups);
|
|
39143
|
+
import_fs_extra3.default.ensureDirSync(outputFolderCards);
|
|
39041
39144
|
const bitsFiles = import_fs_extra3.default.readdirSync(outputFolderBits).filter((f) => f.endsWith(".jsonc"));
|
|
39042
39145
|
for (const file of bitsFiles) {
|
|
39043
39146
|
import_fs_extra3.default.removeSync(import_node_path3.default.join(outputFolderBits, file));
|
|
@@ -39046,7 +39149,18 @@ var ConfigBuilder = class {
|
|
|
39046
39149
|
for (const file of partialsFiles) {
|
|
39047
39150
|
import_fs_extra3.default.removeSync(import_node_path3.default.join(outputFolderGroups, file));
|
|
39048
39151
|
}
|
|
39152
|
+
const cardsFiles = import_fs_extra3.default.readdirSync(outputFolderCards).filter((f) => f.endsWith(".jsonc"));
|
|
39153
|
+
for (const file of cardsFiles) {
|
|
39154
|
+
import_fs_extra3.default.removeSync(import_node_path3.default.join(outputFolderCards, file));
|
|
39155
|
+
}
|
|
39049
39156
|
const fileWrites = [];
|
|
39157
|
+
const tagEntriesTypeOrder = [
|
|
39158
|
+
BitTagConfigKeyType.tag,
|
|
39159
|
+
BitTagConfigKeyType.property,
|
|
39160
|
+
BitTagConfigKeyType.resource,
|
|
39161
|
+
BitTagConfigKeyType.group,
|
|
39162
|
+
BitTagConfigKeyType.unknown
|
|
39163
|
+
];
|
|
39050
39164
|
const resolveGroupReferences = (groupKey) => {
|
|
39051
39165
|
if (squashedGroups.has(groupKey)) {
|
|
39052
39166
|
const replacements = squashedGroups.get(groupKey);
|
|
@@ -39151,6 +39265,38 @@ var ConfigBuilder = class {
|
|
|
39151
39265
|
tags2.push(t);
|
|
39152
39266
|
return tags2;
|
|
39153
39267
|
};
|
|
39268
|
+
const serializeCardSet = (cardSetKey) => {
|
|
39269
|
+
const cardSetConfig = CARDSETS[cardSetKey];
|
|
39270
|
+
if (!cardSetConfig) return void 0;
|
|
39271
|
+
const normalizedKey = normalizeCardKey(cardSetKey);
|
|
39272
|
+
const sides = cardSetConfig.variants.map((variantList) => {
|
|
39273
|
+
const variants = variantList.map((variant) => {
|
|
39274
|
+
const variantTags = [];
|
|
39275
|
+
const variantTagEntries = Object.entries(variant.tags ?? []).sort((a, b) => {
|
|
39276
|
+
const tagA = a[1];
|
|
39277
|
+
const tagB = b[1];
|
|
39278
|
+
const typeA = typeFromConfigKey(tagA.key);
|
|
39279
|
+
const typeB = typeFromConfigKey(tagB.key);
|
|
39280
|
+
const typeOrder = tagEntriesTypeOrder.indexOf(typeA) - tagEntriesTypeOrder.indexOf(typeB);
|
|
39281
|
+
return typeOrder;
|
|
39282
|
+
});
|
|
39283
|
+
for (const [, variantTag] of variantTagEntries) {
|
|
39284
|
+
variantTags.push(...processTagEntries(variantTag, []));
|
|
39285
|
+
}
|
|
39286
|
+
return {
|
|
39287
|
+
tags: variantTags,
|
|
39288
|
+
repeatCount: variant.repeatCount ?? 1,
|
|
39289
|
+
bodyAllowed: variant.bodyAllowed ?? true,
|
|
39290
|
+
bodyRequired: variant.bodyRequired ?? false
|
|
39291
|
+
};
|
|
39292
|
+
});
|
|
39293
|
+
return { variants };
|
|
39294
|
+
});
|
|
39295
|
+
return {
|
|
39296
|
+
key: normalizedKey,
|
|
39297
|
+
sides
|
|
39298
|
+
};
|
|
39299
|
+
};
|
|
39154
39300
|
for (const bt of bitGroupConfigKeys) {
|
|
39155
39301
|
const bitType = instance2.getBitType(bt);
|
|
39156
39302
|
const _bitConfig = BITS[bitType];
|
|
@@ -39183,13 +39329,6 @@ var ConfigBuilder = class {
|
|
|
39183
39329
|
for (const b of bitConfigs) {
|
|
39184
39330
|
const resolvedBitConfig = instance2.getBitConfig(b.bitType);
|
|
39185
39331
|
const tags2 = [];
|
|
39186
|
-
const tagEntriesTypeOrder = [
|
|
39187
|
-
BitTagConfigKeyType.tag,
|
|
39188
|
-
BitTagConfigKeyType.property,
|
|
39189
|
-
BitTagConfigKeyType.resource,
|
|
39190
|
-
BitTagConfigKeyType.group,
|
|
39191
|
-
BitTagConfigKeyType.unknown
|
|
39192
|
-
];
|
|
39193
39332
|
const tagEntries = Object.entries(b.tags ?? []).sort((a, b2) => {
|
|
39194
39333
|
const tagA = a[1];
|
|
39195
39334
|
const tagB = b2[1];
|
|
@@ -39221,6 +39360,10 @@ var ConfigBuilder = class {
|
|
|
39221
39360
|
tags2.push(...processTagEntries(tag, []));
|
|
39222
39361
|
}
|
|
39223
39362
|
}
|
|
39363
|
+
let cardRef;
|
|
39364
|
+
if (b.cardSet && CARDSETS[b.cardSet]) {
|
|
39365
|
+
cardRef = normalizeCardKey(b.cardSet);
|
|
39366
|
+
}
|
|
39224
39367
|
const bitJson = {
|
|
39225
39368
|
name: b.bitType,
|
|
39226
39369
|
description: b.description ?? "",
|
|
@@ -39238,7 +39381,8 @@ var ConfigBuilder = class {
|
|
|
39238
39381
|
footerAllowed: resolvedBitConfig.footerAllowed ?? true,
|
|
39239
39382
|
footerRequired: resolvedBitConfig.footerRequired ?? false,
|
|
39240
39383
|
resourceAttachmentAllowed: resolvedBitConfig.resourceAttachmentAllowed ?? true,
|
|
39241
|
-
tags: tags2
|
|
39384
|
+
tags: tags2,
|
|
39385
|
+
...cardRef ? { card: cardRef } : {}
|
|
39242
39386
|
};
|
|
39243
39387
|
const output = import_node_path3.default.join(outputFolderBits, `${b.bitType}.jsonc`);
|
|
39244
39388
|
const str = JSON.stringify(bitJson, null, 2);
|
|
@@ -39248,7 +39392,7 @@ var ConfigBuilder = class {
|
|
|
39248
39392
|
for (const g of groupConfigs2) {
|
|
39249
39393
|
const tags2 = [];
|
|
39250
39394
|
const groupKey = stringUtils.camelToKebab(g.key);
|
|
39251
|
-
const
|
|
39395
|
+
const tagEntriesTypeOrder2 = [
|
|
39252
39396
|
BitTagConfigKeyType.tag,
|
|
39253
39397
|
BitTagConfigKeyType.property,
|
|
39254
39398
|
BitTagConfigKeyType.resource,
|
|
@@ -39257,7 +39401,7 @@ var ConfigBuilder = class {
|
|
|
39257
39401
|
const tagEntries = Object.entries(g.tags ?? []).sort((a, b) => {
|
|
39258
39402
|
const tagA = a[1];
|
|
39259
39403
|
const tagB = b[1];
|
|
39260
|
-
const typeOrder =
|
|
39404
|
+
const typeOrder = tagEntriesTypeOrder2.indexOf(tagA.type) - tagEntriesTypeOrder2.indexOf(tagB.type);
|
|
39261
39405
|
return typeOrder;
|
|
39262
39406
|
});
|
|
39263
39407
|
for (const [_tagKey, tag] of tagEntries) {
|
|
@@ -39305,6 +39449,15 @@ var ConfigBuilder = class {
|
|
|
39305
39449
|
}
|
|
39306
39450
|
};
|
|
39307
39451
|
writeGroupConfigs(groupConfigs);
|
|
39452
|
+
const writeCardConfigs = () => {
|
|
39453
|
+
for (const cardSetKey of Object.keys(CARDSETS)) {
|
|
39454
|
+
const cardJson = serializeCardSet(cardSetKey);
|
|
39455
|
+
if (!cardJson) continue;
|
|
39456
|
+
const output = import_node_path3.default.join(outputFolderCards, `${cardJson.key}.jsonc`);
|
|
39457
|
+
const str = JSON.stringify(cardJson, null, 2);
|
|
39458
|
+
fileWrites.push(import_fs_extra3.default.writeFile(output, str));
|
|
39459
|
+
}
|
|
39460
|
+
};
|
|
39308
39461
|
const writeBitsAsGroupConfigs = (bitsAsGroupConfigs) => {
|
|
39309
39462
|
for (const b of bitsAsGroupConfigs) {
|
|
39310
39463
|
const groupKey = `group-${b.bitType}`;
|
|
@@ -39321,13 +39474,6 @@ var ConfigBuilder = class {
|
|
|
39321
39474
|
});
|
|
39322
39475
|
}
|
|
39323
39476
|
}
|
|
39324
|
-
const tagEntriesTypeOrder = [
|
|
39325
|
-
BitTagConfigKeyType.tag,
|
|
39326
|
-
BitTagConfigKeyType.property,
|
|
39327
|
-
BitTagConfigKeyType.resource,
|
|
39328
|
-
BitTagConfigKeyType.group,
|
|
39329
|
-
BitTagConfigKeyType.unknown
|
|
39330
|
-
];
|
|
39331
39477
|
const tagEntries = Object.entries(b.tags ?? []).sort((a, b2) => {
|
|
39332
39478
|
const tagA = a[1];
|
|
39333
39479
|
const tagB = b2[1];
|
|
@@ -39358,6 +39504,7 @@ var ConfigBuilder = class {
|
|
|
39358
39504
|
}
|
|
39359
39505
|
};
|
|
39360
39506
|
writeBitsAsGroupConfigs(bitGroupConfigs);
|
|
39507
|
+
writeCardConfigs();
|
|
39361
39508
|
Promise.all(fileWrites).then(() => {
|
|
39362
39509
|
const validationErrors = this.validateConfigTree(outputFolder);
|
|
39363
39510
|
if (validationErrors.length > 0) {
|
|
@@ -39383,6 +39530,7 @@ var ConfigBuilder = class {
|
|
|
39383
39530
|
const errors = [];
|
|
39384
39531
|
const outputFolderBits = import_node_path3.default.join(outputFolder, "bits");
|
|
39385
39532
|
const outputFolderGroups = import_node_path3.default.join(outputFolder, "partials");
|
|
39533
|
+
const outputFolderCards = import_node_path3.default.join(outputFolder, "cards");
|
|
39386
39534
|
const availableGroups = /* @__PURE__ */ new Set();
|
|
39387
39535
|
if (import_fs_extra3.default.existsSync(outputFolderGroups)) {
|
|
39388
39536
|
const groupFiles = import_fs_extra3.default.readdirSync(outputFolderGroups).filter((f) => f.endsWith(".jsonc"));
|
|
@@ -39391,16 +39539,22 @@ var ConfigBuilder = class {
|
|
|
39391
39539
|
availableGroups.add(groupName);
|
|
39392
39540
|
}
|
|
39393
39541
|
}
|
|
39542
|
+
const availableCards = /* @__PURE__ */ new Set();
|
|
39543
|
+
const cardFiles = import_fs_extra3.default.existsSync(outputFolderCards) ? import_fs_extra3.default.readdirSync(outputFolderCards).filter((f) => f.endsWith(".jsonc")) : [];
|
|
39544
|
+
for (const file of cardFiles) {
|
|
39545
|
+
const cardName = file.replace(".jsonc", "");
|
|
39546
|
+
availableCards.add(cardName);
|
|
39547
|
+
}
|
|
39394
39548
|
const checkTags = (tags2, filePath, lineOffset) => {
|
|
39395
39549
|
for (let i = 0; i < tags2.length; i++) {
|
|
39396
39550
|
const tag = tags2[i];
|
|
39397
|
-
if (tag
|
|
39551
|
+
if (tag?.type === "group" && tag.key) {
|
|
39398
39552
|
if (!availableGroups.has(tag.key)) {
|
|
39399
39553
|
const line = lineOffset + i + 1;
|
|
39400
39554
|
errors.push(`Missing group reference '${tag.key}' in ${filePath}:${line}`);
|
|
39401
39555
|
}
|
|
39402
39556
|
}
|
|
39403
|
-
if (
|
|
39557
|
+
if (Array.isArray(tag?.tags)) {
|
|
39404
39558
|
checkTags(tag.tags, filePath, lineOffset + i + 1);
|
|
39405
39559
|
}
|
|
39406
39560
|
}
|
|
@@ -39415,6 +39569,27 @@ var ConfigBuilder = class {
|
|
|
39415
39569
|
if (config.tags && Array.isArray(config.tags)) {
|
|
39416
39570
|
checkTags(config.tags, `bits/${file}`, 15);
|
|
39417
39571
|
}
|
|
39572
|
+
if (typeof config.card === "string") {
|
|
39573
|
+
if (!availableCards.has(config.card)) {
|
|
39574
|
+
errors.push(`Missing card file '${config.card}' referenced in bits/${file}`);
|
|
39575
|
+
}
|
|
39576
|
+
} else if (config.card?.sides && Array.isArray(config.card.sides)) {
|
|
39577
|
+
config.card.sides.forEach((side, sideIdx) => {
|
|
39578
|
+
const variants = side.variants;
|
|
39579
|
+
if (Array.isArray(variants)) {
|
|
39580
|
+
variants.forEach((variant, variantIdx) => {
|
|
39581
|
+
const variantTags = variant.tags;
|
|
39582
|
+
if (Array.isArray(variantTags)) {
|
|
39583
|
+
checkTags(
|
|
39584
|
+
variantTags,
|
|
39585
|
+
`bits/${file} (card side ${sideIdx}, variant ${variantIdx})`,
|
|
39586
|
+
15
|
|
39587
|
+
);
|
|
39588
|
+
}
|
|
39589
|
+
});
|
|
39590
|
+
}
|
|
39591
|
+
});
|
|
39592
|
+
}
|
|
39418
39593
|
} catch (err) {
|
|
39419
39594
|
errors.push(`Failed to parse ${file}: ${err}`);
|
|
39420
39595
|
}
|
|
@@ -39435,6 +39610,38 @@ var ConfigBuilder = class {
|
|
|
39435
39610
|
}
|
|
39436
39611
|
}
|
|
39437
39612
|
}
|
|
39613
|
+
if (cardFiles.length > 0) {
|
|
39614
|
+
for (const file of cardFiles) {
|
|
39615
|
+
const filePath = import_node_path3.default.join(outputFolderCards, file);
|
|
39616
|
+
try {
|
|
39617
|
+
const content = import_fs_extra3.default.readFileSync(filePath, "utf-8");
|
|
39618
|
+
const config = JSON.parse(content);
|
|
39619
|
+
const expectedKey = file.replace(".jsonc", "");
|
|
39620
|
+
if (config.key && config.key !== expectedKey) {
|
|
39621
|
+
errors.push(`Card key mismatch in cards/${file}: expected '${expectedKey}'`);
|
|
39622
|
+
}
|
|
39623
|
+
if (Array.isArray(config.sides)) {
|
|
39624
|
+
config.sides.forEach((side, sideIdx) => {
|
|
39625
|
+
const variants = side.variants;
|
|
39626
|
+
if (Array.isArray(variants)) {
|
|
39627
|
+
variants.forEach((variant, variantIdx) => {
|
|
39628
|
+
const variantTags = variant.tags;
|
|
39629
|
+
if (Array.isArray(variantTags)) {
|
|
39630
|
+
checkTags(
|
|
39631
|
+
variantTags,
|
|
39632
|
+
`cards/${file} (side ${sideIdx}, variant ${variantIdx})`,
|
|
39633
|
+
10
|
|
39634
|
+
);
|
|
39635
|
+
}
|
|
39636
|
+
});
|
|
39637
|
+
}
|
|
39638
|
+
});
|
|
39639
|
+
}
|
|
39640
|
+
} catch (err) {
|
|
39641
|
+
errors.push(`Failed to parse cards/${file}: ${err}`);
|
|
39642
|
+
}
|
|
39643
|
+
}
|
|
39644
|
+
}
|
|
39438
39645
|
return errors;
|
|
39439
39646
|
}
|
|
39440
39647
|
// Build flat bit configs
|
|
@@ -39529,6 +39736,11 @@ var ConfigBuilder = class {
|
|
|
39529
39736
|
for (const [_tagKey, tag] of tagEntries) {
|
|
39530
39737
|
tags2.push(...processTagEntries(tag));
|
|
39531
39738
|
}
|
|
39739
|
+
let cardRef;
|
|
39740
|
+
const cardSetKey = b.cardSet?.configKey;
|
|
39741
|
+
if (cardSetKey && CARDSETS[cardSetKey]) {
|
|
39742
|
+
cardRef = normalizeCardKey(cardSetKey);
|
|
39743
|
+
}
|
|
39532
39744
|
const bitJson = {
|
|
39533
39745
|
name: b.bitType,
|
|
39534
39746
|
description: "",
|
|
@@ -39546,7 +39758,8 @@ var ConfigBuilder = class {
|
|
|
39546
39758
|
footerAllowed: b.footerAllowed ?? true,
|
|
39547
39759
|
footerRequired: b.footerRequired ?? false,
|
|
39548
39760
|
resourceAttachmentAllowed: b.resourceAttachmentAllowed ?? true,
|
|
39549
|
-
tags: tags2
|
|
39761
|
+
tags: tags2,
|
|
39762
|
+
...cardRef ? { card: cardRef } : {}
|
|
39550
39763
|
};
|
|
39551
39764
|
const output = import_node_path3.default.join(outputFolderBits, `${b.bitType}.jsonc`);
|
|
39552
39765
|
const str = JSON.stringify(bitJson, null, 2);
|