@gmb/bitmark-parser-generator 1.35.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/bitmark-parser-generator.min.js +1 -1
- package/dist/browser/bundle-report.html +2 -2
- package/dist/cjs/BitmarkParserGenerator.js +8 -3
- package/dist/cjs/BitmarkParserGenerator.js.map +1 -1
- package/dist/cjs/ast/Ast.js +1 -0
- package/dist/cjs/ast/Ast.js.map +1 -1
- package/dist/cjs/ast/BaseBuilder.js +91 -54
- package/dist/cjs/ast/BaseBuilder.js.map +1 -1
- package/dist/cjs/ast/Builder.js +776 -389
- package/dist/cjs/ast/Builder.js.map +1 -1
- package/dist/cjs/ast/ResourceBuilder.js +516 -252
- package/dist/cjs/ast/ResourceBuilder.js.map +1 -1
- package/dist/cjs/ast/rules/NodeValidator.js +61 -22
- package/dist/cjs/ast/rules/NodeValidator.js.map +1 -1
- package/dist/cjs/breakscaping/Breakscape.js +96 -71
- package/dist/cjs/breakscaping/Breakscape.js.map +1 -1
- package/dist/cjs/config/raw/bits.js +14 -5
- package/dist/cjs/config/raw/bits.js.map +1 -1
- package/dist/cjs/config/raw/properties.js +7 -2
- package/dist/cjs/config/raw/properties.js.map +1 -1
- package/dist/cjs/generated/build-info.js +1 -1
- package/dist/cjs/generated/build-info.js.map +1 -1
- package/dist/cjs/generated/parser/bitmark/bitmark-peggy-parser.js +1 -0
- package/dist/cjs/generated/parser/bitmark/bitmark-peggy-parser.js.map +1 -1
- package/dist/cjs/generator/AstWalkerGenerator.js +4 -1
- package/dist/cjs/generator/AstWalkerGenerator.js.map +1 -1
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js +959 -338
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/cjs/generator/json/JsonGenerator.js +308 -1982
- package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
- package/dist/cjs/generator/text/TextGenerator.js +26 -8
- package/dist/cjs/generator/text/TextGenerator.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/ast/NodeType.js +27 -8
- package/dist/cjs/model/ast/NodeType.js.map +1 -1
- package/dist/cjs/model/config/enum/PropertyConfigKey.js +1 -0
- package/dist/cjs/model/config/enum/PropertyConfigKey.js.map +1 -1
- package/dist/cjs/model/enum/BitType.js +1 -2
- package/dist/cjs/model/enum/BitType.js.map +1 -1
- package/dist/cjs/model/enum/PropertyFormat.js +3 -1
- package/dist/cjs/model/enum/PropertyFormat.js.map +1 -1
- package/dist/cjs/model/enum/TextFormat.js +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js +9 -3
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js +49 -131
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js +7 -31
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js +255 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js +2 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +175 -129
- package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js +8 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js +61 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js +11 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +21 -17
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js +50 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js +2 -15
- package/dist/cjs/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js +2 -4
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js +4 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js +2 -4
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js +5 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js +5 -6
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +23 -7
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js +5 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js +3 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js +19 -8
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js +4 -6
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js +4 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +14 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +37 -21
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +3 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/json/JsonParser.js +73 -765
- package/dist/cjs/parser/json/JsonParser.js.map +1 -1
- package/dist/cjs/parser/text/TextParser.js +61 -2
- package/dist/cjs/parser/text/TextParser.js.map +1 -1
- package/dist/cjs/utils/BitUtils.js +15 -13
- package/dist/cjs/utils/BitUtils.js.map +1 -1
- package/dist/esm/BitmarkParserGenerator.js +8 -3
- package/dist/esm/BitmarkParserGenerator.js.map +1 -1
- package/dist/esm/ast/Ast.js +1 -0
- package/dist/esm/ast/Ast.js.map +1 -1
- package/dist/esm/ast/BaseBuilder.js +91 -54
- package/dist/esm/ast/BaseBuilder.js.map +1 -1
- package/dist/esm/ast/Builder.js +776 -389
- package/dist/esm/ast/Builder.js.map +1 -1
- package/dist/esm/ast/ResourceBuilder.js +516 -252
- package/dist/esm/ast/ResourceBuilder.js.map +1 -1
- package/dist/esm/ast/rules/NodeValidator.js +61 -22
- package/dist/esm/ast/rules/NodeValidator.js.map +1 -1
- package/dist/esm/breakscaping/Breakscape.js +96 -71
- package/dist/esm/breakscaping/Breakscape.js.map +1 -1
- package/dist/esm/config/raw/bits.js +14 -5
- package/dist/esm/config/raw/bits.js.map +1 -1
- package/dist/esm/config/raw/properties.js +7 -2
- package/dist/esm/config/raw/properties.js.map +1 -1
- package/dist/esm/generated/build-info.js +1 -1
- package/dist/esm/generated/build-info.js.map +1 -1
- package/dist/esm/generated/parser/bitmark/bitmark-peggy-parser.js +1 -0
- package/dist/esm/generated/parser/bitmark/bitmark-peggy-parser.js.map +1 -1
- package/dist/esm/generator/AstWalkerGenerator.js +4 -1
- package/dist/esm/generator/AstWalkerGenerator.js.map +1 -1
- package/dist/esm/generator/bitmark/BitmarkGenerator.js +959 -338
- package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/esm/generator/json/JsonGenerator.js +308 -1982
- package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
- package/dist/esm/generator/text/TextGenerator.js +26 -8
- package/dist/esm/generator/text/TextGenerator.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/ast/NodeType.js +27 -8
- package/dist/esm/model/ast/NodeType.js.map +1 -1
- package/dist/esm/model/config/enum/PropertyConfigKey.js +1 -0
- package/dist/esm/model/config/enum/PropertyConfigKey.js.map +1 -1
- package/dist/esm/model/enum/BitType.js +1 -2
- package/dist/esm/model/enum/BitType.js.map +1 -1
- package/dist/esm/model/enum/PropertyFormat.js +3 -1
- package/dist/esm/model/enum/PropertyFormat.js.map +1 -1
- package/dist/esm/model/enum/TextFormat.js +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js +9 -3
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js +49 -131
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js +7 -31
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js +252 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js +2 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +175 -129
- package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js +8 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js +58 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js +11 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +21 -17
- package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js +47 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js +2 -15
- package/dist/esm/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js +2 -4
- package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js +4 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js +2 -4
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js +5 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js +5 -6
- package/dist/esm/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +23 -7
- package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js +5 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js +3 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js +19 -8
- package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js +4 -6
- package/dist/esm/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js +4 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +14 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +37 -21
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +3 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/json/JsonParser.js +73 -765
- package/dist/esm/parser/json/JsonParser.js.map +1 -1
- package/dist/esm/parser/text/TextParser.js +61 -2
- package/dist/esm/parser/text/TextParser.js.map +1 -1
- package/dist/esm/utils/BitUtils.js +15 -13
- package/dist/esm/utils/BitUtils.js.map +1 -1
- package/dist/types/BitmarkParserGenerator.d.ts +8 -0
- package/dist/types/BitmarkParserGenerator.d.ts.map +1 -1
- package/dist/types/ast/Ast.d.ts.map +1 -1
- package/dist/types/ast/BaseBuilder.d.ts +31 -21
- package/dist/types/ast/BaseBuilder.d.ts.map +1 -1
- package/dist/types/ast/Builder.d.ts +279 -441
- package/dist/types/ast/Builder.d.ts.map +1 -1
- package/dist/types/ast/ResourceBuilder.d.ts +177 -164
- package/dist/types/ast/ResourceBuilder.d.ts.map +1 -1
- package/dist/types/ast/rules/NodeValidator.d.ts +3 -2
- package/dist/types/ast/rules/NodeValidator.d.ts.map +1 -1
- package/dist/types/breakscaping/Breakscape.d.ts +6 -5
- package/dist/types/breakscaping/Breakscape.d.ts.map +1 -1
- package/dist/types/config/raw/bits.d.ts.map +1 -1
- package/dist/types/config/raw/properties.d.ts.map +1 -1
- package/dist/types/generated/parser/bitmark/bitmark-peggy-parser.d.ts.map +1 -1
- package/dist/types/generator/AstWalkerGenerator.d.ts.map +1 -1
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +89 -55
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
- package/dist/types/generator/json/JsonGenerator.d.ts +88 -108
- package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
- package/dist/types/generator/text/TextGenerator.d.ts +14 -2
- package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model/ast/NodeType.d.ts +48 -16
- package/dist/types/model/ast/NodeType.d.ts.map +1 -1
- package/dist/types/model/ast/Nodes.d.ts +64 -440
- package/dist/types/model/ast/Nodes.d.ts.map +1 -1
- package/dist/types/model/config/enum/ConfigKey.d.ts +2 -0
- package/dist/types/model/config/enum/ConfigKey.d.ts.map +1 -1
- package/dist/types/model/config/enum/PropertyConfigKey.d.ts +3 -0
- package/dist/types/model/config/enum/PropertyConfigKey.d.ts.map +1 -1
- package/dist/types/model/enum/BitType.d.ts +2 -4
- package/dist/types/model/enum/BitType.d.ts.map +1 -1
- package/dist/types/model/enum/PropertyFormat.d.ts +4 -2
- package/dist/types/model/enum/PropertyFormat.d.ts.map +1 -1
- package/dist/types/model/enum/PropertyTag.d.ts +2 -0
- package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
- package/dist/types/model/json/BitJson.d.ts +32 -20
- package/dist/types/model/json/BitJson.d.ts.map +1 -1
- package/dist/types/model/json/BodyBitJson.d.ts +16 -12
- package/dist/types/model/json/BodyBitJson.d.ts.map +1 -1
- package/dist/types/model/json/ResourceJson.d.ts +2 -22
- package/dist/types/model/json/ResourceJson.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserHelper.d.ts +3 -2
- package/dist/types/parser/bitmark/peg/BitmarkPegParserHelper.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts +2 -15
- package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts +83 -71
- package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts +2 -2
- package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/BodyContentProcessor.d.ts +37 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/BodyContentProcessor.d.ts.map +1 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts +2 -2
- package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.d.ts +15 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.d.ts.map +1 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/FooterContentProcessor.d.ts +16 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/FooterContentProcessor.d.ts.map +1 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts +2 -2
- package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts +5 -2
- package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/json/JsonParser.d.ts +9 -72
- package/dist/types/parser/json/JsonParser.d.ts.map +1 -1
- package/dist/types/parser/text/TextParser.d.ts +16 -1
- package/dist/types/parser/text/TextParser.d.ts.map +1 -1
- package/dist/types/utils/BitUtils.d.ts +8 -8
- package/dist/types/utils/BitUtils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.JsonParser = void 0;
|
|
4
15
|
const Builder_1 = require("../../ast/Builder");
|
|
5
|
-
const ResourceBuilder_1 = require("../../ast/ResourceBuilder");
|
|
6
|
-
const Breakscape_1 = require("../../breakscaping/Breakscape");
|
|
7
16
|
const Config_1 = require("../../config/Config");
|
|
8
|
-
const TextGenerator_1 = require("../../generator/text/TextGenerator");
|
|
9
17
|
const BitType_1 = require("../../model/enum/BitType");
|
|
10
|
-
const BodyBitType_1 = require("../../model/enum/BodyBitType");
|
|
11
18
|
const ResourceTag_1 = require("../../model/enum/ResourceTag");
|
|
12
19
|
const TextFormat_1 = require("../../model/enum/TextFormat");
|
|
13
20
|
const StringUtils_1 = require("../../utils/StringUtils");
|
|
14
|
-
const TextParser_1 = require("../text/TextParser");
|
|
15
21
|
const builder = new Builder_1.Builder();
|
|
16
|
-
const resourceBuilder = new ResourceBuilder_1.ResourceBuilder();
|
|
17
22
|
/**
|
|
18
23
|
* A parser for parsing bitmark JSON to bitmark AST
|
|
19
24
|
*/
|
|
20
25
|
class JsonParser {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.textGenerator = new TextGenerator_1.TextGenerator();
|
|
23
|
-
this.textParser = new TextParser_1.TextParser();
|
|
24
|
-
}
|
|
25
26
|
/**
|
|
26
27
|
* Convert JSON to AST.
|
|
27
28
|
*
|
|
@@ -42,7 +43,7 @@ class JsonParser {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
const bits = bitsNodes.length > 0 ? { bits: bitsNodes } : {};
|
|
45
|
-
const ast = builder.
|
|
46
|
+
const ast = builder.buildBitmark(bits);
|
|
46
47
|
return ast;
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
@@ -125,476 +126,63 @@ class JsonParser {
|
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
128
|
bitToAst(bit, internalComments) {
|
|
128
|
-
var _a;
|
|
129
|
-
const {
|
|
130
|
-
const isCommented = type === BitType_1.BitType._comment && originalType !== undefined;
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
const { statement, product, productVideo, reference: referenceBit } = bit, bitRest = __rest(bit, ["statement", "product", "productVideo", "reference"]);
|
|
131
|
+
const isCommented = bit.type === BitType_1.BitType._comment && bit.originalType !== undefined;
|
|
131
132
|
// Bit type
|
|
132
|
-
const bitType = Config_1.Config.getBitType(isCommented ? originalType : type);
|
|
133
|
-
// Bit level
|
|
134
|
-
const bitLevelValidated = Math.max(Math.min(bitLevel !== null && bitLevel !== void 0 ? bitLevel : 1, Config_1.Config.bitLevelMax), Config_1.Config.bitLevelMin);
|
|
133
|
+
const bitType = Config_1.Config.getBitType(isCommented ? bit.originalType : bit.type);
|
|
135
134
|
// Get the bit config for the bit type
|
|
136
135
|
const bitConfig = Config_1.Config.getBitConfig(bitType);
|
|
137
136
|
// Text Format
|
|
138
|
-
const textFormat = (_a = TextFormat_1.TextFormat.fromValue(format)) !== null && _a !== void 0 ? _a : bitConfig.textFormatDefault;
|
|
139
|
-
//
|
|
140
|
-
const resourceAttachmentType = this.getResourceType(resource);
|
|
141
|
-
// resource(s)
|
|
142
|
-
const resourcesNode = this.resourceBitToAst(bitType, resource, images !== null && images !== void 0 ? images : logos);
|
|
143
|
-
// body & placeholders
|
|
144
|
-
const bodyNode = this.bodyToAst(body, textFormat, placeholders);
|
|
145
|
-
// imagePlaceholder
|
|
146
|
-
const imagePlaceholderNode = this.imagePlaceholderBitToAst(imagePlaceholder);
|
|
147
|
-
// imageSource
|
|
148
|
-
const imageSourceNode = this.imageSourceBitToAst(imageSource);
|
|
149
|
-
// Person (partner, deprecated)
|
|
150
|
-
const personNode = this.personBitToAst(person !== null && person !== void 0 ? person : partner);
|
|
151
|
-
// Mark Config
|
|
152
|
-
const markConfigNode = this.markConfigBitToAst(marks);
|
|
153
|
-
// flashcards
|
|
154
|
-
const flashcardNodes = this.flashcardBitsToAst(cards);
|
|
155
|
-
// definitions
|
|
156
|
-
// descriptions are treated as alias for definitions
|
|
157
|
-
const definitionNodes = Config_1.Config.isOfBitType(bitType, BitType_1.BitType.descriptionList)
|
|
158
|
-
? this.descriptionsBitsToAst(descriptions)
|
|
159
|
-
: this.definitionsBitsToAst(definitions);
|
|
160
|
-
//+-statement
|
|
161
|
-
const statementNodes = this.statementBitsToAst(statement, isCorrect, statements, example);
|
|
162
|
-
//+-response
|
|
163
|
-
const responseNodes = this.responseBitsToAst(bitType, responses);
|
|
164
|
-
// quizzes
|
|
165
|
-
const quizNodes = this.quizBitsToAst(bitType, quizzes);
|
|
166
|
-
// heading
|
|
167
|
-
const headingNode = this.headingBitToAst(heading);
|
|
168
|
-
// pairs
|
|
169
|
-
const pairsNodes = this.pairBitsToAst(pairs);
|
|
170
|
-
// matrix
|
|
171
|
-
const matrixNodes = this.matrixBitsToAst(matrix);
|
|
172
|
-
// table / captionDefinitionList
|
|
173
|
-
const tableNode = this.tableToAst(table);
|
|
174
|
-
//+-choice
|
|
175
|
-
const choiceNodes = this.choiceBitsToAst(choices);
|
|
176
|
-
// questions
|
|
177
|
-
const questionNodes = this.questionBitsToAst(questions);
|
|
178
|
-
// botResponses
|
|
179
|
-
const botResponseNodes = this.botResponseBitsToAst(bitType, responses);
|
|
180
|
-
// technicalTerm
|
|
181
|
-
const technicalTermNode = this.technicalTermToAst(technicalTerm);
|
|
182
|
-
// servings
|
|
183
|
-
const servingsNode = this.servingsToAst(servings);
|
|
184
|
-
// ingredients
|
|
185
|
-
const ingredientsNodes = this.ingredientsBitsToAst(ingredients);
|
|
186
|
-
// ratingLevelStart
|
|
187
|
-
const ratingLevelStartNodes = this.ratingLevelStartEndToAst(ratingLevelStart);
|
|
188
|
-
// ratingLevelEnd
|
|
189
|
-
const ratingLevelEndNodes = this.ratingLevelStartEndToAst(ratingLevelEnd);
|
|
190
|
-
// captionDefinitionList
|
|
191
|
-
const captionDefinitionListNode = this.captionDefinitionListToAst(captionDefinitionList);
|
|
192
|
-
// listItems / sections (cardBits)
|
|
193
|
-
const cardBitNodes = this.listItemsToAst(listItems !== null && listItems !== void 0 ? listItems : sections, textFormat, placeholders);
|
|
194
|
-
// footer
|
|
195
|
-
const footerNode = this.footerToAst(footer, textFormat);
|
|
196
|
-
// Convert reference to referenceProperty
|
|
197
|
-
const { reference, referenceProperty } = this.referenceToAst(referenceIn);
|
|
137
|
+
const textFormat = (_a = TextFormat_1.TextFormat.fromValue(bit.format)) !== null && _a !== void 0 ? _a : bitConfig.textFormatDefault;
|
|
138
|
+
textFormat; // Unused
|
|
198
139
|
// Build bit
|
|
199
|
-
const bitNode = builder.
|
|
200
|
-
isPublic,
|
|
201
|
-
aiGenerated, machineTranslated: this.convertStringToBreakscapedString(machineTranslated), analyticsTag: this.convertStringToBreakscapedString(analyticsTag), feedbackEngine: this.convertStringToBreakscapedString(feedbackEngine), feedbackType: this.convertStringToBreakscapedString(feedbackType), disableFeedback, releaseVersion: this.convertStringToBreakscapedString(releaseVersion), releaseKind: this.convertStringToBreakscapedString(releaseKind), releaseDate: this.convertStringToBreakscapedString(releaseDate), ageRange, lang: this.convertStringToBreakscapedString(lang), language: this.convertStringToBreakscapedString(language), publisher: this.convertStringToBreakscapedString(publisher), publisherName: this.convertStringToBreakscapedString(publisherName), theme: this.convertStringToBreakscapedString(theme), computerLanguage: this.convertStringToBreakscapedString(computerLanguage), target: this.convertStringToBreakscapedString(target), slug: this.convertStringToBreakscapedString(slug), tag: this.convertStringToBreakscapedString(tag), reductionTag: this.convertStringToBreakscapedString(reductionTag), bubbleTag: this.convertStringToBreakscapedString(bubbleTag), levelCEFRp: this.convertStringToBreakscapedString(levelCEFRp), levelCEFR: this.convertStringToBreakscapedString(levelCEFR), levelILR: this.convertStringToBreakscapedString(levelILR), levelACTFL: this.convertStringToBreakscapedString(levelACTFL), icon: this.convertStringToBreakscapedString(icon), iconTag: this.convertStringToBreakscapedString(iconTag), colorTag: this.convertStringToBreakscapedString(colorTag), flashcardSet: this.convertStringToBreakscapedString(flashcardSet), subtype: this.convertStringToBreakscapedString(subtype), bookAlias: this.convertStringToBreakscapedString(bookAlias), coverImage: this.convertStringToBreakscapedString(coverImage), coverColor: this.convertStringToBreakscapedString(coverColor), publications: this.convertStringToBreakscapedString(publications), author: this.convertStringToBreakscapedString(author), date: this.convertStringToBreakscapedString(date), dateEnd: this.convertStringToBreakscapedString(dateEnd), location: this.convertStringToBreakscapedString(location), kind: this.convertStringToBreakscapedString(kind), hasMarkAsDone,
|
|
202
|
-
processHandIn, action: this.convertStringToBreakscapedString(action), showInIndex, blockId: this.convertStringToBreakscapedString(blockId), pageNo,
|
|
203
|
-
x,
|
|
204
|
-
y,
|
|
205
|
-
width,
|
|
206
|
-
height,
|
|
207
|
-
index, classification: this.convertStringToBreakscapedString(classification), availableClassifications: this.convertStringToBreakscapedString(availableClassifications), allowedBit: this.convertStringToBreakscapedString(allowedBit), tableFixedHeader,
|
|
208
|
-
tableSearch,
|
|
209
|
-
tableSort,
|
|
210
|
-
tablePagination,
|
|
211
|
-
tablePaginationLimit,
|
|
212
|
-
tableHeight,
|
|
213
|
-
tableWhitespaceNoWrap,
|
|
214
|
-
tableAutoWidth,
|
|
215
|
-
tableResizableColumns,
|
|
216
|
-
quizCountItems,
|
|
217
|
-
quizStrikethroughSolutions,
|
|
218
|
-
codeLineNumbers,
|
|
219
|
-
codeMinimap, stripePricingTableId: this.convertStringToBreakscapedString(stripePricingTableId), stripePublishableKey: this.convertStringToBreakscapedString(stripePublishableKey), duration: this.convertStringToBreakscapedString(duration), referenceProperty: this.convertStringToBreakscapedString(referenceProperty), thumbImage: this.convertStringToBreakscapedString(thumbImage), scormSource: this.convertStringToBreakscapedString(scormSource), posterImage: this.convertStringToBreakscapedString(posterImage), focusX,
|
|
220
|
-
focusY, pointerLeft: this.convertStringToBreakscapedString(pointerLeft), pointerTop: this.convertStringToBreakscapedString(pointerTop), listItemIndent, backgroundWallpaper: this.convertStringToBreakscapedString(backgroundWallpaper), hasBookNavigation, deeplink: this.convertStringToBreakscapedString(deeplink), externalLink: this.convertStringToBreakscapedString(externalLink), externalLinkText: this.convertStringToBreakscapedString(externalLinkText), videoCallLink: this.convertStringToBreakscapedString(videoCallLink), vendorUrl: this.convertStringToBreakscapedString(vendorUrl), search: this.convertStringToBreakscapedString(search), bot: this.convertStringToBreakscapedString(bot), list: this.convertStringToBreakscapedString(list), textReference: this.convertStringToBreakscapedString(textReference), isTracked,
|
|
221
|
-
isInfoOnly,
|
|
222
|
-
imageFirst, activityType: this.convertStringToBreakscapedString(activityType), labelTrue: this.convertStringToBreakscapedString(labelTrue), labelFalse: this.convertStringToBreakscapedString(labelFalse), content2Buy: this.convertStringToBreakscapedString(content2Buy), mailingList: this.convertStringToBreakscapedString(mailingList), buttonCaption: this.convertStringToBreakscapedString(buttonCaption), callToActionUrl: this.convertStringToBreakscapedString(callToActionUrl), caption: this.convertJsonTextToBreakscapedString(caption), quotedPerson: this.convertStringToBreakscapedString(quotedPerson), partialAnswer: this.convertStringToBreakscapedString(partialAnswer), reasonableNumOfChars, sampleSolution: this.convertStringToBreakscapedString(sampleSolution), additionalSolutions: this.convertStringToBreakscapedString(additionalSolutions), resolved, resolvedDate: this.convertStringToBreakscapedString(resolvedDate), resolvedBy: this.convertStringToBreakscapedString(resolvedBy), maxCreatedBits,
|
|
223
|
-
maxDisplayLevel, page: this.convertStringToBreakscapedString(page), productId: this.convertStringToBreakscapedString(productId), productList: this.convertStringToBreakscapedString(product), productVideoList: this.convertStringToBreakscapedString(productVideo), productFolder: this.convertStringToBreakscapedString(productFolder), technicalTerm: technicalTermNode, servings: servingsNode, ratingLevelStart: ratingLevelStartNodes, ratingLevelEnd: ratingLevelEndNodes, ratingLevelSelected, book: this.convertStringToBreakscapedString(book), title: this.convertJsonTextToBreakscapedString(title), subtitle: this.convertJsonTextToBreakscapedString(subtitle), level,
|
|
224
|
-
toc,
|
|
225
|
-
progress, anchor: this.convertStringToBreakscapedString(anchor), reference: this.convertStringToBreakscapedString(reference), referenceEnd: this.convertStringToBreakscapedString(referenceEnd) }, this.parseItemLeadHintInstructionPageNumberMarginNumber(item, lead, hint, instruction, pageNumber, marginNumber)), this.parseExample(example)), { imageSource: imageSourceNode, person: personNode, markConfig: markConfigNode, imagePlaceholder: imagePlaceholderNode, resources: resourcesNode, body: bodyNode, elements: this.convertStringToBreakscapedString(elements), flashcards: flashcardNodes, definitions: definitionNodes, statements: statementNodes, responses: responseNodes, quizzes: quizNodes, heading: headingNode, pairs: pairsNodes, matrix: matrixNodes, table: tableNode, choices: choiceNodes, questions: questionNodes, botResponses: botResponseNodes, ingredients: ingredientsNodes, captionDefinitionList: captionDefinitionListNode, cardBits: cardBitNodes, footer: footerNode }));
|
|
140
|
+
const bitNode = builder.buildBit(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bitRest), { bitType, bitLevel: Math.max(Math.min((_b = bit.bitLevel) !== null && _b !== void 0 ? _b : 1, Config_1.Config.bitLevelMax), Config_1.Config.bitLevelMin), textFormat: bit.format, resourceType: this.getResourceType(bit.resource), isCommented, internalComment: internalComments, productList: product, productVideoList: productVideo }), this.processReference(referenceBit)), this.parseExample(bit.example)), { person: (_c = bit.partner) !== null && _c !== void 0 ? _c : bit.person, markConfig: bit.marks, resources: this.processResources(bitType, bit.resource, bit.images, bit.logos), body: this.processBody(bit.body, bit.placeholders), flashcards: bit.cards, statements: this.processStatements(statement, bit.isCorrect, bit.statements, bit.example), responses: this.processResponses(bitType, bit.responses), botResponses: this.processBotResponse(bitType, bit.responses), cardBits: this.processListItems((_d = bit.listItems) !== null && _d !== void 0 ? _d : bit.sections, bit.placeholders), footer: this.processFooter(bit.footer) }));
|
|
226
141
|
return bitNode;
|
|
227
142
|
}
|
|
228
|
-
|
|
229
|
-
var _a, _b;
|
|
230
|
-
let node;
|
|
231
|
-
if (imageSource) {
|
|
232
|
-
const { url, mockupId, format, size, trim } = imageSource;
|
|
233
|
-
node = builder.imageSource({
|
|
234
|
-
url: (_a = this.convertStringToBreakscapedString(url)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
235
|
-
mockupId: (_b = this.convertStringToBreakscapedString(mockupId)) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
236
|
-
format: this.convertStringToBreakscapedString(format),
|
|
237
|
-
size,
|
|
238
|
-
trim,
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
return node;
|
|
242
|
-
}
|
|
243
|
-
imagePlaceholderBitToAst(imagePlaceholder) {
|
|
244
|
-
let node;
|
|
245
|
-
if (imagePlaceholder) {
|
|
246
|
-
const { image } = imagePlaceholder;
|
|
247
|
-
node = this.resourceDataToAst(ResourceTag_1.ResourceTag.image, image);
|
|
248
|
-
}
|
|
249
|
-
return node;
|
|
250
|
-
}
|
|
251
|
-
personBitToAst(person) {
|
|
252
|
-
var _a;
|
|
253
|
-
let node;
|
|
254
|
-
if (person) {
|
|
255
|
-
const avatarImage = this.resourceDataToAst(ResourceTag_1.ResourceTag.image, person.avatarImage);
|
|
256
|
-
node = builder.person({
|
|
257
|
-
name: (_a = this.convertStringToBreakscapedString(person.name)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
258
|
-
title: this.convertStringToBreakscapedString(person.title),
|
|
259
|
-
avatarImage,
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
return node;
|
|
263
|
-
}
|
|
264
|
-
markConfigBitToAst(marks) {
|
|
265
|
-
var _a;
|
|
266
|
-
const nodes = [];
|
|
267
|
-
if (Array.isArray(marks)) {
|
|
268
|
-
for (const m of marks) {
|
|
269
|
-
const { mark, color, emphasis } = m;
|
|
270
|
-
const node = builder.markConfig({
|
|
271
|
-
mark: (_a = this.convertStringToBreakscapedString(mark)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
272
|
-
color: this.convertStringToBreakscapedString(color),
|
|
273
|
-
emphasis: this.convertStringToBreakscapedString(emphasis),
|
|
274
|
-
});
|
|
275
|
-
nodes.push(node);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (nodes.length === 0)
|
|
279
|
-
return undefined;
|
|
280
|
-
return nodes;
|
|
281
|
-
}
|
|
282
|
-
flashcardBitsToAst(flashcards) {
|
|
283
|
-
var _a;
|
|
284
|
-
const nodes = [];
|
|
285
|
-
if (Array.isArray(flashcards)) {
|
|
286
|
-
for (const c of flashcards) {
|
|
287
|
-
const { question, answer, alternativeAnswers, item, lead, hint, instruction, example } = c;
|
|
288
|
-
const node = builder.flashcard(Object.assign(Object.assign({ question: (_a = this.convertJsonTextToBreakscapedString(question)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, answer: this.convertJsonTextToBreakscapedString(answer), alternativeAnswers: this.convertJsonTextToBreakscapedString(alternativeAnswers) }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
289
|
-
nodes.push(node);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
if (nodes.length === 0)
|
|
293
|
-
return undefined;
|
|
294
|
-
return nodes;
|
|
295
|
-
}
|
|
296
|
-
definitionsBitsToAst(definitionList) {
|
|
297
|
-
var _a;
|
|
298
|
-
const nodes = [];
|
|
299
|
-
if (Array.isArray(definitionList)) {
|
|
300
|
-
for (const c of definitionList) {
|
|
301
|
-
const { term, description, alternativeDefinitions, item, lead, hint, instruction, example } = c;
|
|
302
|
-
const node = builder.definitionListItem(Object.assign(Object.assign({ term: (_a = this.convertJsonTextToBreakscapedString(term)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, description: this.convertJsonTextToBreakscapedString(description), alternativeDefinitions: this.convertJsonTextToBreakscapedString(alternativeDefinitions) }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
303
|
-
nodes.push(node);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (nodes.length === 0)
|
|
307
|
-
return undefined;
|
|
308
|
-
return nodes;
|
|
309
|
-
}
|
|
310
|
-
descriptionsBitsToAst(definitionList) {
|
|
311
|
-
var _a;
|
|
312
|
-
const nodes = [];
|
|
313
|
-
if (Array.isArray(definitionList)) {
|
|
314
|
-
for (const c of definitionList) {
|
|
315
|
-
const { term, description, alternativeDescriptions, item, lead, hint, instruction, example } = c;
|
|
316
|
-
const node = builder.definitionListItem(Object.assign(Object.assign({ term: (_a = this.convertJsonTextToBreakscapedString(term)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, description: this.convertJsonTextToBreakscapedString(description), alternativeDefinitions: this.convertJsonTextToBreakscapedString(alternativeDescriptions) }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
317
|
-
nodes.push(node);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (nodes.length === 0)
|
|
321
|
-
return undefined;
|
|
322
|
-
return nodes;
|
|
323
|
-
}
|
|
324
|
-
statementBitsToAst(statement, isCorrect, statements, example) {
|
|
325
|
-
var _a, _b;
|
|
143
|
+
processStatements(statement, isCorrect, statements, example) {
|
|
326
144
|
const nodes = [];
|
|
145
|
+
// Add statement defined in the bit
|
|
327
146
|
if (statement) {
|
|
328
|
-
const node =
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
if (Array.isArray(statements)) {
|
|
332
|
-
for (const s of statements) {
|
|
333
|
-
const { statement, isCorrect, item, lead, hint, instruction, example } = s;
|
|
334
|
-
const node = builder.statement(Object.assign(Object.assign({ text: (_b = this.convertStringToBreakscapedString(statement)) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING, isCorrect }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
335
|
-
nodes.push(node);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
if (nodes.length === 0)
|
|
339
|
-
return undefined;
|
|
340
|
-
return nodes;
|
|
341
|
-
}
|
|
342
|
-
choiceBitsToAst(choices) {
|
|
343
|
-
var _a;
|
|
344
|
-
const nodes = [];
|
|
345
|
-
if (Array.isArray(choices)) {
|
|
346
|
-
for (const c of choices) {
|
|
347
|
-
const { choice, isCorrect, item, lead, hint, instruction, example } = c;
|
|
348
|
-
const node = builder.choice(Object.assign(Object.assign({ text: (_a = this.convertStringToBreakscapedString(choice)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, isCorrect }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
147
|
+
const node = Object.assign({ statement: statement !== null && statement !== void 0 ? statement : '', isCorrect: isCorrect !== null && isCorrect !== void 0 ? isCorrect : false }, this.parseExample(example));
|
|
148
|
+
if (node)
|
|
349
149
|
nodes.push(node);
|
|
350
|
-
}
|
|
351
150
|
}
|
|
151
|
+
// add standard statements
|
|
152
|
+
if (Array.isArray(statements))
|
|
153
|
+
for (const item of statements)
|
|
154
|
+
nodes.push(item);
|
|
352
155
|
if (nodes.length === 0)
|
|
353
156
|
return undefined;
|
|
354
157
|
return nodes;
|
|
355
158
|
}
|
|
356
|
-
|
|
357
|
-
var _a;
|
|
358
|
-
const nodes = [];
|
|
159
|
+
processResponses(bitType, responses) {
|
|
359
160
|
// Return early if bot response as the responses should be interpreted as bot responses
|
|
360
161
|
if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.botActionResponse))
|
|
361
162
|
return undefined;
|
|
362
|
-
if (Array.isArray(responses))
|
|
363
|
-
for (const r of responses) {
|
|
364
|
-
const { response, isCorrect, item, lead, hint, instruction, example } = r;
|
|
365
|
-
const node = builder.response(Object.assign(Object.assign({ text: (_a = this.convertStringToBreakscapedString(response)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, isCorrect }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
366
|
-
nodes.push(node);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
if (nodes.length === 0)
|
|
370
|
-
return undefined;
|
|
371
|
-
return nodes;
|
|
372
|
-
}
|
|
373
|
-
selectOptionBitsToAst(options) {
|
|
374
|
-
var _a;
|
|
375
|
-
const nodes = [];
|
|
376
|
-
if (Array.isArray(options)) {
|
|
377
|
-
for (const o of options) {
|
|
378
|
-
const { text, isCorrect, item, lead, hint, instruction, example } = o;
|
|
379
|
-
const node = builder.selectOption(Object.assign(Object.assign({ text: (_a = this.convertStringToBreakscapedString(text)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, isCorrect }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
380
|
-
nodes.push(node);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
return nodes;
|
|
384
|
-
}
|
|
385
|
-
highlightTextBitsToAst(highlightTexts) {
|
|
386
|
-
var _a;
|
|
387
|
-
const nodes = [];
|
|
388
|
-
if (Array.isArray(highlightTexts)) {
|
|
389
|
-
for (const t of highlightTexts) {
|
|
390
|
-
const { text, isCorrect, isHighlighted, item, lead, hint, instruction, example } = t;
|
|
391
|
-
const node = builder.highlightText(Object.assign(Object.assign({ text: (_a = this.convertStringToBreakscapedString(text)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, isCorrect,
|
|
392
|
-
isHighlighted }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
393
|
-
nodes.push(node);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return nodes;
|
|
397
|
-
}
|
|
398
|
-
quizBitsToAst(bitType, quizzes) {
|
|
399
|
-
const nodes = [];
|
|
400
|
-
if (Array.isArray(quizzes)) {
|
|
401
|
-
for (const q of quizzes) {
|
|
402
|
-
const { item, lead, hint, instruction, choices, responses } = q;
|
|
403
|
-
const choiceNodes = this.choiceBitsToAst(choices);
|
|
404
|
-
const responseNodes = this.responseBitsToAst(bitType, responses);
|
|
405
|
-
const node = builder.quiz(Object.assign(Object.assign({}, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), { choices: choiceNodes, responses: responseNodes }));
|
|
406
|
-
nodes.push(node);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
if (nodes.length === 0)
|
|
410
|
-
return undefined;
|
|
411
|
-
return nodes;
|
|
412
|
-
}
|
|
413
|
-
headingBitToAst(heading) {
|
|
414
|
-
var _a, _b;
|
|
415
|
-
let node;
|
|
416
|
-
if (heading && Object.keys(heading).length > 0) {
|
|
417
|
-
node = builder.heading({
|
|
418
|
-
forKeys: (_a = this.convertStringToBreakscapedString(heading.forKeys)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
419
|
-
forValues: (_b = this.convertStringToBreakscapedString(heading.forValues)) !== null && _b !== void 0 ? _b : [],
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
return node;
|
|
423
|
-
}
|
|
424
|
-
pairBitsToAst(pairs) {
|
|
425
|
-
var _a;
|
|
426
|
-
const nodes = [];
|
|
427
|
-
if (Array.isArray(pairs)) {
|
|
428
|
-
for (const p of pairs) {
|
|
429
|
-
const { key, keyAudio, keyImage, values, item, lead, hint, instruction, example, isCaseSensitive } = p;
|
|
430
|
-
const audio = this.resourceDataToAst(ResourceTag_1.ResourceTag.audio, keyAudio);
|
|
431
|
-
const image = this.resourceDataToAst(ResourceTag_1.ResourceTag.image, keyImage);
|
|
432
|
-
const node = builder.pair(Object.assign(Object.assign(Object.assign({ key: this.convertStringToBreakscapedString(key), keyAudio: audio, keyImage: image, values: (_a = this.convertStringToBreakscapedString(values)) !== null && _a !== void 0 ? _a : [] }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)), { isCaseSensitive }));
|
|
433
|
-
nodes.push(node);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (nodes.length === 0)
|
|
437
|
-
return undefined;
|
|
438
|
-
return nodes;
|
|
439
|
-
}
|
|
440
|
-
matrixBitsToAst(matrix) {
|
|
441
|
-
var _a, _b;
|
|
442
|
-
const nodes = [];
|
|
443
|
-
if (Array.isArray(matrix)) {
|
|
444
|
-
for (const m of matrix) {
|
|
445
|
-
const { key, cells, item, lead, hint, instruction, example } = m;
|
|
446
|
-
const node = builder.matrix(Object.assign(Object.assign({ key: (_a = this.convertStringToBreakscapedString(key)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, cells: (_b = this.matrixCellsToAst(cells)) !== null && _b !== void 0 ? _b : [] }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
447
|
-
nodes.push(node);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
if (nodes.length === 0)
|
|
451
|
-
return undefined;
|
|
452
|
-
return nodes;
|
|
453
|
-
}
|
|
454
|
-
matrixCellsToAst(matrixCells) {
|
|
455
|
-
var _a;
|
|
456
|
-
const nodes = [];
|
|
457
|
-
if (Array.isArray(matrixCells)) {
|
|
458
|
-
for (const mc of matrixCells) {
|
|
459
|
-
const { values, item, lead, hint, instruction, isCaseSensitive, example } = mc;
|
|
460
|
-
const node = builder.matrixCell(Object.assign(Object.assign(Object.assign({ values: (_a = this.convertStringToBreakscapedString(values)) !== null && _a !== void 0 ? _a : [] }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), { isCaseSensitive }), this.parseExample(example)));
|
|
461
|
-
nodes.push(node);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
if (nodes.length === 0)
|
|
465
|
-
return undefined;
|
|
466
|
-
return nodes;
|
|
467
|
-
}
|
|
468
|
-
tableToAst(table) {
|
|
469
|
-
var _a, _b;
|
|
470
|
-
let node;
|
|
471
|
-
if (table) {
|
|
472
|
-
const { columns, data } = table;
|
|
473
|
-
node = builder.table({
|
|
474
|
-
columns: (_a = this.convertStringToBreakscapedString(columns)) !== null && _a !== void 0 ? _a : [],
|
|
475
|
-
rows: data ? ((_b = data.map((row) => { var _a; return (_a = this.convertStringToBreakscapedString(row)) !== null && _a !== void 0 ? _a : []; })) !== null && _b !== void 0 ? _b : []) : [],
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
return node;
|
|
479
|
-
}
|
|
480
|
-
questionBitsToAst(questions) {
|
|
481
|
-
var _a;
|
|
482
|
-
const nodes = [];
|
|
483
|
-
if (Array.isArray(questions)) {
|
|
484
|
-
for (const q of questions) {
|
|
485
|
-
const { question, partialAnswer, sampleSolution, additionalSolutions, item, lead, hint, instruction, example, reasonableNumOfChars, } = q;
|
|
486
|
-
const node = builder.question(Object.assign(Object.assign(Object.assign({ question: (_a = this.convertStringToBreakscapedString(question)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, partialAnswer: this.convertStringToBreakscapedString(partialAnswer), sampleSolution: this.convertStringToBreakscapedString(sampleSolution), additionalSolutions: this.convertStringToBreakscapedString(additionalSolutions) }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)), { reasonableNumOfChars }));
|
|
487
|
-
nodes.push(node);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
if (nodes.length === 0)
|
|
163
|
+
if (!Array.isArray(responses))
|
|
491
164
|
return undefined;
|
|
492
|
-
return
|
|
165
|
+
return responses;
|
|
493
166
|
}
|
|
494
|
-
|
|
495
|
-
var _a, _b, _c;
|
|
496
|
-
const nodes = [];
|
|
167
|
+
processBotResponse(bitType, responses) {
|
|
497
168
|
// Return early if NOT bot response as the responses should be interpreted as standard responses
|
|
498
169
|
if (!Config_1.Config.isOfBitType(bitType, BitType_1.BitType.botActionResponse))
|
|
499
170
|
return undefined;
|
|
500
|
-
if (Array.isArray(responses))
|
|
501
|
-
for (const r of responses) {
|
|
502
|
-
const { response, reaction, feedback, item, lead, hint } = r;
|
|
503
|
-
const node = builder.botResponse(Object.assign({ response: (_a = this.convertStringToBreakscapedString(response)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, reaction: (_b = this.convertStringToBreakscapedString(reaction)) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING, feedback: (_c = this.convertStringToBreakscapedString(feedback)) !== null && _c !== void 0 ? _c : Breakscape_1.Breakscape.EMPTY_STRING }, this.parseItemLeadHintInstruction(item, lead, hint, Breakscape_1.Breakscape.EMPTY_STRING)));
|
|
504
|
-
nodes.push(node);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
if (nodes.length === 0)
|
|
171
|
+
if (!Array.isArray(responses))
|
|
508
172
|
return undefined;
|
|
509
|
-
return
|
|
510
|
-
}
|
|
511
|
-
technicalTermToAst(technicalTerm) {
|
|
512
|
-
var _a, _b;
|
|
513
|
-
let node;
|
|
514
|
-
if (technicalTerm) {
|
|
515
|
-
const { technicalTerm: t, lang } = technicalTerm;
|
|
516
|
-
node = builder.technicalTerm({
|
|
517
|
-
technicalTerm: (_a = this.convertStringToBreakscapedString(t)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
518
|
-
lang: (_b = this.convertStringToBreakscapedString(lang)) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
return node;
|
|
173
|
+
return responses;
|
|
522
174
|
}
|
|
523
|
-
|
|
524
|
-
var _a, _b, _c;
|
|
525
|
-
let node;
|
|
526
|
-
if (servings) {
|
|
527
|
-
const { servings: s, unit, unitAbbr, decimalPlaces, disableCalculation, hint } = servings;
|
|
528
|
-
node = builder.servings({
|
|
529
|
-
servings: s,
|
|
530
|
-
unit: (_a = this.convertStringToBreakscapedString(unit)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
531
|
-
unitAbbr: (_b = this.convertStringToBreakscapedString(unitAbbr)) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
532
|
-
decimalPlaces: decimalPlaces !== null && decimalPlaces !== void 0 ? decimalPlaces : 1,
|
|
533
|
-
disableCalculation: disableCalculation !== null && disableCalculation !== void 0 ? disableCalculation : false,
|
|
534
|
-
hint: (_c = this.convertStringToBreakscapedString(hint)) !== null && _c !== void 0 ? _c : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
return node;
|
|
538
|
-
}
|
|
539
|
-
ingredientsBitsToAst(ingredients) {
|
|
540
|
-
var _a, _b;
|
|
541
|
-
const nodes = [];
|
|
542
|
-
if (Array.isArray(ingredients)) {
|
|
543
|
-
for (const i of ingredients) {
|
|
544
|
-
const { title, checked, item, quantity, unit, unitAbbr, decimalPlaces, disableCalculation } = i;
|
|
545
|
-
const node = builder.ingredient({
|
|
546
|
-
title: this.convertStringToBreakscapedString(title),
|
|
547
|
-
checked,
|
|
548
|
-
item: (_a = this.convertStringToBreakscapedString(item)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
549
|
-
quantity,
|
|
550
|
-
unit: (_b = this.convertStringToBreakscapedString(unit)) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
551
|
-
unitAbbr: this.convertStringToBreakscapedString(unitAbbr),
|
|
552
|
-
decimalPlaces: decimalPlaces !== null && decimalPlaces !== void 0 ? decimalPlaces : 1,
|
|
553
|
-
disableCalculation,
|
|
554
|
-
});
|
|
555
|
-
nodes.push(node);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
if (nodes.length === 0)
|
|
559
|
-
return undefined;
|
|
560
|
-
return nodes;
|
|
561
|
-
}
|
|
562
|
-
ratingLevelStartEndToAst(ratingLevelStartEnd) {
|
|
563
|
-
var _a;
|
|
564
|
-
let node;
|
|
565
|
-
if (ratingLevelStartEnd) {
|
|
566
|
-
const { level, label } = ratingLevelStartEnd;
|
|
567
|
-
node = builder.ratingLevelStartEnd({
|
|
568
|
-
level,
|
|
569
|
-
label: (_a = this.convertJsonTextToBreakscapedString(label)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
return node;
|
|
573
|
-
}
|
|
574
|
-
captionDefinitionListToAst(captionDefinitionList) {
|
|
575
|
-
var _a;
|
|
576
|
-
let node;
|
|
577
|
-
if (captionDefinitionList) {
|
|
578
|
-
const { columns, definitions } = captionDefinitionList;
|
|
579
|
-
node = builder.captionDefinitionList({
|
|
580
|
-
columns: (_a = this.convertStringToBreakscapedString(columns)) !== null && _a !== void 0 ? _a : [],
|
|
581
|
-
definitions: (definitions !== null && definitions !== void 0 ? definitions : []).map((d) => {
|
|
582
|
-
var _a, _b;
|
|
583
|
-
return builder.captionDefinition({
|
|
584
|
-
term: (_a = this.convertStringToBreakscapedString(d.term)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
585
|
-
description: (_b = this.convertStringToBreakscapedString(d.description)) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING,
|
|
586
|
-
});
|
|
587
|
-
}),
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
return node;
|
|
591
|
-
}
|
|
592
|
-
listItemsToAst(listItems, textFormat, placeholders) {
|
|
175
|
+
processListItems(listItems, placeholders) {
|
|
593
176
|
const nodes = [];
|
|
594
177
|
if (Array.isArray(listItems)) {
|
|
595
178
|
for (const li of listItems) {
|
|
596
|
-
const
|
|
597
|
-
|
|
179
|
+
const node = Object.assign({}, li);
|
|
180
|
+
if (node.body) {
|
|
181
|
+
node.body = {
|
|
182
|
+
body: node.body,
|
|
183
|
+
placeholders,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
598
186
|
if (node)
|
|
599
187
|
nodes.push(node);
|
|
600
188
|
}
|
|
@@ -610,200 +198,44 @@ class JsonParser {
|
|
|
610
198
|
}
|
|
611
199
|
return undefined;
|
|
612
200
|
}
|
|
613
|
-
|
|
614
|
-
var _a;
|
|
201
|
+
processResources(bitType, resource, images, logos) {
|
|
615
202
|
const nodes = [];
|
|
616
|
-
if (resource)
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
// TODO: This code should use the config to handle the combo resources. For now the logic is hardcoded
|
|
620
|
-
// Handle special cases for multiple resource bits (imageResponsive, stillImageFilm)
|
|
621
|
-
if (resource.type === ResourceTag_1.ResourceTag.imageResponsive) {
|
|
622
|
-
const r = resource;
|
|
623
|
-
const imagePortraitNode = this.resourceDataToAst(ResourceTag_1.ResourceTag.imagePortrait, r.imagePortrait);
|
|
624
|
-
const imageLandscapeNode = this.resourceDataToAst(ResourceTag_1.ResourceTag.imageLandscape, r.imageLandscape);
|
|
625
|
-
if (imagePortraitNode)
|
|
626
|
-
nodes.push(imagePortraitNode);
|
|
627
|
-
if (imageLandscapeNode)
|
|
628
|
-
nodes.push(imageLandscapeNode);
|
|
629
|
-
}
|
|
630
|
-
else if (resource.type === ResourceTag_1.ResourceTag.stillImageFilm) {
|
|
631
|
-
const r = resource;
|
|
632
|
-
const imageNode = this.resourceDataToAst(ResourceTag_1.ResourceTag.image, r.image);
|
|
633
|
-
const audioNode = this.resourceDataToAst(ResourceTag_1.ResourceTag.audio, r.audio);
|
|
634
|
-
if (imageNode)
|
|
635
|
-
nodes.push(imageNode);
|
|
636
|
-
if (audioNode)
|
|
637
|
-
nodes.push(audioNode);
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
// Standard single resource case
|
|
641
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
642
|
-
data = resource[resourceKey];
|
|
643
|
-
if (!data)
|
|
644
|
-
return undefined;
|
|
645
|
-
const node = this.resourceDataToAst(resource.type, data);
|
|
646
|
-
if (node)
|
|
647
|
-
nodes.push(node);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.imagesLogoGrave, BitType_1.BitType.prototypeImages])) {
|
|
203
|
+
if (resource)
|
|
204
|
+
nodes.push(resource);
|
|
205
|
+
if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.prototypeImages])) {
|
|
651
206
|
// Add the logo images
|
|
652
207
|
if (Array.isArray(images)) {
|
|
653
208
|
for (const image of images) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
nodes.push(node);
|
|
209
|
+
if (image)
|
|
210
|
+
nodes.push(image);
|
|
657
211
|
}
|
|
658
212
|
}
|
|
659
213
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
if (!data)
|
|
667
|
-
return undefined;
|
|
668
|
-
const dataAsString = StringUtils_1.StringUtils.isString(data) ? data : undefined;
|
|
669
|
-
// url / src / href / app
|
|
670
|
-
const url = data.url || data.src || data.href || data.app || data.body || dataAsString;
|
|
671
|
-
// Sub resources
|
|
672
|
-
const posterImage = this.resourceDataToAst(ResourceTag_1.ResourceTag.image, data.posterImage);
|
|
673
|
-
const thumbnails = data.thumbnails
|
|
674
|
-
? data.thumbnails.map((t) => {
|
|
675
|
-
return this.resourceDataToAst(ResourceTag_1.ResourceTag.image, t);
|
|
676
|
-
})
|
|
677
|
-
: undefined;
|
|
678
|
-
// Resource
|
|
679
|
-
node = resourceBuilder.resource({
|
|
680
|
-
type,
|
|
681
|
-
// Generic (except Article / Document)
|
|
682
|
-
value: this.convertStringToBreakscapedString(url),
|
|
683
|
-
// ImageLikeResource / AudioLikeResource / VideoLikeResource / Article / Document
|
|
684
|
-
format: this.convertStringToBreakscapedString(data.format),
|
|
685
|
-
// ImageLikeResource
|
|
686
|
-
src1x: this.convertStringToBreakscapedString(data.src1x),
|
|
687
|
-
src2x: this.convertStringToBreakscapedString(data.src2x),
|
|
688
|
-
src3x: this.convertStringToBreakscapedString(data.src3x),
|
|
689
|
-
src4x: this.convertStringToBreakscapedString(data.src4x),
|
|
690
|
-
caption: this.convertJsonTextToBreakscapedString(data.caption),
|
|
691
|
-
// ImageLikeResource / VideoLikeResource
|
|
692
|
-
width: (_a = data.width) !== null && _a !== void 0 ? _a : undefined,
|
|
693
|
-
height: (_b = data.height) !== null && _b !== void 0 ? _b : undefined,
|
|
694
|
-
alt: this.convertStringToBreakscapedString(data.alt),
|
|
695
|
-
zoomDisabled: data.zoomDisabled,
|
|
696
|
-
// VideoLikeResource
|
|
697
|
-
duration: data.duration,
|
|
698
|
-
mute: data.mute,
|
|
699
|
-
autoplay: data.autoplay,
|
|
700
|
-
allowSubtitles: data.allowSubtitles,
|
|
701
|
-
showSubtitles: data.showSubtitles,
|
|
702
|
-
posterImage,
|
|
703
|
-
thumbnails,
|
|
704
|
-
// WebsiteLinkResource
|
|
705
|
-
siteName: this.convertStringToBreakscapedString(data.siteName),
|
|
706
|
-
// Generic Resource
|
|
707
|
-
license: this.convertStringToBreakscapedString(data.license),
|
|
708
|
-
copyright: this.convertStringToBreakscapedString(data.copyright),
|
|
709
|
-
showInIndex: data.showInIndex,
|
|
710
|
-
search: this.convertStringToBreakscapedString(data.search),
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
return node;
|
|
714
|
-
}
|
|
715
|
-
bodyToAst(body, textFormat, placeholders) {
|
|
716
|
-
let node;
|
|
717
|
-
let bodyStr;
|
|
718
|
-
const placeholderNodes = {};
|
|
719
|
-
if (textFormat === TextFormat_1.TextFormat.json) {
|
|
720
|
-
// If the text format is JSON, handle appropriately
|
|
721
|
-
let bodyObject = body;
|
|
722
|
-
// Attempt to parse a string body as JSON to support the legacy format
|
|
723
|
-
if (typeof bodyObject === 'string') {
|
|
724
|
-
try {
|
|
725
|
-
bodyObject = JSON.parse(bodyObject);
|
|
726
|
-
}
|
|
727
|
-
catch (e) {
|
|
728
|
-
// Could not parse JSON - set body to null
|
|
729
|
-
bodyObject = null;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
node = builder.body({ bodyJson: bodyObject });
|
|
733
|
-
}
|
|
734
|
-
else {
|
|
735
|
-
if (Array.isArray(body)) {
|
|
736
|
-
// Body is an array (prosemirror like JSON)
|
|
737
|
-
// Parse the body to string in case it is in JSON format
|
|
738
|
-
bodyStr = this.convertJsonTextToBreakscapedString(body, textFormat);
|
|
739
|
-
// Get the placeholders from the text parser
|
|
740
|
-
placeholders = this.textGenerator.getPlaceholders();
|
|
741
|
-
}
|
|
742
|
-
else {
|
|
743
|
-
// Body is a string (legacy bitmark v2, or not bitmark--/++)
|
|
744
|
-
bodyStr = this.convertJsonTextToBreakscapedString(body, textFormat);
|
|
745
|
-
}
|
|
746
|
-
// Placeholders
|
|
747
|
-
if (placeholders) {
|
|
748
|
-
for (const [key, val] of Object.entries(placeholders)) {
|
|
749
|
-
const bit = this.bodyBitToAst(val);
|
|
750
|
-
placeholderNodes[key] = bit;
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
if (bodyStr) {
|
|
754
|
-
// Split the body string and insert the placeholders
|
|
755
|
-
const bodyPartNodes = [];
|
|
756
|
-
const bodyParts = StringUtils_1.StringUtils.splitPlaceholders(bodyStr, Object.keys(placeholderNodes));
|
|
757
|
-
for (let i = 0, len = bodyParts.length; i < len; i++) {
|
|
758
|
-
const bodyPart = bodyParts[i];
|
|
759
|
-
if (placeholderNodes[bodyPart]) {
|
|
760
|
-
// Replace the placeholder
|
|
761
|
-
bodyPartNodes.push(placeholderNodes[bodyPart]);
|
|
762
|
-
}
|
|
763
|
-
else {
|
|
764
|
-
// Treat as text
|
|
765
|
-
const bodyText = this.bodyTextToAst(bodyPart);
|
|
766
|
-
bodyPartNodes.push(bodyText);
|
|
767
|
-
}
|
|
214
|
+
if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.imagesLogoGrave])) {
|
|
215
|
+
// Add the logo images
|
|
216
|
+
if (Array.isArray(logos)) {
|
|
217
|
+
for (const image of logos) {
|
|
218
|
+
if (image)
|
|
219
|
+
nodes.push(image);
|
|
768
220
|
}
|
|
769
|
-
node = builder.body({ bodyParts: bodyPartNodes });
|
|
770
221
|
}
|
|
771
222
|
}
|
|
772
|
-
return
|
|
773
|
-
}
|
|
774
|
-
bodyTextToAst(bodyText) {
|
|
775
|
-
return builder.bodyText({ text: bodyText !== null && bodyText !== void 0 ? bodyText : Breakscape_1.Breakscape.EMPTY_STRING }, false);
|
|
223
|
+
return nodes;
|
|
776
224
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
case BodyBitType_1.BodyBitType.mark: {
|
|
784
|
-
const mark = this.markBitToAst(bit);
|
|
785
|
-
return mark;
|
|
786
|
-
}
|
|
787
|
-
case BodyBitType_1.BodyBitType.select: {
|
|
788
|
-
const select = this.selectBitToAst(bit);
|
|
789
|
-
return select;
|
|
790
|
-
}
|
|
791
|
-
case BodyBitType_1.BodyBitType.highlight: {
|
|
792
|
-
const hightlight = this.highlightBitToAst(bit);
|
|
793
|
-
return hightlight;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
return this.bodyTextToAst(Breakscape_1.Breakscape.EMPTY_STRING);
|
|
225
|
+
processBody(body, placeholders) {
|
|
226
|
+
return {
|
|
227
|
+
body,
|
|
228
|
+
placeholders,
|
|
229
|
+
};
|
|
797
230
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
return undefined;
|
|
231
|
+
processFooter(footerText) {
|
|
232
|
+
if (!footerText)
|
|
233
|
+
return undefined;
|
|
234
|
+
return {
|
|
235
|
+
footer: footerText,
|
|
236
|
+
};
|
|
805
237
|
}
|
|
806
|
-
|
|
238
|
+
processReference(reference) {
|
|
807
239
|
if (Array.isArray(reference) && reference.length > 0) {
|
|
808
240
|
return {
|
|
809
241
|
reference: undefined,
|
|
@@ -815,143 +247,19 @@ class JsonParser {
|
|
|
815
247
|
referenceProperty: undefined,
|
|
816
248
|
};
|
|
817
249
|
}
|
|
818
|
-
gapBitToAst(bit) {
|
|
819
|
-
var _a;
|
|
820
|
-
const { item, lead, hint, instruction, example, isCaseSensitive, solutions } = bit;
|
|
821
|
-
// Build bit
|
|
822
|
-
const bitNode = builder.gap(Object.assign(Object.assign(Object.assign({ solutions: (_a = this.convertStringToBreakscapedString(solutions)) !== null && _a !== void 0 ? _a : [] }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)), { isCaseSensitive }));
|
|
823
|
-
return bitNode;
|
|
824
|
-
}
|
|
825
|
-
markBitToAst(bit) {
|
|
826
|
-
var _a;
|
|
827
|
-
const { solution, mark, item, lead, hint, instruction, example } = bit;
|
|
828
|
-
// Build bit
|
|
829
|
-
const bitNode = builder.mark(Object.assign(Object.assign({ solution: (_a = this.convertStringToBreakscapedString(solution)) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, mark: this.convertStringToBreakscapedString(mark) }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
830
|
-
return bitNode;
|
|
831
|
-
}
|
|
832
|
-
selectBitToAst(bit) {
|
|
833
|
-
const { options, prefix, postfix, item, lead, hint, instruction, example } = bit;
|
|
834
|
-
// Build options bits
|
|
835
|
-
const selectOptionNodes = this.selectOptionBitsToAst(options);
|
|
836
|
-
// Build bit
|
|
837
|
-
const node = builder.select(Object.assign(Object.assign({ options: selectOptionNodes, prefix: this.convertStringToBreakscapedString(prefix), postfix: this.convertStringToBreakscapedString(postfix) }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
838
|
-
return node;
|
|
839
|
-
}
|
|
840
|
-
highlightBitToAst(bit) {
|
|
841
|
-
const { texts, prefix, postfix, item, lead, hint, instruction, example } = bit;
|
|
842
|
-
// Build options bits
|
|
843
|
-
const highlightTextNodes = this.highlightTextBitsToAst(texts);
|
|
844
|
-
// Build bit
|
|
845
|
-
const node = builder.highlight(Object.assign(Object.assign({ texts: highlightTextNodes, prefix: this.convertStringToBreakscapedString(prefix), postfix: this.convertStringToBreakscapedString(postfix) }, this.parseItemLeadHintInstruction(item, lead, hint, instruction)), this.parseExample(example)));
|
|
846
|
-
return node;
|
|
847
|
-
}
|
|
848
|
-
parseItemLeadHintInstruction(item, lead, hint, instruction) {
|
|
849
|
-
return {
|
|
850
|
-
item: this.convertJsonTextToBreakscapedString(item),
|
|
851
|
-
lead: this.convertJsonTextToBreakscapedString(lead),
|
|
852
|
-
pageNumber: '',
|
|
853
|
-
marginNumber: '',
|
|
854
|
-
hint: this.convertJsonTextToBreakscapedString(hint),
|
|
855
|
-
instruction: this.convertJsonTextToBreakscapedString(instruction),
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
parseItemLeadHintInstructionPageNumberMarginNumber(item, lead, hint, instruction, pageNumber, marginNumber) {
|
|
859
|
-
return {
|
|
860
|
-
item: this.convertJsonTextToBreakscapedString(item),
|
|
861
|
-
lead: this.convertJsonTextToBreakscapedString(lead),
|
|
862
|
-
pageNumber: this.convertJsonTextToBreakscapedString(pageNumber),
|
|
863
|
-
marginNumber: this.convertJsonTextToBreakscapedString(marginNumber),
|
|
864
|
-
hint: this.convertJsonTextToBreakscapedString(hint),
|
|
865
|
-
instruction: this.convertJsonTextToBreakscapedString(instruction),
|
|
866
|
-
};
|
|
867
|
-
}
|
|
868
250
|
parseExample(example) {
|
|
869
251
|
if (example == null)
|
|
870
252
|
return undefined;
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
253
|
+
if (example === true)
|
|
254
|
+
return { example: true };
|
|
255
|
+
if (example === false)
|
|
256
|
+
return { example: false };
|
|
257
|
+
const exampleText = StringUtils_1.StringUtils.isString(example) || Array.isArray(example) ? example : undefined;
|
|
258
|
+
if (exampleText) {
|
|
259
|
+
return { example: exampleText };
|
|
874
260
|
}
|
|
875
261
|
return { example: !!example };
|
|
876
262
|
}
|
|
877
|
-
/**
|
|
878
|
-
* Convert the JsonText from the JSON to the AST format:
|
|
879
|
-
* Input:
|
|
880
|
-
* - Bitmark v2: breakscaped string
|
|
881
|
-
* - Bitmark v3: bitmark text JSON (TextAst)
|
|
882
|
-
* Output:
|
|
883
|
-
* - breakscaped string
|
|
884
|
-
*
|
|
885
|
-
* In the case of Bitmark v2 type texts, there is nothing to do but cast the type.
|
|
886
|
-
*
|
|
887
|
-
* @param breakscaped string or TextAst or breakscaped string[] or TextAst[]
|
|
888
|
-
* @param textFormat format of TextAst
|
|
889
|
-
* @returns Breakscaped string or breakscaped string[]
|
|
890
|
-
*/
|
|
891
|
-
convertJsonTextToBreakscapedString(text, textFormat) {
|
|
892
|
-
// NOTE: it is ok to default to bitmarkMinusMinus here as if the text is text then it will not be an array or
|
|
893
|
-
// return true from isAst() and so will be treated as a string
|
|
894
|
-
textFormat = textFormat !== null && textFormat !== void 0 ? textFormat : TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
895
|
-
const bitTagOnly = (textFormat !== TextFormat_1.TextFormat.bitmarkPlusPlus &&
|
|
896
|
-
textFormat !== TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
897
|
-
if (text == null)
|
|
898
|
-
return undefined;
|
|
899
|
-
if (this.textParser.isAst(text)) {
|
|
900
|
-
// Use the text generator to convert the TextAst to breakscaped string
|
|
901
|
-
// this.ast.printTree(text, NodeType.textAst);
|
|
902
|
-
const parsedText = this.textGenerator.generateSync(text, textFormat);
|
|
903
|
-
return parsedText;
|
|
904
|
-
}
|
|
905
|
-
else if (Array.isArray(text)) {
|
|
906
|
-
const strArray = [];
|
|
907
|
-
for (let i = 0, len = text.length; i < len; i++) {
|
|
908
|
-
const t = text[i];
|
|
909
|
-
if (this.textParser.isAst(t)) {
|
|
910
|
-
// Use the text generator to convert the TextAst to breakscaped string
|
|
911
|
-
// this.ast.printTree(text, NodeType.textAst);
|
|
912
|
-
const parsedText = this.textGenerator.generateSync(t, textFormat);
|
|
913
|
-
strArray[i] = parsedText;
|
|
914
|
-
}
|
|
915
|
-
else {
|
|
916
|
-
strArray[i] = Breakscape_1.Breakscape.breakscape(t, {
|
|
917
|
-
bitTagOnly,
|
|
918
|
-
});
|
|
919
|
-
// strArray[i] = t as BreakscapedString;
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
return strArray;
|
|
923
|
-
}
|
|
924
|
-
return Breakscape_1.Breakscape.breakscape(text, {
|
|
925
|
-
bitTagOnly,
|
|
926
|
-
});
|
|
927
|
-
// return text as BreakscapedString as R;
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Convert the string from the JSON to the AST format:
|
|
931
|
-
* Input:
|
|
932
|
-
* - Bitmark v2/v3: string
|
|
933
|
-
* Output:
|
|
934
|
-
* - breakscaped string
|
|
935
|
-
*
|
|
936
|
-
* In the case of Bitmark v2 type texts, there is nothing to do but cast the type.
|
|
937
|
-
*
|
|
938
|
-
* @param text string or TextAst or string[] or TextAst[]
|
|
939
|
-
* @param textFormat format of TextAst
|
|
940
|
-
* @returns Breakscaped string or breakscaped string[]
|
|
941
|
-
*/
|
|
942
|
-
convertStringToBreakscapedString(text) {
|
|
943
|
-
if (text == null)
|
|
944
|
-
return undefined;
|
|
945
|
-
if (Array.isArray(text)) {
|
|
946
|
-
const strArray = [];
|
|
947
|
-
for (let i = 0, len = text.length; i < len; i++) {
|
|
948
|
-
const t = text[i];
|
|
949
|
-
strArray[i] = Breakscape_1.Breakscape.breakscape(t);
|
|
950
|
-
}
|
|
951
|
-
return strArray;
|
|
952
|
-
}
|
|
953
|
-
return Breakscape_1.Breakscape.breakscape(text);
|
|
954
|
-
}
|
|
955
263
|
}
|
|
956
264
|
exports.JsonParser = JsonParser;
|
|
957
265
|
//# sourceMappingURL=JsonParser.js.map
|