@skeptools/skep-organization-project 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +2157 -5
- package/API.md +2111 -1754
- package/lib/index.js +7 -3
- package/lib/skep-organization-project.js +6 -6
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1134 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +27 -0
- package/node_modules/commander/lib/argument.js +147 -0
- package/node_modules/commander/lib/command.js +2179 -0
- package/node_modules/commander/lib/error.js +45 -0
- package/node_modules/commander/lib/help.js +464 -0
- package/node_modules/commander/lib/option.js +331 -0
- package/node_modules/commander/lib/suggestSimilar.js +100 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +80 -0
- package/node_modules/commander/typings/index.d.ts +889 -0
- package/node_modules/liquidjs/README.md +135 -75
- package/node_modules/liquidjs/bin/liquid.js +128 -13
- package/node_modules/liquidjs/dist/build/fs-impl-browser.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/{emitters → build}/streamed-emitter-browser.d.ts +1 -1
- package/node_modules/liquidjs/dist/build/streamed-emitter-browser.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/cache/cache.d.ts +1 -1
- package/node_modules/liquidjs/dist/cache/index.d.ts +2 -0
- package/node_modules/liquidjs/dist/cache/lru.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/context/block-mode.d.ts +1 -2
- package/node_modules/liquidjs/dist/context/context.d.ts +12 -4
- package/node_modules/liquidjs/dist/context/context.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/context/index.d.ts +3 -0
- package/node_modules/liquidjs/dist/context/scope.d.ts +3 -3
- package/node_modules/liquidjs/dist/drop/blank-drop.d.ts +1 -1
- package/node_modules/liquidjs/dist/drop/drop.d.ts +1 -1
- package/node_modules/liquidjs/dist/drop/index.d.ts +7 -0
- package/node_modules/liquidjs/dist/emitters/index.d.ts +4 -0
- package/node_modules/liquidjs/dist/emitters/keeping-type-emitter.d.ts +1 -1
- package/node_modules/liquidjs/dist/filters/array.d.ts +26 -0
- package/node_modules/liquidjs/dist/filters/date.d.ts +6 -0
- package/node_modules/liquidjs/dist/filters/html.d.ts +6 -0
- package/node_modules/liquidjs/dist/filters/index.d.ts +2 -0
- package/node_modules/liquidjs/dist/filters/math.d.ts +11 -0
- package/node_modules/liquidjs/dist/filters/misc.d.ts +18 -0
- package/node_modules/liquidjs/dist/filters/string.d.ts +27 -0
- package/node_modules/liquidjs/dist/filters/url.d.ts +14 -0
- package/node_modules/liquidjs/dist/fs/fs-impl.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/fs/index.d.ts +2 -0
- package/node_modules/liquidjs/dist/fs/loader.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/fs/map-fs.d.ts +13 -0
- package/node_modules/liquidjs/dist/fs/map-fs.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/fs/node-require.d.ts +1 -2
- package/node_modules/liquidjs/dist/index.d.ts +15 -0
- package/node_modules/liquidjs/dist/liquid-options.d.ts +41 -12
- package/node_modules/liquidjs/dist/liquid-options.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/liquid.browser.min.js +1 -1
- package/node_modules/liquidjs/dist/liquid.browser.min.js.map +1 -1
- package/node_modules/liquidjs/dist/{liquid.browser.esm.js → liquid.browser.mjs} +3099 -2406
- package/node_modules/liquidjs/dist/liquid.browser.umd.js +4172 -3171
- package/node_modules/liquidjs/dist/liquid.browser.umd.js.map +1 -1
- package/node_modules/liquidjs/dist/liquid.d.ts +25 -26
- package/node_modules/liquidjs/dist/liquid.node.js +4252 -0
- package/node_modules/liquidjs/dist/{liquid.node.esm.js → liquid.node.mjs} +3054 -2365
- package/node_modules/liquidjs/dist/parser/filter-arg.d.ts +2 -2
- package/node_modules/liquidjs/dist/parser/index.d.ts +4 -0
- package/node_modules/liquidjs/dist/parser/parse-stream.d.ts +3 -4
- package/node_modules/liquidjs/dist/parser/parse-stream.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/parser/parser.d.ts +7 -9
- package/node_modules/liquidjs/dist/parser/parser.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/parser/token-kind.d.ts +1 -0
- package/node_modules/liquidjs/dist/parser/tokenizer.d.ts +25 -28
- package/node_modules/liquidjs/dist/parser/tokenizer.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/parser/whitespace-ctrl.d.ts +1 -1
- package/node_modules/liquidjs/dist/render/boolean.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/render/expression.d.ts +4 -8
- package/node_modules/liquidjs/dist/render/expression.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/render/index.d.ts +4 -0
- package/node_modules/liquidjs/dist/render/operator.d.ts +6 -4
- package/node_modules/liquidjs/dist/render/render.d.ts +3 -3
- package/node_modules/liquidjs/dist/render/render.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/render/string.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/tags/assign.d.ts +7 -0
- package/node_modules/liquidjs/dist/tags/block.d.ts +9 -0
- package/node_modules/liquidjs/dist/tags/break.d.ts +4 -0
- package/node_modules/liquidjs/dist/tags/capture.d.ts +9 -0
- package/node_modules/liquidjs/dist/tags/case.d.ts +12 -0
- package/node_modules/liquidjs/dist/tags/comment.d.ts +5 -0
- package/node_modules/liquidjs/dist/tags/continue.d.ts +4 -0
- package/node_modules/liquidjs/dist/tags/cycle.d.ts +7 -0
- package/node_modules/liquidjs/dist/tags/decrement.d.ts +6 -0
- package/node_modules/liquidjs/dist/tags/echo.d.ts +6 -0
- package/node_modules/liquidjs/dist/tags/for.d.ts +11 -0
- package/node_modules/liquidjs/dist/tags/if.d.ts +11 -0
- package/node_modules/liquidjs/dist/tags/include.d.ts +8 -0
- package/node_modules/liquidjs/dist/tags/increment.d.ts +6 -0
- package/node_modules/liquidjs/dist/tags/index.d.ts +24 -0
- package/node_modules/liquidjs/dist/tags/inline-comment.d.ts +5 -0
- package/node_modules/liquidjs/dist/tags/layout.d.ts +10 -0
- package/node_modules/liquidjs/dist/tags/liquid.d.ts +7 -0
- package/node_modules/liquidjs/dist/tags/raw.d.ts +6 -0
- package/node_modules/liquidjs/dist/tags/render.d.ts +18 -0
- package/node_modules/liquidjs/dist/tags/tablerow.d.ts +10 -0
- package/node_modules/liquidjs/dist/tags/unless.d.ts +12 -0
- package/node_modules/liquidjs/dist/template/filter-impl-options.d.ts +14 -0
- package/node_modules/liquidjs/dist/template/filter.d.ts +15 -0
- package/node_modules/liquidjs/dist/template/filter.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/template/hash.d.ts +17 -0
- package/node_modules/liquidjs/dist/template/hash.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/template/html.d.ts +4 -5
- package/node_modules/liquidjs/dist/template/index.d.ts +10 -0
- package/node_modules/liquidjs/dist/template/output.d.ts +3 -3
- package/node_modules/liquidjs/dist/template/output.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/template/tag-options-adapter.d.ts +10 -0
- package/node_modules/liquidjs/dist/template/tag.d.ts +18 -0
- package/node_modules/liquidjs/dist/template/value.d.ts +8 -6
- package/node_modules/liquidjs/dist/template/value.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/tokens/delimited-token.d.ts +4 -3
- package/node_modules/liquidjs/dist/tokens/filtered-value-token.d.ts +17 -0
- package/node_modules/liquidjs/dist/tokens/identifier-token.d.ts +0 -1
- package/node_modules/liquidjs/dist/tokens/index.d.ts +18 -0
- package/node_modules/liquidjs/dist/tokens/liquid-tag-token.d.ts +5 -0
- package/node_modules/liquidjs/dist/tokens/literal-token.d.ts +2 -0
- package/node_modules/liquidjs/dist/tokens/number-token.d.ts +6 -4
- package/node_modules/liquidjs/dist/tokens/operator-token.d.ts +18 -1
- package/node_modules/liquidjs/dist/tokens/property-access-token.d.ts +7 -4
- package/node_modules/liquidjs/dist/tokens/quoted-token.d.ts +1 -0
- package/node_modules/liquidjs/dist/tokens/tag-token.d.ts +4 -2
- package/node_modules/liquidjs/dist/tokens/token.d.ts +1 -1
- package/node_modules/liquidjs/dist/tokens/top-level-token.d.ts +4 -0
- package/node_modules/liquidjs/dist/tokens/value-token.d.ts +2 -1
- package/node_modules/liquidjs/dist/util/assert.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/assert.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/async.d.ts +0 -1
- package/node_modules/liquidjs/dist/util/async.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/character.d.ts +3 -1
- package/node_modules/liquidjs/dist/util/error.d.ts +9 -3
- package/node_modules/liquidjs/dist/util/error.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/index.d.ts +12 -0
- package/node_modules/liquidjs/dist/util/intl.d.ts +6 -0
- package/node_modules/liquidjs/dist/util/limiter.d.ts +8 -0
- package/node_modules/liquidjs/dist/util/liquid-date.d.ts +39 -6
- package/node_modules/liquidjs/dist/util/liquid-date.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/literal.d.ts +3 -3
- package/node_modules/liquidjs/dist/util/operator-trie.d.ts +13 -4
- package/node_modules/liquidjs/dist/util/performance.d.ts +5 -0
- package/node_modules/liquidjs/dist/util/performance.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/strftime.d.ts +1 -1
- package/node_modules/liquidjs/dist/util/strftime.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/type-guards.d.ts +1 -11
- package/node_modules/liquidjs/dist/util/type-guards.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/underscore.d.ts +8 -9
- package/node_modules/liquidjs/dist/util/underscore.spec.d.ts +1 -0
- package/node_modules/liquidjs/package.json +41 -42
- package/package.json +37 -32
- package/.gitattributes +0 -23
- package/.projenrc.ts +0 -31
- package/node_modules/liquidjs/CHANGELOG.md +0 -1015
- package/node_modules/liquidjs/dist/builtin/filters/array.d.ts +0 -15
- package/node_modules/liquidjs/dist/builtin/filters/date.d.ts +0 -2
- package/node_modules/liquidjs/dist/builtin/filters/html.d.ts +0 -4
- package/node_modules/liquidjs/dist/builtin/filters/index.d.ts +0 -7
- package/node_modules/liquidjs/dist/builtin/filters/math.d.ts +0 -11
- package/node_modules/liquidjs/dist/builtin/filters/misc.d.ts +0 -5
- package/node_modules/liquidjs/dist/builtin/filters/string.d.ts +0 -16
- package/node_modules/liquidjs/dist/builtin/filters/url.d.ts +0 -2
- package/node_modules/liquidjs/dist/builtin/tags/assign.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/block.d.ts +0 -8
- package/node_modules/liquidjs/dist/builtin/tags/break.d.ts +0 -5
- package/node_modules/liquidjs/dist/builtin/tags/capture.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/case.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/comment.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/continue.d.ts +0 -5
- package/node_modules/liquidjs/dist/builtin/tags/cycle.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/decrement.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/echo.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/for.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/if.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/include.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/increment.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/index.d.ts +0 -5
- package/node_modules/liquidjs/dist/builtin/tags/inline-comment.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/layout.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/liquid.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/raw.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/render.d.ts +0 -13
- package/node_modules/liquidjs/dist/builtin/tags/tablerow.d.ts +0 -3
- package/node_modules/liquidjs/dist/builtin/tags/unless.d.ts +0 -3
- package/node_modules/liquidjs/dist/liquid.node.cjs.js +0 -4820
- package/node_modules/liquidjs/dist/parser/match-operator.d.ts +0 -2
- package/node_modules/liquidjs/dist/template/filter/filter-impl-options.d.ts +0 -4
- package/node_modules/liquidjs/dist/template/filter/filter-impl.d.ts +0 -6
- package/node_modules/liquidjs/dist/template/filter/filter-map.d.ts +0 -13
- package/node_modules/liquidjs/dist/template/filter/filter.d.ts +0 -12
- package/node_modules/liquidjs/dist/template/tag/hash.d.ts +0 -17
- package/node_modules/liquidjs/dist/template/tag/tag-impl-options.d.ts +0 -10
- package/node_modules/liquidjs/dist/template/tag/tag-impl.d.ts +0 -6
- package/node_modules/liquidjs/dist/template/tag/tag-map.d.ts +0 -6
- package/node_modules/liquidjs/dist/template/tag/tag.d.ts +0 -10
- package/node_modules/liquidjs/dist/tokens/toplevel-token.d.ts +0 -4
- package/node_modules/liquidjs/dist/types.d.ts +0 -30
- package/node_modules/liquidjs/dist/util/collection.d.ts +0 -2
- package/node_modules/liquidjs/dist/util/timezone-date.d.ts +0 -39
- /package/node_modules/liquidjs/dist/{fs/browser.d.ts → build/fs-impl-browser.d.ts} +0 -0
- /package/node_modules/liquidjs/dist/fs/{node.d.ts → fs-impl.d.ts} +0 -0
- /package/node_modules/liquidjs/dist/{parser/parse-string-literal.d.ts → render/string.d.ts} +0 -0
|
@@ -1,4820 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* liquidjs@9.43.0, https://github.com/harttle/liquidjs
|
|
3
|
-
* (c) 2016-2022 harttle
|
|
4
|
-
* Released under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
-
|
|
10
|
-
var path = require('path');
|
|
11
|
-
var fs$1 = require('fs');
|
|
12
|
-
var stream = require('stream');
|
|
13
|
-
|
|
14
|
-
/*! *****************************************************************************
|
|
15
|
-
Copyright (c) Microsoft Corporation.
|
|
16
|
-
|
|
17
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
18
|
-
purpose with or without fee is hereby granted.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
21
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
22
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
23
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
24
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
25
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
26
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
27
|
-
***************************************************************************** */
|
|
28
|
-
/* global Reflect, Promise */
|
|
29
|
-
|
|
30
|
-
var extendStatics = function(d, b) {
|
|
31
|
-
extendStatics = Object.setPrototypeOf ||
|
|
32
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
33
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
34
|
-
return extendStatics(d, b);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
function __extends(d, b) {
|
|
38
|
-
if (typeof b !== "function" && b !== null)
|
|
39
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
40
|
-
extendStatics(d, b);
|
|
41
|
-
function __() { this.constructor = d; }
|
|
42
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var __assign = function() {
|
|
46
|
-
__assign = Object.assign || function __assign(t) {
|
|
47
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
48
|
-
s = arguments[i];
|
|
49
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
50
|
-
}
|
|
51
|
-
return t;
|
|
52
|
-
};
|
|
53
|
-
return __assign.apply(this, arguments);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
57
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
58
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
59
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
60
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
61
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
62
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function __generator(thisArg, body) {
|
|
67
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
68
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
69
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
70
|
-
function step(op) {
|
|
71
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
72
|
-
while (_) try {
|
|
73
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
74
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
75
|
-
switch (op[0]) {
|
|
76
|
-
case 0: case 1: t = op; break;
|
|
77
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
78
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
79
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
80
|
-
default:
|
|
81
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
82
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
83
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
84
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
85
|
-
if (t[2]) _.ops.pop();
|
|
86
|
-
_.trys.pop(); continue;
|
|
87
|
-
}
|
|
88
|
-
op = body.call(thisArg, _);
|
|
89
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
90
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function __values(o) {
|
|
95
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
96
|
-
if (m) return m.call(o);
|
|
97
|
-
if (o && typeof o.length === "number") return {
|
|
98
|
-
next: function () {
|
|
99
|
-
if (o && i >= o.length) o = void 0;
|
|
100
|
-
return { value: o && o[i++], done: !o };
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function __read(o, n) {
|
|
107
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
108
|
-
if (!m) return o;
|
|
109
|
-
var i = m.call(o), r, ar = [], e;
|
|
110
|
-
try {
|
|
111
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
112
|
-
}
|
|
113
|
-
catch (error) { e = { error: error }; }
|
|
114
|
-
finally {
|
|
115
|
-
try {
|
|
116
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
117
|
-
}
|
|
118
|
-
finally { if (e) throw e.error; }
|
|
119
|
-
}
|
|
120
|
-
return ar;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function __spreadArray(to, from, pack) {
|
|
124
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
125
|
-
if (ar || !(i in from)) {
|
|
126
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
127
|
-
ar[i] = from[i];
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
var Drop = /** @class */ (function () {
|
|
134
|
-
function Drop() {
|
|
135
|
-
}
|
|
136
|
-
Drop.prototype.liquidMethodMissing = function (key) {
|
|
137
|
-
return undefined;
|
|
138
|
-
};
|
|
139
|
-
return Drop;
|
|
140
|
-
}());
|
|
141
|
-
|
|
142
|
-
var toString$1 = Object.prototype.toString;
|
|
143
|
-
var toLowerCase = String.prototype.toLowerCase;
|
|
144
|
-
var hasOwnProperty = Object.hasOwnProperty;
|
|
145
|
-
function isString(value) {
|
|
146
|
-
return typeof value === 'string';
|
|
147
|
-
}
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
149
|
-
function isFunction(value) {
|
|
150
|
-
return typeof value === 'function';
|
|
151
|
-
}
|
|
152
|
-
function isPromise(val) {
|
|
153
|
-
return val && isFunction(val.then);
|
|
154
|
-
}
|
|
155
|
-
function isIterator(val) {
|
|
156
|
-
return val && isFunction(val.next) && isFunction(val.throw) && isFunction(val.return);
|
|
157
|
-
}
|
|
158
|
-
function escapeRegex(str) {
|
|
159
|
-
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
160
|
-
}
|
|
161
|
-
function promisify(fn) {
|
|
162
|
-
return function () {
|
|
163
|
-
var args = [];
|
|
164
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
165
|
-
args[_i] = arguments[_i];
|
|
166
|
-
}
|
|
167
|
-
return new Promise(function (resolve, reject) {
|
|
168
|
-
fn.apply(void 0, __spreadArray(__spreadArray([], __read(args), false), [function (err, result) {
|
|
169
|
-
err ? reject(err) : resolve(result);
|
|
170
|
-
}], false));
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function stringify(value) {
|
|
175
|
-
value = toValue(value);
|
|
176
|
-
if (isString(value))
|
|
177
|
-
return value;
|
|
178
|
-
if (isNil(value))
|
|
179
|
-
return '';
|
|
180
|
-
if (isArray(value))
|
|
181
|
-
return value.map(function (x) { return stringify(x); }).join('');
|
|
182
|
-
return String(value);
|
|
183
|
-
}
|
|
184
|
-
function toValue(value) {
|
|
185
|
-
return (value instanceof Drop && isFunction(value.valueOf)) ? value.valueOf() : value;
|
|
186
|
-
}
|
|
187
|
-
function isNumber(value) {
|
|
188
|
-
return typeof value === 'number';
|
|
189
|
-
}
|
|
190
|
-
function toLiquid(value) {
|
|
191
|
-
if (value && isFunction(value.toLiquid))
|
|
192
|
-
return toLiquid(value.toLiquid());
|
|
193
|
-
return value;
|
|
194
|
-
}
|
|
195
|
-
function isNil(value) {
|
|
196
|
-
return value == null;
|
|
197
|
-
}
|
|
198
|
-
function isArray(value) {
|
|
199
|
-
// be compatible with IE 8
|
|
200
|
-
return toString$1.call(value) === '[object Array]';
|
|
201
|
-
}
|
|
202
|
-
function isIterable(value) {
|
|
203
|
-
return isObject(value) && Symbol.iterator in value;
|
|
204
|
-
}
|
|
205
|
-
/*
|
|
206
|
-
* Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property.
|
|
207
|
-
* The iteratee is invoked with three arguments: (value, key, object).
|
|
208
|
-
* Iteratee functions may exit iteration early by explicitly returning false.
|
|
209
|
-
* @param {Object} object The object to iterate over.
|
|
210
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
211
|
-
* @return {Object} Returns object.
|
|
212
|
-
*/
|
|
213
|
-
function forOwn(obj, iteratee) {
|
|
214
|
-
obj = obj || {};
|
|
215
|
-
for (var k in obj) {
|
|
216
|
-
if (hasOwnProperty.call(obj, k)) {
|
|
217
|
-
if (iteratee(obj[k], k, obj) === false)
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return obj;
|
|
222
|
-
}
|
|
223
|
-
function last$1(arr) {
|
|
224
|
-
return arr[arr.length - 1];
|
|
225
|
-
}
|
|
226
|
-
/*
|
|
227
|
-
* Checks if value is the language type of Object.
|
|
228
|
-
* (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))
|
|
229
|
-
* @param {any} value The value to check.
|
|
230
|
-
* @return {Boolean} Returns true if value is an object, else false.
|
|
231
|
-
*/
|
|
232
|
-
function isObject(value) {
|
|
233
|
-
var type = typeof value;
|
|
234
|
-
return value !== null && (type === 'object' || type === 'function');
|
|
235
|
-
}
|
|
236
|
-
function range(start, stop, step) {
|
|
237
|
-
if (step === void 0) { step = 1; }
|
|
238
|
-
var arr = [];
|
|
239
|
-
for (var i = start; i < stop; i += step) {
|
|
240
|
-
arr.push(i);
|
|
241
|
-
}
|
|
242
|
-
return arr;
|
|
243
|
-
}
|
|
244
|
-
function padStart(str, length, ch) {
|
|
245
|
-
if (ch === void 0) { ch = ' '; }
|
|
246
|
-
return pad(str, length, ch, function (str, ch) { return ch + str; });
|
|
247
|
-
}
|
|
248
|
-
function padEnd(str, length, ch) {
|
|
249
|
-
if (ch === void 0) { ch = ' '; }
|
|
250
|
-
return pad(str, length, ch, function (str, ch) { return str + ch; });
|
|
251
|
-
}
|
|
252
|
-
function pad(str, length, ch, add) {
|
|
253
|
-
str = String(str);
|
|
254
|
-
var n = length - str.length;
|
|
255
|
-
while (n-- > 0)
|
|
256
|
-
str = add(str, ch);
|
|
257
|
-
return str;
|
|
258
|
-
}
|
|
259
|
-
function identify(val) {
|
|
260
|
-
return val;
|
|
261
|
-
}
|
|
262
|
-
function snakeCase(str) {
|
|
263
|
-
return str.replace(/(\w?)([A-Z])/g, function (_, a, b) { return (a ? a + '_' : '') + b.toLowerCase(); });
|
|
264
|
-
}
|
|
265
|
-
function changeCase(str) {
|
|
266
|
-
var hasLowerCase = __spreadArray([], __read(str), false).some(function (ch) { return ch >= 'a' && ch <= 'z'; });
|
|
267
|
-
return hasLowerCase ? str.toUpperCase() : str.toLowerCase();
|
|
268
|
-
}
|
|
269
|
-
function ellipsis(str, N) {
|
|
270
|
-
return str.length > N ? str.slice(0, N - 3) + '...' : str;
|
|
271
|
-
}
|
|
272
|
-
// compare string in case-insensitive way, undefined values to the tail
|
|
273
|
-
function caseInsensitiveCompare(a, b) {
|
|
274
|
-
if (a == null && b == null)
|
|
275
|
-
return 0;
|
|
276
|
-
if (a == null)
|
|
277
|
-
return 1;
|
|
278
|
-
if (b == null)
|
|
279
|
-
return -1;
|
|
280
|
-
a = toLowerCase.call(a);
|
|
281
|
-
b = toLowerCase.call(b);
|
|
282
|
-
if (a < b)
|
|
283
|
-
return -1;
|
|
284
|
-
if (a > b)
|
|
285
|
-
return 1;
|
|
286
|
-
return 0;
|
|
287
|
-
}
|
|
288
|
-
function argumentsToValue(fn) {
|
|
289
|
-
return function () {
|
|
290
|
-
var args = [];
|
|
291
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
292
|
-
args[_i] = arguments[_i];
|
|
293
|
-
}
|
|
294
|
-
return fn.apply(void 0, __spreadArray([], __read(args.map(toValue)), false));
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
function escapeRegExp(text) {
|
|
298
|
-
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
var Node = /** @class */ (function () {
|
|
302
|
-
function Node(key, value, next, prev) {
|
|
303
|
-
this.key = key;
|
|
304
|
-
this.value = value;
|
|
305
|
-
this.next = next;
|
|
306
|
-
this.prev = prev;
|
|
307
|
-
}
|
|
308
|
-
return Node;
|
|
309
|
-
}());
|
|
310
|
-
var LRU = /** @class */ (function () {
|
|
311
|
-
function LRU(limit, size) {
|
|
312
|
-
if (size === void 0) { size = 0; }
|
|
313
|
-
this.limit = limit;
|
|
314
|
-
this.size = size;
|
|
315
|
-
this.cache = {};
|
|
316
|
-
this.head = new Node('HEAD', null, null, null);
|
|
317
|
-
this.tail = new Node('TAIL', null, null, null);
|
|
318
|
-
this.head.next = this.tail;
|
|
319
|
-
this.tail.prev = this.head;
|
|
320
|
-
}
|
|
321
|
-
LRU.prototype.write = function (key, value) {
|
|
322
|
-
if (this.cache[key]) {
|
|
323
|
-
this.cache[key].value = value;
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
var node = new Node(key, value, this.head.next, this.head);
|
|
327
|
-
this.head.next.prev = node;
|
|
328
|
-
this.head.next = node;
|
|
329
|
-
this.cache[key] = node;
|
|
330
|
-
this.size++;
|
|
331
|
-
this.ensureLimit();
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
LRU.prototype.read = function (key) {
|
|
335
|
-
if (!this.cache[key])
|
|
336
|
-
return;
|
|
337
|
-
var value = this.cache[key].value;
|
|
338
|
-
this.remove(key);
|
|
339
|
-
this.write(key, value);
|
|
340
|
-
return value;
|
|
341
|
-
};
|
|
342
|
-
LRU.prototype.remove = function (key) {
|
|
343
|
-
var node = this.cache[key];
|
|
344
|
-
node.prev.next = node.next;
|
|
345
|
-
node.next.prev = node.prev;
|
|
346
|
-
delete this.cache[key];
|
|
347
|
-
this.size--;
|
|
348
|
-
};
|
|
349
|
-
LRU.prototype.clear = function () {
|
|
350
|
-
this.head.next = this.tail;
|
|
351
|
-
this.tail.prev = this.head;
|
|
352
|
-
this.size = 0;
|
|
353
|
-
this.cache = {};
|
|
354
|
-
};
|
|
355
|
-
LRU.prototype.ensureLimit = function () {
|
|
356
|
-
if (this.size > this.limit)
|
|
357
|
-
this.remove(this.tail.prev.key);
|
|
358
|
-
};
|
|
359
|
-
return LRU;
|
|
360
|
-
}());
|
|
361
|
-
|
|
362
|
-
var requireResolve = require.resolve;
|
|
363
|
-
|
|
364
|
-
var statAsync = promisify(fs$1.stat);
|
|
365
|
-
var readFileAsync = promisify(fs$1.readFile);
|
|
366
|
-
function exists(filepath) {
|
|
367
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
368
|
-
return __generator(this, function (_a) {
|
|
369
|
-
switch (_a.label) {
|
|
370
|
-
case 0:
|
|
371
|
-
_a.trys.push([0, 2, , 3]);
|
|
372
|
-
return [4 /*yield*/, statAsync(filepath)];
|
|
373
|
-
case 1:
|
|
374
|
-
_a.sent();
|
|
375
|
-
return [2 /*return*/, true];
|
|
376
|
-
case 2:
|
|
377
|
-
_a.sent();
|
|
378
|
-
return [2 /*return*/, false];
|
|
379
|
-
case 3: return [2 /*return*/];
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
function readFile(filepath) {
|
|
385
|
-
return readFileAsync(filepath, 'utf8');
|
|
386
|
-
}
|
|
387
|
-
function existsSync(filepath) {
|
|
388
|
-
try {
|
|
389
|
-
fs$1.statSync(filepath);
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
catch (err) {
|
|
393
|
-
return false;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
function readFileSync(filepath) {
|
|
397
|
-
return fs$1.readFileSync(filepath, 'utf8');
|
|
398
|
-
}
|
|
399
|
-
function resolve(root, file, ext) {
|
|
400
|
-
if (!path.extname(file))
|
|
401
|
-
file += ext;
|
|
402
|
-
return path.resolve(root, file);
|
|
403
|
-
}
|
|
404
|
-
function fallback(file) {
|
|
405
|
-
try {
|
|
406
|
-
return requireResolve(file);
|
|
407
|
-
}
|
|
408
|
-
catch (e) { }
|
|
409
|
-
}
|
|
410
|
-
function dirname(filepath) {
|
|
411
|
-
return path.dirname(filepath);
|
|
412
|
-
}
|
|
413
|
-
function contains(root, file) {
|
|
414
|
-
root = path.resolve(root);
|
|
415
|
-
root = root.endsWith(path.sep) ? root : root + path.sep;
|
|
416
|
-
return file.startsWith(root);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
var fs = /*#__PURE__*/Object.freeze({
|
|
420
|
-
__proto__: null,
|
|
421
|
-
exists: exists,
|
|
422
|
-
readFile: readFile,
|
|
423
|
-
existsSync: existsSync,
|
|
424
|
-
readFileSync: readFileSync,
|
|
425
|
-
resolve: resolve,
|
|
426
|
-
fallback: fallback,
|
|
427
|
-
dirname: dirname,
|
|
428
|
-
contains: contains,
|
|
429
|
-
sep: path.sep
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
function isComparable(arg) {
|
|
433
|
-
return arg && isFunction(arg.equals);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
function isTruthy(val, ctx) {
|
|
437
|
-
return !isFalsy(val, ctx);
|
|
438
|
-
}
|
|
439
|
-
function isFalsy(val, ctx) {
|
|
440
|
-
if (ctx.opts.jsTruthy) {
|
|
441
|
-
return !val;
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
return val === false || undefined === val || val === null;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
var defaultOperators = {
|
|
449
|
-
'==': function (l, r) {
|
|
450
|
-
if (isComparable(l))
|
|
451
|
-
return l.equals(r);
|
|
452
|
-
if (isComparable(r))
|
|
453
|
-
return r.equals(l);
|
|
454
|
-
return toValue(l) === toValue(r);
|
|
455
|
-
},
|
|
456
|
-
'!=': function (l, r) {
|
|
457
|
-
if (isComparable(l))
|
|
458
|
-
return !l.equals(r);
|
|
459
|
-
if (isComparable(r))
|
|
460
|
-
return !r.equals(l);
|
|
461
|
-
return toValue(l) !== toValue(r);
|
|
462
|
-
},
|
|
463
|
-
'>': function (l, r) {
|
|
464
|
-
if (isComparable(l))
|
|
465
|
-
return l.gt(r);
|
|
466
|
-
if (isComparable(r))
|
|
467
|
-
return r.lt(l);
|
|
468
|
-
return toValue(l) > toValue(r);
|
|
469
|
-
},
|
|
470
|
-
'<': function (l, r) {
|
|
471
|
-
if (isComparable(l))
|
|
472
|
-
return l.lt(r);
|
|
473
|
-
if (isComparable(r))
|
|
474
|
-
return r.gt(l);
|
|
475
|
-
return toValue(l) < toValue(r);
|
|
476
|
-
},
|
|
477
|
-
'>=': function (l, r) {
|
|
478
|
-
if (isComparable(l))
|
|
479
|
-
return l.geq(r);
|
|
480
|
-
if (isComparable(r))
|
|
481
|
-
return r.leq(l);
|
|
482
|
-
return toValue(l) >= toValue(r);
|
|
483
|
-
},
|
|
484
|
-
'<=': function (l, r) {
|
|
485
|
-
if (isComparable(l))
|
|
486
|
-
return l.leq(r);
|
|
487
|
-
if (isComparable(r))
|
|
488
|
-
return r.geq(l);
|
|
489
|
-
return toValue(l) <= toValue(r);
|
|
490
|
-
},
|
|
491
|
-
'contains': function (l, r) {
|
|
492
|
-
l = toValue(l);
|
|
493
|
-
r = toValue(r);
|
|
494
|
-
return l && isFunction(l.indexOf) ? l.indexOf(r) > -1 : false;
|
|
495
|
-
},
|
|
496
|
-
'and': function (l, r, ctx) { return isTruthy(toValue(l), ctx) && isTruthy(toValue(r), ctx); },
|
|
497
|
-
'or': function (l, r, ctx) { return isTruthy(toValue(l), ctx) || isTruthy(toValue(r), ctx); }
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
// **DO NOT CHANGE THIS FILE**
|
|
501
|
-
//
|
|
502
|
-
// This file is generated by bin/character-gen.js
|
|
503
|
-
// bitmask character types to boost performance
|
|
504
|
-
var TYPES = [0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 4, 4, 4, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 8, 0, 0, 0, 0, 8, 0, 0, 0, 64, 0, 65, 0, 0, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 0, 0, 2, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0];
|
|
505
|
-
var IDENTIFIER = 1;
|
|
506
|
-
var BLANK = 4;
|
|
507
|
-
var QUOTE = 8;
|
|
508
|
-
var INLINE_BLANK = 16;
|
|
509
|
-
var NUMBER = 32;
|
|
510
|
-
var SIGN = 64;
|
|
511
|
-
TYPES[160] = TYPES[5760] = TYPES[6158] = TYPES[8192] = TYPES[8193] = TYPES[8194] = TYPES[8195] = TYPES[8196] = TYPES[8197] = TYPES[8198] = TYPES[8199] = TYPES[8200] = TYPES[8201] = TYPES[8202] = TYPES[8232] = TYPES[8233] = TYPES[8239] = TYPES[8287] = TYPES[12288] = BLANK;
|
|
512
|
-
|
|
513
|
-
function createTrie(operators) {
|
|
514
|
-
var e_1, _a;
|
|
515
|
-
var trie = {};
|
|
516
|
-
try {
|
|
517
|
-
for (var _b = __values(Object.entries(operators)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
518
|
-
var _d = __read(_c.value, 2), name_1 = _d[0], handler = _d[1];
|
|
519
|
-
var node = trie;
|
|
520
|
-
for (var i = 0; i < name_1.length; i++) {
|
|
521
|
-
var c = name_1[i];
|
|
522
|
-
node[c] = node[c] || {};
|
|
523
|
-
if (i === name_1.length - 1 && (TYPES[name_1.charCodeAt(i)] & IDENTIFIER)) {
|
|
524
|
-
node[c].needBoundary = true;
|
|
525
|
-
}
|
|
526
|
-
node = node[c];
|
|
527
|
-
}
|
|
528
|
-
node.handler = handler;
|
|
529
|
-
node.end = true;
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
533
|
-
finally {
|
|
534
|
-
try {
|
|
535
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
536
|
-
}
|
|
537
|
-
finally { if (e_1) throw e_1.error; }
|
|
538
|
-
}
|
|
539
|
-
return trie;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
var escapeMap = {
|
|
543
|
-
'&': '&',
|
|
544
|
-
'<': '<',
|
|
545
|
-
'>': '>',
|
|
546
|
-
'"': '"',
|
|
547
|
-
"'": '''
|
|
548
|
-
};
|
|
549
|
-
var unescapeMap = {
|
|
550
|
-
'&': '&',
|
|
551
|
-
'<': '<',
|
|
552
|
-
'>': '>',
|
|
553
|
-
'"': '"',
|
|
554
|
-
''': "'"
|
|
555
|
-
};
|
|
556
|
-
function escape(str) {
|
|
557
|
-
return stringify(str).replace(/&|<|>|"|'/g, function (m) { return escapeMap[m]; });
|
|
558
|
-
}
|
|
559
|
-
function unescape(str) {
|
|
560
|
-
return stringify(str).replace(/&(amp|lt|gt|#34|#39);/g, function (m) { return unescapeMap[m]; });
|
|
561
|
-
}
|
|
562
|
-
function escapeOnce(str) {
|
|
563
|
-
return escape(unescape(stringify(str)));
|
|
564
|
-
}
|
|
565
|
-
function newlineToBr(v) {
|
|
566
|
-
return stringify(v).replace(/\n/g, '<br />\n');
|
|
567
|
-
}
|
|
568
|
-
function stripHtml(v) {
|
|
569
|
-
return stringify(v).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g, '');
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
var abs = argumentsToValue(Math.abs);
|
|
573
|
-
var atLeast = argumentsToValue(Math.max);
|
|
574
|
-
var atMost = argumentsToValue(Math.min);
|
|
575
|
-
var ceil = argumentsToValue(Math.ceil);
|
|
576
|
-
var dividedBy = argumentsToValue(function (dividend, divisor, integerArithmetic) {
|
|
577
|
-
if (integerArithmetic === void 0) { integerArithmetic = false; }
|
|
578
|
-
return integerArithmetic ? Math.floor(dividend / divisor) : dividend / divisor;
|
|
579
|
-
});
|
|
580
|
-
var floor = argumentsToValue(Math.floor);
|
|
581
|
-
var minus = argumentsToValue(function (v, arg) { return v - arg; });
|
|
582
|
-
var modulo = argumentsToValue(function (v, arg) { return v % arg; });
|
|
583
|
-
var times = argumentsToValue(function (v, arg) { return v * arg; });
|
|
584
|
-
function round(v, arg) {
|
|
585
|
-
if (arg === void 0) { arg = 0; }
|
|
586
|
-
v = toValue(v);
|
|
587
|
-
arg = toValue(arg);
|
|
588
|
-
var amp = Math.pow(10, arg);
|
|
589
|
-
return Math.round(v * amp) / amp;
|
|
590
|
-
}
|
|
591
|
-
function plus(v, arg) {
|
|
592
|
-
v = toValue(v);
|
|
593
|
-
arg = toValue(arg);
|
|
594
|
-
return Number(v) + Number(arg);
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
var urlDecode = function (x) { return stringify(x).split('+').map(decodeURIComponent).join(' '); };
|
|
598
|
-
var urlEncode = function (x) { return stringify(x).split(' ').map(encodeURIComponent).join('+'); };
|
|
599
|
-
|
|
600
|
-
function toEnumerable(val) {
|
|
601
|
-
val = toValue(val);
|
|
602
|
-
if (isArray(val))
|
|
603
|
-
return val;
|
|
604
|
-
if (isString(val) && val.length > 0)
|
|
605
|
-
return [val];
|
|
606
|
-
if (isIterable(val))
|
|
607
|
-
return Array.from(val);
|
|
608
|
-
if (isObject(val))
|
|
609
|
-
return Object.keys(val).map(function (key) { return [key, val[key]]; });
|
|
610
|
-
return [];
|
|
611
|
-
}
|
|
612
|
-
function toArray(val) {
|
|
613
|
-
if (isNil(val))
|
|
614
|
-
return [];
|
|
615
|
-
if (isArray(val))
|
|
616
|
-
return val;
|
|
617
|
-
return [val];
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
var join = argumentsToValue(function (v, arg) { return toArray(v).join(arg === undefined ? ' ' : arg); });
|
|
621
|
-
var last = argumentsToValue(function (v) { return isArray(v) ? last$1(v) : ''; });
|
|
622
|
-
var first = argumentsToValue(function (v) { return isArray(v) ? v[0] : ''; });
|
|
623
|
-
var reverse = argumentsToValue(function (v) { return __spreadArray([], __read(toArray(v)), false).reverse(); });
|
|
624
|
-
function sort(arr, property) {
|
|
625
|
-
var values, _a, _b, item, _c, _d, _e, _f, e_1_1;
|
|
626
|
-
var e_1, _g;
|
|
627
|
-
return __generator(this, function (_h) {
|
|
628
|
-
switch (_h.label) {
|
|
629
|
-
case 0:
|
|
630
|
-
values = [];
|
|
631
|
-
_h.label = 1;
|
|
632
|
-
case 1:
|
|
633
|
-
_h.trys.push([1, 8, 9, 10]);
|
|
634
|
-
_a = __values(toArray(toValue(arr))), _b = _a.next();
|
|
635
|
-
_h.label = 2;
|
|
636
|
-
case 2:
|
|
637
|
-
if (!!_b.done) return [3 /*break*/, 7];
|
|
638
|
-
item = _b.value;
|
|
639
|
-
_d = (_c = values).push;
|
|
640
|
-
_e = [item];
|
|
641
|
-
if (!property) return [3 /*break*/, 4];
|
|
642
|
-
return [4 /*yield*/, this.context._getFromScope(item, stringify(property).split('.'))];
|
|
643
|
-
case 3:
|
|
644
|
-
_f = _h.sent();
|
|
645
|
-
return [3 /*break*/, 5];
|
|
646
|
-
case 4:
|
|
647
|
-
_f = item;
|
|
648
|
-
_h.label = 5;
|
|
649
|
-
case 5:
|
|
650
|
-
_d.apply(_c, [_e.concat([
|
|
651
|
-
_f
|
|
652
|
-
])]);
|
|
653
|
-
_h.label = 6;
|
|
654
|
-
case 6:
|
|
655
|
-
_b = _a.next();
|
|
656
|
-
return [3 /*break*/, 2];
|
|
657
|
-
case 7: return [3 /*break*/, 10];
|
|
658
|
-
case 8:
|
|
659
|
-
e_1_1 = _h.sent();
|
|
660
|
-
e_1 = { error: e_1_1 };
|
|
661
|
-
return [3 /*break*/, 10];
|
|
662
|
-
case 9:
|
|
663
|
-
try {
|
|
664
|
-
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
|
|
665
|
-
}
|
|
666
|
-
finally { if (e_1) throw e_1.error; }
|
|
667
|
-
return [7 /*endfinally*/];
|
|
668
|
-
case 10: return [2 /*return*/, values.sort(function (lhs, rhs) {
|
|
669
|
-
var lvalue = lhs[1];
|
|
670
|
-
var rvalue = rhs[1];
|
|
671
|
-
return lvalue < rvalue ? -1 : (lvalue > rvalue ? 1 : 0);
|
|
672
|
-
}).map(function (tuple) { return tuple[0]; })];
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
function sortNatural(input, property) {
|
|
677
|
-
input = toValue(input);
|
|
678
|
-
var propertyString = stringify(property);
|
|
679
|
-
var compare = property === undefined
|
|
680
|
-
? caseInsensitiveCompare
|
|
681
|
-
: function (lhs, rhs) { return caseInsensitiveCompare(lhs[propertyString], rhs[propertyString]); };
|
|
682
|
-
return __spreadArray([], __read(toArray(input)), false).sort(compare);
|
|
683
|
-
}
|
|
684
|
-
var size = function (v) { return (v && v.length) || 0; };
|
|
685
|
-
function map(arr, property) {
|
|
686
|
-
var results, _a, _b, item, _c, _d, e_2_1;
|
|
687
|
-
var e_2, _e;
|
|
688
|
-
return __generator(this, function (_f) {
|
|
689
|
-
switch (_f.label) {
|
|
690
|
-
case 0:
|
|
691
|
-
results = [];
|
|
692
|
-
_f.label = 1;
|
|
693
|
-
case 1:
|
|
694
|
-
_f.trys.push([1, 6, 7, 8]);
|
|
695
|
-
_a = __values(toArray(toValue(arr))), _b = _a.next();
|
|
696
|
-
_f.label = 2;
|
|
697
|
-
case 2:
|
|
698
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
699
|
-
item = _b.value;
|
|
700
|
-
_d = (_c = results).push;
|
|
701
|
-
return [4 /*yield*/, this.context._getFromScope(item, stringify(property).split('.'))];
|
|
702
|
-
case 3:
|
|
703
|
-
_d.apply(_c, [_f.sent()]);
|
|
704
|
-
_f.label = 4;
|
|
705
|
-
case 4:
|
|
706
|
-
_b = _a.next();
|
|
707
|
-
return [3 /*break*/, 2];
|
|
708
|
-
case 5: return [3 /*break*/, 8];
|
|
709
|
-
case 6:
|
|
710
|
-
e_2_1 = _f.sent();
|
|
711
|
-
e_2 = { error: e_2_1 };
|
|
712
|
-
return [3 /*break*/, 8];
|
|
713
|
-
case 7:
|
|
714
|
-
try {
|
|
715
|
-
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
716
|
-
}
|
|
717
|
-
finally { if (e_2) throw e_2.error; }
|
|
718
|
-
return [7 /*endfinally*/];
|
|
719
|
-
case 8: return [2 /*return*/, results];
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
function compact(arr) {
|
|
724
|
-
arr = toValue(arr);
|
|
725
|
-
return toArray(arr).filter(function (x) { return !isNil(toValue(x)); });
|
|
726
|
-
}
|
|
727
|
-
function concat(v, arg) {
|
|
728
|
-
if (arg === void 0) { arg = []; }
|
|
729
|
-
v = toValue(v);
|
|
730
|
-
arg = toArray(arg).map(function (v) { return toValue(v); });
|
|
731
|
-
return toArray(v).concat(arg);
|
|
732
|
-
}
|
|
733
|
-
function slice(v, begin, length) {
|
|
734
|
-
if (length === void 0) { length = 1; }
|
|
735
|
-
v = toValue(v);
|
|
736
|
-
if (isNil(v))
|
|
737
|
-
return [];
|
|
738
|
-
if (!isArray(v))
|
|
739
|
-
v = stringify(v);
|
|
740
|
-
begin = begin < 0 ? v.length + begin : begin;
|
|
741
|
-
return v.slice(begin, begin + length);
|
|
742
|
-
}
|
|
743
|
-
function where(arr, property, expected) {
|
|
744
|
-
var values, arr_1, arr_1_1, item, _a, _b, e_3_1;
|
|
745
|
-
var e_3, _c;
|
|
746
|
-
var _this = this;
|
|
747
|
-
return __generator(this, function (_d) {
|
|
748
|
-
switch (_d.label) {
|
|
749
|
-
case 0:
|
|
750
|
-
values = [];
|
|
751
|
-
arr = toArray(toValue(arr));
|
|
752
|
-
_d.label = 1;
|
|
753
|
-
case 1:
|
|
754
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
755
|
-
arr_1 = __values(arr), arr_1_1 = arr_1.next();
|
|
756
|
-
_d.label = 2;
|
|
757
|
-
case 2:
|
|
758
|
-
if (!!arr_1_1.done) return [3 /*break*/, 5];
|
|
759
|
-
item = arr_1_1.value;
|
|
760
|
-
_b = (_a = values).push;
|
|
761
|
-
return [4 /*yield*/, this.context._getFromScope(item, stringify(property).split('.'))];
|
|
762
|
-
case 3:
|
|
763
|
-
_b.apply(_a, [_d.sent()]);
|
|
764
|
-
_d.label = 4;
|
|
765
|
-
case 4:
|
|
766
|
-
arr_1_1 = arr_1.next();
|
|
767
|
-
return [3 /*break*/, 2];
|
|
768
|
-
case 5: return [3 /*break*/, 8];
|
|
769
|
-
case 6:
|
|
770
|
-
e_3_1 = _d.sent();
|
|
771
|
-
e_3 = { error: e_3_1 };
|
|
772
|
-
return [3 /*break*/, 8];
|
|
773
|
-
case 7:
|
|
774
|
-
try {
|
|
775
|
-
if (arr_1_1 && !arr_1_1.done && (_c = arr_1.return)) _c.call(arr_1);
|
|
776
|
-
}
|
|
777
|
-
finally { if (e_3) throw e_3.error; }
|
|
778
|
-
return [7 /*endfinally*/];
|
|
779
|
-
case 8: return [2 /*return*/, arr.filter(function (_, i) {
|
|
780
|
-
if (expected === undefined)
|
|
781
|
-
return isTruthy(values[i], _this.context);
|
|
782
|
-
if (isComparable(expected))
|
|
783
|
-
return expected.equals(values[i]);
|
|
784
|
-
return values[i] === expected;
|
|
785
|
-
})];
|
|
786
|
-
}
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
function uniq(arr) {
|
|
790
|
-
arr = toValue(arr);
|
|
791
|
-
var u = {};
|
|
792
|
-
return (arr || []).filter(function (val) {
|
|
793
|
-
if (hasOwnProperty.call(u, String(val)))
|
|
794
|
-
return false;
|
|
795
|
-
u[String(val)] = true;
|
|
796
|
-
return true;
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
var rFormat = /%([-_0^#:]+)?(\d+)?([EO])?(.)/;
|
|
801
|
-
var monthNames = [
|
|
802
|
-
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
|
|
803
|
-
'September', 'October', 'November', 'December'
|
|
804
|
-
];
|
|
805
|
-
var dayNames = [
|
|
806
|
-
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
|
|
807
|
-
];
|
|
808
|
-
var monthNamesShort = monthNames.map(abbr);
|
|
809
|
-
var dayNamesShort = dayNames.map(abbr);
|
|
810
|
-
var suffixes = {
|
|
811
|
-
1: 'st',
|
|
812
|
-
2: 'nd',
|
|
813
|
-
3: 'rd',
|
|
814
|
-
'default': 'th'
|
|
815
|
-
};
|
|
816
|
-
function abbr(str) {
|
|
817
|
-
return str.slice(0, 3);
|
|
818
|
-
}
|
|
819
|
-
// prototype extensions
|
|
820
|
-
function daysInMonth(d) {
|
|
821
|
-
var feb = isLeapYear(d) ? 29 : 28;
|
|
822
|
-
return [31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
823
|
-
}
|
|
824
|
-
function getDayOfYear(d) {
|
|
825
|
-
var num = 0;
|
|
826
|
-
for (var i = 0; i < d.getMonth(); ++i) {
|
|
827
|
-
num += daysInMonth(d)[i];
|
|
828
|
-
}
|
|
829
|
-
return num + d.getDate();
|
|
830
|
-
}
|
|
831
|
-
function getWeekOfYear(d, startDay) {
|
|
832
|
-
// Skip to startDay of this week
|
|
833
|
-
var now = getDayOfYear(d) + (startDay - d.getDay());
|
|
834
|
-
// Find the first startDay of the year
|
|
835
|
-
var jan1 = new Date(d.getFullYear(), 0, 1);
|
|
836
|
-
var then = (7 - jan1.getDay() + startDay);
|
|
837
|
-
return String(Math.floor((now - then) / 7) + 1);
|
|
838
|
-
}
|
|
839
|
-
function isLeapYear(d) {
|
|
840
|
-
var year = d.getFullYear();
|
|
841
|
-
return !!((year & 3) === 0 && (year % 100 || (year % 400 === 0 && year)));
|
|
842
|
-
}
|
|
843
|
-
function getSuffix(d) {
|
|
844
|
-
var str = d.getDate().toString();
|
|
845
|
-
var index = parseInt(str.slice(-1));
|
|
846
|
-
return suffixes[index] || suffixes['default'];
|
|
847
|
-
}
|
|
848
|
-
function century(d) {
|
|
849
|
-
return parseInt(d.getFullYear().toString().substring(0, 2), 10);
|
|
850
|
-
}
|
|
851
|
-
// default to 0
|
|
852
|
-
var padWidths = {
|
|
853
|
-
d: 2,
|
|
854
|
-
e: 2,
|
|
855
|
-
H: 2,
|
|
856
|
-
I: 2,
|
|
857
|
-
j: 3,
|
|
858
|
-
k: 2,
|
|
859
|
-
l: 2,
|
|
860
|
-
L: 3,
|
|
861
|
-
m: 2,
|
|
862
|
-
M: 2,
|
|
863
|
-
S: 2,
|
|
864
|
-
U: 2,
|
|
865
|
-
W: 2
|
|
866
|
-
};
|
|
867
|
-
// default to '0'
|
|
868
|
-
var padChars = {
|
|
869
|
-
a: ' ',
|
|
870
|
-
A: ' ',
|
|
871
|
-
b: ' ',
|
|
872
|
-
B: ' ',
|
|
873
|
-
c: ' ',
|
|
874
|
-
e: ' ',
|
|
875
|
-
k: ' ',
|
|
876
|
-
l: ' ',
|
|
877
|
-
p: ' ',
|
|
878
|
-
P: ' '
|
|
879
|
-
};
|
|
880
|
-
var formatCodes = {
|
|
881
|
-
a: function (d) { return dayNamesShort[d.getDay()]; },
|
|
882
|
-
A: function (d) { return dayNames[d.getDay()]; },
|
|
883
|
-
b: function (d) { return monthNamesShort[d.getMonth()]; },
|
|
884
|
-
B: function (d) { return monthNames[d.getMonth()]; },
|
|
885
|
-
c: function (d) { return d.toLocaleString(); },
|
|
886
|
-
C: function (d) { return century(d); },
|
|
887
|
-
d: function (d) { return d.getDate(); },
|
|
888
|
-
e: function (d) { return d.getDate(); },
|
|
889
|
-
H: function (d) { return d.getHours(); },
|
|
890
|
-
I: function (d) { return String(d.getHours() % 12 || 12); },
|
|
891
|
-
j: function (d) { return getDayOfYear(d); },
|
|
892
|
-
k: function (d) { return d.getHours(); },
|
|
893
|
-
l: function (d) { return String(d.getHours() % 12 || 12); },
|
|
894
|
-
L: function (d) { return d.getMilliseconds(); },
|
|
895
|
-
m: function (d) { return d.getMonth() + 1; },
|
|
896
|
-
M: function (d) { return d.getMinutes(); },
|
|
897
|
-
N: function (d, opts) {
|
|
898
|
-
var width = Number(opts.width) || 9;
|
|
899
|
-
var str = String(d.getMilliseconds()).slice(0, width);
|
|
900
|
-
return padEnd(str, width, '0');
|
|
901
|
-
},
|
|
902
|
-
p: function (d) { return (d.getHours() < 12 ? 'AM' : 'PM'); },
|
|
903
|
-
P: function (d) { return (d.getHours() < 12 ? 'am' : 'pm'); },
|
|
904
|
-
q: function (d) { return getSuffix(d); },
|
|
905
|
-
s: function (d) { return Math.round(d.getTime() / 1000); },
|
|
906
|
-
S: function (d) { return d.getSeconds(); },
|
|
907
|
-
u: function (d) { return d.getDay() || 7; },
|
|
908
|
-
U: function (d) { return getWeekOfYear(d, 0); },
|
|
909
|
-
w: function (d) { return d.getDay(); },
|
|
910
|
-
W: function (d) { return getWeekOfYear(d, 1); },
|
|
911
|
-
x: function (d) { return d.toLocaleDateString(); },
|
|
912
|
-
X: function (d) { return d.toLocaleTimeString(); },
|
|
913
|
-
y: function (d) { return d.getFullYear().toString().slice(2, 4); },
|
|
914
|
-
Y: function (d) { return d.getFullYear(); },
|
|
915
|
-
z: function (d, opts) {
|
|
916
|
-
var nOffset = Math.abs(d.getTimezoneOffset());
|
|
917
|
-
var h = Math.floor(nOffset / 60);
|
|
918
|
-
var m = nOffset % 60;
|
|
919
|
-
return (d.getTimezoneOffset() > 0 ? '-' : '+') +
|
|
920
|
-
padStart(h, 2, '0') +
|
|
921
|
-
(opts.flags[':'] ? ':' : '') +
|
|
922
|
-
padStart(m, 2, '0');
|
|
923
|
-
},
|
|
924
|
-
't': function () { return '\t'; },
|
|
925
|
-
'n': function () { return '\n'; },
|
|
926
|
-
'%': function () { return '%'; }
|
|
927
|
-
};
|
|
928
|
-
formatCodes.h = formatCodes.b;
|
|
929
|
-
function strftime (d, formatStr) {
|
|
930
|
-
var output = '';
|
|
931
|
-
var remaining = formatStr;
|
|
932
|
-
var match;
|
|
933
|
-
while ((match = rFormat.exec(remaining))) {
|
|
934
|
-
output += remaining.slice(0, match.index);
|
|
935
|
-
remaining = remaining.slice(match.index + match[0].length);
|
|
936
|
-
output += format(d, match);
|
|
937
|
-
}
|
|
938
|
-
return output + remaining;
|
|
939
|
-
}
|
|
940
|
-
function format(d, match) {
|
|
941
|
-
var e_1, _a;
|
|
942
|
-
var _b = __read(match, 5), input = _b[0], _c = _b[1], flagStr = _c === void 0 ? '' : _c, width = _b[2], modifier = _b[3], conversion = _b[4];
|
|
943
|
-
var convert = formatCodes[conversion];
|
|
944
|
-
if (!convert)
|
|
945
|
-
return input;
|
|
946
|
-
var flags = {};
|
|
947
|
-
try {
|
|
948
|
-
for (var flagStr_1 = __values(flagStr), flagStr_1_1 = flagStr_1.next(); !flagStr_1_1.done; flagStr_1_1 = flagStr_1.next()) {
|
|
949
|
-
var flag = flagStr_1_1.value;
|
|
950
|
-
flags[flag] = true;
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
954
|
-
finally {
|
|
955
|
-
try {
|
|
956
|
-
if (flagStr_1_1 && !flagStr_1_1.done && (_a = flagStr_1.return)) _a.call(flagStr_1);
|
|
957
|
-
}
|
|
958
|
-
finally { if (e_1) throw e_1.error; }
|
|
959
|
-
}
|
|
960
|
-
var ret = String(convert(d, { flags: flags, width: width, modifier: modifier }));
|
|
961
|
-
var padChar = padChars[conversion] || '0';
|
|
962
|
-
var padWidth = width || padWidths[conversion] || 0;
|
|
963
|
-
if (flags['^'])
|
|
964
|
-
ret = ret.toUpperCase();
|
|
965
|
-
else if (flags['#'])
|
|
966
|
-
ret = changeCase(ret);
|
|
967
|
-
if (flags['_'])
|
|
968
|
-
padChar = ' ';
|
|
969
|
-
else if (flags['0'])
|
|
970
|
-
padChar = '0';
|
|
971
|
-
if (flags['-'])
|
|
972
|
-
padWidth = 0;
|
|
973
|
-
return padStart(ret, padWidth, padChar);
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
// one minute in milliseconds
|
|
977
|
-
var OneMinute = 60000;
|
|
978
|
-
var hostTimezoneOffset = new Date().getTimezoneOffset();
|
|
979
|
-
var ISO8601_TIMEZONE_PATTERN = /([zZ]|([+-])(\d{2}):(\d{2}))$/;
|
|
980
|
-
/**
|
|
981
|
-
* A date implementation with timezone info, just like Ruby date
|
|
982
|
-
*
|
|
983
|
-
* Implementation:
|
|
984
|
-
* - create a Date offset by it's timezone difference, avoiding overriding a bunch of methods
|
|
985
|
-
* - rewrite getTimezoneOffset() to trick strftime
|
|
986
|
-
*/
|
|
987
|
-
var TimezoneDate = /** @class */ (function () {
|
|
988
|
-
function TimezoneDate(init, timezoneOffset) {
|
|
989
|
-
if (init instanceof TimezoneDate) {
|
|
990
|
-
this.date = init.date;
|
|
991
|
-
timezoneOffset = init.timezoneOffset;
|
|
992
|
-
}
|
|
993
|
-
else {
|
|
994
|
-
var diff = (hostTimezoneOffset - timezoneOffset) * OneMinute;
|
|
995
|
-
var time = new Date(init).getTime() + diff;
|
|
996
|
-
this.date = new Date(time);
|
|
997
|
-
}
|
|
998
|
-
this.timezoneOffset = timezoneOffset;
|
|
999
|
-
}
|
|
1000
|
-
TimezoneDate.prototype.getTime = function () {
|
|
1001
|
-
return this.date.getTime();
|
|
1002
|
-
};
|
|
1003
|
-
TimezoneDate.prototype.getMilliseconds = function () {
|
|
1004
|
-
return this.date.getMilliseconds();
|
|
1005
|
-
};
|
|
1006
|
-
TimezoneDate.prototype.getSeconds = function () {
|
|
1007
|
-
return this.date.getSeconds();
|
|
1008
|
-
};
|
|
1009
|
-
TimezoneDate.prototype.getMinutes = function () {
|
|
1010
|
-
return this.date.getMinutes();
|
|
1011
|
-
};
|
|
1012
|
-
TimezoneDate.prototype.getHours = function () {
|
|
1013
|
-
return this.date.getHours();
|
|
1014
|
-
};
|
|
1015
|
-
TimezoneDate.prototype.getDay = function () {
|
|
1016
|
-
return this.date.getDay();
|
|
1017
|
-
};
|
|
1018
|
-
TimezoneDate.prototype.getDate = function () {
|
|
1019
|
-
return this.date.getDate();
|
|
1020
|
-
};
|
|
1021
|
-
TimezoneDate.prototype.getMonth = function () {
|
|
1022
|
-
return this.date.getMonth();
|
|
1023
|
-
};
|
|
1024
|
-
TimezoneDate.prototype.getFullYear = function () {
|
|
1025
|
-
return this.date.getFullYear();
|
|
1026
|
-
};
|
|
1027
|
-
TimezoneDate.prototype.toLocaleTimeString = function (locale) {
|
|
1028
|
-
return this.date.toLocaleTimeString(locale);
|
|
1029
|
-
};
|
|
1030
|
-
TimezoneDate.prototype.toLocaleDateString = function (locale) {
|
|
1031
|
-
return this.date.toLocaleDateString(locale);
|
|
1032
|
-
};
|
|
1033
|
-
TimezoneDate.prototype.getTimezoneOffset = function () {
|
|
1034
|
-
return this.timezoneOffset;
|
|
1035
|
-
};
|
|
1036
|
-
/**
|
|
1037
|
-
* Create a Date object fixed to it's declared Timezone. Both
|
|
1038
|
-
* - 2021-08-06T02:29:00.000Z and
|
|
1039
|
-
* - 2021-08-06T02:29:00.000+08:00
|
|
1040
|
-
* will always be displayed as
|
|
1041
|
-
* - 2021-08-06 02:29:00
|
|
1042
|
-
* regardless timezoneOffset in JavaScript realm
|
|
1043
|
-
*
|
|
1044
|
-
* The implementation hack:
|
|
1045
|
-
* Instead of calling `.getMonth()`/`.getUTCMonth()` respect to `preserveTimezones`,
|
|
1046
|
-
* we create a different Date to trick strftime, it's both simpler and more performant.
|
|
1047
|
-
* Given that a template is expected to be parsed fewer times than rendered.
|
|
1048
|
-
*/
|
|
1049
|
-
TimezoneDate.createDateFixedToTimezone = function (dateString) {
|
|
1050
|
-
var m = dateString.match(ISO8601_TIMEZONE_PATTERN);
|
|
1051
|
-
// representing a UTC timestamp
|
|
1052
|
-
if (m && m[1] === 'Z') {
|
|
1053
|
-
return new TimezoneDate(+new Date(dateString), 0);
|
|
1054
|
-
}
|
|
1055
|
-
// has a timezone specified
|
|
1056
|
-
if (m && m[2] && m[3] && m[4]) {
|
|
1057
|
-
var _a = __read(m, 5), sign = _a[2], hours = _a[3], minutes = _a[4];
|
|
1058
|
-
var delta = (sign === '+' ? -1 : 1) * (parseInt(hours, 10) * 60 + parseInt(minutes, 10));
|
|
1059
|
-
return new TimezoneDate(+new Date(dateString), delta);
|
|
1060
|
-
}
|
|
1061
|
-
return new Date(dateString);
|
|
1062
|
-
};
|
|
1063
|
-
return TimezoneDate;
|
|
1064
|
-
}());
|
|
1065
|
-
|
|
1066
|
-
function date(v, format, timeZoneOffset) {
|
|
1067
|
-
var opts = this.context.opts;
|
|
1068
|
-
var date;
|
|
1069
|
-
v = toValue(v);
|
|
1070
|
-
format = stringify(format);
|
|
1071
|
-
if (v === 'now' || v === 'today') {
|
|
1072
|
-
date = new Date();
|
|
1073
|
-
}
|
|
1074
|
-
else if (isNumber(v)) {
|
|
1075
|
-
date = new Date(v * 1000);
|
|
1076
|
-
}
|
|
1077
|
-
else if (isString(v)) {
|
|
1078
|
-
if (/^\d+$/.test(v)) {
|
|
1079
|
-
date = new Date(+v * 1000);
|
|
1080
|
-
}
|
|
1081
|
-
else if (opts.preserveTimezones) {
|
|
1082
|
-
date = TimezoneDate.createDateFixedToTimezone(v);
|
|
1083
|
-
}
|
|
1084
|
-
else {
|
|
1085
|
-
date = new Date(v);
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
else {
|
|
1089
|
-
date = v;
|
|
1090
|
-
}
|
|
1091
|
-
if (!isValidDate(date))
|
|
1092
|
-
return v;
|
|
1093
|
-
if (timeZoneOffset !== undefined) {
|
|
1094
|
-
date = new TimezoneDate(date, timeZoneOffset);
|
|
1095
|
-
}
|
|
1096
|
-
else if (opts.timezoneOffset !== undefined) {
|
|
1097
|
-
date = new TimezoneDate(date, opts.timezoneOffset);
|
|
1098
|
-
}
|
|
1099
|
-
return strftime(date, format);
|
|
1100
|
-
}
|
|
1101
|
-
function isValidDate(date) {
|
|
1102
|
-
return (date instanceof Date || date instanceof TimezoneDate) && !isNaN(date.getTime());
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
function Default(value, defaultValue) {
|
|
1106
|
-
var args = [];
|
|
1107
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1108
|
-
args[_i - 2] = arguments[_i];
|
|
1109
|
-
}
|
|
1110
|
-
value = toValue(value);
|
|
1111
|
-
if (isArray(value) || isString(value))
|
|
1112
|
-
return value.length ? value : defaultValue;
|
|
1113
|
-
if (value === false && (new Map(args)).get('allow_false'))
|
|
1114
|
-
return false;
|
|
1115
|
-
return isFalsy(value, this.context) ? defaultValue : value;
|
|
1116
|
-
}
|
|
1117
|
-
function json(value) {
|
|
1118
|
-
return JSON.stringify(value);
|
|
1119
|
-
}
|
|
1120
|
-
var raw$1 = identify;
|
|
1121
|
-
|
|
1122
|
-
var LiquidError = /** @class */ (function (_super) {
|
|
1123
|
-
__extends(LiquidError, _super);
|
|
1124
|
-
function LiquidError(err, token) {
|
|
1125
|
-
var _this = _super.call(this, err.message) || this;
|
|
1126
|
-
_this.originalError = err;
|
|
1127
|
-
_this.token = token;
|
|
1128
|
-
_this.context = '';
|
|
1129
|
-
return _this;
|
|
1130
|
-
}
|
|
1131
|
-
LiquidError.prototype.update = function () {
|
|
1132
|
-
var err = this.originalError;
|
|
1133
|
-
this.context = mkContext(this.token);
|
|
1134
|
-
this.message = mkMessage(err.message, this.token);
|
|
1135
|
-
this.stack = this.message + '\n' + this.context +
|
|
1136
|
-
'\n' + this.stack + '\nFrom ' + err.stack;
|
|
1137
|
-
};
|
|
1138
|
-
return LiquidError;
|
|
1139
|
-
}(Error));
|
|
1140
|
-
var TokenizationError = /** @class */ (function (_super) {
|
|
1141
|
-
__extends(TokenizationError, _super);
|
|
1142
|
-
function TokenizationError(message, token) {
|
|
1143
|
-
var _this = _super.call(this, new Error(message), token) || this;
|
|
1144
|
-
_this.name = 'TokenizationError';
|
|
1145
|
-
_super.prototype.update.call(_this);
|
|
1146
|
-
return _this;
|
|
1147
|
-
}
|
|
1148
|
-
return TokenizationError;
|
|
1149
|
-
}(LiquidError));
|
|
1150
|
-
var ParseError = /** @class */ (function (_super) {
|
|
1151
|
-
__extends(ParseError, _super);
|
|
1152
|
-
function ParseError(err, token) {
|
|
1153
|
-
var _this = _super.call(this, err, token) || this;
|
|
1154
|
-
_this.name = 'ParseError';
|
|
1155
|
-
_this.message = err.message;
|
|
1156
|
-
_super.prototype.update.call(_this);
|
|
1157
|
-
return _this;
|
|
1158
|
-
}
|
|
1159
|
-
return ParseError;
|
|
1160
|
-
}(LiquidError));
|
|
1161
|
-
var RenderError = /** @class */ (function (_super) {
|
|
1162
|
-
__extends(RenderError, _super);
|
|
1163
|
-
function RenderError(err, tpl) {
|
|
1164
|
-
var _this = _super.call(this, err, tpl.token) || this;
|
|
1165
|
-
_this.name = 'RenderError';
|
|
1166
|
-
_this.message = err.message;
|
|
1167
|
-
_super.prototype.update.call(_this);
|
|
1168
|
-
return _this;
|
|
1169
|
-
}
|
|
1170
|
-
RenderError.is = function (obj) {
|
|
1171
|
-
return obj.name === 'RenderError';
|
|
1172
|
-
};
|
|
1173
|
-
return RenderError;
|
|
1174
|
-
}(LiquidError));
|
|
1175
|
-
var UndefinedVariableError = /** @class */ (function (_super) {
|
|
1176
|
-
__extends(UndefinedVariableError, _super);
|
|
1177
|
-
function UndefinedVariableError(err, token) {
|
|
1178
|
-
var _this = _super.call(this, err, token) || this;
|
|
1179
|
-
_this.name = 'UndefinedVariableError';
|
|
1180
|
-
_this.message = err.message;
|
|
1181
|
-
_super.prototype.update.call(_this);
|
|
1182
|
-
return _this;
|
|
1183
|
-
}
|
|
1184
|
-
return UndefinedVariableError;
|
|
1185
|
-
}(LiquidError));
|
|
1186
|
-
// only used internally; raised where we don't have token information,
|
|
1187
|
-
// so it can't be an UndefinedVariableError.
|
|
1188
|
-
var InternalUndefinedVariableError = /** @class */ (function (_super) {
|
|
1189
|
-
__extends(InternalUndefinedVariableError, _super);
|
|
1190
|
-
function InternalUndefinedVariableError(variableName) {
|
|
1191
|
-
var _this = _super.call(this, "undefined variable: ".concat(variableName)) || this;
|
|
1192
|
-
_this.name = 'InternalUndefinedVariableError';
|
|
1193
|
-
_this.variableName = variableName;
|
|
1194
|
-
return _this;
|
|
1195
|
-
}
|
|
1196
|
-
return InternalUndefinedVariableError;
|
|
1197
|
-
}(Error));
|
|
1198
|
-
var AssertionError = /** @class */ (function (_super) {
|
|
1199
|
-
__extends(AssertionError, _super);
|
|
1200
|
-
function AssertionError(message) {
|
|
1201
|
-
var _this = _super.call(this, message) || this;
|
|
1202
|
-
_this.name = 'AssertionError';
|
|
1203
|
-
_this.message = message + '';
|
|
1204
|
-
return _this;
|
|
1205
|
-
}
|
|
1206
|
-
return AssertionError;
|
|
1207
|
-
}(Error));
|
|
1208
|
-
function mkContext(token) {
|
|
1209
|
-
var _a = __read(token.getPosition(), 1), line = _a[0];
|
|
1210
|
-
var lines = token.input.split('\n');
|
|
1211
|
-
var begin = Math.max(line - 2, 1);
|
|
1212
|
-
var end = Math.min(line + 3, lines.length);
|
|
1213
|
-
var context = range(begin, end + 1)
|
|
1214
|
-
.map(function (lineNumber) {
|
|
1215
|
-
var indicator = (lineNumber === line) ? '>> ' : ' ';
|
|
1216
|
-
var num = padStart(String(lineNumber), String(end).length);
|
|
1217
|
-
var text = lines[lineNumber - 1];
|
|
1218
|
-
return "".concat(indicator).concat(num, "| ").concat(text);
|
|
1219
|
-
})
|
|
1220
|
-
.join('\n');
|
|
1221
|
-
return context;
|
|
1222
|
-
}
|
|
1223
|
-
function mkMessage(msg, token) {
|
|
1224
|
-
if (token.file)
|
|
1225
|
-
msg += ", file:".concat(token.file);
|
|
1226
|
-
var _a = __read(token.getPosition(), 2), line = _a[0], col = _a[1];
|
|
1227
|
-
msg += ", line:".concat(line, ", col:").concat(col);
|
|
1228
|
-
return msg;
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
function assert(predicate, message) {
|
|
1232
|
-
if (!predicate) {
|
|
1233
|
-
var msg = typeof message === 'function'
|
|
1234
|
-
? message()
|
|
1235
|
-
: (message || "expect ".concat(predicate, " to be true"));
|
|
1236
|
-
throw new AssertionError(msg);
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* String related filters
|
|
1242
|
-
*
|
|
1243
|
-
* * prefer stringify() to String() since `undefined`, `null` should eval ''
|
|
1244
|
-
*/
|
|
1245
|
-
function append(v, arg) {
|
|
1246
|
-
assert(arguments.length === 2, 'append expect 2 arguments');
|
|
1247
|
-
return stringify(v) + stringify(arg);
|
|
1248
|
-
}
|
|
1249
|
-
function prepend(v, arg) {
|
|
1250
|
-
assert(arguments.length === 2, 'prepend expect 2 arguments');
|
|
1251
|
-
return stringify(arg) + stringify(v);
|
|
1252
|
-
}
|
|
1253
|
-
function lstrip(v, chars) {
|
|
1254
|
-
if (chars) {
|
|
1255
|
-
chars = escapeRegExp(stringify(chars));
|
|
1256
|
-
return stringify(v).replace(new RegExp("^[".concat(chars, "]+"), 'g'), '');
|
|
1257
|
-
}
|
|
1258
|
-
return stringify(v).replace(/^\s+/, '');
|
|
1259
|
-
}
|
|
1260
|
-
function downcase(v) {
|
|
1261
|
-
return stringify(v).toLowerCase();
|
|
1262
|
-
}
|
|
1263
|
-
function upcase(str) {
|
|
1264
|
-
return stringify(str).toUpperCase();
|
|
1265
|
-
}
|
|
1266
|
-
function remove(v, arg) {
|
|
1267
|
-
return stringify(v).split(String(arg)).join('');
|
|
1268
|
-
}
|
|
1269
|
-
function removeFirst(v, l) {
|
|
1270
|
-
return stringify(v).replace(String(l), '');
|
|
1271
|
-
}
|
|
1272
|
-
function rstrip(str, chars) {
|
|
1273
|
-
if (chars) {
|
|
1274
|
-
chars = escapeRegExp(stringify(chars));
|
|
1275
|
-
return stringify(str).replace(new RegExp("[".concat(chars, "]+$"), 'g'), '');
|
|
1276
|
-
}
|
|
1277
|
-
return stringify(str).replace(/\s+$/, '');
|
|
1278
|
-
}
|
|
1279
|
-
function split(v, arg) {
|
|
1280
|
-
var arr = stringify(v).split(String(arg));
|
|
1281
|
-
// align to ruby split, which is the behavior of shopify/liquid
|
|
1282
|
-
// see: https://ruby-doc.org/core-2.4.0/String.html#method-i-split
|
|
1283
|
-
while (arr.length && arr[arr.length - 1] === '')
|
|
1284
|
-
arr.pop();
|
|
1285
|
-
return arr;
|
|
1286
|
-
}
|
|
1287
|
-
function strip(v, chars) {
|
|
1288
|
-
if (chars) {
|
|
1289
|
-
chars = escapeRegExp(stringify(chars));
|
|
1290
|
-
return stringify(v)
|
|
1291
|
-
.replace(new RegExp("^[".concat(chars, "]+"), 'g'), '')
|
|
1292
|
-
.replace(new RegExp("[".concat(chars, "]+$"), 'g'), '');
|
|
1293
|
-
}
|
|
1294
|
-
return stringify(v).trim();
|
|
1295
|
-
}
|
|
1296
|
-
function stripNewlines(v) {
|
|
1297
|
-
return stringify(v).replace(/\n/g, '');
|
|
1298
|
-
}
|
|
1299
|
-
function capitalize(str) {
|
|
1300
|
-
str = stringify(str);
|
|
1301
|
-
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
1302
|
-
}
|
|
1303
|
-
function replace(v, pattern, replacement) {
|
|
1304
|
-
return stringify(v).split(String(pattern)).join(replacement);
|
|
1305
|
-
}
|
|
1306
|
-
function replaceFirst(v, arg1, arg2) {
|
|
1307
|
-
return stringify(v).replace(String(arg1), arg2);
|
|
1308
|
-
}
|
|
1309
|
-
function truncate(v, l, o) {
|
|
1310
|
-
if (l === void 0) { l = 50; }
|
|
1311
|
-
if (o === void 0) { o = '...'; }
|
|
1312
|
-
v = stringify(v);
|
|
1313
|
-
if (v.length <= l)
|
|
1314
|
-
return v;
|
|
1315
|
-
return v.substring(0, l - o.length) + o;
|
|
1316
|
-
}
|
|
1317
|
-
function truncatewords(v, words, o) {
|
|
1318
|
-
if (words === void 0) { words = 15; }
|
|
1319
|
-
if (o === void 0) { o = '...'; }
|
|
1320
|
-
var arr = stringify(v).split(/\s+/);
|
|
1321
|
-
if (words <= 0)
|
|
1322
|
-
words = 1;
|
|
1323
|
-
var ret = arr.slice(0, words).join(' ');
|
|
1324
|
-
if (arr.length >= words)
|
|
1325
|
-
ret += o;
|
|
1326
|
-
return ret;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
var builtinFilters = /*#__PURE__*/Object.freeze({
|
|
1330
|
-
__proto__: null,
|
|
1331
|
-
escape: escape,
|
|
1332
|
-
escapeOnce: escapeOnce,
|
|
1333
|
-
newlineToBr: newlineToBr,
|
|
1334
|
-
stripHtml: stripHtml,
|
|
1335
|
-
abs: abs,
|
|
1336
|
-
atLeast: atLeast,
|
|
1337
|
-
atMost: atMost,
|
|
1338
|
-
ceil: ceil,
|
|
1339
|
-
dividedBy: dividedBy,
|
|
1340
|
-
floor: floor,
|
|
1341
|
-
minus: minus,
|
|
1342
|
-
modulo: modulo,
|
|
1343
|
-
times: times,
|
|
1344
|
-
round: round,
|
|
1345
|
-
plus: plus,
|
|
1346
|
-
urlDecode: urlDecode,
|
|
1347
|
-
urlEncode: urlEncode,
|
|
1348
|
-
join: join,
|
|
1349
|
-
last: last,
|
|
1350
|
-
first: first,
|
|
1351
|
-
reverse: reverse,
|
|
1352
|
-
sort: sort,
|
|
1353
|
-
sortNatural: sortNatural,
|
|
1354
|
-
size: size,
|
|
1355
|
-
map: map,
|
|
1356
|
-
compact: compact,
|
|
1357
|
-
concat: concat,
|
|
1358
|
-
slice: slice,
|
|
1359
|
-
where: where,
|
|
1360
|
-
uniq: uniq,
|
|
1361
|
-
date: date,
|
|
1362
|
-
Default: Default,
|
|
1363
|
-
json: json,
|
|
1364
|
-
raw: raw$1,
|
|
1365
|
-
append: append,
|
|
1366
|
-
prepend: prepend,
|
|
1367
|
-
lstrip: lstrip,
|
|
1368
|
-
downcase: downcase,
|
|
1369
|
-
upcase: upcase,
|
|
1370
|
-
remove: remove,
|
|
1371
|
-
removeFirst: removeFirst,
|
|
1372
|
-
rstrip: rstrip,
|
|
1373
|
-
split: split,
|
|
1374
|
-
strip: strip,
|
|
1375
|
-
stripNewlines: stripNewlines,
|
|
1376
|
-
capitalize: capitalize,
|
|
1377
|
-
replace: replace,
|
|
1378
|
-
replaceFirst: replaceFirst,
|
|
1379
|
-
truncate: truncate,
|
|
1380
|
-
truncatewords: truncatewords
|
|
1381
|
-
});
|
|
1382
|
-
|
|
1383
|
-
exports.TokenKind = void 0;
|
|
1384
|
-
(function (TokenKind) {
|
|
1385
|
-
TokenKind[TokenKind["Number"] = 1] = "Number";
|
|
1386
|
-
TokenKind[TokenKind["Literal"] = 2] = "Literal";
|
|
1387
|
-
TokenKind[TokenKind["Tag"] = 4] = "Tag";
|
|
1388
|
-
TokenKind[TokenKind["Output"] = 8] = "Output";
|
|
1389
|
-
TokenKind[TokenKind["HTML"] = 16] = "HTML";
|
|
1390
|
-
TokenKind[TokenKind["Filter"] = 32] = "Filter";
|
|
1391
|
-
TokenKind[TokenKind["Hash"] = 64] = "Hash";
|
|
1392
|
-
TokenKind[TokenKind["PropertyAccess"] = 128] = "PropertyAccess";
|
|
1393
|
-
TokenKind[TokenKind["Word"] = 256] = "Word";
|
|
1394
|
-
TokenKind[TokenKind["Range"] = 512] = "Range";
|
|
1395
|
-
TokenKind[TokenKind["Quoted"] = 1024] = "Quoted";
|
|
1396
|
-
TokenKind[TokenKind["Operator"] = 2048] = "Operator";
|
|
1397
|
-
TokenKind[TokenKind["Delimited"] = 12] = "Delimited";
|
|
1398
|
-
})(exports.TokenKind || (exports.TokenKind = {}));
|
|
1399
|
-
|
|
1400
|
-
function isDelimitedToken(val) {
|
|
1401
|
-
return !!(getKind(val) & exports.TokenKind.Delimited);
|
|
1402
|
-
}
|
|
1403
|
-
function isOperatorToken(val) {
|
|
1404
|
-
return getKind(val) === exports.TokenKind.Operator;
|
|
1405
|
-
}
|
|
1406
|
-
function isHTMLToken(val) {
|
|
1407
|
-
return getKind(val) === exports.TokenKind.HTML;
|
|
1408
|
-
}
|
|
1409
|
-
function isOutputToken(val) {
|
|
1410
|
-
return getKind(val) === exports.TokenKind.Output;
|
|
1411
|
-
}
|
|
1412
|
-
function isTagToken(val) {
|
|
1413
|
-
return getKind(val) === exports.TokenKind.Tag;
|
|
1414
|
-
}
|
|
1415
|
-
function isQuotedToken(val) {
|
|
1416
|
-
return getKind(val) === exports.TokenKind.Quoted;
|
|
1417
|
-
}
|
|
1418
|
-
function isLiteralToken(val) {
|
|
1419
|
-
return getKind(val) === exports.TokenKind.Literal;
|
|
1420
|
-
}
|
|
1421
|
-
function isNumberToken(val) {
|
|
1422
|
-
return getKind(val) === exports.TokenKind.Number;
|
|
1423
|
-
}
|
|
1424
|
-
function isPropertyAccessToken(val) {
|
|
1425
|
-
return getKind(val) === exports.TokenKind.PropertyAccess;
|
|
1426
|
-
}
|
|
1427
|
-
function isWordToken(val) {
|
|
1428
|
-
return getKind(val) === exports.TokenKind.Word;
|
|
1429
|
-
}
|
|
1430
|
-
function isRangeToken(val) {
|
|
1431
|
-
return getKind(val) === exports.TokenKind.Range;
|
|
1432
|
-
}
|
|
1433
|
-
function getKind(val) {
|
|
1434
|
-
return val ? val.kind : -1;
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
var typeGuards = /*#__PURE__*/Object.freeze({
|
|
1438
|
-
__proto__: null,
|
|
1439
|
-
isDelimitedToken: isDelimitedToken,
|
|
1440
|
-
isOperatorToken: isOperatorToken,
|
|
1441
|
-
isHTMLToken: isHTMLToken,
|
|
1442
|
-
isOutputToken: isOutputToken,
|
|
1443
|
-
isTagToken: isTagToken,
|
|
1444
|
-
isQuotedToken: isQuotedToken,
|
|
1445
|
-
isLiteralToken: isLiteralToken,
|
|
1446
|
-
isNumberToken: isNumberToken,
|
|
1447
|
-
isPropertyAccessToken: isPropertyAccessToken,
|
|
1448
|
-
isWordToken: isWordToken,
|
|
1449
|
-
isRangeToken: isRangeToken
|
|
1450
|
-
});
|
|
1451
|
-
|
|
1452
|
-
var NullDrop = /** @class */ (function (_super) {
|
|
1453
|
-
__extends(NullDrop, _super);
|
|
1454
|
-
function NullDrop() {
|
|
1455
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1456
|
-
}
|
|
1457
|
-
NullDrop.prototype.equals = function (value) {
|
|
1458
|
-
return isNil(toValue(value));
|
|
1459
|
-
};
|
|
1460
|
-
NullDrop.prototype.gt = function () {
|
|
1461
|
-
return false;
|
|
1462
|
-
};
|
|
1463
|
-
NullDrop.prototype.geq = function () {
|
|
1464
|
-
return false;
|
|
1465
|
-
};
|
|
1466
|
-
NullDrop.prototype.lt = function () {
|
|
1467
|
-
return false;
|
|
1468
|
-
};
|
|
1469
|
-
NullDrop.prototype.leq = function () {
|
|
1470
|
-
return false;
|
|
1471
|
-
};
|
|
1472
|
-
NullDrop.prototype.valueOf = function () {
|
|
1473
|
-
return null;
|
|
1474
|
-
};
|
|
1475
|
-
return NullDrop;
|
|
1476
|
-
}(Drop));
|
|
1477
|
-
|
|
1478
|
-
var EmptyDrop = /** @class */ (function (_super) {
|
|
1479
|
-
__extends(EmptyDrop, _super);
|
|
1480
|
-
function EmptyDrop() {
|
|
1481
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1482
|
-
}
|
|
1483
|
-
EmptyDrop.prototype.equals = function (value) {
|
|
1484
|
-
if (value instanceof EmptyDrop)
|
|
1485
|
-
return false;
|
|
1486
|
-
value = toValue(value);
|
|
1487
|
-
if (isString(value) || isArray(value))
|
|
1488
|
-
return value.length === 0;
|
|
1489
|
-
if (isObject(value))
|
|
1490
|
-
return Object.keys(value).length === 0;
|
|
1491
|
-
return false;
|
|
1492
|
-
};
|
|
1493
|
-
EmptyDrop.prototype.gt = function () {
|
|
1494
|
-
return false;
|
|
1495
|
-
};
|
|
1496
|
-
EmptyDrop.prototype.geq = function () {
|
|
1497
|
-
return false;
|
|
1498
|
-
};
|
|
1499
|
-
EmptyDrop.prototype.lt = function () {
|
|
1500
|
-
return false;
|
|
1501
|
-
};
|
|
1502
|
-
EmptyDrop.prototype.leq = function () {
|
|
1503
|
-
return false;
|
|
1504
|
-
};
|
|
1505
|
-
EmptyDrop.prototype.valueOf = function () {
|
|
1506
|
-
return '';
|
|
1507
|
-
};
|
|
1508
|
-
return EmptyDrop;
|
|
1509
|
-
}(Drop));
|
|
1510
|
-
|
|
1511
|
-
var BlankDrop = /** @class */ (function (_super) {
|
|
1512
|
-
__extends(BlankDrop, _super);
|
|
1513
|
-
function BlankDrop() {
|
|
1514
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1515
|
-
}
|
|
1516
|
-
BlankDrop.prototype.equals = function (value) {
|
|
1517
|
-
if (value === false)
|
|
1518
|
-
return true;
|
|
1519
|
-
if (isNil(toValue(value)))
|
|
1520
|
-
return true;
|
|
1521
|
-
if (isString(value))
|
|
1522
|
-
return /^\s*$/.test(value);
|
|
1523
|
-
return _super.prototype.equals.call(this, value);
|
|
1524
|
-
};
|
|
1525
|
-
return BlankDrop;
|
|
1526
|
-
}(EmptyDrop));
|
|
1527
|
-
|
|
1528
|
-
var nil = new NullDrop();
|
|
1529
|
-
var literalValues = {
|
|
1530
|
-
'true': true,
|
|
1531
|
-
'false': false,
|
|
1532
|
-
'nil': nil,
|
|
1533
|
-
'null': nil,
|
|
1534
|
-
'empty': new EmptyDrop(),
|
|
1535
|
-
'blank': new BlankDrop()
|
|
1536
|
-
};
|
|
1537
|
-
|
|
1538
|
-
var rHex = /[\da-fA-F]/;
|
|
1539
|
-
var rOct = /[0-7]/;
|
|
1540
|
-
var escapeChar = {
|
|
1541
|
-
b: '\b',
|
|
1542
|
-
f: '\f',
|
|
1543
|
-
n: '\n',
|
|
1544
|
-
r: '\r',
|
|
1545
|
-
t: '\t',
|
|
1546
|
-
v: '\x0B'
|
|
1547
|
-
};
|
|
1548
|
-
function hexVal(c) {
|
|
1549
|
-
var code = c.charCodeAt(0);
|
|
1550
|
-
if (code >= 97)
|
|
1551
|
-
return code - 87;
|
|
1552
|
-
if (code >= 65)
|
|
1553
|
-
return code - 55;
|
|
1554
|
-
return code - 48;
|
|
1555
|
-
}
|
|
1556
|
-
function parseStringLiteral(str) {
|
|
1557
|
-
var ret = '';
|
|
1558
|
-
for (var i = 1; i < str.length - 1; i++) {
|
|
1559
|
-
if (str[i] !== '\\') {
|
|
1560
|
-
ret += str[i];
|
|
1561
|
-
continue;
|
|
1562
|
-
}
|
|
1563
|
-
if (escapeChar[str[i + 1]] !== undefined) {
|
|
1564
|
-
ret += escapeChar[str[++i]];
|
|
1565
|
-
}
|
|
1566
|
-
else if (str[i + 1] === 'u') {
|
|
1567
|
-
var val = 0;
|
|
1568
|
-
var j = i + 2;
|
|
1569
|
-
while (j <= i + 5 && rHex.test(str[j])) {
|
|
1570
|
-
val = val * 16 + hexVal(str[j++]);
|
|
1571
|
-
}
|
|
1572
|
-
i = j - 1;
|
|
1573
|
-
ret += String.fromCharCode(val);
|
|
1574
|
-
}
|
|
1575
|
-
else if (!rOct.test(str[i + 1])) {
|
|
1576
|
-
ret += str[++i];
|
|
1577
|
-
}
|
|
1578
|
-
else {
|
|
1579
|
-
var j = i + 1;
|
|
1580
|
-
var val = 0;
|
|
1581
|
-
while (j <= i + 3 && rOct.test(str[j])) {
|
|
1582
|
-
val = val * 8 + hexVal(str[j++]);
|
|
1583
|
-
}
|
|
1584
|
-
i = j - 1;
|
|
1585
|
-
ret += String.fromCharCode(val);
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
return ret;
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
// convert an async iterator to a Promise
|
|
1592
|
-
function toPromise(val) {
|
|
1593
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1594
|
-
var value, done, next, state, err_1;
|
|
1595
|
-
return __generator(this, function (_a) {
|
|
1596
|
-
switch (_a.label) {
|
|
1597
|
-
case 0:
|
|
1598
|
-
if (!isIterator(val))
|
|
1599
|
-
return [2 /*return*/, val];
|
|
1600
|
-
done = false;
|
|
1601
|
-
next = 'next';
|
|
1602
|
-
_a.label = 1;
|
|
1603
|
-
case 1:
|
|
1604
|
-
state = val[next](value);
|
|
1605
|
-
done = state.done;
|
|
1606
|
-
value = state.value;
|
|
1607
|
-
next = 'next';
|
|
1608
|
-
_a.label = 2;
|
|
1609
|
-
case 2:
|
|
1610
|
-
_a.trys.push([2, 5, , 6]);
|
|
1611
|
-
if (isIterator(value))
|
|
1612
|
-
value = toPromise(value);
|
|
1613
|
-
if (!isPromise(value)) return [3 /*break*/, 4];
|
|
1614
|
-
return [4 /*yield*/, value];
|
|
1615
|
-
case 3:
|
|
1616
|
-
value = _a.sent();
|
|
1617
|
-
_a.label = 4;
|
|
1618
|
-
case 4: return [3 /*break*/, 6];
|
|
1619
|
-
case 5:
|
|
1620
|
-
err_1 = _a.sent();
|
|
1621
|
-
next = 'throw';
|
|
1622
|
-
value = err_1;
|
|
1623
|
-
return [3 /*break*/, 6];
|
|
1624
|
-
case 6:
|
|
1625
|
-
if (!done) return [3 /*break*/, 1];
|
|
1626
|
-
_a.label = 7;
|
|
1627
|
-
case 7: return [2 /*return*/, value];
|
|
1628
|
-
}
|
|
1629
|
-
});
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
// convert an async iterator to a value in a synchronous manner
|
|
1633
|
-
function toValueSync(val) {
|
|
1634
|
-
if (!isIterator(val))
|
|
1635
|
-
return val;
|
|
1636
|
-
var value;
|
|
1637
|
-
var done = false;
|
|
1638
|
-
var next = 'next';
|
|
1639
|
-
do {
|
|
1640
|
-
var state = val[next](value);
|
|
1641
|
-
done = state.done;
|
|
1642
|
-
value = state.value;
|
|
1643
|
-
next = 'next';
|
|
1644
|
-
if (isIterator(value)) {
|
|
1645
|
-
try {
|
|
1646
|
-
value = toValueSync(value);
|
|
1647
|
-
}
|
|
1648
|
-
catch (err) {
|
|
1649
|
-
next = 'throw';
|
|
1650
|
-
value = err;
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
} while (!done);
|
|
1654
|
-
return value;
|
|
1655
|
-
}
|
|
1656
|
-
var toThenable = toPromise;
|
|
1657
|
-
|
|
1658
|
-
var Expression = /** @class */ (function () {
|
|
1659
|
-
function Expression(tokens) {
|
|
1660
|
-
this.postfix = __spreadArray([], __read(toPostfix(tokens)), false);
|
|
1661
|
-
}
|
|
1662
|
-
Expression.prototype.evaluate = function (ctx, lenient) {
|
|
1663
|
-
var operands, _a, _b, token, r, l, result, _c, _d, e_1_1;
|
|
1664
|
-
var e_1, _e;
|
|
1665
|
-
return __generator(this, function (_f) {
|
|
1666
|
-
switch (_f.label) {
|
|
1667
|
-
case 0:
|
|
1668
|
-
assert(ctx, 'unable to evaluate: context not defined');
|
|
1669
|
-
operands = [];
|
|
1670
|
-
_f.label = 1;
|
|
1671
|
-
case 1:
|
|
1672
|
-
_f.trys.push([1, 8, 9, 10]);
|
|
1673
|
-
_a = __values(this.postfix), _b = _a.next();
|
|
1674
|
-
_f.label = 2;
|
|
1675
|
-
case 2:
|
|
1676
|
-
if (!!_b.done) return [3 /*break*/, 7];
|
|
1677
|
-
token = _b.value;
|
|
1678
|
-
if (!isOperatorToken(token)) return [3 /*break*/, 4];
|
|
1679
|
-
r = operands.pop();
|
|
1680
|
-
l = operands.pop();
|
|
1681
|
-
return [4 /*yield*/, evalOperatorToken(ctx.opts.operators, token, l, r, ctx)];
|
|
1682
|
-
case 3:
|
|
1683
|
-
result = _f.sent();
|
|
1684
|
-
operands.push(result);
|
|
1685
|
-
return [3 /*break*/, 6];
|
|
1686
|
-
case 4:
|
|
1687
|
-
_d = (_c = operands).push;
|
|
1688
|
-
return [4 /*yield*/, _evalToken(token, ctx, lenient && this.postfix.length === 1)];
|
|
1689
|
-
case 5:
|
|
1690
|
-
_d.apply(_c, [_f.sent()]);
|
|
1691
|
-
_f.label = 6;
|
|
1692
|
-
case 6:
|
|
1693
|
-
_b = _a.next();
|
|
1694
|
-
return [3 /*break*/, 2];
|
|
1695
|
-
case 7: return [3 /*break*/, 10];
|
|
1696
|
-
case 8:
|
|
1697
|
-
e_1_1 = _f.sent();
|
|
1698
|
-
e_1 = { error: e_1_1 };
|
|
1699
|
-
return [3 /*break*/, 10];
|
|
1700
|
-
case 9:
|
|
1701
|
-
try {
|
|
1702
|
-
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
1703
|
-
}
|
|
1704
|
-
finally { if (e_1) throw e_1.error; }
|
|
1705
|
-
return [7 /*endfinally*/];
|
|
1706
|
-
case 10: return [2 /*return*/, operands[0]];
|
|
1707
|
-
}
|
|
1708
|
-
});
|
|
1709
|
-
};
|
|
1710
|
-
return Expression;
|
|
1711
|
-
}());
|
|
1712
|
-
/**
|
|
1713
|
-
* @deprecated use `_evalToken` instead
|
|
1714
|
-
*/
|
|
1715
|
-
function evalToken(token, ctx, lenient) {
|
|
1716
|
-
if (lenient === void 0) { lenient = false; }
|
|
1717
|
-
return __generator(this, function (_a) {
|
|
1718
|
-
return [2 /*return*/, toValueSync(_evalToken(token, ctx, lenient))];
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
function _evalToken(token, ctx, lenient) {
|
|
1722
|
-
if (lenient === void 0) { lenient = false; }
|
|
1723
|
-
return __generator(this, function (_a) {
|
|
1724
|
-
switch (_a.label) {
|
|
1725
|
-
case 0:
|
|
1726
|
-
if (!isPropertyAccessToken(token)) return [3 /*break*/, 2];
|
|
1727
|
-
return [4 /*yield*/, evalPropertyAccessToken(token, ctx, lenient)];
|
|
1728
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1729
|
-
case 2:
|
|
1730
|
-
if (!isRangeToken(token)) return [3 /*break*/, 4];
|
|
1731
|
-
return [4 /*yield*/, evalRangeToken(token, ctx)];
|
|
1732
|
-
case 3: return [2 /*return*/, _a.sent()];
|
|
1733
|
-
case 4:
|
|
1734
|
-
if (isLiteralToken(token))
|
|
1735
|
-
return [2 /*return*/, evalLiteralToken(token)];
|
|
1736
|
-
if (isNumberToken(token))
|
|
1737
|
-
return [2 /*return*/, evalNumberToken(token)];
|
|
1738
|
-
if (isWordToken(token))
|
|
1739
|
-
return [2 /*return*/, token.getText()];
|
|
1740
|
-
if (isQuotedToken(token))
|
|
1741
|
-
return [2 /*return*/, evalQuotedToken(token)];
|
|
1742
|
-
return [2 /*return*/];
|
|
1743
|
-
}
|
|
1744
|
-
});
|
|
1745
|
-
}
|
|
1746
|
-
function evalPropertyAccessToken(token, ctx, lenient) {
|
|
1747
|
-
var props, _a, _b, prop, _c, _d, e_2_1, e_3;
|
|
1748
|
-
var e_2, _e;
|
|
1749
|
-
return __generator(this, function (_f) {
|
|
1750
|
-
switch (_f.label) {
|
|
1751
|
-
case 0:
|
|
1752
|
-
props = [];
|
|
1753
|
-
_f.label = 1;
|
|
1754
|
-
case 1:
|
|
1755
|
-
_f.trys.push([1, 6, 7, 8]);
|
|
1756
|
-
_a = __values(token.props), _b = _a.next();
|
|
1757
|
-
_f.label = 2;
|
|
1758
|
-
case 2:
|
|
1759
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
1760
|
-
prop = _b.value;
|
|
1761
|
-
_d = (_c = props).push;
|
|
1762
|
-
return [4 /*yield*/, _evalToken(prop, ctx, false)];
|
|
1763
|
-
case 3:
|
|
1764
|
-
_d.apply(_c, [(_f.sent())]);
|
|
1765
|
-
_f.label = 4;
|
|
1766
|
-
case 4:
|
|
1767
|
-
_b = _a.next();
|
|
1768
|
-
return [3 /*break*/, 2];
|
|
1769
|
-
case 5: return [3 /*break*/, 8];
|
|
1770
|
-
case 6:
|
|
1771
|
-
e_2_1 = _f.sent();
|
|
1772
|
-
e_2 = { error: e_2_1 };
|
|
1773
|
-
return [3 /*break*/, 8];
|
|
1774
|
-
case 7:
|
|
1775
|
-
try {
|
|
1776
|
-
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
1777
|
-
}
|
|
1778
|
-
finally { if (e_2) throw e_2.error; }
|
|
1779
|
-
return [7 /*endfinally*/];
|
|
1780
|
-
case 8:
|
|
1781
|
-
_f.trys.push([8, 10, , 11]);
|
|
1782
|
-
return [4 /*yield*/, ctx._get(__spreadArray([token.propertyName], __read(props), false))];
|
|
1783
|
-
case 9: return [2 /*return*/, _f.sent()];
|
|
1784
|
-
case 10:
|
|
1785
|
-
e_3 = _f.sent();
|
|
1786
|
-
if (lenient && e_3.name === 'InternalUndefinedVariableError')
|
|
1787
|
-
return [2 /*return*/, null];
|
|
1788
|
-
throw (new UndefinedVariableError(e_3, token));
|
|
1789
|
-
case 11: return [2 /*return*/];
|
|
1790
|
-
}
|
|
1791
|
-
});
|
|
1792
|
-
}
|
|
1793
|
-
function evalNumberToken(token) {
|
|
1794
|
-
var str = token.whole.content + '.' + (token.decimal ? token.decimal.content : '');
|
|
1795
|
-
return Number(str);
|
|
1796
|
-
}
|
|
1797
|
-
function evalQuotedToken(token) {
|
|
1798
|
-
return parseStringLiteral(token.getText());
|
|
1799
|
-
}
|
|
1800
|
-
function evalOperatorToken(operators, token, lhs, rhs, ctx) {
|
|
1801
|
-
var impl = operators[token.operator];
|
|
1802
|
-
return impl(lhs, rhs, ctx);
|
|
1803
|
-
}
|
|
1804
|
-
function evalLiteralToken(token) {
|
|
1805
|
-
return literalValues[token.literal];
|
|
1806
|
-
}
|
|
1807
|
-
function evalRangeToken(token, ctx) {
|
|
1808
|
-
var low, high;
|
|
1809
|
-
return __generator(this, function (_a) {
|
|
1810
|
-
switch (_a.label) {
|
|
1811
|
-
case 0: return [4 /*yield*/, _evalToken(token.lhs, ctx)];
|
|
1812
|
-
case 1:
|
|
1813
|
-
low = _a.sent();
|
|
1814
|
-
return [4 /*yield*/, _evalToken(token.rhs, ctx)];
|
|
1815
|
-
case 2:
|
|
1816
|
-
high = _a.sent();
|
|
1817
|
-
return [2 /*return*/, range(+low, +high + 1)];
|
|
1818
|
-
}
|
|
1819
|
-
});
|
|
1820
|
-
}
|
|
1821
|
-
function toPostfix(tokens) {
|
|
1822
|
-
var ops, tokens_1, tokens_1_1, token, e_4_1;
|
|
1823
|
-
var e_4, _a;
|
|
1824
|
-
return __generator(this, function (_b) {
|
|
1825
|
-
switch (_b.label) {
|
|
1826
|
-
case 0:
|
|
1827
|
-
ops = [];
|
|
1828
|
-
_b.label = 1;
|
|
1829
|
-
case 1:
|
|
1830
|
-
_b.trys.push([1, 10, 11, 12]);
|
|
1831
|
-
tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next();
|
|
1832
|
-
_b.label = 2;
|
|
1833
|
-
case 2:
|
|
1834
|
-
if (!!tokens_1_1.done) return [3 /*break*/, 9];
|
|
1835
|
-
token = tokens_1_1.value;
|
|
1836
|
-
if (!isOperatorToken(token)) return [3 /*break*/, 6];
|
|
1837
|
-
_b.label = 3;
|
|
1838
|
-
case 3:
|
|
1839
|
-
if (!(ops.length && ops[ops.length - 1].getPrecedence() > token.getPrecedence())) return [3 /*break*/, 5];
|
|
1840
|
-
return [4 /*yield*/, ops.pop()];
|
|
1841
|
-
case 4:
|
|
1842
|
-
_b.sent();
|
|
1843
|
-
return [3 /*break*/, 3];
|
|
1844
|
-
case 5:
|
|
1845
|
-
ops.push(token);
|
|
1846
|
-
return [3 /*break*/, 8];
|
|
1847
|
-
case 6: return [4 /*yield*/, token];
|
|
1848
|
-
case 7:
|
|
1849
|
-
_b.sent();
|
|
1850
|
-
_b.label = 8;
|
|
1851
|
-
case 8:
|
|
1852
|
-
tokens_1_1 = tokens_1.next();
|
|
1853
|
-
return [3 /*break*/, 2];
|
|
1854
|
-
case 9: return [3 /*break*/, 12];
|
|
1855
|
-
case 10:
|
|
1856
|
-
e_4_1 = _b.sent();
|
|
1857
|
-
e_4 = { error: e_4_1 };
|
|
1858
|
-
return [3 /*break*/, 12];
|
|
1859
|
-
case 11:
|
|
1860
|
-
try {
|
|
1861
|
-
if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
|
|
1862
|
-
}
|
|
1863
|
-
finally { if (e_4) throw e_4.error; }
|
|
1864
|
-
return [7 /*endfinally*/];
|
|
1865
|
-
case 12:
|
|
1866
|
-
if (!ops.length) return [3 /*break*/, 14];
|
|
1867
|
-
return [4 /*yield*/, ops.pop()];
|
|
1868
|
-
case 13:
|
|
1869
|
-
_b.sent();
|
|
1870
|
-
return [3 /*break*/, 12];
|
|
1871
|
-
case 14: return [2 /*return*/];
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
|
-
var Token = /** @class */ (function () {
|
|
1877
|
-
function Token(kind, input, begin, end, file) {
|
|
1878
|
-
this.kind = kind;
|
|
1879
|
-
this.input = input;
|
|
1880
|
-
this.begin = begin;
|
|
1881
|
-
this.end = end;
|
|
1882
|
-
this.file = file;
|
|
1883
|
-
}
|
|
1884
|
-
Token.prototype.getText = function () {
|
|
1885
|
-
return this.input.slice(this.begin, this.end);
|
|
1886
|
-
};
|
|
1887
|
-
Token.prototype.getPosition = function () {
|
|
1888
|
-
var _a = __read([1, 1], 2), row = _a[0], col = _a[1];
|
|
1889
|
-
for (var i = 0; i < this.begin; i++) {
|
|
1890
|
-
if (this.input[i] === '\n') {
|
|
1891
|
-
row++;
|
|
1892
|
-
col = 1;
|
|
1893
|
-
}
|
|
1894
|
-
else
|
|
1895
|
-
col++;
|
|
1896
|
-
}
|
|
1897
|
-
return [row, col];
|
|
1898
|
-
};
|
|
1899
|
-
Token.prototype.size = function () {
|
|
1900
|
-
return this.end - this.begin;
|
|
1901
|
-
};
|
|
1902
|
-
return Token;
|
|
1903
|
-
}());
|
|
1904
|
-
|
|
1905
|
-
var DelimitedToken = /** @class */ (function (_super) {
|
|
1906
|
-
__extends(DelimitedToken, _super);
|
|
1907
|
-
function DelimitedToken(kind, content, input, begin, end, trimLeft, trimRight, file) {
|
|
1908
|
-
var _this = _super.call(this, kind, input, begin, end, file) || this;
|
|
1909
|
-
_this.trimLeft = false;
|
|
1910
|
-
_this.trimRight = false;
|
|
1911
|
-
_this.content = _this.getText();
|
|
1912
|
-
var tl = content[0] === '-';
|
|
1913
|
-
var tr = last$1(content) === '-';
|
|
1914
|
-
_this.content = content
|
|
1915
|
-
.slice(tl ? 1 : 0, tr ? -1 : content.length)
|
|
1916
|
-
.trim();
|
|
1917
|
-
_this.trimLeft = tl || trimLeft;
|
|
1918
|
-
_this.trimRight = tr || trimRight;
|
|
1919
|
-
return _this;
|
|
1920
|
-
}
|
|
1921
|
-
return DelimitedToken;
|
|
1922
|
-
}(Token));
|
|
1923
|
-
|
|
1924
|
-
function whiteSpaceCtrl(tokens, options) {
|
|
1925
|
-
var inRaw = false;
|
|
1926
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
1927
|
-
var token = tokens[i];
|
|
1928
|
-
if (!isDelimitedToken(token))
|
|
1929
|
-
continue;
|
|
1930
|
-
if (!inRaw && token.trimLeft) {
|
|
1931
|
-
trimLeft(tokens[i - 1], options.greedy);
|
|
1932
|
-
}
|
|
1933
|
-
if (isTagToken(token)) {
|
|
1934
|
-
if (token.name === 'raw')
|
|
1935
|
-
inRaw = true;
|
|
1936
|
-
else if (token.name === 'endraw')
|
|
1937
|
-
inRaw = false;
|
|
1938
|
-
}
|
|
1939
|
-
if (!inRaw && token.trimRight) {
|
|
1940
|
-
trimRight(tokens[i + 1], options.greedy);
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
function trimLeft(token, greedy) {
|
|
1945
|
-
if (!token || !isHTMLToken(token))
|
|
1946
|
-
return;
|
|
1947
|
-
var mask = greedy ? BLANK : INLINE_BLANK;
|
|
1948
|
-
while (TYPES[token.input.charCodeAt(token.end - 1 - token.trimRight)] & mask)
|
|
1949
|
-
token.trimRight++;
|
|
1950
|
-
}
|
|
1951
|
-
function trimRight(token, greedy) {
|
|
1952
|
-
if (!token || !isHTMLToken(token))
|
|
1953
|
-
return;
|
|
1954
|
-
var mask = greedy ? BLANK : INLINE_BLANK;
|
|
1955
|
-
while (TYPES[token.input.charCodeAt(token.begin + token.trimLeft)] & mask)
|
|
1956
|
-
token.trimLeft++;
|
|
1957
|
-
if (token.input.charAt(token.begin + token.trimLeft) === '\n')
|
|
1958
|
-
token.trimLeft++;
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
var NumberToken = /** @class */ (function (_super) {
|
|
1962
|
-
__extends(NumberToken, _super);
|
|
1963
|
-
function NumberToken(whole, decimal) {
|
|
1964
|
-
var _this = _super.call(this, exports.TokenKind.Number, whole.input, whole.begin, decimal ? decimal.end : whole.end, whole.file) || this;
|
|
1965
|
-
_this.whole = whole;
|
|
1966
|
-
_this.decimal = decimal;
|
|
1967
|
-
return _this;
|
|
1968
|
-
}
|
|
1969
|
-
return NumberToken;
|
|
1970
|
-
}(Token));
|
|
1971
|
-
|
|
1972
|
-
var IdentifierToken = /** @class */ (function (_super) {
|
|
1973
|
-
__extends(IdentifierToken, _super);
|
|
1974
|
-
function IdentifierToken(input, begin, end, file) {
|
|
1975
|
-
var _this = _super.call(this, exports.TokenKind.Word, input, begin, end, file) || this;
|
|
1976
|
-
_this.input = input;
|
|
1977
|
-
_this.begin = begin;
|
|
1978
|
-
_this.end = end;
|
|
1979
|
-
_this.file = file;
|
|
1980
|
-
_this.content = _this.getText();
|
|
1981
|
-
return _this;
|
|
1982
|
-
}
|
|
1983
|
-
IdentifierToken.prototype.isNumber = function (allowSign) {
|
|
1984
|
-
if (allowSign === void 0) { allowSign = false; }
|
|
1985
|
-
var begin = allowSign && TYPES[this.input.charCodeAt(this.begin)] & SIGN
|
|
1986
|
-
? this.begin + 1
|
|
1987
|
-
: this.begin;
|
|
1988
|
-
for (var i = begin; i < this.end; i++) {
|
|
1989
|
-
if (!(TYPES[this.input.charCodeAt(i)] & NUMBER))
|
|
1990
|
-
return false;
|
|
1991
|
-
}
|
|
1992
|
-
return true;
|
|
1993
|
-
};
|
|
1994
|
-
return IdentifierToken;
|
|
1995
|
-
}(Token));
|
|
1996
|
-
|
|
1997
|
-
var LiteralToken = /** @class */ (function (_super) {
|
|
1998
|
-
__extends(LiteralToken, _super);
|
|
1999
|
-
function LiteralToken(input, begin, end, file) {
|
|
2000
|
-
var _this = _super.call(this, exports.TokenKind.Literal, input, begin, end, file) || this;
|
|
2001
|
-
_this.input = input;
|
|
2002
|
-
_this.begin = begin;
|
|
2003
|
-
_this.end = end;
|
|
2004
|
-
_this.file = file;
|
|
2005
|
-
_this.literal = _this.getText();
|
|
2006
|
-
return _this;
|
|
2007
|
-
}
|
|
2008
|
-
return LiteralToken;
|
|
2009
|
-
}(Token));
|
|
2010
|
-
|
|
2011
|
-
var precedence = {
|
|
2012
|
-
'==': 1,
|
|
2013
|
-
'!=': 1,
|
|
2014
|
-
'>': 1,
|
|
2015
|
-
'<': 1,
|
|
2016
|
-
'>=': 1,
|
|
2017
|
-
'<=': 1,
|
|
2018
|
-
'contains': 1,
|
|
2019
|
-
'and': 0,
|
|
2020
|
-
'or': 0
|
|
2021
|
-
};
|
|
2022
|
-
var OperatorToken = /** @class */ (function (_super) {
|
|
2023
|
-
__extends(OperatorToken, _super);
|
|
2024
|
-
function OperatorToken(input, begin, end, file) {
|
|
2025
|
-
var _this = _super.call(this, exports.TokenKind.Operator, input, begin, end, file) || this;
|
|
2026
|
-
_this.input = input;
|
|
2027
|
-
_this.begin = begin;
|
|
2028
|
-
_this.end = end;
|
|
2029
|
-
_this.file = file;
|
|
2030
|
-
_this.operator = _this.getText();
|
|
2031
|
-
return _this;
|
|
2032
|
-
}
|
|
2033
|
-
OperatorToken.prototype.getPrecedence = function () {
|
|
2034
|
-
var key = this.getText();
|
|
2035
|
-
return key in precedence ? precedence[key] : 1;
|
|
2036
|
-
};
|
|
2037
|
-
return OperatorToken;
|
|
2038
|
-
}(Token));
|
|
2039
|
-
|
|
2040
|
-
var PropertyAccessToken = /** @class */ (function (_super) {
|
|
2041
|
-
__extends(PropertyAccessToken, _super);
|
|
2042
|
-
function PropertyAccessToken(variable, props, end) {
|
|
2043
|
-
var _this = _super.call(this, exports.TokenKind.PropertyAccess, variable.input, variable.begin, end, variable.file) || this;
|
|
2044
|
-
_this.variable = variable;
|
|
2045
|
-
_this.props = props;
|
|
2046
|
-
_this.propertyName = _this.variable instanceof IdentifierToken
|
|
2047
|
-
? _this.variable.getText()
|
|
2048
|
-
: parseStringLiteral(_this.variable.getText());
|
|
2049
|
-
return _this;
|
|
2050
|
-
}
|
|
2051
|
-
return PropertyAccessToken;
|
|
2052
|
-
}(Token));
|
|
2053
|
-
|
|
2054
|
-
var FilterToken = /** @class */ (function (_super) {
|
|
2055
|
-
__extends(FilterToken, _super);
|
|
2056
|
-
function FilterToken(name, args, input, begin, end, file) {
|
|
2057
|
-
var _this = _super.call(this, exports.TokenKind.Filter, input, begin, end, file) || this;
|
|
2058
|
-
_this.name = name;
|
|
2059
|
-
_this.args = args;
|
|
2060
|
-
return _this;
|
|
2061
|
-
}
|
|
2062
|
-
return FilterToken;
|
|
2063
|
-
}(Token));
|
|
2064
|
-
|
|
2065
|
-
var HashToken = /** @class */ (function (_super) {
|
|
2066
|
-
__extends(HashToken, _super);
|
|
2067
|
-
function HashToken(input, begin, end, name, value, file) {
|
|
2068
|
-
var _this = _super.call(this, exports.TokenKind.Hash, input, begin, end, file) || this;
|
|
2069
|
-
_this.input = input;
|
|
2070
|
-
_this.begin = begin;
|
|
2071
|
-
_this.end = end;
|
|
2072
|
-
_this.name = name;
|
|
2073
|
-
_this.value = value;
|
|
2074
|
-
_this.file = file;
|
|
2075
|
-
return _this;
|
|
2076
|
-
}
|
|
2077
|
-
return HashToken;
|
|
2078
|
-
}(Token));
|
|
2079
|
-
|
|
2080
|
-
var QuotedToken = /** @class */ (function (_super) {
|
|
2081
|
-
__extends(QuotedToken, _super);
|
|
2082
|
-
function QuotedToken(input, begin, end, file) {
|
|
2083
|
-
var _this = _super.call(this, exports.TokenKind.Quoted, input, begin, end, file) || this;
|
|
2084
|
-
_this.input = input;
|
|
2085
|
-
_this.begin = begin;
|
|
2086
|
-
_this.end = end;
|
|
2087
|
-
_this.file = file;
|
|
2088
|
-
return _this;
|
|
2089
|
-
}
|
|
2090
|
-
return QuotedToken;
|
|
2091
|
-
}(Token));
|
|
2092
|
-
|
|
2093
|
-
var HTMLToken = /** @class */ (function (_super) {
|
|
2094
|
-
__extends(HTMLToken, _super);
|
|
2095
|
-
function HTMLToken(input, begin, end, file) {
|
|
2096
|
-
var _this = _super.call(this, exports.TokenKind.HTML, input, begin, end, file) || this;
|
|
2097
|
-
_this.input = input;
|
|
2098
|
-
_this.begin = begin;
|
|
2099
|
-
_this.end = end;
|
|
2100
|
-
_this.file = file;
|
|
2101
|
-
_this.trimLeft = 0;
|
|
2102
|
-
_this.trimRight = 0;
|
|
2103
|
-
return _this;
|
|
2104
|
-
}
|
|
2105
|
-
HTMLToken.prototype.getContent = function () {
|
|
2106
|
-
return this.input.slice(this.begin + this.trimLeft, this.end - this.trimRight);
|
|
2107
|
-
};
|
|
2108
|
-
return HTMLToken;
|
|
2109
|
-
}(Token));
|
|
2110
|
-
|
|
2111
|
-
var RangeToken = /** @class */ (function (_super) {
|
|
2112
|
-
__extends(RangeToken, _super);
|
|
2113
|
-
function RangeToken(input, begin, end, lhs, rhs, file) {
|
|
2114
|
-
var _this = _super.call(this, exports.TokenKind.Range, input, begin, end, file) || this;
|
|
2115
|
-
_this.input = input;
|
|
2116
|
-
_this.begin = begin;
|
|
2117
|
-
_this.end = end;
|
|
2118
|
-
_this.lhs = lhs;
|
|
2119
|
-
_this.rhs = rhs;
|
|
2120
|
-
_this.file = file;
|
|
2121
|
-
return _this;
|
|
2122
|
-
}
|
|
2123
|
-
return RangeToken;
|
|
2124
|
-
}(Token));
|
|
2125
|
-
|
|
2126
|
-
var OutputToken = /** @class */ (function (_super) {
|
|
2127
|
-
__extends(OutputToken, _super);
|
|
2128
|
-
function OutputToken(input, begin, end, options, file) {
|
|
2129
|
-
var _this = this;
|
|
2130
|
-
var trimOutputLeft = options.trimOutputLeft, trimOutputRight = options.trimOutputRight, outputDelimiterLeft = options.outputDelimiterLeft, outputDelimiterRight = options.outputDelimiterRight;
|
|
2131
|
-
var value = input.slice(begin + outputDelimiterLeft.length, end - outputDelimiterRight.length);
|
|
2132
|
-
_this = _super.call(this, exports.TokenKind.Output, value, input, begin, end, trimOutputLeft, trimOutputRight, file) || this;
|
|
2133
|
-
return _this;
|
|
2134
|
-
}
|
|
2135
|
-
return OutputToken;
|
|
2136
|
-
}(DelimitedToken));
|
|
2137
|
-
|
|
2138
|
-
function matchOperator(str, begin, trie, end) {
|
|
2139
|
-
if (end === void 0) { end = str.length; }
|
|
2140
|
-
var node = trie;
|
|
2141
|
-
var i = begin;
|
|
2142
|
-
var info;
|
|
2143
|
-
while (node[str[i]] && i < end) {
|
|
2144
|
-
node = node[str[i++]];
|
|
2145
|
-
if (node['end'])
|
|
2146
|
-
info = node;
|
|
2147
|
-
}
|
|
2148
|
-
if (!info)
|
|
2149
|
-
return -1;
|
|
2150
|
-
if (info['needBoundary'] && (TYPES[str.charCodeAt(i)] & IDENTIFIER))
|
|
2151
|
-
return -1;
|
|
2152
|
-
return i;
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
var LiquidTagToken = /** @class */ (function (_super) {
|
|
2156
|
-
__extends(LiquidTagToken, _super);
|
|
2157
|
-
function LiquidTagToken(input, begin, end, options, file) {
|
|
2158
|
-
var _this = this;
|
|
2159
|
-
var value = input.slice(begin, end);
|
|
2160
|
-
_this = _super.call(this, exports.TokenKind.Tag, value, input, begin, end, false, false, file) || this;
|
|
2161
|
-
if (!/\S/.test(value)) {
|
|
2162
|
-
// A line that contains only whitespace.
|
|
2163
|
-
_this.name = '';
|
|
2164
|
-
_this.args = '';
|
|
2165
|
-
}
|
|
2166
|
-
else {
|
|
2167
|
-
var tokenizer = new Tokenizer(_this.content, options.operatorsTrie);
|
|
2168
|
-
_this.name = tokenizer.readTagName();
|
|
2169
|
-
if (!_this.name)
|
|
2170
|
-
throw new TokenizationError("illegal liquid tag syntax", _this);
|
|
2171
|
-
tokenizer.skipBlank();
|
|
2172
|
-
_this.args = tokenizer.remaining();
|
|
2173
|
-
}
|
|
2174
|
-
return _this;
|
|
2175
|
-
}
|
|
2176
|
-
return LiquidTagToken;
|
|
2177
|
-
}(DelimitedToken));
|
|
2178
|
-
|
|
2179
|
-
var Tokenizer = /** @class */ (function () {
|
|
2180
|
-
function Tokenizer(input, trie, file) {
|
|
2181
|
-
if (trie === void 0) { trie = defaultOptions.operatorsTrie; }
|
|
2182
|
-
if (file === void 0) { file = ''; }
|
|
2183
|
-
this.input = input;
|
|
2184
|
-
this.trie = trie;
|
|
2185
|
-
this.file = file;
|
|
2186
|
-
this.p = 0;
|
|
2187
|
-
this.rawBeginAt = -1;
|
|
2188
|
-
this.N = input.length;
|
|
2189
|
-
}
|
|
2190
|
-
Tokenizer.prototype.readExpression = function () {
|
|
2191
|
-
return new Expression(this.readExpressionTokens());
|
|
2192
|
-
};
|
|
2193
|
-
Tokenizer.prototype.readExpressionTokens = function () {
|
|
2194
|
-
var operand, operator, operand_1;
|
|
2195
|
-
return __generator(this, function (_a) {
|
|
2196
|
-
switch (_a.label) {
|
|
2197
|
-
case 0:
|
|
2198
|
-
operand = this.readValue();
|
|
2199
|
-
if (!operand)
|
|
2200
|
-
return [2 /*return*/];
|
|
2201
|
-
return [4 /*yield*/, operand];
|
|
2202
|
-
case 1:
|
|
2203
|
-
_a.sent();
|
|
2204
|
-
_a.label = 2;
|
|
2205
|
-
case 2:
|
|
2206
|
-
if (!(this.p < this.N)) return [3 /*break*/, 5];
|
|
2207
|
-
operator = this.readOperator();
|
|
2208
|
-
if (!operator)
|
|
2209
|
-
return [2 /*return*/];
|
|
2210
|
-
operand_1 = this.readValue();
|
|
2211
|
-
if (!operand_1)
|
|
2212
|
-
return [2 /*return*/];
|
|
2213
|
-
return [4 /*yield*/, operator];
|
|
2214
|
-
case 3:
|
|
2215
|
-
_a.sent();
|
|
2216
|
-
return [4 /*yield*/, operand_1];
|
|
2217
|
-
case 4:
|
|
2218
|
-
_a.sent();
|
|
2219
|
-
return [3 /*break*/, 2];
|
|
2220
|
-
case 5: return [2 /*return*/];
|
|
2221
|
-
}
|
|
2222
|
-
});
|
|
2223
|
-
};
|
|
2224
|
-
Tokenizer.prototype.readOperator = function () {
|
|
2225
|
-
this.skipBlank();
|
|
2226
|
-
var end = matchOperator(this.input, this.p, this.trie);
|
|
2227
|
-
if (end === -1)
|
|
2228
|
-
return;
|
|
2229
|
-
return new OperatorToken(this.input, this.p, (this.p = end), this.file);
|
|
2230
|
-
};
|
|
2231
|
-
Tokenizer.prototype.readFilters = function () {
|
|
2232
|
-
var filters = [];
|
|
2233
|
-
while (true) {
|
|
2234
|
-
var filter = this.readFilter();
|
|
2235
|
-
if (!filter)
|
|
2236
|
-
return filters;
|
|
2237
|
-
filters.push(filter);
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
Tokenizer.prototype.readFilter = function () {
|
|
2241
|
-
var _this = this;
|
|
2242
|
-
this.skipBlank();
|
|
2243
|
-
if (this.end())
|
|
2244
|
-
return null;
|
|
2245
|
-
assert(this.peek() === '|', function () { return "unexpected token at ".concat(_this.snapshot()); });
|
|
2246
|
-
this.p++;
|
|
2247
|
-
var begin = this.p;
|
|
2248
|
-
var name = this.readIdentifier();
|
|
2249
|
-
if (!name.size())
|
|
2250
|
-
return null;
|
|
2251
|
-
var args = [];
|
|
2252
|
-
this.skipBlank();
|
|
2253
|
-
if (this.peek() === ':') {
|
|
2254
|
-
do {
|
|
2255
|
-
++this.p;
|
|
2256
|
-
var arg = this.readFilterArg();
|
|
2257
|
-
arg && args.push(arg);
|
|
2258
|
-
this.skipBlank();
|
|
2259
|
-
assert(this.end() || this.peek() === ',' || this.peek() === '|', function () { return "unexpected character ".concat(_this.snapshot()); });
|
|
2260
|
-
} while (this.peek() === ',');
|
|
2261
|
-
}
|
|
2262
|
-
return new FilterToken(name.getText(), args, this.input, begin, this.p, this.file);
|
|
2263
|
-
};
|
|
2264
|
-
Tokenizer.prototype.readFilterArg = function () {
|
|
2265
|
-
var key = this.readValue();
|
|
2266
|
-
if (!key)
|
|
2267
|
-
return;
|
|
2268
|
-
this.skipBlank();
|
|
2269
|
-
if (this.peek() !== ':')
|
|
2270
|
-
return key;
|
|
2271
|
-
++this.p;
|
|
2272
|
-
var value = this.readValue();
|
|
2273
|
-
return [key.getText(), value];
|
|
2274
|
-
};
|
|
2275
|
-
Tokenizer.prototype.readTopLevelTokens = function (options) {
|
|
2276
|
-
if (options === void 0) { options = defaultOptions; }
|
|
2277
|
-
var tokens = [];
|
|
2278
|
-
while (this.p < this.N) {
|
|
2279
|
-
var token = this.readTopLevelToken(options);
|
|
2280
|
-
tokens.push(token);
|
|
2281
|
-
}
|
|
2282
|
-
whiteSpaceCtrl(tokens, options);
|
|
2283
|
-
return tokens;
|
|
2284
|
-
};
|
|
2285
|
-
Tokenizer.prototype.readTopLevelToken = function (options) {
|
|
2286
|
-
var tagDelimiterLeft = options.tagDelimiterLeft, outputDelimiterLeft = options.outputDelimiterLeft;
|
|
2287
|
-
if (this.rawBeginAt > -1)
|
|
2288
|
-
return this.readEndrawOrRawContent(options);
|
|
2289
|
-
if (this.match(tagDelimiterLeft))
|
|
2290
|
-
return this.readTagToken(options);
|
|
2291
|
-
if (this.match(outputDelimiterLeft))
|
|
2292
|
-
return this.readOutputToken(options);
|
|
2293
|
-
return this.readHTMLToken([tagDelimiterLeft, outputDelimiterLeft]);
|
|
2294
|
-
};
|
|
2295
|
-
Tokenizer.prototype.readHTMLToken = function (stopStrings) {
|
|
2296
|
-
var _this = this;
|
|
2297
|
-
var begin = this.p;
|
|
2298
|
-
while (this.p < this.N) {
|
|
2299
|
-
if (stopStrings.some(function (str) { return _this.match(str); }))
|
|
2300
|
-
break;
|
|
2301
|
-
++this.p;
|
|
2302
|
-
}
|
|
2303
|
-
return new HTMLToken(this.input, begin, this.p, this.file);
|
|
2304
|
-
};
|
|
2305
|
-
Tokenizer.prototype.readTagToken = function (options) {
|
|
2306
|
-
if (options === void 0) { options = defaultOptions; }
|
|
2307
|
-
var _a = this, file = _a.file, input = _a.input;
|
|
2308
|
-
var begin = this.p;
|
|
2309
|
-
if (this.readToDelimiter(options.tagDelimiterRight) === -1) {
|
|
2310
|
-
throw this.mkError("tag ".concat(this.snapshot(begin), " not closed"), begin);
|
|
2311
|
-
}
|
|
2312
|
-
var token = new TagToken(input, begin, this.p, options, file);
|
|
2313
|
-
if (token.name === 'raw')
|
|
2314
|
-
this.rawBeginAt = begin;
|
|
2315
|
-
return token;
|
|
2316
|
-
};
|
|
2317
|
-
Tokenizer.prototype.readToDelimiter = function (delimiter) {
|
|
2318
|
-
while (this.p < this.N) {
|
|
2319
|
-
if ((this.peekType() & QUOTE)) {
|
|
2320
|
-
this.readQuoted();
|
|
2321
|
-
continue;
|
|
2322
|
-
}
|
|
2323
|
-
++this.p;
|
|
2324
|
-
if (this.rmatch(delimiter))
|
|
2325
|
-
return this.p;
|
|
2326
|
-
}
|
|
2327
|
-
return -1;
|
|
2328
|
-
};
|
|
2329
|
-
Tokenizer.prototype.readOutputToken = function (options) {
|
|
2330
|
-
if (options === void 0) { options = defaultOptions; }
|
|
2331
|
-
var _a = this, file = _a.file, input = _a.input;
|
|
2332
|
-
var outputDelimiterRight = options.outputDelimiterRight;
|
|
2333
|
-
var begin = this.p;
|
|
2334
|
-
if (this.readToDelimiter(outputDelimiterRight) === -1) {
|
|
2335
|
-
throw this.mkError("output ".concat(this.snapshot(begin), " not closed"), begin);
|
|
2336
|
-
}
|
|
2337
|
-
return new OutputToken(input, begin, this.p, options, file);
|
|
2338
|
-
};
|
|
2339
|
-
Tokenizer.prototype.readEndrawOrRawContent = function (options) {
|
|
2340
|
-
var tagDelimiterLeft = options.tagDelimiterLeft, tagDelimiterRight = options.tagDelimiterRight;
|
|
2341
|
-
var begin = this.p;
|
|
2342
|
-
var leftPos = this.readTo(tagDelimiterLeft) - tagDelimiterLeft.length;
|
|
2343
|
-
while (this.p < this.N) {
|
|
2344
|
-
if (this.readIdentifier().getText() !== 'endraw') {
|
|
2345
|
-
leftPos = this.readTo(tagDelimiterLeft) - tagDelimiterLeft.length;
|
|
2346
|
-
continue;
|
|
2347
|
-
}
|
|
2348
|
-
while (this.p <= this.N) {
|
|
2349
|
-
if (this.rmatch(tagDelimiterRight)) {
|
|
2350
|
-
var end = this.p;
|
|
2351
|
-
if (begin === leftPos) {
|
|
2352
|
-
this.rawBeginAt = -1;
|
|
2353
|
-
return new TagToken(this.input, begin, end, options, this.file);
|
|
2354
|
-
}
|
|
2355
|
-
else {
|
|
2356
|
-
this.p = leftPos;
|
|
2357
|
-
return new HTMLToken(this.input, begin, leftPos, this.file);
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
if (this.rmatch(tagDelimiterLeft))
|
|
2361
|
-
break;
|
|
2362
|
-
this.p++;
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
throw this.mkError("raw ".concat(this.snapshot(this.rawBeginAt), " not closed"), begin);
|
|
2366
|
-
};
|
|
2367
|
-
Tokenizer.prototype.readLiquidTagTokens = function (options) {
|
|
2368
|
-
if (options === void 0) { options = defaultOptions; }
|
|
2369
|
-
var tokens = [];
|
|
2370
|
-
while (this.p < this.N) {
|
|
2371
|
-
var token = this.readLiquidTagToken(options);
|
|
2372
|
-
if (token.name)
|
|
2373
|
-
tokens.push(token);
|
|
2374
|
-
}
|
|
2375
|
-
return tokens;
|
|
2376
|
-
};
|
|
2377
|
-
Tokenizer.prototype.readLiquidTagToken = function (options) {
|
|
2378
|
-
var _a = this, file = _a.file, input = _a.input;
|
|
2379
|
-
var begin = this.p;
|
|
2380
|
-
var end = this.N;
|
|
2381
|
-
if (this.readToDelimiter('\n') !== -1)
|
|
2382
|
-
end = this.p;
|
|
2383
|
-
return new LiquidTagToken(input, begin, end, options, file);
|
|
2384
|
-
};
|
|
2385
|
-
Tokenizer.prototype.mkError = function (msg, begin) {
|
|
2386
|
-
return new TokenizationError(msg, new IdentifierToken(this.input, begin, this.N, this.file));
|
|
2387
|
-
};
|
|
2388
|
-
Tokenizer.prototype.snapshot = function (begin) {
|
|
2389
|
-
if (begin === void 0) { begin = this.p; }
|
|
2390
|
-
return JSON.stringify(ellipsis(this.input.slice(begin), 16));
|
|
2391
|
-
};
|
|
2392
|
-
/**
|
|
2393
|
-
* @deprecated
|
|
2394
|
-
*/
|
|
2395
|
-
Tokenizer.prototype.readWord = function () {
|
|
2396
|
-
console.warn('Tokenizer#readWord() will be removed, use #readIdentifier instead');
|
|
2397
|
-
return this.readIdentifier();
|
|
2398
|
-
};
|
|
2399
|
-
Tokenizer.prototype.readIdentifier = function () {
|
|
2400
|
-
this.skipBlank();
|
|
2401
|
-
var begin = this.p;
|
|
2402
|
-
while (this.peekType() & IDENTIFIER)
|
|
2403
|
-
++this.p;
|
|
2404
|
-
return new IdentifierToken(this.input, begin, this.p, this.file);
|
|
2405
|
-
};
|
|
2406
|
-
Tokenizer.prototype.readTagName = function () {
|
|
2407
|
-
this.skipBlank();
|
|
2408
|
-
// Handle inline comment tags
|
|
2409
|
-
if (this.input[this.p] === '#')
|
|
2410
|
-
return this.input.slice(this.p, ++this.p);
|
|
2411
|
-
return this.readIdentifier().getText();
|
|
2412
|
-
};
|
|
2413
|
-
Tokenizer.prototype.readHashes = function (jekyllStyle) {
|
|
2414
|
-
var hashes = [];
|
|
2415
|
-
while (true) {
|
|
2416
|
-
var hash = this.readHash(jekyllStyle);
|
|
2417
|
-
if (!hash)
|
|
2418
|
-
return hashes;
|
|
2419
|
-
hashes.push(hash);
|
|
2420
|
-
}
|
|
2421
|
-
};
|
|
2422
|
-
Tokenizer.prototype.readHash = function (jekyllStyle) {
|
|
2423
|
-
this.skipBlank();
|
|
2424
|
-
if (this.peek() === ',')
|
|
2425
|
-
++this.p;
|
|
2426
|
-
var begin = this.p;
|
|
2427
|
-
var name = this.readIdentifier();
|
|
2428
|
-
if (!name.size())
|
|
2429
|
-
return;
|
|
2430
|
-
var value;
|
|
2431
|
-
this.skipBlank();
|
|
2432
|
-
var sep = jekyllStyle ? '=' : ':';
|
|
2433
|
-
if (this.peek() === sep) {
|
|
2434
|
-
++this.p;
|
|
2435
|
-
value = this.readValue();
|
|
2436
|
-
}
|
|
2437
|
-
return new HashToken(this.input, begin, this.p, name, value, this.file);
|
|
2438
|
-
};
|
|
2439
|
-
Tokenizer.prototype.remaining = function () {
|
|
2440
|
-
return this.input.slice(this.p);
|
|
2441
|
-
};
|
|
2442
|
-
Tokenizer.prototype.advance = function (i) {
|
|
2443
|
-
if (i === void 0) { i = 1; }
|
|
2444
|
-
this.p += i;
|
|
2445
|
-
};
|
|
2446
|
-
Tokenizer.prototype.end = function () {
|
|
2447
|
-
return this.p >= this.N;
|
|
2448
|
-
};
|
|
2449
|
-
Tokenizer.prototype.readTo = function (end) {
|
|
2450
|
-
while (this.p < this.N) {
|
|
2451
|
-
++this.p;
|
|
2452
|
-
if (this.rmatch(end))
|
|
2453
|
-
return this.p;
|
|
2454
|
-
}
|
|
2455
|
-
return -1;
|
|
2456
|
-
};
|
|
2457
|
-
Tokenizer.prototype.readValue = function () {
|
|
2458
|
-
var value = this.readQuoted() || this.readRange();
|
|
2459
|
-
if (value)
|
|
2460
|
-
return value;
|
|
2461
|
-
if (this.peek() === '[') {
|
|
2462
|
-
this.p++;
|
|
2463
|
-
var prop = this.readQuoted();
|
|
2464
|
-
if (!prop)
|
|
2465
|
-
return;
|
|
2466
|
-
if (this.peek() !== ']')
|
|
2467
|
-
return;
|
|
2468
|
-
this.p++;
|
|
2469
|
-
return new PropertyAccessToken(prop, [], this.p);
|
|
2470
|
-
}
|
|
2471
|
-
var variable = this.readIdentifier();
|
|
2472
|
-
if (!variable.size())
|
|
2473
|
-
return;
|
|
2474
|
-
var isNumber = variable.isNumber(true);
|
|
2475
|
-
var props = [];
|
|
2476
|
-
while (true) {
|
|
2477
|
-
if (this.peek() === '[') {
|
|
2478
|
-
isNumber = false;
|
|
2479
|
-
this.p++;
|
|
2480
|
-
var prop = this.readValue() || new IdentifierToken(this.input, this.p, this.p, this.file);
|
|
2481
|
-
this.readTo(']');
|
|
2482
|
-
props.push(prop);
|
|
2483
|
-
}
|
|
2484
|
-
else if (this.peek() === '.' && this.peek(1) !== '.') { // skip range syntax
|
|
2485
|
-
this.p++;
|
|
2486
|
-
var prop = this.readIdentifier();
|
|
2487
|
-
if (!prop.size())
|
|
2488
|
-
break;
|
|
2489
|
-
if (!prop.isNumber())
|
|
2490
|
-
isNumber = false;
|
|
2491
|
-
props.push(prop);
|
|
2492
|
-
}
|
|
2493
|
-
else
|
|
2494
|
-
break;
|
|
2495
|
-
}
|
|
2496
|
-
if (!props.length && literalValues.hasOwnProperty(variable.content)) {
|
|
2497
|
-
return new LiteralToken(this.input, variable.begin, variable.end, this.file);
|
|
2498
|
-
}
|
|
2499
|
-
if (isNumber)
|
|
2500
|
-
return new NumberToken(variable, props[0]);
|
|
2501
|
-
return new PropertyAccessToken(variable, props, this.p);
|
|
2502
|
-
};
|
|
2503
|
-
Tokenizer.prototype.readRange = function () {
|
|
2504
|
-
this.skipBlank();
|
|
2505
|
-
var begin = this.p;
|
|
2506
|
-
if (this.peek() !== '(')
|
|
2507
|
-
return;
|
|
2508
|
-
++this.p;
|
|
2509
|
-
var lhs = this.readValueOrThrow();
|
|
2510
|
-
this.p += 2;
|
|
2511
|
-
var rhs = this.readValueOrThrow();
|
|
2512
|
-
++this.p;
|
|
2513
|
-
return new RangeToken(this.input, begin, this.p, lhs, rhs, this.file);
|
|
2514
|
-
};
|
|
2515
|
-
Tokenizer.prototype.readValueOrThrow = function () {
|
|
2516
|
-
var _this = this;
|
|
2517
|
-
var value = this.readValue();
|
|
2518
|
-
assert(value, function () { return "unexpected token ".concat(_this.snapshot(), ", value expected"); });
|
|
2519
|
-
return value;
|
|
2520
|
-
};
|
|
2521
|
-
Tokenizer.prototype.readQuoted = function () {
|
|
2522
|
-
this.skipBlank();
|
|
2523
|
-
var begin = this.p;
|
|
2524
|
-
if (!(this.peekType() & QUOTE))
|
|
2525
|
-
return;
|
|
2526
|
-
++this.p;
|
|
2527
|
-
var escaped = false;
|
|
2528
|
-
while (this.p < this.N) {
|
|
2529
|
-
++this.p;
|
|
2530
|
-
if (this.input[this.p - 1] === this.input[begin] && !escaped)
|
|
2531
|
-
break;
|
|
2532
|
-
if (escaped)
|
|
2533
|
-
escaped = false;
|
|
2534
|
-
else if (this.input[this.p - 1] === '\\')
|
|
2535
|
-
escaped = true;
|
|
2536
|
-
}
|
|
2537
|
-
return new QuotedToken(this.input, begin, this.p, this.file);
|
|
2538
|
-
};
|
|
2539
|
-
Tokenizer.prototype.readFileNameTemplate = function (options) {
|
|
2540
|
-
var outputDelimiterLeft, htmlStopStrings, htmlStopStringSet;
|
|
2541
|
-
return __generator(this, function (_a) {
|
|
2542
|
-
switch (_a.label) {
|
|
2543
|
-
case 0:
|
|
2544
|
-
outputDelimiterLeft = options.outputDelimiterLeft;
|
|
2545
|
-
htmlStopStrings = [',', ' ', outputDelimiterLeft];
|
|
2546
|
-
htmlStopStringSet = new Set(htmlStopStrings);
|
|
2547
|
-
_a.label = 1;
|
|
2548
|
-
case 1:
|
|
2549
|
-
if (!(this.p < this.N && !htmlStopStringSet.has(this.peek()))) return [3 /*break*/, 3];
|
|
2550
|
-
return [4 /*yield*/, this.match(outputDelimiterLeft)
|
|
2551
|
-
? this.readOutputToken(options)
|
|
2552
|
-
: this.readHTMLToken(htmlStopStrings)];
|
|
2553
|
-
case 2:
|
|
2554
|
-
_a.sent();
|
|
2555
|
-
return [3 /*break*/, 1];
|
|
2556
|
-
case 3: return [2 /*return*/];
|
|
2557
|
-
}
|
|
2558
|
-
});
|
|
2559
|
-
};
|
|
2560
|
-
Tokenizer.prototype.match = function (word) {
|
|
2561
|
-
for (var i = 0; i < word.length; i++) {
|
|
2562
|
-
if (word[i] !== this.input[this.p + i])
|
|
2563
|
-
return false;
|
|
2564
|
-
}
|
|
2565
|
-
return true;
|
|
2566
|
-
};
|
|
2567
|
-
Tokenizer.prototype.rmatch = function (pattern) {
|
|
2568
|
-
for (var i = 0; i < pattern.length; i++) {
|
|
2569
|
-
if (pattern[pattern.length - 1 - i] !== this.input[this.p - 1 - i])
|
|
2570
|
-
return false;
|
|
2571
|
-
}
|
|
2572
|
-
return true;
|
|
2573
|
-
};
|
|
2574
|
-
Tokenizer.prototype.peekType = function (n) {
|
|
2575
|
-
if (n === void 0) { n = 0; }
|
|
2576
|
-
return TYPES[this.input.charCodeAt(this.p + n)];
|
|
2577
|
-
};
|
|
2578
|
-
Tokenizer.prototype.peek = function (n) {
|
|
2579
|
-
if (n === void 0) { n = 0; }
|
|
2580
|
-
return this.input[this.p + n];
|
|
2581
|
-
};
|
|
2582
|
-
Tokenizer.prototype.skipBlank = function () {
|
|
2583
|
-
while (this.peekType() & BLANK)
|
|
2584
|
-
++this.p;
|
|
2585
|
-
};
|
|
2586
|
-
return Tokenizer;
|
|
2587
|
-
}());
|
|
2588
|
-
|
|
2589
|
-
var TagToken = /** @class */ (function (_super) {
|
|
2590
|
-
__extends(TagToken, _super);
|
|
2591
|
-
function TagToken(input, begin, end, options, file) {
|
|
2592
|
-
var _this = this;
|
|
2593
|
-
var trimTagLeft = options.trimTagLeft, trimTagRight = options.trimTagRight, tagDelimiterLeft = options.tagDelimiterLeft, tagDelimiterRight = options.tagDelimiterRight;
|
|
2594
|
-
var value = input.slice(begin + tagDelimiterLeft.length, end - tagDelimiterRight.length);
|
|
2595
|
-
_this = _super.call(this, exports.TokenKind.Tag, value, input, begin, end, trimTagLeft, trimTagRight, file) || this;
|
|
2596
|
-
var tokenizer = new Tokenizer(_this.content, options.operatorsTrie);
|
|
2597
|
-
_this.name = tokenizer.readTagName();
|
|
2598
|
-
if (!_this.name)
|
|
2599
|
-
throw new TokenizationError("illegal tag syntax", _this);
|
|
2600
|
-
tokenizer.skipBlank();
|
|
2601
|
-
_this.args = tokenizer.remaining();
|
|
2602
|
-
return _this;
|
|
2603
|
-
}
|
|
2604
|
-
return TagToken;
|
|
2605
|
-
}(DelimitedToken));
|
|
2606
|
-
|
|
2607
|
-
var ParseStream = /** @class */ (function () {
|
|
2608
|
-
function ParseStream(tokens, parseToken) {
|
|
2609
|
-
this.handlers = {};
|
|
2610
|
-
this.stopRequested = false;
|
|
2611
|
-
this.tokens = tokens;
|
|
2612
|
-
this.parseToken = parseToken;
|
|
2613
|
-
}
|
|
2614
|
-
ParseStream.prototype.on = function (name, cb) {
|
|
2615
|
-
this.handlers[name] = cb;
|
|
2616
|
-
return this;
|
|
2617
|
-
};
|
|
2618
|
-
ParseStream.prototype.trigger = function (event, arg) {
|
|
2619
|
-
var h = this.handlers[event];
|
|
2620
|
-
return h ? (h.call(this, arg), true) : false;
|
|
2621
|
-
};
|
|
2622
|
-
ParseStream.prototype.start = function () {
|
|
2623
|
-
this.trigger('start');
|
|
2624
|
-
var token;
|
|
2625
|
-
while (!this.stopRequested && (token = this.tokens.shift())) {
|
|
2626
|
-
if (this.trigger('token', token))
|
|
2627
|
-
continue;
|
|
2628
|
-
if (isTagToken(token) && this.trigger("tag:".concat(token.name), token)) {
|
|
2629
|
-
continue;
|
|
2630
|
-
}
|
|
2631
|
-
var template = this.parseToken(token, this.tokens);
|
|
2632
|
-
this.trigger('template', template);
|
|
2633
|
-
}
|
|
2634
|
-
if (!this.stopRequested)
|
|
2635
|
-
this.trigger('end');
|
|
2636
|
-
return this;
|
|
2637
|
-
};
|
|
2638
|
-
ParseStream.prototype.stop = function () {
|
|
2639
|
-
this.stopRequested = true;
|
|
2640
|
-
return this;
|
|
2641
|
-
};
|
|
2642
|
-
return ParseStream;
|
|
2643
|
-
}());
|
|
2644
|
-
|
|
2645
|
-
/**
|
|
2646
|
-
* Key-Value Pairs Representing Tag Arguments
|
|
2647
|
-
* Example:
|
|
2648
|
-
* For the markup `, foo:'bar', coo:2 reversed %}`,
|
|
2649
|
-
* hash['foo'] === 'bar'
|
|
2650
|
-
* hash['coo'] === 2
|
|
2651
|
-
* hash['reversed'] === undefined
|
|
2652
|
-
*/
|
|
2653
|
-
var Hash = /** @class */ (function () {
|
|
2654
|
-
function Hash(markup, jekyllStyle) {
|
|
2655
|
-
var e_1, _a;
|
|
2656
|
-
this.hash = {};
|
|
2657
|
-
var tokenizer = new Tokenizer(markup, {});
|
|
2658
|
-
try {
|
|
2659
|
-
for (var _b = __values(tokenizer.readHashes(jekyllStyle)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2660
|
-
var hash = _c.value;
|
|
2661
|
-
this.hash[hash.name.content] = hash.value;
|
|
2662
|
-
}
|
|
2663
|
-
}
|
|
2664
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2665
|
-
finally {
|
|
2666
|
-
try {
|
|
2667
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2668
|
-
}
|
|
2669
|
-
finally { if (e_1) throw e_1.error; }
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
Hash.prototype.render = function (ctx) {
|
|
2673
|
-
var hash, _a, _b, key, _c, _d, _e, e_2_1;
|
|
2674
|
-
var e_2, _f;
|
|
2675
|
-
return __generator(this, function (_g) {
|
|
2676
|
-
switch (_g.label) {
|
|
2677
|
-
case 0:
|
|
2678
|
-
hash = {};
|
|
2679
|
-
_g.label = 1;
|
|
2680
|
-
case 1:
|
|
2681
|
-
_g.trys.push([1, 8, 9, 10]);
|
|
2682
|
-
_a = __values(Object.keys(this.hash)), _b = _a.next();
|
|
2683
|
-
_g.label = 2;
|
|
2684
|
-
case 2:
|
|
2685
|
-
if (!!_b.done) return [3 /*break*/, 7];
|
|
2686
|
-
key = _b.value;
|
|
2687
|
-
_c = hash;
|
|
2688
|
-
_d = key;
|
|
2689
|
-
if (!(this.hash[key] === undefined)) return [3 /*break*/, 3];
|
|
2690
|
-
_e = true;
|
|
2691
|
-
return [3 /*break*/, 5];
|
|
2692
|
-
case 3: return [4 /*yield*/, _evalToken(this.hash[key], ctx)];
|
|
2693
|
-
case 4:
|
|
2694
|
-
_e = _g.sent();
|
|
2695
|
-
_g.label = 5;
|
|
2696
|
-
case 5:
|
|
2697
|
-
_c[_d] = _e;
|
|
2698
|
-
_g.label = 6;
|
|
2699
|
-
case 6:
|
|
2700
|
-
_b = _a.next();
|
|
2701
|
-
return [3 /*break*/, 2];
|
|
2702
|
-
case 7: return [3 /*break*/, 10];
|
|
2703
|
-
case 8:
|
|
2704
|
-
e_2_1 = _g.sent();
|
|
2705
|
-
e_2 = { error: e_2_1 };
|
|
2706
|
-
return [3 /*break*/, 10];
|
|
2707
|
-
case 9:
|
|
2708
|
-
try {
|
|
2709
|
-
if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
|
|
2710
|
-
}
|
|
2711
|
-
finally { if (e_2) throw e_2.error; }
|
|
2712
|
-
return [7 /*endfinally*/];
|
|
2713
|
-
case 10: return [2 /*return*/, hash];
|
|
2714
|
-
}
|
|
2715
|
-
});
|
|
2716
|
-
};
|
|
2717
|
-
return Hash;
|
|
2718
|
-
}());
|
|
2719
|
-
|
|
2720
|
-
function isKeyValuePair(arr) {
|
|
2721
|
-
return isArray(arr);
|
|
2722
|
-
}
|
|
2723
|
-
|
|
2724
|
-
var Filter = /** @class */ (function () {
|
|
2725
|
-
function Filter(name, impl, args, liquid) {
|
|
2726
|
-
this.name = name;
|
|
2727
|
-
this.impl = impl || identify;
|
|
2728
|
-
this.args = args;
|
|
2729
|
-
this.liquid = liquid;
|
|
2730
|
-
}
|
|
2731
|
-
Filter.prototype.render = function (value, context) {
|
|
2732
|
-
var argv, _a, _b, arg, _c, _d, _e, _f, _g, e_1_1;
|
|
2733
|
-
var e_1, _h;
|
|
2734
|
-
return __generator(this, function (_j) {
|
|
2735
|
-
switch (_j.label) {
|
|
2736
|
-
case 0:
|
|
2737
|
-
argv = [];
|
|
2738
|
-
_j.label = 1;
|
|
2739
|
-
case 1:
|
|
2740
|
-
_j.trys.push([1, 8, 9, 10]);
|
|
2741
|
-
_a = __values(this.args), _b = _a.next();
|
|
2742
|
-
_j.label = 2;
|
|
2743
|
-
case 2:
|
|
2744
|
-
if (!!_b.done) return [3 /*break*/, 7];
|
|
2745
|
-
arg = _b.value;
|
|
2746
|
-
if (!isKeyValuePair(arg)) return [3 /*break*/, 4];
|
|
2747
|
-
_d = (_c = argv).push;
|
|
2748
|
-
_e = [arg[0]];
|
|
2749
|
-
return [4 /*yield*/, _evalToken(arg[1], context)];
|
|
2750
|
-
case 3:
|
|
2751
|
-
_d.apply(_c, [_e.concat([_j.sent()])]);
|
|
2752
|
-
return [3 /*break*/, 6];
|
|
2753
|
-
case 4:
|
|
2754
|
-
_g = (_f = argv).push;
|
|
2755
|
-
return [4 /*yield*/, _evalToken(arg, context)];
|
|
2756
|
-
case 5:
|
|
2757
|
-
_g.apply(_f, [_j.sent()]);
|
|
2758
|
-
_j.label = 6;
|
|
2759
|
-
case 6:
|
|
2760
|
-
_b = _a.next();
|
|
2761
|
-
return [3 /*break*/, 2];
|
|
2762
|
-
case 7: return [3 /*break*/, 10];
|
|
2763
|
-
case 8:
|
|
2764
|
-
e_1_1 = _j.sent();
|
|
2765
|
-
e_1 = { error: e_1_1 };
|
|
2766
|
-
return [3 /*break*/, 10];
|
|
2767
|
-
case 9:
|
|
2768
|
-
try {
|
|
2769
|
-
if (_b && !_b.done && (_h = _a.return)) _h.call(_a);
|
|
2770
|
-
}
|
|
2771
|
-
finally { if (e_1) throw e_1.error; }
|
|
2772
|
-
return [7 /*endfinally*/];
|
|
2773
|
-
case 10: return [2 /*return*/, this.impl.apply({ context: context, liquid: this.liquid }, __spreadArray([value], __read(argv), false))];
|
|
2774
|
-
}
|
|
2775
|
-
});
|
|
2776
|
-
};
|
|
2777
|
-
return Filter;
|
|
2778
|
-
}());
|
|
2779
|
-
|
|
2780
|
-
var Value = /** @class */ (function () {
|
|
2781
|
-
/**
|
|
2782
|
-
* @param str the value to be valuated, eg.: "foobar" | truncate: 3
|
|
2783
|
-
*/
|
|
2784
|
-
function Value(str, liquid) {
|
|
2785
|
-
this.filters = [];
|
|
2786
|
-
var tokenizer = new Tokenizer(str, liquid.options.operatorsTrie);
|
|
2787
|
-
this.initial = tokenizer.readExpression();
|
|
2788
|
-
this.filters = tokenizer.readFilters().map(function (_a) {
|
|
2789
|
-
var name = _a.name, args = _a.args;
|
|
2790
|
-
return new Filter(name, liquid.filters.get(name), args, liquid);
|
|
2791
|
-
});
|
|
2792
|
-
}
|
|
2793
|
-
Value.prototype.value = function (ctx, lenient) {
|
|
2794
|
-
var val, _a, _b, filter, e_1_1;
|
|
2795
|
-
var e_1, _c;
|
|
2796
|
-
return __generator(this, function (_d) {
|
|
2797
|
-
switch (_d.label) {
|
|
2798
|
-
case 0:
|
|
2799
|
-
lenient = lenient || (ctx.opts.lenientIf && this.filters.length > 0 && this.filters[0].name === 'default');
|
|
2800
|
-
return [4 /*yield*/, this.initial.evaluate(ctx, lenient)];
|
|
2801
|
-
case 1:
|
|
2802
|
-
val = _d.sent();
|
|
2803
|
-
_d.label = 2;
|
|
2804
|
-
case 2:
|
|
2805
|
-
_d.trys.push([2, 7, 8, 9]);
|
|
2806
|
-
_a = __values(this.filters), _b = _a.next();
|
|
2807
|
-
_d.label = 3;
|
|
2808
|
-
case 3:
|
|
2809
|
-
if (!!_b.done) return [3 /*break*/, 6];
|
|
2810
|
-
filter = _b.value;
|
|
2811
|
-
return [4 /*yield*/, filter.render(val, ctx)];
|
|
2812
|
-
case 4:
|
|
2813
|
-
val = _d.sent();
|
|
2814
|
-
_d.label = 5;
|
|
2815
|
-
case 5:
|
|
2816
|
-
_b = _a.next();
|
|
2817
|
-
return [3 /*break*/, 3];
|
|
2818
|
-
case 6: return [3 /*break*/, 9];
|
|
2819
|
-
case 7:
|
|
2820
|
-
e_1_1 = _d.sent();
|
|
2821
|
-
e_1 = { error: e_1_1 };
|
|
2822
|
-
return [3 /*break*/, 9];
|
|
2823
|
-
case 8:
|
|
2824
|
-
try {
|
|
2825
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
2826
|
-
}
|
|
2827
|
-
finally { if (e_1) throw e_1.error; }
|
|
2828
|
-
return [7 /*endfinally*/];
|
|
2829
|
-
case 9: return [2 /*return*/, val];
|
|
2830
|
-
}
|
|
2831
|
-
});
|
|
2832
|
-
};
|
|
2833
|
-
return Value;
|
|
2834
|
-
}());
|
|
2835
|
-
|
|
2836
|
-
var assign = {
|
|
2837
|
-
parse: function (token) {
|
|
2838
|
-
var tokenizer = new Tokenizer(token.args, this.liquid.options.operatorsTrie);
|
|
2839
|
-
this.key = tokenizer.readIdentifier().content;
|
|
2840
|
-
tokenizer.skipBlank();
|
|
2841
|
-
assert(tokenizer.peek() === '=', function () { return "illegal token ".concat(token.getText()); });
|
|
2842
|
-
tokenizer.advance();
|
|
2843
|
-
this.value = new Value(tokenizer.remaining(), this.liquid);
|
|
2844
|
-
},
|
|
2845
|
-
render: function (ctx) {
|
|
2846
|
-
var _a, _b;
|
|
2847
|
-
return __generator(this, function (_c) {
|
|
2848
|
-
switch (_c.label) {
|
|
2849
|
-
case 0:
|
|
2850
|
-
_a = ctx.bottom();
|
|
2851
|
-
_b = this.key;
|
|
2852
|
-
return [4 /*yield*/, this.value.value(ctx, this.liquid.options.lenientIf)];
|
|
2853
|
-
case 1:
|
|
2854
|
-
_a[_b] = _c.sent();
|
|
2855
|
-
return [2 /*return*/];
|
|
2856
|
-
}
|
|
2857
|
-
});
|
|
2858
|
-
}
|
|
2859
|
-
};
|
|
2860
|
-
|
|
2861
|
-
var ForloopDrop = /** @class */ (function (_super) {
|
|
2862
|
-
__extends(ForloopDrop, _super);
|
|
2863
|
-
function ForloopDrop(length, collection, variable) {
|
|
2864
|
-
var _this = _super.call(this) || this;
|
|
2865
|
-
_this.i = 0;
|
|
2866
|
-
_this.length = length;
|
|
2867
|
-
_this.name = "".concat(variable, "-").concat(collection);
|
|
2868
|
-
return _this;
|
|
2869
|
-
}
|
|
2870
|
-
ForloopDrop.prototype.next = function () {
|
|
2871
|
-
this.i++;
|
|
2872
|
-
};
|
|
2873
|
-
ForloopDrop.prototype.index0 = function () {
|
|
2874
|
-
return this.i;
|
|
2875
|
-
};
|
|
2876
|
-
ForloopDrop.prototype.index = function () {
|
|
2877
|
-
return this.i + 1;
|
|
2878
|
-
};
|
|
2879
|
-
ForloopDrop.prototype.first = function () {
|
|
2880
|
-
return this.i === 0;
|
|
2881
|
-
};
|
|
2882
|
-
ForloopDrop.prototype.last = function () {
|
|
2883
|
-
return this.i === this.length - 1;
|
|
2884
|
-
};
|
|
2885
|
-
ForloopDrop.prototype.rindex = function () {
|
|
2886
|
-
return this.length - this.i;
|
|
2887
|
-
};
|
|
2888
|
-
ForloopDrop.prototype.rindex0 = function () {
|
|
2889
|
-
return this.length - this.i - 1;
|
|
2890
|
-
};
|
|
2891
|
-
ForloopDrop.prototype.valueOf = function () {
|
|
2892
|
-
return JSON.stringify(this);
|
|
2893
|
-
};
|
|
2894
|
-
return ForloopDrop;
|
|
2895
|
-
}(Drop));
|
|
2896
|
-
|
|
2897
|
-
var MODIFIERS = ['offset', 'limit', 'reversed'];
|
|
2898
|
-
var For = {
|
|
2899
|
-
type: 'block',
|
|
2900
|
-
parse: function (token, remainTokens) {
|
|
2901
|
-
var _this = this;
|
|
2902
|
-
var tokenizer = new Tokenizer(token.args, this.liquid.options.operatorsTrie);
|
|
2903
|
-
var variable = tokenizer.readIdentifier();
|
|
2904
|
-
var inStr = tokenizer.readIdentifier();
|
|
2905
|
-
var collection = tokenizer.readValue();
|
|
2906
|
-
assert(variable.size() && inStr.content === 'in' && collection, function () { return "illegal tag: ".concat(token.getText()); });
|
|
2907
|
-
this.variable = variable.content;
|
|
2908
|
-
this.collection = collection;
|
|
2909
|
-
this.hash = new Hash(tokenizer.remaining());
|
|
2910
|
-
this.templates = [];
|
|
2911
|
-
this.elseTemplates = [];
|
|
2912
|
-
var p;
|
|
2913
|
-
var stream = this.liquid.parser.parseStream(remainTokens)
|
|
2914
|
-
.on('start', function () { return (p = _this.templates); })
|
|
2915
|
-
.on('tag:else', function () { return (p = _this.elseTemplates); })
|
|
2916
|
-
.on('tag:endfor', function () { return stream.stop(); })
|
|
2917
|
-
.on('template', function (tpl) { return p.push(tpl); })
|
|
2918
|
-
.on('end', function () {
|
|
2919
|
-
throw new Error("tag ".concat(token.getText(), " not closed"));
|
|
2920
|
-
});
|
|
2921
|
-
stream.start();
|
|
2922
|
-
},
|
|
2923
|
-
render: function (ctx, emitter) {
|
|
2924
|
-
var r, collection, _a, continueKey, hash, modifiers, scope, collection_1, collection_1_1, item, e_1_1;
|
|
2925
|
-
var e_1, _b;
|
|
2926
|
-
return __generator(this, function (_c) {
|
|
2927
|
-
switch (_c.label) {
|
|
2928
|
-
case 0:
|
|
2929
|
-
r = this.liquid.renderer;
|
|
2930
|
-
_a = toEnumerable;
|
|
2931
|
-
return [4 /*yield*/, _evalToken(this.collection, ctx)];
|
|
2932
|
-
case 1:
|
|
2933
|
-
collection = _a.apply(void 0, [_c.sent()]);
|
|
2934
|
-
if (!!collection.length) return [3 /*break*/, 3];
|
|
2935
|
-
return [4 /*yield*/, r.renderTemplates(this.elseTemplates, ctx, emitter)];
|
|
2936
|
-
case 2:
|
|
2937
|
-
_c.sent();
|
|
2938
|
-
return [2 /*return*/];
|
|
2939
|
-
case 3:
|
|
2940
|
-
continueKey = 'continue-' + this.variable + '-' + this.collection.getText();
|
|
2941
|
-
ctx.push({ continue: ctx.getRegister(continueKey) });
|
|
2942
|
-
return [4 /*yield*/, this.hash.render(ctx)];
|
|
2943
|
-
case 4:
|
|
2944
|
-
hash = _c.sent();
|
|
2945
|
-
ctx.pop();
|
|
2946
|
-
modifiers = this.liquid.options.orderedFilterParameters
|
|
2947
|
-
? Object.keys(hash).filter(function (x) { return MODIFIERS.includes(x); })
|
|
2948
|
-
: MODIFIERS.filter(function (x) { return hash[x] !== undefined; });
|
|
2949
|
-
collection = modifiers.reduce(function (collection, modifier) {
|
|
2950
|
-
if (modifier === 'offset')
|
|
2951
|
-
return offset(collection, hash['offset']);
|
|
2952
|
-
if (modifier === 'limit')
|
|
2953
|
-
return limit(collection, hash['limit']);
|
|
2954
|
-
return reversed(collection);
|
|
2955
|
-
}, collection);
|
|
2956
|
-
ctx.setRegister(continueKey, (hash['offset'] || 0) + collection.length);
|
|
2957
|
-
scope = { forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) };
|
|
2958
|
-
ctx.push(scope);
|
|
2959
|
-
_c.label = 5;
|
|
2960
|
-
case 5:
|
|
2961
|
-
_c.trys.push([5, 10, 11, 12]);
|
|
2962
|
-
collection_1 = __values(collection), collection_1_1 = collection_1.next();
|
|
2963
|
-
_c.label = 6;
|
|
2964
|
-
case 6:
|
|
2965
|
-
if (!!collection_1_1.done) return [3 /*break*/, 9];
|
|
2966
|
-
item = collection_1_1.value;
|
|
2967
|
-
scope[this.variable] = item;
|
|
2968
|
-
return [4 /*yield*/, r.renderTemplates(this.templates, ctx, emitter)];
|
|
2969
|
-
case 7:
|
|
2970
|
-
_c.sent();
|
|
2971
|
-
if (emitter['break']) {
|
|
2972
|
-
emitter['break'] = false;
|
|
2973
|
-
return [3 /*break*/, 9];
|
|
2974
|
-
}
|
|
2975
|
-
emitter['continue'] = false;
|
|
2976
|
-
scope.forloop.next();
|
|
2977
|
-
_c.label = 8;
|
|
2978
|
-
case 8:
|
|
2979
|
-
collection_1_1 = collection_1.next();
|
|
2980
|
-
return [3 /*break*/, 6];
|
|
2981
|
-
case 9: return [3 /*break*/, 12];
|
|
2982
|
-
case 10:
|
|
2983
|
-
e_1_1 = _c.sent();
|
|
2984
|
-
e_1 = { error: e_1_1 };
|
|
2985
|
-
return [3 /*break*/, 12];
|
|
2986
|
-
case 11:
|
|
2987
|
-
try {
|
|
2988
|
-
if (collection_1_1 && !collection_1_1.done && (_b = collection_1.return)) _b.call(collection_1);
|
|
2989
|
-
}
|
|
2990
|
-
finally { if (e_1) throw e_1.error; }
|
|
2991
|
-
return [7 /*endfinally*/];
|
|
2992
|
-
case 12:
|
|
2993
|
-
ctx.pop();
|
|
2994
|
-
return [2 /*return*/];
|
|
2995
|
-
}
|
|
2996
|
-
});
|
|
2997
|
-
}
|
|
2998
|
-
};
|
|
2999
|
-
function reversed(arr) {
|
|
3000
|
-
return __spreadArray([], __read(arr), false).reverse();
|
|
3001
|
-
}
|
|
3002
|
-
function offset(arr, count) {
|
|
3003
|
-
return arr.slice(count);
|
|
3004
|
-
}
|
|
3005
|
-
function limit(arr, count) {
|
|
3006
|
-
return arr.slice(0, count);
|
|
3007
|
-
}
|
|
3008
|
-
|
|
3009
|
-
var capture = {
|
|
3010
|
-
parse: function (tagToken, remainTokens) {
|
|
3011
|
-
var _this = this;
|
|
3012
|
-
var tokenizer = new Tokenizer(tagToken.args, this.liquid.options.operatorsTrie);
|
|
3013
|
-
this.variable = readVariableName(tokenizer);
|
|
3014
|
-
assert(this.variable, function () { return "".concat(tagToken.args, " not valid identifier"); });
|
|
3015
|
-
this.templates = [];
|
|
3016
|
-
var stream = this.liquid.parser.parseStream(remainTokens);
|
|
3017
|
-
stream.on('tag:endcapture', function () { return stream.stop(); })
|
|
3018
|
-
.on('template', function (tpl) { return _this.templates.push(tpl); })
|
|
3019
|
-
.on('end', function () {
|
|
3020
|
-
throw new Error("tag ".concat(tagToken.getText(), " not closed"));
|
|
3021
|
-
});
|
|
3022
|
-
stream.start();
|
|
3023
|
-
},
|
|
3024
|
-
render: function (ctx) {
|
|
3025
|
-
var r, html;
|
|
3026
|
-
return __generator(this, function (_a) {
|
|
3027
|
-
switch (_a.label) {
|
|
3028
|
-
case 0:
|
|
3029
|
-
r = this.liquid.renderer;
|
|
3030
|
-
return [4 /*yield*/, r.renderTemplates(this.templates, ctx)];
|
|
3031
|
-
case 1:
|
|
3032
|
-
html = _a.sent();
|
|
3033
|
-
ctx.bottom()[this.variable] = html;
|
|
3034
|
-
return [2 /*return*/];
|
|
3035
|
-
}
|
|
3036
|
-
});
|
|
3037
|
-
}
|
|
3038
|
-
};
|
|
3039
|
-
function readVariableName(tokenizer) {
|
|
3040
|
-
var word = tokenizer.readIdentifier().content;
|
|
3041
|
-
if (word)
|
|
3042
|
-
return word;
|
|
3043
|
-
var quoted = tokenizer.readQuoted();
|
|
3044
|
-
if (quoted)
|
|
3045
|
-
return evalQuotedToken(quoted);
|
|
3046
|
-
}
|
|
3047
|
-
|
|
3048
|
-
var Case = {
|
|
3049
|
-
parse: function (tagToken, remainTokens) {
|
|
3050
|
-
var _this = this;
|
|
3051
|
-
this.cond = new Value(tagToken.args, this.liquid);
|
|
3052
|
-
this.cases = [];
|
|
3053
|
-
this.elseTemplates = [];
|
|
3054
|
-
var p = [];
|
|
3055
|
-
var stream = this.liquid.parser.parseStream(remainTokens)
|
|
3056
|
-
.on('tag:when', function (token) {
|
|
3057
|
-
p = [];
|
|
3058
|
-
var tokenizer = new Tokenizer(token.args, _this.liquid.options.operatorsTrie);
|
|
3059
|
-
while (!tokenizer.end()) {
|
|
3060
|
-
var value = tokenizer.readValue();
|
|
3061
|
-
_this.cases.push({
|
|
3062
|
-
val: value,
|
|
3063
|
-
templates: p
|
|
3064
|
-
});
|
|
3065
|
-
tokenizer.readTo(',');
|
|
3066
|
-
}
|
|
3067
|
-
})
|
|
3068
|
-
.on('tag:else', function () { return (p = _this.elseTemplates); })
|
|
3069
|
-
.on('tag:endcase', function () { return stream.stop(); })
|
|
3070
|
-
.on('template', function (tpl) { return p.push(tpl); })
|
|
3071
|
-
.on('end', function () {
|
|
3072
|
-
throw new Error("tag ".concat(tagToken.getText(), " not closed"));
|
|
3073
|
-
});
|
|
3074
|
-
stream.start();
|
|
3075
|
-
},
|
|
3076
|
-
render: function (ctx, emitter) {
|
|
3077
|
-
var r, cond, _a, _b, _c, branch, val, e_1_1;
|
|
3078
|
-
var e_1, _d;
|
|
3079
|
-
return __generator(this, function (_e) {
|
|
3080
|
-
switch (_e.label) {
|
|
3081
|
-
case 0:
|
|
3082
|
-
r = this.liquid.renderer;
|
|
3083
|
-
_a = toValue;
|
|
3084
|
-
return [4 /*yield*/, this.cond.value(ctx, ctx.opts.lenientIf)];
|
|
3085
|
-
case 1:
|
|
3086
|
-
cond = _a.apply(void 0, [_e.sent()]);
|
|
3087
|
-
_e.label = 2;
|
|
3088
|
-
case 2:
|
|
3089
|
-
_e.trys.push([2, 8, 9, 10]);
|
|
3090
|
-
_b = __values(this.cases), _c = _b.next();
|
|
3091
|
-
_e.label = 3;
|
|
3092
|
-
case 3:
|
|
3093
|
-
if (!!_c.done) return [3 /*break*/, 7];
|
|
3094
|
-
branch = _c.value;
|
|
3095
|
-
return [4 /*yield*/, _evalToken(branch.val, ctx, ctx.opts.lenientIf)];
|
|
3096
|
-
case 4:
|
|
3097
|
-
val = _e.sent();
|
|
3098
|
-
if (!(val === cond)) return [3 /*break*/, 6];
|
|
3099
|
-
return [4 /*yield*/, r.renderTemplates(branch.templates, ctx, emitter)];
|
|
3100
|
-
case 5:
|
|
3101
|
-
_e.sent();
|
|
3102
|
-
return [2 /*return*/];
|
|
3103
|
-
case 6:
|
|
3104
|
-
_c = _b.next();
|
|
3105
|
-
return [3 /*break*/, 3];
|
|
3106
|
-
case 7: return [3 /*break*/, 10];
|
|
3107
|
-
case 8:
|
|
3108
|
-
e_1_1 = _e.sent();
|
|
3109
|
-
e_1 = { error: e_1_1 };
|
|
3110
|
-
return [3 /*break*/, 10];
|
|
3111
|
-
case 9:
|
|
3112
|
-
try {
|
|
3113
|
-
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
3114
|
-
}
|
|
3115
|
-
finally { if (e_1) throw e_1.error; }
|
|
3116
|
-
return [7 /*endfinally*/];
|
|
3117
|
-
case 10: return [4 /*yield*/, r.renderTemplates(this.elseTemplates, ctx, emitter)];
|
|
3118
|
-
case 11:
|
|
3119
|
-
_e.sent();
|
|
3120
|
-
return [2 /*return*/];
|
|
3121
|
-
}
|
|
3122
|
-
});
|
|
3123
|
-
}
|
|
3124
|
-
};
|
|
3125
|
-
|
|
3126
|
-
var comment = {
|
|
3127
|
-
parse: function (tagToken, remainTokens) {
|
|
3128
|
-
var stream = this.liquid.parser.parseStream(remainTokens);
|
|
3129
|
-
stream
|
|
3130
|
-
.on('token', function (token) {
|
|
3131
|
-
if (token.name === 'endcomment')
|
|
3132
|
-
stream.stop();
|
|
3133
|
-
})
|
|
3134
|
-
.on('end', function () {
|
|
3135
|
-
throw new Error("tag ".concat(tagToken.getText(), " not closed"));
|
|
3136
|
-
});
|
|
3137
|
-
stream.start();
|
|
3138
|
-
}
|
|
3139
|
-
};
|
|
3140
|
-
|
|
3141
|
-
var BlockMode;
|
|
3142
|
-
(function (BlockMode) {
|
|
3143
|
-
/* store rendered html into blocks */
|
|
3144
|
-
BlockMode[BlockMode["OUTPUT"] = 0] = "OUTPUT";
|
|
3145
|
-
/* output rendered html directly */
|
|
3146
|
-
BlockMode[BlockMode["STORE"] = 1] = "STORE";
|
|
3147
|
-
})(BlockMode || (BlockMode = {}));
|
|
3148
|
-
var BlockMode$1 = BlockMode;
|
|
3149
|
-
|
|
3150
|
-
var render = {
|
|
3151
|
-
parseFilePath: parseFilePath,
|
|
3152
|
-
renderFilePath: renderFilePath,
|
|
3153
|
-
parse: function (token) {
|
|
3154
|
-
var args = token.args;
|
|
3155
|
-
var tokenizer = new Tokenizer(args, this.liquid.options.operatorsTrie);
|
|
3156
|
-
this['file'] = this.parseFilePath(tokenizer, this.liquid);
|
|
3157
|
-
this['currentFile'] = token.file;
|
|
3158
|
-
while (!tokenizer.end()) {
|
|
3159
|
-
tokenizer.skipBlank();
|
|
3160
|
-
var begin = tokenizer.p;
|
|
3161
|
-
var keyword = tokenizer.readIdentifier();
|
|
3162
|
-
if (keyword.content === 'with' || keyword.content === 'for') {
|
|
3163
|
-
tokenizer.skipBlank();
|
|
3164
|
-
// can be normal key/value pair, like "with: true"
|
|
3165
|
-
if (tokenizer.peek() !== ':') {
|
|
3166
|
-
var value = tokenizer.readValue();
|
|
3167
|
-
// can be normal key, like "with,"
|
|
3168
|
-
if (value) {
|
|
3169
|
-
var beforeAs = tokenizer.p;
|
|
3170
|
-
var asStr = tokenizer.readIdentifier();
|
|
3171
|
-
var alias = void 0;
|
|
3172
|
-
if (asStr.content === 'as')
|
|
3173
|
-
alias = tokenizer.readIdentifier();
|
|
3174
|
-
else
|
|
3175
|
-
tokenizer.p = beforeAs;
|
|
3176
|
-
this[keyword.content] = { value: value, alias: alias && alias.content };
|
|
3177
|
-
tokenizer.skipBlank();
|
|
3178
|
-
if (tokenizer.peek() === ',')
|
|
3179
|
-
tokenizer.advance();
|
|
3180
|
-
// matched!
|
|
3181
|
-
continue;
|
|
3182
|
-
}
|
|
3183
|
-
}
|
|
3184
|
-
}
|
|
3185
|
-
/**
|
|
3186
|
-
* restore cursor if with/for not matched
|
|
3187
|
-
*/
|
|
3188
|
-
tokenizer.p = begin;
|
|
3189
|
-
break;
|
|
3190
|
-
}
|
|
3191
|
-
this.hash = new Hash(tokenizer.remaining());
|
|
3192
|
-
},
|
|
3193
|
-
render: function (ctx, emitter) {
|
|
3194
|
-
var _a, liquid, hash, filepath, childCtx, scope, _b, _c, _d, value, alias, _e, _f, _g, value, alias, collection, collection_1, collection_1_1, item, templates, e_1_1, templates;
|
|
3195
|
-
var e_1, _h;
|
|
3196
|
-
return __generator(this, function (_j) {
|
|
3197
|
-
switch (_j.label) {
|
|
3198
|
-
case 0:
|
|
3199
|
-
_a = this, liquid = _a.liquid, hash = _a.hash;
|
|
3200
|
-
return [4 /*yield*/, this.renderFilePath(this['file'], ctx, liquid)];
|
|
3201
|
-
case 1:
|
|
3202
|
-
filepath = _j.sent();
|
|
3203
|
-
assert(filepath, function () { return "illegal filename \"".concat(filepath, "\""); });
|
|
3204
|
-
childCtx = new Context({}, ctx.opts, { sync: ctx.sync, globals: ctx.globals, strictVariables: ctx.strictVariables });
|
|
3205
|
-
scope = childCtx.bottom();
|
|
3206
|
-
_b = __assign;
|
|
3207
|
-
_c = [scope];
|
|
3208
|
-
return [4 /*yield*/, hash.render(ctx)];
|
|
3209
|
-
case 2:
|
|
3210
|
-
_b.apply(void 0, _c.concat([_j.sent()]));
|
|
3211
|
-
if (!this['with']) return [3 /*break*/, 4];
|
|
3212
|
-
_d = this['with'], value = _d.value, alias = _d.alias;
|
|
3213
|
-
_e = scope;
|
|
3214
|
-
_f = alias || filepath;
|
|
3215
|
-
return [4 /*yield*/, _evalToken(value, ctx)];
|
|
3216
|
-
case 3:
|
|
3217
|
-
_e[_f] = _j.sent();
|
|
3218
|
-
_j.label = 4;
|
|
3219
|
-
case 4:
|
|
3220
|
-
if (!this['for']) return [3 /*break*/, 15];
|
|
3221
|
-
_g = this['for'], value = _g.value, alias = _g.alias;
|
|
3222
|
-
return [4 /*yield*/, _evalToken(value, ctx)];
|
|
3223
|
-
case 5:
|
|
3224
|
-
collection = _j.sent();
|
|
3225
|
-
collection = toEnumerable(collection);
|
|
3226
|
-
scope['forloop'] = new ForloopDrop(collection.length, value.getText(), alias);
|
|
3227
|
-
_j.label = 6;
|
|
3228
|
-
case 6:
|
|
3229
|
-
_j.trys.push([6, 12, 13, 14]);
|
|
3230
|
-
collection_1 = __values(collection), collection_1_1 = collection_1.next();
|
|
3231
|
-
_j.label = 7;
|
|
3232
|
-
case 7:
|
|
3233
|
-
if (!!collection_1_1.done) return [3 /*break*/, 11];
|
|
3234
|
-
item = collection_1_1.value;
|
|
3235
|
-
scope[alias] = item;
|
|
3236
|
-
return [4 /*yield*/, liquid._parsePartialFile(filepath, childCtx.sync, this['currentFile'])];
|
|
3237
|
-
case 8:
|
|
3238
|
-
templates = _j.sent();
|
|
3239
|
-
return [4 /*yield*/, liquid.renderer.renderTemplates(templates, childCtx, emitter)];
|
|
3240
|
-
case 9:
|
|
3241
|
-
_j.sent();
|
|
3242
|
-
scope['forloop'].next();
|
|
3243
|
-
_j.label = 10;
|
|
3244
|
-
case 10:
|
|
3245
|
-
collection_1_1 = collection_1.next();
|
|
3246
|
-
return [3 /*break*/, 7];
|
|
3247
|
-
case 11: return [3 /*break*/, 14];
|
|
3248
|
-
case 12:
|
|
3249
|
-
e_1_1 = _j.sent();
|
|
3250
|
-
e_1 = { error: e_1_1 };
|
|
3251
|
-
return [3 /*break*/, 14];
|
|
3252
|
-
case 13:
|
|
3253
|
-
try {
|
|
3254
|
-
if (collection_1_1 && !collection_1_1.done && (_h = collection_1.return)) _h.call(collection_1);
|
|
3255
|
-
}
|
|
3256
|
-
finally { if (e_1) throw e_1.error; }
|
|
3257
|
-
return [7 /*endfinally*/];
|
|
3258
|
-
case 14: return [3 /*break*/, 18];
|
|
3259
|
-
case 15: return [4 /*yield*/, liquid._parsePartialFile(filepath, childCtx.sync, this['currentFile'])];
|
|
3260
|
-
case 16:
|
|
3261
|
-
templates = _j.sent();
|
|
3262
|
-
return [4 /*yield*/, liquid.renderer.renderTemplates(templates, childCtx, emitter)];
|
|
3263
|
-
case 17:
|
|
3264
|
-
_j.sent();
|
|
3265
|
-
_j.label = 18;
|
|
3266
|
-
case 18: return [2 /*return*/];
|
|
3267
|
-
}
|
|
3268
|
-
});
|
|
3269
|
-
}
|
|
3270
|
-
};
|
|
3271
|
-
/**
|
|
3272
|
-
* @return null for "none",
|
|
3273
|
-
* @return Template[] for quoted with tags and/or filters
|
|
3274
|
-
* @return Token for expression (not quoted)
|
|
3275
|
-
* @throws TypeError if cannot read next token
|
|
3276
|
-
*/
|
|
3277
|
-
function parseFilePath(tokenizer, liquid) {
|
|
3278
|
-
if (liquid.options.dynamicPartials) {
|
|
3279
|
-
var file = tokenizer.readValue();
|
|
3280
|
-
if (file === undefined)
|
|
3281
|
-
throw new TypeError("illegal argument \"".concat(tokenizer.input, "\""));
|
|
3282
|
-
if (file.getText() === 'none')
|
|
3283
|
-
return null;
|
|
3284
|
-
if (isQuotedToken(file)) {
|
|
3285
|
-
// for filenames like "files/{{file}}", eval as liquid template
|
|
3286
|
-
var templates_1 = liquid.parse(evalQuotedToken(file));
|
|
3287
|
-
return optimize(templates_1);
|
|
3288
|
-
}
|
|
3289
|
-
return file;
|
|
3290
|
-
}
|
|
3291
|
-
var tokens = __spreadArray([], __read(tokenizer.readFileNameTemplate(liquid.options)), false);
|
|
3292
|
-
var templates = optimize(liquid.parser.parseTokens(tokens));
|
|
3293
|
-
return templates === 'none' ? null : templates;
|
|
3294
|
-
}
|
|
3295
|
-
function optimize(templates) {
|
|
3296
|
-
// for filenames like "files/file.liquid", extract the string directly
|
|
3297
|
-
if (templates.length === 1 && isHTMLToken(templates[0].token))
|
|
3298
|
-
return templates[0].token.getContent();
|
|
3299
|
-
return templates;
|
|
3300
|
-
}
|
|
3301
|
-
function renderFilePath(file, ctx, liquid) {
|
|
3302
|
-
return __generator(this, function (_a) {
|
|
3303
|
-
switch (_a.label) {
|
|
3304
|
-
case 0:
|
|
3305
|
-
if (typeof file === 'string')
|
|
3306
|
-
return [2 /*return*/, file];
|
|
3307
|
-
if (Array.isArray(file))
|
|
3308
|
-
return [2 /*return*/, liquid.renderer.renderTemplates(file, ctx)];
|
|
3309
|
-
return [4 /*yield*/, _evalToken(file, ctx)];
|
|
3310
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
3311
|
-
}
|
|
3312
|
-
});
|
|
3313
|
-
}
|
|
3314
|
-
|
|
3315
|
-
var include = {
|
|
3316
|
-
parseFilePath: parseFilePath,
|
|
3317
|
-
renderFilePath: renderFilePath,
|
|
3318
|
-
parse: function (token) {
|
|
3319
|
-
var args = token.args;
|
|
3320
|
-
var tokenizer = new Tokenizer(args, this.liquid.options.operatorsTrie);
|
|
3321
|
-
this['file'] = this.parseFilePath(tokenizer, this.liquid);
|
|
3322
|
-
this['currentFile'] = token.file;
|
|
3323
|
-
var begin = tokenizer.p;
|
|
3324
|
-
var withStr = tokenizer.readIdentifier();
|
|
3325
|
-
if (withStr.content === 'with') {
|
|
3326
|
-
tokenizer.skipBlank();
|
|
3327
|
-
if (tokenizer.peek() !== ':') {
|
|
3328
|
-
this.withVar = tokenizer.readValue();
|
|
3329
|
-
}
|
|
3330
|
-
else
|
|
3331
|
-
tokenizer.p = begin;
|
|
3332
|
-
}
|
|
3333
|
-
else
|
|
3334
|
-
tokenizer.p = begin;
|
|
3335
|
-
this.hash = new Hash(tokenizer.remaining(), this.liquid.options.jekyllInclude);
|
|
3336
|
-
},
|
|
3337
|
-
render: function (ctx, emitter) {
|
|
3338
|
-
var _a, liquid, hash, withVar, renderer, filepath, saved, scope, _b, _c, templates;
|
|
3339
|
-
return __generator(this, function (_d) {
|
|
3340
|
-
switch (_d.label) {
|
|
3341
|
-
case 0:
|
|
3342
|
-
_a = this, liquid = _a.liquid, hash = _a.hash, withVar = _a.withVar;
|
|
3343
|
-
renderer = liquid.renderer;
|
|
3344
|
-
return [4 /*yield*/, this.renderFilePath(this['file'], ctx, liquid)];
|
|
3345
|
-
case 1:
|
|
3346
|
-
filepath = _d.sent();
|
|
3347
|
-
assert(filepath, function () { return "illegal filename \"".concat(filepath, "\""); });
|
|
3348
|
-
saved = ctx.saveRegister('blocks', 'blockMode');
|
|
3349
|
-
ctx.setRegister('blocks', {});
|
|
3350
|
-
ctx.setRegister('blockMode', BlockMode$1.OUTPUT);
|
|
3351
|
-
return [4 /*yield*/, hash.render(ctx)];
|
|
3352
|
-
case 2:
|
|
3353
|
-
scope = _d.sent();
|
|
3354
|
-
if (!withVar) return [3 /*break*/, 4];
|
|
3355
|
-
_b = scope;
|
|
3356
|
-
_c = filepath;
|
|
3357
|
-
return [4 /*yield*/, _evalToken(withVar, ctx)];
|
|
3358
|
-
case 3:
|
|
3359
|
-
_b[_c] = _d.sent();
|
|
3360
|
-
_d.label = 4;
|
|
3361
|
-
case 4: return [4 /*yield*/, liquid._parsePartialFile(filepath, ctx.sync, this['currentFile'])];
|
|
3362
|
-
case 5:
|
|
3363
|
-
templates = _d.sent();
|
|
3364
|
-
ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
|
|
3365
|
-
return [4 /*yield*/, renderer.renderTemplates(templates, ctx, emitter)];
|
|
3366
|
-
case 6:
|
|
3367
|
-
_d.sent();
|
|
3368
|
-
ctx.pop();
|
|
3369
|
-
ctx.restoreRegister(saved);
|
|
3370
|
-
return [2 /*return*/];
|
|
3371
|
-
}
|
|
3372
|
-
});
|
|
3373
|
-
}
|
|
3374
|
-
};
|
|
3375
|
-
|
|
3376
|
-
var decrement = {
|
|
3377
|
-
parse: function (token) {
|
|
3378
|
-
var tokenizer = new Tokenizer(token.args, this.liquid.options.operatorsTrie);
|
|
3379
|
-
this.variable = tokenizer.readIdentifier().content;
|
|
3380
|
-
},
|
|
3381
|
-
render: function (context, emitter) {
|
|
3382
|
-
var scope = context.environments;
|
|
3383
|
-
if (!isNumber(scope[this.variable])) {
|
|
3384
|
-
scope[this.variable] = 0;
|
|
3385
|
-
}
|
|
3386
|
-
emitter.write(stringify(--scope[this.variable]));
|
|
3387
|
-
}
|
|
3388
|
-
};
|
|
3389
|
-
|
|
3390
|
-
var cycle = {
|
|
3391
|
-
parse: function (tagToken) {
|
|
3392
|
-
var tokenizer = new Tokenizer(tagToken.args, this.liquid.options.operatorsTrie);
|
|
3393
|
-
var group = tokenizer.readValue();
|
|
3394
|
-
tokenizer.skipBlank();
|
|
3395
|
-
this.candidates = [];
|
|
3396
|
-
if (group) {
|
|
3397
|
-
if (tokenizer.peek() === ':') {
|
|
3398
|
-
this.group = group;
|
|
3399
|
-
tokenizer.advance();
|
|
3400
|
-
}
|
|
3401
|
-
else
|
|
3402
|
-
this.candidates.push(group);
|
|
3403
|
-
}
|
|
3404
|
-
while (!tokenizer.end()) {
|
|
3405
|
-
var value = tokenizer.readValue();
|
|
3406
|
-
if (value)
|
|
3407
|
-
this.candidates.push(value);
|
|
3408
|
-
tokenizer.readTo(',');
|
|
3409
|
-
}
|
|
3410
|
-
assert(this.candidates.length, function () { return "empty candidates: ".concat(tagToken.getText()); });
|
|
3411
|
-
},
|
|
3412
|
-
render: function (ctx, emitter) {
|
|
3413
|
-
var group, fingerprint, groups, idx, candidate, html;
|
|
3414
|
-
return __generator(this, function (_a) {
|
|
3415
|
-
switch (_a.label) {
|
|
3416
|
-
case 0: return [4 /*yield*/, _evalToken(this.group, ctx)];
|
|
3417
|
-
case 1:
|
|
3418
|
-
group = _a.sent();
|
|
3419
|
-
fingerprint = "cycle:".concat(group, ":") + this.candidates.join(',');
|
|
3420
|
-
groups = ctx.getRegister('cycle');
|
|
3421
|
-
idx = groups[fingerprint];
|
|
3422
|
-
if (idx === undefined) {
|
|
3423
|
-
idx = groups[fingerprint] = 0;
|
|
3424
|
-
}
|
|
3425
|
-
candidate = this.candidates[idx];
|
|
3426
|
-
idx = (idx + 1) % this.candidates.length;
|
|
3427
|
-
groups[fingerprint] = idx;
|
|
3428
|
-
return [4 /*yield*/, _evalToken(candidate, ctx)];
|
|
3429
|
-
case 2:
|
|
3430
|
-
html = _a.sent();
|
|
3431
|
-
emitter.write(html);
|
|
3432
|
-
return [2 /*return*/];
|
|
3433
|
-
}
|
|
3434
|
-
});
|
|
3435
|
-
}
|
|
3436
|
-
};
|
|
3437
|
-
|
|
3438
|
-
var If = {
|
|
3439
|
-
parse: function (tagToken, remainTokens) {
|
|
3440
|
-
var _this = this;
|
|
3441
|
-
this.branches = [];
|
|
3442
|
-
this.elseTemplates = [];
|
|
3443
|
-
var p;
|
|
3444
|
-
this.liquid.parser.parseStream(remainTokens)
|
|
3445
|
-
.on('start', function () { return _this.branches.push({
|
|
3446
|
-
predicate: new Value(tagToken.args, _this.liquid),
|
|
3447
|
-
templates: (p = [])
|
|
3448
|
-
}); })
|
|
3449
|
-
.on('tag:elsif', function (token) { return _this.branches.push({
|
|
3450
|
-
predicate: new Value(token.args, _this.liquid),
|
|
3451
|
-
templates: (p = [])
|
|
3452
|
-
}); })
|
|
3453
|
-
.on('tag:else', function () { return (p = _this.elseTemplates); })
|
|
3454
|
-
.on('tag:endif', function () { this.stop(); })
|
|
3455
|
-
.on('template', function (tpl) { return p.push(tpl); })
|
|
3456
|
-
.on('end', function () { throw new Error("tag ".concat(tagToken.getText(), " not closed")); })
|
|
3457
|
-
.start();
|
|
3458
|
-
},
|
|
3459
|
-
render: function (ctx, emitter) {
|
|
3460
|
-
var r, _a, _b, _c, predicate, templates, value, e_1_1;
|
|
3461
|
-
var e_1, _d;
|
|
3462
|
-
return __generator(this, function (_e) {
|
|
3463
|
-
switch (_e.label) {
|
|
3464
|
-
case 0:
|
|
3465
|
-
r = this.liquid.renderer;
|
|
3466
|
-
_e.label = 1;
|
|
3467
|
-
case 1:
|
|
3468
|
-
_e.trys.push([1, 7, 8, 9]);
|
|
3469
|
-
_a = __values(this.branches), _b = _a.next();
|
|
3470
|
-
_e.label = 2;
|
|
3471
|
-
case 2:
|
|
3472
|
-
if (!!_b.done) return [3 /*break*/, 6];
|
|
3473
|
-
_c = _b.value, predicate = _c.predicate, templates = _c.templates;
|
|
3474
|
-
return [4 /*yield*/, predicate.value(ctx, ctx.opts.lenientIf)];
|
|
3475
|
-
case 3:
|
|
3476
|
-
value = _e.sent();
|
|
3477
|
-
if (!isTruthy(value, ctx)) return [3 /*break*/, 5];
|
|
3478
|
-
return [4 /*yield*/, r.renderTemplates(templates, ctx, emitter)];
|
|
3479
|
-
case 4:
|
|
3480
|
-
_e.sent();
|
|
3481
|
-
return [2 /*return*/];
|
|
3482
|
-
case 5:
|
|
3483
|
-
_b = _a.next();
|
|
3484
|
-
return [3 /*break*/, 2];
|
|
3485
|
-
case 6: return [3 /*break*/, 9];
|
|
3486
|
-
case 7:
|
|
3487
|
-
e_1_1 = _e.sent();
|
|
3488
|
-
e_1 = { error: e_1_1 };
|
|
3489
|
-
return [3 /*break*/, 9];
|
|
3490
|
-
case 8:
|
|
3491
|
-
try {
|
|
3492
|
-
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
3493
|
-
}
|
|
3494
|
-
finally { if (e_1) throw e_1.error; }
|
|
3495
|
-
return [7 /*endfinally*/];
|
|
3496
|
-
case 9: return [4 /*yield*/, r.renderTemplates(this.elseTemplates, ctx, emitter)];
|
|
3497
|
-
case 10:
|
|
3498
|
-
_e.sent();
|
|
3499
|
-
return [2 /*return*/];
|
|
3500
|
-
}
|
|
3501
|
-
});
|
|
3502
|
-
}
|
|
3503
|
-
};
|
|
3504
|
-
|
|
3505
|
-
var increment = {
|
|
3506
|
-
parse: function (token) {
|
|
3507
|
-
var tokenizer = new Tokenizer(token.args, this.liquid.options.operatorsTrie);
|
|
3508
|
-
this.variable = tokenizer.readIdentifier().content;
|
|
3509
|
-
},
|
|
3510
|
-
render: function (context, emitter) {
|
|
3511
|
-
var scope = context.environments;
|
|
3512
|
-
if (!isNumber(scope[this.variable])) {
|
|
3513
|
-
scope[this.variable] = 0;
|
|
3514
|
-
}
|
|
3515
|
-
var val = scope[this.variable];
|
|
3516
|
-
scope[this.variable]++;
|
|
3517
|
-
emitter.write(stringify(val));
|
|
3518
|
-
}
|
|
3519
|
-
};
|
|
3520
|
-
|
|
3521
|
-
var layout = {
|
|
3522
|
-
parseFilePath: parseFilePath,
|
|
3523
|
-
renderFilePath: renderFilePath,
|
|
3524
|
-
parse: function (token, remainTokens) {
|
|
3525
|
-
var tokenizer = new Tokenizer(token.args, this.liquid.options.operatorsTrie);
|
|
3526
|
-
this['file'] = this.parseFilePath(tokenizer, this.liquid);
|
|
3527
|
-
this['currentFile'] = token.file;
|
|
3528
|
-
this.hash = new Hash(tokenizer.remaining());
|
|
3529
|
-
this.tpls = this.liquid.parser.parseTokens(remainTokens);
|
|
3530
|
-
},
|
|
3531
|
-
render: function (ctx, emitter) {
|
|
3532
|
-
var _a, liquid, hash, file, renderer, filepath, templates, html, blocks, _b, _c;
|
|
3533
|
-
return __generator(this, function (_d) {
|
|
3534
|
-
switch (_d.label) {
|
|
3535
|
-
case 0:
|
|
3536
|
-
_a = this, liquid = _a.liquid, hash = _a.hash, file = _a.file;
|
|
3537
|
-
renderer = liquid.renderer;
|
|
3538
|
-
if (!(file === null)) return [3 /*break*/, 2];
|
|
3539
|
-
ctx.setRegister('blockMode', BlockMode$1.OUTPUT);
|
|
3540
|
-
return [4 /*yield*/, renderer.renderTemplates(this.tpls, ctx, emitter)];
|
|
3541
|
-
case 1:
|
|
3542
|
-
_d.sent();
|
|
3543
|
-
return [2 /*return*/];
|
|
3544
|
-
case 2: return [4 /*yield*/, this.renderFilePath(this['file'], ctx, liquid)];
|
|
3545
|
-
case 3:
|
|
3546
|
-
filepath = _d.sent();
|
|
3547
|
-
assert(filepath, function () { return "illegal filename \"".concat(filepath, "\""); });
|
|
3548
|
-
return [4 /*yield*/, liquid._parseLayoutFile(filepath, ctx.sync, this['currentFile'])
|
|
3549
|
-
// render remaining contents and store rendered results
|
|
3550
|
-
];
|
|
3551
|
-
case 4:
|
|
3552
|
-
templates = _d.sent();
|
|
3553
|
-
// render remaining contents and store rendered results
|
|
3554
|
-
ctx.setRegister('blockMode', BlockMode$1.STORE);
|
|
3555
|
-
return [4 /*yield*/, renderer.renderTemplates(this.tpls, ctx)];
|
|
3556
|
-
case 5:
|
|
3557
|
-
html = _d.sent();
|
|
3558
|
-
blocks = ctx.getRegister('blocks');
|
|
3559
|
-
// set whole content to anonymous block if anonymous doesn't specified
|
|
3560
|
-
if (blocks[''] === undefined)
|
|
3561
|
-
blocks[''] = function (parent, emitter) { return emitter.write(html); };
|
|
3562
|
-
ctx.setRegister('blockMode', BlockMode$1.OUTPUT);
|
|
3563
|
-
// render the layout file use stored blocks
|
|
3564
|
-
_c = (_b = ctx).push;
|
|
3565
|
-
return [4 /*yield*/, hash.render(ctx)];
|
|
3566
|
-
case 6:
|
|
3567
|
-
// render the layout file use stored blocks
|
|
3568
|
-
_c.apply(_b, [_d.sent()]);
|
|
3569
|
-
return [4 /*yield*/, renderer.renderTemplates(templates, ctx, emitter)];
|
|
3570
|
-
case 7:
|
|
3571
|
-
_d.sent();
|
|
3572
|
-
ctx.pop();
|
|
3573
|
-
return [2 /*return*/];
|
|
3574
|
-
}
|
|
3575
|
-
});
|
|
3576
|
-
}
|
|
3577
|
-
};
|
|
3578
|
-
|
|
3579
|
-
var BlockDrop = /** @class */ (function (_super) {
|
|
3580
|
-
__extends(BlockDrop, _super);
|
|
3581
|
-
function BlockDrop(
|
|
3582
|
-
// the block render from layout template
|
|
3583
|
-
superBlockRender) {
|
|
3584
|
-
if (superBlockRender === void 0) { superBlockRender = function () { return ''; }; }
|
|
3585
|
-
var _this = _super.call(this) || this;
|
|
3586
|
-
_this.superBlockRender = superBlockRender;
|
|
3587
|
-
return _this;
|
|
3588
|
-
}
|
|
3589
|
-
/**
|
|
3590
|
-
* Provide parent access in child block by
|
|
3591
|
-
* {{ block.super }}
|
|
3592
|
-
*/
|
|
3593
|
-
BlockDrop.prototype.super = function () {
|
|
3594
|
-
return this.superBlockRender();
|
|
3595
|
-
};
|
|
3596
|
-
return BlockDrop;
|
|
3597
|
-
}(Drop));
|
|
3598
|
-
|
|
3599
|
-
var block = {
|
|
3600
|
-
parse: function (token, remainTokens) {
|
|
3601
|
-
var _this = this;
|
|
3602
|
-
var match = /\w+/.exec(token.args);
|
|
3603
|
-
this.block = match ? match[0] : '';
|
|
3604
|
-
this.tpls = [];
|
|
3605
|
-
this.liquid.parser.parseStream(remainTokens)
|
|
3606
|
-
.on('tag:endblock', function () { this.stop(); })
|
|
3607
|
-
.on('template', function (tpl) { return _this.tpls.push(tpl); })
|
|
3608
|
-
.on('end', function () { throw new Error("tag ".concat(token.getText(), " not closed")); })
|
|
3609
|
-
.start();
|
|
3610
|
-
},
|
|
3611
|
-
render: function (ctx, emitter) {
|
|
3612
|
-
var blockRender;
|
|
3613
|
-
return __generator(this, function (_a) {
|
|
3614
|
-
switch (_a.label) {
|
|
3615
|
-
case 0:
|
|
3616
|
-
blockRender = this.getBlockRender(ctx);
|
|
3617
|
-
if (!(ctx.getRegister('blockMode') === BlockMode$1.STORE)) return [3 /*break*/, 1];
|
|
3618
|
-
ctx.getRegister('blocks')[this.block] = blockRender;
|
|
3619
|
-
return [3 /*break*/, 3];
|
|
3620
|
-
case 1: return [4 /*yield*/, blockRender(new BlockDrop(), emitter)];
|
|
3621
|
-
case 2:
|
|
3622
|
-
_a.sent();
|
|
3623
|
-
_a.label = 3;
|
|
3624
|
-
case 3: return [2 /*return*/];
|
|
3625
|
-
}
|
|
3626
|
-
});
|
|
3627
|
-
},
|
|
3628
|
-
getBlockRender: function (ctx) {
|
|
3629
|
-
var _a = this, liquid = _a.liquid, tpls = _a.tpls;
|
|
3630
|
-
var renderChild = ctx.getRegister('blocks')[this.block];
|
|
3631
|
-
var renderCurrent = function (superBlock, emitter) {
|
|
3632
|
-
return __generator(this, function (_a) {
|
|
3633
|
-
switch (_a.label) {
|
|
3634
|
-
case 0:
|
|
3635
|
-
// add {{ block.super }} support when rendering
|
|
3636
|
-
ctx.push({ block: superBlock });
|
|
3637
|
-
return [4 /*yield*/, liquid.renderer.renderTemplates(tpls, ctx, emitter)];
|
|
3638
|
-
case 1:
|
|
3639
|
-
_a.sent();
|
|
3640
|
-
ctx.pop();
|
|
3641
|
-
return [2 /*return*/];
|
|
3642
|
-
}
|
|
3643
|
-
});
|
|
3644
|
-
};
|
|
3645
|
-
return renderChild
|
|
3646
|
-
? function (superBlock, emitter) { return renderChild(new BlockDrop(function () { return renderCurrent(superBlock, emitter); }), emitter); }
|
|
3647
|
-
: renderCurrent;
|
|
3648
|
-
}
|
|
3649
|
-
};
|
|
3650
|
-
|
|
3651
|
-
var raw = {
|
|
3652
|
-
parse: function (tagToken, remainTokens) {
|
|
3653
|
-
var _this = this;
|
|
3654
|
-
this.tokens = [];
|
|
3655
|
-
var stream = this.liquid.parser.parseStream(remainTokens);
|
|
3656
|
-
stream
|
|
3657
|
-
.on('token', function (token) {
|
|
3658
|
-
if (token.name === 'endraw')
|
|
3659
|
-
stream.stop();
|
|
3660
|
-
else
|
|
3661
|
-
_this.tokens.push(token);
|
|
3662
|
-
})
|
|
3663
|
-
.on('end', function () {
|
|
3664
|
-
throw new Error("tag ".concat(tagToken.getText(), " not closed"));
|
|
3665
|
-
});
|
|
3666
|
-
stream.start();
|
|
3667
|
-
},
|
|
3668
|
-
render: function () {
|
|
3669
|
-
return this.tokens.map(function (token) { return token.getText(); }).join('');
|
|
3670
|
-
}
|
|
3671
|
-
};
|
|
3672
|
-
|
|
3673
|
-
var TablerowloopDrop = /** @class */ (function (_super) {
|
|
3674
|
-
__extends(TablerowloopDrop, _super);
|
|
3675
|
-
function TablerowloopDrop(length, cols, collection, variable) {
|
|
3676
|
-
var _this = _super.call(this, length, collection, variable) || this;
|
|
3677
|
-
_this.length = length;
|
|
3678
|
-
_this.cols = cols;
|
|
3679
|
-
return _this;
|
|
3680
|
-
}
|
|
3681
|
-
TablerowloopDrop.prototype.row = function () {
|
|
3682
|
-
return Math.floor(this.i / this.cols) + 1;
|
|
3683
|
-
};
|
|
3684
|
-
TablerowloopDrop.prototype.col0 = function () {
|
|
3685
|
-
return (this.i % this.cols);
|
|
3686
|
-
};
|
|
3687
|
-
TablerowloopDrop.prototype.col = function () {
|
|
3688
|
-
return this.col0() + 1;
|
|
3689
|
-
};
|
|
3690
|
-
TablerowloopDrop.prototype.col_first = function () {
|
|
3691
|
-
return this.col0() === 0;
|
|
3692
|
-
};
|
|
3693
|
-
TablerowloopDrop.prototype.col_last = function () {
|
|
3694
|
-
return this.col() === this.cols;
|
|
3695
|
-
};
|
|
3696
|
-
return TablerowloopDrop;
|
|
3697
|
-
}(ForloopDrop));
|
|
3698
|
-
|
|
3699
|
-
var tablerow = {
|
|
3700
|
-
parse: function (tagToken, remainTokens) {
|
|
3701
|
-
var _this = this;
|
|
3702
|
-
var tokenizer = new Tokenizer(tagToken.args, this.liquid.options.operatorsTrie);
|
|
3703
|
-
var variable = tokenizer.readIdentifier();
|
|
3704
|
-
tokenizer.skipBlank();
|
|
3705
|
-
var tmp = tokenizer.readIdentifier();
|
|
3706
|
-
assert(tmp && tmp.content === 'in', function () { return "illegal tag: ".concat(tagToken.getText()); });
|
|
3707
|
-
this.variable = variable.content;
|
|
3708
|
-
this.collection = tokenizer.readValue();
|
|
3709
|
-
this.hash = new Hash(tokenizer.remaining());
|
|
3710
|
-
this.templates = [];
|
|
3711
|
-
var p;
|
|
3712
|
-
var stream = this.liquid.parser.parseStream(remainTokens)
|
|
3713
|
-
.on('start', function () { return (p = _this.templates); })
|
|
3714
|
-
.on('tag:endtablerow', function () { return stream.stop(); })
|
|
3715
|
-
.on('template', function (tpl) { return p.push(tpl); })
|
|
3716
|
-
.on('end', function () {
|
|
3717
|
-
throw new Error("tag ".concat(tagToken.getText(), " not closed"));
|
|
3718
|
-
});
|
|
3719
|
-
stream.start();
|
|
3720
|
-
},
|
|
3721
|
-
render: function (ctx, emitter) {
|
|
3722
|
-
var collection, _a, hash, offset, limit, cols, r, tablerowloop, scope, idx;
|
|
3723
|
-
return __generator(this, function (_b) {
|
|
3724
|
-
switch (_b.label) {
|
|
3725
|
-
case 0:
|
|
3726
|
-
_a = toEnumerable;
|
|
3727
|
-
return [4 /*yield*/, _evalToken(this.collection, ctx)];
|
|
3728
|
-
case 1:
|
|
3729
|
-
collection = _a.apply(void 0, [_b.sent()]);
|
|
3730
|
-
return [4 /*yield*/, this.hash.render(ctx)];
|
|
3731
|
-
case 2:
|
|
3732
|
-
hash = _b.sent();
|
|
3733
|
-
offset = hash.offset || 0;
|
|
3734
|
-
limit = (hash.limit === undefined) ? collection.length : hash.limit;
|
|
3735
|
-
collection = collection.slice(offset, offset + limit);
|
|
3736
|
-
cols = hash.cols || collection.length;
|
|
3737
|
-
r = this.liquid.renderer;
|
|
3738
|
-
tablerowloop = new TablerowloopDrop(collection.length, cols, this.collection.getText(), this.variable);
|
|
3739
|
-
scope = { tablerowloop: tablerowloop };
|
|
3740
|
-
ctx.push(scope);
|
|
3741
|
-
idx = 0;
|
|
3742
|
-
_b.label = 3;
|
|
3743
|
-
case 3:
|
|
3744
|
-
if (!(idx < collection.length)) return [3 /*break*/, 6];
|
|
3745
|
-
scope[this.variable] = collection[idx];
|
|
3746
|
-
if (tablerowloop.col0() === 0) {
|
|
3747
|
-
if (tablerowloop.row() !== 1)
|
|
3748
|
-
emitter.write('</tr>');
|
|
3749
|
-
emitter.write("<tr class=\"row".concat(tablerowloop.row(), "\">"));
|
|
3750
|
-
}
|
|
3751
|
-
emitter.write("<td class=\"col".concat(tablerowloop.col(), "\">"));
|
|
3752
|
-
return [4 /*yield*/, r.renderTemplates(this.templates, ctx, emitter)];
|
|
3753
|
-
case 4:
|
|
3754
|
-
_b.sent();
|
|
3755
|
-
emitter.write('</td>');
|
|
3756
|
-
_b.label = 5;
|
|
3757
|
-
case 5:
|
|
3758
|
-
idx++, tablerowloop.next();
|
|
3759
|
-
return [3 /*break*/, 3];
|
|
3760
|
-
case 6:
|
|
3761
|
-
if (collection.length)
|
|
3762
|
-
emitter.write('</tr>');
|
|
3763
|
-
ctx.pop();
|
|
3764
|
-
return [2 /*return*/];
|
|
3765
|
-
}
|
|
3766
|
-
});
|
|
3767
|
-
}
|
|
3768
|
-
};
|
|
3769
|
-
|
|
3770
|
-
var unless = {
|
|
3771
|
-
parse: function (tagToken, remainTokens) {
|
|
3772
|
-
var _this = this;
|
|
3773
|
-
this.branches = [];
|
|
3774
|
-
this.elseTemplates = [];
|
|
3775
|
-
var p;
|
|
3776
|
-
this.liquid.parser.parseStream(remainTokens)
|
|
3777
|
-
.on('start', function () { return _this.branches.push({
|
|
3778
|
-
predicate: new Value(tagToken.args, _this.liquid),
|
|
3779
|
-
test: isFalsy,
|
|
3780
|
-
templates: (p = [])
|
|
3781
|
-
}); })
|
|
3782
|
-
.on('tag:elsif', function (token) { return _this.branches.push({
|
|
3783
|
-
predicate: new Value(token.args, _this.liquid),
|
|
3784
|
-
test: isTruthy,
|
|
3785
|
-
templates: (p = [])
|
|
3786
|
-
}); })
|
|
3787
|
-
.on('tag:else', function () { return (p = _this.elseTemplates); })
|
|
3788
|
-
.on('tag:endunless', function () { this.stop(); })
|
|
3789
|
-
.on('template', function (tpl) { return p.push(tpl); })
|
|
3790
|
-
.on('end', function () { throw new Error("tag ".concat(tagToken.getText(), " not closed")); })
|
|
3791
|
-
.start();
|
|
3792
|
-
},
|
|
3793
|
-
render: function (ctx, emitter) {
|
|
3794
|
-
var r, _a, _b, _c, predicate, test_1, templates, value, e_1_1;
|
|
3795
|
-
var e_1, _d;
|
|
3796
|
-
return __generator(this, function (_e) {
|
|
3797
|
-
switch (_e.label) {
|
|
3798
|
-
case 0:
|
|
3799
|
-
r = this.liquid.renderer;
|
|
3800
|
-
_e.label = 1;
|
|
3801
|
-
case 1:
|
|
3802
|
-
_e.trys.push([1, 7, 8, 9]);
|
|
3803
|
-
_a = __values(this.branches), _b = _a.next();
|
|
3804
|
-
_e.label = 2;
|
|
3805
|
-
case 2:
|
|
3806
|
-
if (!!_b.done) return [3 /*break*/, 6];
|
|
3807
|
-
_c = _b.value, predicate = _c.predicate, test_1 = _c.test, templates = _c.templates;
|
|
3808
|
-
return [4 /*yield*/, predicate.value(ctx, ctx.opts.lenientIf)];
|
|
3809
|
-
case 3:
|
|
3810
|
-
value = _e.sent();
|
|
3811
|
-
if (!test_1(value, ctx)) return [3 /*break*/, 5];
|
|
3812
|
-
return [4 /*yield*/, r.renderTemplates(templates, ctx, emitter)];
|
|
3813
|
-
case 4:
|
|
3814
|
-
_e.sent();
|
|
3815
|
-
return [2 /*return*/];
|
|
3816
|
-
case 5:
|
|
3817
|
-
_b = _a.next();
|
|
3818
|
-
return [3 /*break*/, 2];
|
|
3819
|
-
case 6: return [3 /*break*/, 9];
|
|
3820
|
-
case 7:
|
|
3821
|
-
e_1_1 = _e.sent();
|
|
3822
|
-
e_1 = { error: e_1_1 };
|
|
3823
|
-
return [3 /*break*/, 9];
|
|
3824
|
-
case 8:
|
|
3825
|
-
try {
|
|
3826
|
-
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
3827
|
-
}
|
|
3828
|
-
finally { if (e_1) throw e_1.error; }
|
|
3829
|
-
return [7 /*endfinally*/];
|
|
3830
|
-
case 9: return [4 /*yield*/, r.renderTemplates(this.elseTemplates, ctx, emitter)];
|
|
3831
|
-
case 10:
|
|
3832
|
-
_e.sent();
|
|
3833
|
-
return [2 /*return*/];
|
|
3834
|
-
}
|
|
3835
|
-
});
|
|
3836
|
-
}
|
|
3837
|
-
};
|
|
3838
|
-
|
|
3839
|
-
var Break = {
|
|
3840
|
-
render: function (ctx, emitter) {
|
|
3841
|
-
emitter['break'] = true;
|
|
3842
|
-
}
|
|
3843
|
-
};
|
|
3844
|
-
|
|
3845
|
-
var Continue = {
|
|
3846
|
-
render: function (ctx, emitter) {
|
|
3847
|
-
emitter['continue'] = true;
|
|
3848
|
-
}
|
|
3849
|
-
};
|
|
3850
|
-
|
|
3851
|
-
var echo = {
|
|
3852
|
-
parse: function (token) {
|
|
3853
|
-
this.value = new Value(token.args, this.liquid);
|
|
3854
|
-
},
|
|
3855
|
-
render: function (ctx, emitter) {
|
|
3856
|
-
var val;
|
|
3857
|
-
return __generator(this, function (_a) {
|
|
3858
|
-
switch (_a.label) {
|
|
3859
|
-
case 0: return [4 /*yield*/, this.value.value(ctx, false)];
|
|
3860
|
-
case 1:
|
|
3861
|
-
val = _a.sent();
|
|
3862
|
-
emitter.write(val);
|
|
3863
|
-
return [2 /*return*/];
|
|
3864
|
-
}
|
|
3865
|
-
});
|
|
3866
|
-
}
|
|
3867
|
-
};
|
|
3868
|
-
|
|
3869
|
-
var liquid = {
|
|
3870
|
-
parse: function (token) {
|
|
3871
|
-
var tokenizer = new Tokenizer(token.args, this.liquid.options.operatorsTrie);
|
|
3872
|
-
var tokens = tokenizer.readLiquidTagTokens(this.liquid.options);
|
|
3873
|
-
this.tpls = this.liquid.parser.parseTokens(tokens);
|
|
3874
|
-
},
|
|
3875
|
-
render: function (ctx, emitter) {
|
|
3876
|
-
return __generator(this, function (_a) {
|
|
3877
|
-
switch (_a.label) {
|
|
3878
|
-
case 0: return [4 /*yield*/, this.liquid.renderer.renderTemplates(this.tpls, ctx, emitter)];
|
|
3879
|
-
case 1:
|
|
3880
|
-
_a.sent();
|
|
3881
|
-
return [2 /*return*/];
|
|
3882
|
-
}
|
|
3883
|
-
});
|
|
3884
|
-
}
|
|
3885
|
-
};
|
|
3886
|
-
|
|
3887
|
-
var inlineComment = {
|
|
3888
|
-
parse: function (tagToken, remainTokens) {
|
|
3889
|
-
if (tagToken.args.search(/\n\s*[^#\s]/g) !== -1) {
|
|
3890
|
-
throw new Error('every line of an inline comment must start with a \'#\' character');
|
|
3891
|
-
}
|
|
3892
|
-
}
|
|
3893
|
-
};
|
|
3894
|
-
|
|
3895
|
-
var tags = {
|
|
3896
|
-
assign: assign,
|
|
3897
|
-
'for': For,
|
|
3898
|
-
capture: capture,
|
|
3899
|
-
'case': Case,
|
|
3900
|
-
comment: comment,
|
|
3901
|
-
include: include,
|
|
3902
|
-
render: render,
|
|
3903
|
-
decrement: decrement,
|
|
3904
|
-
increment: increment,
|
|
3905
|
-
cycle: cycle,
|
|
3906
|
-
'if': If,
|
|
3907
|
-
layout: layout,
|
|
3908
|
-
block: block,
|
|
3909
|
-
raw: raw,
|
|
3910
|
-
tablerow: tablerow,
|
|
3911
|
-
unless: unless,
|
|
3912
|
-
'break': Break, 'continue': Continue,
|
|
3913
|
-
echo: echo,
|
|
3914
|
-
liquid: liquid,
|
|
3915
|
-
'#': inlineComment
|
|
3916
|
-
};
|
|
3917
|
-
|
|
3918
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
3919
|
-
__proto__: null,
|
|
3920
|
-
'default': tags
|
|
3921
|
-
});
|
|
3922
|
-
|
|
3923
|
-
var filters = new Map();
|
|
3924
|
-
forOwn(builtinFilters, function (conf, name) {
|
|
3925
|
-
filters.set(snakeCase(name), conf);
|
|
3926
|
-
});
|
|
3927
|
-
var defaultOptions = {
|
|
3928
|
-
root: ['.'],
|
|
3929
|
-
layouts: ['.'],
|
|
3930
|
-
partials: ['.'],
|
|
3931
|
-
relativeReference: true,
|
|
3932
|
-
jekyllInclude: false,
|
|
3933
|
-
cache: undefined,
|
|
3934
|
-
extname: '',
|
|
3935
|
-
fs: fs,
|
|
3936
|
-
dynamicPartials: true,
|
|
3937
|
-
jsTruthy: false,
|
|
3938
|
-
trimTagRight: false,
|
|
3939
|
-
trimTagLeft: false,
|
|
3940
|
-
trimOutputRight: false,
|
|
3941
|
-
trimOutputLeft: false,
|
|
3942
|
-
greedy: true,
|
|
3943
|
-
tagDelimiterLeft: '{%',
|
|
3944
|
-
tagDelimiterRight: '%}',
|
|
3945
|
-
outputDelimiterLeft: '{{',
|
|
3946
|
-
outputDelimiterRight: '}}',
|
|
3947
|
-
preserveTimezones: false,
|
|
3948
|
-
strictFilters: false,
|
|
3949
|
-
strictVariables: false,
|
|
3950
|
-
ownPropertyOnly: false,
|
|
3951
|
-
lenientIf: false,
|
|
3952
|
-
globals: {},
|
|
3953
|
-
keepOutputType: false,
|
|
3954
|
-
operators: defaultOperators,
|
|
3955
|
-
operatorsTrie: createTrie(defaultOperators)
|
|
3956
|
-
};
|
|
3957
|
-
function normalize(options) {
|
|
3958
|
-
if (options.hasOwnProperty('operators')) {
|
|
3959
|
-
options.operatorsTrie = createTrie(options.operators);
|
|
3960
|
-
}
|
|
3961
|
-
if (options.hasOwnProperty('root')) {
|
|
3962
|
-
if (!options.hasOwnProperty('partials'))
|
|
3963
|
-
options.partials = options.root;
|
|
3964
|
-
if (!options.hasOwnProperty('layouts'))
|
|
3965
|
-
options.layouts = options.root;
|
|
3966
|
-
}
|
|
3967
|
-
if (options.hasOwnProperty('cache')) {
|
|
3968
|
-
var cache = void 0;
|
|
3969
|
-
if (typeof options.cache === 'number')
|
|
3970
|
-
cache = options.cache > 0 ? new LRU(options.cache) : undefined;
|
|
3971
|
-
else if (typeof options.cache === 'object')
|
|
3972
|
-
cache = options.cache;
|
|
3973
|
-
else
|
|
3974
|
-
cache = options.cache ? new LRU(1024) : undefined;
|
|
3975
|
-
options.cache = cache;
|
|
3976
|
-
}
|
|
3977
|
-
options = __assign(__assign(__assign({}, defaultOptions), (options.jekyllInclude ? { dynamicPartials: false } : {})), options);
|
|
3978
|
-
if (!options.fs.dirname && options.relativeReference) {
|
|
3979
|
-
console.warn('[LiquidJS] `fs.dirname` is required for relativeReference, set relativeReference to `false` to suppress this warning, or provide implementation for `fs.dirname`');
|
|
3980
|
-
options.relativeReference = false;
|
|
3981
|
-
}
|
|
3982
|
-
options.root = normalizeDirectoryList(options.root);
|
|
3983
|
-
options.partials = normalizeDirectoryList(options.partials);
|
|
3984
|
-
options.layouts = normalizeDirectoryList(options.layouts);
|
|
3985
|
-
options.outputEscape = options.outputEscape && getOutputEscapeFunction(options.outputEscape);
|
|
3986
|
-
return options;
|
|
3987
|
-
}
|
|
3988
|
-
function getOutputEscapeFunction(nameOrFunction) {
|
|
3989
|
-
if (isString(nameOrFunction)) {
|
|
3990
|
-
var filterImpl = filters.get(nameOrFunction);
|
|
3991
|
-
assert(isFunction(filterImpl), "filter \"".concat(nameOrFunction, "\" not found"));
|
|
3992
|
-
return filterImpl;
|
|
3993
|
-
}
|
|
3994
|
-
else {
|
|
3995
|
-
assert(isFunction(nameOrFunction), '`outputEscape` need to be of type string or function');
|
|
3996
|
-
return nameOrFunction;
|
|
3997
|
-
}
|
|
3998
|
-
}
|
|
3999
|
-
function normalizeDirectoryList(value) {
|
|
4000
|
-
var list = [];
|
|
4001
|
-
if (isArray(value))
|
|
4002
|
-
list = value;
|
|
4003
|
-
if (isString(value))
|
|
4004
|
-
list = [value];
|
|
4005
|
-
return list;
|
|
4006
|
-
}
|
|
4007
|
-
|
|
4008
|
-
var Context = /** @class */ (function () {
|
|
4009
|
-
function Context(env, opts, renderOptions) {
|
|
4010
|
-
if (env === void 0) { env = {}; }
|
|
4011
|
-
if (opts === void 0) { opts = defaultOptions; }
|
|
4012
|
-
if (renderOptions === void 0) { renderOptions = {}; }
|
|
4013
|
-
var _a, _b;
|
|
4014
|
-
/**
|
|
4015
|
-
* insert a Context-level empty scope,
|
|
4016
|
-
* for tags like `{% capture %}` `{% assign %}` to operate
|
|
4017
|
-
*/
|
|
4018
|
-
this.scopes = [{}];
|
|
4019
|
-
this.registers = {};
|
|
4020
|
-
this.sync = !!renderOptions.sync;
|
|
4021
|
-
this.opts = opts;
|
|
4022
|
-
this.globals = (_a = renderOptions.globals) !== null && _a !== void 0 ? _a : opts.globals;
|
|
4023
|
-
this.environments = env;
|
|
4024
|
-
this.strictVariables = (_b = renderOptions.strictVariables) !== null && _b !== void 0 ? _b : this.opts.strictVariables;
|
|
4025
|
-
}
|
|
4026
|
-
Context.prototype.getRegister = function (key) {
|
|
4027
|
-
return (this.registers[key] = this.registers[key] || {});
|
|
4028
|
-
};
|
|
4029
|
-
Context.prototype.setRegister = function (key, value) {
|
|
4030
|
-
return (this.registers[key] = value);
|
|
4031
|
-
};
|
|
4032
|
-
Context.prototype.saveRegister = function () {
|
|
4033
|
-
var _this = this;
|
|
4034
|
-
var keys = [];
|
|
4035
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
4036
|
-
keys[_i] = arguments[_i];
|
|
4037
|
-
}
|
|
4038
|
-
return keys.map(function (key) { return [key, _this.getRegister(key)]; });
|
|
4039
|
-
};
|
|
4040
|
-
Context.prototype.restoreRegister = function (keyValues) {
|
|
4041
|
-
var _this = this;
|
|
4042
|
-
return keyValues.forEach(function (_a) {
|
|
4043
|
-
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
4044
|
-
return _this.setRegister(key, value);
|
|
4045
|
-
});
|
|
4046
|
-
};
|
|
4047
|
-
Context.prototype.getAll = function () {
|
|
4048
|
-
return __spreadArray([this.globals, this.environments], __read(this.scopes), false).reduce(function (ctx, val) { return __assign(ctx, val); }, {});
|
|
4049
|
-
};
|
|
4050
|
-
/**
|
|
4051
|
-
* @deprecated use `_get()` instead
|
|
4052
|
-
*/
|
|
4053
|
-
Context.prototype.get = function (paths) {
|
|
4054
|
-
return toValueSync(this._get(paths));
|
|
4055
|
-
};
|
|
4056
|
-
Context.prototype._get = function (paths) {
|
|
4057
|
-
var scope;
|
|
4058
|
-
return __generator(this, function (_a) {
|
|
4059
|
-
switch (_a.label) {
|
|
4060
|
-
case 0:
|
|
4061
|
-
scope = this.findScope(paths[0]);
|
|
4062
|
-
return [4 /*yield*/, this._getFromScope(scope, paths)];
|
|
4063
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
4064
|
-
}
|
|
4065
|
-
});
|
|
4066
|
-
};
|
|
4067
|
-
/**
|
|
4068
|
-
* @deprecated use `_get()` instead
|
|
4069
|
-
*/
|
|
4070
|
-
Context.prototype.getFromScope = function (scope, paths) {
|
|
4071
|
-
return toValueSync(this._getFromScope(scope, paths));
|
|
4072
|
-
};
|
|
4073
|
-
Context.prototype._getFromScope = function (scope, paths) {
|
|
4074
|
-
var i;
|
|
4075
|
-
return __generator(this, function (_a) {
|
|
4076
|
-
switch (_a.label) {
|
|
4077
|
-
case 0:
|
|
4078
|
-
if (isString(paths))
|
|
4079
|
-
paths = paths.split('.');
|
|
4080
|
-
i = 0;
|
|
4081
|
-
_a.label = 1;
|
|
4082
|
-
case 1:
|
|
4083
|
-
if (!(i < paths.length)) return [3 /*break*/, 4];
|
|
4084
|
-
return [4 /*yield*/, readProperty(scope, paths[i], this.opts.ownPropertyOnly)];
|
|
4085
|
-
case 2:
|
|
4086
|
-
scope = _a.sent();
|
|
4087
|
-
if (isNil(scope) && this.strictVariables) {
|
|
4088
|
-
throw new InternalUndefinedVariableError(paths.slice(0, i + 1).join('.'));
|
|
4089
|
-
}
|
|
4090
|
-
_a.label = 3;
|
|
4091
|
-
case 3:
|
|
4092
|
-
i++;
|
|
4093
|
-
return [3 /*break*/, 1];
|
|
4094
|
-
case 4: return [2 /*return*/, scope];
|
|
4095
|
-
}
|
|
4096
|
-
});
|
|
4097
|
-
};
|
|
4098
|
-
Context.prototype.push = function (ctx) {
|
|
4099
|
-
return this.scopes.push(ctx);
|
|
4100
|
-
};
|
|
4101
|
-
Context.prototype.pop = function () {
|
|
4102
|
-
return this.scopes.pop();
|
|
4103
|
-
};
|
|
4104
|
-
Context.prototype.bottom = function () {
|
|
4105
|
-
return this.scopes[0];
|
|
4106
|
-
};
|
|
4107
|
-
Context.prototype.findScope = function (key) {
|
|
4108
|
-
for (var i = this.scopes.length - 1; i >= 0; i--) {
|
|
4109
|
-
var candidate = this.scopes[i];
|
|
4110
|
-
if (key in candidate)
|
|
4111
|
-
return candidate;
|
|
4112
|
-
}
|
|
4113
|
-
if (key in this.environments)
|
|
4114
|
-
return this.environments;
|
|
4115
|
-
return this.globals;
|
|
4116
|
-
};
|
|
4117
|
-
return Context;
|
|
4118
|
-
}());
|
|
4119
|
-
function readProperty(obj, key, ownPropertyOnly) {
|
|
4120
|
-
if (isNil(obj))
|
|
4121
|
-
return obj;
|
|
4122
|
-
obj = toLiquid(obj);
|
|
4123
|
-
if (isArray(obj) && key < 0)
|
|
4124
|
-
return obj[obj.length + +key];
|
|
4125
|
-
var jsProperty = readJSProperty(obj, key, ownPropertyOnly);
|
|
4126
|
-
if (jsProperty === undefined && obj instanceof Drop)
|
|
4127
|
-
return obj.liquidMethodMissing(key);
|
|
4128
|
-
if (isFunction(jsProperty))
|
|
4129
|
-
return jsProperty.call(obj);
|
|
4130
|
-
if (key === 'size')
|
|
4131
|
-
return readSize(obj);
|
|
4132
|
-
else if (key === 'first')
|
|
4133
|
-
return readFirst(obj);
|
|
4134
|
-
else if (key === 'last')
|
|
4135
|
-
return readLast(obj);
|
|
4136
|
-
return jsProperty;
|
|
4137
|
-
}
|
|
4138
|
-
function readJSProperty(obj, key, ownPropertyOnly) {
|
|
4139
|
-
if (ownPropertyOnly && !Object.hasOwnProperty.call(obj, key))
|
|
4140
|
-
return undefined;
|
|
4141
|
-
return obj[key];
|
|
4142
|
-
}
|
|
4143
|
-
function readFirst(obj) {
|
|
4144
|
-
if (isArray(obj))
|
|
4145
|
-
return obj[0];
|
|
4146
|
-
return obj['first'];
|
|
4147
|
-
}
|
|
4148
|
-
function readLast(obj) {
|
|
4149
|
-
if (isArray(obj))
|
|
4150
|
-
return obj[obj.length - 1];
|
|
4151
|
-
return obj['last'];
|
|
4152
|
-
}
|
|
4153
|
-
function readSize(obj) {
|
|
4154
|
-
if (obj.hasOwnProperty('size') || obj['size'] !== undefined)
|
|
4155
|
-
return obj['size'];
|
|
4156
|
-
if (isArray(obj) || isString(obj))
|
|
4157
|
-
return obj.length;
|
|
4158
|
-
if (typeof obj === 'object')
|
|
4159
|
-
return Object.keys(obj).length;
|
|
4160
|
-
}
|
|
4161
|
-
|
|
4162
|
-
var LookupType;
|
|
4163
|
-
(function (LookupType) {
|
|
4164
|
-
LookupType["Partials"] = "partials";
|
|
4165
|
-
LookupType["Layouts"] = "layouts";
|
|
4166
|
-
LookupType["Root"] = "root";
|
|
4167
|
-
})(LookupType || (LookupType = {}));
|
|
4168
|
-
var Loader = /** @class */ (function () {
|
|
4169
|
-
function Loader(options) {
|
|
4170
|
-
this.options = options;
|
|
4171
|
-
if (options.relativeReference) {
|
|
4172
|
-
var sep = options.fs.sep;
|
|
4173
|
-
assert(sep, '`fs.sep` is required for relative reference');
|
|
4174
|
-
var rRelativePath_1 = new RegExp(['.' + sep, '..' + sep, './', '../'].map(function (prefix) { return escapeRegex(prefix); }).join('|'));
|
|
4175
|
-
this.shouldLoadRelative = function (referencedFile) { return rRelativePath_1.test(referencedFile); };
|
|
4176
|
-
}
|
|
4177
|
-
else {
|
|
4178
|
-
this.shouldLoadRelative = function (referencedFile) { return false; };
|
|
4179
|
-
}
|
|
4180
|
-
this.contains = this.options.fs.contains || (function () { return true; });
|
|
4181
|
-
}
|
|
4182
|
-
Loader.prototype.lookup = function (file, type, sync, currentFile) {
|
|
4183
|
-
var fs, dirs, _a, _b, filepath, _c, e_1_1;
|
|
4184
|
-
var e_1, _d;
|
|
4185
|
-
return __generator(this, function (_e) {
|
|
4186
|
-
switch (_e.label) {
|
|
4187
|
-
case 0:
|
|
4188
|
-
fs = this.options.fs;
|
|
4189
|
-
dirs = this.options[type];
|
|
4190
|
-
_e.label = 1;
|
|
4191
|
-
case 1:
|
|
4192
|
-
_e.trys.push([1, 8, 9, 10]);
|
|
4193
|
-
_a = __values(this.candidates(file, dirs, currentFile, type !== LookupType.Root)), _b = _a.next();
|
|
4194
|
-
_e.label = 2;
|
|
4195
|
-
case 2:
|
|
4196
|
-
if (!!_b.done) return [3 /*break*/, 7];
|
|
4197
|
-
filepath = _b.value;
|
|
4198
|
-
if (!sync) return [3 /*break*/, 3];
|
|
4199
|
-
_c = fs.existsSync(filepath);
|
|
4200
|
-
return [3 /*break*/, 5];
|
|
4201
|
-
case 3: return [4 /*yield*/, fs.exists(filepath)];
|
|
4202
|
-
case 4:
|
|
4203
|
-
_c = _e.sent();
|
|
4204
|
-
_e.label = 5;
|
|
4205
|
-
case 5:
|
|
4206
|
-
if (_c)
|
|
4207
|
-
return [2 /*return*/, filepath];
|
|
4208
|
-
_e.label = 6;
|
|
4209
|
-
case 6:
|
|
4210
|
-
_b = _a.next();
|
|
4211
|
-
return [3 /*break*/, 2];
|
|
4212
|
-
case 7: return [3 /*break*/, 10];
|
|
4213
|
-
case 8:
|
|
4214
|
-
e_1_1 = _e.sent();
|
|
4215
|
-
e_1 = { error: e_1_1 };
|
|
4216
|
-
return [3 /*break*/, 10];
|
|
4217
|
-
case 9:
|
|
4218
|
-
try {
|
|
4219
|
-
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
4220
|
-
}
|
|
4221
|
-
finally { if (e_1) throw e_1.error; }
|
|
4222
|
-
return [7 /*endfinally*/];
|
|
4223
|
-
case 10: throw this.lookupError(file, dirs);
|
|
4224
|
-
}
|
|
4225
|
-
});
|
|
4226
|
-
};
|
|
4227
|
-
Loader.prototype.candidates = function (file, dirs, currentFile, enforceRoot) {
|
|
4228
|
-
var _a, fs, extname, referenced, dirs_1, dirs_1_1, dir, e_2_1, dirs_2, dirs_2_1, dir, referenced, e_3_1, filepath;
|
|
4229
|
-
var e_2, _b, e_3, _c;
|
|
4230
|
-
return __generator(this, function (_d) {
|
|
4231
|
-
switch (_d.label) {
|
|
4232
|
-
case 0:
|
|
4233
|
-
_a = this.options, fs = _a.fs, extname = _a.extname;
|
|
4234
|
-
if (!(this.shouldLoadRelative(file) && currentFile)) return [3 /*break*/, 8];
|
|
4235
|
-
referenced = fs.resolve(this.dirname(currentFile), file, extname);
|
|
4236
|
-
_d.label = 1;
|
|
4237
|
-
case 1:
|
|
4238
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
4239
|
-
dirs_1 = __values(dirs), dirs_1_1 = dirs_1.next();
|
|
4240
|
-
_d.label = 2;
|
|
4241
|
-
case 2:
|
|
4242
|
-
if (!!dirs_1_1.done) return [3 /*break*/, 5];
|
|
4243
|
-
dir = dirs_1_1.value;
|
|
4244
|
-
if (!(!enforceRoot || this.contains(dir, referenced))) return [3 /*break*/, 4];
|
|
4245
|
-
// the relatively referenced file is within one of root dirs
|
|
4246
|
-
return [4 /*yield*/, referenced];
|
|
4247
|
-
case 3:
|
|
4248
|
-
// the relatively referenced file is within one of root dirs
|
|
4249
|
-
_d.sent();
|
|
4250
|
-
return [3 /*break*/, 5];
|
|
4251
|
-
case 4:
|
|
4252
|
-
dirs_1_1 = dirs_1.next();
|
|
4253
|
-
return [3 /*break*/, 2];
|
|
4254
|
-
case 5: return [3 /*break*/, 8];
|
|
4255
|
-
case 6:
|
|
4256
|
-
e_2_1 = _d.sent();
|
|
4257
|
-
e_2 = { error: e_2_1 };
|
|
4258
|
-
return [3 /*break*/, 8];
|
|
4259
|
-
case 7:
|
|
4260
|
-
try {
|
|
4261
|
-
if (dirs_1_1 && !dirs_1_1.done && (_b = dirs_1.return)) _b.call(dirs_1);
|
|
4262
|
-
}
|
|
4263
|
-
finally { if (e_2) throw e_2.error; }
|
|
4264
|
-
return [7 /*endfinally*/];
|
|
4265
|
-
case 8:
|
|
4266
|
-
_d.trys.push([8, 13, 14, 15]);
|
|
4267
|
-
dirs_2 = __values(dirs), dirs_2_1 = dirs_2.next();
|
|
4268
|
-
_d.label = 9;
|
|
4269
|
-
case 9:
|
|
4270
|
-
if (!!dirs_2_1.done) return [3 /*break*/, 12];
|
|
4271
|
-
dir = dirs_2_1.value;
|
|
4272
|
-
referenced = fs.resolve(dir, file, extname);
|
|
4273
|
-
if (!(!enforceRoot || this.contains(dir, referenced))) return [3 /*break*/, 11];
|
|
4274
|
-
return [4 /*yield*/, referenced];
|
|
4275
|
-
case 10:
|
|
4276
|
-
_d.sent();
|
|
4277
|
-
_d.label = 11;
|
|
4278
|
-
case 11:
|
|
4279
|
-
dirs_2_1 = dirs_2.next();
|
|
4280
|
-
return [3 /*break*/, 9];
|
|
4281
|
-
case 12: return [3 /*break*/, 15];
|
|
4282
|
-
case 13:
|
|
4283
|
-
e_3_1 = _d.sent();
|
|
4284
|
-
e_3 = { error: e_3_1 };
|
|
4285
|
-
return [3 /*break*/, 15];
|
|
4286
|
-
case 14:
|
|
4287
|
-
try {
|
|
4288
|
-
if (dirs_2_1 && !dirs_2_1.done && (_c = dirs_2.return)) _c.call(dirs_2);
|
|
4289
|
-
}
|
|
4290
|
-
finally { if (e_3) throw e_3.error; }
|
|
4291
|
-
return [7 /*endfinally*/];
|
|
4292
|
-
case 15:
|
|
4293
|
-
if (!(fs.fallback !== undefined)) return [3 /*break*/, 17];
|
|
4294
|
-
filepath = fs.fallback(file);
|
|
4295
|
-
if (!(filepath !== undefined)) return [3 /*break*/, 17];
|
|
4296
|
-
return [4 /*yield*/, filepath];
|
|
4297
|
-
case 16:
|
|
4298
|
-
_d.sent();
|
|
4299
|
-
_d.label = 17;
|
|
4300
|
-
case 17: return [2 /*return*/];
|
|
4301
|
-
}
|
|
4302
|
-
});
|
|
4303
|
-
};
|
|
4304
|
-
Loader.prototype.dirname = function (path) {
|
|
4305
|
-
var fs = this.options.fs;
|
|
4306
|
-
assert(fs.dirname, '`fs.dirname` is required for relative reference');
|
|
4307
|
-
return fs.dirname(path);
|
|
4308
|
-
};
|
|
4309
|
-
Loader.prototype.lookupError = function (file, roots) {
|
|
4310
|
-
var err = new Error('ENOENT');
|
|
4311
|
-
err.message = "ENOENT: Failed to lookup \"".concat(file, "\" in \"").concat(roots, "\"");
|
|
4312
|
-
err.code = 'ENOENT';
|
|
4313
|
-
return err;
|
|
4314
|
-
};
|
|
4315
|
-
return Loader;
|
|
4316
|
-
}());
|
|
4317
|
-
|
|
4318
|
-
var SimpleEmitter = /** @class */ (function () {
|
|
4319
|
-
function SimpleEmitter() {
|
|
4320
|
-
this.buffer = '';
|
|
4321
|
-
}
|
|
4322
|
-
SimpleEmitter.prototype.write = function (html) {
|
|
4323
|
-
this.buffer += stringify(html);
|
|
4324
|
-
};
|
|
4325
|
-
return SimpleEmitter;
|
|
4326
|
-
}());
|
|
4327
|
-
|
|
4328
|
-
var StreamedEmitter = /** @class */ (function () {
|
|
4329
|
-
function StreamedEmitter() {
|
|
4330
|
-
this.buffer = '';
|
|
4331
|
-
this.stream = new stream.PassThrough();
|
|
4332
|
-
}
|
|
4333
|
-
StreamedEmitter.prototype.write = function (html) {
|
|
4334
|
-
this.stream.write(stringify(html));
|
|
4335
|
-
};
|
|
4336
|
-
StreamedEmitter.prototype.error = function (err) {
|
|
4337
|
-
this.stream.emit('error', err);
|
|
4338
|
-
};
|
|
4339
|
-
StreamedEmitter.prototype.end = function () {
|
|
4340
|
-
this.stream.end();
|
|
4341
|
-
};
|
|
4342
|
-
return StreamedEmitter;
|
|
4343
|
-
}());
|
|
4344
|
-
|
|
4345
|
-
var KeepingTypeEmitter = /** @class */ (function () {
|
|
4346
|
-
function KeepingTypeEmitter() {
|
|
4347
|
-
this.buffer = '';
|
|
4348
|
-
}
|
|
4349
|
-
KeepingTypeEmitter.prototype.write = function (html) {
|
|
4350
|
-
html = toValue(html);
|
|
4351
|
-
// This will only preserve the type if the value is isolated.
|
|
4352
|
-
// I.E:
|
|
4353
|
-
// {{ my-port }} -> 42
|
|
4354
|
-
// {{ my-host }}:{{ my-port }} -> 'host:42'
|
|
4355
|
-
if (typeof html !== 'string' && this.buffer === '') {
|
|
4356
|
-
this.buffer = html;
|
|
4357
|
-
}
|
|
4358
|
-
else {
|
|
4359
|
-
this.buffer = stringify(this.buffer) + stringify(html);
|
|
4360
|
-
}
|
|
4361
|
-
};
|
|
4362
|
-
return KeepingTypeEmitter;
|
|
4363
|
-
}());
|
|
4364
|
-
|
|
4365
|
-
var Render = /** @class */ (function () {
|
|
4366
|
-
function Render() {
|
|
4367
|
-
}
|
|
4368
|
-
Render.prototype.renderTemplatesToNodeStream = function (templates, ctx) {
|
|
4369
|
-
var _this = this;
|
|
4370
|
-
var emitter = new StreamedEmitter();
|
|
4371
|
-
Promise.resolve().then(function () { return toPromise(_this.renderTemplates(templates, ctx, emitter)); })
|
|
4372
|
-
.then(function () { return emitter.end(); }, function (err) { return emitter.error(err); });
|
|
4373
|
-
return emitter.stream;
|
|
4374
|
-
};
|
|
4375
|
-
Render.prototype.renderTemplates = function (templates, ctx, emitter) {
|
|
4376
|
-
var templates_1, templates_1_1, tpl, html, e_1, err, e_2_1;
|
|
4377
|
-
var e_2, _a;
|
|
4378
|
-
return __generator(this, function (_b) {
|
|
4379
|
-
switch (_b.label) {
|
|
4380
|
-
case 0:
|
|
4381
|
-
if (!emitter) {
|
|
4382
|
-
emitter = ctx.opts.keepOutputType ? new KeepingTypeEmitter() : new SimpleEmitter();
|
|
4383
|
-
}
|
|
4384
|
-
_b.label = 1;
|
|
4385
|
-
case 1:
|
|
4386
|
-
_b.trys.push([1, 8, 9, 10]);
|
|
4387
|
-
templates_1 = __values(templates), templates_1_1 = templates_1.next();
|
|
4388
|
-
_b.label = 2;
|
|
4389
|
-
case 2:
|
|
4390
|
-
if (!!templates_1_1.done) return [3 /*break*/, 7];
|
|
4391
|
-
tpl = templates_1_1.value;
|
|
4392
|
-
_b.label = 3;
|
|
4393
|
-
case 3:
|
|
4394
|
-
_b.trys.push([3, 5, , 6]);
|
|
4395
|
-
return [4 /*yield*/, tpl.render(ctx, emitter)
|
|
4396
|
-
// if not, it'll return an `html`, write to the emitter for it
|
|
4397
|
-
];
|
|
4398
|
-
case 4:
|
|
4399
|
-
html = _b.sent();
|
|
4400
|
-
// if not, it'll return an `html`, write to the emitter for it
|
|
4401
|
-
html && emitter.write(html);
|
|
4402
|
-
if (emitter['break'] || emitter['continue'])
|
|
4403
|
-
return [3 /*break*/, 7];
|
|
4404
|
-
return [3 /*break*/, 6];
|
|
4405
|
-
case 5:
|
|
4406
|
-
e_1 = _b.sent();
|
|
4407
|
-
err = RenderError.is(e_1) ? e_1 : new RenderError(e_1, tpl);
|
|
4408
|
-
throw err;
|
|
4409
|
-
case 6:
|
|
4410
|
-
templates_1_1 = templates_1.next();
|
|
4411
|
-
return [3 /*break*/, 2];
|
|
4412
|
-
case 7: return [3 /*break*/, 10];
|
|
4413
|
-
case 8:
|
|
4414
|
-
e_2_1 = _b.sent();
|
|
4415
|
-
e_2 = { error: e_2_1 };
|
|
4416
|
-
return [3 /*break*/, 10];
|
|
4417
|
-
case 9:
|
|
4418
|
-
try {
|
|
4419
|
-
if (templates_1_1 && !templates_1_1.done && (_a = templates_1.return)) _a.call(templates_1);
|
|
4420
|
-
}
|
|
4421
|
-
finally { if (e_2) throw e_2.error; }
|
|
4422
|
-
return [7 /*endfinally*/];
|
|
4423
|
-
case 10: return [2 /*return*/, emitter.buffer];
|
|
4424
|
-
}
|
|
4425
|
-
});
|
|
4426
|
-
};
|
|
4427
|
-
return Render;
|
|
4428
|
-
}());
|
|
4429
|
-
|
|
4430
|
-
var TemplateImpl = /** @class */ (function () {
|
|
4431
|
-
function TemplateImpl(token) {
|
|
4432
|
-
this.token = token;
|
|
4433
|
-
}
|
|
4434
|
-
return TemplateImpl;
|
|
4435
|
-
}());
|
|
4436
|
-
|
|
4437
|
-
var Tag = /** @class */ (function (_super) {
|
|
4438
|
-
__extends(Tag, _super);
|
|
4439
|
-
function Tag(token, tokens, liquid) {
|
|
4440
|
-
var _this = _super.call(this, token) || this;
|
|
4441
|
-
_this.name = token.name;
|
|
4442
|
-
var impl = liquid.tags.get(token.name);
|
|
4443
|
-
_this.impl = Object.create(impl);
|
|
4444
|
-
_this.impl.liquid = liquid;
|
|
4445
|
-
if (_this.impl.parse) {
|
|
4446
|
-
_this.impl.parse(token, tokens);
|
|
4447
|
-
}
|
|
4448
|
-
return _this;
|
|
4449
|
-
}
|
|
4450
|
-
Tag.prototype.render = function (ctx, emitter) {
|
|
4451
|
-
var hash, impl;
|
|
4452
|
-
return __generator(this, function (_a) {
|
|
4453
|
-
switch (_a.label) {
|
|
4454
|
-
case 0: return [4 /*yield*/, new Hash(this.token.args).render(ctx)];
|
|
4455
|
-
case 1:
|
|
4456
|
-
hash = (_a.sent());
|
|
4457
|
-
impl = this.impl;
|
|
4458
|
-
if (!isFunction(impl.render)) return [3 /*break*/, 3];
|
|
4459
|
-
return [4 /*yield*/, impl.render(ctx, emitter, hash)];
|
|
4460
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
4461
|
-
case 3: return [2 /*return*/];
|
|
4462
|
-
}
|
|
4463
|
-
});
|
|
4464
|
-
};
|
|
4465
|
-
return Tag;
|
|
4466
|
-
}(TemplateImpl));
|
|
4467
|
-
|
|
4468
|
-
var Output = /** @class */ (function (_super) {
|
|
4469
|
-
__extends(Output, _super);
|
|
4470
|
-
function Output(token, liquid) {
|
|
4471
|
-
var _this = _super.call(this, token) || this;
|
|
4472
|
-
_this.value = new Value(token.content, liquid);
|
|
4473
|
-
var filters = _this.value.filters;
|
|
4474
|
-
var outputEscape = liquid.options.outputEscape;
|
|
4475
|
-
if (filters.length && filters[filters.length - 1].name === 'raw') {
|
|
4476
|
-
filters.pop();
|
|
4477
|
-
}
|
|
4478
|
-
else if (outputEscape) {
|
|
4479
|
-
filters.push(new Filter(toString.call(outputEscape), outputEscape, [], liquid));
|
|
4480
|
-
}
|
|
4481
|
-
return _this;
|
|
4482
|
-
}
|
|
4483
|
-
Output.prototype.render = function (ctx, emitter) {
|
|
4484
|
-
var val;
|
|
4485
|
-
return __generator(this, function (_a) {
|
|
4486
|
-
switch (_a.label) {
|
|
4487
|
-
case 0: return [4 /*yield*/, this.value.value(ctx, false)];
|
|
4488
|
-
case 1:
|
|
4489
|
-
val = _a.sent();
|
|
4490
|
-
emitter.write(val);
|
|
4491
|
-
return [2 /*return*/];
|
|
4492
|
-
}
|
|
4493
|
-
});
|
|
4494
|
-
};
|
|
4495
|
-
return Output;
|
|
4496
|
-
}(TemplateImpl));
|
|
4497
|
-
|
|
4498
|
-
var HTML = /** @class */ (function (_super) {
|
|
4499
|
-
__extends(HTML, _super);
|
|
4500
|
-
function HTML(token) {
|
|
4501
|
-
var _this = _super.call(this, token) || this;
|
|
4502
|
-
_this.str = token.getContent();
|
|
4503
|
-
return _this;
|
|
4504
|
-
}
|
|
4505
|
-
HTML.prototype.render = function (ctx, emitter) {
|
|
4506
|
-
return __generator(this, function (_a) {
|
|
4507
|
-
emitter.write(this.str);
|
|
4508
|
-
return [2 /*return*/];
|
|
4509
|
-
});
|
|
4510
|
-
};
|
|
4511
|
-
return HTML;
|
|
4512
|
-
}(TemplateImpl));
|
|
4513
|
-
|
|
4514
|
-
var Parser = /** @class */ (function () {
|
|
4515
|
-
function Parser(liquid) {
|
|
4516
|
-
this.liquid = liquid;
|
|
4517
|
-
this.cache = this.liquid.options.cache;
|
|
4518
|
-
this.fs = this.liquid.options.fs;
|
|
4519
|
-
this.parseFile = this.cache ? this._parseFileCached : this._parseFile;
|
|
4520
|
-
this.loader = new Loader(this.liquid.options);
|
|
4521
|
-
}
|
|
4522
|
-
Parser.prototype.parse = function (html, filepath) {
|
|
4523
|
-
var tokenizer = new Tokenizer(html, this.liquid.options.operatorsTrie, filepath);
|
|
4524
|
-
var tokens = tokenizer.readTopLevelTokens(this.liquid.options);
|
|
4525
|
-
return this.parseTokens(tokens);
|
|
4526
|
-
};
|
|
4527
|
-
Parser.prototype.parseTokens = function (tokens) {
|
|
4528
|
-
var token;
|
|
4529
|
-
var templates = [];
|
|
4530
|
-
while ((token = tokens.shift())) {
|
|
4531
|
-
templates.push(this.parseToken(token, tokens));
|
|
4532
|
-
}
|
|
4533
|
-
return templates;
|
|
4534
|
-
};
|
|
4535
|
-
Parser.prototype.parseToken = function (token, remainTokens) {
|
|
4536
|
-
try {
|
|
4537
|
-
if (isTagToken(token)) {
|
|
4538
|
-
return new Tag(token, remainTokens, this.liquid);
|
|
4539
|
-
}
|
|
4540
|
-
if (isOutputToken(token)) {
|
|
4541
|
-
return new Output(token, this.liquid);
|
|
4542
|
-
}
|
|
4543
|
-
return new HTML(token);
|
|
4544
|
-
}
|
|
4545
|
-
catch (e) {
|
|
4546
|
-
throw new ParseError(e, token);
|
|
4547
|
-
}
|
|
4548
|
-
};
|
|
4549
|
-
Parser.prototype.parseStream = function (tokens) {
|
|
4550
|
-
var _this = this;
|
|
4551
|
-
return new ParseStream(tokens, function (token, tokens) { return _this.parseToken(token, tokens); });
|
|
4552
|
-
};
|
|
4553
|
-
Parser.prototype._parseFileCached = function (file, sync, type, currentFile) {
|
|
4554
|
-
var cache, key, tpls, task, taskOrTpl, _a, err_1;
|
|
4555
|
-
if (type === void 0) { type = LookupType.Root; }
|
|
4556
|
-
return __generator(this, function (_b) {
|
|
4557
|
-
switch (_b.label) {
|
|
4558
|
-
case 0:
|
|
4559
|
-
cache = this.cache;
|
|
4560
|
-
key = this.loader.shouldLoadRelative(file) ? currentFile + ',' + file : type + ':' + file;
|
|
4561
|
-
return [4 /*yield*/, cache.read(key)];
|
|
4562
|
-
case 1:
|
|
4563
|
-
tpls = _b.sent();
|
|
4564
|
-
if (tpls)
|
|
4565
|
-
return [2 /*return*/, tpls];
|
|
4566
|
-
task = this._parseFile(file, sync, type, currentFile);
|
|
4567
|
-
if (!sync) return [3 /*break*/, 3];
|
|
4568
|
-
return [4 /*yield*/, task];
|
|
4569
|
-
case 2:
|
|
4570
|
-
_a = _b.sent();
|
|
4571
|
-
return [3 /*break*/, 4];
|
|
4572
|
-
case 3:
|
|
4573
|
-
_a = toPromise(task);
|
|
4574
|
-
_b.label = 4;
|
|
4575
|
-
case 4:
|
|
4576
|
-
taskOrTpl = _a;
|
|
4577
|
-
cache.write(key, taskOrTpl);
|
|
4578
|
-
_b.label = 5;
|
|
4579
|
-
case 5:
|
|
4580
|
-
_b.trys.push([5, 7, , 8]);
|
|
4581
|
-
return [4 /*yield*/, taskOrTpl];
|
|
4582
|
-
case 6: return [2 /*return*/, _b.sent()];
|
|
4583
|
-
case 7:
|
|
4584
|
-
err_1 = _b.sent();
|
|
4585
|
-
cache.remove(key);
|
|
4586
|
-
throw err_1;
|
|
4587
|
-
case 8: return [2 /*return*/];
|
|
4588
|
-
}
|
|
4589
|
-
});
|
|
4590
|
-
};
|
|
4591
|
-
Parser.prototype._parseFile = function (file, sync, type, currentFile) {
|
|
4592
|
-
var filepath, _a, _b, _c;
|
|
4593
|
-
if (type === void 0) { type = LookupType.Root; }
|
|
4594
|
-
return __generator(this, function (_d) {
|
|
4595
|
-
switch (_d.label) {
|
|
4596
|
-
case 0: return [4 /*yield*/, this.loader.lookup(file, type, sync, currentFile)];
|
|
4597
|
-
case 1:
|
|
4598
|
-
filepath = _d.sent();
|
|
4599
|
-
_b = (_a = this.liquid).parse;
|
|
4600
|
-
if (!sync) return [3 /*break*/, 2];
|
|
4601
|
-
_c = this.fs.readFileSync(filepath);
|
|
4602
|
-
return [3 /*break*/, 4];
|
|
4603
|
-
case 2: return [4 /*yield*/, this.fs.readFile(filepath)];
|
|
4604
|
-
case 3:
|
|
4605
|
-
_c = _d.sent();
|
|
4606
|
-
_d.label = 4;
|
|
4607
|
-
case 4: return [2 /*return*/, _b.apply(_a, [_c, filepath])];
|
|
4608
|
-
}
|
|
4609
|
-
});
|
|
4610
|
-
};
|
|
4611
|
-
return Parser;
|
|
4612
|
-
}());
|
|
4613
|
-
|
|
4614
|
-
var TagMap = /** @class */ (function () {
|
|
4615
|
-
function TagMap() {
|
|
4616
|
-
this.impls = {};
|
|
4617
|
-
}
|
|
4618
|
-
TagMap.prototype.get = function (name) {
|
|
4619
|
-
var impl = this.impls[name];
|
|
4620
|
-
assert(impl, function () { return "tag \"".concat(name, "\" not found"); });
|
|
4621
|
-
return impl;
|
|
4622
|
-
};
|
|
4623
|
-
TagMap.prototype.set = function (name, impl) {
|
|
4624
|
-
this.impls[name] = impl;
|
|
4625
|
-
};
|
|
4626
|
-
return TagMap;
|
|
4627
|
-
}());
|
|
4628
|
-
|
|
4629
|
-
var FilterMap = /** @class */ (function () {
|
|
4630
|
-
function FilterMap(strictFilters, liquid) {
|
|
4631
|
-
this.strictFilters = strictFilters;
|
|
4632
|
-
this.liquid = liquid;
|
|
4633
|
-
this.impls = {};
|
|
4634
|
-
}
|
|
4635
|
-
FilterMap.prototype.get = function (name) {
|
|
4636
|
-
var impl = this.impls[name];
|
|
4637
|
-
assert(impl || !this.strictFilters, function () { return "undefined filter: ".concat(name); });
|
|
4638
|
-
return impl;
|
|
4639
|
-
};
|
|
4640
|
-
FilterMap.prototype.set = function (name, impl) {
|
|
4641
|
-
this.impls[name] = impl;
|
|
4642
|
-
};
|
|
4643
|
-
FilterMap.prototype.create = function (name, args) {
|
|
4644
|
-
return new Filter(name, this.get(name), args, this.liquid);
|
|
4645
|
-
};
|
|
4646
|
-
return FilterMap;
|
|
4647
|
-
}());
|
|
4648
|
-
|
|
4649
|
-
var version = '9.43.0';
|
|
4650
|
-
var Liquid = /** @class */ (function () {
|
|
4651
|
-
function Liquid(opts) {
|
|
4652
|
-
var _this = this;
|
|
4653
|
-
if (opts === void 0) { opts = {}; }
|
|
4654
|
-
this.options = normalize(opts);
|
|
4655
|
-
this.parser = new Parser(this);
|
|
4656
|
-
this.renderer = new Render();
|
|
4657
|
-
this.filters = new FilterMap(this.options.strictFilters, this);
|
|
4658
|
-
this.tags = new TagMap();
|
|
4659
|
-
forOwn(tags, function (conf, name) { return _this.registerTag(snakeCase(name), conf); });
|
|
4660
|
-
forOwn(builtinFilters, function (handler, name) { return _this.registerFilter(snakeCase(name), handler); });
|
|
4661
|
-
}
|
|
4662
|
-
Liquid.prototype.parse = function (html, filepath) {
|
|
4663
|
-
return this.parser.parse(html, filepath);
|
|
4664
|
-
};
|
|
4665
|
-
Liquid.prototype._render = function (tpl, scope, renderOptions) {
|
|
4666
|
-
var ctx = new Context(scope, this.options, renderOptions);
|
|
4667
|
-
return this.renderer.renderTemplates(tpl, ctx);
|
|
4668
|
-
};
|
|
4669
|
-
Liquid.prototype.render = function (tpl, scope, renderOptions) {
|
|
4670
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4671
|
-
return __generator(this, function (_a) {
|
|
4672
|
-
return [2 /*return*/, toPromise(this._render(tpl, scope, __assign(__assign({}, renderOptions), { sync: false })))];
|
|
4673
|
-
});
|
|
4674
|
-
});
|
|
4675
|
-
};
|
|
4676
|
-
Liquid.prototype.renderSync = function (tpl, scope, renderOptions) {
|
|
4677
|
-
return toValueSync(this._render(tpl, scope, __assign(__assign({}, renderOptions), { sync: true })));
|
|
4678
|
-
};
|
|
4679
|
-
Liquid.prototype.renderToNodeStream = function (tpl, scope, renderOptions) {
|
|
4680
|
-
if (renderOptions === void 0) { renderOptions = {}; }
|
|
4681
|
-
var ctx = new Context(scope, this.options, renderOptions);
|
|
4682
|
-
return this.renderer.renderTemplatesToNodeStream(tpl, ctx);
|
|
4683
|
-
};
|
|
4684
|
-
Liquid.prototype._parseAndRender = function (html, scope, renderOptions) {
|
|
4685
|
-
var tpl = this.parse(html);
|
|
4686
|
-
return this._render(tpl, scope, renderOptions);
|
|
4687
|
-
};
|
|
4688
|
-
Liquid.prototype.parseAndRender = function (html, scope, renderOptions) {
|
|
4689
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4690
|
-
return __generator(this, function (_a) {
|
|
4691
|
-
return [2 /*return*/, toPromise(this._parseAndRender(html, scope, __assign(__assign({}, renderOptions), { sync: false })))];
|
|
4692
|
-
});
|
|
4693
|
-
});
|
|
4694
|
-
};
|
|
4695
|
-
Liquid.prototype.parseAndRenderSync = function (html, scope, renderOptions) {
|
|
4696
|
-
return toValueSync(this._parseAndRender(html, scope, __assign(__assign({}, renderOptions), { sync: true })));
|
|
4697
|
-
};
|
|
4698
|
-
Liquid.prototype._parsePartialFile = function (file, sync, currentFile) {
|
|
4699
|
-
return this.parser.parseFile(file, sync, LookupType.Partials, currentFile);
|
|
4700
|
-
};
|
|
4701
|
-
Liquid.prototype._parseLayoutFile = function (file, sync, currentFile) {
|
|
4702
|
-
return this.parser.parseFile(file, sync, LookupType.Layouts, currentFile);
|
|
4703
|
-
};
|
|
4704
|
-
Liquid.prototype.parseFile = function (file) {
|
|
4705
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4706
|
-
return __generator(this, function (_a) {
|
|
4707
|
-
return [2 /*return*/, toPromise(this.parser.parseFile(file, false))];
|
|
4708
|
-
});
|
|
4709
|
-
});
|
|
4710
|
-
};
|
|
4711
|
-
Liquid.prototype.parseFileSync = function (file) {
|
|
4712
|
-
return toValueSync(this.parser.parseFile(file, true));
|
|
4713
|
-
};
|
|
4714
|
-
Liquid.prototype.renderFile = function (file, ctx, renderOptions) {
|
|
4715
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4716
|
-
var templates;
|
|
4717
|
-
return __generator(this, function (_a) {
|
|
4718
|
-
switch (_a.label) {
|
|
4719
|
-
case 0: return [4 /*yield*/, this.parseFile(file)];
|
|
4720
|
-
case 1:
|
|
4721
|
-
templates = _a.sent();
|
|
4722
|
-
return [2 /*return*/, this.render(templates, ctx, renderOptions)];
|
|
4723
|
-
}
|
|
4724
|
-
});
|
|
4725
|
-
});
|
|
4726
|
-
};
|
|
4727
|
-
Liquid.prototype.renderFileSync = function (file, ctx, renderOptions) {
|
|
4728
|
-
var templates = this.parseFileSync(file);
|
|
4729
|
-
return this.renderSync(templates, ctx, renderOptions);
|
|
4730
|
-
};
|
|
4731
|
-
Liquid.prototype.renderFileToNodeStream = function (file, scope, renderOptions) {
|
|
4732
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4733
|
-
var templates;
|
|
4734
|
-
return __generator(this, function (_a) {
|
|
4735
|
-
switch (_a.label) {
|
|
4736
|
-
case 0: return [4 /*yield*/, this.parseFile(file)];
|
|
4737
|
-
case 1:
|
|
4738
|
-
templates = _a.sent();
|
|
4739
|
-
return [2 /*return*/, this.renderToNodeStream(templates, scope, renderOptions)];
|
|
4740
|
-
}
|
|
4741
|
-
});
|
|
4742
|
-
});
|
|
4743
|
-
};
|
|
4744
|
-
Liquid.prototype._evalValue = function (str, scopeOrContext) {
|
|
4745
|
-
var value = new Value(str, this);
|
|
4746
|
-
var ctx = scopeOrContext instanceof Context ? scopeOrContext : new Context(scopeOrContext, this.options);
|
|
4747
|
-
return value.value(ctx, false);
|
|
4748
|
-
};
|
|
4749
|
-
Liquid.prototype.evalValue = function (str, scopeOrContext) {
|
|
4750
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4751
|
-
return __generator(this, function (_a) {
|
|
4752
|
-
return [2 /*return*/, toPromise(this._evalValue(str, scopeOrContext))];
|
|
4753
|
-
});
|
|
4754
|
-
});
|
|
4755
|
-
};
|
|
4756
|
-
Liquid.prototype.evalValueSync = function (str, scopeOrContext) {
|
|
4757
|
-
return toValueSync(this._evalValue(str, scopeOrContext));
|
|
4758
|
-
};
|
|
4759
|
-
Liquid.prototype.registerFilter = function (name, filter) {
|
|
4760
|
-
this.filters.set(name, filter);
|
|
4761
|
-
};
|
|
4762
|
-
Liquid.prototype.registerTag = function (name, tag) {
|
|
4763
|
-
this.tags.set(name, tag);
|
|
4764
|
-
};
|
|
4765
|
-
Liquid.prototype.plugin = function (plugin) {
|
|
4766
|
-
return plugin.call(this, Liquid);
|
|
4767
|
-
};
|
|
4768
|
-
Liquid.prototype.express = function () {
|
|
4769
|
-
var self = this; // eslint-disable-line
|
|
4770
|
-
var firstCall = true;
|
|
4771
|
-
return function (filePath, ctx, callback) {
|
|
4772
|
-
var _a, _b, _c;
|
|
4773
|
-
if (firstCall) {
|
|
4774
|
-
firstCall = false;
|
|
4775
|
-
var dirs = normalizeDirectoryList(this.root);
|
|
4776
|
-
(_a = self.options.root).unshift.apply(_a, __spreadArray([], __read(dirs), false));
|
|
4777
|
-
(_b = self.options.layouts).unshift.apply(_b, __spreadArray([], __read(dirs), false));
|
|
4778
|
-
(_c = self.options.partials).unshift.apply(_c, __spreadArray([], __read(dirs), false));
|
|
4779
|
-
}
|
|
4780
|
-
self.renderFile(filePath, ctx).then(function (html) { return callback(null, html); }, callback);
|
|
4781
|
-
};
|
|
4782
|
-
};
|
|
4783
|
-
return Liquid;
|
|
4784
|
-
}());
|
|
4785
|
-
|
|
4786
|
-
exports.AssertionError = AssertionError;
|
|
4787
|
-
exports.Context = Context;
|
|
4788
|
-
exports.Drop = Drop;
|
|
4789
|
-
exports.Expression = Expression;
|
|
4790
|
-
exports.Hash = Hash;
|
|
4791
|
-
exports.InternalUndefinedVariableError = InternalUndefinedVariableError;
|
|
4792
|
-
exports.Liquid = Liquid;
|
|
4793
|
-
exports.LiquidError = LiquidError;
|
|
4794
|
-
exports.ParseError = ParseError;
|
|
4795
|
-
exports.ParseStream = ParseStream;
|
|
4796
|
-
exports.RenderError = RenderError;
|
|
4797
|
-
exports.TagToken = TagToken;
|
|
4798
|
-
exports.TimezoneDate = TimezoneDate;
|
|
4799
|
-
exports.Token = Token;
|
|
4800
|
-
exports.TokenizationError = TokenizationError;
|
|
4801
|
-
exports.Tokenizer = Tokenizer;
|
|
4802
|
-
exports.TypeGuards = typeGuards;
|
|
4803
|
-
exports.UndefinedVariableError = UndefinedVariableError;
|
|
4804
|
-
exports.Value = Value;
|
|
4805
|
-
exports._evalToken = _evalToken;
|
|
4806
|
-
exports.assert = assert;
|
|
4807
|
-
exports.createTrie = createTrie;
|
|
4808
|
-
exports.defaultOperators = defaultOperators;
|
|
4809
|
-
exports.defaultOptions = defaultOptions;
|
|
4810
|
-
exports.evalQuotedToken = evalQuotedToken;
|
|
4811
|
-
exports.evalToken = evalToken;
|
|
4812
|
-
exports.filters = builtinFilters;
|
|
4813
|
-
exports.isFalsy = isFalsy;
|
|
4814
|
-
exports.isTruthy = isTruthy;
|
|
4815
|
-
exports.tags = index;
|
|
4816
|
-
exports.toPromise = toPromise;
|
|
4817
|
-
exports.toThenable = toThenable;
|
|
4818
|
-
exports.toValue = toValue;
|
|
4819
|
-
exports.toValueSync = toValueSync;
|
|
4820
|
-
exports.version = version;
|