@diplodoc/transform 4.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/CHANGELOG.diplodoc.md +38 -0
- package/CHANGELOG.md +404 -0
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/README.ru.md +36 -0
- package/dist/css/yfm.css +736 -0
- package/dist/css/yfm.css.map +7 -0
- package/dist/css/yfm.min.css +2 -0
- package/dist/css/yfm.min.css.map +7 -0
- package/dist/js/code.d.ts +1 -0
- package/dist/js/cut.d.ts +1 -0
- package/dist/js/index.d.ts +5 -0
- package/dist/js/polyfill.d.ts +1 -0
- package/dist/js/tabs.d.ts +1 -0
- package/dist/js/term/index.d.ts +1 -0
- package/dist/js/term/utils.d.ts +10 -0
- package/dist/js/utils.d.ts +2 -0
- package/dist/js/yfm.js +432 -0
- package/dist/js/yfm.js.map +7 -0
- package/dist/js/yfm.min.js +2 -0
- package/dist/js/yfm.min.js.map +7 -0
- package/lib/getObject.d.ts +2 -0
- package/lib/getObject.js +11 -0
- package/lib/getObject.js.map +1 -0
- package/lib/headings.d.ts +4 -0
- package/lib/headings.js +73 -0
- package/lib/headings.js.map +1 -0
- package/lib/highlight.d.ts +3 -0
- package/lib/highlight.js +29 -0
- package/lib/highlight.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +35 -0
- package/lib/index.js.map +1 -0
- package/lib/liquid/conditions.d.ts +4 -0
- package/lib/liquid/conditions.js +181 -0
- package/lib/liquid/conditions.js.map +1 -0
- package/lib/liquid/cycles.d.ts +4 -0
- package/lib/liquid/cycles.js +160 -0
- package/lib/liquid/cycles.js.map +1 -0
- package/lib/liquid/errors.d.ts +3 -0
- package/lib/liquid/errors.js +13 -0
- package/lib/liquid/errors.js.map +1 -0
- package/lib/liquid/evaluation.d.ts +3 -0
- package/lib/liquid/evaluation.js +138 -0
- package/lib/liquid/evaluation.js.map +1 -0
- package/lib/liquid/filters.d.ts +9 -0
- package/lib/liquid/filters.js +22 -0
- package/lib/liquid/filters.js.map +1 -0
- package/lib/liquid/index.d.ts +9 -0
- package/lib/liquid/index.js +87 -0
- package/lib/liquid/index.js.map +1 -0
- package/lib/liquid/lexical.d.ts +14 -0
- package/lib/liquid/lexical.js +79 -0
- package/lib/liquid/lexical.js.map +1 -0
- package/lib/liquid/services/argv.d.ts +15 -0
- package/lib/liquid/services/argv.js +17 -0
- package/lib/liquid/services/argv.js.map +1 -0
- package/lib/liquid/sourceMap.d.ts +24 -0
- package/lib/liquid/sourceMap.js +56 -0
- package/lib/liquid/sourceMap.js.map +1 -0
- package/lib/liquid/substitutions.d.ts +2 -0
- package/lib/liquid/substitutions.js +36 -0
- package/lib/liquid/substitutions.js.map +1 -0
- package/lib/liquid/utils.d.ts +8 -0
- package/lib/liquid/utils.js +24 -0
- package/lib/liquid/utils.js.map +1 -0
- package/lib/log.d.ts +18 -0
- package/lib/log.js +54 -0
- package/lib/log.js.map +1 -0
- package/lib/md.d.ts +14 -0
- package/lib/md.js +96 -0
- package/lib/md.js.map +1 -0
- package/lib/plugins/anchors/collect.d.ts +5 -0
- package/lib/plugins/anchors/collect.js +81 -0
- package/lib/plugins/anchors/collect.js.map +1 -0
- package/lib/plugins/anchors/constants.d.ts +2 -0
- package/lib/plugins/anchors/constants.js +6 -0
- package/lib/plugins/anchors/constants.js.map +1 -0
- package/lib/plugins/anchors/index.d.ts +7 -0
- package/lib/plugins/anchors/index.js +134 -0
- package/lib/plugins/anchors/index.js.map +1 -0
- package/lib/plugins/changelog/collect.d.ts +8 -0
- package/lib/plugins/changelog/collect.js +50 -0
- package/lib/plugins/changelog/collect.js.map +1 -0
- package/lib/plugins/changelog/index.d.ts +6 -0
- package/lib/plugins/changelog/index.js +131 -0
- package/lib/plugins/changelog/index.js.map +1 -0
- package/lib/plugins/changelog/types.d.ts +10 -0
- package/lib/plugins/changelog/types.js +3 -0
- package/lib/plugins/changelog/types.js.map +1 -0
- package/lib/plugins/checkbox/checkbox.d.ts +7 -0
- package/lib/plugins/checkbox/checkbox.js +91 -0
- package/lib/plugins/checkbox/checkbox.js.map +1 -0
- package/lib/plugins/checkbox/index.d.ts +8 -0
- package/lib/plugins/checkbox/index.js +12 -0
- package/lib/plugins/checkbox/index.js.map +1 -0
- package/lib/plugins/code.d.ts +3 -0
- package/lib/plugins/code.js +61 -0
- package/lib/plugins/code.js.map +1 -0
- package/lib/plugins/cut.d.ts +3 -0
- package/lib/plugins/cut.js +70 -0
- package/lib/plugins/cut.js.map +1 -0
- package/lib/plugins/deflist.d.ts +3 -0
- package/lib/plugins/deflist.js +8 -0
- package/lib/plugins/deflist.js.map +1 -0
- package/lib/plugins/file/const.d.ts +27 -0
- package/lib/plugins/file/const.js +47 -0
- package/lib/plugins/file/const.js.map +1 -0
- package/lib/plugins/file/file.d.ts +8 -0
- package/lib/plugins/file/file.js +63 -0
- package/lib/plugins/file/file.js.map +1 -0
- package/lib/plugins/file/index.d.ts +4 -0
- package/lib/plugins/file/index.js +9 -0
- package/lib/plugins/file/index.js.map +1 -0
- package/lib/plugins/images/collect.d.ts +8 -0
- package/lib/plugins/images/collect.js +43 -0
- package/lib/plugins/images/collect.js.map +1 -0
- package/lib/plugins/images/index.d.ts +10 -0
- package/lib/plugins/images/index.js +81 -0
- package/lib/plugins/images/index.js.map +1 -0
- package/lib/plugins/imsize/const.d.ts +7 -0
- package/lib/plugins/imsize/const.js +12 -0
- package/lib/plugins/imsize/const.js.map +1 -0
- package/lib/plugins/imsize/helpers.d.ts +6 -0
- package/lib/plugins/imsize/helpers.js +64 -0
- package/lib/plugins/imsize/helpers.js.map +1 -0
- package/lib/plugins/imsize/index.d.ts +8 -0
- package/lib/plugins/imsize/index.js +12 -0
- package/lib/plugins/imsize/index.js.map +1 -0
- package/lib/plugins/imsize/plugin.d.ts +3 -0
- package/lib/plugins/imsize/plugin.js +188 -0
- package/lib/plugins/imsize/plugin.js.map +1 -0
- package/lib/plugins/includes/collect.d.ts +8 -0
- package/lib/plugins/includes/collect.js +49 -0
- package/lib/plugins/includes/collect.js.map +1 -0
- package/lib/plugins/includes/index.d.ts +8 -0
- package/lib/plugins/includes/index.js +98 -0
- package/lib/plugins/includes/index.js.map +1 -0
- package/lib/plugins/links/collect.d.ts +7 -0
- package/lib/plugins/links/collect.js +74 -0
- package/lib/plugins/links/collect.js.map +1 -0
- package/lib/plugins/links/constants.d.ts +1 -0
- package/lib/plugins/links/constants.js +5 -0
- package/lib/plugins/links/constants.js.map +1 -0
- package/lib/plugins/links/index.d.ts +24 -0
- package/lib/plugins/links/index.js +178 -0
- package/lib/plugins/links/index.js.map +1 -0
- package/lib/plugins/meta.d.ts +3 -0
- package/lib/plugins/meta.js +8 -0
- package/lib/plugins/meta.js.map +1 -0
- package/lib/plugins/monospace.d.ts +3 -0
- package/lib/plugins/monospace.js +109 -0
- package/lib/plugins/monospace.js.map +1 -0
- package/lib/plugins/notes.d.ts +3 -0
- package/lib/plugins/notes.js +103 -0
- package/lib/plugins/notes.js.map +1 -0
- package/lib/plugins/sup.d.ts +3 -0
- package/lib/plugins/sup.js +8 -0
- package/lib/plugins/sup.js.map +1 -0
- package/lib/plugins/table/index.d.ts +3 -0
- package/lib/plugins/table/index.js +215 -0
- package/lib/plugins/table/index.js.map +1 -0
- package/lib/plugins/tabs.d.ts +4 -0
- package/lib/plugins/tabs.js +4 -0
- package/lib/plugins/tabs.js.map +1 -0
- package/lib/plugins/term/constants.d.ts +1 -0
- package/lib/plugins/term/constants.js +5 -0
- package/lib/plugins/term/constants.js.map +1 -0
- package/lib/plugins/term/index.d.ts +3 -0
- package/lib/plugins/term/index.js +108 -0
- package/lib/plugins/term/index.js.map +1 -0
- package/lib/plugins/term/termDefinitions.d.ts +4 -0
- package/lib/plugins/term/termDefinitions.js +125 -0
- package/lib/plugins/term/termDefinitions.js.map +1 -0
- package/lib/plugins/typings.d.ts +12 -0
- package/lib/plugins/typings.js +3 -0
- package/lib/plugins/typings.js.map +1 -0
- package/lib/plugins/utils.d.ts +6 -0
- package/lib/plugins/utils.js +30 -0
- package/lib/plugins/utils.js.map +1 -0
- package/lib/plugins/video/const.d.ts +10 -0
- package/lib/plugins/video/const.js +22 -0
- package/lib/plugins/video/const.js.map +1 -0
- package/lib/plugins/video/index.d.ts +8 -0
- package/lib/plugins/video/index.js +104 -0
- package/lib/plugins/video/index.js.map +1 -0
- package/lib/plugins/video/parsers.d.ts +6 -0
- package/lib/plugins/video/parsers.js +64 -0
- package/lib/plugins/video/parsers.js.map +1 -0
- package/lib/plugins/video/types.d.ts +34 -0
- package/lib/plugins/video/types.js +3 -0
- package/lib/plugins/video/types.js.map +1 -0
- package/lib/plugins/video/utils.d.ts +2 -0
- package/lib/plugins/video/utils.js +25 -0
- package/lib/plugins/video/utils.js.map +1 -0
- package/lib/plugins.d.ts +3 -0
- package/lib/plugins.js +36 -0
- package/lib/plugins.js.map +1 -0
- package/lib/sanitize.d.ts +12 -0
- package/lib/sanitize.js +572 -0
- package/lib/sanitize.js.map +1 -0
- package/lib/title.d.ts +7 -0
- package/lib/title.js +18 -0
- package/lib/title.js.map +1 -0
- package/lib/typings.d.ts +57 -0
- package/lib/typings.js +3 -0
- package/lib/typings.js.map +1 -0
- package/lib/utils.d.ts +13 -0
- package/lib/utils.js +79 -0
- package/lib/utils.js.map +1 -0
- package/lib/utilsFS.d.ts +27 -0
- package/lib/utilsFS.js +89 -0
- package/lib/utilsFS.js.map +1 -0
- package/lib/yfmlint/index.d.ts +26 -0
- package/lib/yfmlint/index.js +72 -0
- package/lib/yfmlint/index.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/index.d.ts +9 -0
- package/lib/yfmlint/markdownlint-custom-rule/index.js +22 -0
- package/lib/yfmlint/markdownlint-custom-rule/index.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.js +33 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.js +33 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.js +29 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.js +47 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.js.map +1 -0
- package/lib/yfmlint/typings.d.ts +12 -0
- package/lib/yfmlint/typings.js +3 -0
- package/lib/yfmlint/typings.js.map +1 -0
- package/lib/yfmlint/utils.d.ts +9 -0
- package/lib/yfmlint/utils.js +22 -0
- package/lib/yfmlint/utils.js.map +1 -0
- package/lib/yfmlint/yfmlint.d.ts +3 -0
- package/lib/yfmlint/yfmlint.js +69 -0
- package/lib/yfmlint/yfmlint.js.map +1 -0
- package/package.json +106 -0
- package/src/.eslintrc +10 -0
- package/src/js/code.ts +65 -0
- package/src/js/cut.ts +57 -0
- package/src/js/index.ts +6 -0
- package/src/js/polyfill.js +27 -0
- package/src/js/term/index.ts +79 -0
- package/src/js/term/utils.ts +151 -0
- package/src/js/utils.ts +9 -0
- package/src/scss/_anchor.scss +33 -0
- package/src/scss/_code.scss +23 -0
- package/src/scss/_common.scss +407 -0
- package/src/scss/_cut.scss +42 -0
- package/src/scss/_file.scss +35 -0
- package/src/scss/_highlight.scss +96 -0
- package/src/scss/_note.scss +73 -0
- package/src/scss/_print.scss +20 -0
- package/src/scss/_term.scss +79 -0
- package/src/scss/_variables.scss +16 -0
- package/src/scss/yfm.scss +11 -0
- package/src/transform/getObject.ts +10 -0
- package/src/transform/headings.ts +88 -0
- package/src/transform/highlight.ts +33 -0
- package/src/transform/index.ts +50 -0
- package/src/transform/liquid/conditions.ts +259 -0
- package/src/transform/liquid/cycles.ts +244 -0
- package/src/transform/liquid/errors.ts +10 -0
- package/src/transform/liquid/evaluation.ts +145 -0
- package/src/transform/liquid/filters.ts +19 -0
- package/src/transform/liquid/index.ts +141 -0
- package/src/transform/liquid/lexical.ts +86 -0
- package/src/transform/liquid/services/argv.ts +23 -0
- package/src/transform/liquid/sourceMap.ts +72 -0
- package/src/transform/liquid/substitutions.ts +40 -0
- package/src/transform/liquid/utils.ts +30 -0
- package/src/transform/log.ts +60 -0
- package/src/transform/md.ts +123 -0
- package/src/transform/plugins/anchors/collect.ts +101 -0
- package/src/transform/plugins/anchors/constants.ts +2 -0
- package/src/transform/plugins/anchors/index.ts +166 -0
- package/src/transform/plugins/changelog/collect.ts +66 -0
- package/src/transform/plugins/changelog/index.ts +164 -0
- package/src/transform/plugins/changelog/types.ts +10 -0
- package/src/transform/plugins/checkbox/checkbox.ts +107 -0
- package/src/transform/plugins/checkbox/index.ts +15 -0
- package/src/transform/plugins/code.ts +79 -0
- package/src/transform/plugins/cut.ts +98 -0
- package/src/transform/plugins/deflist.ts +5 -0
- package/src/transform/plugins/file/README.md +34 -0
- package/src/transform/plugins/file/const.ts +46 -0
- package/src/transform/plugins/file/file.ts +82 -0
- package/src/transform/plugins/file/index.ts +10 -0
- package/src/transform/plugins/images/collect.ts +60 -0
- package/src/transform/plugins/images/index.ts +119 -0
- package/src/transform/plugins/imsize/const.ts +7 -0
- package/src/transform/plugins/imsize/helpers.ts +75 -0
- package/src/transform/plugins/imsize/index.ts +14 -0
- package/src/transform/plugins/imsize/plugin.ts +214 -0
- package/src/transform/plugins/includes/collect.ts +73 -0
- package/src/transform/plugins/includes/index.ts +127 -0
- package/src/transform/plugins/links/collect.ts +92 -0
- package/src/transform/plugins/links/constants.ts +1 -0
- package/src/transform/plugins/links/index.ts +218 -0
- package/src/transform/plugins/meta.ts +5 -0
- package/src/transform/plugins/monospace.ts +141 -0
- package/src/transform/plugins/notes.ts +134 -0
- package/src/transform/plugins/sup.ts +5 -0
- package/src/transform/plugins/table/index.ts +290 -0
- package/src/transform/plugins/tabs.ts +3 -0
- package/src/transform/plugins/term/constants.ts +1 -0
- package/src/transform/plugins/term/index.ts +139 -0
- package/src/transform/plugins/term/termDefinitions.ts +177 -0
- package/src/transform/plugins/typings.ts +14 -0
- package/src/transform/plugins/utils.ts +38 -0
- package/src/transform/plugins/video/const.ts +20 -0
- package/src/transform/plugins/video/index.ts +134 -0
- package/src/transform/plugins/video/parsers.ts +65 -0
- package/src/transform/plugins/video/types.ts +27 -0
- package/src/transform/plugins/video/utils.ts +24 -0
- package/src/transform/plugins.ts +35 -0
- package/src/transform/sanitize.ts +596 -0
- package/src/transform/title.ts +22 -0
- package/src/transform/typings.ts +64 -0
- package/src/transform/utils.ts +91 -0
- package/src/transform/utilsFS.ts +128 -0
- package/src/transform/yfmlint/README.md +48 -0
- package/src/transform/yfmlint/index.ts +124 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/index.ts +9 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts +36 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm002.ts +33 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm003.ts +33 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm004.ts +27 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm005.ts +27 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm006.ts +26 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts +28 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm008.ts +26 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm009.ts +54 -0
- package/src/transform/yfmlint/typings.ts +13 -0
- package/src/transform/yfmlint/utils.ts +31 -0
- package/src/transform/yfmlint/yfmlint.ts +73 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.evalExp = void 0;
|
|
30
|
+
const lexical = __importStar(require("./lexical"));
|
|
31
|
+
const getObject_1 = __importDefault(require("../getObject"));
|
|
32
|
+
const log_1 = require("../log");
|
|
33
|
+
const filters_1 = __importDefault(require("./filters"));
|
|
34
|
+
const errors_1 = require("./errors");
|
|
35
|
+
const operators = {
|
|
36
|
+
'==': ((l, r) => l === r),
|
|
37
|
+
'!=': ((l, r) => l !== r),
|
|
38
|
+
'>': ((l, r) => l !== null && r !== null && l > r),
|
|
39
|
+
'<': ((l, r) => l !== null && r !== null && l < r),
|
|
40
|
+
'>=': ((l, r) => l !== null && r !== null && l >= r),
|
|
41
|
+
'<=': ((l, r) => l !== null && r !== null && l <= r),
|
|
42
|
+
contains: ((l, r) => l !== null && r !== null && l.includes(r)),
|
|
43
|
+
and: ((l, r) => isTruthy(l) && isTruthy(r)),
|
|
44
|
+
or: ((l, r) => isTruthy(l) || isTruthy(r)),
|
|
45
|
+
'|': ((l, filter, exp) => {
|
|
46
|
+
try {
|
|
47
|
+
return filter(l);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
if (!filter) {
|
|
51
|
+
throw new errors_1.SkippedEvalError('Cannot apply an unsupported filter', exp);
|
|
52
|
+
}
|
|
53
|
+
throw new errors_1.SkippedEvalError('There are some problems with the filter', exp);
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
'.': ((l, r, exp) => {
|
|
57
|
+
const parsed = lexical.getParsedMethod(r);
|
|
58
|
+
try {
|
|
59
|
+
if (!parsed)
|
|
60
|
+
throw new Error();
|
|
61
|
+
const { name, args } = parsed;
|
|
62
|
+
return l[name](...args);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
if (!l) {
|
|
66
|
+
throw new errors_1.SkippedEvalError(`Cannot apply the function '${name}' on an undefined variable`, exp);
|
|
67
|
+
}
|
|
68
|
+
throw new errors_1.SkippedEvalError('There are some problems with the function', exp);
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
};
|
|
72
|
+
function evalValue(originStr, scope) {
|
|
73
|
+
const str = originStr && originStr.trim();
|
|
74
|
+
if (!str) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
if (lexical.isLiteral(str)) {
|
|
78
|
+
return lexical.parseLiteral(str);
|
|
79
|
+
}
|
|
80
|
+
if (lexical.isVariable(str)) {
|
|
81
|
+
return (0, getObject_1.default)(str, scope);
|
|
82
|
+
}
|
|
83
|
+
throw new TypeError(`cannot eval '${str}' as value`);
|
|
84
|
+
}
|
|
85
|
+
function isTruthy(val) {
|
|
86
|
+
return !isFalsy(val);
|
|
87
|
+
}
|
|
88
|
+
function isFalsy(val) {
|
|
89
|
+
return val === false || undefined === val || val === null;
|
|
90
|
+
}
|
|
91
|
+
function evalExp(exp, scope) {
|
|
92
|
+
const operatorREs = lexical.operators;
|
|
93
|
+
let match;
|
|
94
|
+
if (Object.getOwnPropertyNames(filters_1.default).includes(exp.trim())) {
|
|
95
|
+
return filters_1.default[exp.trim()];
|
|
96
|
+
}
|
|
97
|
+
if (lexical.isSupportedMethod(exp)) {
|
|
98
|
+
return exp;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
for (let i = 0; i < operatorREs.length; i++) {
|
|
102
|
+
const operatorRE = operatorREs[i];
|
|
103
|
+
const expRE = new RegExp(`^(${lexical.quoteBalanced.source})(${operatorRE.source})(${lexical.quoteBalanced.source})$`);
|
|
104
|
+
if ((match = exp.match(expRE))) {
|
|
105
|
+
const l = evalExp(match[1], scope);
|
|
106
|
+
const operator = match[2].trim();
|
|
107
|
+
const op = operators[operator];
|
|
108
|
+
const r = evalExp(match[3], scope);
|
|
109
|
+
if (operator !== '.' ||
|
|
110
|
+
(operator === '.' && lexical.isSupportedMethod(r))) {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
|
+
return op(l, r, exp);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if ((match = exp.match(lexical.rangeLine))) {
|
|
117
|
+
const low = evalValue(match[1], scope);
|
|
118
|
+
const high = evalValue(match[2], scope);
|
|
119
|
+
const range = [];
|
|
120
|
+
for (let j = low; j <= high; j++) {
|
|
121
|
+
range.push(j);
|
|
122
|
+
}
|
|
123
|
+
return range;
|
|
124
|
+
}
|
|
125
|
+
return evalValue(exp, scope);
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
if (e instanceof errors_1.SkippedEvalError) {
|
|
129
|
+
log_1.log.warn(`Skip error: ${e}`);
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
log_1.log.error(`Error: ${e}`);
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
exports.evalExp = evalExp;
|
|
137
|
+
exports.default = (exp, scope) => Boolean(evalExp(exp, scope));
|
|
138
|
+
//# sourceMappingURL=evaluation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation.js","sourceRoot":"","sources":["../../src/transform/liquid/evaluation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAqC;AACrC,6DAAqC;AACrC,gCAA2B;AAC3B,wDAAgC;AAChC,qCAA0C;AAY1C,MAAM,SAAS,GAAwD;IACnE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,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 -0,0 +1,9 @@
|
|
|
1
|
+
export declare function length(input: string): number;
|
|
2
|
+
export declare function capitalize(input: string): string;
|
|
3
|
+
export declare function escapeMarkdown(input: string): string;
|
|
4
|
+
declare const index: {
|
|
5
|
+
length: typeof length;
|
|
6
|
+
capitalize: typeof capitalize;
|
|
7
|
+
escapeMarkdown: typeof escapeMarkdown;
|
|
8
|
+
};
|
|
9
|
+
export default index;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeMarkdown = exports.capitalize = exports.length = void 0;
|
|
4
|
+
function length(input) {
|
|
5
|
+
return input.length;
|
|
6
|
+
}
|
|
7
|
+
exports.length = length;
|
|
8
|
+
function capitalize(input) {
|
|
9
|
+
return String(input).replace(/^([a-z])/, (_m, chr) => chr.toUpperCase());
|
|
10
|
+
}
|
|
11
|
+
exports.capitalize = capitalize;
|
|
12
|
+
function escapeMarkdown(input) {
|
|
13
|
+
return String(input).replace(/([\\`*_{}[\]()#+\-.!|])/g, '\\$1');
|
|
14
|
+
}
|
|
15
|
+
exports.escapeMarkdown = escapeMarkdown;
|
|
16
|
+
const index = {
|
|
17
|
+
length,
|
|
18
|
+
capitalize,
|
|
19
|
+
escapeMarkdown,
|
|
20
|
+
};
|
|
21
|
+
exports.default = index;
|
|
22
|
+
//# sourceMappingURL=filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/transform/liquid/filters.ts"],"names":[],"mappings":";;;AAAA,SAAgB,MAAM,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,MAAM,CAAC;AACxB,CAAC;AAFD,wBAEC;AAED,SAAgB,UAAU,CAAC,KAAa;IACpC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7E,CAAC;AAFD,gCAEC;AAED,SAAgB,cAAc,CAAC,KAAa;IACxC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC;AAFD,wCAEC;AAED,MAAM,KAAK,GAAG;IACV,MAAM;IACN,UAAU;IACV,cAAc;CACjB,CAAC;AAEF,kBAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArgvSettings } from './services/argv';
|
|
2
|
+
import { Dictionary } from 'lodash';
|
|
3
|
+
declare function liquid<B extends boolean = false, C = B extends false ? string : {
|
|
4
|
+
output: string;
|
|
5
|
+
sourceMap: Dictionary<string>;
|
|
6
|
+
}>(originInput: string, vars: Record<string, unknown>, path?: string, settings?: ArgvSettings & {
|
|
7
|
+
withSourceMap?: B;
|
|
8
|
+
}): C;
|
|
9
|
+
export default liquid;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const substitutions_1 = __importDefault(require("./substitutions"));
|
|
7
|
+
const sourceMap_1 = require("./sourceMap");
|
|
8
|
+
const cycles_1 = __importDefault(require("./cycles"));
|
|
9
|
+
const conditions_1 = __importDefault(require("./conditions"));
|
|
10
|
+
const argv_1 = __importDefault(require("./services/argv"));
|
|
11
|
+
const fence = '```';
|
|
12
|
+
const find = (open, close, string, index) => {
|
|
13
|
+
const start = string.indexOf(open, index);
|
|
14
|
+
const end = start > -1 ? string.indexOf(close, start + open.length) : -1;
|
|
15
|
+
return [start, end];
|
|
16
|
+
};
|
|
17
|
+
const replace = (open, close, value, string) => {
|
|
18
|
+
let result = '';
|
|
19
|
+
let carriage = 0;
|
|
20
|
+
let [start, end] = find(open, close, string, carriage);
|
|
21
|
+
while (start > -1 && end > -1) {
|
|
22
|
+
const fragment = string.slice(start + open.length, end);
|
|
23
|
+
result += string.slice(carriage, start) + open + value(fragment) + close;
|
|
24
|
+
carriage = end + close.length;
|
|
25
|
+
[start, end] = find(open, close, string, carriage);
|
|
26
|
+
}
|
|
27
|
+
result += string.slice(carriage);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
function saveCode(str, vars, codes, path, substitutions) {
|
|
31
|
+
return replace(fence, fence, (code) => {
|
|
32
|
+
const codeWithVars = substitutions ? (0, substitutions_1.default)(code, vars, path) : code;
|
|
33
|
+
const index = codes.push(codeWithVars) - 1;
|
|
34
|
+
/* Keep the same count of lines to avoid transformation of the source map */
|
|
35
|
+
const codeLines = codeWithVars.split('\n');
|
|
36
|
+
const emptyLines = codeLines.length > 1 ? '\n'.repeat(codeLines.length) : '';
|
|
37
|
+
return `${index}${emptyLines}`;
|
|
38
|
+
}, str);
|
|
39
|
+
}
|
|
40
|
+
function repairCode(str, codes) {
|
|
41
|
+
return replace(fence, fence, (code) => codes[Number(code)], str);
|
|
42
|
+
}
|
|
43
|
+
function liquid(originInput, vars, path, settings) {
|
|
44
|
+
const { cycles = true, conditions = true, substitutions = true, conditionsInCode = false, keepNotVar = false, withSourceMap, } = settings || {};
|
|
45
|
+
argv_1.default.init({
|
|
46
|
+
cycles,
|
|
47
|
+
conditions,
|
|
48
|
+
substitutions,
|
|
49
|
+
conditionsInCode,
|
|
50
|
+
keepNotVar,
|
|
51
|
+
withSourceMap,
|
|
52
|
+
});
|
|
53
|
+
const codes = [];
|
|
54
|
+
let output = conditionsInCode
|
|
55
|
+
? originInput
|
|
56
|
+
: saveCode(originInput, vars, codes, path, substitutions);
|
|
57
|
+
let sourceMap = {};
|
|
58
|
+
if (withSourceMap) {
|
|
59
|
+
const lines = output.split('\n');
|
|
60
|
+
sourceMap = lines.reduce((acc, _cur, index) => {
|
|
61
|
+
acc[index + 1] = index + 1;
|
|
62
|
+
return acc;
|
|
63
|
+
}, {});
|
|
64
|
+
}
|
|
65
|
+
if (cycles) {
|
|
66
|
+
output = (0, cycles_1.default)(output, vars, path, { sourceMap });
|
|
67
|
+
}
|
|
68
|
+
if (conditions) {
|
|
69
|
+
output = (0, conditions_1.default)(output, vars, path, { sourceMap });
|
|
70
|
+
}
|
|
71
|
+
if (substitutions) {
|
|
72
|
+
output = (0, substitutions_1.default)(output, vars, path);
|
|
73
|
+
}
|
|
74
|
+
output = conditionsInCode ? output : repairCode(output, codes);
|
|
75
|
+
codes.length = 0;
|
|
76
|
+
if (withSourceMap) {
|
|
77
|
+
return {
|
|
78
|
+
output,
|
|
79
|
+
sourceMap: (0, sourceMap_1.prepareSourceMap)(sourceMap),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return output;
|
|
83
|
+
}
|
|
84
|
+
// 'export default' instead of 'export = ' because of circular dependency with './cycles.ts'.
|
|
85
|
+
// somehow it breaks import in './cycles.ts' and imports nothing
|
|
86
|
+
exports.default = liquid;
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/liquid/index.ts"],"names":[],"mappings":";;;;;AAAA,oEAAiD;AACjD,2CAA6C;AAE7C,sDAAmC;AACnC,8DAA2C;AAE3C,2DAA0D;AAG1D,MAAM,KAAK,GAAG,KAAK,CAAC;AAEpB,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;IACxE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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AM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAA2B,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAClE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;YAE3B,OAAO,GAAG,CAAC;QACf,CAAC,EAAE,EAAE,CAAC,CAAC;KACV;IAED,IAAI,MAAM,EAAE;QACR,MAAM,GAAG,IAAA,gBAAW,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,SAAS,EAAC,CAAC,CAAC;KACzD;IAED,IAAI,UAAU,EAAE;QACZ,MAAM,GAAG,IAAA,oBAAe,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,SAAS,EAAC,CAAC,CAAC;KAC7D;IAED,IAAI,aAAa,EAAE;QACf,MAAM,GAAG,IAAA,uBAAkB,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;KACnD;IAED,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/D,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAEjB,IAAI,aAAa,EAAE;QACf,OAAO;YACH,MAAM;YACN,SAAS,EAAE,IAAA,4BAAgB,EAAC,SAAS,CAAC;SACzB,CAAC;KACrB;IAED,OAAO,MAAsB,CAAC;AAClC,CAAC;AAED,6FAA6F;AAC7F,gEAAgE;AAChE,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const quoteBalanced: RegExp;
|
|
2
|
+
export declare const vars: RegExp;
|
|
3
|
+
export declare const variable: RegExp;
|
|
4
|
+
export declare const tagLine: RegExp;
|
|
5
|
+
export declare const rangeLine: RegExp;
|
|
6
|
+
export declare const operators: RegExp[];
|
|
7
|
+
export declare const isSupportedMethod: (exp: string) => boolean;
|
|
8
|
+
export declare const getParsedMethod: (exp: String) => {
|
|
9
|
+
name: string;
|
|
10
|
+
args: string[];
|
|
11
|
+
} | null;
|
|
12
|
+
export declare const isLiteral: (str: string) => boolean;
|
|
13
|
+
export declare const isVariable: (str: string) => boolean;
|
|
14
|
+
export declare function parseLiteral(str: string): string | number | boolean;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseLiteral = exports.isVariable = exports.isLiteral = exports.getParsedMethod = exports.isSupportedMethod = exports.operators = exports.rangeLine = exports.tagLine = exports.variable = exports.vars = exports.quoteBalanced = void 0;
|
|
4
|
+
// quote related
|
|
5
|
+
const singleQuoted = /'[^']*'/;
|
|
6
|
+
const doubleQuoted = /"[^"]*"/;
|
|
7
|
+
const quoted = new RegExp(`${singleQuoted.source}|${doubleQuoted.source}`);
|
|
8
|
+
exports.quoteBalanced = new RegExp(`(?:${quoted.source}|[^'"])*`);
|
|
9
|
+
exports.vars = /((not_var)?({{2}([. \w-|(),]+)}{2}))/gm;
|
|
10
|
+
// basic types
|
|
11
|
+
const number = /-?\d+\.?\d*|\.?\d+/;
|
|
12
|
+
const bool = /true|false/;
|
|
13
|
+
// property access
|
|
14
|
+
const identifier = /[\w-|]+[?]?/;
|
|
15
|
+
const subscript = new RegExp(`\\[(?:${quoted.source}|[\\w-\\.]+)\\]`);
|
|
16
|
+
const literal = new RegExp(`(?:${quoted.source}|${bool.source}|${number.source})`);
|
|
17
|
+
exports.variable = new RegExp(`${identifier.source}(?:\\.${identifier.source}|${subscript.source})*`);
|
|
18
|
+
// range related
|
|
19
|
+
const rangeLimit = new RegExp(`(?:${exports.variable.source}|${number.source})`);
|
|
20
|
+
const rangeCapture = new RegExp(`\\((${rangeLimit.source})\\.\\.(${rangeLimit.source})\\)`);
|
|
21
|
+
// full match
|
|
22
|
+
exports.tagLine = new RegExp(`^\\s*(${identifier.source})\\s*([\\s\\S]*)\\s*$`);
|
|
23
|
+
const literalLine = new RegExp(`^${literal.source}$`, 'i');
|
|
24
|
+
const variableLine = new RegExp(`^${exports.variable.source}$`);
|
|
25
|
+
const numberLine = new RegExp(`^${number.source}$`);
|
|
26
|
+
const boolLine = new RegExp(`^${bool.source}$`, 'i');
|
|
27
|
+
const quotedLine = new RegExp(`^${quoted.source}$`);
|
|
28
|
+
exports.rangeLine = new RegExp(`^${rangeCapture.source}$`);
|
|
29
|
+
exports.operators = [
|
|
30
|
+
/\s+or\s+/,
|
|
31
|
+
/\s+and\s+/,
|
|
32
|
+
/[=]=|!=|<=|>=|<|>|\s+contains\s+/,
|
|
33
|
+
/\s+\|\s+/,
|
|
34
|
+
/\s+\|/,
|
|
35
|
+
/\|\s+/,
|
|
36
|
+
/\./,
|
|
37
|
+
];
|
|
38
|
+
const prepareArgsForMethods = {
|
|
39
|
+
slice: (args) => args.map((arg) => Number(arg)),
|
|
40
|
+
};
|
|
41
|
+
const supportedMethods = Object.keys(prepareArgsForMethods);
|
|
42
|
+
const supportedMethodsRE = new RegExp(`^(${supportedMethods.join('\\|')})\\(([^)]*)\\)$`);
|
|
43
|
+
const isSupportedMethod = (exp) => {
|
|
44
|
+
return supportedMethodsRE.test(exp);
|
|
45
|
+
};
|
|
46
|
+
exports.isSupportedMethod = isSupportedMethod;
|
|
47
|
+
const getParsedMethod = (exp) => {
|
|
48
|
+
const match = exp.match(supportedMethodsRE);
|
|
49
|
+
if (!match)
|
|
50
|
+
return null;
|
|
51
|
+
const name = match[1];
|
|
52
|
+
const args = match[2].split(/[\s,]+/);
|
|
53
|
+
return {
|
|
54
|
+
name,
|
|
55
|
+
args,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
exports.getParsedMethod = getParsedMethod;
|
|
59
|
+
const isLiteral = (str) => literalLine.test(str);
|
|
60
|
+
exports.isLiteral = isLiteral;
|
|
61
|
+
const isVariable = (str) => variableLine.test(str);
|
|
62
|
+
exports.isVariable = isVariable;
|
|
63
|
+
function parseLiteral(str) {
|
|
64
|
+
let res = str.match(numberLine);
|
|
65
|
+
if (res) {
|
|
66
|
+
return Number(str);
|
|
67
|
+
}
|
|
68
|
+
res = str.match(boolLine);
|
|
69
|
+
if (res) {
|
|
70
|
+
return str.toLowerCase() === 'true';
|
|
71
|
+
}
|
|
72
|
+
res = str.match(quotedLine);
|
|
73
|
+
if (res) {
|
|
74
|
+
return str.slice(1, -1);
|
|
75
|
+
}
|
|
76
|
+
throw new TypeError(`cannot parse '${str}' as literal`);
|
|
77
|
+
}
|
|
78
|
+
exports.parseLiteral = parseLiteral;
|
|
79
|
+
//# sourceMappingURL=lexical.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical.js","sourceRoot":"","sources":["../../src/transform/liquid/lexical.ts"],"names":[],"mappings":";;;AAAA,gBAAgB;AAChB,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9D,QAAA,aAAa,GAAG,IAAI,MAAM,CAAC,MAAM,MAAM,CAAC,MAAM,UAAU,CAAC,CAAC;AAE1D,QAAA,IAAI,GAAG,wCAAwC,CAAC;AAE7D,cAAc;AACd,MAAM,MAAM,GAAG,oBAAoB,CAAC;AACpC,MAAM,IAAI,GAAG,YAAY,CAAC;AAE1B,kBAAkB;AAClB,MAAM,UAAU,GAAG,aAAa,CAAC;AACjC,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,iBAAiB,CAAC,CAAC;AACtE,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,MAAM,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AACtE,QAAA,QAA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AQ,CAAC,CAAC;IAC1B,IAAI,GAAG,EAAE;QACL,OAAO,GAAG,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;KACvC;IACD,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5B,IAAI,GAAG,EAAE;QACL,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC3B;IAED,MAAM,IAAI,SAAS,CAAC,iBAAiB,GAAG,cAAc,CAAC,CAAC;AAC5D,CAAC;AAhBD,oCAgBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type ArgvSettings = {
|
|
2
|
+
conditions?: boolean;
|
|
3
|
+
conditionsInCode?: boolean;
|
|
4
|
+
cycles?: boolean;
|
|
5
|
+
substitutions?: boolean;
|
|
6
|
+
keepNotVar?: boolean;
|
|
7
|
+
withSourceMap?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function getConfig(): ArgvSettings;
|
|
10
|
+
export declare function init(argv: ArgvSettings): void;
|
|
11
|
+
declare const _default: {
|
|
12
|
+
init: typeof init;
|
|
13
|
+
getConfig: typeof getConfig;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.init = exports.getConfig = void 0;
|
|
4
|
+
let _argv;
|
|
5
|
+
function getConfig() {
|
|
6
|
+
return _argv || {};
|
|
7
|
+
}
|
|
8
|
+
exports.getConfig = getConfig;
|
|
9
|
+
function init(argv) {
|
|
10
|
+
_argv = Object.assign({}, argv);
|
|
11
|
+
}
|
|
12
|
+
exports.init = init;
|
|
13
|
+
exports.default = {
|
|
14
|
+
init,
|
|
15
|
+
getConfig,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=argv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argv.js","sourceRoot":"","sources":["../../../src/transform/liquid/services/argv.ts"],"names":[],"mappings":";;;AASA,IAAI,KAAmB,CAAC;AAExB,SAAgB,SAAS;IACrB,OAAO,KAAK,IAAI,EAAE,CAAC;AACvB,CAAC;AAFD,8BAEC;AAED,SAAgB,IAAI,CAAC,IAAkB;IACnC,KAAK,qBAAO,IAAI,CAAC,CAAC;AACtB,CAAC;AAFD,oBAEC;AAED,kBAAe;IACX,IAAI;IACJ,SAAS;CACZ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function getLineNumber(input: string, index: number): number;
|
|
2
|
+
export declare function prepareSourceMap(sourceMap: object): import("lodash").Dictionary<string>;
|
|
3
|
+
declare type Options = {
|
|
4
|
+
firstLineNumber: number;
|
|
5
|
+
lastLineNumber: number;
|
|
6
|
+
sourceMap: Record<number, number>;
|
|
7
|
+
};
|
|
8
|
+
declare type MoveLinesOptions = {
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
offset: number;
|
|
12
|
+
withReplace?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function createSourceMapApi({ firstLineNumber, lastLineNumber, sourceMap }: Options): {
|
|
15
|
+
isInlineTag: boolean;
|
|
16
|
+
getSourceMapValue: (i: number) => number;
|
|
17
|
+
moveLines: ({ start, end, offset, withReplace }: MoveLinesOptions) => void;
|
|
18
|
+
removeLines: ({ start, end }: {
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
}) => void;
|
|
22
|
+
removeLine: (i: number) => void;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createSourceMapApi = exports.prepareSourceMap = exports.getLineNumber = void 0;
|
|
7
|
+
const invert_1 = __importDefault(require("lodash/invert"));
|
|
8
|
+
const DELETED_LINE = Number.MIN_SAFE_INTEGER;
|
|
9
|
+
function getLineNumber(input, index) {
|
|
10
|
+
return input.substring(0, index).split('\n').length;
|
|
11
|
+
}
|
|
12
|
+
exports.getLineNumber = getLineNumber;
|
|
13
|
+
function prepareSourceMap(sourceMap) {
|
|
14
|
+
const newToOldMap = (0, invert_1.default)(sourceMap);
|
|
15
|
+
delete newToOldMap[DELETED_LINE];
|
|
16
|
+
return newToOldMap;
|
|
17
|
+
}
|
|
18
|
+
exports.prepareSourceMap = prepareSourceMap;
|
|
19
|
+
function createSourceMapApi({ firstLineNumber, lastLineNumber, sourceMap }) {
|
|
20
|
+
const isInlineTag = firstLineNumber === lastLineNumber;
|
|
21
|
+
const newToOldIndexes = (0, invert_1.default)(sourceMap);
|
|
22
|
+
const getOriginIndex = (i) => Number(newToOldIndexes[i]);
|
|
23
|
+
const setSourceMapValue = (i, value) => {
|
|
24
|
+
sourceMap[getOriginIndex(i)] = value;
|
|
25
|
+
};
|
|
26
|
+
const getSourceMapValue = (i) => sourceMap[getOriginIndex(i)];
|
|
27
|
+
const moveLines = ({ start, end, offset, withReplace = false }) => {
|
|
28
|
+
if (isInlineTag) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
for (let i = start; i <= end; i++) {
|
|
32
|
+
const newLineNumber = i + offset;
|
|
33
|
+
setSourceMapValue(i, newLineNumber);
|
|
34
|
+
if (withReplace) {
|
|
35
|
+
setSourceMapValue(newLineNumber, DELETED_LINE);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const removeLine = (i) => {
|
|
40
|
+
setSourceMapValue(i, DELETED_LINE);
|
|
41
|
+
};
|
|
42
|
+
const removeLines = ({ start, end }) => {
|
|
43
|
+
for (let i = start; i <= end; i++) {
|
|
44
|
+
removeLine(i);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
isInlineTag,
|
|
49
|
+
getSourceMapValue,
|
|
50
|
+
moveLines,
|
|
51
|
+
removeLines,
|
|
52
|
+
removeLine,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.createSourceMapApi = createSourceMapApi;
|
|
56
|
+
//# sourceMappingURL=sourceMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceMap.js","sourceRoot":"","sources":["../../src/transform/liquid/sourceMap.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAmC;AAEnC,MAAM,YAAY,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAE7C,SAAgB,aAAa,CAAC,KAAa,EAAE,KAAa;IACtD,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AACxD,CAAC;AAFD,sCAEC;AAED,SAAgB,gBAAgB,CAAC,SAAiB;IAC9C,MAAM,WAAW,GAAG,IAAA,gBAAM,EAAC,SAAS,CAAC,CAAC;IACtC,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;IAEjC,OAAO,WAAW,CAAC;AACvB,CAAC;AALD,4CAKC;AAeD,SAAgB,kBAAkB,CAAC,EAAC,eAAe,EAAE,cAAc,EAAE,SAAS,EAAU;IACpF,MAAM,WAAW,GAAG,eAAe,KAAK,cAAc,CAAC;IACvD,MAAM,eAAe,GAAG,IAAA,gBAAM,EAAC,SAAS,CAAC,CAAC;IAE1C,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjE,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,KAAa,EAAE,EAAE;QACnD,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACzC,CAAC,CAAC;IACF,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtE,MAAM,SAAS,GAAG,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,GAAG,KAAK,EAAmB,EAAE,EAAE;QAC9E,IAAI,WAAW,EAAE;YACb,OAAO;SACV;QAED,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE;YAC/B,MAAM,aAAa,GAAG,CAAC,GAAG,MAAM,CAAC;YACjC,iBAAiB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;YAEpC,IAAI,WAAW,EAAE;gBACb,iBAAiB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;aAClD;SACJ;IACL,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,EAAE;QAC7B,iBAAiB,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IACvC,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,EAAC,KAAK,EAAE,GAAG,EAA+B,EAAE,EAAE;QAC/D,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE;YAC/B,UAAU,CAAC,CAAC,CAAC,CAAC;SACjB;IACL,CAAC,CAAC;IAEF,OAAO;QACH,WAAW;QACX,iBAAiB;QACjB,SAAS;QACT,WAAW;QACX,UAAU;KACb,CAAC;AACN,CAAC;AA3CD,gDA2CC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const chalk_1 = require("chalk");
|
|
6
|
+
const argv_1 = __importDefault(require("./services/argv"));
|
|
7
|
+
const getObject_1 = __importDefault(require("../getObject"));
|
|
8
|
+
const evaluation_1 = require("./evaluation");
|
|
9
|
+
const log_1 = require("../log");
|
|
10
|
+
const lexical_1 = require("./lexical");
|
|
11
|
+
const substitutions = (str, builtVars, path) => {
|
|
12
|
+
const { keepNotVar } = argv_1.default.getConfig();
|
|
13
|
+
return str.replace(lexical_1.vars, (match, _groupNotVar, flag, groupVar, groupVarValue) => {
|
|
14
|
+
if (flag) {
|
|
15
|
+
return keepNotVar ? _groupNotVar : groupVar;
|
|
16
|
+
}
|
|
17
|
+
const trimVarPath = groupVarValue.trim();
|
|
18
|
+
if (trimVarPath.startsWith('.')) {
|
|
19
|
+
return groupVar;
|
|
20
|
+
}
|
|
21
|
+
let value;
|
|
22
|
+
if ((0, lexical_1.isVariable)(trimVarPath)) {
|
|
23
|
+
value = (0, getObject_1.default)(trimVarPath, builtVars);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
value = (0, evaluation_1.evalExp)(trimVarPath, builtVars);
|
|
27
|
+
}
|
|
28
|
+
if (value === undefined) {
|
|
29
|
+
value = match;
|
|
30
|
+
log_1.log.warn(`Variable ${(0, chalk_1.bold)(trimVarPath)} not found${path ? ` in ${(0, chalk_1.bold)(path)}` : ''}`);
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
module.exports = substitutions;
|
|
36
|
+
//# sourceMappingURL=substitutions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"substitutions.js","sourceRoot":"","sources":["../../src/transform/liquid/substitutions.ts"],"names":[],"mappings":";;;;AAAA,iCAA2B;AAE3B,2DAA0C;AAC1C,6DAAqC;AACrC,6CAAqC;AACrC,gCAA2B;AAC3B,uCAAqD;AAErD,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,SAAkC,EAAE,IAAa,EAAE,EAAE;IACrF,MAAM,EAAC,UAAU,EAAC,GAAG,cAAW,CAAC,SAAS,EAAE,CAAC;IAE7C,OAAO,GAAG,CAAC,OAAO,CAAC,cAAM,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE;QAC9E,IAAI,IAAI,EAAE;YACN,OAAO,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;SAC/C;QAED,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;QAEzC,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC7B,OAAO,QAAQ,CAAC;SACnB;QAED,IAAI,KAAK,CAAC;QACV,IAAI,IAAA,oBAAU,EAAC,WAAW,CAAC,EAAE;YACzB,KAAK,GAAG,IAAA,mBAAS,EAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SAC7C;aAAM;YACH,KAAK,GAAG,IAAA,oBAAO,EAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SAC3C;QAED,IAAI,KAAK,KAAK,SAAS,EAAE;YACrB,KAAK,GAAG,KAAK,CAAC;YAEd,SAAG,CAAC,IAAI,CAAC,YAAY,IAAA,YAAI,EAAC,WAAW,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC,OAAO,IAAA,YAAI,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SACzF;QAED,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,iBAAS,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function removeIndentBlock(str: string): string;
|
|
2
|
+
declare type Opts = {
|
|
3
|
+
content: string;
|
|
4
|
+
tagStartPos: number;
|
|
5
|
+
tagContent: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function getPreparedLeftContent({ content, tagStartPos, tagContent }: Opts): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPreparedLeftContent = exports.removeIndentBlock = void 0;
|
|
4
|
+
function removeIndentBlock(str) {
|
|
5
|
+
let i = str.length - 1;
|
|
6
|
+
let curChar = str[i];
|
|
7
|
+
while (curChar === ' ') {
|
|
8
|
+
curChar = str[--i];
|
|
9
|
+
}
|
|
10
|
+
if (curChar === '\n') {
|
|
11
|
+
return str.substring(0, i + 1);
|
|
12
|
+
}
|
|
13
|
+
return str;
|
|
14
|
+
}
|
|
15
|
+
exports.removeIndentBlock = removeIndentBlock;
|
|
16
|
+
function getPreparedLeftContent({ content, tagStartPos, tagContent }) {
|
|
17
|
+
const preparedLeftContent = content.substring(0, tagStartPos);
|
|
18
|
+
if (tagContent === '') {
|
|
19
|
+
return removeIndentBlock(preparedLeftContent);
|
|
20
|
+
}
|
|
21
|
+
return preparedLeftContent;
|
|
22
|
+
}
|
|
23
|
+
exports.getPreparedLeftContent = getPreparedLeftContent;
|
|
24
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/transform/liquid/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAAC,GAAW;IACzC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IACvB,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAErB,OAAO,OAAO,KAAK,GAAG,EAAE;QACpB,OAAO,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;KACtB;IAED,IAAI,OAAO,KAAK,IAAI,EAAE;QAClB,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KAClC;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAbD,8CAaC;AAQD,SAAgB,sBAAsB,CAAC,EAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAO;IAC3E,MAAM,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAE9D,IAAI,UAAU,KAAK,EAAE,EAAE;QACnB,OAAO,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;KACjD;IAED,OAAO,mBAAmB,CAAC;AAC/B,CAAC;AARD,wDAQC"}
|
package/lib/log.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum LogLevels {
|
|
2
|
+
INFO = "info",
|
|
3
|
+
WARN = "warn",
|
|
4
|
+
ERROR = "error",
|
|
5
|
+
DISABLED = "disabled"
|
|
6
|
+
}
|
|
7
|
+
export declare const log: {
|
|
8
|
+
info: (msg: string) => void;
|
|
9
|
+
warn: (msg: string) => void;
|
|
10
|
+
error: (msg: string) => void;
|
|
11
|
+
LogLevels: typeof LogLevels;
|
|
12
|
+
get: () => Record<LogLevels, string[]>;
|
|
13
|
+
add: (logs: Record<LogLevels, string[]>) => void;
|
|
14
|
+
clear: () => void;
|
|
15
|
+
isEmpty: () => boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare type Logger = typeof log;
|
|
18
|
+
export default log;
|