@gmb/bitmark-parser-generator 1.4.14 → 1.4.16

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.
Files changed (129) hide show
  1. package/dist/browser/bitmark-parser-generator.min.js +1 -1
  2. package/dist/browser/bundle-report.html +2 -2
  3. package/dist/cjs/ast/Builder.js +2 -19
  4. package/dist/cjs/ast/Builder.js.map +1 -1
  5. package/dist/cjs/ast/ResourceBuilder.js +10 -4
  6. package/dist/cjs/ast/ResourceBuilder.js.map +1 -1
  7. package/dist/cjs/config/raw/bits.js +2 -0
  8. package/dist/cjs/config/raw/bits.js.map +1 -1
  9. package/dist/cjs/config/raw/groups.js +4 -0
  10. package/dist/cjs/config/raw/groups.js.map +1 -1
  11. package/dist/cjs/config/raw/properties.js +9 -0
  12. package/dist/cjs/config/raw/properties.js.map +1 -1
  13. package/dist/cjs/config/raw/tags.js +0 -3
  14. package/dist/cjs/config/raw/tags.js.map +1 -1
  15. package/dist/cjs/generated/build-info.js +1 -1
  16. package/dist/cjs/generator/bitmark/BitmarkGenerator.js +21 -2
  17. package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
  18. package/dist/cjs/generator/json/JsonGenerator.js +130 -79
  19. package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
  20. package/dist/cjs/model/ast/NodeType.js +3 -0
  21. package/dist/cjs/model/ast/NodeType.js.map +1 -1
  22. package/dist/cjs/model/config/enum/PropertyConfigKey.js +2 -0
  23. package/dist/cjs/model/config/enum/PropertyConfigKey.js.map +1 -1
  24. package/dist/cjs/model/config/enum/TagConfigKey.js +0 -1
  25. package/dist/cjs/model/config/enum/TagConfigKey.js.map +1 -1
  26. package/dist/cjs/model/enum/BitType.js +2 -0
  27. package/dist/cjs/model/enum/BitType.js.map +1 -1
  28. package/dist/cjs/model/enum/PropertyTag.js +2 -0
  29. package/dist/cjs/model/enum/PropertyTag.js.map +1 -1
  30. package/dist/cjs/model/enum/Tag.js +0 -1
  31. package/dist/cjs/model/enum/Tag.js.map +1 -1
  32. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js +6 -15
  33. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
  34. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserTypes.js +0 -1
  35. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
  36. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js +18 -6
  37. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
  38. package/dist/cjs/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.js +6 -8
  39. package/dist/cjs/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.js.map +1 -1
  40. package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +7 -0
  41. package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
  42. package/dist/cjs/parser/json/JsonParser.js +5 -4
  43. package/dist/cjs/parser/json/JsonParser.js.map +1 -1
  44. package/dist/esm/ast/Builder.js +2 -19
  45. package/dist/esm/ast/Builder.js.map +1 -1
  46. package/dist/esm/ast/ResourceBuilder.js +10 -4
  47. package/dist/esm/ast/ResourceBuilder.js.map +1 -1
  48. package/dist/esm/config/raw/bits.js +2 -0
  49. package/dist/esm/config/raw/bits.js.map +1 -1
  50. package/dist/esm/config/raw/groups.js +4 -0
  51. package/dist/esm/config/raw/groups.js.map +1 -1
  52. package/dist/esm/config/raw/properties.js +9 -0
  53. package/dist/esm/config/raw/properties.js.map +1 -1
  54. package/dist/esm/config/raw/tags.js +0 -3
  55. package/dist/esm/config/raw/tags.js.map +1 -1
  56. package/dist/esm/generated/build-info.js +1 -1
  57. package/dist/esm/generator/bitmark/BitmarkGenerator.js +21 -2
  58. package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
  59. package/dist/esm/generator/json/JsonGenerator.js +130 -79
  60. package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
  61. package/dist/esm/model/ast/NodeType.js +3 -0
  62. package/dist/esm/model/ast/NodeType.js.map +1 -1
  63. package/dist/esm/model/config/enum/PropertyConfigKey.js +2 -0
  64. package/dist/esm/model/config/enum/PropertyConfigKey.js.map +1 -1
  65. package/dist/esm/model/config/enum/TagConfigKey.js +0 -1
  66. package/dist/esm/model/config/enum/TagConfigKey.js.map +1 -1
  67. package/dist/esm/model/enum/BitType.js +2 -0
  68. package/dist/esm/model/enum/BitType.js.map +1 -1
  69. package/dist/esm/model/enum/PropertyTag.js +2 -0
  70. package/dist/esm/model/enum/PropertyTag.js.map +1 -1
  71. package/dist/esm/model/enum/Tag.js +0 -1
  72. package/dist/esm/model/enum/Tag.js.map +1 -1
  73. package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js +6 -15
  74. package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
  75. package/dist/esm/parser/bitmark/peg/BitmarkPegParserTypes.js +0 -1
  76. package/dist/esm/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
  77. package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js +18 -6
  78. package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
  79. package/dist/esm/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.js +6 -8
  80. package/dist/esm/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.js.map +1 -1
  81. package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +7 -0
  82. package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
  83. package/dist/esm/parser/json/JsonParser.js +5 -4
  84. package/dist/esm/parser/json/JsonParser.js.map +1 -1
  85. package/dist/types/ast/Builder.d.ts +2 -15
  86. package/dist/types/ast/Builder.d.ts.map +1 -1
  87. package/dist/types/ast/ResourceBuilder.d.ts +3 -0
  88. package/dist/types/ast/ResourceBuilder.d.ts.map +1 -1
  89. package/dist/types/config/raw/bits.d.ts.map +1 -1
  90. package/dist/types/config/raw/groups.d.ts.map +1 -1
  91. package/dist/types/config/raw/properties.d.ts.map +1 -1
  92. package/dist/types/config/raw/tags.d.ts.map +1 -1
  93. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +2 -0
  94. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
  95. package/dist/types/generator/json/JsonGenerator.d.ts +40 -25
  96. package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
  97. package/dist/types/model/ast/NodeType.d.ts +6 -0
  98. package/dist/types/model/ast/NodeType.d.ts.map +1 -1
  99. package/dist/types/model/ast/Nodes.d.ts +4 -16
  100. package/dist/types/model/ast/Nodes.d.ts.map +1 -1
  101. package/dist/types/model/config/enum/ConfigKey.d.ts +4 -2
  102. package/dist/types/model/config/enum/ConfigKey.d.ts.map +1 -1
  103. package/dist/types/model/config/enum/PropertyConfigKey.d.ts +6 -0
  104. package/dist/types/model/config/enum/PropertyConfigKey.d.ts.map +1 -1
  105. package/dist/types/model/config/enum/TagConfigKey.d.ts +0 -3
  106. package/dist/types/model/config/enum/TagConfigKey.d.ts.map +1 -1
  107. package/dist/types/model/enum/BitType.d.ts +4 -0
  108. package/dist/types/model/enum/BitType.d.ts.map +1 -1
  109. package/dist/types/model/enum/PropertyTag.d.ts +4 -0
  110. package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
  111. package/dist/types/model/enum/Tag.d.ts +0 -2
  112. package/dist/types/model/enum/Tag.d.ts.map +1 -1
  113. package/dist/types/model/json/BitJson.d.ts +1 -0
  114. package/dist/types/model/json/BitJson.d.ts.map +1 -1
  115. package/dist/types/model/json/ParserJson.d.ts +2 -0
  116. package/dist/types/model/json/ParserJson.d.ts.map +1 -1
  117. package/dist/types/model/json/ResourceJson.d.ts +2 -0
  118. package/dist/types/model/json/ResourceJson.d.ts.map +1 -1
  119. package/dist/types/model/parser/ParserInfo.d.ts +0 -1
  120. package/dist/types/model/parser/ParserInfo.d.ts.map +1 -1
  121. package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts.map +1 -1
  122. package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts +4 -6
  123. package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts.map +1 -1
  124. package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts.map +1 -1
  125. package/dist/types/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.d.ts +1 -2
  126. package/dist/types/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.d.ts.map +1 -1
  127. package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts.map +1 -1
  128. package/dist/types/parser/json/JsonParser.d.ts.map +1 -1
  129. package/package.json +1 -1
@@ -262,16 +262,17 @@ class JsonGenerator {
262
262
  this.bitJson.imageSource = imageSourceJson;
263
263
  }
264
264
  // bitmarkAst -> bits -> bitsValue -> partner
265
- enter_partner(node, parent, _route) {
265
+ enter_partner(node, parent, route) {
266
266
  const partner = node.value;
267
+ const bitType = this.getBitType(route);
267
268
  // Ignore values that are not at the bit level as they might be handled elsewhere
268
- if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
269
+ if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue || !bitType)
269
270
  return;
270
271
  const { name, avatarImage } = partner;
271
272
  const partnerJson = {};
272
273
  this.addProperty(partnerJson, 'name', name !== null && name !== void 0 ? name : '', true);
273
274
  if (avatarImage) {
274
- const res = this.parseResourceToJson(avatarImage);
275
+ const res = this.parseResourceToJson(bitType, avatarImage);
275
276
  if (res && res.type === ResourceTag_1.ResourceTag.image) {
276
277
  partnerJson.avatarImage = res.image;
277
278
  }
@@ -685,16 +686,17 @@ class JsonGenerator {
685
686
  this.bitJson.heading = headingJson;
686
687
  }
687
688
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs
688
- enter_pairs(node, _parent, _route) {
689
+ enter_pairs(node, _parent, route) {
689
690
  var _a, _b, _c, _d;
690
691
  const pairs = node.value;
691
692
  const pairsJson = [];
692
- if (pairs) {
693
+ const bitType = this.getBitType(route);
694
+ if (pairs && bitType) {
693
695
  for (const p of pairs) {
694
696
  // Get default example
695
697
  const defaultExample = Array.isArray(p.values) && p.values.length > 0 && p.values[0];
696
698
  // Create the question
697
- const pairJson = Object.assign(Object.assign(Object.assign({ key: (_a = Breakscape_1.Breakscape.unbreakscape(p.key)) !== null && _a !== void 0 ? _a : '', keyAudio: p.keyAudio ? this.addAudioResource(p.keyAudio) : undefined, keyImage: p.keyImage ? this.addImageResource(p.keyImage) : undefined, values: (_b = Breakscape_1.Breakscape.unbreakscape(p.values)) !== null && _b !== void 0 ? _b : [] }, this.toItemLeadHintInstruction(p)), { isCaseSensitive: (_c = p.isCaseSensitive) !== null && _c !== void 0 ? _c : true }), this.toExample(p, {
699
+ const pairJson = Object.assign(Object.assign(Object.assign({ key: (_a = Breakscape_1.Breakscape.unbreakscape(p.key)) !== null && _a !== void 0 ? _a : '', keyAudio: p.keyAudio ? this.addAudioResource(bitType, p.keyAudio) : undefined, keyImage: p.keyImage ? this.addImageResource(bitType, p.keyImage) : undefined, values: (_b = Breakscape_1.Breakscape.unbreakscape(p.values)) !== null && _b !== void 0 ? _b : [] }, this.toItemLeadHintInstruction(p)), { isCaseSensitive: (_c = p.isCaseSensitive) !== null && _c !== void 0 ? _c : true }), this.toExample(p, {
698
700
  defaultExample,
699
701
  isBoolean: false,
700
702
  }));
@@ -839,7 +841,7 @@ class JsonGenerator {
839
841
  if (r) {
840
842
  const tagConfig = Config_1.Config.getTagConfigForTag(bitConfig.tags, r.typeAlias);
841
843
  const key = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.jsonKey) !== null && _a !== void 0 ? _a : r.typeAlias;
842
- const json = this.parseResourceToJson(r);
844
+ const json = this.parseResourceToJson(bitType, r);
843
845
  if (json) {
844
846
  for (const [k, v] of Object.entries(json)) {
845
847
  if (k !== 'type') {
@@ -857,7 +859,7 @@ class JsonGenerator {
857
859
  // This is a standard resource. If there is more than one resource, use the first one.
858
860
  // There should not be more than one because of validation
859
861
  if (resources.length >= 1) {
860
- resourceJson = this.parseResourceToJson(resources[0]);
862
+ resourceJson = this.parseResourceToJson(bitType, resources[0]);
861
863
  }
862
864
  }
863
865
  this.bitJson.resource = resourceJson;
@@ -927,9 +929,11 @@ class JsonGenerator {
927
929
  this.bitWrapperJson.bitmark = bitmark;
928
930
  }
929
931
  // bitmarkAst -> bits -> bitsValue -> parser
930
- enter_parser(node, parent, _route) {
932
+ // bitmarkAst -> bits -> bitsValue -> * -> internalComment
933
+ enter_parser(node, parent, route) {
931
934
  const parser = node.value;
932
- if (parser) {
935
+ const bitType = this.getBitType(route);
936
+ if (parser && bitType) {
933
937
  const { version, excessResources: parserExcessResources, warnings, errors } = parser, parserRest = __rest(parser, ["version", "excessResources", "warnings", "errors"]);
934
938
  const bitmarkVersion = `${this.bitmarkVersion}`;
935
939
  // Parse resources to JSON from AST
@@ -937,15 +941,18 @@ class JsonGenerator {
937
941
  if (Array.isArray(parserExcessResources) && parserExcessResources.length > 0) {
938
942
  excessResources = [];
939
943
  for (const r of parserExcessResources) {
940
- const rJson = this.parseResourceToJson(r);
944
+ const rJson = this.parseResourceToJson(bitType, r);
941
945
  if (rJson)
942
946
  excessResources.push(rJson);
943
947
  }
944
948
  }
949
+ // Extract comments from the AST and add to the parser
950
+ const comments = Breakscape_1.Breakscape.unbreakscape(this.getInternalComments(route));
945
951
  if ((parent === null || parent === void 0 ? void 0 : parent.key) === NodeType_1.NodeType.bitsValue) {
946
952
  // Bit level parser information
947
953
  this.bitWrapperJson.parser = Object.assign(Object.assign({ version,
948
- bitmarkVersion }, parserRest), { warnings,
954
+ bitmarkVersion,
955
+ comments }, parserRest), { warnings,
949
956
  errors,
950
957
  excessResources });
951
958
  if (!this.options.enableWarnings) {
@@ -986,6 +993,8 @@ class JsonGenerator {
986
993
  for (const propertyConfig of Object.values(propertiesConfig)) {
987
994
  const astKey = (_a = propertyConfig.astKey) !== null && _a !== void 0 ? _a : propertyConfig.tag;
988
995
  // Special cases (handled outside of the automatically generated handlers)
996
+ if (astKey === PropertyTag_1.PropertyTag.internalComment)
997
+ continue;
989
998
  if (astKey === PropertyTag_1.PropertyTag.example)
990
999
  continue;
991
1000
  if (astKey === PropertyTag_1.PropertyTag.imageSource)
@@ -1097,7 +1106,7 @@ class JsonGenerator {
1097
1106
  delete highlightJson.lead;
1098
1107
  return highlightJson;
1099
1108
  }
1100
- parseResourceToJson(resource) {
1109
+ parseResourceToJson(bitType, resource) {
1101
1110
  if (!resource)
1102
1111
  return undefined;
1103
1112
  // All resources should now be valid as they are validated in the AST
@@ -1115,111 +1124,111 @@ class JsonGenerator {
1115
1124
  case ResourceTag_1.ResourceTag.image:
1116
1125
  resourceJson = {
1117
1126
  type: ResourceTag_1.ResourceTag.image,
1118
- image: this.addImageResource(resource),
1127
+ image: this.addImageResource(bitType, resource),
1119
1128
  };
1120
1129
  break;
1121
1130
  case ResourceTag_1.ResourceTag.imageLink:
1122
1131
  resourceJson = {
1123
1132
  type: ResourceTag_1.ResourceTag.imageLink,
1124
- imageLink: this.addImageLinkResource(resource),
1133
+ imageLink: this.addImageLinkResource(bitType, resource),
1125
1134
  };
1126
1135
  break;
1127
1136
  case ResourceTag_1.ResourceTag.audio:
1128
1137
  resourceJson = {
1129
1138
  type: ResourceTag_1.ResourceTag.audio,
1130
- audio: this.addAudioResource(resource),
1139
+ audio: this.addAudioResource(bitType, resource),
1131
1140
  };
1132
1141
  break;
1133
1142
  case ResourceTag_1.ResourceTag.audioEmbed:
1134
1143
  resourceJson = {
1135
1144
  type: ResourceTag_1.ResourceTag.audioEmbed,
1136
- audioEmbed: this.addAudioEmbedResource(resource),
1145
+ audioEmbed: this.addAudioEmbedResource(bitType, resource),
1137
1146
  };
1138
1147
  break;
1139
1148
  case ResourceTag_1.ResourceTag.audioLink:
1140
1149
  resourceJson = {
1141
1150
  type: ResourceTag_1.ResourceTag.audioLink,
1142
- audioLink: this.addAudioLinkResource(resource),
1151
+ audioLink: this.addAudioLinkResource(bitType, resource),
1143
1152
  };
1144
1153
  break;
1145
1154
  case ResourceTag_1.ResourceTag.video:
1146
1155
  resourceJson = {
1147
1156
  type: ResourceTag_1.ResourceTag.video,
1148
- video: this.addVideoResource(resource),
1157
+ video: this.addVideoResource(bitType, resource),
1149
1158
  };
1150
1159
  break;
1151
1160
  case ResourceTag_1.ResourceTag.videoEmbed:
1152
1161
  resourceJson = {
1153
1162
  type: ResourceTag_1.ResourceTag.videoEmbed,
1154
- videoEmbed: this.addVideoEmbedResource(resource),
1163
+ videoEmbed: this.addVideoEmbedResource(bitType, resource),
1155
1164
  };
1156
- resourceJson.videoEmbed = this.addVideoLinkResource(resource);
1165
+ resourceJson.videoEmbed = this.addVideoLinkResource(bitType, resource);
1157
1166
  break;
1158
1167
  case ResourceTag_1.ResourceTag.videoLink:
1159
1168
  resourceJson = {
1160
1169
  type: ResourceTag_1.ResourceTag.videoLink,
1161
- videoLink: this.addVideoLinkResource(resource),
1170
+ videoLink: this.addVideoLinkResource(bitType, resource),
1162
1171
  };
1163
1172
  break;
1164
1173
  case ResourceTag_1.ResourceTag.stillImageFilmEmbed:
1165
1174
  resourceJson = {
1166
1175
  type: ResourceTag_1.ResourceTag.stillImageFilmEmbed,
1167
- stillImageFilmEmbed: this.addStillImageFilmEmbedResource(resource),
1176
+ stillImageFilmEmbed: this.addStillImageFilmEmbedResource(bitType, resource),
1168
1177
  };
1169
1178
  break;
1170
1179
  case ResourceTag_1.ResourceTag.stillImageFilmLink:
1171
1180
  resourceJson = {
1172
1181
  type: ResourceTag_1.ResourceTag.stillImageFilmLink,
1173
- stillImageFilmLink: this.addStillImageFilmLinkResource(resource),
1182
+ stillImageFilmLink: this.addStillImageFilmLinkResource(bitType, resource),
1174
1183
  };
1175
1184
  break;
1176
1185
  case ResourceTag_1.ResourceTag.article:
1177
1186
  resourceJson = {
1178
1187
  type: ResourceTag_1.ResourceTag.article,
1179
- article: this.addArticleResource(resource),
1188
+ article: this.addArticleResource(bitType, resource),
1180
1189
  };
1181
1190
  break;
1182
1191
  case ResourceTag_1.ResourceTag.document:
1183
1192
  resourceJson = {
1184
1193
  type: ResourceTag_1.ResourceTag.document,
1185
- document: this.addDocumentResource(resource),
1194
+ document: this.addDocumentResource(bitType, resource),
1186
1195
  };
1187
1196
  break;
1188
1197
  case ResourceTag_1.ResourceTag.documentEmbed:
1189
1198
  resourceJson = {
1190
1199
  type: ResourceTag_1.ResourceTag.documentEmbed,
1191
- documentEmbed: this.addDocumentEmbedResource(resource),
1200
+ documentEmbed: this.addDocumentEmbedResource(bitType, resource),
1192
1201
  };
1193
1202
  break;
1194
1203
  case ResourceTag_1.ResourceTag.documentLink:
1195
1204
  resourceJson = {
1196
1205
  type: ResourceTag_1.ResourceTag.documentLink,
1197
- documentLink: this.addDocumentLinkResource(resource),
1206
+ documentLink: this.addDocumentLinkResource(bitType, resource),
1198
1207
  };
1199
1208
  break;
1200
1209
  case ResourceTag_1.ResourceTag.documentDownload:
1201
1210
  resourceJson = {
1202
1211
  type: ResourceTag_1.ResourceTag.documentDownload,
1203
- documentDownload: this.addDocumentDownloadResource(resource),
1212
+ documentDownload: this.addDocumentDownloadResource(bitType, resource),
1204
1213
  };
1205
1214
  break;
1206
1215
  case ResourceTag_1.ResourceTag.appLink:
1207
1216
  resourceJson = {
1208
1217
  type: ResourceTag_1.ResourceTag.appLink,
1209
- appLink: this.addAppLinkResource(resource),
1218
+ appLink: this.addAppLinkResource(bitType, resource),
1210
1219
  };
1211
1220
  break;
1212
1221
  case ResourceTag_1.ResourceTag.websiteLink:
1213
1222
  resourceJson = {
1214
1223
  type: ResourceTag_1.ResourceTag.websiteLink,
1215
- websiteLink: this.addWebsiteLinkResource(resource),
1224
+ websiteLink: this.addWebsiteLinkResource(bitType, resource),
1216
1225
  };
1217
1226
  break;
1218
1227
  default:
1219
1228
  }
1220
1229
  return resourceJson;
1221
1230
  }
1222
- addImageResource(resource) {
1231
+ addImageResource(bitType, resource) {
1223
1232
  var _a, _b, _c;
1224
1233
  const resourceJson = {};
1225
1234
  if (StringUtils_1.StringUtils.isString(resource)) {
@@ -1250,10 +1259,11 @@ class JsonGenerator {
1250
1259
  resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
1251
1260
  resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
1252
1261
  resourceJson.alt = (_c = Breakscape_1.Breakscape.unbreakscape(resource.alt)) !== null && _c !== void 0 ? _c : '';
1253
- this.addGenericResourceProperties(resource, resourceJson);
1262
+ resourceJson.zoomDisabled = this.getZoomDisabled(bitType, resource.zoomDisabled);
1263
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1254
1264
  return resourceJson;
1255
1265
  }
1256
- addImageLinkResource(resource) {
1266
+ addImageLinkResource(bitType, resource) {
1257
1267
  var _a, _b, _c;
1258
1268
  const resourceJson = {};
1259
1269
  if (StringUtils_1.StringUtils.isString(resource)) {
@@ -1284,10 +1294,11 @@ class JsonGenerator {
1284
1294
  resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
1285
1295
  resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
1286
1296
  resourceJson.alt = (_c = Breakscape_1.Breakscape.unbreakscape(resource.alt)) !== null && _c !== void 0 ? _c : '';
1287
- this.addGenericResourceProperties(resource, resourceJson);
1297
+ resourceJson.zoomDisabled = this.getZoomDisabled(bitType, resource.zoomDisabled);
1298
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1288
1299
  return resourceJson;
1289
1300
  }
1290
- addAudioResource(resource) {
1301
+ addAudioResource(bitType, resource) {
1291
1302
  const resourceJson = {};
1292
1303
  if (resource.format != null)
1293
1304
  resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
@@ -1301,10 +1312,10 @@ class JsonGenerator {
1301
1312
  resourceJson.mute = resource.mute;
1302
1313
  if (resource.autoplay != null)
1303
1314
  resourceJson.autoplay = resource.autoplay;
1304
- this.addGenericResourceProperties(resource, resourceJson);
1315
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1305
1316
  return resourceJson;
1306
1317
  }
1307
- addAudioEmbedResource(resource) {
1318
+ addAudioEmbedResource(bitType, resource) {
1308
1319
  const resourceJson = {};
1309
1320
  if (resource.format != null)
1310
1321
  resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
@@ -1318,10 +1329,10 @@ class JsonGenerator {
1318
1329
  resourceJson.mute = resource.mute;
1319
1330
  if (resource.autoplay != null)
1320
1331
  resourceJson.autoplay = resource.autoplay;
1321
- this.addGenericResourceProperties(resource, resourceJson);
1332
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1322
1333
  return resourceJson;
1323
1334
  }
1324
- addAudioLinkResource(resource) {
1335
+ addAudioLinkResource(bitType, resource) {
1325
1336
  const resourceJson = {};
1326
1337
  if (resource.format != null)
1327
1338
  resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
@@ -1335,10 +1346,10 @@ class JsonGenerator {
1335
1346
  resourceJson.mute = resource.mute;
1336
1347
  if (resource.autoplay != null)
1337
1348
  resourceJson.autoplay = resource.autoplay;
1338
- this.addGenericResourceProperties(resource, resourceJson, true);
1349
+ this.addGenericResourceProperties(bitType, resource, resourceJson, true);
1339
1350
  return resourceJson;
1340
1351
  }
1341
- addVideoResource(resource) {
1352
+ addVideoResource(bitType, resource) {
1342
1353
  var _a, _b;
1343
1354
  const resourceJson = {};
1344
1355
  if (resource.format != null)
@@ -1362,17 +1373,17 @@ class JsonGenerator {
1362
1373
  if (resource.alt != null)
1363
1374
  resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
1364
1375
  if (resource.posterImage != null)
1365
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1376
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1366
1377
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1367
1378
  resourceJson.thumbnails = [];
1368
1379
  for (const thumbnail of resource.thumbnails) {
1369
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1380
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1370
1381
  }
1371
1382
  }
1372
- this.addGenericResourceProperties(resource, resourceJson);
1383
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1373
1384
  return resourceJson;
1374
1385
  }
1375
- addVideoEmbedResource(resource) {
1386
+ addVideoEmbedResource(bitType, resource) {
1376
1387
  var _a, _b;
1377
1388
  const resourceJson = {};
1378
1389
  if (resource.format != null)
@@ -1396,17 +1407,17 @@ class JsonGenerator {
1396
1407
  if (resource.alt != null)
1397
1408
  resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
1398
1409
  if (resource.posterImage != null)
1399
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1410
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1400
1411
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1401
1412
  resourceJson.thumbnails = [];
1402
1413
  for (const thumbnail of resource.thumbnails) {
1403
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1414
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1404
1415
  }
1405
1416
  }
1406
- this.addGenericResourceProperties(resource, resourceJson);
1417
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1407
1418
  return resourceJson;
1408
1419
  }
1409
- addVideoLinkResource(resource) {
1420
+ addVideoLinkResource(bitType, resource) {
1410
1421
  var _a, _b;
1411
1422
  const resourceJson = {};
1412
1423
  if (resource.format != null)
@@ -1430,17 +1441,17 @@ class JsonGenerator {
1430
1441
  if (resource.alt != null)
1431
1442
  resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
1432
1443
  if (resource.posterImage != null)
1433
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1444
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1434
1445
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1435
1446
  resourceJson.thumbnails = [];
1436
1447
  for (const thumbnail of resource.thumbnails) {
1437
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1448
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1438
1449
  }
1439
1450
  }
1440
- this.addGenericResourceProperties(resource, resourceJson);
1451
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1441
1452
  return resourceJson;
1442
1453
  }
1443
- addStillImageFilmEmbedResource(resource) {
1454
+ addStillImageFilmEmbedResource(bitType, resource) {
1444
1455
  var _a, _b;
1445
1456
  const resourceJson = {};
1446
1457
  if (resource.format != null)
@@ -1464,17 +1475,17 @@ class JsonGenerator {
1464
1475
  if (resource.alt != null)
1465
1476
  resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
1466
1477
  if (resource.posterImage != null)
1467
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1478
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1468
1479
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1469
1480
  resourceJson.thumbnails = [];
1470
1481
  for (const thumbnail of resource.thumbnails) {
1471
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1482
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1472
1483
  }
1473
1484
  }
1474
- this.addGenericResourceProperties(resource, resourceJson);
1485
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1475
1486
  return resourceJson;
1476
1487
  }
1477
- addStillImageFilmLinkResource(resource) {
1488
+ addStillImageFilmLinkResource(bitType, resource) {
1478
1489
  var _a, _b;
1479
1490
  const resourceJson = {};
1480
1491
  if (resource.format != null)
@@ -1498,17 +1509,17 @@ class JsonGenerator {
1498
1509
  if (resource.alt != null)
1499
1510
  resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
1500
1511
  if (resource.posterImage != null)
1501
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1512
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1502
1513
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1503
1514
  resourceJson.thumbnails = [];
1504
1515
  for (const thumbnail of resource.thumbnails) {
1505
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1516
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1506
1517
  }
1507
1518
  }
1508
- this.addGenericResourceProperties(resource, resourceJson);
1519
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1509
1520
  return resourceJson;
1510
1521
  }
1511
- addArticleResource(resource) {
1522
+ addArticleResource(bitType, resource) {
1512
1523
  const resourceJson = {};
1513
1524
  if (resource.format != null)
1514
1525
  resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
@@ -1517,10 +1528,10 @@ class JsonGenerator {
1517
1528
  if (resource.value != null)
1518
1529
  resourceJson.body = Breakscape_1.Breakscape.unbreakscape(resource.value);
1519
1530
  // if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
1520
- this.addGenericResourceProperties(resource, resourceJson);
1531
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1521
1532
  return resourceJson;
1522
1533
  }
1523
- addDocumentResource(resource) {
1534
+ addDocumentResource(bitType, resource) {
1524
1535
  const resourceJson = {};
1525
1536
  if (resource.format != null)
1526
1537
  resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
@@ -1529,10 +1540,10 @@ class JsonGenerator {
1529
1540
  if (resource.value != null)
1530
1541
  resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
1531
1542
  // if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
1532
- this.addGenericResourceProperties(resource, resourceJson);
1543
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1533
1544
  return resourceJson;
1534
1545
  }
1535
- addDocumentEmbedResource(resource) {
1546
+ addDocumentEmbedResource(bitType, resource) {
1536
1547
  const resourceJson = {};
1537
1548
  if (resource.format != null)
1538
1549
  resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
@@ -1541,10 +1552,10 @@ class JsonGenerator {
1541
1552
  if (resource.value != null)
1542
1553
  resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
1543
1554
  // if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
1544
- this.addGenericResourceProperties(resource, resourceJson);
1555
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1545
1556
  return resourceJson;
1546
1557
  }
1547
- addDocumentLinkResource(resource) {
1558
+ addDocumentLinkResource(bitType, resource) {
1548
1559
  const resourceJson = {};
1549
1560
  if (resource.format != null)
1550
1561
  resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
@@ -1553,10 +1564,10 @@ class JsonGenerator {
1553
1564
  if (resource.value != null)
1554
1565
  resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
1555
1566
  // if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
1556
- this.addGenericResourceProperties(resource, resourceJson);
1567
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1557
1568
  return resourceJson;
1558
1569
  }
1559
- addDocumentDownloadResource(resource) {
1570
+ addDocumentDownloadResource(bitType, resource) {
1560
1571
  const resourceJson = {};
1561
1572
  if (resource.format != null)
1562
1573
  resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
@@ -1565,28 +1576,28 @@ class JsonGenerator {
1565
1576
  if (resource.value != null)
1566
1577
  resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
1567
1578
  // if (resource.href != null) resourceJson.href = resource.href; // It is never used (and doesn't exist in the AST model)
1568
- this.addGenericResourceProperties(resource, resourceJson);
1579
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1569
1580
  return resourceJson;
1570
1581
  }
1571
- addAppLinkResource(resource) {
1582
+ addAppLinkResource(bitType, resource) {
1572
1583
  const resourceJson = {};
1573
1584
  // if (resource.format != null) resourceJson.format = BreakscapeUtils.unbreakscape(resource.format);
1574
1585
  if (resource.value != null)
1575
1586
  resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
1576
- this.addGenericResourceProperties(resource, resourceJson);
1587
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1577
1588
  return resourceJson;
1578
1589
  }
1579
- addWebsiteLinkResource(resource) {
1590
+ addWebsiteLinkResource(bitType, resource) {
1580
1591
  const resourceJson = {};
1581
1592
  // if (resource.format != null) resourceJson.format = BreakscapeUtils.unbreakscape(resource.format);
1582
1593
  if (resource.value != null)
1583
1594
  resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
1584
1595
  if (resource.siteName != null)
1585
1596
  resourceJson.siteName = Breakscape_1.Breakscape.unbreakscape(resource.siteName);
1586
- this.addGenericResourceProperties(resource, resourceJson);
1597
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1587
1598
  return resourceJson;
1588
1599
  }
1589
- addGenericResourceProperties(resource, resourceJson, noDefaults) {
1600
+ addGenericResourceProperties(_bitType, resource, resourceJson, noDefaults) {
1590
1601
  var _a, _b, _c, _d, _e, _f, _g, _h;
1591
1602
  if (noDefaults) {
1592
1603
  if (resource.license != null)
@@ -1666,10 +1677,29 @@ class JsonGenerator {
1666
1677
  // }
1667
1678
  }
1668
1679
  }
1680
+ /**
1681
+ * Get the value for the zoomDisabled property, setting the appropriate default value if no value is set.
1682
+ *
1683
+ * @param bitType
1684
+ * @param zoomDisabled
1685
+ * @returns
1686
+ */
1687
+ getZoomDisabled(bitType, zoomDisabled) {
1688
+ if (zoomDisabled != null)
1689
+ return zoomDisabled;
1690
+ // The default value in the JSON is hardcoded, because there is currently no good way to set a different
1691
+ // default per bit in the BitConfig.
1692
+ switch (bitType.alias) {
1693
+ case BitType_1.AliasBitType.imageSeparator:
1694
+ case BitType_1.AliasBitType.pageBanner:
1695
+ return true;
1696
+ }
1697
+ return false;
1698
+ }
1669
1699
  /**
1670
1700
  * Get the bit type from any node
1671
1701
  *
1672
- * @param route the route to the node
1702
+ * @param route the route to the current node
1673
1703
  * @returns the bit type
1674
1704
  */
1675
1705
  getBitType(route) {
@@ -1684,7 +1714,7 @@ class JsonGenerator {
1684
1714
  /**
1685
1715
  * Get the text format from any node
1686
1716
  *
1687
- * @param route the route to the node
1717
+ * @param route the route to the current node
1688
1718
  * @returns the text format
1689
1719
  */
1690
1720
  getTextFormat(route) {
@@ -1704,7 +1734,7 @@ class JsonGenerator {
1704
1734
  /**
1705
1735
  * Get the bit resourceType atttachment from any node
1706
1736
  *
1707
- * @param route the route to the node
1737
+ * @param route the route to the current node
1708
1738
  * @returns the bit type
1709
1739
  */
1710
1740
  getResourceType(route) {
@@ -1716,6 +1746,24 @@ class JsonGenerator {
1716
1746
  }
1717
1747
  return undefined;
1718
1748
  }
1749
+ /**
1750
+ * Get the internal comments from any node
1751
+ *
1752
+ * @param route the route to the current node
1753
+ * @returns the text format
1754
+ */
1755
+ getInternalComments(route) {
1756
+ const bitType = this.getBitType(route);
1757
+ if (bitType) {
1758
+ for (const node of route) {
1759
+ if (node.key === NodeType_1.NodeType.bitsValue) {
1760
+ const n = node.value;
1761
+ return n.internalComment;
1762
+ }
1763
+ }
1764
+ }
1765
+ return undefined;
1766
+ }
1719
1767
  /**
1720
1768
  * Convert the text from the AST to the JSON format:
1721
1769
  * Input:
@@ -1810,6 +1858,7 @@ class JsonGenerator {
1810
1858
  format: bit.textFormat,
1811
1859
  // Properties
1812
1860
  id: undefined,
1861
+ internalComment: undefined,
1813
1862
  externalId: undefined,
1814
1863
  spaceId: undefined,
1815
1864
  padletId: undefined,
@@ -2145,6 +2194,8 @@ class JsonGenerator {
2145
2194
  // Properties
2146
2195
  if (bitJson.id == null)
2147
2196
  delete bitJson.id;
2197
+ if (bitJson.internalComment == null)
2198
+ delete bitJson.internalComment;
2148
2199
  if (bitJson.externalId == null)
2149
2200
  delete bitJson.externalId;
2150
2201
  if (bitJson.spaceId == null)