@gmb/bitmark-parser-generator 5.1.0 → 5.3.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 +120 -6
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +30 -3
- package/dist/browser/esm/index.d.ts +30 -3
- package/dist/browser/esm/index.js +120 -6
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/cli/main.js +347 -74
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +310 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -3
- package/dist/index.d.ts +30 -3
- package/dist/index.js +310 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -270,6 +270,7 @@ var BitType = {
|
|
|
270
270
|
flashcard1: "flashcard-1",
|
|
271
271
|
focusImage: "focus-image",
|
|
272
272
|
footNote: "foot-note",
|
|
273
|
+
formFreeText: "form-free-text",
|
|
273
274
|
formula: "formula",
|
|
274
275
|
gapText: "gap-text",
|
|
275
276
|
gapTextInstructionGrouped: "gap-text-instruction-grouped",
|
|
@@ -282,6 +283,8 @@ var BitType = {
|
|
|
282
283
|
handInFeedbackExpert: "hand-in-feedback-expert",
|
|
283
284
|
handInFeedbackSelf: "hand-in-feedback-self",
|
|
284
285
|
handInFile: "hand-in-file",
|
|
286
|
+
handInFreeText: "hand-in-free-text",
|
|
287
|
+
handInFreeTextExpert: "hand-in-free-text-expert",
|
|
285
288
|
handInLocation: "hand-in-location",
|
|
286
289
|
handInPhoto: "hand-in-photo",
|
|
287
290
|
handInScan: "hand-in-scan",
|
|
@@ -594,6 +597,7 @@ var BitType = {
|
|
|
594
597
|
trueFalse: "true-false",
|
|
595
598
|
trueFalse1: "true-false-1",
|
|
596
599
|
vendorAmcharts5Chart: "vendor-amcharts-5-chart",
|
|
600
|
+
vendorDatadogDashboard: "vendor-datadog-dashboard",
|
|
597
601
|
vendorDatadogDashboardEmbed: "vendor-datadog-dashboard-embed",
|
|
598
602
|
vendorFormbricksEmbed: "vendor-formbricks-embed",
|
|
599
603
|
vendorFormbricksLink: "vendor-formbricks-link",
|
|
@@ -1233,6 +1237,7 @@ var propertyKeys = {
|
|
|
1233
1237
|
property_internalComment: "@internalComment",
|
|
1234
1238
|
property_internalPrintPdf: "@internalPrintPdf",
|
|
1235
1239
|
property_hasPrintRestriction: "@hasPrintRestriction",
|
|
1240
|
+
property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput",
|
|
1236
1241
|
property_isCaseSensitive: "@isCaseSensitive",
|
|
1237
1242
|
property_isInfoOnly: "@isInfoOnly",
|
|
1238
1243
|
property_isPublic: "@isPublic",
|
|
@@ -1259,6 +1264,7 @@ var propertyKeys = {
|
|
|
1259
1264
|
property_listItemIndent: "@listItemIndent",
|
|
1260
1265
|
property_location: "@location",
|
|
1261
1266
|
property_machineTranslated: "@machineTranslated",
|
|
1267
|
+
property_translationOf: "@translationOf",
|
|
1262
1268
|
property_spansPageBreak: "@spansPageBreak",
|
|
1263
1269
|
property_mailingList: "@mailingList",
|
|
1264
1270
|
property_mark: "@mark",
|
|
@@ -1291,6 +1297,7 @@ var propertyKeys = {
|
|
|
1291
1297
|
property_platformMargin: "@platformMargin",
|
|
1292
1298
|
property_platformBorderRadius: "@platformBorderRadius",
|
|
1293
1299
|
property_platformSelectionBorderRadius: "@platformSelectionBorderRadius",
|
|
1300
|
+
property_platformLogoMaxHeight: "@platformLogoMaxHeight",
|
|
1294
1301
|
property_platformNeedsShadow: "@platformNeedsShadow",
|
|
1295
1302
|
property_platformSeparatorColor: "@platformSeparatorColor",
|
|
1296
1303
|
property_platformTextSelectionColor: "@platformTextSelectionColor",
|
|
@@ -2746,6 +2753,11 @@ var GROUPS = {
|
|
|
2746
2753
|
description: "If true, the bit is machine-translated",
|
|
2747
2754
|
format: TagFormat.plainText
|
|
2748
2755
|
},
|
|
2756
|
+
{
|
|
2757
|
+
key: ConfigKey.property_translationOf,
|
|
2758
|
+
description: "Translation source reference",
|
|
2759
|
+
format: TagFormat.plainText
|
|
2760
|
+
},
|
|
2749
2761
|
{
|
|
2750
2762
|
key: ConfigKey.property_spansPageBreak,
|
|
2751
2763
|
description: "If true, the bit spans a page break",
|
|
@@ -3396,6 +3408,12 @@ var GROUPS = {
|
|
|
3396
3408
|
description: "If true, the book has print restrictions",
|
|
3397
3409
|
format: TagFormat.boolean,
|
|
3398
3410
|
defaultValue: "true"
|
|
3411
|
+
},
|
|
3412
|
+
{
|
|
3413
|
+
key: ConfigKey.property_enforceUpdateOverUserInput,
|
|
3414
|
+
description: "If true, prioritize new content over legacy content from the instance API",
|
|
3415
|
+
format: TagFormat.boolean,
|
|
3416
|
+
defaultValue: "false"
|
|
3399
3417
|
}
|
|
3400
3418
|
]
|
|
3401
3419
|
},
|
|
@@ -8722,6 +8740,11 @@ var BITS = {
|
|
|
8722
8740
|
],
|
|
8723
8741
|
maxCount: 1
|
|
8724
8742
|
},
|
|
8743
|
+
{
|
|
8744
|
+
key: ConfigKey.property_platformLogoMaxHeight,
|
|
8745
|
+
description: "Maximum height for the platform logo",
|
|
8746
|
+
format: TagFormat.number
|
|
8747
|
+
},
|
|
8725
8748
|
{
|
|
8726
8749
|
key: ConfigKey.group_platformStylesCommon,
|
|
8727
8750
|
description: "Common platform styles"
|
|
@@ -9416,6 +9439,11 @@ var BITS = {
|
|
|
9416
9439
|
baseBitType: BitType._standard,
|
|
9417
9440
|
description: "Footnote bit, used to create footnotes in articles or books"
|
|
9418
9441
|
},
|
|
9442
|
+
[BitType.formFreeText]: {
|
|
9443
|
+
since: "5.3.0",
|
|
9444
|
+
baseBitType: BitType.interview,
|
|
9445
|
+
description: "Form free text bit, used to create free text forms in articles or books"
|
|
9446
|
+
},
|
|
9419
9447
|
[BitType.groupBorn]: {
|
|
9420
9448
|
since: "1.3.0",
|
|
9421
9449
|
baseBitType: BitType._standard,
|
|
@@ -9475,6 +9503,16 @@ var BITS = {
|
|
|
9475
9503
|
}
|
|
9476
9504
|
]
|
|
9477
9505
|
},
|
|
9506
|
+
[BitType.handInFreeText]: {
|
|
9507
|
+
since: "5.3.0",
|
|
9508
|
+
baseBitType: BitType.interview,
|
|
9509
|
+
description: "Hand in free text bit, used to create free text submission sections in articles or books"
|
|
9510
|
+
},
|
|
9511
|
+
[BitType.handInFreeTextExpert]: {
|
|
9512
|
+
since: "5.3.0",
|
|
9513
|
+
baseBitType: BitType.interview,
|
|
9514
|
+
description: "Hand in free text expert bit, used to create free text expert submission sections in articles or books"
|
|
9515
|
+
},
|
|
9478
9516
|
[BitType.handInLocation]: {
|
|
9479
9517
|
since: "1.5.15",
|
|
9480
9518
|
baseBitType: BitType._standard,
|
|
@@ -9584,6 +9622,11 @@ var BITS = {
|
|
|
9584
9622
|
description: "AmCharts 5 chart bit, used to embed AmCharts 5 charts in articles or books",
|
|
9585
9623
|
textFormatDefault: TextFormat.json
|
|
9586
9624
|
},
|
|
9625
|
+
[BitType.vendorDatadogDashboard]: {
|
|
9626
|
+
since: "5.2.0",
|
|
9627
|
+
baseBitType: BitType.nonProductionPrototypeIframe,
|
|
9628
|
+
description: "A Datadog dashboard bit, used to embed Datadog dashboards"
|
|
9629
|
+
},
|
|
9587
9630
|
[BitType.vendorDatadogDashboardEmbed]: {
|
|
9588
9631
|
since: "3.12.0",
|
|
9589
9632
|
baseBitType: BitType.code,
|
|
@@ -10213,7 +10256,7 @@ var instance2 = new Config();
|
|
|
10213
10256
|
// src/generated/package_info.ts
|
|
10214
10257
|
var PACKAGE_INFO = {
|
|
10215
10258
|
"name": "@gmb/bitmark-parser-generator",
|
|
10216
|
-
"version": "5.
|
|
10259
|
+
"version": "5.3.0",
|
|
10217
10260
|
"author": "Get More Brain Ltd",
|
|
10218
10261
|
"license": "ISC",
|
|
10219
10262
|
"description": "A bitmark parser and generator using Peggy.js"
|
|
@@ -10834,6 +10877,8 @@ var NodeType = {
|
|
|
10834
10877
|
internalPrintPdfValue: "internalPrintPdfValue",
|
|
10835
10878
|
hasPrintRestriction: "hasPrintRestriction",
|
|
10836
10879
|
hasPrintRestrictionValue: "hasPrintRestrictionValue",
|
|
10880
|
+
enforceUpdateOverUserInput: "enforceUpdateOverUserInput",
|
|
10881
|
+
enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue",
|
|
10837
10882
|
isCaseSensitive: "isCaseSensitive",
|
|
10838
10883
|
isCommented: "isCommented",
|
|
10839
10884
|
isCorrect: "isCorrect",
|
|
@@ -10900,6 +10945,8 @@ var NodeType = {
|
|
|
10900
10945
|
locationValue: "locationValue",
|
|
10901
10946
|
machineTranslated: "machineTranslated",
|
|
10902
10947
|
machineTranslatedValue: "machineTranslatedValue",
|
|
10948
|
+
translationOf: "translationOf",
|
|
10949
|
+
translationOfValue: "translationOfValue",
|
|
10903
10950
|
spansPageBreak: "spansPageBreak",
|
|
10904
10951
|
spansPageBreakValue: "spansPageBreakValue",
|
|
10905
10952
|
mailingList: "mailingList",
|
|
@@ -10951,6 +10998,8 @@ var NodeType = {
|
|
|
10951
10998
|
platformIconValue: "platformIconValue",
|
|
10952
10999
|
platformLogo: "platformLogo",
|
|
10953
11000
|
platformLogoValue: "platformLogoValue",
|
|
11001
|
+
platformLogoMaxHeight: "platformLogoMaxHeight",
|
|
11002
|
+
platformLogoMaxHeightValue: "platformLogoMaxHeightValue",
|
|
10954
11003
|
platformPrimaryColor: "platformPrimaryColor",
|
|
10955
11004
|
platformPrimaryColorValue: "platformPrimaryColorValue",
|
|
10956
11005
|
platformSecondaryColor: "platformSecondaryColor",
|
|
@@ -12019,7 +12068,7 @@ var Stage = {
|
|
|
12019
12068
|
between: "between",
|
|
12020
12069
|
exit: "exit"
|
|
12021
12070
|
};
|
|
12022
|
-
var TextGenerator = class extends AstWalkerGenerator {
|
|
12071
|
+
var TextGenerator = class _TextGenerator extends AstWalkerGenerator {
|
|
12023
12072
|
/**
|
|
12024
12073
|
* Generate text from a bitmark text AST
|
|
12025
12074
|
*
|
|
@@ -12031,6 +12080,7 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12031
12080
|
__publicField(this, "ast", new Ast());
|
|
12032
12081
|
__publicField(this, "bitmarkVersion");
|
|
12033
12082
|
__publicField(this, "options");
|
|
12083
|
+
__publicField(this, "internalTextGenerator", null);
|
|
12034
12084
|
// State
|
|
12035
12085
|
__publicField(this, "generateOptions", {});
|
|
12036
12086
|
__publicField(this, "textFormat", TextFormat.bitmarkText);
|
|
@@ -12046,6 +12096,7 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12046
12096
|
__publicField(this, "exitedCodeBlock", false);
|
|
12047
12097
|
__publicField(this, "inBulletList", false);
|
|
12048
12098
|
__publicField(this, "inInline", false);
|
|
12099
|
+
__publicField(this, "markDepth", 0);
|
|
12049
12100
|
__publicField(this, "textDepth", 0);
|
|
12050
12101
|
__publicField(this, "placeholderIndex", 0);
|
|
12051
12102
|
__publicField(this, "placeholders", {});
|
|
@@ -12070,6 +12121,13 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12070
12121
|
this.between = this.between.bind(this);
|
|
12071
12122
|
this.exit = this.exit.bind(this);
|
|
12072
12123
|
this.leaf = this.leaf.bind(this);
|
|
12124
|
+
if (!this.options.isInternal) {
|
|
12125
|
+
this.internalTextGenerator = new _TextGenerator(bitmarkVersion, {
|
|
12126
|
+
...this.options,
|
|
12127
|
+
writeCallback: void 0,
|
|
12128
|
+
isInternal: true
|
|
12129
|
+
});
|
|
12130
|
+
}
|
|
12073
12131
|
}
|
|
12074
12132
|
/**
|
|
12075
12133
|
* Generate text from a bitmark text AST
|
|
@@ -12126,6 +12184,7 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12126
12184
|
this.exitedCodeBlock = false;
|
|
12127
12185
|
this.inBulletList = false;
|
|
12128
12186
|
this.inInline = false;
|
|
12187
|
+
this.markDepth = 0;
|
|
12129
12188
|
this.textDepth = 0;
|
|
12130
12189
|
this.placeholderIndex = 0;
|
|
12131
12190
|
this.placeholders = {};
|
|
@@ -12173,8 +12232,16 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12173
12232
|
exit_contentValueValue(node, route) {
|
|
12174
12233
|
return this.handleExitNode(node.value, route);
|
|
12175
12234
|
}
|
|
12235
|
+
// * -> marks
|
|
12236
|
+
enter_marks(_node, _route) {
|
|
12237
|
+
this.markDepth++;
|
|
12238
|
+
}
|
|
12239
|
+
exit_marks(_node, _route) {
|
|
12240
|
+
this.markDepth--;
|
|
12241
|
+
}
|
|
12176
12242
|
// END NODE HANDLERS
|
|
12177
12243
|
handleEnterNode(node, route) {
|
|
12244
|
+
if (this.markDepth > 0) return;
|
|
12178
12245
|
this.handleEnterNodePreTextCheck(node, route);
|
|
12179
12246
|
this.handleIndent(node);
|
|
12180
12247
|
switch (node.type) {
|
|
@@ -12185,7 +12252,7 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12185
12252
|
case TextNodeType.hardBreak:
|
|
12186
12253
|
this.writeHardBreak(node);
|
|
12187
12254
|
break;
|
|
12188
|
-
case TextNodeType.text:
|
|
12255
|
+
case TextNodeType.text: {
|
|
12189
12256
|
this.writeMarks(node, Stage.enter);
|
|
12190
12257
|
this.writeText(node);
|
|
12191
12258
|
this.writeMarks(node, Stage.between);
|
|
@@ -12194,6 +12261,7 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12194
12261
|
}
|
|
12195
12262
|
this.textDepth++;
|
|
12196
12263
|
break;
|
|
12264
|
+
}
|
|
12197
12265
|
case TextNodeType.heading:
|
|
12198
12266
|
this.writeHeading(node);
|
|
12199
12267
|
this.inHeading = true;
|
|
@@ -12244,6 +12312,7 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12244
12312
|
}
|
|
12245
12313
|
}
|
|
12246
12314
|
handleExitNode(node, _route) {
|
|
12315
|
+
if (this.markDepth > 0) return;
|
|
12247
12316
|
switch (node.type) {
|
|
12248
12317
|
case TextNodeType.text:
|
|
12249
12318
|
this.textDepth--;
|
|
@@ -12550,7 +12619,7 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12550
12619
|
*/
|
|
12551
12620
|
writeMarks(node, stage) {
|
|
12552
12621
|
if (node.marks) {
|
|
12553
|
-
const forceSingleMark = !!(this.inInline || this.inHeading);
|
|
12622
|
+
const forceSingleMark = this.generateOptions.forceInline || !!(this.inInline || this.inHeading);
|
|
12554
12623
|
this.thisNodeIsPreText = false;
|
|
12555
12624
|
const emptyMarks = node.marks.length === 0;
|
|
12556
12625
|
if (emptyMarks) {
|
|
@@ -12781,13 +12850,33 @@ var TextGenerator = class extends AstWalkerGenerator {
|
|
|
12781
12850
|
s += `|provider:${provider}`;
|
|
12782
12851
|
this.write(s);
|
|
12783
12852
|
}
|
|
12784
|
-
writeFootnoteMark(
|
|
12853
|
+
writeFootnoteMark(mark) {
|
|
12785
12854
|
const s = `footnote:`;
|
|
12786
12855
|
this.write(s);
|
|
12856
|
+
const text = this.internalTextGenerator?.generateSync(
|
|
12857
|
+
mark.attrs?.content,
|
|
12858
|
+
this.textFormat,
|
|
12859
|
+
this.textLocation,
|
|
12860
|
+
{
|
|
12861
|
+
...this.generateOptions,
|
|
12862
|
+
forceInline: true
|
|
12863
|
+
}
|
|
12864
|
+
) ?? "";
|
|
12865
|
+
this.write(text);
|
|
12787
12866
|
}
|
|
12788
|
-
writeFootnoteStarMark(
|
|
12867
|
+
writeFootnoteStarMark(mark) {
|
|
12789
12868
|
const s = `footnote*:`;
|
|
12790
12869
|
this.write(s);
|
|
12870
|
+
const text = this.internalTextGenerator?.generateSync(
|
|
12871
|
+
mark.attrs?.content,
|
|
12872
|
+
this.textFormat,
|
|
12873
|
+
this.textLocation,
|
|
12874
|
+
{
|
|
12875
|
+
...this.generateOptions,
|
|
12876
|
+
forceInline: true
|
|
12877
|
+
}
|
|
12878
|
+
) ?? "";
|
|
12879
|
+
this.write(text);
|
|
12791
12880
|
}
|
|
12792
12881
|
writeSymbolMark(mark) {
|
|
12793
12882
|
if (mark.attrs == null) return;
|
|
@@ -23944,6 +24033,12 @@ var Builder = class extends BaseBuilder {
|
|
|
23944
24033
|
data.machineTranslated,
|
|
23945
24034
|
options
|
|
23946
24035
|
),
|
|
24036
|
+
translationOf: this.toAstProperty(
|
|
24037
|
+
bitType,
|
|
24038
|
+
ConfigKey.property_translationOf,
|
|
24039
|
+
data.translationOf,
|
|
24040
|
+
options
|
|
24041
|
+
),
|
|
23947
24042
|
spansPageBreak: this.toAstProperty(
|
|
23948
24043
|
bitType,
|
|
23949
24044
|
ConfigKey.property_spansPageBreak,
|
|
@@ -24660,6 +24755,12 @@ var Builder = class extends BaseBuilder {
|
|
|
24660
24755
|
data.hasPrintRestriction,
|
|
24661
24756
|
options
|
|
24662
24757
|
),
|
|
24758
|
+
enforceUpdateOverUserInput: this.toAstProperty(
|
|
24759
|
+
bitType,
|
|
24760
|
+
ConfigKey.property_enforceUpdateOverUserInput,
|
|
24761
|
+
data.enforceUpdateOverUserInput,
|
|
24762
|
+
options
|
|
24763
|
+
),
|
|
24663
24764
|
tocResource: this.toAstProperty(
|
|
24664
24765
|
bitType,
|
|
24665
24766
|
ConfigKey.property_tocResource,
|
|
@@ -24687,6 +24788,12 @@ var Builder = class extends BaseBuilder {
|
|
|
24687
24788
|
),
|
|
24688
24789
|
platformIcon: this.toImageResource(context, data.platformIcon),
|
|
24689
24790
|
platformLogo: this.toImageResource(context, data.platformLogo),
|
|
24791
|
+
platformLogoMaxHeight: this.toAstProperty(
|
|
24792
|
+
bitType,
|
|
24793
|
+
ConfigKey.property_platformLogoMaxHeight,
|
|
24794
|
+
data.platformLogoMaxHeight,
|
|
24795
|
+
options
|
|
24796
|
+
),
|
|
24690
24797
|
platformPrimaryColor: this.toAstProperty(
|
|
24691
24798
|
bitType,
|
|
24692
24799
|
ConfigKey.property_platformPrimaryColor,
|
|
@@ -30360,6 +30467,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
|
|
|
30360
30467
|
if (instance2.isOfBitType(bitType, BitType.book)) {
|
|
30361
30468
|
if (bitJson.maxTocChapterLevel == null) bitJson.maxTocChapterLevel = -1;
|
|
30362
30469
|
if (bitJson.hasPrintRestriction == null) bitJson.hasPrintRestriction = true;
|
|
30470
|
+
if (bitJson.enforceUpdateOverUserInput == null) bitJson.enforceUpdateOverUserInput = false;
|
|
30363
30471
|
if (bitJson.hasMarkAsDone == null) bitJson.hasMarkAsDone = false;
|
|
30364
30472
|
if (bitJson.processHandIn == null) bitJson.processHandIn = false;
|
|
30365
30473
|
if (bitJson.isPublic == null) bitJson.isPublic = false;
|
|
@@ -30440,6 +30548,9 @@ var JsonGenerator = class extends AstWalkerGenerator {
|
|
|
30440
30548
|
if (instance2.isOfBitType(bitType, BitType.platformBrandTarget)) {
|
|
30441
30549
|
if (bitJson.platformBrandTarget == null) bitJson.platformBrandTarget = "none";
|
|
30442
30550
|
}
|
|
30551
|
+
if (instance2.isOfBitType(bitType, BitType.platformHeader)) {
|
|
30552
|
+
if (bitJson.platformLogoMaxHeight == null) bitJson.platformLogoMaxHeight = 40;
|
|
30553
|
+
}
|
|
30443
30554
|
if (isTopLevelExample) {
|
|
30444
30555
|
if (bitJson.isExample == null) bitJson.isExample = false;
|
|
30445
30556
|
} else {
|
|
@@ -32727,6 +32838,9 @@ function parseFeedback(_context, _bitType, cardSet) {
|
|
|
32727
32838
|
const choice = {
|
|
32728
32839
|
choice: tfTags.choice,
|
|
32729
32840
|
requireReason: tfTags.isCorrect,
|
|
32841
|
+
item: tfTags.item,
|
|
32842
|
+
lead: tfTags.lead,
|
|
32843
|
+
instruction: tfTags.instruction,
|
|
32730
32844
|
__isDefaultExample,
|
|
32731
32845
|
example
|
|
32732
32846
|
};
|
|
@@ -38827,8 +38941,20 @@ var ConfigBuilder = class {
|
|
|
38827
38941
|
this.buildFlat(opts);
|
|
38828
38942
|
const bitConfigs = [];
|
|
38829
38943
|
const groupConfigs = [];
|
|
38830
|
-
const bitGroupConfigKeys =
|
|
38944
|
+
const bitGroupConfigKeys = /* @__PURE__ */ new Set();
|
|
38831
38945
|
const bitGroupConfigs = [];
|
|
38946
|
+
for (const bt of Enum22(BitType).values()) {
|
|
38947
|
+
const bitType = instance2.getBitType(bt);
|
|
38948
|
+
const _bitConfig = BITS[bitType];
|
|
38949
|
+
if (_bitConfig?.baseBitType) {
|
|
38950
|
+
let currentBitType = _bitConfig.baseBitType;
|
|
38951
|
+
while (currentBitType) {
|
|
38952
|
+
bitGroupConfigKeys.add(currentBitType);
|
|
38953
|
+
const parentConfig = BITS[currentBitType];
|
|
38954
|
+
currentBitType = parentConfig?.baseBitType;
|
|
38955
|
+
}
|
|
38956
|
+
}
|
|
38957
|
+
}
|
|
38832
38958
|
for (const bt of Enum22(BitType).values()) {
|
|
38833
38959
|
const bitType = instance2.getBitType(bt);
|
|
38834
38960
|
const _bitConfig = BITS[bitType];
|
|
@@ -38851,7 +38977,22 @@ var ConfigBuilder = class {
|
|
|
38851
38977
|
const outputFolderGroups = path3.join(outputFolder, "partials");
|
|
38852
38978
|
fs3.ensureDirSync(outputFolderBits);
|
|
38853
38979
|
fs3.ensureDirSync(outputFolderGroups);
|
|
38980
|
+
const bitsFiles = fs3.readdirSync(outputFolderBits).filter((f) => f.endsWith(".jsonc"));
|
|
38981
|
+
for (const file of bitsFiles) {
|
|
38982
|
+
fs3.removeSync(path3.join(outputFolderBits, file));
|
|
38983
|
+
}
|
|
38984
|
+
const partialsFiles = fs3.readdirSync(outputFolderGroups).filter((f) => f.endsWith(".jsonc"));
|
|
38985
|
+
for (const file of partialsFiles) {
|
|
38986
|
+
fs3.removeSync(path3.join(outputFolderGroups, file));
|
|
38987
|
+
}
|
|
38854
38988
|
const fileWrites = [];
|
|
38989
|
+
const resolveGroupReferences = (groupKey) => {
|
|
38990
|
+
if (squashedGroups.has(groupKey)) {
|
|
38991
|
+
const replacements = squashedGroups.get(groupKey);
|
|
38992
|
+
return replacements.flatMap((r) => resolveGroupReferences(r));
|
|
38993
|
+
}
|
|
38994
|
+
return [groupKey];
|
|
38995
|
+
};
|
|
38855
38996
|
const keyToJsonKey = (key, tagNameChain) => {
|
|
38856
38997
|
let jsonKey = key;
|
|
38857
38998
|
if (key === "%") {
|
|
@@ -38915,10 +39056,13 @@ var ConfigBuilder = class {
|
|
|
38915
39056
|
if (k.startsWith("group_")) k = k.substring(6);
|
|
38916
39057
|
k = /*'_' +*/
|
|
38917
39058
|
stringUtils.camelToKebab(k);
|
|
38918
|
-
|
|
38919
|
-
|
|
38920
|
-
|
|
38921
|
-
|
|
39059
|
+
const resolvedGroups = resolveGroupReferences(k);
|
|
39060
|
+
for (const groupKey of resolvedGroups) {
|
|
39061
|
+
tags2.push({
|
|
39062
|
+
type: "group",
|
|
39063
|
+
key: groupKey
|
|
39064
|
+
});
|
|
39065
|
+
}
|
|
38922
39066
|
return tags2;
|
|
38923
39067
|
}
|
|
38924
39068
|
if (Array.isArray(tag.chain) && tag.chain.length > 0) {
|
|
@@ -38946,7 +39090,37 @@ var ConfigBuilder = class {
|
|
|
38946
39090
|
tags2.push(t);
|
|
38947
39091
|
return tags2;
|
|
38948
39092
|
};
|
|
39093
|
+
for (const bt of bitGroupConfigKeys) {
|
|
39094
|
+
const bitType = instance2.getBitType(bt);
|
|
39095
|
+
const _bitConfig = BITS[bitType];
|
|
39096
|
+
if (_bitConfig) {
|
|
39097
|
+
_bitConfig.bitType = bitType;
|
|
39098
|
+
if (!bitGroupConfigs.some((c) => c.bitType === bitType)) {
|
|
39099
|
+
bitGroupConfigs.push(_bitConfig);
|
|
39100
|
+
}
|
|
39101
|
+
}
|
|
39102
|
+
}
|
|
39103
|
+
const squashedGroups = /* @__PURE__ */ new Map();
|
|
39104
|
+
for (const b of bitGroupConfigs) {
|
|
39105
|
+
const groupKey = `group-${b.bitType}`;
|
|
39106
|
+
const processedTags = [];
|
|
39107
|
+
for (const [, tag] of Object.entries(b.tags ?? [])) {
|
|
39108
|
+
processedTags.push(...processTagEntries(tag, []));
|
|
39109
|
+
}
|
|
39110
|
+
const allAreGroups = processedTags.every((t) => t.type === "group");
|
|
39111
|
+
if (allAreGroups && processedTags.length > 0) {
|
|
39112
|
+
const replacements = [];
|
|
39113
|
+
if (b.baseBitType) {
|
|
39114
|
+
replacements.push(`group-${b.baseBitType}`);
|
|
39115
|
+
}
|
|
39116
|
+
for (const t of processedTags) {
|
|
39117
|
+
replacements.push(t.key);
|
|
39118
|
+
}
|
|
39119
|
+
squashedGroups.set(groupKey, replacements);
|
|
39120
|
+
}
|
|
39121
|
+
}
|
|
38949
39122
|
for (const b of bitConfigs) {
|
|
39123
|
+
const resolvedBitConfig = instance2.getBitConfig(b.bitType);
|
|
38950
39124
|
const tags2 = [];
|
|
38951
39125
|
const tagEntriesTypeOrder = [
|
|
38952
39126
|
BitTagConfigKeyType.tag,
|
|
@@ -38963,47 +39137,52 @@ var ConfigBuilder = class {
|
|
|
38963
39137
|
const typeOrder = tagEntriesTypeOrder.indexOf(typeA) - tagEntriesTypeOrder.indexOf(typeB);
|
|
38964
39138
|
return typeOrder;
|
|
38965
39139
|
});
|
|
38966
|
-
|
|
38967
|
-
|
|
38968
|
-
|
|
38969
|
-
|
|
38970
|
-
|
|
38971
|
-
|
|
38972
|
-
|
|
38973
|
-
|
|
38974
|
-
|
|
39140
|
+
const isInheritedFrom = bitGroupConfigKeys.has(b.bitType);
|
|
39141
|
+
if (isInheritedFrom) {
|
|
39142
|
+
const resolvedGroups = resolveGroupReferences(`group-${b.bitType}`);
|
|
39143
|
+
for (const groupKey of resolvedGroups) {
|
|
39144
|
+
tags2.push({
|
|
39145
|
+
type: "group",
|
|
39146
|
+
key: groupKey
|
|
39147
|
+
});
|
|
39148
|
+
}
|
|
39149
|
+
} else {
|
|
39150
|
+
if (b.baseBitType) {
|
|
39151
|
+
const resolvedGroups = resolveGroupReferences(`group-${b.baseBitType}`);
|
|
39152
|
+
for (const groupKey of resolvedGroups) {
|
|
39153
|
+
tags2.push({
|
|
39154
|
+
type: "group",
|
|
39155
|
+
key: groupKey
|
|
39156
|
+
});
|
|
39157
|
+
}
|
|
39158
|
+
}
|
|
39159
|
+
for (const [_tagKey, tag] of tagEntries) {
|
|
39160
|
+
tags2.push(...processTagEntries(tag, []));
|
|
39161
|
+
}
|
|
38975
39162
|
}
|
|
38976
39163
|
const bitJson = {
|
|
38977
39164
|
name: b.bitType,
|
|
38978
39165
|
description: b.description ?? "",
|
|
38979
|
-
since:
|
|
38980
|
-
deprecated:
|
|
39166
|
+
since: resolvedBitConfig.since,
|
|
39167
|
+
deprecated: resolvedBitConfig.deprecated,
|
|
38981
39168
|
history: [
|
|
38982
39169
|
{
|
|
38983
|
-
version:
|
|
39170
|
+
version: resolvedBitConfig.since,
|
|
38984
39171
|
changes: ["Initial version"]
|
|
38985
39172
|
}
|
|
38986
39173
|
],
|
|
38987
|
-
format:
|
|
38988
|
-
bodyAllowed:
|
|
38989
|
-
bodyRequired:
|
|
38990
|
-
footerAllowed:
|
|
38991
|
-
footerRequired:
|
|
38992
|
-
resourceAttachmentAllowed:
|
|
39174
|
+
format: resolvedBitConfig.textFormatDefault ?? "bitmark--",
|
|
39175
|
+
bodyAllowed: resolvedBitConfig.bodyAllowed ?? true,
|
|
39176
|
+
bodyRequired: resolvedBitConfig.bodyRequired ?? false,
|
|
39177
|
+
footerAllowed: resolvedBitConfig.footerAllowed ?? true,
|
|
39178
|
+
footerRequired: resolvedBitConfig.footerRequired ?? false,
|
|
39179
|
+
resourceAttachmentAllowed: resolvedBitConfig.resourceAttachmentAllowed ?? true,
|
|
38993
39180
|
tags: tags2
|
|
38994
39181
|
};
|
|
38995
39182
|
const output = path3.join(outputFolderBits, `${b.bitType}.jsonc`);
|
|
38996
39183
|
const str = JSON.stringify(bitJson, null, 2);
|
|
38997
39184
|
fileWrites.push(fs3.writeFile(output, str));
|
|
38998
39185
|
}
|
|
38999
|
-
for (const bt of bitGroupConfigKeys) {
|
|
39000
|
-
const bitType = instance2.getBitType(bt);
|
|
39001
|
-
const _bitConfig = BITS[bitType];
|
|
39002
|
-
if (_bitConfig) {
|
|
39003
|
-
_bitConfig.bitType = bitType;
|
|
39004
|
-
bitGroupConfigs.push(_bitConfig);
|
|
39005
|
-
}
|
|
39006
|
-
}
|
|
39007
39186
|
const writeGroupConfigs = (groupConfigs2) => {
|
|
39008
39187
|
for (const g of groupConfigs2) {
|
|
39009
39188
|
const tags2 = [];
|
|
@@ -39068,7 +39247,19 @@ var ConfigBuilder = class {
|
|
|
39068
39247
|
const writeBitsAsGroupConfigs = (bitsAsGroupConfigs) => {
|
|
39069
39248
|
for (const b of bitsAsGroupConfigs) {
|
|
39070
39249
|
const groupKey = `group-${b.bitType}`;
|
|
39250
|
+
if (squashedGroups.has(groupKey)) {
|
|
39251
|
+
continue;
|
|
39252
|
+
}
|
|
39071
39253
|
const tags2 = [];
|
|
39254
|
+
if (b.baseBitType) {
|
|
39255
|
+
const resolvedGroups = resolveGroupReferences(`group-${b.baseBitType}`);
|
|
39256
|
+
for (const gk of resolvedGroups) {
|
|
39257
|
+
tags2.push({
|
|
39258
|
+
type: "group",
|
|
39259
|
+
key: gk
|
|
39260
|
+
});
|
|
39261
|
+
}
|
|
39262
|
+
}
|
|
39072
39263
|
const tagEntriesTypeOrder = [
|
|
39073
39264
|
BitTagConfigKeyType.tag,
|
|
39074
39265
|
BitTagConfigKeyType.property,
|
|
@@ -39106,6 +39297,84 @@ var ConfigBuilder = class {
|
|
|
39106
39297
|
}
|
|
39107
39298
|
};
|
|
39108
39299
|
writeBitsAsGroupConfigs(bitGroupConfigs);
|
|
39300
|
+
Promise.all(fileWrites).then(() => {
|
|
39301
|
+
const validationErrors = this.validateConfigTree(outputFolder);
|
|
39302
|
+
if (validationErrors.length > 0) {
|
|
39303
|
+
console.error("\n\u26A0\uFE0F Config tree validation errors:");
|
|
39304
|
+
for (const error of validationErrors) {
|
|
39305
|
+
console.error(` - ${error}`);
|
|
39306
|
+
}
|
|
39307
|
+
throw new Error(`Config tree validation failed with ${validationErrors.length} error(s)`);
|
|
39308
|
+
} else {
|
|
39309
|
+
console.log("\u2705 Config tree validation passed");
|
|
39310
|
+
}
|
|
39311
|
+
}).catch((err) => {
|
|
39312
|
+
console.error("Error during config build or validation:", err);
|
|
39313
|
+
throw err;
|
|
39314
|
+
});
|
|
39315
|
+
}
|
|
39316
|
+
/**
|
|
39317
|
+
* Validate the config tree for missing group references
|
|
39318
|
+
* @param outputFolder - The folder containing the config files
|
|
39319
|
+
* @returns Array of validation errors, empty if valid
|
|
39320
|
+
*/
|
|
39321
|
+
validateConfigTree(outputFolder) {
|
|
39322
|
+
const errors = [];
|
|
39323
|
+
const outputFolderBits = path3.join(outputFolder, "bits");
|
|
39324
|
+
const outputFolderGroups = path3.join(outputFolder, "partials");
|
|
39325
|
+
const availableGroups = /* @__PURE__ */ new Set();
|
|
39326
|
+
if (fs3.existsSync(outputFolderGroups)) {
|
|
39327
|
+
const groupFiles = fs3.readdirSync(outputFolderGroups).filter((f) => f.endsWith(".jsonc"));
|
|
39328
|
+
for (const file of groupFiles) {
|
|
39329
|
+
const groupName = file.replace(".jsonc", "");
|
|
39330
|
+
availableGroups.add(groupName);
|
|
39331
|
+
}
|
|
39332
|
+
}
|
|
39333
|
+
const checkTags = (tags2, filePath, lineOffset) => {
|
|
39334
|
+
for (let i = 0; i < tags2.length; i++) {
|
|
39335
|
+
const tag = tags2[i];
|
|
39336
|
+
if (tag.type === "group") {
|
|
39337
|
+
if (!availableGroups.has(tag.key)) {
|
|
39338
|
+
const line = lineOffset + i + 1;
|
|
39339
|
+
errors.push(`Missing group reference '${tag.key}' in ${filePath}:${line}`);
|
|
39340
|
+
}
|
|
39341
|
+
}
|
|
39342
|
+
if (tag.tags && Array.isArray(tag.tags)) {
|
|
39343
|
+
checkTags(tag.tags, filePath, lineOffset + i + 1);
|
|
39344
|
+
}
|
|
39345
|
+
}
|
|
39346
|
+
};
|
|
39347
|
+
if (fs3.existsSync(outputFolderBits)) {
|
|
39348
|
+
const bitFiles = fs3.readdirSync(outputFolderBits).filter((f) => f.endsWith(".jsonc"));
|
|
39349
|
+
for (const file of bitFiles) {
|
|
39350
|
+
const filePath = path3.join(outputFolderBits, file);
|
|
39351
|
+
try {
|
|
39352
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
39353
|
+
const config = JSON.parse(content);
|
|
39354
|
+
if (config.tags && Array.isArray(config.tags)) {
|
|
39355
|
+
checkTags(config.tags, `bits/${file}`, 15);
|
|
39356
|
+
}
|
|
39357
|
+
} catch (err) {
|
|
39358
|
+
errors.push(`Failed to parse ${file}: ${err}`);
|
|
39359
|
+
}
|
|
39360
|
+
}
|
|
39361
|
+
}
|
|
39362
|
+
if (fs3.existsSync(outputFolderGroups)) {
|
|
39363
|
+
const groupFiles = fs3.readdirSync(outputFolderGroups).filter((f) => f.endsWith(".jsonc"));
|
|
39364
|
+
for (const file of groupFiles) {
|
|
39365
|
+
const filePath = path3.join(outputFolderGroups, file);
|
|
39366
|
+
try {
|
|
39367
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
39368
|
+
const config = JSON.parse(content);
|
|
39369
|
+
if (config.tags && Array.isArray(config.tags)) {
|
|
39370
|
+
checkTags(config.tags, `partials/${file}`, 15);
|
|
39371
|
+
}
|
|
39372
|
+
} catch (err) {
|
|
39373
|
+
errors.push(`Failed to parse ${file}: ${err}`);
|
|
39374
|
+
}
|
|
39375
|
+
}
|
|
39376
|
+
}
|
|
39377
|
+
return errors;
|
|
39109
39378
|
}
|
|
39110
39379
|
// Build flat bit configs
|
|
39111
39380
|
buildFlat(options) {
|
|
@@ -39119,6 +39388,10 @@ var ConfigBuilder = class {
|
|
|
39119
39388
|
const outputFolder = opts.outputDir ?? "assets/config";
|
|
39120
39389
|
const outputFolderBits = path3.join(outputFolder, "bits_flat");
|
|
39121
39390
|
fs3.ensureDirSync(outputFolderBits);
|
|
39391
|
+
const existingFiles = fs3.readdirSync(outputFolderBits).filter((f) => f.endsWith(".jsonc"));
|
|
39392
|
+
for (const file of existingFiles) {
|
|
39393
|
+
fs3.removeSync(path3.join(outputFolderBits, file));
|
|
39394
|
+
}
|
|
39122
39395
|
const processTagEntries = (tag) => {
|
|
39123
39396
|
const tags2 = [];
|
|
39124
39397
|
let tagName = tag.key;
|