@gmb/bitmark-parser-generator 1.4.16 → 1.4.18

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 (226) 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/BitmarkParserGenerator.js +2 -13
  4. package/dist/cjs/BitmarkParserGenerator.js.map +1 -1
  5. package/dist/cjs/ast/Builder.js +8 -8
  6. package/dist/cjs/ast/Builder.js.map +1 -1
  7. package/dist/cjs/ast/rules/NodeValidator.js +6 -23
  8. package/dist/cjs/ast/rules/NodeValidator.js.map +1 -1
  9. package/dist/cjs/config/Config.js +57 -86
  10. package/dist/cjs/config/Config.js.map +1 -1
  11. package/dist/cjs/config/raw/bits.js +388 -450
  12. package/dist/cjs/config/raw/bits.js.map +1 -1
  13. package/dist/cjs/config/raw/properties.js +37 -0
  14. package/dist/cjs/config/raw/properties.js.map +1 -1
  15. package/dist/cjs/generated/build-info.js +1 -1
  16. package/dist/cjs/generator/bitmark/BitmarkGenerator.js +9 -11
  17. package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
  18. package/dist/cjs/generator/json/JsonGenerator.js +236 -208
  19. package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
  20. package/dist/cjs/index.js +2 -3
  21. package/dist/cjs/index.js.map +1 -1
  22. package/dist/cjs/info/InfoBuilder.js +10 -33
  23. package/dist/cjs/info/InfoBuilder.js.map +1 -1
  24. package/dist/cjs/model/ast/NodeType.js +16 -0
  25. package/dist/cjs/model/ast/NodeType.js.map +1 -1
  26. package/dist/cjs/model/config/BitConfig.js +8 -7
  27. package/dist/cjs/model/config/BitConfig.js.map +1 -1
  28. package/dist/cjs/model/config/enum/PropertyConfigKey.js +7 -0
  29. package/dist/cjs/model/config/enum/PropertyConfigKey.js.map +1 -1
  30. package/dist/cjs/model/enum/BitType.js +86 -84
  31. package/dist/cjs/model/enum/BitType.js.map +1 -1
  32. package/dist/cjs/model/enum/PropertyAstKey.js +2 -0
  33. package/dist/cjs/model/enum/PropertyAstKey.js.map +1 -1
  34. package/dist/cjs/model/enum/PropertyTag.js +5 -0
  35. package/dist/cjs/model/enum/PropertyTag.js.map +1 -1
  36. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js +14 -14
  37. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
  38. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js +6 -6
  39. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
  40. package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
  41. package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +11 -10
  42. package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
  43. package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
  44. package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
  45. package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +52 -47
  46. package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
  47. package/dist/cjs/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
  48. package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
  49. package/dist/cjs/parser/bitmark/peg/contentProcessors/{CommentTagContentProcessor.js → InternalCommentTagContentProcessor.js} +5 -5
  50. package/dist/cjs/parser/bitmark/peg/contentProcessors/InternalCommentTagContentProcessor.js.map +1 -0
  51. package/dist/cjs/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
  52. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
  53. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
  54. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.js.map +1 -1
  55. package/dist/cjs/parser/bitmark/peg/contentProcessors/PartnerChainContentProcessor.js.map +1 -1
  56. package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +2 -2
  57. package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
  58. package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
  59. package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
  60. package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +15 -17
  61. package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
  62. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +14 -11
  63. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
  64. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
  65. package/dist/cjs/parser/json/JsonParser.js +9 -9
  66. package/dist/cjs/parser/json/JsonParser.js.map +1 -1
  67. package/dist/cjs/utils/ObjectUtils.js +62 -0
  68. package/dist/cjs/utils/ObjectUtils.js.map +1 -1
  69. package/dist/esm/BitmarkParserGenerator.js +2 -13
  70. package/dist/esm/BitmarkParserGenerator.js.map +1 -1
  71. package/dist/esm/ast/Builder.js +9 -9
  72. package/dist/esm/ast/Builder.js.map +1 -1
  73. package/dist/esm/ast/rules/NodeValidator.js +6 -23
  74. package/dist/esm/ast/rules/NodeValidator.js.map +1 -1
  75. package/dist/esm/config/Config.js +57 -86
  76. package/dist/esm/config/Config.js.map +1 -1
  77. package/dist/esm/config/raw/bits.js +389 -451
  78. package/dist/esm/config/raw/bits.js.map +1 -1
  79. package/dist/esm/config/raw/properties.js +37 -0
  80. package/dist/esm/config/raw/properties.js.map +1 -1
  81. package/dist/esm/generated/build-info.js +1 -1
  82. package/dist/esm/generator/bitmark/BitmarkGenerator.js +10 -12
  83. package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
  84. package/dist/esm/generator/json/JsonGenerator.js +237 -209
  85. package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
  86. package/dist/esm/index.js +1 -1
  87. package/dist/esm/index.js.map +1 -1
  88. package/dist/esm/info/InfoBuilder.js +11 -34
  89. package/dist/esm/info/InfoBuilder.js.map +1 -1
  90. package/dist/esm/model/ast/NodeType.js +16 -0
  91. package/dist/esm/model/ast/NodeType.js.map +1 -1
  92. package/dist/esm/model/config/BitConfig.js +8 -7
  93. package/dist/esm/model/config/BitConfig.js.map +1 -1
  94. package/dist/esm/model/config/enum/PropertyConfigKey.js +7 -0
  95. package/dist/esm/model/config/enum/PropertyConfigKey.js.map +1 -1
  96. package/dist/esm/model/enum/BitType.js +85 -82
  97. package/dist/esm/model/enum/BitType.js.map +1 -1
  98. package/dist/esm/model/enum/PropertyAstKey.js +2 -0
  99. package/dist/esm/model/enum/PropertyAstKey.js.map +1 -1
  100. package/dist/esm/model/enum/PropertyTag.js +5 -0
  101. package/dist/esm/model/enum/PropertyTag.js.map +1 -1
  102. package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js +15 -15
  103. package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
  104. package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js +6 -6
  105. package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
  106. package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
  107. package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +12 -11
  108. package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
  109. package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
  110. package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
  111. package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +53 -48
  112. package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
  113. package/dist/esm/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
  114. package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
  115. package/dist/esm/parser/bitmark/peg/contentProcessors/{CommentTagContentProcessor.js → InternalCommentTagContentProcessor.js} +5 -5
  116. package/dist/esm/parser/bitmark/peg/contentProcessors/InternalCommentTagContentProcessor.js.map +1 -0
  117. package/dist/esm/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
  118. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
  119. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
  120. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.js.map +1 -1
  121. package/dist/esm/parser/bitmark/peg/contentProcessors/PartnerChainContentProcessor.js.map +1 -1
  122. package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +2 -2
  123. package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
  124. package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
  125. package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
  126. package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +16 -18
  127. package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
  128. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +15 -12
  129. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
  130. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
  131. package/dist/esm/parser/json/JsonParser.js +10 -10
  132. package/dist/esm/parser/json/JsonParser.js.map +1 -1
  133. package/dist/esm/utils/ObjectUtils.js +59 -0
  134. package/dist/esm/utils/ObjectUtils.js.map +1 -1
  135. package/dist/types/BitmarkParserGenerator.d.ts.map +1 -1
  136. package/dist/types/ast/Builder.d.ts +9 -2
  137. package/dist/types/ast/Builder.d.ts.map +1 -1
  138. package/dist/types/ast/rules/NodeValidator.d.ts +0 -1
  139. package/dist/types/ast/rules/NodeValidator.d.ts.map +1 -1
  140. package/dist/types/config/Config.d.ts +16 -28
  141. package/dist/types/config/Config.d.ts.map +1 -1
  142. package/dist/types/config/raw/bits.d.ts.map +1 -1
  143. package/dist/types/config/raw/properties.d.ts.map +1 -1
  144. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +4 -4
  145. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
  146. package/dist/types/generator/json/JsonGenerator.d.ts +22 -22
  147. package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
  148. package/dist/types/generator/text/TextGenerator.d.ts +2 -2
  149. package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
  150. package/dist/types/index.d.ts +2 -2
  151. package/dist/types/index.d.ts.map +1 -1
  152. package/dist/types/info/InfoBuilder.d.ts +3 -4
  153. package/dist/types/info/InfoBuilder.d.ts.map +1 -1
  154. package/dist/types/model/ast/NodeType.d.ts +32 -0
  155. package/dist/types/model/ast/NodeType.d.ts.map +1 -1
  156. package/dist/types/model/ast/Nodes.d.ts +9 -2
  157. package/dist/types/model/ast/Nodes.d.ts.map +1 -1
  158. package/dist/types/model/config/BitConfig.d.ts +5 -4
  159. package/dist/types/model/config/BitConfig.d.ts.map +1 -1
  160. package/dist/types/model/config/_Config.d.ts +3 -5
  161. package/dist/types/model/config/_Config.d.ts.map +1 -1
  162. package/dist/types/model/config/enum/ConfigKey.d.ts +14 -0
  163. package/dist/types/model/config/enum/ConfigKey.d.ts.map +1 -1
  164. package/dist/types/model/config/enum/PropertyConfigKey.d.ts +21 -0
  165. package/dist/types/model/config/enum/PropertyConfigKey.d.ts.map +1 -1
  166. package/dist/types/model/enum/BitType.d.ts +171 -178
  167. package/dist/types/model/enum/BitType.d.ts.map +1 -1
  168. package/dist/types/model/enum/PropertyAstKey.d.ts +4 -0
  169. package/dist/types/model/enum/PropertyAstKey.d.ts.map +1 -1
  170. package/dist/types/model/enum/PropertyTag.d.ts +10 -0
  171. package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
  172. package/dist/types/model/json/BitJson.d.ts +5 -0
  173. package/dist/types/model/json/BitJson.d.ts.map +1 -1
  174. package/dist/types/model/json/ParserJson.d.ts +1 -1
  175. package/dist/types/model/json/ParserJson.d.ts.map +1 -1
  176. package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts.map +1 -1
  177. package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts +6 -6
  178. package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts.map +1 -1
  179. package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts +6 -6
  180. package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts.map +1 -1
  181. package/dist/types/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.d.ts +2 -2
  182. package/dist/types/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.d.ts.map +1 -1
  183. package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts +2 -2
  184. package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts.map +1 -1
  185. package/dist/types/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.d.ts +2 -2
  186. package/dist/types/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.d.ts.map +1 -1
  187. package/dist/types/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.d.ts +2 -2
  188. package/dist/types/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.d.ts.map +1 -1
  189. package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts +2 -2
  190. package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts.map +1 -1
  191. package/dist/types/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.d.ts +2 -2
  192. package/dist/types/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.d.ts.map +1 -1
  193. package/dist/types/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.d.ts +2 -2
  194. package/dist/types/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.d.ts.map +1 -1
  195. package/dist/types/parser/bitmark/peg/contentProcessors/InternalCommentTagContentProcessor.d.ts +5 -0
  196. package/dist/types/parser/bitmark/peg/contentProcessors/InternalCommentTagContentProcessor.d.ts.map +1 -0
  197. package/dist/types/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.d.ts +2 -2
  198. package/dist/types/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.d.ts.map +1 -1
  199. package/dist/types/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.d.ts +2 -2
  200. package/dist/types/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.d.ts.map +1 -1
  201. package/dist/types/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.d.ts +2 -2
  202. package/dist/types/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.d.ts.map +1 -1
  203. package/dist/types/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.d.ts +2 -2
  204. package/dist/types/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.d.ts.map +1 -1
  205. package/dist/types/parser/bitmark/peg/contentProcessors/PartnerChainContentProcessor.d.ts +2 -2
  206. package/dist/types/parser/bitmark/peg/contentProcessors/PartnerChainContentProcessor.d.ts.map +1 -1
  207. package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts +2 -2
  208. package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts.map +1 -1
  209. package/dist/types/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.d.ts +2 -2
  210. package/dist/types/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.d.ts.map +1 -1
  211. package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts +3 -3
  212. package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts.map +1 -1
  213. package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts +3 -3
  214. package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts.map +1 -1
  215. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts +2 -2
  216. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts.map +1 -1
  217. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.d.ts +2 -2
  218. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.d.ts.map +1 -1
  219. package/dist/types/parser/json/JsonParser.d.ts.map +1 -1
  220. package/dist/types/utils/ObjectUtils.d.ts +9 -0
  221. package/dist/types/utils/ObjectUtils.d.ts.map +1 -1
  222. package/package.json +3 -1
  223. package/dist/cjs/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.js.map +0 -1
  224. package/dist/esm/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.js.map +0 -1
  225. package/dist/types/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.d.ts +0 -5
  226. package/dist/types/parser/bitmark/peg/contentProcessors/CommentTagContentProcessor.d.ts.map +0 -1
@@ -22,7 +22,7 @@ import { Ast } from '../../ast/Ast';
22
22
  import { Breakscape } from '../../breakscaping/Breakscape';
23
23
  import { Config } from '../../config/Config';
24
24
  import { NodeType } from '../../model/ast/NodeType';
25
- import { AliasBitType, RootBitType } from '../../model/enum/BitType';
25
+ import { BitType } from '../../model/enum/BitType';
26
26
  import { BitmarkVersion, DEFAULT_BITMARK_VERSION } from '../../model/enum/BitmarkVersion';
27
27
  import { BodyBitType } from '../../model/enum/BodyBitType';
28
28
  import { ExampleType } from '../../model/enum/ExampleType';
@@ -218,7 +218,7 @@ class JsonGenerator {
218
218
  if (isBoolean) {
219
219
  // Boolean example
220
220
  defaultExample = true;
221
- if (bit.bitType.root === RootBitType.trueFalse1) {
221
+ if (Config.isOfBitType(bit.bitType, BitType.trueFalse1)) {
222
222
  if (((_b = (_a = bit.cardNode) === null || _a === void 0 ? void 0 : _a.statement) === null || _b === void 0 ? void 0 : _b.isCorrect) !== undefined) {
223
223
  defaultExample = bit.cardNode.statement.isCorrect;
224
224
  }
@@ -336,7 +336,7 @@ class JsonGenerator {
336
336
  return;
337
337
  // Create the listItems / sections if not already created
338
338
  let listItems;
339
- if (bitType.alias === AliasBitType.pageFooter) {
339
+ if (bitType === BitType.pageFooter) {
340
340
  if (!this.bitJson.sections)
341
341
  this.bitJson.sections = [];
342
342
  listItems = this.bitJson.sections;
@@ -943,13 +943,13 @@ class JsonGenerator {
943
943
  excessResources.push(rJson);
944
944
  }
945
945
  }
946
- // Extract comments from the AST and add to the parser
947
- const comments = Breakscape.unbreakscape(this.getInternalComments(route));
946
+ // Extract internal comments from the AST and add to the parser
947
+ const internalComments = Breakscape.unbreakscape(this.getInternalComments(route));
948
948
  if ((parent === null || parent === void 0 ? void 0 : parent.key) === NodeType.bitsValue) {
949
949
  // Bit level parser information
950
950
  this.bitWrapperJson.parser = Object.assign(Object.assign({ version,
951
951
  bitmarkVersion,
952
- comments }, parserRest), { warnings,
952
+ internalComments }, parserRest), { warnings,
953
953
  errors,
954
954
  excessResources });
955
955
  if (!this.options.enableWarnings) {
@@ -1686,9 +1686,9 @@ class JsonGenerator {
1686
1686
  return zoomDisabled;
1687
1687
  // The default value in the JSON is hardcoded, because there is currently no good way to set a different
1688
1688
  // default per bit in the BitConfig.
1689
- switch (bitType.alias) {
1690
- case AliasBitType.imageSeparator:
1691
- case AliasBitType.pageBanner:
1689
+ switch (bitType) {
1690
+ case BitType.imageSeparator:
1691
+ case BitType.pageBanner:
1692
1692
  return true;
1693
1693
  }
1694
1694
  return false;
@@ -1851,7 +1851,7 @@ class JsonGenerator {
1851
1851
  */
1852
1852
  createBitJson(bit) {
1853
1853
  const bitJson = {
1854
- type: bit.bitType.alias,
1854
+ type: bit.bitType,
1855
1855
  format: bit.textFormat,
1856
1856
  // Properties
1857
1857
  id: undefined,
@@ -1889,6 +1889,8 @@ class JsonGenerator {
1889
1889
  thumbImage: undefined,
1890
1890
  focusX: undefined,
1891
1891
  focusY: undefined,
1892
+ pointerLeft: undefined,
1893
+ pointerTop: undefined,
1892
1894
  deeplink: undefined,
1893
1895
  externalLink: undefined,
1894
1896
  externalLinkText: undefined,
@@ -1907,6 +1909,9 @@ class JsonGenerator {
1907
1909
  resolvedDate: undefined,
1908
1910
  resolvedBy: undefined,
1909
1911
  maxCreatedBits: undefined,
1912
+ product: undefined,
1913
+ productVideo: undefined,
1914
+ productFolder: undefined,
1910
1915
  // Book data
1911
1916
  title: undefined,
1912
1917
  subtitle: undefined,
@@ -1985,207 +1990,224 @@ class JsonGenerator {
1985
1990
  // NOTE: Not all bits have the same default properties.
1986
1991
  // The properties used are a bit random sometimes?
1987
1992
  // It would be better if this functionality was generated from the bit config
1988
- switch (bitType.root) {
1989
- case RootBitType._error:
1990
- case RootBitType._comment:
1991
- delete bitJson.format;
1992
- break;
1993
- case RootBitType.article:
1994
- case RootBitType.sampleSolution:
1995
- case RootBitType.page:
1996
- if (bitJson.body == null)
1997
- bitJson.body = this.bodyDefault;
1998
- break;
1999
- default: // Most bits have these defaults, but there are special cases (not sure if that is by error or design)
2000
- if (bitJson.item == null)
2001
- bitJson.item = this.textDefault;
2002
- if (bitJson.hint == null)
2003
- bitJson.hint = this.textDefault;
2004
- if (bitJson.isExample == null)
2005
- bitJson.isExample = false;
2006
- if (bitJson.example == null)
2007
- bitJson.example = null;
2008
- if (bitJson.body == null)
2009
- bitJson.body = this.bodyDefault;
2010
- // Special case for 'ai' bits
2011
- if (bitType.alias === AliasBitType.articleAi ||
2012
- bitType.alias === AliasBitType.noteAi ||
2013
- bitType.alias === AliasBitType.summaryAi) {
2014
- if (bitJson.AIGenerated == null)
2015
- bitJson.AIGenerated = true;
2016
- }
2017
- // Special case for 'review-...' bits
2018
- if (bitType.root === RootBitType.reviewNote) {
2019
- if (bitJson.resolved == null)
2020
- bitJson.resolved = false;
2021
- if (bitJson.resolvedDate == null)
2022
- bitJson.resolvedDate = '';
2023
- if (bitJson.resolvedBy == null)
2024
- bitJson.resolvedBy = '';
2025
- }
2026
- break;
1993
+ if (Config.isOfBitType(bitType, [BitType._error, BitType._comment])) {
1994
+ //
1995
+ delete bitJson.format;
1996
+ //
1997
+ }
1998
+ else if (Config.isOfBitType(bitType, [BitType.article, BitType.sampleSolution, BitType.page])) {
1999
+ //
2000
+ if (bitJson.body == null)
2001
+ bitJson.body = this.bodyDefault;
2002
+ //
2003
+ }
2004
+ else if (Config.isOfBitType(bitType, [
2005
+ BitType.cloze,
2006
+ BitType.multipleChoice1,
2007
+ BitType.multipleResponse1,
2008
+ BitType.multipleChoiceText,
2009
+ BitType.highlightText,
2010
+ BitType.clozeAndMultipleChoiceText,
2011
+ BitType.sequence,
2012
+ BitType.mark,
2013
+ BitType.flashcard,
2014
+ ])) {
2027
2015
  // Default, but with no 'example' at the bit level.
2028
- case RootBitType.cloze:
2029
- case RootBitType.multipleChoice1:
2030
- case RootBitType.multipleResponse1:
2031
- case RootBitType.multipleChoiceText:
2032
- case RootBitType.highlightText:
2033
- case RootBitType.clozeAndMultipleChoiceText:
2034
- case RootBitType.sequence:
2035
- case RootBitType.mark:
2036
- case RootBitType.flashcard:
2037
- if (bitJson.item == null)
2038
- bitJson.item = this.textDefault;
2039
- if (bitJson.hint == null)
2040
- bitJson.hint = this.textDefault;
2041
- if (bitJson.instruction == null)
2042
- bitJson.instruction = this.textDefault;
2043
- if (bitJson.isExample == null)
2044
- bitJson.isExample = false;
2045
- if (bitJson.body == null)
2046
- bitJson.body = this.bodyDefault;
2047
- break;
2016
+ if (bitJson.item == null)
2017
+ bitJson.item = this.textDefault;
2018
+ if (bitJson.hint == null)
2019
+ bitJson.hint = this.textDefault;
2020
+ if (bitJson.instruction == null)
2021
+ bitJson.instruction = this.textDefault;
2022
+ if (bitJson.isExample == null)
2023
+ bitJson.isExample = false;
2024
+ if (bitJson.body == null)
2025
+ bitJson.body = this.bodyDefault;
2026
+ //
2027
+ }
2028
+ else if (Config.isOfBitType(bitType, [BitType.multipleChoice, BitType.multipleResponse])) {
2048
2029
  // Default with a card (and hence a footer possibility)
2049
- case RootBitType.multipleChoice:
2050
- case RootBitType.multipleResponse:
2051
- if (bitJson.item == null)
2052
- bitJson.item = this.textDefault;
2053
- if (bitJson.hint == null)
2054
- bitJson.hint = this.textDefault;
2055
- if (bitJson.instruction == null)
2056
- bitJson.instruction = this.textDefault;
2057
- if (bitJson.isExample == null)
2058
- bitJson.isExample = false;
2059
- if (bitJson.body == null)
2060
- bitJson.body = this.bodyDefault;
2061
- if (bitJson.footer == null)
2062
- bitJson.footer = this.textDefault;
2063
- break;
2064
- case RootBitType.essay:
2065
- if (bitJson.item == null)
2066
- bitJson.item = this.textDefault;
2067
- if (bitJson.hint == null)
2068
- bitJson.hint = this.textDefault;
2069
- if (bitJson.instruction == null)
2070
- bitJson.instruction = this.textDefault;
2071
- if (bitJson.isExample == null)
2072
- bitJson.isExample = false;
2073
- if (bitJson.example == null)
2074
- bitJson.example = null;
2075
- if (bitJson.body == null)
2076
- bitJson.body = this.bodyDefault;
2077
- if (bitJson.partialAnswer == null)
2078
- bitJson.partialAnswer = '';
2079
- // if (bitJson.sampleSolution == null) bitJson.sampleSolution = '';
2080
- break;
2081
- case RootBitType.trueFalse1:
2082
- if (bitJson.item == null)
2083
- bitJson.item = this.textDefault;
2084
- if (bitJson.lead == null)
2085
- bitJson.lead = this.textDefault;
2086
- if (bitJson.hint == null)
2087
- bitJson.hint = this.textDefault;
2088
- if (bitJson.instruction == null)
2089
- bitJson.instruction = this.textDefault;
2090
- if (bitJson.isExample == null)
2091
- bitJson.isExample = false;
2092
- if (bitJson.example == null)
2093
- bitJson.example = null;
2094
- if (bitJson.isCorrect == null)
2095
- bitJson.isCorrect = false;
2096
- if (bitJson.body == null)
2097
- bitJson.body = this.bodyDefault;
2098
- break;
2099
- case RootBitType.trueFalse:
2100
- if (bitJson.item == null)
2101
- bitJson.item = this.textDefault;
2102
- if (bitJson.lead == null)
2103
- bitJson.lead = this.textDefault;
2104
- if (bitJson.hint == null)
2105
- bitJson.hint = this.textDefault;
2106
- if (bitJson.instruction == null)
2107
- bitJson.instruction = this.textDefault;
2108
- if (bitJson.isExample == null)
2109
- bitJson.isExample = false;
2110
- if (bitJson.labelFalse == null)
2111
- bitJson.labelFalse = '';
2112
- if (bitJson.labelTrue == null)
2113
- bitJson.labelTrue = '';
2114
- if (bitJson.body == null)
2115
- bitJson.body = this.bodyDefault;
2116
- break;
2117
- case RootBitType.chapter:
2118
- if (bitJson.item == null)
2119
- bitJson.item = this.textDefault;
2120
- if (bitJson.hint == null)
2121
- bitJson.hint = this.textDefault;
2122
- if (bitJson.isExample == null)
2123
- bitJson.isExample = false;
2124
- if (bitJson.example == null)
2125
- bitJson.example = null;
2126
- if (bitJson.toc == null)
2127
- bitJson.toc = true; // Always set on chapter bits?
2128
- if (bitJson.progress == null)
2129
- bitJson.progress = true; // Always set on chapter bits
2130
- if (bitJson.level == null)
2131
- bitJson.level = 1; // Set level 1 if none set (makes no sense, but in ANTLR parser)
2132
- if (bitJson.body == null)
2133
- bitJson.body = this.bodyDefault;
2134
- break;
2135
- case RootBitType.interview:
2136
- if (bitJson.item == null)
2137
- bitJson.item = this.textDefault;
2138
- if (bitJson.hint == null)
2139
- bitJson.hint = this.textDefault;
2140
- if (bitJson.instruction == null)
2141
- bitJson.instruction = this.textDefault;
2142
- if (bitJson.isExample == null)
2143
- bitJson.isExample = false;
2144
- if (bitJson.body == null)
2145
- bitJson.body = this.bodyDefault;
2146
- if (bitJson.footer == null)
2147
- bitJson.footer = this.textDefault;
2148
- if (bitJson.questions == null)
2149
- bitJson.questions = [];
2150
- break;
2151
- case RootBitType.match:
2152
- if (bitJson.item == null)
2153
- bitJson.item = this.textDefault;
2154
- if (bitJson.heading == null)
2155
- bitJson.heading = {};
2156
- if (bitJson.body == null)
2157
- bitJson.body = this.bodyDefault;
2158
- break;
2159
- case RootBitType.matchMatrix:
2160
- if (bitJson.item == null)
2161
- bitJson.item = this.textDefault;
2162
- if (bitJson.body == null)
2163
- bitJson.body = this.bodyDefault;
2164
- break;
2165
- case RootBitType.learningPathBook:
2166
- case RootBitType.learningPathExternalLink:
2167
- case RootBitType.learningPathVideoCall:
2168
- if (bitJson.item == null)
2169
- bitJson.item = this.textDefault;
2170
- if (bitJson.hint == null)
2171
- bitJson.hint = this.textDefault;
2172
- if (bitJson.isExample == null)
2173
- bitJson.isExample = false;
2174
- if (bitJson.example == null)
2175
- bitJson.example = null;
2176
- if (bitJson.isTracked == null)
2177
- bitJson.isTracked = true;
2178
- if (bitJson.isInfoOnly == null)
2179
- bitJson.isInfoOnly = false;
2180
- if (bitJson.body == null)
2181
- bitJson.body = this.bodyDefault;
2182
- break;
2183
- case RootBitType.pageBuyButton:
2184
- if (bitJson.content2Buy == null)
2185
- bitJson.content2Buy = '';
2186
- if (bitJson.body == null)
2187
- bitJson.body = this.bodyDefault;
2188
- break;
2030
+ if (bitJson.item == null)
2031
+ bitJson.item = this.textDefault;
2032
+ if (bitJson.hint == null)
2033
+ bitJson.hint = this.textDefault;
2034
+ if (bitJson.instruction == null)
2035
+ bitJson.instruction = this.textDefault;
2036
+ if (bitJson.isExample == null)
2037
+ bitJson.isExample = false;
2038
+ if (bitJson.body == null)
2039
+ bitJson.body = this.bodyDefault;
2040
+ if (bitJson.footer == null)
2041
+ bitJson.footer = this.textDefault;
2042
+ //
2043
+ }
2044
+ else if (Config.isOfBitType(bitType, BitType.essay)) {
2045
+ //
2046
+ if (bitJson.item == null)
2047
+ bitJson.item = this.textDefault;
2048
+ if (bitJson.hint == null)
2049
+ bitJson.hint = this.textDefault;
2050
+ if (bitJson.instruction == null)
2051
+ bitJson.instruction = this.textDefault;
2052
+ if (bitJson.isExample == null)
2053
+ bitJson.isExample = false;
2054
+ if (bitJson.example == null)
2055
+ bitJson.example = null;
2056
+ if (bitJson.body == null)
2057
+ bitJson.body = this.bodyDefault;
2058
+ if (bitJson.partialAnswer == null)
2059
+ bitJson.partialAnswer = '';
2060
+ // if (bitJson.sampleSolution == null) bitJson.sampleSolution = '';
2061
+ //
2062
+ }
2063
+ else if (Config.isOfBitType(bitType, BitType.trueFalse1)) {
2064
+ //
2065
+ if (bitJson.item == null)
2066
+ bitJson.item = this.textDefault;
2067
+ if (bitJson.lead == null)
2068
+ bitJson.lead = this.textDefault;
2069
+ if (bitJson.hint == null)
2070
+ bitJson.hint = this.textDefault;
2071
+ if (bitJson.instruction == null)
2072
+ bitJson.instruction = this.textDefault;
2073
+ if (bitJson.isExample == null)
2074
+ bitJson.isExample = false;
2075
+ if (bitJson.example == null)
2076
+ bitJson.example = null;
2077
+ if (bitJson.isCorrect == null)
2078
+ bitJson.isCorrect = false;
2079
+ if (bitJson.body == null)
2080
+ bitJson.body = this.bodyDefault;
2081
+ //
2082
+ }
2083
+ else if (Config.isOfBitType(bitType, BitType.trueFalse)) {
2084
+ //
2085
+ if (bitJson.item == null)
2086
+ bitJson.item = this.textDefault;
2087
+ if (bitJson.lead == null)
2088
+ bitJson.lead = this.textDefault;
2089
+ if (bitJson.hint == null)
2090
+ bitJson.hint = this.textDefault;
2091
+ if (bitJson.instruction == null)
2092
+ bitJson.instruction = this.textDefault;
2093
+ if (bitJson.isExample == null)
2094
+ bitJson.isExample = false;
2095
+ if (bitJson.labelFalse == null)
2096
+ bitJson.labelFalse = '';
2097
+ if (bitJson.labelTrue == null)
2098
+ bitJson.labelTrue = '';
2099
+ if (bitJson.body == null)
2100
+ bitJson.body = this.bodyDefault;
2101
+ //
2102
+ }
2103
+ else if (Config.isOfBitType(bitType, BitType.chapter)) {
2104
+ //
2105
+ if (bitJson.item == null)
2106
+ bitJson.item = this.textDefault;
2107
+ if (bitJson.hint == null)
2108
+ bitJson.hint = this.textDefault;
2109
+ if (bitJson.isExample == null)
2110
+ bitJson.isExample = false;
2111
+ if (bitJson.example == null)
2112
+ bitJson.example = null;
2113
+ if (bitJson.toc == null)
2114
+ bitJson.toc = true; // Always set on chapter bits?
2115
+ if (bitJson.progress == null)
2116
+ bitJson.progress = true; // Always set on chapter bits
2117
+ if (bitJson.level == null)
2118
+ bitJson.level = 1; // Set level 1 if none set (makes no sense, but in ANTLR parser)
2119
+ if (bitJson.body == null)
2120
+ bitJson.body = this.bodyDefault;
2121
+ //
2122
+ }
2123
+ else if (Config.isOfBitType(bitType, BitType.interview)) {
2124
+ //
2125
+ if (bitJson.item == null)
2126
+ bitJson.item = this.textDefault;
2127
+ if (bitJson.hint == null)
2128
+ bitJson.hint = this.textDefault;
2129
+ if (bitJson.instruction == null)
2130
+ bitJson.instruction = this.textDefault;
2131
+ if (bitJson.isExample == null)
2132
+ bitJson.isExample = false;
2133
+ if (bitJson.body == null)
2134
+ bitJson.body = this.bodyDefault;
2135
+ if (bitJson.footer == null)
2136
+ bitJson.footer = this.textDefault;
2137
+ if (bitJson.questions == null)
2138
+ bitJson.questions = [];
2139
+ //
2140
+ }
2141
+ else if (bitType === BitType.matchMatrix) {
2142
+ //
2143
+ if (bitJson.item == null)
2144
+ bitJson.item = this.textDefault;
2145
+ if (bitJson.body == null)
2146
+ bitJson.body = this.bodyDefault;
2147
+ //
2148
+ }
2149
+ else if (Config.isOfBitType(bitType, BitType.match)) {
2150
+ //
2151
+ if (bitJson.item == null)
2152
+ bitJson.item = this.textDefault;
2153
+ if (bitJson.heading == null)
2154
+ bitJson.heading = {};
2155
+ if (bitJson.body == null)
2156
+ bitJson.body = this.bodyDefault;
2157
+ //
2158
+ }
2159
+ else if (Config.isOfBitType(bitType, BitType.learningPathBook)) {
2160
+ //
2161
+ if (bitJson.item == null)
2162
+ bitJson.item = this.textDefault;
2163
+ if (bitJson.hint == null)
2164
+ bitJson.hint = this.textDefault;
2165
+ if (bitJson.isExample == null)
2166
+ bitJson.isExample = false;
2167
+ if (bitJson.example == null)
2168
+ bitJson.example = null;
2169
+ if (bitJson.isTracked == null)
2170
+ bitJson.isTracked = true;
2171
+ if (bitJson.isInfoOnly == null)
2172
+ bitJson.isInfoOnly = false;
2173
+ if (bitJson.body == null)
2174
+ bitJson.body = this.bodyDefault;
2175
+ //
2176
+ }
2177
+ else if (Config.isOfBitType(bitType, BitType.pageBuyButton)) {
2178
+ //
2179
+ if (bitJson.content2Buy == null)
2180
+ bitJson.content2Buy = '';
2181
+ if (bitJson.body == null)
2182
+ bitJson.body = this.bodyDefault;
2183
+ //
2184
+ }
2185
+ else {
2186
+ // Most bits have these defaults, but there are special cases (not sure if that is by error or design)
2187
+ if (bitJson.item == null)
2188
+ bitJson.item = this.textDefault;
2189
+ if (bitJson.hint == null)
2190
+ bitJson.hint = this.textDefault;
2191
+ if (bitJson.isExample == null)
2192
+ bitJson.isExample = false;
2193
+ if (bitJson.example == null)
2194
+ bitJson.example = null;
2195
+ if (bitJson.body == null)
2196
+ bitJson.body = this.bodyDefault;
2197
+ // Special case for 'ai' bits
2198
+ if (bitType === BitType.articleAi || bitType === BitType.noteAi || bitType === BitType.summaryAi) {
2199
+ if (bitJson.AIGenerated == null)
2200
+ bitJson.AIGenerated = true;
2201
+ }
2202
+ // Special case for 'review-...' bits
2203
+ if (Config.isOfBitType(bitType, BitType.reviewNote)) {
2204
+ if (bitJson.resolved == null)
2205
+ bitJson.resolved = false;
2206
+ if (bitJson.resolvedDate == null)
2207
+ bitJson.resolvedDate = '';
2208
+ if (bitJson.resolvedBy == null)
2209
+ bitJson.resolvedBy = '';
2210
+ }
2189
2211
  }
2190
2212
  // Remove unwanted properties
2191
2213
  // Properties
@@ -2289,6 +2311,12 @@ class JsonGenerator {
2289
2311
  delete bitJson.resolvedBy;
2290
2312
  if (bitJson.maxCreatedBits == null)
2291
2313
  delete bitJson.maxCreatedBits;
2314
+ if (bitJson.product == null)
2315
+ delete bitJson.product;
2316
+ if (bitJson.productVideo == null)
2317
+ delete bitJson.productVideo;
2318
+ if (bitJson.productFolder == null)
2319
+ delete bitJson.productFolder;
2292
2320
  // Book data
2293
2321
  if (bitJson.title == null)
2294
2322
  delete bitJson.title;