@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
@@ -259,16 +259,17 @@ class JsonGenerator {
259
259
  this.bitJson.imageSource = imageSourceJson;
260
260
  }
261
261
  // bitmarkAst -> bits -> bitsValue -> partner
262
- enter_partner(node, parent, _route) {
262
+ enter_partner(node, parent, route) {
263
263
  const partner = node.value;
264
+ const bitType = this.getBitType(route);
264
265
  // Ignore values that are not at the bit level as they might be handled elsewhere
265
- if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
266
+ if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue || !bitType)
266
267
  return;
267
268
  const { name, avatarImage } = partner;
268
269
  const partnerJson = {};
269
270
  this.addProperty(partnerJson, 'name', name !== null && name !== void 0 ? name : '', true);
270
271
  if (avatarImage) {
271
- const res = this.parseResourceToJson(avatarImage);
272
+ const res = this.parseResourceToJson(bitType, avatarImage);
272
273
  if (res && res.type === ResourceTag.image) {
273
274
  partnerJson.avatarImage = res.image;
274
275
  }
@@ -682,16 +683,17 @@ class JsonGenerator {
682
683
  this.bitJson.heading = headingJson;
683
684
  }
684
685
  // bitmarkAst -> bits -> bitsValue -> cardNode -> pairs
685
- enter_pairs(node, _parent, _route) {
686
+ enter_pairs(node, _parent, route) {
686
687
  var _a, _b, _c, _d;
687
688
  const pairs = node.value;
688
689
  const pairsJson = [];
689
- if (pairs) {
690
+ const bitType = this.getBitType(route);
691
+ if (pairs && bitType) {
690
692
  for (const p of pairs) {
691
693
  // Get default example
692
694
  const defaultExample = Array.isArray(p.values) && p.values.length > 0 && p.values[0];
693
695
  // Create the question
694
- const pairJson = Object.assign(Object.assign(Object.assign({ key: (_a = 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.unbreakscape(p.values)) !== null && _b !== void 0 ? _b : [] }, this.toItemLeadHintInstruction(p)), { isCaseSensitive: (_c = p.isCaseSensitive) !== null && _c !== void 0 ? _c : true }), this.toExample(p, {
696
+ const pairJson = Object.assign(Object.assign(Object.assign({ key: (_a = 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.unbreakscape(p.values)) !== null && _b !== void 0 ? _b : [] }, this.toItemLeadHintInstruction(p)), { isCaseSensitive: (_c = p.isCaseSensitive) !== null && _c !== void 0 ? _c : true }), this.toExample(p, {
695
697
  defaultExample,
696
698
  isBoolean: false,
697
699
  }));
@@ -836,7 +838,7 @@ class JsonGenerator {
836
838
  if (r) {
837
839
  const tagConfig = Config.getTagConfigForTag(bitConfig.tags, r.typeAlias);
838
840
  const key = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.jsonKey) !== null && _a !== void 0 ? _a : r.typeAlias;
839
- const json = this.parseResourceToJson(r);
841
+ const json = this.parseResourceToJson(bitType, r);
840
842
  if (json) {
841
843
  for (const [k, v] of Object.entries(json)) {
842
844
  if (k !== 'type') {
@@ -854,7 +856,7 @@ class JsonGenerator {
854
856
  // This is a standard resource. If there is more than one resource, use the first one.
855
857
  // There should not be more than one because of validation
856
858
  if (resources.length >= 1) {
857
- resourceJson = this.parseResourceToJson(resources[0]);
859
+ resourceJson = this.parseResourceToJson(bitType, resources[0]);
858
860
  }
859
861
  }
860
862
  this.bitJson.resource = resourceJson;
@@ -924,9 +926,11 @@ class JsonGenerator {
924
926
  this.bitWrapperJson.bitmark = bitmark;
925
927
  }
926
928
  // bitmarkAst -> bits -> bitsValue -> parser
927
- enter_parser(node, parent, _route) {
929
+ // bitmarkAst -> bits -> bitsValue -> * -> internalComment
930
+ enter_parser(node, parent, route) {
928
931
  const parser = node.value;
929
- if (parser) {
932
+ const bitType = this.getBitType(route);
933
+ if (parser && bitType) {
930
934
  const { version, excessResources: parserExcessResources, warnings, errors } = parser, parserRest = __rest(parser, ["version", "excessResources", "warnings", "errors"]);
931
935
  const bitmarkVersion = `${this.bitmarkVersion}`;
932
936
  // Parse resources to JSON from AST
@@ -934,15 +938,18 @@ class JsonGenerator {
934
938
  if (Array.isArray(parserExcessResources) && parserExcessResources.length > 0) {
935
939
  excessResources = [];
936
940
  for (const r of parserExcessResources) {
937
- const rJson = this.parseResourceToJson(r);
941
+ const rJson = this.parseResourceToJson(bitType, r);
938
942
  if (rJson)
939
943
  excessResources.push(rJson);
940
944
  }
941
945
  }
946
+ // Extract comments from the AST and add to the parser
947
+ const comments = Breakscape.unbreakscape(this.getInternalComments(route));
942
948
  if ((parent === null || parent === void 0 ? void 0 : parent.key) === NodeType.bitsValue) {
943
949
  // Bit level parser information
944
950
  this.bitWrapperJson.parser = Object.assign(Object.assign({ version,
945
- bitmarkVersion }, parserRest), { warnings,
951
+ bitmarkVersion,
952
+ comments }, parserRest), { warnings,
946
953
  errors,
947
954
  excessResources });
948
955
  if (!this.options.enableWarnings) {
@@ -983,6 +990,8 @@ class JsonGenerator {
983
990
  for (const propertyConfig of Object.values(propertiesConfig)) {
984
991
  const astKey = (_a = propertyConfig.astKey) !== null && _a !== void 0 ? _a : propertyConfig.tag;
985
992
  // Special cases (handled outside of the automatically generated handlers)
993
+ if (astKey === PropertyTag.internalComment)
994
+ continue;
986
995
  if (astKey === PropertyTag.example)
987
996
  continue;
988
997
  if (astKey === PropertyTag.imageSource)
@@ -1094,7 +1103,7 @@ class JsonGenerator {
1094
1103
  delete highlightJson.lead;
1095
1104
  return highlightJson;
1096
1105
  }
1097
- parseResourceToJson(resource) {
1106
+ parseResourceToJson(bitType, resource) {
1098
1107
  if (!resource)
1099
1108
  return undefined;
1100
1109
  // All resources should now be valid as they are validated in the AST
@@ -1112,111 +1121,111 @@ class JsonGenerator {
1112
1121
  case ResourceTag.image:
1113
1122
  resourceJson = {
1114
1123
  type: ResourceTag.image,
1115
- image: this.addImageResource(resource),
1124
+ image: this.addImageResource(bitType, resource),
1116
1125
  };
1117
1126
  break;
1118
1127
  case ResourceTag.imageLink:
1119
1128
  resourceJson = {
1120
1129
  type: ResourceTag.imageLink,
1121
- imageLink: this.addImageLinkResource(resource),
1130
+ imageLink: this.addImageLinkResource(bitType, resource),
1122
1131
  };
1123
1132
  break;
1124
1133
  case ResourceTag.audio:
1125
1134
  resourceJson = {
1126
1135
  type: ResourceTag.audio,
1127
- audio: this.addAudioResource(resource),
1136
+ audio: this.addAudioResource(bitType, resource),
1128
1137
  };
1129
1138
  break;
1130
1139
  case ResourceTag.audioEmbed:
1131
1140
  resourceJson = {
1132
1141
  type: ResourceTag.audioEmbed,
1133
- audioEmbed: this.addAudioEmbedResource(resource),
1142
+ audioEmbed: this.addAudioEmbedResource(bitType, resource),
1134
1143
  };
1135
1144
  break;
1136
1145
  case ResourceTag.audioLink:
1137
1146
  resourceJson = {
1138
1147
  type: ResourceTag.audioLink,
1139
- audioLink: this.addAudioLinkResource(resource),
1148
+ audioLink: this.addAudioLinkResource(bitType, resource),
1140
1149
  };
1141
1150
  break;
1142
1151
  case ResourceTag.video:
1143
1152
  resourceJson = {
1144
1153
  type: ResourceTag.video,
1145
- video: this.addVideoResource(resource),
1154
+ video: this.addVideoResource(bitType, resource),
1146
1155
  };
1147
1156
  break;
1148
1157
  case ResourceTag.videoEmbed:
1149
1158
  resourceJson = {
1150
1159
  type: ResourceTag.videoEmbed,
1151
- videoEmbed: this.addVideoEmbedResource(resource),
1160
+ videoEmbed: this.addVideoEmbedResource(bitType, resource),
1152
1161
  };
1153
- resourceJson.videoEmbed = this.addVideoLinkResource(resource);
1162
+ resourceJson.videoEmbed = this.addVideoLinkResource(bitType, resource);
1154
1163
  break;
1155
1164
  case ResourceTag.videoLink:
1156
1165
  resourceJson = {
1157
1166
  type: ResourceTag.videoLink,
1158
- videoLink: this.addVideoLinkResource(resource),
1167
+ videoLink: this.addVideoLinkResource(bitType, resource),
1159
1168
  };
1160
1169
  break;
1161
1170
  case ResourceTag.stillImageFilmEmbed:
1162
1171
  resourceJson = {
1163
1172
  type: ResourceTag.stillImageFilmEmbed,
1164
- stillImageFilmEmbed: this.addStillImageFilmEmbedResource(resource),
1173
+ stillImageFilmEmbed: this.addStillImageFilmEmbedResource(bitType, resource),
1165
1174
  };
1166
1175
  break;
1167
1176
  case ResourceTag.stillImageFilmLink:
1168
1177
  resourceJson = {
1169
1178
  type: ResourceTag.stillImageFilmLink,
1170
- stillImageFilmLink: this.addStillImageFilmLinkResource(resource),
1179
+ stillImageFilmLink: this.addStillImageFilmLinkResource(bitType, resource),
1171
1180
  };
1172
1181
  break;
1173
1182
  case ResourceTag.article:
1174
1183
  resourceJson = {
1175
1184
  type: ResourceTag.article,
1176
- article: this.addArticleResource(resource),
1185
+ article: this.addArticleResource(bitType, resource),
1177
1186
  };
1178
1187
  break;
1179
1188
  case ResourceTag.document:
1180
1189
  resourceJson = {
1181
1190
  type: ResourceTag.document,
1182
- document: this.addDocumentResource(resource),
1191
+ document: this.addDocumentResource(bitType, resource),
1183
1192
  };
1184
1193
  break;
1185
1194
  case ResourceTag.documentEmbed:
1186
1195
  resourceJson = {
1187
1196
  type: ResourceTag.documentEmbed,
1188
- documentEmbed: this.addDocumentEmbedResource(resource),
1197
+ documentEmbed: this.addDocumentEmbedResource(bitType, resource),
1189
1198
  };
1190
1199
  break;
1191
1200
  case ResourceTag.documentLink:
1192
1201
  resourceJson = {
1193
1202
  type: ResourceTag.documentLink,
1194
- documentLink: this.addDocumentLinkResource(resource),
1203
+ documentLink: this.addDocumentLinkResource(bitType, resource),
1195
1204
  };
1196
1205
  break;
1197
1206
  case ResourceTag.documentDownload:
1198
1207
  resourceJson = {
1199
1208
  type: ResourceTag.documentDownload,
1200
- documentDownload: this.addDocumentDownloadResource(resource),
1209
+ documentDownload: this.addDocumentDownloadResource(bitType, resource),
1201
1210
  };
1202
1211
  break;
1203
1212
  case ResourceTag.appLink:
1204
1213
  resourceJson = {
1205
1214
  type: ResourceTag.appLink,
1206
- appLink: this.addAppLinkResource(resource),
1215
+ appLink: this.addAppLinkResource(bitType, resource),
1207
1216
  };
1208
1217
  break;
1209
1218
  case ResourceTag.websiteLink:
1210
1219
  resourceJson = {
1211
1220
  type: ResourceTag.websiteLink,
1212
- websiteLink: this.addWebsiteLinkResource(resource),
1221
+ websiteLink: this.addWebsiteLinkResource(bitType, resource),
1213
1222
  };
1214
1223
  break;
1215
1224
  default:
1216
1225
  }
1217
1226
  return resourceJson;
1218
1227
  }
1219
- addImageResource(resource) {
1228
+ addImageResource(bitType, resource) {
1220
1229
  var _a, _b, _c;
1221
1230
  const resourceJson = {};
1222
1231
  if (StringUtils.isString(resource)) {
@@ -1247,10 +1256,11 @@ class JsonGenerator {
1247
1256
  resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
1248
1257
  resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
1249
1258
  resourceJson.alt = (_c = Breakscape.unbreakscape(resource.alt)) !== null && _c !== void 0 ? _c : '';
1250
- this.addGenericResourceProperties(resource, resourceJson);
1259
+ resourceJson.zoomDisabled = this.getZoomDisabled(bitType, resource.zoomDisabled);
1260
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1251
1261
  return resourceJson;
1252
1262
  }
1253
- addImageLinkResource(resource) {
1263
+ addImageLinkResource(bitType, resource) {
1254
1264
  var _a, _b, _c;
1255
1265
  const resourceJson = {};
1256
1266
  if (StringUtils.isString(resource)) {
@@ -1281,10 +1291,11 @@ class JsonGenerator {
1281
1291
  resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
1282
1292
  resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
1283
1293
  resourceJson.alt = (_c = Breakscape.unbreakscape(resource.alt)) !== null && _c !== void 0 ? _c : '';
1284
- this.addGenericResourceProperties(resource, resourceJson);
1294
+ resourceJson.zoomDisabled = this.getZoomDisabled(bitType, resource.zoomDisabled);
1295
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1285
1296
  return resourceJson;
1286
1297
  }
1287
- addAudioResource(resource) {
1298
+ addAudioResource(bitType, resource) {
1288
1299
  const resourceJson = {};
1289
1300
  if (resource.format != null)
1290
1301
  resourceJson.format = Breakscape.unbreakscape(resource.format);
@@ -1298,10 +1309,10 @@ class JsonGenerator {
1298
1309
  resourceJson.mute = resource.mute;
1299
1310
  if (resource.autoplay != null)
1300
1311
  resourceJson.autoplay = resource.autoplay;
1301
- this.addGenericResourceProperties(resource, resourceJson);
1312
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1302
1313
  return resourceJson;
1303
1314
  }
1304
- addAudioEmbedResource(resource) {
1315
+ addAudioEmbedResource(bitType, resource) {
1305
1316
  const resourceJson = {};
1306
1317
  if (resource.format != null)
1307
1318
  resourceJson.format = Breakscape.unbreakscape(resource.format);
@@ -1315,10 +1326,10 @@ class JsonGenerator {
1315
1326
  resourceJson.mute = resource.mute;
1316
1327
  if (resource.autoplay != null)
1317
1328
  resourceJson.autoplay = resource.autoplay;
1318
- this.addGenericResourceProperties(resource, resourceJson);
1329
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1319
1330
  return resourceJson;
1320
1331
  }
1321
- addAudioLinkResource(resource) {
1332
+ addAudioLinkResource(bitType, resource) {
1322
1333
  const resourceJson = {};
1323
1334
  if (resource.format != null)
1324
1335
  resourceJson.format = Breakscape.unbreakscape(resource.format);
@@ -1332,10 +1343,10 @@ class JsonGenerator {
1332
1343
  resourceJson.mute = resource.mute;
1333
1344
  if (resource.autoplay != null)
1334
1345
  resourceJson.autoplay = resource.autoplay;
1335
- this.addGenericResourceProperties(resource, resourceJson, true);
1346
+ this.addGenericResourceProperties(bitType, resource, resourceJson, true);
1336
1347
  return resourceJson;
1337
1348
  }
1338
- addVideoResource(resource) {
1349
+ addVideoResource(bitType, resource) {
1339
1350
  var _a, _b;
1340
1351
  const resourceJson = {};
1341
1352
  if (resource.format != null)
@@ -1359,17 +1370,17 @@ class JsonGenerator {
1359
1370
  if (resource.alt != null)
1360
1371
  resourceJson.alt = Breakscape.unbreakscape(resource.alt);
1361
1372
  if (resource.posterImage != null)
1362
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1373
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1363
1374
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1364
1375
  resourceJson.thumbnails = [];
1365
1376
  for (const thumbnail of resource.thumbnails) {
1366
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1377
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1367
1378
  }
1368
1379
  }
1369
- this.addGenericResourceProperties(resource, resourceJson);
1380
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1370
1381
  return resourceJson;
1371
1382
  }
1372
- addVideoEmbedResource(resource) {
1383
+ addVideoEmbedResource(bitType, resource) {
1373
1384
  var _a, _b;
1374
1385
  const resourceJson = {};
1375
1386
  if (resource.format != null)
@@ -1393,17 +1404,17 @@ class JsonGenerator {
1393
1404
  if (resource.alt != null)
1394
1405
  resourceJson.alt = Breakscape.unbreakscape(resource.alt);
1395
1406
  if (resource.posterImage != null)
1396
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1407
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1397
1408
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1398
1409
  resourceJson.thumbnails = [];
1399
1410
  for (const thumbnail of resource.thumbnails) {
1400
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1411
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1401
1412
  }
1402
1413
  }
1403
- this.addGenericResourceProperties(resource, resourceJson);
1414
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1404
1415
  return resourceJson;
1405
1416
  }
1406
- addVideoLinkResource(resource) {
1417
+ addVideoLinkResource(bitType, resource) {
1407
1418
  var _a, _b;
1408
1419
  const resourceJson = {};
1409
1420
  if (resource.format != null)
@@ -1427,17 +1438,17 @@ class JsonGenerator {
1427
1438
  if (resource.alt != null)
1428
1439
  resourceJson.alt = Breakscape.unbreakscape(resource.alt);
1429
1440
  if (resource.posterImage != null)
1430
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1441
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1431
1442
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1432
1443
  resourceJson.thumbnails = [];
1433
1444
  for (const thumbnail of resource.thumbnails) {
1434
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1445
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1435
1446
  }
1436
1447
  }
1437
- this.addGenericResourceProperties(resource, resourceJson);
1448
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1438
1449
  return resourceJson;
1439
1450
  }
1440
- addStillImageFilmEmbedResource(resource) {
1451
+ addStillImageFilmEmbedResource(bitType, resource) {
1441
1452
  var _a, _b;
1442
1453
  const resourceJson = {};
1443
1454
  if (resource.format != null)
@@ -1461,17 +1472,17 @@ class JsonGenerator {
1461
1472
  if (resource.alt != null)
1462
1473
  resourceJson.alt = Breakscape.unbreakscape(resource.alt);
1463
1474
  if (resource.posterImage != null)
1464
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1475
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1465
1476
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1466
1477
  resourceJson.thumbnails = [];
1467
1478
  for (const thumbnail of resource.thumbnails) {
1468
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1479
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1469
1480
  }
1470
1481
  }
1471
- this.addGenericResourceProperties(resource, resourceJson);
1482
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1472
1483
  return resourceJson;
1473
1484
  }
1474
- addStillImageFilmLinkResource(resource) {
1485
+ addStillImageFilmLinkResource(bitType, resource) {
1475
1486
  var _a, _b;
1476
1487
  const resourceJson = {};
1477
1488
  if (resource.format != null)
@@ -1495,17 +1506,17 @@ class JsonGenerator {
1495
1506
  if (resource.alt != null)
1496
1507
  resourceJson.alt = Breakscape.unbreakscape(resource.alt);
1497
1508
  if (resource.posterImage != null)
1498
- resourceJson.posterImage = this.addImageResource(resource.posterImage);
1509
+ resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
1499
1510
  if (resource.thumbnails != null && resource.thumbnails.length > 0) {
1500
1511
  resourceJson.thumbnails = [];
1501
1512
  for (const thumbnail of resource.thumbnails) {
1502
- resourceJson.thumbnails.push(this.addImageResource(thumbnail));
1513
+ resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
1503
1514
  }
1504
1515
  }
1505
- this.addGenericResourceProperties(resource, resourceJson);
1516
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1506
1517
  return resourceJson;
1507
1518
  }
1508
- addArticleResource(resource) {
1519
+ addArticleResource(bitType, resource) {
1509
1520
  const resourceJson = {};
1510
1521
  if (resource.format != null)
1511
1522
  resourceJson.format = Breakscape.unbreakscape(resource.format);
@@ -1514,10 +1525,10 @@ class JsonGenerator {
1514
1525
  if (resource.value != null)
1515
1526
  resourceJson.body = Breakscape.unbreakscape(resource.value);
1516
1527
  // if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
1517
- this.addGenericResourceProperties(resource, resourceJson);
1528
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1518
1529
  return resourceJson;
1519
1530
  }
1520
- addDocumentResource(resource) {
1531
+ addDocumentResource(bitType, resource) {
1521
1532
  const resourceJson = {};
1522
1533
  if (resource.format != null)
1523
1534
  resourceJson.format = Breakscape.unbreakscape(resource.format);
@@ -1526,10 +1537,10 @@ class JsonGenerator {
1526
1537
  if (resource.value != null)
1527
1538
  resourceJson.url = Breakscape.unbreakscape(resource.value);
1528
1539
  // if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
1529
- this.addGenericResourceProperties(resource, resourceJson);
1540
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1530
1541
  return resourceJson;
1531
1542
  }
1532
- addDocumentEmbedResource(resource) {
1543
+ addDocumentEmbedResource(bitType, resource) {
1533
1544
  const resourceJson = {};
1534
1545
  if (resource.format != null)
1535
1546
  resourceJson.format = Breakscape.unbreakscape(resource.format);
@@ -1538,10 +1549,10 @@ class JsonGenerator {
1538
1549
  if (resource.value != null)
1539
1550
  resourceJson.url = Breakscape.unbreakscape(resource.value);
1540
1551
  // if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
1541
- this.addGenericResourceProperties(resource, resourceJson);
1552
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1542
1553
  return resourceJson;
1543
1554
  }
1544
- addDocumentLinkResource(resource) {
1555
+ addDocumentLinkResource(bitType, resource) {
1545
1556
  const resourceJson = {};
1546
1557
  if (resource.format != null)
1547
1558
  resourceJson.format = Breakscape.unbreakscape(resource.format);
@@ -1550,10 +1561,10 @@ class JsonGenerator {
1550
1561
  if (resource.value != null)
1551
1562
  resourceJson.url = Breakscape.unbreakscape(resource.value);
1552
1563
  // if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
1553
- this.addGenericResourceProperties(resource, resourceJson);
1564
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1554
1565
  return resourceJson;
1555
1566
  }
1556
- addDocumentDownloadResource(resource) {
1567
+ addDocumentDownloadResource(bitType, resource) {
1557
1568
  const resourceJson = {};
1558
1569
  if (resource.format != null)
1559
1570
  resourceJson.format = Breakscape.unbreakscape(resource.format);
@@ -1562,28 +1573,28 @@ class JsonGenerator {
1562
1573
  if (resource.value != null)
1563
1574
  resourceJson.url = Breakscape.unbreakscape(resource.value);
1564
1575
  // if (resource.href != null) resourceJson.href = resource.href; // It is never used (and doesn't exist in the AST model)
1565
- this.addGenericResourceProperties(resource, resourceJson);
1576
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1566
1577
  return resourceJson;
1567
1578
  }
1568
- addAppLinkResource(resource) {
1579
+ addAppLinkResource(bitType, resource) {
1569
1580
  const resourceJson = {};
1570
1581
  // if (resource.format != null) resourceJson.format = BreakscapeUtils.unbreakscape(resource.format);
1571
1582
  if (resource.value != null)
1572
1583
  resourceJson.url = Breakscape.unbreakscape(resource.value);
1573
- this.addGenericResourceProperties(resource, resourceJson);
1584
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1574
1585
  return resourceJson;
1575
1586
  }
1576
- addWebsiteLinkResource(resource) {
1587
+ addWebsiteLinkResource(bitType, resource) {
1577
1588
  const resourceJson = {};
1578
1589
  // if (resource.format != null) resourceJson.format = BreakscapeUtils.unbreakscape(resource.format);
1579
1590
  if (resource.value != null)
1580
1591
  resourceJson.url = Breakscape.unbreakscape(resource.value);
1581
1592
  if (resource.siteName != null)
1582
1593
  resourceJson.siteName = Breakscape.unbreakscape(resource.siteName);
1583
- this.addGenericResourceProperties(resource, resourceJson);
1594
+ this.addGenericResourceProperties(bitType, resource, resourceJson);
1584
1595
  return resourceJson;
1585
1596
  }
1586
- addGenericResourceProperties(resource, resourceJson, noDefaults) {
1597
+ addGenericResourceProperties(_bitType, resource, resourceJson, noDefaults) {
1587
1598
  var _a, _b, _c, _d, _e, _f, _g, _h;
1588
1599
  if (noDefaults) {
1589
1600
  if (resource.license != null)
@@ -1663,10 +1674,29 @@ class JsonGenerator {
1663
1674
  // }
1664
1675
  }
1665
1676
  }
1677
+ /**
1678
+ * Get the value for the zoomDisabled property, setting the appropriate default value if no value is set.
1679
+ *
1680
+ * @param bitType
1681
+ * @param zoomDisabled
1682
+ * @returns
1683
+ */
1684
+ getZoomDisabled(bitType, zoomDisabled) {
1685
+ if (zoomDisabled != null)
1686
+ return zoomDisabled;
1687
+ // The default value in the JSON is hardcoded, because there is currently no good way to set a different
1688
+ // default per bit in the BitConfig.
1689
+ switch (bitType.alias) {
1690
+ case AliasBitType.imageSeparator:
1691
+ case AliasBitType.pageBanner:
1692
+ return true;
1693
+ }
1694
+ return false;
1695
+ }
1666
1696
  /**
1667
1697
  * Get the bit type from any node
1668
1698
  *
1669
- * @param route the route to the node
1699
+ * @param route the route to the current node
1670
1700
  * @returns the bit type
1671
1701
  */
1672
1702
  getBitType(route) {
@@ -1681,7 +1711,7 @@ class JsonGenerator {
1681
1711
  /**
1682
1712
  * Get the text format from any node
1683
1713
  *
1684
- * @param route the route to the node
1714
+ * @param route the route to the current node
1685
1715
  * @returns the text format
1686
1716
  */
1687
1717
  getTextFormat(route) {
@@ -1701,7 +1731,7 @@ class JsonGenerator {
1701
1731
  /**
1702
1732
  * Get the bit resourceType atttachment from any node
1703
1733
  *
1704
- * @param route the route to the node
1734
+ * @param route the route to the current node
1705
1735
  * @returns the bit type
1706
1736
  */
1707
1737
  getResourceType(route) {
@@ -1713,6 +1743,24 @@ class JsonGenerator {
1713
1743
  }
1714
1744
  return undefined;
1715
1745
  }
1746
+ /**
1747
+ * Get the internal comments from any node
1748
+ *
1749
+ * @param route the route to the current node
1750
+ * @returns the text format
1751
+ */
1752
+ getInternalComments(route) {
1753
+ const bitType = this.getBitType(route);
1754
+ if (bitType) {
1755
+ for (const node of route) {
1756
+ if (node.key === NodeType.bitsValue) {
1757
+ const n = node.value;
1758
+ return n.internalComment;
1759
+ }
1760
+ }
1761
+ }
1762
+ return undefined;
1763
+ }
1716
1764
  /**
1717
1765
  * Convert the text from the AST to the JSON format:
1718
1766
  * Input:
@@ -1807,6 +1855,7 @@ class JsonGenerator {
1807
1855
  format: bit.textFormat,
1808
1856
  // Properties
1809
1857
  id: undefined,
1858
+ internalComment: undefined,
1810
1859
  externalId: undefined,
1811
1860
  spaceId: undefined,
1812
1861
  padletId: undefined,
@@ -2142,6 +2191,8 @@ class JsonGenerator {
2142
2191
  // Properties
2143
2192
  if (bitJson.id == null)
2144
2193
  delete bitJson.id;
2194
+ if (bitJson.internalComment == null)
2195
+ delete bitJson.internalComment;
2145
2196
  if (bitJson.externalId == null)
2146
2197
  delete bitJson.externalId;
2147
2198
  if (bitJson.spaceId == null)