@11ty/client 4.0.0-alpha.1 → 4.0.0-alpha.11
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/README.md +30 -0
- package/dist/{eleventy.js → core-fs.js} +26583 -16308
- package/dist/{eleventy.core.js → core-minimal.js} +9132 -6389
- package/dist/formats/{eleventy-liquid.js → liquid.js} +1235 -996
- package/dist/formats/markdown.js +6014 -0
- package/dist/formats/{eleventy-nunjucks.js → nunjucks.js} +2496 -2579
- package/dist/plugins/plugin-i18n.js +2045 -0
- package/package.json +16 -15
- package/dist/formats/eleventy-markdown.js +0 -5815
- package/dist/plugins/eleventy-plugin-i18n.js +0 -16412
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Eleventy v4.0.0-alpha.
|
|
1
|
+
/*! Eleventy (Build Awesome) v4.0.0-alpha.11 (@11ty/client/liquid Engine Bundle) */
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -12,11 +12,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
12
12
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
13
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
14
|
});
|
|
15
|
-
var __esm = (fn, res) => function __init() {
|
|
16
|
-
|
|
15
|
+
var __esm = (fn, res, err) => function __init() {
|
|
16
|
+
if (err) throw err[0];
|
|
17
|
+
try {
|
|
18
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw err = [e], e;
|
|
21
|
+
}
|
|
17
22
|
};
|
|
18
23
|
var __commonJS = (cb, mod) => function __require2() {
|
|
19
|
-
|
|
24
|
+
try {
|
|
25
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
throw mod = 0, e;
|
|
28
|
+
}
|
|
20
29
|
};
|
|
21
30
|
var __export = (target, all) => {
|
|
22
31
|
for (var name in all)
|
|
@@ -40,559 +49,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
40
49
|
));
|
|
41
50
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
51
|
|
|
43
|
-
// ../../node_modules/moo/moo.js
|
|
44
|
-
var require_moo = __commonJS({
|
|
45
|
-
"../../node_modules/moo/moo.js"(exports, module) {
|
|
46
|
-
(function(root, factory) {
|
|
47
|
-
if (typeof define === "function" && define.amd) {
|
|
48
|
-
define([], factory);
|
|
49
|
-
} else if (typeof module === "object" && module.exports) {
|
|
50
|
-
module.exports = factory();
|
|
51
|
-
} else {
|
|
52
|
-
root.moo = factory();
|
|
53
|
-
}
|
|
54
|
-
})(exports, function() {
|
|
55
|
-
"use strict";
|
|
56
|
-
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
57
|
-
var toString2 = Object.prototype.toString;
|
|
58
|
-
var hasSticky = typeof new RegExp().sticky === "boolean";
|
|
59
|
-
function isRegExp(o) {
|
|
60
|
-
return o && toString2.call(o) === "[object RegExp]";
|
|
61
|
-
}
|
|
62
|
-
__name(isRegExp, "isRegExp");
|
|
63
|
-
function isObject2(o) {
|
|
64
|
-
return o && typeof o === "object" && !isRegExp(o) && !Array.isArray(o);
|
|
65
|
-
}
|
|
66
|
-
__name(isObject2, "isObject");
|
|
67
|
-
function reEscape(s) {
|
|
68
|
-
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
69
|
-
}
|
|
70
|
-
__name(reEscape, "reEscape");
|
|
71
|
-
function reGroups(s) {
|
|
72
|
-
var re = new RegExp("|" + s);
|
|
73
|
-
return re.exec("").length - 1;
|
|
74
|
-
}
|
|
75
|
-
__name(reGroups, "reGroups");
|
|
76
|
-
function reCapture(s) {
|
|
77
|
-
return "(" + s + ")";
|
|
78
|
-
}
|
|
79
|
-
__name(reCapture, "reCapture");
|
|
80
|
-
function reUnion(regexps) {
|
|
81
|
-
if (!regexps.length) return "(?!)";
|
|
82
|
-
var source = regexps.map(function(s) {
|
|
83
|
-
return "(?:" + s + ")";
|
|
84
|
-
}).join("|");
|
|
85
|
-
return "(?:" + source + ")";
|
|
86
|
-
}
|
|
87
|
-
__name(reUnion, "reUnion");
|
|
88
|
-
function regexpOrLiteral(obj) {
|
|
89
|
-
if (typeof obj === "string") {
|
|
90
|
-
return "(?:" + reEscape(obj) + ")";
|
|
91
|
-
} else if (isRegExp(obj)) {
|
|
92
|
-
if (obj.ignoreCase) throw new Error("RegExp /i flag not allowed");
|
|
93
|
-
if (obj.global) throw new Error("RegExp /g flag is implied");
|
|
94
|
-
if (obj.sticky) throw new Error("RegExp /y flag is implied");
|
|
95
|
-
if (obj.multiline) throw new Error("RegExp /m flag is implied");
|
|
96
|
-
return obj.source;
|
|
97
|
-
} else {
|
|
98
|
-
throw new Error("Not a pattern: " + obj);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
__name(regexpOrLiteral, "regexpOrLiteral");
|
|
102
|
-
function pad2(s, length) {
|
|
103
|
-
if (s.length > length) {
|
|
104
|
-
return s;
|
|
105
|
-
}
|
|
106
|
-
return Array(length - s.length + 1).join(" ") + s;
|
|
107
|
-
}
|
|
108
|
-
__name(pad2, "pad");
|
|
109
|
-
function lastNLines(string, numLines) {
|
|
110
|
-
var position = string.length;
|
|
111
|
-
var lineBreaks = 0;
|
|
112
|
-
while (true) {
|
|
113
|
-
var idx = string.lastIndexOf("\n", position - 1);
|
|
114
|
-
if (idx === -1) {
|
|
115
|
-
break;
|
|
116
|
-
} else {
|
|
117
|
-
lineBreaks++;
|
|
118
|
-
}
|
|
119
|
-
position = idx;
|
|
120
|
-
if (lineBreaks === numLines) {
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
if (position === 0) {
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
var startPosition = lineBreaks < numLines ? 0 : position + 1;
|
|
128
|
-
return string.substring(startPosition).split("\n");
|
|
129
|
-
}
|
|
130
|
-
__name(lastNLines, "lastNLines");
|
|
131
|
-
function objectToRules(object) {
|
|
132
|
-
var keys = Object.getOwnPropertyNames(object);
|
|
133
|
-
var result = [];
|
|
134
|
-
for (var i = 0; i < keys.length; i++) {
|
|
135
|
-
var key = keys[i];
|
|
136
|
-
var thing = object[key];
|
|
137
|
-
var rules = [].concat(thing);
|
|
138
|
-
if (key === "include") {
|
|
139
|
-
for (var j = 0; j < rules.length; j++) {
|
|
140
|
-
result.push({ include: rules[j] });
|
|
141
|
-
}
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
var match = [];
|
|
145
|
-
rules.forEach(function(rule) {
|
|
146
|
-
if (isObject2(rule)) {
|
|
147
|
-
if (match.length) result.push(ruleOptions(key, match));
|
|
148
|
-
result.push(ruleOptions(key, rule));
|
|
149
|
-
match = [];
|
|
150
|
-
} else {
|
|
151
|
-
match.push(rule);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
if (match.length) result.push(ruleOptions(key, match));
|
|
155
|
-
}
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
|
-
__name(objectToRules, "objectToRules");
|
|
159
|
-
function arrayToRules(array) {
|
|
160
|
-
var result = [];
|
|
161
|
-
for (var i = 0; i < array.length; i++) {
|
|
162
|
-
var obj = array[i];
|
|
163
|
-
if (obj.include) {
|
|
164
|
-
var include = [].concat(obj.include);
|
|
165
|
-
for (var j = 0; j < include.length; j++) {
|
|
166
|
-
result.push({ include: include[j] });
|
|
167
|
-
}
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (!obj.type) {
|
|
171
|
-
throw new Error("Rule has no type: " + JSON.stringify(obj));
|
|
172
|
-
}
|
|
173
|
-
result.push(ruleOptions(obj.type, obj));
|
|
174
|
-
}
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
__name(arrayToRules, "arrayToRules");
|
|
178
|
-
function ruleOptions(type, obj) {
|
|
179
|
-
if (!isObject2(obj)) {
|
|
180
|
-
obj = { match: obj };
|
|
181
|
-
}
|
|
182
|
-
if (obj.include) {
|
|
183
|
-
throw new Error("Matching rules cannot also include states");
|
|
184
|
-
}
|
|
185
|
-
var options = {
|
|
186
|
-
defaultType: type,
|
|
187
|
-
lineBreaks: !!obj.error || !!obj.fallback,
|
|
188
|
-
pop: false,
|
|
189
|
-
next: null,
|
|
190
|
-
push: null,
|
|
191
|
-
error: false,
|
|
192
|
-
fallback: false,
|
|
193
|
-
value: null,
|
|
194
|
-
type: null,
|
|
195
|
-
shouldThrow: false
|
|
196
|
-
};
|
|
197
|
-
for (var key in obj) {
|
|
198
|
-
if (hasOwnProperty2.call(obj, key)) {
|
|
199
|
-
options[key] = obj[key];
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (typeof options.type === "string" && type !== options.type) {
|
|
203
|
-
throw new Error("Type transform cannot be a string (type '" + options.type + "' for token '" + type + "')");
|
|
204
|
-
}
|
|
205
|
-
var match = options.match;
|
|
206
|
-
options.match = Array.isArray(match) ? match : match ? [match] : [];
|
|
207
|
-
options.match.sort(function(a, b) {
|
|
208
|
-
return isRegExp(a) && isRegExp(b) ? 0 : isRegExp(b) ? -1 : isRegExp(a) ? 1 : b.length - a.length;
|
|
209
|
-
});
|
|
210
|
-
return options;
|
|
211
|
-
}
|
|
212
|
-
__name(ruleOptions, "ruleOptions");
|
|
213
|
-
function toRules(spec) {
|
|
214
|
-
return Array.isArray(spec) ? arrayToRules(spec) : objectToRules(spec);
|
|
215
|
-
}
|
|
216
|
-
__name(toRules, "toRules");
|
|
217
|
-
var defaultErrorRule = ruleOptions("error", { lineBreaks: true, shouldThrow: true });
|
|
218
|
-
function compileRules(rules, hasStates) {
|
|
219
|
-
var errorRule = null;
|
|
220
|
-
var fast = /* @__PURE__ */ Object.create(null);
|
|
221
|
-
var fastAllowed = true;
|
|
222
|
-
var unicodeFlag = null;
|
|
223
|
-
var groups = [];
|
|
224
|
-
var parts = [];
|
|
225
|
-
for (var i = 0; i < rules.length; i++) {
|
|
226
|
-
if (rules[i].fallback) {
|
|
227
|
-
fastAllowed = false;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
for (var i = 0; i < rules.length; i++) {
|
|
231
|
-
var options = rules[i];
|
|
232
|
-
if (options.include) {
|
|
233
|
-
throw new Error("Inheritance is not allowed in stateless lexers");
|
|
234
|
-
}
|
|
235
|
-
if (options.error || options.fallback) {
|
|
236
|
-
if (errorRule) {
|
|
237
|
-
if (!options.fallback === !errorRule.fallback) {
|
|
238
|
-
throw new Error("Multiple " + (options.fallback ? "fallback" : "error") + " rules not allowed (for token '" + options.defaultType + "')");
|
|
239
|
-
} else {
|
|
240
|
-
throw new Error("fallback and error are mutually exclusive (for token '" + options.defaultType + "')");
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
errorRule = options;
|
|
244
|
-
}
|
|
245
|
-
var match = options.match.slice();
|
|
246
|
-
if (fastAllowed) {
|
|
247
|
-
while (match.length && typeof match[0] === "string" && match[0].length === 1) {
|
|
248
|
-
var word = match.shift();
|
|
249
|
-
fast[word.charCodeAt(0)] = options;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (options.pop || options.push || options.next) {
|
|
253
|
-
if (!hasStates) {
|
|
254
|
-
throw new Error("State-switching options are not allowed in stateless lexers (for token '" + options.defaultType + "')");
|
|
255
|
-
}
|
|
256
|
-
if (options.fallback) {
|
|
257
|
-
throw new Error("State-switching options are not allowed on fallback tokens (for token '" + options.defaultType + "')");
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (match.length === 0) {
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
fastAllowed = false;
|
|
264
|
-
groups.push(options);
|
|
265
|
-
for (var j = 0; j < match.length; j++) {
|
|
266
|
-
var obj = match[j];
|
|
267
|
-
if (!isRegExp(obj)) {
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
if (unicodeFlag === null) {
|
|
271
|
-
unicodeFlag = obj.unicode;
|
|
272
|
-
} else if (unicodeFlag !== obj.unicode && options.fallback === false) {
|
|
273
|
-
throw new Error("If one rule is /u then all must be");
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
var pat = reUnion(match.map(regexpOrLiteral));
|
|
277
|
-
var regexp = new RegExp(pat);
|
|
278
|
-
if (regexp.test("")) {
|
|
279
|
-
throw new Error("RegExp matches empty string: " + regexp);
|
|
280
|
-
}
|
|
281
|
-
var groupCount = reGroups(pat);
|
|
282
|
-
if (groupCount > 0) {
|
|
283
|
-
throw new Error("RegExp has capture groups: " + regexp + "\nUse (?: \u2026 ) instead");
|
|
284
|
-
}
|
|
285
|
-
if (!options.lineBreaks && regexp.test("\n")) {
|
|
286
|
-
throw new Error("Rule should declare lineBreaks: " + regexp);
|
|
287
|
-
}
|
|
288
|
-
parts.push(reCapture(pat));
|
|
289
|
-
}
|
|
290
|
-
var fallbackRule = errorRule && errorRule.fallback;
|
|
291
|
-
var flags = hasSticky && !fallbackRule ? "ym" : "gm";
|
|
292
|
-
var suffix = hasSticky || fallbackRule ? "" : "|";
|
|
293
|
-
if (unicodeFlag === true) flags += "u";
|
|
294
|
-
var combined = new RegExp(reUnion(parts) + suffix, flags);
|
|
295
|
-
return { regexp: combined, groups, fast, error: errorRule || defaultErrorRule };
|
|
296
|
-
}
|
|
297
|
-
__name(compileRules, "compileRules");
|
|
298
|
-
function compile(rules) {
|
|
299
|
-
var result = compileRules(toRules(rules));
|
|
300
|
-
return new Lexer({ start: result }, "start");
|
|
301
|
-
}
|
|
302
|
-
__name(compile, "compile");
|
|
303
|
-
function checkStateGroup(g, name, map2) {
|
|
304
|
-
var state = g && (g.push || g.next);
|
|
305
|
-
if (state && !map2[state]) {
|
|
306
|
-
throw new Error("Missing state '" + state + "' (in token '" + g.defaultType + "' of state '" + name + "')");
|
|
307
|
-
}
|
|
308
|
-
if (g && g.pop && +g.pop !== 1) {
|
|
309
|
-
throw new Error("pop must be 1 (in token '" + g.defaultType + "' of state '" + name + "')");
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
__name(checkStateGroup, "checkStateGroup");
|
|
313
|
-
function compileStates(states, start) {
|
|
314
|
-
var all = states.$all ? toRules(states.$all) : [];
|
|
315
|
-
delete states.$all;
|
|
316
|
-
var keys = Object.getOwnPropertyNames(states);
|
|
317
|
-
if (!start) start = keys[0];
|
|
318
|
-
var ruleMap = /* @__PURE__ */ Object.create(null);
|
|
319
|
-
for (var i = 0; i < keys.length; i++) {
|
|
320
|
-
var key = keys[i];
|
|
321
|
-
ruleMap[key] = toRules(states[key]).concat(all);
|
|
322
|
-
}
|
|
323
|
-
for (var i = 0; i < keys.length; i++) {
|
|
324
|
-
var key = keys[i];
|
|
325
|
-
var rules = ruleMap[key];
|
|
326
|
-
var included = /* @__PURE__ */ Object.create(null);
|
|
327
|
-
for (var j = 0; j < rules.length; j++) {
|
|
328
|
-
var rule = rules[j];
|
|
329
|
-
if (!rule.include) continue;
|
|
330
|
-
var splice = [j, 1];
|
|
331
|
-
if (rule.include !== key && !included[rule.include]) {
|
|
332
|
-
included[rule.include] = true;
|
|
333
|
-
var newRules = ruleMap[rule.include];
|
|
334
|
-
if (!newRules) {
|
|
335
|
-
throw new Error("Cannot include nonexistent state '" + rule.include + "' (in state '" + key + "')");
|
|
336
|
-
}
|
|
337
|
-
for (var k = 0; k < newRules.length; k++) {
|
|
338
|
-
var newRule = newRules[k];
|
|
339
|
-
if (rules.indexOf(newRule) !== -1) continue;
|
|
340
|
-
splice.push(newRule);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
rules.splice.apply(rules, splice);
|
|
344
|
-
j--;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
var map2 = /* @__PURE__ */ Object.create(null);
|
|
348
|
-
for (var i = 0; i < keys.length; i++) {
|
|
349
|
-
var key = keys[i];
|
|
350
|
-
map2[key] = compileRules(ruleMap[key], true);
|
|
351
|
-
}
|
|
352
|
-
for (var i = 0; i < keys.length; i++) {
|
|
353
|
-
var name = keys[i];
|
|
354
|
-
var state = map2[name];
|
|
355
|
-
var groups = state.groups;
|
|
356
|
-
for (var j = 0; j < groups.length; j++) {
|
|
357
|
-
checkStateGroup(groups[j], name, map2);
|
|
358
|
-
}
|
|
359
|
-
var fastKeys = Object.getOwnPropertyNames(state.fast);
|
|
360
|
-
for (var j = 0; j < fastKeys.length; j++) {
|
|
361
|
-
checkStateGroup(state.fast[fastKeys[j]], name, map2);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return new Lexer(map2, start);
|
|
365
|
-
}
|
|
366
|
-
__name(compileStates, "compileStates");
|
|
367
|
-
function keywordTransform(map2) {
|
|
368
|
-
var isMap = typeof Map !== "undefined";
|
|
369
|
-
var reverseMap = isMap ? /* @__PURE__ */ new Map() : /* @__PURE__ */ Object.create(null);
|
|
370
|
-
var types = Object.getOwnPropertyNames(map2);
|
|
371
|
-
for (var i = 0; i < types.length; i++) {
|
|
372
|
-
var tokenType = types[i];
|
|
373
|
-
var item = map2[tokenType];
|
|
374
|
-
var keywordList = Array.isArray(item) ? item : [item];
|
|
375
|
-
keywordList.forEach(function(keyword) {
|
|
376
|
-
if (typeof keyword !== "string") {
|
|
377
|
-
throw new Error("keyword must be string (in keyword '" + tokenType + "')");
|
|
378
|
-
}
|
|
379
|
-
if (isMap) {
|
|
380
|
-
reverseMap.set(keyword, tokenType);
|
|
381
|
-
} else {
|
|
382
|
-
reverseMap[keyword] = tokenType;
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
return function(k) {
|
|
387
|
-
return isMap ? reverseMap.get(k) : reverseMap[k];
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
__name(keywordTransform, "keywordTransform");
|
|
391
|
-
var Lexer = /* @__PURE__ */ __name(function(states, state) {
|
|
392
|
-
this.startState = state;
|
|
393
|
-
this.states = states;
|
|
394
|
-
this.buffer = "";
|
|
395
|
-
this.stack = [];
|
|
396
|
-
this.reset();
|
|
397
|
-
}, "Lexer");
|
|
398
|
-
Lexer.prototype.reset = function(data, info) {
|
|
399
|
-
this.buffer = data || "";
|
|
400
|
-
this.index = 0;
|
|
401
|
-
this.line = info ? info.line : 1;
|
|
402
|
-
this.col = info ? info.col : 1;
|
|
403
|
-
this.queuedToken = info ? info.queuedToken : null;
|
|
404
|
-
this.queuedText = info ? info.queuedText : "";
|
|
405
|
-
this.queuedThrow = info ? info.queuedThrow : null;
|
|
406
|
-
this.setState(info ? info.state : this.startState);
|
|
407
|
-
this.stack = info && info.stack ? info.stack.slice() : [];
|
|
408
|
-
return this;
|
|
409
|
-
};
|
|
410
|
-
Lexer.prototype.save = function() {
|
|
411
|
-
return {
|
|
412
|
-
line: this.line,
|
|
413
|
-
col: this.col,
|
|
414
|
-
state: this.state,
|
|
415
|
-
stack: this.stack.slice(),
|
|
416
|
-
queuedToken: this.queuedToken,
|
|
417
|
-
queuedText: this.queuedText,
|
|
418
|
-
queuedThrow: this.queuedThrow
|
|
419
|
-
};
|
|
420
|
-
};
|
|
421
|
-
Lexer.prototype.setState = function(state) {
|
|
422
|
-
if (!state || this.state === state) return;
|
|
423
|
-
this.state = state;
|
|
424
|
-
var info = this.states[state];
|
|
425
|
-
this.groups = info.groups;
|
|
426
|
-
this.error = info.error;
|
|
427
|
-
this.re = info.regexp;
|
|
428
|
-
this.fast = info.fast;
|
|
429
|
-
};
|
|
430
|
-
Lexer.prototype.popState = function() {
|
|
431
|
-
this.setState(this.stack.pop());
|
|
432
|
-
};
|
|
433
|
-
Lexer.prototype.pushState = function(state) {
|
|
434
|
-
this.stack.push(this.state);
|
|
435
|
-
this.setState(state);
|
|
436
|
-
};
|
|
437
|
-
var eat = hasSticky ? function(re, buffer) {
|
|
438
|
-
return re.exec(buffer);
|
|
439
|
-
} : function(re, buffer) {
|
|
440
|
-
var match = re.exec(buffer);
|
|
441
|
-
if (match[0].length === 0) {
|
|
442
|
-
return null;
|
|
443
|
-
}
|
|
444
|
-
return match;
|
|
445
|
-
};
|
|
446
|
-
Lexer.prototype._getGroup = function(match) {
|
|
447
|
-
var groupCount = this.groups.length;
|
|
448
|
-
for (var i = 0; i < groupCount; i++) {
|
|
449
|
-
if (match[i + 1] !== void 0) {
|
|
450
|
-
return this.groups[i];
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
throw new Error("Cannot find token type for matched text");
|
|
454
|
-
};
|
|
455
|
-
function tokenToString() {
|
|
456
|
-
return this.value;
|
|
457
|
-
}
|
|
458
|
-
__name(tokenToString, "tokenToString");
|
|
459
|
-
Lexer.prototype.next = function() {
|
|
460
|
-
var index = this.index;
|
|
461
|
-
if (this.queuedGroup) {
|
|
462
|
-
var token = this._token(this.queuedGroup, this.queuedText, index);
|
|
463
|
-
this.queuedGroup = null;
|
|
464
|
-
this.queuedText = "";
|
|
465
|
-
return token;
|
|
466
|
-
}
|
|
467
|
-
var buffer = this.buffer;
|
|
468
|
-
if (index === buffer.length) {
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
var group = this.fast[buffer.charCodeAt(index)];
|
|
472
|
-
if (group) {
|
|
473
|
-
return this._token(group, buffer.charAt(index), index);
|
|
474
|
-
}
|
|
475
|
-
var re = this.re;
|
|
476
|
-
re.lastIndex = index;
|
|
477
|
-
var match = eat(re, buffer);
|
|
478
|
-
var error = this.error;
|
|
479
|
-
if (match == null) {
|
|
480
|
-
return this._token(error, buffer.slice(index, buffer.length), index);
|
|
481
|
-
}
|
|
482
|
-
var group = this._getGroup(match);
|
|
483
|
-
var text = match[0];
|
|
484
|
-
if (error.fallback && match.index !== index) {
|
|
485
|
-
this.queuedGroup = group;
|
|
486
|
-
this.queuedText = text;
|
|
487
|
-
return this._token(error, buffer.slice(index, match.index), index);
|
|
488
|
-
}
|
|
489
|
-
return this._token(group, text, index);
|
|
490
|
-
};
|
|
491
|
-
Lexer.prototype._token = function(group, text, offset2) {
|
|
492
|
-
var lineBreaks = 0;
|
|
493
|
-
if (group.lineBreaks) {
|
|
494
|
-
var matchNL = /\n/g;
|
|
495
|
-
var nl = 1;
|
|
496
|
-
if (text === "\n") {
|
|
497
|
-
lineBreaks = 1;
|
|
498
|
-
} else {
|
|
499
|
-
while (matchNL.exec(text)) {
|
|
500
|
-
lineBreaks++;
|
|
501
|
-
nl = matchNL.lastIndex;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
var token = {
|
|
506
|
-
type: typeof group.type === "function" && group.type(text) || group.defaultType,
|
|
507
|
-
value: typeof group.value === "function" ? group.value(text) : text,
|
|
508
|
-
text,
|
|
509
|
-
toString: tokenToString,
|
|
510
|
-
offset: offset2,
|
|
511
|
-
lineBreaks,
|
|
512
|
-
line: this.line,
|
|
513
|
-
col: this.col
|
|
514
|
-
};
|
|
515
|
-
var size2 = text.length;
|
|
516
|
-
this.index += size2;
|
|
517
|
-
this.line += lineBreaks;
|
|
518
|
-
if (lineBreaks !== 0) {
|
|
519
|
-
this.col = size2 - nl + 1;
|
|
520
|
-
} else {
|
|
521
|
-
this.col += size2;
|
|
522
|
-
}
|
|
523
|
-
if (group.shouldThrow) {
|
|
524
|
-
var err = new Error(this.formatError(token, "invalid syntax"));
|
|
525
|
-
throw err;
|
|
526
|
-
}
|
|
527
|
-
if (group.pop) this.popState();
|
|
528
|
-
else if (group.push) this.pushState(group.push);
|
|
529
|
-
else if (group.next) this.setState(group.next);
|
|
530
|
-
return token;
|
|
531
|
-
};
|
|
532
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator) {
|
|
533
|
-
var LexerIterator = /* @__PURE__ */ __name(function(lexer) {
|
|
534
|
-
this.lexer = lexer;
|
|
535
|
-
}, "LexerIterator");
|
|
536
|
-
LexerIterator.prototype.next = function() {
|
|
537
|
-
var token = this.lexer.next();
|
|
538
|
-
return { value: token, done: !token };
|
|
539
|
-
};
|
|
540
|
-
LexerIterator.prototype[Symbol.iterator] = function() {
|
|
541
|
-
return this;
|
|
542
|
-
};
|
|
543
|
-
Lexer.prototype[Symbol.iterator] = function() {
|
|
544
|
-
return new LexerIterator(this);
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
Lexer.prototype.formatError = function(token, message) {
|
|
548
|
-
if (token == null) {
|
|
549
|
-
var text = this.buffer.slice(this.index);
|
|
550
|
-
var token = {
|
|
551
|
-
text,
|
|
552
|
-
offset: this.index,
|
|
553
|
-
lineBreaks: text.indexOf("\n") === -1 ? 0 : 1,
|
|
554
|
-
line: this.line,
|
|
555
|
-
col: this.col
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
var numLinesAround = 2;
|
|
559
|
-
var firstDisplayedLine = Math.max(token.line - numLinesAround, 1);
|
|
560
|
-
var lastDisplayedLine = token.line + numLinesAround;
|
|
561
|
-
var lastLineDigits = String(lastDisplayedLine).length;
|
|
562
|
-
var displayedLines = lastNLines(
|
|
563
|
-
this.buffer,
|
|
564
|
-
this.line - token.line + numLinesAround + 1
|
|
565
|
-
).slice(0, 5);
|
|
566
|
-
var errorLines = [];
|
|
567
|
-
errorLines.push(message + " at line " + token.line + " col " + token.col + ":");
|
|
568
|
-
errorLines.push("");
|
|
569
|
-
for (var i = 0; i < displayedLines.length; i++) {
|
|
570
|
-
var line = displayedLines[i];
|
|
571
|
-
var lineNo = firstDisplayedLine + i;
|
|
572
|
-
errorLines.push(pad2(String(lineNo), lastLineDigits) + " " + line);
|
|
573
|
-
if (lineNo === token.line) {
|
|
574
|
-
errorLines.push(pad2("", lastLineDigits + token.col + 1) + "^");
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
return errorLines.join("\n");
|
|
578
|
-
};
|
|
579
|
-
Lexer.prototype.clone = function() {
|
|
580
|
-
return new Lexer(this.states, this.state);
|
|
581
|
-
};
|
|
582
|
-
Lexer.prototype.has = function(tokenType) {
|
|
583
|
-
return true;
|
|
584
|
-
};
|
|
585
|
-
return {
|
|
586
|
-
compile,
|
|
587
|
-
states: compileStates,
|
|
588
|
-
error: Object.freeze({ error: true }),
|
|
589
|
-
fallback: Object.freeze({ fallback: true }),
|
|
590
|
-
keywords: keywordTransform
|
|
591
|
-
};
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
|
|
596
52
|
// ../../node_modules/path/node_modules/util/support/isBufferBrowser.js
|
|
597
53
|
var require_isBufferBrowser = __commonJS({
|
|
598
54
|
"../../node_modules/path/node_modules/util/support/isBufferBrowser.js"(exports, module) {
|
|
@@ -1512,14 +968,19 @@ __export(shim_consume_fs_exports, {
|
|
|
1512
968
|
promises: () => promises,
|
|
1513
969
|
readFileSync: () => readFileSync2,
|
|
1514
970
|
readSync: () => readSync,
|
|
971
|
+
readdir: () => readdir,
|
|
972
|
+
readdirSync: () => readdirSync,
|
|
973
|
+
realpath: () => realpath,
|
|
974
|
+
realpathSync: () => realpathSync,
|
|
975
|
+
stat: () => stat,
|
|
1515
976
|
statSync: () => statSync,
|
|
1516
977
|
writeFileSync: () => writeFileSync
|
|
1517
978
|
});
|
|
1518
|
-
var GLOBAL_FS_NAME, fs2, mkdir, existsSync2, mkdirSync, readFileSync2, statSync, writeFileSync, promises, readSync, fstatSync, closeSync, openSync, shim_consume_fs_default;
|
|
979
|
+
var GLOBAL_FS_NAME, fs2, mkdir, existsSync2, mkdirSync, readFileSync2, statSync, writeFileSync, promises, readSync, fstatSync, closeSync, openSync, readdir, readdirSync, realpath, realpathSync, stat, shim_consume_fs_default;
|
|
1519
980
|
var init_shim_consume_fs = __esm({
|
|
1520
981
|
"../../node_modules/@11ty/package-bundler/shims/shim-consume-fs.js"() {
|
|
1521
982
|
GLOBAL_FS_NAME = "eleventyFileSystem";
|
|
1522
|
-
fs2 = window[GLOBAL_FS_NAME] || globalThis[GLOBAL_FS_NAME];
|
|
983
|
+
fs2 = typeof window !== "undefined" && window[GLOBAL_FS_NAME] || typeof globalThis !== "undefined" && globalThis[GLOBAL_FS_NAME];
|
|
1523
984
|
if (!fs2) {
|
|
1524
985
|
let noopError = function() {
|
|
1525
986
|
throw new Error("This function was not included in your Eleventy bundle. Make sure you load memfs.js before using the virtual file system.");
|
|
@@ -1537,7 +998,13 @@ var init_shim_consume_fs = __esm({
|
|
|
1537
998
|
readSync: noopError,
|
|
1538
999
|
fstatSync: noopError,
|
|
1539
1000
|
closeSync: noopError,
|
|
1540
|
-
openSync: noopError
|
|
1001
|
+
openSync: noopError,
|
|
1002
|
+
// tinyglobby
|
|
1003
|
+
readdir: noopError,
|
|
1004
|
+
readdirSync: noopError,
|
|
1005
|
+
realpath: noopError,
|
|
1006
|
+
realpathSync: noopError,
|
|
1007
|
+
stat: noopError
|
|
1541
1008
|
};
|
|
1542
1009
|
}
|
|
1543
1010
|
mkdir = fs2.mkdir;
|
|
@@ -1551,6 +1018,11 @@ var init_shim_consume_fs = __esm({
|
|
|
1551
1018
|
fstatSync = fs2.fstatSync;
|
|
1552
1019
|
closeSync = fs2.closeSync;
|
|
1553
1020
|
openSync = fs2.openSync;
|
|
1021
|
+
readdir = fs2.readdir;
|
|
1022
|
+
readdirSync = fs2.readdirSync;
|
|
1023
|
+
realpath = fs2.realpath;
|
|
1024
|
+
realpathSync = fs2.realpathSync;
|
|
1025
|
+
stat = fs2.stat;
|
|
1554
1026
|
shim_consume_fs_default = fs2;
|
|
1555
1027
|
}
|
|
1556
1028
|
});
|
|
@@ -1643,18 +1115,30 @@ var require_TemplatePath = __commonJS({
|
|
|
1643
1115
|
TemplatePath2.stripLeadingDotSlash = function(path2) {
|
|
1644
1116
|
return typeof path2 === "string" ? path2.replace(/^\.\//, "") : path2;
|
|
1645
1117
|
};
|
|
1118
|
+
function getSubPathRemainder(filePath, subPath) {
|
|
1119
|
+
if (filePath === subPath) {
|
|
1120
|
+
return "";
|
|
1121
|
+
}
|
|
1122
|
+
if (subPath === ".") {
|
|
1123
|
+
let isOutside = filePath === ".." || filePath.startsWith("../") || path.isAbsolute(filePath);
|
|
1124
|
+
return isOutside ? void 0 : filePath;
|
|
1125
|
+
}
|
|
1126
|
+
let prefix = subPath.endsWith("/") ? subPath : `${subPath}/`;
|
|
1127
|
+
return filePath.startsWith(prefix) ? filePath.slice(prefix.length) : void 0;
|
|
1128
|
+
}
|
|
1129
|
+
__name(getSubPathRemainder, "getSubPathRemainder");
|
|
1646
1130
|
TemplatePath2.startsWithSubPath = function(path2, subPath) {
|
|
1647
1131
|
path2 = TemplatePath2.normalize(path2);
|
|
1648
1132
|
subPath = TemplatePath2.normalize(subPath);
|
|
1649
|
-
return path2
|
|
1133
|
+
return getSubPathRemainder(path2, subPath) !== void 0;
|
|
1650
1134
|
};
|
|
1651
1135
|
TemplatePath2.stripLeadingSubPath = function(path2, subPath) {
|
|
1652
1136
|
path2 = TemplatePath2.normalize(path2);
|
|
1653
1137
|
subPath = TemplatePath2.normalize(subPath);
|
|
1654
|
-
if (subPath
|
|
1655
|
-
return path2
|
|
1138
|
+
if (subPath === ".") {
|
|
1139
|
+
return path2;
|
|
1656
1140
|
}
|
|
1657
|
-
return path2;
|
|
1141
|
+
return getSubPathRemainder(path2, subPath) ?? path2;
|
|
1658
1142
|
};
|
|
1659
1143
|
TemplatePath2.isDirectorySync = function(path2) {
|
|
1660
1144
|
return fs3.existsSync(path2) && fs3.statSync(path2).isDirectory();
|
|
@@ -1716,7 +1200,7 @@ var require_TemplatePath = __commonJS({
|
|
|
1716
1200
|
var require_IsPlainObject = __commonJS({
|
|
1717
1201
|
"../../node_modules/@11ty/eleventy-utils/src/IsPlainObject.js"(exports, module) {
|
|
1718
1202
|
module.exports = function(value) {
|
|
1719
|
-
if (value === null || typeof value !== "object") {
|
|
1203
|
+
if (value === null || typeof value !== "object" || value === Object.prototype) {
|
|
1720
1204
|
return false;
|
|
1721
1205
|
}
|
|
1722
1206
|
let proto = Object.getPrototypeOf(value);
|
|
@@ -1731,6 +1215,7 @@ var require_Merge = __commonJS({
|
|
|
1731
1215
|
"use strict";
|
|
1732
1216
|
var isPlainObject = require_IsPlainObject();
|
|
1733
1217
|
var OVERRIDE_PREFIX = "override:";
|
|
1218
|
+
var UNSAFE_KEY = "__proto__";
|
|
1734
1219
|
function cleanKey(key, prefix) {
|
|
1735
1220
|
if (prefix && key.startsWith(prefix)) {
|
|
1736
1221
|
return key.slice(prefix.length);
|
|
@@ -1740,21 +1225,29 @@ var require_Merge = __commonJS({
|
|
|
1740
1225
|
__name(cleanKey, "cleanKey");
|
|
1741
1226
|
function getMergedItem(target, source, prefixes = {}) {
|
|
1742
1227
|
let { override } = prefixes;
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
sourcePlainObjectShortcut
|
|
1228
|
+
let sourcePlainObjectShortcut = isPlainObject(source);
|
|
1229
|
+
let targetPlainObjectShortcut = false;
|
|
1230
|
+
if (!target) {
|
|
1231
|
+
if (Object.isFrozen(source)) {
|
|
1232
|
+
return source;
|
|
1233
|
+
}
|
|
1234
|
+
if (sourcePlainObjectShortcut) {
|
|
1235
|
+
targetPlainObjectShortcut = true;
|
|
1236
|
+
target = {};
|
|
1237
|
+
}
|
|
1750
1238
|
}
|
|
1751
1239
|
if (Array.isArray(target) && Array.isArray(source)) {
|
|
1752
1240
|
return target.concat(source);
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1241
|
+
}
|
|
1242
|
+
if (targetPlainObjectShortcut || isPlainObject(target)) {
|
|
1243
|
+
if (sourcePlainObjectShortcut) {
|
|
1755
1244
|
for (let key in source) {
|
|
1756
1245
|
let overrideKey = cleanKey(key, override);
|
|
1757
|
-
|
|
1246
|
+
if (overrideKey === UNSAFE_KEY) {
|
|
1247
|
+
continue;
|
|
1248
|
+
}
|
|
1249
|
+
let targetValue = Object.hasOwn(target, key) ? target[key] : void 0;
|
|
1250
|
+
target[overrideKey] = getMergedItem(targetValue, source[key], prefixes);
|
|
1758
1251
|
}
|
|
1759
1252
|
}
|
|
1760
1253
|
return target;
|
|
@@ -1776,7 +1269,10 @@ var require_Merge = __commonJS({
|
|
|
1776
1269
|
if (isPlainObject(target)) {
|
|
1777
1270
|
for (let key in target) {
|
|
1778
1271
|
if (key.indexOf(OVERRIDE_PREFIX) === 0) {
|
|
1779
|
-
|
|
1272
|
+
let cleanedKey = key.slice(OVERRIDE_PREFIX.length);
|
|
1273
|
+
if (cleanedKey !== UNSAFE_KEY) {
|
|
1274
|
+
target[cleanedKey] = target[key];
|
|
1275
|
+
}
|
|
1780
1276
|
delete target[key];
|
|
1781
1277
|
}
|
|
1782
1278
|
}
|
|
@@ -1857,26 +1353,10 @@ var require_Url = __commonJS({
|
|
|
1857
1353
|
}
|
|
1858
1354
|
});
|
|
1859
1355
|
|
|
1860
|
-
// ../../node_modules/@11ty/eleventy-utils/src/Buffer.js
|
|
1861
|
-
var require_Buffer = __commonJS({
|
|
1862
|
-
"../../node_modules/@11ty/eleventy-utils/src/Buffer.js"(exports, module) {
|
|
1863
|
-
function isBuffer(inst) {
|
|
1864
|
-
if (typeof Buffer !== "undefined") {
|
|
1865
|
-
return Buffer.isBuffer(inst);
|
|
1866
|
-
}
|
|
1867
|
-
return inst instanceof Uint8Array;
|
|
1868
|
-
}
|
|
1869
|
-
__name(isBuffer, "isBuffer");
|
|
1870
|
-
module.exports = {
|
|
1871
|
-
isBuffer
|
|
1872
|
-
};
|
|
1873
|
-
}
|
|
1874
|
-
});
|
|
1875
|
-
|
|
1876
1356
|
// ../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js
|
|
1877
1357
|
var require_lib_sha256 = __commonJS({
|
|
1878
1358
|
"../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js"(exports, module) {
|
|
1879
|
-
module.exports = /* @__PURE__ */ __name(function
|
|
1359
|
+
module.exports = /* @__PURE__ */ __name(function sha2562(data) {
|
|
1880
1360
|
let h0 = 1779033703, h1 = 3144134277, h2 = 1013904242, h3 = 2773480762, h4 = 1359893119, h5 = 2600822924, h6 = 528734635, h7 = 1541459225, tsz = 0, bp = 0;
|
|
1881
1361
|
const k = [
|
|
1882
1362
|
1116352408,
|
|
@@ -2049,8 +1529,7 @@ var require_lib_sha256 = __commonJS({
|
|
|
2049
1529
|
var require_HashTypes = __commonJS({
|
|
2050
1530
|
"../../node_modules/@11ty/eleventy-utils/src/HashTypes.js"(exports, module) {
|
|
2051
1531
|
var { base64UrlSafe } = require_Url();
|
|
2052
|
-
var
|
|
2053
|
-
var sha256 = require_lib_sha256();
|
|
1532
|
+
var sha2562 = require_lib_sha256();
|
|
2054
1533
|
function hasNodeCryptoModule() {
|
|
2055
1534
|
try {
|
|
2056
1535
|
__require("node:crypto");
|
|
@@ -2113,7 +1592,7 @@ var require_HashTypes = __commonJS({
|
|
|
2113
1592
|
static async toHash(...content) {
|
|
2114
1593
|
let encoder = new TextEncoder();
|
|
2115
1594
|
let input = this.mergeUint8Array(...content.map((c) => {
|
|
2116
|
-
if (
|
|
1595
|
+
if (c instanceof Uint8Array) {
|
|
2117
1596
|
return c;
|
|
2118
1597
|
}
|
|
2119
1598
|
return encoder.encode(c);
|
|
@@ -2165,7 +1644,7 @@ var require_HashTypes = __commonJS({
|
|
|
2165
1644
|
__name(this, "ScriptHash");
|
|
2166
1645
|
}
|
|
2167
1646
|
static toHash(...content) {
|
|
2168
|
-
let hash =
|
|
1647
|
+
let hash = sha2562();
|
|
2169
1648
|
for (let c of content) {
|
|
2170
1649
|
hash.add(c);
|
|
2171
1650
|
}
|
|
@@ -2216,6 +1695,22 @@ var require_CreateHash = __commonJS({
|
|
|
2216
1695
|
}
|
|
2217
1696
|
});
|
|
2218
1697
|
|
|
1698
|
+
// ../../node_modules/@11ty/eleventy-utils/src/Buffer.js
|
|
1699
|
+
var require_Buffer = __commonJS({
|
|
1700
|
+
"../../node_modules/@11ty/eleventy-utils/src/Buffer.js"(exports, module) {
|
|
1701
|
+
function isBuffer(inst) {
|
|
1702
|
+
if (typeof Buffer !== "undefined") {
|
|
1703
|
+
return Buffer.isBuffer(inst);
|
|
1704
|
+
}
|
|
1705
|
+
return inst instanceof Uint8Array;
|
|
1706
|
+
}
|
|
1707
|
+
__name(isBuffer, "isBuffer");
|
|
1708
|
+
module.exports = {
|
|
1709
|
+
isBuffer
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
|
|
2219
1714
|
// ../../node_modules/@11ty/eleventy-utils/index.js
|
|
2220
1715
|
var require_eleventy_utils = __commonJS({
|
|
2221
1716
|
"../../node_modules/@11ty/eleventy-utils/index.js"(exports, module) {
|
|
@@ -2241,9 +1736,6 @@ var require_eleventy_utils = __commonJS({
|
|
|
2241
1736
|
}
|
|
2242
1737
|
});
|
|
2243
1738
|
|
|
2244
|
-
// ../../src/Engines/Liquid.js
|
|
2245
|
-
var import_moo = __toESM(require_moo(), 1);
|
|
2246
|
-
|
|
2247
1739
|
// ../../node_modules/liquidjs/dist/liquid.browser.mjs
|
|
2248
1740
|
var Token = class {
|
|
2249
1741
|
static {
|
|
@@ -2278,7 +1770,7 @@ var Drop = class {
|
|
|
2278
1770
|
static {
|
|
2279
1771
|
__name(this, "Drop");
|
|
2280
1772
|
}
|
|
2281
|
-
liquidMethodMissing(key) {
|
|
1773
|
+
liquidMethodMissing(key, context) {
|
|
2282
1774
|
return void 0;
|
|
2283
1775
|
}
|
|
2284
1776
|
};
|
|
@@ -2301,10 +1793,6 @@ function isIterator(val) {
|
|
|
2301
1793
|
return val && isFunction(val.next) && isFunction(val.throw) && isFunction(val.return);
|
|
2302
1794
|
}
|
|
2303
1795
|
__name(isIterator, "isIterator");
|
|
2304
|
-
function escapeRegex(str) {
|
|
2305
|
-
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
2306
|
-
}
|
|
2307
|
-
__name(escapeRegex, "escapeRegex");
|
|
2308
1796
|
function stringify(value) {
|
|
2309
1797
|
value = toValue(value);
|
|
2310
1798
|
if (isString(value))
|
|
@@ -2316,6 +1804,28 @@ function stringify(value) {
|
|
|
2316
1804
|
return String(value);
|
|
2317
1805
|
}
|
|
2318
1806
|
__name(stringify, "stringify");
|
|
1807
|
+
function advanceCodePoints(str, from, count) {
|
|
1808
|
+
let index = from;
|
|
1809
|
+
for (let i = 0; i < count && index < str.length; i++)
|
|
1810
|
+
index += str.codePointAt(index) > 65535 ? 2 : 1;
|
|
1811
|
+
return index;
|
|
1812
|
+
}
|
|
1813
|
+
__name(advanceCodePoints, "advanceCodePoints");
|
|
1814
|
+
function codePointLength(str) {
|
|
1815
|
+
let length = 0;
|
|
1816
|
+
for (let index = 0; index < str.length; index = advanceCodePoints(str, index, 1))
|
|
1817
|
+
length++;
|
|
1818
|
+
return length;
|
|
1819
|
+
}
|
|
1820
|
+
__name(codePointLength, "codePointLength");
|
|
1821
|
+
function readArrayElement(arr, index, ownPropertyOnly) {
|
|
1822
|
+
if (index < 0)
|
|
1823
|
+
index = arr.length + index;
|
|
1824
|
+
if (ownPropertyOnly && !hasOwnProperty.call(arr, index))
|
|
1825
|
+
return void 0;
|
|
1826
|
+
return arr[index];
|
|
1827
|
+
}
|
|
1828
|
+
__name(readArrayElement, "readArrayElement");
|
|
2319
1829
|
function toEnumerable(val) {
|
|
2320
1830
|
val = toValue(val);
|
|
2321
1831
|
if (isArray(val))
|
|
@@ -2343,8 +1853,7 @@ function toValue(value) {
|
|
|
2343
1853
|
}
|
|
2344
1854
|
__name(toValue, "toValue");
|
|
2345
1855
|
function toNumber(value) {
|
|
2346
|
-
|
|
2347
|
-
return isNaN(value) ? 0 : value;
|
|
1856
|
+
return +toValue(value) || 0;
|
|
2348
1857
|
}
|
|
2349
1858
|
__name(toNumber, "toNumber");
|
|
2350
1859
|
function isNumber(value) {
|
|
@@ -2415,10 +1924,10 @@ function padEnd(str, length, ch = " ") {
|
|
|
2415
1924
|
__name(padEnd, "padEnd");
|
|
2416
1925
|
function pad(str, length, ch, add) {
|
|
2417
1926
|
str = String(str);
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
return str;
|
|
1927
|
+
const n = length - str.length;
|
|
1928
|
+
if (n <= 0)
|
|
1929
|
+
return str;
|
|
1930
|
+
return add(str, ch.repeat(n));
|
|
2422
1931
|
}
|
|
2423
1932
|
__name(pad, "pad");
|
|
2424
1933
|
function identify(val) {
|
|
@@ -2434,12 +1943,26 @@ function ellipsis(str, N) {
|
|
|
2434
1943
|
return str.length > N ? str.slice(0, N - 3) + "..." : str;
|
|
2435
1944
|
}
|
|
2436
1945
|
__name(ellipsis, "ellipsis");
|
|
1946
|
+
function orderedCompare(a, b) {
|
|
1947
|
+
if (isNil(a) && isNil(b))
|
|
1948
|
+
return 0;
|
|
1949
|
+
if (isNil(a))
|
|
1950
|
+
return 1;
|
|
1951
|
+
if (isNil(b))
|
|
1952
|
+
return -1;
|
|
1953
|
+
if (a < b)
|
|
1954
|
+
return -1;
|
|
1955
|
+
if (a > b)
|
|
1956
|
+
return 1;
|
|
1957
|
+
return 0;
|
|
1958
|
+
}
|
|
1959
|
+
__name(orderedCompare, "orderedCompare");
|
|
2437
1960
|
function caseInsensitiveCompare(a, b) {
|
|
2438
|
-
if (a
|
|
1961
|
+
if (isNil(a) && isNil(b))
|
|
2439
1962
|
return 0;
|
|
2440
|
-
if (a
|
|
1963
|
+
if (isNil(a))
|
|
2441
1964
|
return 1;
|
|
2442
|
-
if (b
|
|
1965
|
+
if (isNil(b))
|
|
2443
1966
|
return -1;
|
|
2444
1967
|
a = toLowerCase.call(a);
|
|
2445
1968
|
b = toLowerCase.call(b);
|
|
@@ -2456,10 +1979,12 @@ function argumentsToValue(fn) {
|
|
|
2456
1979
|
};
|
|
2457
1980
|
}
|
|
2458
1981
|
__name(argumentsToValue, "argumentsToValue");
|
|
2459
|
-
function
|
|
2460
|
-
return
|
|
1982
|
+
function argumentsToNumber(fn) {
|
|
1983
|
+
return function(...args) {
|
|
1984
|
+
return fn.call(this, ...args.map(toNumber));
|
|
1985
|
+
};
|
|
2461
1986
|
}
|
|
2462
|
-
__name(
|
|
1987
|
+
__name(argumentsToNumber, "argumentsToNumber");
|
|
2463
1988
|
function* strictUniq(array) {
|
|
2464
1989
|
const seen = /* @__PURE__ */ new Set();
|
|
2465
1990
|
for (const element of array) {
|
|
@@ -2632,8 +2157,8 @@ var NullDrop = class extends Drop {
|
|
|
2632
2157
|
static {
|
|
2633
2158
|
__name(this, "NullDrop");
|
|
2634
2159
|
}
|
|
2635
|
-
equals(value) {
|
|
2636
|
-
return isNil(toValue(value));
|
|
2160
|
+
*equals(value) {
|
|
2161
|
+
return isNil(yield toValue(value));
|
|
2637
2162
|
}
|
|
2638
2163
|
gt() {
|
|
2639
2164
|
return false;
|
|
@@ -2655,10 +2180,10 @@ var EmptyDrop = class _EmptyDrop extends Drop {
|
|
|
2655
2180
|
static {
|
|
2656
2181
|
__name(this, "EmptyDrop");
|
|
2657
2182
|
}
|
|
2658
|
-
equals(value) {
|
|
2183
|
+
*equals(value) {
|
|
2659
2184
|
if (value instanceof _EmptyDrop)
|
|
2660
2185
|
return false;
|
|
2661
|
-
value = toValue(value);
|
|
2186
|
+
value = yield toValue(value);
|
|
2662
2187
|
if (isString(value) || isArray(value))
|
|
2663
2188
|
return value.length === 0;
|
|
2664
2189
|
if (isObject(value))
|
|
@@ -2688,14 +2213,14 @@ var BlankDrop = class _BlankDrop extends EmptyDrop {
|
|
|
2688
2213
|
static {
|
|
2689
2214
|
__name(this, "BlankDrop");
|
|
2690
2215
|
}
|
|
2691
|
-
equals(value) {
|
|
2216
|
+
*equals(value) {
|
|
2692
2217
|
if (value === false)
|
|
2693
2218
|
return true;
|
|
2694
|
-
if (isNil(toValue(value)))
|
|
2219
|
+
if (isNil(yield toValue(value)))
|
|
2695
2220
|
return true;
|
|
2696
2221
|
if (isString(value))
|
|
2697
2222
|
return /^\s*$/.test(value);
|
|
2698
|
-
return super.equals(value);
|
|
2223
|
+
return yield super.equals(value);
|
|
2699
2224
|
}
|
|
2700
2225
|
static is(value) {
|
|
2701
2226
|
return value instanceof _BlankDrop;
|
|
@@ -2804,7 +2329,11 @@ var literalValues = {
|
|
|
2804
2329
|
"empty": new EmptyDrop(),
|
|
2805
2330
|
"blank": new BlankDrop()
|
|
2806
2331
|
};
|
|
2332
|
+
var trieCache = /* @__PURE__ */ new WeakMap();
|
|
2807
2333
|
function createTrie(input) {
|
|
2334
|
+
const cached = trieCache.get(input);
|
|
2335
|
+
if (cached)
|
|
2336
|
+
return cached;
|
|
2808
2337
|
const trie = {};
|
|
2809
2338
|
for (const [name, data] of Object.entries(input)) {
|
|
2810
2339
|
let node = trie;
|
|
@@ -2819,6 +2348,7 @@ function createTrie(input) {
|
|
|
2819
2348
|
node.data = data;
|
|
2820
2349
|
node.end = true;
|
|
2821
2350
|
}
|
|
2351
|
+
trieCache.set(input, trie);
|
|
2822
2352
|
return trie;
|
|
2823
2353
|
}
|
|
2824
2354
|
__name(createTrie, "createTrie");
|
|
@@ -2864,6 +2394,13 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
2864
2394
|
});
|
|
2865
2395
|
}
|
|
2866
2396
|
__name(__awaiter, "__awaiter");
|
|
2397
|
+
function toLiquidAsync(asyncFn, syncFn) {
|
|
2398
|
+
const syncImpl = syncFn || asyncFn;
|
|
2399
|
+
return (sync, ...args) => {
|
|
2400
|
+
return sync ? syncImpl(...args) : asyncFn(...args);
|
|
2401
|
+
};
|
|
2402
|
+
}
|
|
2403
|
+
__name(toLiquidAsync, "toLiquidAsync");
|
|
2867
2404
|
function toPromise(val) {
|
|
2868
2405
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2869
2406
|
if (!isIterator(val))
|
|
@@ -2873,7 +2410,7 @@ function toPromise(val) {
|
|
|
2873
2410
|
let next = "next";
|
|
2874
2411
|
do {
|
|
2875
2412
|
const state = val[next](value);
|
|
2876
|
-
done = state.done;
|
|
2413
|
+
done = !!state.done;
|
|
2877
2414
|
value = state.value;
|
|
2878
2415
|
next = "next";
|
|
2879
2416
|
try {
|
|
@@ -2898,7 +2435,7 @@ function toValueSync(val) {
|
|
|
2898
2435
|
let next = "next";
|
|
2899
2436
|
do {
|
|
2900
2437
|
const state = val[next](value);
|
|
2901
|
-
done = state.done;
|
|
2438
|
+
done = !!state.done;
|
|
2902
2439
|
value = state.value;
|
|
2903
2440
|
next = "next";
|
|
2904
2441
|
if (isIterator(value)) {
|
|
@@ -2928,10 +2465,8 @@ function getDayOfYear(d) {
|
|
|
2928
2465
|
}
|
|
2929
2466
|
__name(getDayOfYear, "getDayOfYear");
|
|
2930
2467
|
function getWeekOfYear(d, startDay) {
|
|
2931
|
-
const
|
|
2932
|
-
|
|
2933
|
-
const then = 7 - jan1.getDay() + startDay;
|
|
2934
|
-
return String(Math.floor((now - then) / 7) + 1);
|
|
2468
|
+
const daysSinceStartDay = (d.getDay() - startDay + 7) % 7;
|
|
2469
|
+
return String(Math.floor((getDayOfYear(d) - 1 - daysSinceStartDay + 7) / 7));
|
|
2935
2470
|
}
|
|
2936
2471
|
__name(getWeekOfYear, "getWeekOfYear");
|
|
2937
2472
|
function isLeapYear(d) {
|
|
@@ -2956,10 +2491,11 @@ function ordinal(d) {
|
|
|
2956
2491
|
}
|
|
2957
2492
|
__name(ordinal, "ordinal");
|
|
2958
2493
|
function century(d) {
|
|
2959
|
-
return
|
|
2494
|
+
return Math.floor(d.getFullYear() / 100);
|
|
2960
2495
|
}
|
|
2961
2496
|
__name(century, "century");
|
|
2962
2497
|
var padWidths = {
|
|
2498
|
+
C: 2,
|
|
2963
2499
|
d: 2,
|
|
2964
2500
|
e: 2,
|
|
2965
2501
|
H: 2,
|
|
@@ -2972,7 +2508,9 @@ var padWidths = {
|
|
|
2972
2508
|
M: 2,
|
|
2973
2509
|
S: 2,
|
|
2974
2510
|
U: 2,
|
|
2975
|
-
W: 2
|
|
2511
|
+
W: 2,
|
|
2512
|
+
y: 2,
|
|
2513
|
+
Y: 4
|
|
2976
2514
|
};
|
|
2977
2515
|
var padSpaceChars = new Set("aAbBceklpP");
|
|
2978
2516
|
function getTimezoneOffset(d, opts) {
|
|
@@ -3000,14 +2538,16 @@ var formatCodes = {
|
|
|
3000
2538
|
m: /* @__PURE__ */ __name((d) => d.getMonth() + 1, "m"),
|
|
3001
2539
|
M: /* @__PURE__ */ __name((d) => d.getMinutes(), "M"),
|
|
3002
2540
|
N: /* @__PURE__ */ __name((d, opts) => {
|
|
2541
|
+
var _a;
|
|
3003
2542
|
const width = Number(opts.width) || 9;
|
|
3004
|
-
const str = String(d.getMilliseconds()).slice(0, width);
|
|
2543
|
+
const str = padStart(String(d.getMilliseconds()), 3, "0").slice(0, width);
|
|
2544
|
+
(_a = opts.memoryLimit) === null || _a === void 0 ? void 0 : _a.use(width - str.length);
|
|
3005
2545
|
return padEnd(str, width, "0");
|
|
3006
2546
|
}, "N"),
|
|
3007
2547
|
p: /* @__PURE__ */ __name((d) => d.getHours() < 12 ? "AM" : "PM", "p"),
|
|
3008
2548
|
P: /* @__PURE__ */ __name((d) => d.getHours() < 12 ? "am" : "pm", "P"),
|
|
3009
2549
|
q: /* @__PURE__ */ __name((d) => ordinal(d), "q"),
|
|
3010
|
-
s: /* @__PURE__ */ __name((d) => Math.
|
|
2550
|
+
s: /* @__PURE__ */ __name((d) => Math.floor(d.dateValue() / 1e3), "s"),
|
|
3011
2551
|
S: /* @__PURE__ */ __name((d) => d.getSeconds(), "S"),
|
|
3012
2552
|
u: /* @__PURE__ */ __name((d) => d.getDay() || 7, "u"),
|
|
3013
2553
|
U: /* @__PURE__ */ __name((d) => getWeekOfYear(d, 0), "U"),
|
|
@@ -3015,7 +2555,7 @@ var formatCodes = {
|
|
|
3015
2555
|
W: /* @__PURE__ */ __name((d) => getWeekOfYear(d, 1), "W"),
|
|
3016
2556
|
x: /* @__PURE__ */ __name((d) => d.toLocaleDateString(), "x"),
|
|
3017
2557
|
X: /* @__PURE__ */ __name((d) => d.toLocaleTimeString(), "X"),
|
|
3018
|
-
y: /* @__PURE__ */ __name((d) => d.getFullYear()
|
|
2558
|
+
y: /* @__PURE__ */ __name((d) => (d.getFullYear() % 100 + 100) % 100, "y"),
|
|
3019
2559
|
Y: /* @__PURE__ */ __name((d) => d.getFullYear(), "Y"),
|
|
3020
2560
|
z: getTimezoneOffset,
|
|
3021
2561
|
Z: /* @__PURE__ */ __name((d, opts) => d.getTimeZoneName() || getTimezoneOffset(d, opts), "Z"),
|
|
@@ -3024,19 +2564,19 @@ var formatCodes = {
|
|
|
3024
2564
|
"%": /* @__PURE__ */ __name(() => "%", "%")
|
|
3025
2565
|
};
|
|
3026
2566
|
formatCodes.h = formatCodes.b;
|
|
3027
|
-
function strftime(d, formatStr) {
|
|
2567
|
+
function strftime(d, formatStr, memoryLimit) {
|
|
3028
2568
|
let output = "";
|
|
3029
2569
|
let remaining = formatStr;
|
|
3030
2570
|
let match;
|
|
3031
2571
|
while (match = rFormat.exec(remaining)) {
|
|
3032
2572
|
output += remaining.slice(0, match.index);
|
|
3033
2573
|
remaining = remaining.slice(match.index + match[0].length);
|
|
3034
|
-
output += format(d, match);
|
|
2574
|
+
output += format(d, match, memoryLimit);
|
|
3035
2575
|
}
|
|
3036
2576
|
return output + remaining;
|
|
3037
2577
|
}
|
|
3038
2578
|
__name(strftime, "strftime");
|
|
3039
|
-
function format(d, match) {
|
|
2579
|
+
function format(d, match, memoryLimit) {
|
|
3040
2580
|
const [input, flagStr = "", width, modifier, conversion] = match;
|
|
3041
2581
|
const convert = formatCodes[conversion];
|
|
3042
2582
|
if (!convert)
|
|
@@ -3044,9 +2584,9 @@ function format(d, match) {
|
|
|
3044
2584
|
const flags = {};
|
|
3045
2585
|
for (const flag of flagStr)
|
|
3046
2586
|
flags[flag] = true;
|
|
3047
|
-
let ret = String(convert(d, { flags, width, modifier }));
|
|
2587
|
+
let ret = String(convert(d, { flags, width, modifier, memoryLimit }));
|
|
3048
2588
|
let padChar = padSpaceChars.has(conversion) ? " " : "0";
|
|
3049
|
-
let padWidth = width || padWidths[conversion] || 0;
|
|
2589
|
+
let padWidth = Number(width) || padWidths[conversion] || 0;
|
|
3050
2590
|
if (flags["^"])
|
|
3051
2591
|
ret = ret.toUpperCase();
|
|
3052
2592
|
else if (flags["#"])
|
|
@@ -3057,6 +2597,9 @@ function format(d, match) {
|
|
|
3057
2597
|
padChar = "0";
|
|
3058
2598
|
if (flags["-"])
|
|
3059
2599
|
padWidth = 0;
|
|
2600
|
+
memoryLimit === null || memoryLimit === void 0 ? void 0 : memoryLimit.use(Number(padWidth) - ret.length);
|
|
2601
|
+
if (padChar === "0" && ret[0] === "-")
|
|
2602
|
+
return "-" + padStart(ret.slice(1), padWidth - 1, padChar);
|
|
3060
2603
|
return padStart(ret, padWidth, padChar);
|
|
3061
2604
|
}
|
|
3062
2605
|
__name(format, "format");
|
|
@@ -3112,6 +2655,15 @@ var LiquidDate = class _LiquidDate {
|
|
|
3112
2655
|
getTime() {
|
|
3113
2656
|
return this.displayDate.getTime();
|
|
3114
2657
|
}
|
|
2658
|
+
/**
|
|
2659
|
+
* The underlying UTC timestamp in milliseconds, unaffected by the display
|
|
2660
|
+
* timezone. Use this (not `getTime()`) for timezone-invariant values like
|
|
2661
|
+
* `%s`: `getTime()` reads `displayDate`, which is deliberately shifted by
|
|
2662
|
+
* the display timezone offset so wall-clock getters can delegate to Date.
|
|
2663
|
+
*/
|
|
2664
|
+
dateValue() {
|
|
2665
|
+
return this.date.getTime();
|
|
2666
|
+
}
|
|
3115
2667
|
getMilliseconds() {
|
|
3116
2668
|
return this.displayDate.getMilliseconds();
|
|
3117
2669
|
}
|
|
@@ -3223,13 +2775,15 @@ var Limiter = class {
|
|
|
3223
2775
|
this.limit = limit2;
|
|
3224
2776
|
}
|
|
3225
2777
|
use(count) {
|
|
3226
|
-
count
|
|
3227
|
-
|
|
3228
|
-
|
|
2778
|
+
if (+count > 0) {
|
|
2779
|
+
assert(this.base + +count <= this.limit, this.message);
|
|
2780
|
+
this.base += +count;
|
|
2781
|
+
}
|
|
3229
2782
|
}
|
|
3230
2783
|
check(count) {
|
|
3231
|
-
count
|
|
3232
|
-
|
|
2784
|
+
if (+count > 0) {
|
|
2785
|
+
assert(+count <= this.limit, this.message);
|
|
2786
|
+
}
|
|
3233
2787
|
}
|
|
3234
2788
|
};
|
|
3235
2789
|
var DelimitedToken = class extends Token {
|
|
@@ -3264,7 +2818,7 @@ var TagToken = class extends DelimitedToken {
|
|
|
3264
2818
|
const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } = options;
|
|
3265
2819
|
const [valueBegin, valueEnd] = [begin + tagDelimiterLeft.length, end - tagDelimiterRight.length];
|
|
3266
2820
|
super(TokenKind.Tag, [valueBegin, valueEnd], input, begin, end, trimTagLeft, trimTagRight, file);
|
|
3267
|
-
this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange);
|
|
2821
|
+
this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange, options.groupedExpressions);
|
|
3268
2822
|
this.name = this.tokenizer.readTagName();
|
|
3269
2823
|
this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`);
|
|
3270
2824
|
this.tokenizer.skipBlank();
|
|
@@ -3376,8 +2930,7 @@ var OperatorToken = class extends Token {
|
|
|
3376
2930
|
this.operator = this.getText();
|
|
3377
2931
|
}
|
|
3378
2932
|
getPrecedence() {
|
|
3379
|
-
|
|
3380
|
-
return key in operatorPrecedences ? operatorPrecedences[key] : 1;
|
|
2933
|
+
return this.operator in operatorPrecedences ? operatorPrecedences[this.operator] : 1;
|
|
3381
2934
|
}
|
|
3382
2935
|
};
|
|
3383
2936
|
var PropertyAccessToken = class extends Token {
|
|
@@ -3498,7 +3051,7 @@ var LiquidTagToken = class extends DelimitedToken {
|
|
|
3498
3051
|
}
|
|
3499
3052
|
constructor(input, begin, end, options, file) {
|
|
3500
3053
|
super(TokenKind.Tag, [begin, end], input, begin, end, false, false, file);
|
|
3501
|
-
this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange);
|
|
3054
|
+
this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange, options.groupedExpressions);
|
|
3502
3055
|
this.name = this.tokenizer.readTagName();
|
|
3503
3056
|
this.tokenizer.assert(this.name, "illegal liquid tag syntax");
|
|
3504
3057
|
this.tokenizer.skipBlank();
|
|
@@ -3541,6 +3094,7 @@ var Render = class {
|
|
|
3541
3094
|
if (!emitter) {
|
|
3542
3095
|
emitter = ctx.opts.keepOutputType ? new KeepingTypeEmitter() : new SimpleEmitter();
|
|
3543
3096
|
}
|
|
3097
|
+
ctx.renderLimit.check(getPerformance().now());
|
|
3544
3098
|
const errors = [];
|
|
3545
3099
|
for (const tpl of templates) {
|
|
3546
3100
|
ctx.renderLimit.check(getPerformance().now());
|
|
@@ -3563,6 +3117,33 @@ var Render = class {
|
|
|
3563
3117
|
return emitter.buffer;
|
|
3564
3118
|
}
|
|
3565
3119
|
};
|
|
3120
|
+
function isKeyValuePair(arr) {
|
|
3121
|
+
return isArray(arr);
|
|
3122
|
+
}
|
|
3123
|
+
__name(isKeyValuePair, "isKeyValuePair");
|
|
3124
|
+
var Filter = class {
|
|
3125
|
+
static {
|
|
3126
|
+
__name(this, "Filter");
|
|
3127
|
+
}
|
|
3128
|
+
constructor(token, options, liquid) {
|
|
3129
|
+
this.token = token;
|
|
3130
|
+
this.name = token.name;
|
|
3131
|
+
this.handler = isFunction(options) ? options : isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify;
|
|
3132
|
+
this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
|
|
3133
|
+
this.args = token.args;
|
|
3134
|
+
this.liquid = liquid;
|
|
3135
|
+
}
|
|
3136
|
+
*render(value, context) {
|
|
3137
|
+
const argv = [];
|
|
3138
|
+
for (const arg of this.args) {
|
|
3139
|
+
if (isKeyValuePair(arg))
|
|
3140
|
+
argv.push([arg[0], yield evalToken(arg[1], context)]);
|
|
3141
|
+
else
|
|
3142
|
+
argv.push(yield evalToken(arg, context));
|
|
3143
|
+
}
|
|
3144
|
+
return yield this.handler.apply({ context, token: this.token, liquid: this.liquid }, [value, ...argv]);
|
|
3145
|
+
}
|
|
3146
|
+
};
|
|
3566
3147
|
var Expression = class {
|
|
3567
3148
|
static {
|
|
3568
3149
|
__name(this, "Expression");
|
|
@@ -3603,12 +3184,31 @@ function* evalToken(token, ctx, lenient = false) {
|
|
|
3603
3184
|
return yield evalPropertyAccessToken(token, ctx, lenient);
|
|
3604
3185
|
if (isRangeToken(token))
|
|
3605
3186
|
return yield evalRangeToken(token, ctx);
|
|
3187
|
+
if (isFilteredValueToken(token))
|
|
3188
|
+
return yield evalFilteredValueToken(token, ctx, lenient);
|
|
3606
3189
|
}
|
|
3607
3190
|
__name(evalToken, "evalToken");
|
|
3191
|
+
function* evalFilteredValueToken(token, ctx, lenient) {
|
|
3192
|
+
assert(ctx.liquid, "FilteredValueToken evaluation requires liquid instance in context");
|
|
3193
|
+
lenient = lenient || ctx.opts.lenientIf && token.filters.length > 0 && token.filters[0].name === "default";
|
|
3194
|
+
let val = yield token.initial.evaluate(ctx, lenient);
|
|
3195
|
+
for (const filterToken of token.filters) {
|
|
3196
|
+
const filterImpl = ctx.liquid.filters[filterToken.name];
|
|
3197
|
+
assert(filterImpl || !ctx.liquid.options.strictFilters, () => `undefined filter: ${filterToken.name}`);
|
|
3198
|
+
const filter2 = new Filter(filterToken, filterImpl, ctx.liquid);
|
|
3199
|
+
val = yield filter2.render(val, ctx);
|
|
3200
|
+
}
|
|
3201
|
+
return val;
|
|
3202
|
+
}
|
|
3203
|
+
__name(evalFilteredValueToken, "evalFilteredValueToken");
|
|
3204
|
+
function* evalTokenValue(token, ctx, lenient = false) {
|
|
3205
|
+
return yield toValue(yield evalToken(token, ctx, lenient));
|
|
3206
|
+
}
|
|
3207
|
+
__name(evalTokenValue, "evalTokenValue");
|
|
3608
3208
|
function* evalPropertyAccessToken(token, ctx, lenient) {
|
|
3609
3209
|
const props = [];
|
|
3610
3210
|
for (const prop of token.props) {
|
|
3611
|
-
props.push(yield
|
|
3211
|
+
props.push(yield evalTokenValue(prop, ctx, false));
|
|
3612
3212
|
}
|
|
3613
3213
|
try {
|
|
3614
3214
|
if (token.variable) {
|
|
@@ -3629,8 +3229,8 @@ function evalQuotedToken(token) {
|
|
|
3629
3229
|
}
|
|
3630
3230
|
__name(evalQuotedToken, "evalQuotedToken");
|
|
3631
3231
|
function* evalRangeToken(token, ctx) {
|
|
3632
|
-
const low = yield
|
|
3633
|
-
const high = yield
|
|
3232
|
+
const low = yield evalTokenValue(token.lhs, ctx);
|
|
3233
|
+
const high = yield evalTokenValue(token.rhs, ctx);
|
|
3634
3234
|
ctx.memoryLimit.use(high - low + 1);
|
|
3635
3235
|
return range(+low, +high + 1);
|
|
3636
3236
|
}
|
|
@@ -3665,69 +3265,87 @@ function isFalsy(val, ctx) {
|
|
|
3665
3265
|
}
|
|
3666
3266
|
__name(isFalsy, "isFalsy");
|
|
3667
3267
|
var defaultOperators = {
|
|
3668
|
-
"==":
|
|
3669
|
-
|
|
3670
|
-
"
|
|
3268
|
+
"==": /* @__PURE__ */ __name(function* (l, r) {
|
|
3269
|
+
return yield equals(l, r);
|
|
3270
|
+
}, "=="),
|
|
3271
|
+
"!=": /* @__PURE__ */ __name(function* (l, r) {
|
|
3272
|
+
return !(yield equals(l, r));
|
|
3273
|
+
}, "!="),
|
|
3274
|
+
">": /* @__PURE__ */ __name(function* (l, r) {
|
|
3671
3275
|
if (isComparable(l))
|
|
3672
|
-
return l.gt(r);
|
|
3276
|
+
return yield l.gt(r);
|
|
3673
3277
|
if (isComparable(r))
|
|
3674
|
-
return r.lt(l);
|
|
3675
|
-
return toValue(l) > toValue(r);
|
|
3278
|
+
return yield r.lt(l);
|
|
3279
|
+
return (yield toValue(l)) > (yield toValue(r));
|
|
3676
3280
|
}, ">"),
|
|
3677
|
-
"<": /* @__PURE__ */ __name((l, r)
|
|
3281
|
+
"<": /* @__PURE__ */ __name(function* (l, r) {
|
|
3678
3282
|
if (isComparable(l))
|
|
3679
|
-
return l.lt(r);
|
|
3283
|
+
return yield l.lt(r);
|
|
3680
3284
|
if (isComparable(r))
|
|
3681
|
-
return r.gt(l);
|
|
3682
|
-
return toValue(l) < toValue(r);
|
|
3285
|
+
return yield r.gt(l);
|
|
3286
|
+
return (yield toValue(l)) < (yield toValue(r));
|
|
3683
3287
|
}, "<"),
|
|
3684
|
-
">=": /* @__PURE__ */ __name((l, r)
|
|
3288
|
+
">=": /* @__PURE__ */ __name(function* (l, r) {
|
|
3685
3289
|
if (isComparable(l))
|
|
3686
|
-
return l.geq(r);
|
|
3290
|
+
return yield l.geq(r);
|
|
3687
3291
|
if (isComparable(r))
|
|
3688
|
-
return r.leq(l);
|
|
3689
|
-
return toValue(l) >= toValue(r);
|
|
3292
|
+
return yield r.leq(l);
|
|
3293
|
+
return (yield toValue(l)) >= (yield toValue(r));
|
|
3690
3294
|
}, ">="),
|
|
3691
|
-
"<=": /* @__PURE__ */ __name((l, r)
|
|
3295
|
+
"<=": /* @__PURE__ */ __name(function* (l, r) {
|
|
3692
3296
|
if (isComparable(l))
|
|
3693
|
-
return l.leq(r);
|
|
3297
|
+
return yield l.leq(r);
|
|
3694
3298
|
if (isComparable(r))
|
|
3695
|
-
return r.geq(l);
|
|
3696
|
-
return toValue(l) <= toValue(r);
|
|
3299
|
+
return yield r.geq(l);
|
|
3300
|
+
return (yield toValue(l)) <= (yield toValue(r));
|
|
3697
3301
|
}, "<="),
|
|
3698
|
-
"contains": /* @__PURE__ */ __name((l, r)
|
|
3699
|
-
l = toValue(l);
|
|
3302
|
+
"contains": /* @__PURE__ */ __name(function* (l, r) {
|
|
3303
|
+
l = yield toValue(l);
|
|
3700
3304
|
if (isArray(l))
|
|
3701
|
-
return
|
|
3305
|
+
return yield arrayIncludes(l, r);
|
|
3702
3306
|
if (isFunction(l === null || l === void 0 ? void 0 : l.indexOf))
|
|
3703
|
-
return l.indexOf(toValue(r)) > -1;
|
|
3307
|
+
return l.indexOf(yield toValue(r)) > -1;
|
|
3704
3308
|
return false;
|
|
3705
3309
|
}, "contains"),
|
|
3706
|
-
"not": /* @__PURE__ */ __name(
|
|
3707
|
-
|
|
3708
|
-
|
|
3310
|
+
"not": /* @__PURE__ */ __name(function* (v, ctx) {
|
|
3311
|
+
return isFalsy(yield toValue(v), ctx);
|
|
3312
|
+
}, "not"),
|
|
3313
|
+
"and": /* @__PURE__ */ __name(function* (l, r, ctx) {
|
|
3314
|
+
return isTruthy(yield toValue(l), ctx) && isTruthy(yield toValue(r), ctx);
|
|
3315
|
+
}, "and"),
|
|
3316
|
+
"or": /* @__PURE__ */ __name(function* (l, r, ctx) {
|
|
3317
|
+
return isTruthy(yield toValue(l), ctx) || isTruthy(yield toValue(r), ctx);
|
|
3318
|
+
}, "or")
|
|
3709
3319
|
};
|
|
3710
|
-
function equals(lhs, rhs) {
|
|
3320
|
+
function* equals(lhs, rhs) {
|
|
3711
3321
|
if (isComparable(lhs))
|
|
3712
|
-
return lhs.equals(rhs);
|
|
3322
|
+
return yield lhs.equals(rhs);
|
|
3713
3323
|
if (isComparable(rhs))
|
|
3714
|
-
return rhs.equals(lhs);
|
|
3715
|
-
lhs = toValue(lhs);
|
|
3716
|
-
rhs = toValue(rhs);
|
|
3324
|
+
return yield rhs.equals(lhs);
|
|
3325
|
+
lhs = yield toValue(lhs);
|
|
3326
|
+
rhs = yield toValue(rhs);
|
|
3717
3327
|
if (isArray(lhs)) {
|
|
3718
|
-
return isArray(rhs) && arrayEquals(lhs, rhs);
|
|
3328
|
+
return isArray(rhs) && (yield arrayEquals(lhs, rhs));
|
|
3719
3329
|
}
|
|
3720
3330
|
return lhs === rhs;
|
|
3721
3331
|
}
|
|
3722
3332
|
__name(equals, "equals");
|
|
3723
|
-
function arrayEquals(lhs, rhs) {
|
|
3333
|
+
function* arrayEquals(lhs, rhs) {
|
|
3724
3334
|
if (lhs.length !== rhs.length)
|
|
3725
3335
|
return false;
|
|
3726
|
-
|
|
3336
|
+
for (let i = 0; i < lhs.length; i++) {
|
|
3337
|
+
if (!(yield equals(lhs[i], rhs[i])))
|
|
3338
|
+
return false;
|
|
3339
|
+
}
|
|
3340
|
+
return true;
|
|
3727
3341
|
}
|
|
3728
3342
|
__name(arrayEquals, "arrayEquals");
|
|
3729
|
-
function arrayIncludes(arr, item) {
|
|
3730
|
-
|
|
3343
|
+
function* arrayIncludes(arr, item) {
|
|
3344
|
+
for (const value of arr) {
|
|
3345
|
+
if (yield equals(value, item))
|
|
3346
|
+
return true;
|
|
3347
|
+
}
|
|
3348
|
+
return false;
|
|
3731
3349
|
}
|
|
3732
3350
|
__name(arrayIncludes, "arrayIncludes");
|
|
3733
3351
|
var Node = class {
|
|
@@ -3871,6 +3489,18 @@ var fs = /* @__PURE__ */ Object.freeze({
|
|
|
3871
3489
|
dirname,
|
|
3872
3490
|
sep
|
|
3873
3491
|
});
|
|
3492
|
+
function chargeJsonReplacerValue(memoryLimit, val) {
|
|
3493
|
+
if (typeof val === "string") {
|
|
3494
|
+
memoryLimit.use(val.length);
|
|
3495
|
+
} else if (val === null || typeof val === "number" || typeof val === "boolean") {
|
|
3496
|
+
memoryLimit.use(JSON.stringify(val).length);
|
|
3497
|
+
} else if (Array.isArray(val)) {
|
|
3498
|
+
memoryLimit.use(val.length + 1);
|
|
3499
|
+
} else if (typeof val === "object") {
|
|
3500
|
+
memoryLimit.use(2);
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
__name(chargeJsonReplacerValue, "chargeJsonReplacerValue");
|
|
3874
3504
|
function defaultFilter(value, defaultValue, ...args) {
|
|
3875
3505
|
value = toValue(value);
|
|
3876
3506
|
if (isArray(value) || isString(value))
|
|
@@ -3881,19 +3511,29 @@ function defaultFilter(value, defaultValue, ...args) {
|
|
|
3881
3511
|
}
|
|
3882
3512
|
__name(defaultFilter, "defaultFilter");
|
|
3883
3513
|
function json(value, space = 0) {
|
|
3884
|
-
|
|
3514
|
+
const memoryLimit = this.context.memoryLimit;
|
|
3515
|
+
return JSON.stringify(value, (_key, val) => {
|
|
3516
|
+
chargeJsonReplacerValue(memoryLimit, val);
|
|
3517
|
+
return val;
|
|
3518
|
+
}, space);
|
|
3885
3519
|
}
|
|
3886
3520
|
__name(json, "json");
|
|
3887
3521
|
function inspect(value, space = 0) {
|
|
3522
|
+
const memoryLimit = this.context.memoryLimit;
|
|
3888
3523
|
const ancestors = [];
|
|
3889
3524
|
return JSON.stringify(value, function(_key, value2) {
|
|
3890
|
-
if (typeof value2 !== "object" || value2 === null)
|
|
3525
|
+
if (typeof value2 !== "object" || value2 === null) {
|
|
3526
|
+
chargeJsonReplacerValue(memoryLimit, value2);
|
|
3891
3527
|
return value2;
|
|
3528
|
+
}
|
|
3892
3529
|
while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
|
|
3893
3530
|
ancestors.pop();
|
|
3894
|
-
if (ancestors.includes(value2))
|
|
3531
|
+
if (ancestors.includes(value2)) {
|
|
3532
|
+
memoryLimit.use("[Circular]".length);
|
|
3895
3533
|
return "[Circular]";
|
|
3534
|
+
}
|
|
3896
3535
|
ancestors.push(value2);
|
|
3536
|
+
chargeJsonReplacerValue(memoryLimit, value2);
|
|
3897
3537
|
return value2;
|
|
3898
3538
|
}, space);
|
|
3899
3539
|
}
|
|
@@ -3957,7 +3597,28 @@ __name(newline_to_br, "newline_to_br");
|
|
|
3957
3597
|
function strip_html(v) {
|
|
3958
3598
|
const str = stringify(v);
|
|
3959
3599
|
this.context.memoryLimit.use(str.length);
|
|
3960
|
-
|
|
3600
|
+
const blocks = /* @__PURE__ */ new Map([["<script", "<\/script>"], ["<style", "</style>"], ["<!--", "-->"], ["<", ">"]]);
|
|
3601
|
+
let out = "";
|
|
3602
|
+
let i = 0;
|
|
3603
|
+
while (i < str.length) {
|
|
3604
|
+
const lt = str.indexOf("<", i);
|
|
3605
|
+
if (lt < 0)
|
|
3606
|
+
return out + str.slice(i);
|
|
3607
|
+
out += str.slice(i, lt);
|
|
3608
|
+
for (const [opener, closer] of blocks) {
|
|
3609
|
+
if (!str.startsWith(opener, lt))
|
|
3610
|
+
continue;
|
|
3611
|
+
const e = str.indexOf(closer, lt + opener.length);
|
|
3612
|
+
if (e >= 0) {
|
|
3613
|
+
i = e + closer.length;
|
|
3614
|
+
break;
|
|
3615
|
+
}
|
|
3616
|
+
blocks.delete(opener);
|
|
3617
|
+
}
|
|
3618
|
+
if (i <= lt)
|
|
3619
|
+
return out + str.slice(lt);
|
|
3620
|
+
}
|
|
3621
|
+
return out;
|
|
3961
3622
|
}
|
|
3962
3623
|
__name(strip_html, "strip_html");
|
|
3963
3624
|
var htmlFilters = /* @__PURE__ */ Object.freeze({
|
|
@@ -4048,6 +3709,7 @@ var defaultOptions = {
|
|
|
4048
3709
|
globals: {},
|
|
4049
3710
|
keepOutputType: false,
|
|
4050
3711
|
operators: defaultOperators,
|
|
3712
|
+
groupedExpressions: false,
|
|
4051
3713
|
memoryLimit: Infinity,
|
|
4052
3714
|
parseLimit: Infinity,
|
|
4053
3715
|
renderLimit: Infinity
|
|
@@ -4151,7 +3813,7 @@ var Tokenizer = class {
|
|
|
4151
3813
|
static {
|
|
4152
3814
|
__name(this, "Tokenizer");
|
|
4153
3815
|
}
|
|
4154
|
-
constructor(input, operators = defaultOptions.operators, file, range2) {
|
|
3816
|
+
constructor(input, operators = defaultOptions.operators, file, range2, groupedExpressions = false) {
|
|
4155
3817
|
this.input = input;
|
|
4156
3818
|
this.file = file;
|
|
4157
3819
|
this.rawBeginAt = -1;
|
|
@@ -4159,6 +3821,7 @@ var Tokenizer = class {
|
|
|
4159
3821
|
this.N = range2 ? range2[1] : input.length;
|
|
4160
3822
|
this.opTrie = createTrie(operators);
|
|
4161
3823
|
this.literalTrie = createTrie(literalValues);
|
|
3824
|
+
this.groupedExpressions = groupedExpressions;
|
|
4162
3825
|
}
|
|
4163
3826
|
readExpression() {
|
|
4164
3827
|
return new Expression(this.readExpressionTokens());
|
|
@@ -4220,6 +3883,8 @@ var Tokenizer = class {
|
|
|
4220
3883
|
this.skipBlank();
|
|
4221
3884
|
if (this.end())
|
|
4222
3885
|
return null;
|
|
3886
|
+
if (this.peek() === ")" || this.peek() === ",")
|
|
3887
|
+
return null;
|
|
4223
3888
|
this.assert(this.read() === "|", `expected "|" before filter`);
|
|
4224
3889
|
const name = this.readIdentifier();
|
|
4225
3890
|
if (!name.size()) {
|
|
@@ -4234,9 +3899,9 @@ var Tokenizer = class {
|
|
|
4234
3899
|
const arg = this.readFilterArg();
|
|
4235
3900
|
arg && args.push(arg);
|
|
4236
3901
|
this.skipBlank();
|
|
4237
|
-
this.assert(this.end() || this.peek() === "," || this.peek() === "|", () => `unexpected character ${this.snapshot()}`);
|
|
3902
|
+
this.assert(this.end() || this.peek() === "," || this.peek() === "|" || this.peek() === ")", () => `unexpected character ${this.snapshot()}`);
|
|
4238
3903
|
} while (this.peek() === ",");
|
|
4239
|
-
} else if (this.peek() === "|" || this.end()) ;
|
|
3904
|
+
} else if (this.peek() === "|" || this.peek() === ")" || this.peek() === "," || this.end()) ;
|
|
4240
3905
|
else {
|
|
4241
3906
|
throw this.error('expected ":" after filter name');
|
|
4242
3907
|
}
|
|
@@ -4440,7 +4105,10 @@ var Tokenizer = class {
|
|
|
4440
4105
|
readValue() {
|
|
4441
4106
|
this.skipBlank();
|
|
4442
4107
|
const begin = this.p;
|
|
4443
|
-
|
|
4108
|
+
let variable = this.readLiteral() || this.readQuoted() || this.readNumber();
|
|
4109
|
+
if (!variable && this.peek() === "(") {
|
|
4110
|
+
variable = this.readGroupOrRange();
|
|
4111
|
+
}
|
|
4444
4112
|
const props = this.readProperties(!variable);
|
|
4445
4113
|
if (!props.length)
|
|
4446
4114
|
return variable;
|
|
@@ -4517,7 +4185,7 @@ var Tokenizer = class {
|
|
|
4517
4185
|
this.p = end;
|
|
4518
4186
|
return literal;
|
|
4519
4187
|
}
|
|
4520
|
-
|
|
4188
|
+
readGroupOrRange() {
|
|
4521
4189
|
this.skipBlank();
|
|
4522
4190
|
const begin = this.p;
|
|
4523
4191
|
if (this.peek() !== "(")
|
|
@@ -4525,11 +4193,22 @@ var Tokenizer = class {
|
|
|
4525
4193
|
++this.p;
|
|
4526
4194
|
const lhs = this.readValueOrThrow();
|
|
4527
4195
|
this.skipBlank();
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4196
|
+
if (this.peek() === "." && this.peek(1) === ".") {
|
|
4197
|
+
this.p += 2;
|
|
4198
|
+
const rhs = this.readValueOrThrow();
|
|
4199
|
+
this.skipBlank();
|
|
4200
|
+
this.assert(this.read() === ")", "invalid range syntax");
|
|
4201
|
+
return new RangeToken(this.input, begin, this.p, lhs, rhs, this.file);
|
|
4202
|
+
}
|
|
4203
|
+
if (this.groupedExpressions) {
|
|
4204
|
+
const initial = new Expression([lhs, ...this.readExpressionTokens()]);
|
|
4205
|
+
this.assert(initial.valid(), () => `invalid value expression: ${this.snapshot()}`);
|
|
4206
|
+
const filters2 = this.readFilters();
|
|
4207
|
+
this.skipBlank();
|
|
4208
|
+
this.assert(this.read() === ")", "unbalanced parentheses");
|
|
4209
|
+
return new FilteredValueToken(initial, filters2, this.input, begin, this.p, this.file);
|
|
4210
|
+
}
|
|
4211
|
+
throw this.error("invalid range syntax");
|
|
4533
4212
|
}
|
|
4534
4213
|
readValueOrThrow() {
|
|
4535
4214
|
const value = this.readValue();
|
|
@@ -4556,7 +4235,7 @@ var Tokenizer = class {
|
|
|
4556
4235
|
}
|
|
4557
4236
|
*readFileNameTemplate(options) {
|
|
4558
4237
|
const { outputDelimiterLeft } = options;
|
|
4559
|
-
const htmlStopStrings = [",", " ", outputDelimiterLeft];
|
|
4238
|
+
const htmlStopStrings = [",", " ", "\r", "\n", " ", outputDelimiterLeft];
|
|
4560
4239
|
const htmlStopStringSet = new Set(htmlStopStrings);
|
|
4561
4240
|
while (this.p < this.N && !htmlStopStringSet.has(this.peek())) {
|
|
4562
4241
|
yield this.match(outputDelimiterLeft) ? this.readOutputToken(options) : this.readHTMLToken(htmlStopStrings);
|
|
@@ -4679,33 +4358,6 @@ function createTagClass(options) {
|
|
|
4679
4358
|
};
|
|
4680
4359
|
}
|
|
4681
4360
|
__name(createTagClass, "createTagClass");
|
|
4682
|
-
function isKeyValuePair(arr) {
|
|
4683
|
-
return isArray(arr);
|
|
4684
|
-
}
|
|
4685
|
-
__name(isKeyValuePair, "isKeyValuePair");
|
|
4686
|
-
var Filter = class {
|
|
4687
|
-
static {
|
|
4688
|
-
__name(this, "Filter");
|
|
4689
|
-
}
|
|
4690
|
-
constructor(token, options, liquid) {
|
|
4691
|
-
this.token = token;
|
|
4692
|
-
this.name = token.name;
|
|
4693
|
-
this.handler = isFunction(options) ? options : isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify;
|
|
4694
|
-
this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
|
|
4695
|
-
this.args = token.args;
|
|
4696
|
-
this.liquid = liquid;
|
|
4697
|
-
}
|
|
4698
|
-
*render(value, context) {
|
|
4699
|
-
const argv = [];
|
|
4700
|
-
for (const arg of this.args) {
|
|
4701
|
-
if (isKeyValuePair(arg))
|
|
4702
|
-
argv.push([arg[0], yield evalToken(arg[1], context)]);
|
|
4703
|
-
else
|
|
4704
|
-
argv.push(yield evalToken(arg, context));
|
|
4705
|
-
}
|
|
4706
|
-
return yield this.handler.apply({ context, token: this.token, liquid: this.liquid }, [value, ...argv]);
|
|
4707
|
-
}
|
|
4708
|
-
};
|
|
4709
4361
|
var Value = class {
|
|
4710
4362
|
static {
|
|
4711
4363
|
__name(this, "Value");
|
|
@@ -4715,7 +4367,7 @@ var Value = class {
|
|
|
4715
4367
|
*/
|
|
4716
4368
|
constructor(input, liquid) {
|
|
4717
4369
|
this.filters = [];
|
|
4718
|
-
const token = typeof input === "string" ? new Tokenizer(input, liquid.options.operators).readFilteredValue() : input;
|
|
4370
|
+
const token = typeof input === "string" ? new Tokenizer(input, liquid.options.operators, void 0, void 0, liquid.options.groupedExpressions).readFilteredValue() : input;
|
|
4719
4371
|
this.initial = token.initial;
|
|
4720
4372
|
this.filters = token.filters.map((token2) => new Filter(token2, this.getFilter(liquid, token2.name), liquid));
|
|
4721
4373
|
}
|
|
@@ -4740,7 +4392,7 @@ var Output = class extends TemplateImpl {
|
|
|
4740
4392
|
constructor(token, liquid) {
|
|
4741
4393
|
var _a;
|
|
4742
4394
|
super(token);
|
|
4743
|
-
const tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange);
|
|
4395
|
+
const tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange, liquid.options.groupedExpressions);
|
|
4744
4396
|
this.value = new Value(tokenizer.readFilteredValue(), liquid);
|
|
4745
4397
|
const filters2 = this.value.filters;
|
|
4746
4398
|
const outputEscape = liquid.options.outputEscape;
|
|
@@ -4750,7 +4402,7 @@ var Output = class extends TemplateImpl {
|
|
|
4750
4402
|
}
|
|
4751
4403
|
}
|
|
4752
4404
|
*render(ctx, emitter) {
|
|
4753
|
-
const val = yield this.value.value(ctx, false);
|
|
4405
|
+
const val = yield toValue(yield this.value.value(ctx, false));
|
|
4754
4406
|
emitter.write(val);
|
|
4755
4407
|
}
|
|
4756
4408
|
*arguments() {
|
|
@@ -5015,11 +4667,31 @@ function* extractValueTokenVariables(token) {
|
|
|
5015
4667
|
if (isRangeToken(token)) {
|
|
5016
4668
|
yield* extractValueTokenVariables(token.lhs);
|
|
5017
4669
|
yield* extractValueTokenVariables(token.rhs);
|
|
4670
|
+
} else if (isFilteredValueToken(token)) {
|
|
4671
|
+
yield* extractGroupedExpressionTokenVariables(token);
|
|
5018
4672
|
} else if (isPropertyAccessToken(token)) {
|
|
5019
4673
|
yield extractPropertyAccessVariable(token);
|
|
5020
4674
|
}
|
|
5021
4675
|
}
|
|
5022
4676
|
__name(extractValueTokenVariables, "extractValueTokenVariables");
|
|
4677
|
+
function* extractGroupedExpressionTokenVariables(token) {
|
|
4678
|
+
if (!isFilteredValueToken(token))
|
|
4679
|
+
return;
|
|
4680
|
+
for (const t of token.initial.postfix) {
|
|
4681
|
+
if (isValueToken(t))
|
|
4682
|
+
yield* extractValueTokenVariables(t);
|
|
4683
|
+
}
|
|
4684
|
+
for (const filter2 of token.filters) {
|
|
4685
|
+
for (const arg of filter2.args) {
|
|
4686
|
+
if (isKeyValuePair(arg) && arg[1]) {
|
|
4687
|
+
yield* extractValueTokenVariables(arg[1]);
|
|
4688
|
+
} else if (isValueToken(arg)) {
|
|
4689
|
+
yield* extractValueTokenVariables(arg);
|
|
4690
|
+
}
|
|
4691
|
+
}
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4694
|
+
__name(extractGroupedExpressionTokenVariables, "extractGroupedExpressionTokenVariables");
|
|
5023
4695
|
function extractPropertyAccessVariable(token) {
|
|
5024
4696
|
const segments = [];
|
|
5025
4697
|
let file = token.file;
|
|
@@ -5084,42 +4756,50 @@ var Loader = class {
|
|
|
5084
4756
|
__name(this, "Loader");
|
|
5085
4757
|
}
|
|
5086
4758
|
constructor(options) {
|
|
4759
|
+
var _a, _b, _c, _d;
|
|
5087
4760
|
this.options = options;
|
|
5088
4761
|
if (options.relativeReference) {
|
|
5089
4762
|
const sep2 = options.fs.sep;
|
|
5090
4763
|
assert(sep2, "`fs.sep` is required for relative reference");
|
|
5091
|
-
const
|
|
5092
|
-
this.shouldLoadRelative = (referencedFile) =>
|
|
4764
|
+
const prefixes = ["." + sep2, ".." + sep2, "./", "../"];
|
|
4765
|
+
this.shouldLoadRelative = (referencedFile) => prefixes.some((prefix) => referencedFile.startsWith(prefix));
|
|
5093
4766
|
} else {
|
|
5094
4767
|
this.shouldLoadRelative = (_referencedFile) => false;
|
|
5095
4768
|
}
|
|
5096
|
-
|
|
4769
|
+
const fs3 = options.fs;
|
|
4770
|
+
this.contains = toLiquidAsync(((_a = fs3.contains) === null || _a === void 0 ? void 0 : _a.bind(fs3)) || (() => __awaiter(this, void 0, void 0, function* () {
|
|
4771
|
+
return true;
|
|
4772
|
+
})), ((_b = fs3.containsSync) === null || _b === void 0 ? void 0 : _b.bind(fs3)) || (() => true));
|
|
4773
|
+
this.exists = toLiquidAsync(((_c = fs3.exists) === null || _c === void 0 ? void 0 : _c.bind(fs3)) || (() => __awaiter(this, void 0, void 0, function* () {
|
|
4774
|
+
return false;
|
|
4775
|
+
})), (_d = fs3.existsSync) === null || _d === void 0 ? void 0 : _d.bind(fs3));
|
|
5097
4776
|
}
|
|
5098
4777
|
*lookup(file, type, sync, currentFile) {
|
|
5099
|
-
const { fs: fs3 } = this.options;
|
|
5100
4778
|
const dirs = this.options[type];
|
|
5101
|
-
for (const filepath of this.candidates(file, dirs, currentFile
|
|
5102
|
-
|
|
4779
|
+
for (const filepath of this.candidates(file, dirs, currentFile)) {
|
|
4780
|
+
let allowed = false;
|
|
4781
|
+
for (const dir of dirs) {
|
|
4782
|
+
if (yield this.contains(!!sync, dir, filepath)) {
|
|
4783
|
+
allowed = true;
|
|
4784
|
+
break;
|
|
4785
|
+
}
|
|
4786
|
+
}
|
|
4787
|
+
if (!allowed)
|
|
4788
|
+
continue;
|
|
4789
|
+
if (yield this.exists(!!sync, filepath))
|
|
5103
4790
|
return filepath;
|
|
5104
4791
|
}
|
|
5105
4792
|
throw this.lookupError(file, dirs);
|
|
5106
4793
|
}
|
|
5107
|
-
*candidates(file, dirs, currentFile
|
|
4794
|
+
*candidates(file, dirs, currentFile) {
|
|
5108
4795
|
const { fs: fs3, extname } = this.options;
|
|
5109
4796
|
if (this.shouldLoadRelative(file) && currentFile) {
|
|
5110
4797
|
const referenced = fs3.resolve(this.dirname(currentFile), file, extname);
|
|
5111
|
-
|
|
5112
|
-
if (!enforceRoot || this.contains(dir, referenced)) {
|
|
5113
|
-
yield referenced;
|
|
5114
|
-
break;
|
|
5115
|
-
}
|
|
5116
|
-
}
|
|
4798
|
+
yield referenced;
|
|
5117
4799
|
}
|
|
5118
4800
|
for (const dir of dirs) {
|
|
5119
4801
|
const referenced = fs3.resolve(dir, file, extname);
|
|
5120
|
-
|
|
5121
|
-
yield referenced;
|
|
5122
|
-
}
|
|
4802
|
+
yield referenced;
|
|
5123
4803
|
}
|
|
5124
4804
|
if (fs3.fallback !== void 0) {
|
|
5125
4805
|
const filepath = fs3.fallback(file);
|
|
@@ -5144,17 +4824,21 @@ var Parser = class {
|
|
|
5144
4824
|
__name(this, "Parser");
|
|
5145
4825
|
}
|
|
5146
4826
|
constructor(liquid) {
|
|
4827
|
+
var _a, _b;
|
|
5147
4828
|
this.liquid = liquid;
|
|
5148
4829
|
this.cache = this.liquid.options.cache;
|
|
5149
4830
|
this.fs = this.liquid.options.fs;
|
|
5150
4831
|
this.parseFile = this.cache ? this._parseFileCached : this._parseFile;
|
|
5151
4832
|
this.loader = new Loader(this.liquid.options);
|
|
5152
4833
|
this.parseLimit = new Limiter("parse length", liquid.options.parseLimit);
|
|
4834
|
+
this.readFile = toLiquidAsync(((_a = this.fs.readFile) === null || _a === void 0 ? void 0 : _a.bind(this.fs)) || (() => __awaiter(this, void 0, void 0, function* () {
|
|
4835
|
+
throw new Error("readFile not implemented");
|
|
4836
|
+
})), (_b = this.fs.readFileSync) === null || _b === void 0 ? void 0 : _b.bind(this.fs));
|
|
5153
4837
|
}
|
|
5154
4838
|
parse(html, filepath) {
|
|
5155
4839
|
html = String(html);
|
|
5156
4840
|
this.parseLimit.use(html.length);
|
|
5157
|
-
const tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath);
|
|
4841
|
+
const tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath, void 0, this.liquid.options.groupedExpressions);
|
|
5158
4842
|
const tokens = tokenizer.readTopLevelTokens(this.liquid.options);
|
|
5159
4843
|
return this.parseTokens(tokens);
|
|
5160
4844
|
}
|
|
@@ -5214,7 +4898,7 @@ var Parser = class {
|
|
|
5214
4898
|
}
|
|
5215
4899
|
*_parseFile(file, sync, type = LookupType.Root, currentFile) {
|
|
5216
4900
|
const filepath = yield this.loader.lookup(file, type, sync, currentFile);
|
|
5217
|
-
return this.parse(
|
|
4901
|
+
return this.parse(yield this.readFile(!!sync, filepath), filepath);
|
|
5218
4902
|
}
|
|
5219
4903
|
};
|
|
5220
4904
|
var TokenKind;
|
|
@@ -5232,6 +4916,7 @@ var TokenKind;
|
|
|
5232
4916
|
TokenKind2[TokenKind2["Quoted"] = 1024] = "Quoted";
|
|
5233
4917
|
TokenKind2[TokenKind2["Operator"] = 2048] = "Operator";
|
|
5234
4918
|
TokenKind2[TokenKind2["FilteredValue"] = 4096] = "FilteredValue";
|
|
4919
|
+
TokenKind2[TokenKind2["GroupedExpression"] = 8192] = "GroupedExpression";
|
|
5235
4920
|
TokenKind2[TokenKind2["Delimited"] = 12] = "Delimited";
|
|
5236
4921
|
})(TokenKind || (TokenKind = {}));
|
|
5237
4922
|
function isDelimitedToken(val) {
|
|
@@ -5274,21 +4959,32 @@ function isRangeToken(val) {
|
|
|
5274
4959
|
return getKind(val) === TokenKind.Range;
|
|
5275
4960
|
}
|
|
5276
4961
|
__name(isRangeToken, "isRangeToken");
|
|
4962
|
+
function isFilteredValueToken(val) {
|
|
4963
|
+
return getKind(val) === TokenKind.FilteredValue;
|
|
4964
|
+
}
|
|
4965
|
+
__name(isFilteredValueToken, "isFilteredValueToken");
|
|
5277
4966
|
function isValueToken(val) {
|
|
5278
|
-
return (getKind(val) &
|
|
4967
|
+
return (getKind(val) & 5763) > 0;
|
|
5279
4968
|
}
|
|
5280
4969
|
__name(isValueToken, "isValueToken");
|
|
5281
4970
|
function getKind(val) {
|
|
5282
4971
|
return val ? val.kind : -1;
|
|
5283
4972
|
}
|
|
5284
4973
|
__name(getKind, "getKind");
|
|
4974
|
+
function createScope(from) {
|
|
4975
|
+
const scope = /* @__PURE__ */ Object.create(null);
|
|
4976
|
+
if (from)
|
|
4977
|
+
Object.assign(scope, from);
|
|
4978
|
+
return scope;
|
|
4979
|
+
}
|
|
4980
|
+
__name(createScope, "createScope");
|
|
5285
4981
|
var Context = class _Context {
|
|
5286
4982
|
static {
|
|
5287
4983
|
__name(this, "Context");
|
|
5288
4984
|
}
|
|
5289
|
-
constructor(env = {}, opts = defaultOptions, renderOptions = {}, { memoryLimit, renderLimit } = {}) {
|
|
4985
|
+
constructor(env = {}, opts = defaultOptions, renderOptions = {}, { memoryLimit, renderLimit, liquid } = {}) {
|
|
5290
4986
|
var _a, _b, _c, _d, _e;
|
|
5291
|
-
this.scopes = [
|
|
4987
|
+
this.scopes = [createScope()];
|
|
5292
4988
|
this.registers = {};
|
|
5293
4989
|
this.breakCalled = false;
|
|
5294
4990
|
this.continueCalled = false;
|
|
@@ -5300,9 +4996,10 @@ var Context = class _Context {
|
|
|
5300
4996
|
this.ownPropertyOnly = (_c = renderOptions.ownPropertyOnly) !== null && _c !== void 0 ? _c : opts.ownPropertyOnly;
|
|
5301
4997
|
this.memoryLimit = memoryLimit !== null && memoryLimit !== void 0 ? memoryLimit : new Limiter("memory alloc", (_d = renderOptions.memoryLimit) !== null && _d !== void 0 ? _d : opts.memoryLimit);
|
|
5302
4998
|
this.renderLimit = renderLimit !== null && renderLimit !== void 0 ? renderLimit : new Limiter("template render", getPerformance().now() + ((_e = renderOptions.renderLimit) !== null && _e !== void 0 ? _e : opts.renderLimit));
|
|
4999
|
+
this.liquid = liquid;
|
|
5303
5000
|
}
|
|
5304
|
-
getRegister(key) {
|
|
5305
|
-
return this.registers[key] = this.registers[key] ||
|
|
5001
|
+
getRegister(key, defaultValue = void 0) {
|
|
5002
|
+
return this.registers[key] = this.registers[key] || defaultValue;
|
|
5306
5003
|
}
|
|
5307
5004
|
setRegister(key, value) {
|
|
5308
5005
|
return this.registers[key] = value;
|
|
@@ -5339,7 +5036,7 @@ var Context = class _Context {
|
|
|
5339
5036
|
if (isString(paths))
|
|
5340
5037
|
paths = paths.split(".");
|
|
5341
5038
|
for (let i = 0; i < paths.length; i++) {
|
|
5342
|
-
scope = yield readProperty(scope, paths[i]
|
|
5039
|
+
scope = yield this.readProperty(scope, paths[i]);
|
|
5343
5040
|
if (strictVariables && isUndefined(scope)) {
|
|
5344
5041
|
throw new InternalUndefinedVariableError(paths.slice(0, i + 1).join("."));
|
|
5345
5042
|
}
|
|
@@ -5359,10 +5056,12 @@ var Context = class _Context {
|
|
|
5359
5056
|
return new _Context(scope, this.opts, {
|
|
5360
5057
|
sync: this.sync,
|
|
5361
5058
|
globals: this.globals,
|
|
5362
|
-
strictVariables: this.strictVariables
|
|
5059
|
+
strictVariables: this.strictVariables,
|
|
5060
|
+
ownPropertyOnly: this.ownPropertyOnly
|
|
5363
5061
|
}, {
|
|
5364
5062
|
renderLimit: this.renderLimit,
|
|
5365
|
-
memoryLimit: this.memoryLimit
|
|
5063
|
+
memoryLimit: this.memoryLimit,
|
|
5064
|
+
liquid: this.liquid
|
|
5366
5065
|
});
|
|
5367
5066
|
}
|
|
5368
5067
|
findScope(key) {
|
|
@@ -5375,44 +5074,43 @@ var Context = class _Context {
|
|
|
5375
5074
|
return this.environments;
|
|
5376
5075
|
return this.globals;
|
|
5377
5076
|
}
|
|
5077
|
+
readProperty(obj, key) {
|
|
5078
|
+
obj = toLiquid(obj);
|
|
5079
|
+
key = toValue(key);
|
|
5080
|
+
if (isNil(obj))
|
|
5081
|
+
return obj;
|
|
5082
|
+
if (isArray(obj) && isNumber(key))
|
|
5083
|
+
return readArrayElement(obj, key, this.ownPropertyOnly);
|
|
5084
|
+
const value = readJSProperty(obj, key, this.ownPropertyOnly);
|
|
5085
|
+
if (value === void 0 && obj instanceof Drop)
|
|
5086
|
+
return obj.liquidMethodMissing(key, this);
|
|
5087
|
+
if (isFunction(value))
|
|
5088
|
+
return value.call(obj);
|
|
5089
|
+
if (key === "size")
|
|
5090
|
+
return readSize(obj);
|
|
5091
|
+
else if (key === "first")
|
|
5092
|
+
return readFirst(obj, this.ownPropertyOnly);
|
|
5093
|
+
else if (key === "last")
|
|
5094
|
+
return readLast(obj, this.ownPropertyOnly);
|
|
5095
|
+
return value;
|
|
5096
|
+
}
|
|
5378
5097
|
};
|
|
5379
|
-
function readProperty(obj, key, ownPropertyOnly) {
|
|
5380
|
-
obj = toLiquid(obj);
|
|
5381
|
-
key = toValue(key);
|
|
5382
|
-
if (isNil(obj))
|
|
5383
|
-
return obj;
|
|
5384
|
-
if (isArray(obj) && key < 0)
|
|
5385
|
-
return obj[obj.length + +key];
|
|
5386
|
-
const value = readJSProperty(obj, key, ownPropertyOnly);
|
|
5387
|
-
if (value === void 0 && obj instanceof Drop)
|
|
5388
|
-
return obj.liquidMethodMissing(key);
|
|
5389
|
-
if (isFunction(value))
|
|
5390
|
-
return value.call(obj);
|
|
5391
|
-
if (key === "size")
|
|
5392
|
-
return readSize(obj);
|
|
5393
|
-
else if (key === "first")
|
|
5394
|
-
return readFirst(obj);
|
|
5395
|
-
else if (key === "last")
|
|
5396
|
-
return readLast(obj);
|
|
5397
|
-
return value;
|
|
5398
|
-
}
|
|
5399
|
-
__name(readProperty, "readProperty");
|
|
5400
5098
|
function readJSProperty(obj, key, ownPropertyOnly) {
|
|
5401
5099
|
if (ownPropertyOnly && !hasOwnProperty.call(obj, key) && !(obj instanceof Drop))
|
|
5402
5100
|
return void 0;
|
|
5403
5101
|
return obj[key];
|
|
5404
5102
|
}
|
|
5405
5103
|
__name(readJSProperty, "readJSProperty");
|
|
5406
|
-
function readFirst(obj) {
|
|
5104
|
+
function readFirst(obj, ownPropertyOnly) {
|
|
5407
5105
|
if (isArray(obj))
|
|
5408
|
-
return obj
|
|
5409
|
-
return obj
|
|
5106
|
+
return readArrayElement(obj, 0, ownPropertyOnly);
|
|
5107
|
+
return readJSProperty(obj, "first", ownPropertyOnly);
|
|
5410
5108
|
}
|
|
5411
5109
|
__name(readFirst, "readFirst");
|
|
5412
|
-
function readLast(obj) {
|
|
5110
|
+
function readLast(obj, ownPropertyOnly) {
|
|
5413
5111
|
if (isArray(obj))
|
|
5414
|
-
return obj
|
|
5415
|
-
return obj
|
|
5112
|
+
return readArrayElement(obj, -1, ownPropertyOnly);
|
|
5113
|
+
return readJSProperty(obj, "last", ownPropertyOnly);
|
|
5416
5114
|
}
|
|
5417
5115
|
__name(readLast, "readLast");
|
|
5418
5116
|
function readSize(obj) {
|
|
@@ -5429,28 +5127,31 @@ var BlockMode;
|
|
|
5429
5127
|
BlockMode2[BlockMode2["OUTPUT"] = 0] = "OUTPUT";
|
|
5430
5128
|
BlockMode2[BlockMode2["STORE"] = 1] = "STORE";
|
|
5431
5129
|
})(BlockMode || (BlockMode = {}));
|
|
5432
|
-
var abs =
|
|
5433
|
-
var at_least =
|
|
5434
|
-
var at_most =
|
|
5435
|
-
var ceil =
|
|
5436
|
-
var divided_by =
|
|
5437
|
-
var floor =
|
|
5438
|
-
var minus =
|
|
5439
|
-
var
|
|
5440
|
-
var
|
|
5130
|
+
var abs = argumentsToNumber(Math.abs);
|
|
5131
|
+
var at_least = argumentsToNumber(Math.max);
|
|
5132
|
+
var at_most = argumentsToNumber(Math.min);
|
|
5133
|
+
var ceil = argumentsToNumber(Math.ceil);
|
|
5134
|
+
var divided_by = argumentsToNumber((dividend, divisor, integerArithmetic = false) => integerArithmetic ? Math.floor(dividend / divisor) : dividend / divisor);
|
|
5135
|
+
var floor = argumentsToNumber(Math.floor);
|
|
5136
|
+
var minus = argumentsToNumber((v, arg) => v - arg);
|
|
5137
|
+
var plus = argumentsToNumber((lhs, rhs) => lhs + rhs);
|
|
5138
|
+
var modulo = argumentsToNumber((v, arg) => (v % arg + arg) % arg);
|
|
5139
|
+
var times = argumentsToNumber((v, arg) => v * arg);
|
|
5140
|
+
function shiftDecimal(n, exponent) {
|
|
5141
|
+
const [mantissa, power = "0"] = String(n).split("e");
|
|
5142
|
+
return Number(`${mantissa}e${Number(power) + exponent}`);
|
|
5143
|
+
}
|
|
5144
|
+
__name(shiftDecimal, "shiftDecimal");
|
|
5441
5145
|
function round(v, arg = 0) {
|
|
5442
|
-
v =
|
|
5443
|
-
arg =
|
|
5444
|
-
const
|
|
5445
|
-
|
|
5146
|
+
v = toNumber(v);
|
|
5147
|
+
arg = toNumber(arg);
|
|
5148
|
+
const scaled = shiftDecimal(Math.abs(v), arg);
|
|
5149
|
+
if (!(scaled <= Number.MAX_SAFE_INTEGER))
|
|
5150
|
+
return v;
|
|
5151
|
+
const rounded = shiftDecimal(Math.round(scaled), -arg);
|
|
5152
|
+
return v < 0 ? -rounded : rounded;
|
|
5446
5153
|
}
|
|
5447
5154
|
__name(round, "round");
|
|
5448
|
-
function plus(v, arg) {
|
|
5449
|
-
v = toValue(v);
|
|
5450
|
-
arg = toValue(arg);
|
|
5451
|
-
return Number(v) + Number(arg);
|
|
5452
|
-
}
|
|
5453
|
-
__name(plus, "plus");
|
|
5454
5155
|
var mathFilters = /* @__PURE__ */ Object.freeze({
|
|
5455
5156
|
__proto__: null,
|
|
5456
5157
|
abs,
|
|
@@ -5460,12 +5161,12 @@ var mathFilters = /* @__PURE__ */ Object.freeze({
|
|
|
5460
5161
|
divided_by,
|
|
5461
5162
|
floor,
|
|
5462
5163
|
minus,
|
|
5164
|
+
plus,
|
|
5463
5165
|
modulo,
|
|
5464
5166
|
times,
|
|
5465
|
-
round
|
|
5466
|
-
plus
|
|
5167
|
+
round
|
|
5467
5168
|
});
|
|
5468
|
-
var url_decode = /* @__PURE__ */ __name((x) => decodeURIComponent(stringify(x)
|
|
5169
|
+
var url_decode = /* @__PURE__ */ __name((x) => decodeURIComponent(stringify(x).replace(/\+/g, " ")), "url_decode");
|
|
5469
5170
|
var url_encode = /* @__PURE__ */ __name((x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+"), "url_encode");
|
|
5470
5171
|
var cgi_escape = /* @__PURE__ */ __name((x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+").replace(/[!'()*]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase()), "cgi_escape");
|
|
5471
5172
|
var uri_escape = /* @__PURE__ */ __name((x) => encodeURI(stringify(x)).replace(/%5B/g, "[").replace(/%5D/g, "]"), "uri_escape");
|
|
@@ -5504,18 +5205,24 @@ var urlFilters = /* @__PURE__ */ Object.freeze({
|
|
|
5504
5205
|
var join = argumentsToValue(function(v, arg) {
|
|
5505
5206
|
const array = toArray(v);
|
|
5506
5207
|
const sep2 = isNil(arg) ? " " : stringify(arg);
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5208
|
+
let outputSize = sep2.length * Math.max(array.length - 1, 0);
|
|
5209
|
+
for (let i = 0; i < array.length; i++)
|
|
5210
|
+
outputSize += String(array[i]).length;
|
|
5211
|
+
this.context.memoryLimit.use(outputSize);
|
|
5212
|
+
return Array.prototype.join.call(array, sep2);
|
|
5213
|
+
});
|
|
5214
|
+
var last$1 = argumentsToValue(function(v) {
|
|
5215
|
+
return isArrayLike(v) ? readArrayElement(v, -1, this.context.ownPropertyOnly) : "";
|
|
5216
|
+
});
|
|
5217
|
+
var first = argumentsToValue(function(v) {
|
|
5218
|
+
return isArrayLike(v) ? readArrayElement(v, 0, this.context.ownPropertyOnly) : "";
|
|
5510
5219
|
});
|
|
5511
|
-
var last$1 = argumentsToValue((v) => isArrayLike(v) ? last(v) : "");
|
|
5512
|
-
var first = argumentsToValue((v) => isArrayLike(v) ? v[0] : "");
|
|
5513
5220
|
var reverse = argumentsToValue(function(v) {
|
|
5514
5221
|
const array = toArray(v);
|
|
5515
5222
|
this.context.memoryLimit.use(array.length);
|
|
5516
5223
|
return [...array].reverse();
|
|
5517
5224
|
});
|
|
5518
|
-
function*
|
|
5225
|
+
function* sortBy(arr, property, comparator) {
|
|
5519
5226
|
const values = [];
|
|
5520
5227
|
const array = toArray(arr);
|
|
5521
5228
|
this.context.memoryLimit.use(array.length);
|
|
@@ -5525,19 +5232,15 @@ function* sort(arr, property) {
|
|
|
5525
5232
|
property ? yield this.context._getFromScope(item, stringify(property).split("."), false) : item
|
|
5526
5233
|
]);
|
|
5527
5234
|
}
|
|
5528
|
-
return values.sort((lhs, rhs) =>
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5235
|
+
return values.sort((lhs, rhs) => comparator(lhs[1], rhs[1])).map((tuple) => tuple[0]);
|
|
5236
|
+
}
|
|
5237
|
+
__name(sortBy, "sortBy");
|
|
5238
|
+
function* sort(arr, property) {
|
|
5239
|
+
return yield* sortBy.call(this, arr, property, orderedCompare);
|
|
5533
5240
|
}
|
|
5534
5241
|
__name(sort, "sort");
|
|
5535
|
-
function sort_natural(
|
|
5536
|
-
|
|
5537
|
-
const compare = property === void 0 ? caseInsensitiveCompare : (lhs, rhs) => caseInsensitiveCompare(lhs[propertyString], rhs[propertyString]);
|
|
5538
|
-
const array = toArray(input);
|
|
5539
|
-
this.context.memoryLimit.use(array.length);
|
|
5540
|
-
return [...array].sort(compare);
|
|
5242
|
+
function* sort_natural(arr, property) {
|
|
5243
|
+
return yield* sortBy.call(this, arr, property, caseInsensitiveCompare);
|
|
5541
5244
|
}
|
|
5542
5245
|
__name(sort_natural, "sort_natural");
|
|
5543
5246
|
var size = /* @__PURE__ */ __name((v) => v && v.length || 0, "size");
|
|
@@ -5564,14 +5267,14 @@ __name(sum, "sum");
|
|
|
5564
5267
|
function compact(arr) {
|
|
5565
5268
|
const array = toArray(arr);
|
|
5566
5269
|
this.context.memoryLimit.use(array.length);
|
|
5567
|
-
return
|
|
5270
|
+
return Array.prototype.filter.call(array, (x) => !isNil(toValue(x)));
|
|
5568
5271
|
}
|
|
5569
5272
|
__name(compact, "compact");
|
|
5570
5273
|
function concat(v, arg = []) {
|
|
5571
5274
|
const lhs = toArray(v);
|
|
5572
5275
|
const rhs = toArray(arg);
|
|
5573
5276
|
this.context.memoryLimit.use(lhs.length + rhs.length);
|
|
5574
|
-
return
|
|
5277
|
+
return Array.prototype.concat.call(lhs, rhs);
|
|
5575
5278
|
}
|
|
5576
5279
|
__name(concat, "concat");
|
|
5577
5280
|
function push(v, arg) {
|
|
@@ -5587,7 +5290,9 @@ function unshift(v, arg) {
|
|
|
5587
5290
|
}
|
|
5588
5291
|
__name(unshift, "unshift");
|
|
5589
5292
|
function pop(v) {
|
|
5590
|
-
const
|
|
5293
|
+
const array = toArray(v);
|
|
5294
|
+
this.context.memoryLimit.use(array.length);
|
|
5295
|
+
const clone = [...array];
|
|
5591
5296
|
clone.pop();
|
|
5592
5297
|
return clone;
|
|
5593
5298
|
}
|
|
@@ -5606,31 +5311,40 @@ function slice(v, begin, length = 1) {
|
|
|
5606
5311
|
return [];
|
|
5607
5312
|
if (!isArray(v))
|
|
5608
5313
|
v = stringify(v);
|
|
5609
|
-
begin = begin < 0 ? v.length + begin : begin;
|
|
5314
|
+
begin = begin < 0 ? (isArray(v) ? v.length : codePointLength(v)) + begin : begin;
|
|
5315
|
+
if (begin < 0 || length < 0)
|
|
5316
|
+
return isArray(v) ? [] : "";
|
|
5610
5317
|
this.context.memoryLimit.use(length);
|
|
5611
|
-
|
|
5318
|
+
if (isArray(v))
|
|
5319
|
+
return Array.prototype.slice.call(v, begin, begin + length);
|
|
5320
|
+
const start = advanceCodePoints(v, 0, begin);
|
|
5321
|
+
return v.slice(start, advanceCodePoints(v, start, length));
|
|
5612
5322
|
}
|
|
5613
5323
|
__name(slice, "slice");
|
|
5614
|
-
function
|
|
5324
|
+
function* matches(value, expected) {
|
|
5615
5325
|
if (this.context.opts.jekyllWhere) {
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
return
|
|
5326
|
+
if (EmptyDrop.is(expected))
|
|
5327
|
+
return yield equals(value, expected);
|
|
5328
|
+
if (isArray(value))
|
|
5329
|
+
return yield arrayIncludes(value, expected);
|
|
5330
|
+
return yield equals(value, expected);
|
|
5621
5331
|
}
|
|
5332
|
+
if (expected === void 0)
|
|
5333
|
+
return isTruthy(value, this.context);
|
|
5334
|
+
return yield equals(value, expected);
|
|
5622
5335
|
}
|
|
5623
|
-
__name(
|
|
5336
|
+
__name(matches, "matches");
|
|
5624
5337
|
function* filter(include, arr, property, expected) {
|
|
5625
|
-
const values = [];
|
|
5626
5338
|
arr = toArray(arr);
|
|
5627
5339
|
this.context.memoryLimit.use(arr.length);
|
|
5628
5340
|
const token = new Tokenizer(stringify(property)).readScopeValue();
|
|
5341
|
+
const result = [];
|
|
5629
5342
|
for (const item of arr) {
|
|
5630
|
-
|
|
5343
|
+
const value = yield evalToken(token, this.context.spawn(item));
|
|
5344
|
+
if ((yield matches.call(this, value, expected)) === include)
|
|
5345
|
+
result.push(item);
|
|
5631
5346
|
}
|
|
5632
|
-
|
|
5633
|
-
return arr.filter((_, i) => matcher(values[i]) === include);
|
|
5347
|
+
return result;
|
|
5634
5348
|
}
|
|
5635
5349
|
__name(filter, "filter");
|
|
5636
5350
|
function* filter_exp(include, arr, itemName, exp) {
|
|
@@ -5697,10 +5411,9 @@ __name(group_by_exp, "group_by_exp");
|
|
|
5697
5411
|
function* search(arr, property, expected) {
|
|
5698
5412
|
const token = new Tokenizer(stringify(property)).readScopeValue();
|
|
5699
5413
|
const array = toArray(arr);
|
|
5700
|
-
const matcher = expectedMatcher.call(this, expected);
|
|
5701
5414
|
for (let index = 0; index < array.length; index++) {
|
|
5702
5415
|
const value = yield evalToken(token, this.context.spawn(array[index]));
|
|
5703
|
-
if (
|
|
5416
|
+
if (yield matches.call(this, value, expected))
|
|
5704
5417
|
return [index, array[index]];
|
|
5705
5418
|
}
|
|
5706
5419
|
}
|
|
@@ -5759,7 +5472,7 @@ function sample(v, count = 1) {
|
|
|
5759
5472
|
return [];
|
|
5760
5473
|
if (!isArray(v))
|
|
5761
5474
|
v = stringify(v);
|
|
5762
|
-
this.context.memoryLimit.use(
|
|
5475
|
+
this.context.memoryLimit.use(v.length);
|
|
5763
5476
|
const shuffled = [...v].sort(() => Math.random() - 0.5);
|
|
5764
5477
|
if (count === 1)
|
|
5765
5478
|
return shuffled[0];
|
|
@@ -5800,15 +5513,16 @@ var arrayFilters = /* @__PURE__ */ Object.freeze({
|
|
|
5800
5513
|
sample
|
|
5801
5514
|
});
|
|
5802
5515
|
function date(v, format2, timezoneOffset) {
|
|
5803
|
-
var _a, _b
|
|
5804
|
-
const size2 = ((_a = v === null || v === void 0 ? void 0 : v.length) !== null && _a !== void 0 ? _a : 0) + ((_b =
|
|
5516
|
+
var _a, _b;
|
|
5517
|
+
const size2 = ((_a = v === null || v === void 0 ? void 0 : v.length) !== null && _a !== void 0 ? _a : 0) + ((_b = timezoneOffset === null || timezoneOffset === void 0 ? void 0 : timezoneOffset.length) !== null && _b !== void 0 ? _b : 0);
|
|
5805
5518
|
this.context.memoryLimit.use(size2);
|
|
5806
5519
|
const date2 = parseDate(v, this.context.opts, timezoneOffset);
|
|
5807
5520
|
if (!date2)
|
|
5808
5521
|
return v;
|
|
5809
5522
|
format2 = toValue(format2);
|
|
5810
5523
|
format2 = isNil(format2) ? this.context.opts.dateFormat : stringify(format2);
|
|
5811
|
-
|
|
5524
|
+
this.context.memoryLimit.use(format2.length);
|
|
5525
|
+
return strftime(date2, format2, this.context.memoryLimit);
|
|
5812
5526
|
}
|
|
5813
5527
|
__name(date, "date");
|
|
5814
5528
|
function date_to_xmlschema(v) {
|
|
@@ -5816,7 +5530,10 @@ function date_to_xmlschema(v) {
|
|
|
5816
5530
|
}
|
|
5817
5531
|
__name(date_to_xmlschema, "date_to_xmlschema");
|
|
5818
5532
|
function date_to_rfc822(v) {
|
|
5819
|
-
|
|
5533
|
+
const date2 = parseDate(v, this.context.opts, void 0, "en-US");
|
|
5534
|
+
if (!date2)
|
|
5535
|
+
return v;
|
|
5536
|
+
return strftime(date2, "%a, %d %b %Y %H:%M:%S %z", this.context.memoryLimit);
|
|
5820
5537
|
}
|
|
5821
5538
|
__name(date_to_rfc822, "date_to_rfc822");
|
|
5822
5539
|
function date_to_string(v, type, style) {
|
|
@@ -5831,19 +5548,21 @@ function stringify_date(v, month_type, type, style) {
|
|
|
5831
5548
|
const date2 = parseDate(v, this.context.opts);
|
|
5832
5549
|
if (!date2)
|
|
5833
5550
|
return v;
|
|
5551
|
+
const ml = this.context.memoryLimit;
|
|
5834
5552
|
if (type === "ordinal") {
|
|
5835
5553
|
const d = date2.getDate();
|
|
5836
|
-
return style === "US" ? strftime(date2, `${month_type} ${d}%q, %Y
|
|
5554
|
+
return style === "US" ? strftime(date2, `${month_type} ${d}%q, %Y`, ml) : strftime(date2, `${d}%q ${month_type} %Y`, ml);
|
|
5837
5555
|
}
|
|
5838
|
-
return strftime(date2, `%d ${month_type} %Y
|
|
5556
|
+
return strftime(date2, `%d ${month_type} %Y`, ml);
|
|
5839
5557
|
}
|
|
5840
5558
|
__name(stringify_date, "stringify_date");
|
|
5841
|
-
function parseDate(v, opts, timezoneOffset) {
|
|
5559
|
+
function parseDate(v, opts, timezoneOffset, locale = opts.locale) {
|
|
5842
5560
|
let date2;
|
|
5843
5561
|
const defaultTimezoneOffset = timezoneOffset !== null && timezoneOffset !== void 0 ? timezoneOffset : opts.timezoneOffset;
|
|
5844
|
-
const locale = opts.locale;
|
|
5845
5562
|
v = toValue(v);
|
|
5846
|
-
if (v
|
|
5563
|
+
if (isNil(v)) {
|
|
5564
|
+
return void 0;
|
|
5565
|
+
} else if (v === "now" || v === "today") {
|
|
5847
5566
|
date2 = new LiquidDate(Date.now(), locale, defaultTimezoneOffset);
|
|
5848
5567
|
} else if (isNumber(v)) {
|
|
5849
5568
|
date2 = new LiquidDate(v * 1e3, locale, defaultTimezoneOffset);
|
|
@@ -5887,14 +5606,36 @@ function prepend(v, arg) {
|
|
|
5887
5606
|
return rhs + lhs;
|
|
5888
5607
|
}
|
|
5889
5608
|
__name(prepend, "prepend");
|
|
5609
|
+
function getTrimStart(str, chars) {
|
|
5610
|
+
let start = 0;
|
|
5611
|
+
for (const char of str) {
|
|
5612
|
+
if (!chars.has(char))
|
|
5613
|
+
break;
|
|
5614
|
+
start += char.length;
|
|
5615
|
+
}
|
|
5616
|
+
return start;
|
|
5617
|
+
}
|
|
5618
|
+
__name(getTrimStart, "getTrimStart");
|
|
5619
|
+
function getTrimEnd(str, chars, start = 0) {
|
|
5620
|
+
let end = str.length;
|
|
5621
|
+
while (end > start) {
|
|
5622
|
+
const size2 = end - start >= 2 && str.codePointAt(end - 2) > 65535 ? 2 : 1;
|
|
5623
|
+
if (!chars.has(str.slice(end - size2, end)))
|
|
5624
|
+
break;
|
|
5625
|
+
end -= size2;
|
|
5626
|
+
}
|
|
5627
|
+
return end;
|
|
5628
|
+
}
|
|
5629
|
+
__name(getTrimEnd, "getTrimEnd");
|
|
5890
5630
|
function lstrip(v, chars) {
|
|
5891
5631
|
const str = stringify(v);
|
|
5892
5632
|
this.context.memoryLimit.use(str.length);
|
|
5893
5633
|
if (chars) {
|
|
5894
|
-
chars =
|
|
5895
|
-
|
|
5634
|
+
chars = stringify(chars);
|
|
5635
|
+
this.context.memoryLimit.use(chars.length);
|
|
5636
|
+
return str.slice(getTrimStart(str, new Set(chars)));
|
|
5896
5637
|
}
|
|
5897
|
-
return str.
|
|
5638
|
+
return str.trimStart();
|
|
5898
5639
|
}
|
|
5899
5640
|
__name(lstrip, "lstrip");
|
|
5900
5641
|
function downcase(v) {
|
|
@@ -5911,20 +5652,22 @@ function upcase(v) {
|
|
|
5911
5652
|
__name(upcase, "upcase");
|
|
5912
5653
|
function remove(v, arg) {
|
|
5913
5654
|
const str = stringify(v);
|
|
5914
|
-
|
|
5915
|
-
|
|
5655
|
+
arg = stringify(arg);
|
|
5656
|
+
this.context.memoryLimit.use(str.length + arg.length);
|
|
5657
|
+
return str.split(arg).join("");
|
|
5916
5658
|
}
|
|
5917
5659
|
__name(remove, "remove");
|
|
5918
5660
|
function remove_first(v, l) {
|
|
5919
5661
|
const str = stringify(v);
|
|
5920
|
-
|
|
5921
|
-
|
|
5662
|
+
l = stringify(l);
|
|
5663
|
+
this.context.memoryLimit.use(str.length + l.length);
|
|
5664
|
+
return str.replace(l, "");
|
|
5922
5665
|
}
|
|
5923
5666
|
__name(remove_first, "remove_first");
|
|
5924
5667
|
function remove_last(v, l) {
|
|
5925
5668
|
const str = stringify(v);
|
|
5926
|
-
this.context.memoryLimit.use(str.length);
|
|
5927
5669
|
const pattern = stringify(l);
|
|
5670
|
+
this.context.memoryLimit.use(str.length + pattern.length);
|
|
5928
5671
|
const index = str.lastIndexOf(pattern);
|
|
5929
5672
|
if (index === -1)
|
|
5930
5673
|
return str;
|
|
@@ -5935,10 +5678,11 @@ function rstrip(str, chars) {
|
|
|
5935
5678
|
str = stringify(str);
|
|
5936
5679
|
this.context.memoryLimit.use(str.length);
|
|
5937
5680
|
if (chars) {
|
|
5938
|
-
chars =
|
|
5939
|
-
|
|
5681
|
+
chars = stringify(chars);
|
|
5682
|
+
this.context.memoryLimit.use(chars.length);
|
|
5683
|
+
return str.slice(0, getTrimEnd(str, new Set(chars)));
|
|
5940
5684
|
}
|
|
5941
|
-
return str.
|
|
5685
|
+
return str.trimEnd();
|
|
5942
5686
|
}
|
|
5943
5687
|
__name(rstrip, "rstrip");
|
|
5944
5688
|
function split(v, arg) {
|
|
@@ -5954,8 +5698,10 @@ function strip(v, chars) {
|
|
|
5954
5698
|
const str = stringify(v);
|
|
5955
5699
|
this.context.memoryLimit.use(str.length);
|
|
5956
5700
|
if (chars) {
|
|
5957
|
-
|
|
5958
|
-
|
|
5701
|
+
const set = new Set(stringify(chars));
|
|
5702
|
+
this.context.memoryLimit.use(set.size);
|
|
5703
|
+
const start = getTrimStart(str, set);
|
|
5704
|
+
return str.slice(start, getTrimEnd(str, set, start));
|
|
5959
5705
|
}
|
|
5960
5706
|
return str.trim();
|
|
5961
5707
|
}
|
|
@@ -5966,6 +5712,12 @@ function strip_newlines(v) {
|
|
|
5966
5712
|
return str.replace(/\r?\n/gm, "");
|
|
5967
5713
|
}
|
|
5968
5714
|
__name(strip_newlines, "strip_newlines");
|
|
5715
|
+
function squish(v) {
|
|
5716
|
+
const str = stringify(v);
|
|
5717
|
+
this.context.memoryLimit.use(str.length);
|
|
5718
|
+
return str.replace(/\s+/g, " ").trim();
|
|
5719
|
+
}
|
|
5720
|
+
__name(squish, "squish");
|
|
5969
5721
|
function capitalize(str) {
|
|
5970
5722
|
str = stringify(str);
|
|
5971
5723
|
this.context.memoryLimit.use(str.length);
|
|
@@ -5974,39 +5726,47 @@ function capitalize(str) {
|
|
|
5974
5726
|
__name(capitalize, "capitalize");
|
|
5975
5727
|
function replace(v, pattern, replacement) {
|
|
5976
5728
|
const str = stringify(v);
|
|
5977
|
-
|
|
5978
|
-
|
|
5729
|
+
pattern = stringify(pattern);
|
|
5730
|
+
replacement = stringify(replacement);
|
|
5731
|
+
const parts = str.split(pattern);
|
|
5732
|
+
const outputSize = str.length + (parts.length - 1) * (replacement.length - pattern.length);
|
|
5733
|
+
this.context.memoryLimit.use(outputSize);
|
|
5734
|
+
return parts.join(replacement);
|
|
5979
5735
|
}
|
|
5980
5736
|
__name(replace, "replace");
|
|
5981
5737
|
function replace_first(v, arg1, arg2) {
|
|
5982
5738
|
const str = stringify(v);
|
|
5983
|
-
|
|
5984
|
-
|
|
5739
|
+
arg1 = stringify(arg1);
|
|
5740
|
+
arg2 = stringify(arg2);
|
|
5741
|
+
this.context.memoryLimit.use(str.length + arg1.length + arg2.length);
|
|
5742
|
+
return str.replace(arg1, () => arg2);
|
|
5985
5743
|
}
|
|
5986
5744
|
__name(replace_first, "replace_first");
|
|
5987
5745
|
function replace_last(v, arg1, arg2) {
|
|
5988
5746
|
const str = stringify(v);
|
|
5989
|
-
this.context.memoryLimit.use(str.length);
|
|
5990
5747
|
const pattern = stringify(arg1);
|
|
5748
|
+
const replacement = stringify(arg2);
|
|
5749
|
+
this.context.memoryLimit.use(str.length + pattern.length + replacement.length);
|
|
5991
5750
|
const index = str.lastIndexOf(pattern);
|
|
5992
5751
|
if (index === -1)
|
|
5993
5752
|
return str;
|
|
5994
|
-
const replacement = stringify(arg2);
|
|
5995
5753
|
return str.substring(0, index) + replacement + str.substring(index + pattern.length);
|
|
5996
5754
|
}
|
|
5997
5755
|
__name(replace_last, "replace_last");
|
|
5998
5756
|
function truncate(v, l = 50, o = "...") {
|
|
5999
5757
|
const str = stringify(v);
|
|
6000
|
-
|
|
6001
|
-
|
|
5758
|
+
o = stringify(o);
|
|
5759
|
+
this.context.memoryLimit.use(str.length + o.length);
|
|
5760
|
+
if (str.length <= l || advanceCodePoints(str, 0, l) >= str.length)
|
|
6002
5761
|
return v;
|
|
6003
|
-
return str.
|
|
5762
|
+
return str.slice(0, advanceCodePoints(str, 0, Math.max(l - codePointLength(o), 0))) + o;
|
|
6004
5763
|
}
|
|
6005
5764
|
__name(truncate, "truncate");
|
|
6006
5765
|
function truncatewords(v, words = 15, o = "...") {
|
|
6007
5766
|
const str = stringify(v);
|
|
6008
|
-
|
|
6009
|
-
|
|
5767
|
+
o = stringify(o);
|
|
5768
|
+
this.context.memoryLimit.use(str.length + o.length);
|
|
5769
|
+
const arr = str.trimStart().split(/\s+/);
|
|
6010
5770
|
if (words <= 0)
|
|
6011
5771
|
words = 1;
|
|
6012
5772
|
let ret = arr.slice(0, words).join(" ");
|
|
@@ -6037,8 +5797,13 @@ function number_of_words(input, mode) {
|
|
|
6037
5797
|
}
|
|
6038
5798
|
}
|
|
6039
5799
|
__name(number_of_words, "number_of_words");
|
|
6040
|
-
function array_to_sentence_string(
|
|
6041
|
-
|
|
5800
|
+
function array_to_sentence_string(input, connector = "and") {
|
|
5801
|
+
const array = toArray(input);
|
|
5802
|
+
connector = stringify(connector);
|
|
5803
|
+
let outputSize = connector.length + array.length * 2;
|
|
5804
|
+
for (let i = 0; i < array.length; i++)
|
|
5805
|
+
outputSize += stringify(array[i]).length;
|
|
5806
|
+
this.context.memoryLimit.use(outputSize);
|
|
6042
5807
|
switch (array.length) {
|
|
6043
5808
|
case 0:
|
|
6044
5809
|
return "";
|
|
@@ -6065,6 +5830,7 @@ var stringFilters = /* @__PURE__ */ Object.freeze({
|
|
|
6065
5830
|
split,
|
|
6066
5831
|
strip,
|
|
6067
5832
|
strip_newlines,
|
|
5833
|
+
squish,
|
|
6068
5834
|
capitalize,
|
|
6069
5835
|
replace,
|
|
6070
5836
|
replace_first,
|
|
@@ -6075,7 +5841,93 @@ var stringFilters = /* @__PURE__ */ Object.freeze({
|
|
|
6075
5841
|
number_of_words,
|
|
6076
5842
|
array_to_sentence_string
|
|
6077
5843
|
});
|
|
6078
|
-
|
|
5844
|
+
function base64Encode(str) {
|
|
5845
|
+
const bytes = new TextEncoder().encode(str);
|
|
5846
|
+
let binary = "";
|
|
5847
|
+
for (let i = 0; i < bytes.length; i += 32768) {
|
|
5848
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
5849
|
+
}
|
|
5850
|
+
return btoa(binary);
|
|
5851
|
+
}
|
|
5852
|
+
__name(base64Encode, "base64Encode");
|
|
5853
|
+
function base64Decode(str) {
|
|
5854
|
+
return new TextDecoder().decode(Uint8Array.from(atob(str), (c) => c.charCodeAt(0)));
|
|
5855
|
+
}
|
|
5856
|
+
__name(base64Decode, "base64Decode");
|
|
5857
|
+
function base64_encode(value) {
|
|
5858
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(value)) {
|
|
5859
|
+
this.context.memoryLimit.use(value.byteLength);
|
|
5860
|
+
return value.toString("base64");
|
|
5861
|
+
}
|
|
5862
|
+
const str = stringify(value);
|
|
5863
|
+
this.context.memoryLimit.use(str.length);
|
|
5864
|
+
return base64Encode(str);
|
|
5865
|
+
}
|
|
5866
|
+
__name(base64_encode, "base64_encode");
|
|
5867
|
+
function base64_decode(value) {
|
|
5868
|
+
const str = stringify(value);
|
|
5869
|
+
this.context.memoryLimit.use(str.length);
|
|
5870
|
+
assert(isBase64(str), "invalid base64 provided to base64_decode");
|
|
5871
|
+
return base64Decode(str);
|
|
5872
|
+
}
|
|
5873
|
+
__name(base64_decode, "base64_decode");
|
|
5874
|
+
function isBase64(str) {
|
|
5875
|
+
str = str.replace(/[\t\n\f\r ]/g, "");
|
|
5876
|
+
if (str.length % 4 === 0)
|
|
5877
|
+
str = str.replace(/==?$/, "");
|
|
5878
|
+
return str.length % 4 !== 1 && /^[A-Za-z0-9+/]*$/.test(str);
|
|
5879
|
+
}
|
|
5880
|
+
__name(isBase64, "isBase64");
|
|
5881
|
+
var base64Filters = /* @__PURE__ */ Object.freeze({
|
|
5882
|
+
__proto__: null,
|
|
5883
|
+
base64_encode,
|
|
5884
|
+
base64_decode
|
|
5885
|
+
});
|
|
5886
|
+
function bufferToHex(buffer) {
|
|
5887
|
+
const bytes = new Uint8Array(buffer);
|
|
5888
|
+
let hex = "";
|
|
5889
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
5890
|
+
hex += bytes[i].toString(16).padStart(2, "0");
|
|
5891
|
+
}
|
|
5892
|
+
return hex;
|
|
5893
|
+
}
|
|
5894
|
+
__name(bufferToHex, "bufferToHex");
|
|
5895
|
+
function sha256(str) {
|
|
5896
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5897
|
+
const data = new TextEncoder().encode(str);
|
|
5898
|
+
const digest = yield crypto.subtle.digest("SHA-256", data);
|
|
5899
|
+
return bufferToHex(digest);
|
|
5900
|
+
});
|
|
5901
|
+
}
|
|
5902
|
+
__name(sha256, "sha256");
|
|
5903
|
+
function hmacSha256(str, key) {
|
|
5904
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5905
|
+
const encoder = new TextEncoder();
|
|
5906
|
+
const cryptoKey = yield crypto.subtle.importKey("raw", encoder.encode(key), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
5907
|
+
const signature = yield crypto.subtle.sign("HMAC", cryptoKey, encoder.encode(str));
|
|
5908
|
+
return bufferToHex(signature);
|
|
5909
|
+
});
|
|
5910
|
+
}
|
|
5911
|
+
__name(hmacSha256, "hmacSha256");
|
|
5912
|
+
function sha256$1(value) {
|
|
5913
|
+
const str = stringify(value);
|
|
5914
|
+
this.context.memoryLimit.use(str.length);
|
|
5915
|
+
return sha256(str);
|
|
5916
|
+
}
|
|
5917
|
+
__name(sha256$1, "sha256$1");
|
|
5918
|
+
function hmac_sha256(value, key) {
|
|
5919
|
+
const str = stringify(value);
|
|
5920
|
+
const keyStr = stringify(key);
|
|
5921
|
+
this.context.memoryLimit.use(str.length + keyStr.length);
|
|
5922
|
+
return hmacSha256(str, keyStr);
|
|
5923
|
+
}
|
|
5924
|
+
__name(hmac_sha256, "hmac_sha256");
|
|
5925
|
+
var cryptoFilters = /* @__PURE__ */ Object.freeze({
|
|
5926
|
+
__proto__: null,
|
|
5927
|
+
sha256: sha256$1,
|
|
5928
|
+
hmac_sha256
|
|
5929
|
+
});
|
|
5930
|
+
var filters = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, htmlFilters), mathFilters), urlFilters), arrayFilters), dateFilters), stringFilters), base64Filters), cryptoFilters), misc);
|
|
6079
5931
|
var AssignTag = class extends Tag {
|
|
6080
5932
|
static {
|
|
6081
5933
|
__name(this, "AssignTag");
|
|
@@ -6138,7 +5990,7 @@ var ForTag = class extends Tag {
|
|
|
6138
5990
|
return;
|
|
6139
5991
|
}
|
|
6140
5992
|
const continueKey = "continue-" + this.variable + "-" + this.collection.getText();
|
|
6141
|
-
ctx.push({ continue: ctx.getRegister(continueKey) });
|
|
5993
|
+
ctx.push(createScope({ continue: ctx.getRegister(continueKey, {}) }));
|
|
6142
5994
|
const hash = yield this.hash.render(ctx);
|
|
6143
5995
|
ctx.pop();
|
|
6144
5996
|
const modifiers = this.liquid.options.orderedFilterParameters ? Object.keys(hash).filter((x) => MODIFIERS.includes(x)) : MODIFIERS.filter((x) => hash[x] !== void 0);
|
|
@@ -6150,7 +6002,7 @@ var ForTag = class extends Tag {
|
|
|
6150
6002
|
return reversed(collection2);
|
|
6151
6003
|
}, collection);
|
|
6152
6004
|
ctx.setRegister(continueKey, (hash["offset"] || 0) + collection.length);
|
|
6153
|
-
const scope = { forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) };
|
|
6005
|
+
const scope = createScope({ forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) });
|
|
6154
6006
|
ctx.push(scope);
|
|
6155
6007
|
for (const item of collection) {
|
|
6156
6008
|
scope[this.variable] = item;
|
|
@@ -6277,12 +6129,12 @@ var CaseTag = class extends Tag {
|
|
|
6277
6129
|
}
|
|
6278
6130
|
*render(ctx, emitter) {
|
|
6279
6131
|
const r = this.liquid.renderer;
|
|
6280
|
-
const target = toValue(yield this.value.value(ctx, ctx.opts.lenientIf));
|
|
6132
|
+
const target = yield toValue(yield this.value.value(ctx, ctx.opts.lenientIf));
|
|
6281
6133
|
let branchHit = false;
|
|
6282
6134
|
for (const branch of this.branches) {
|
|
6283
6135
|
for (const valueToken of branch.values) {
|
|
6284
6136
|
const value = yield evalToken(valueToken, ctx, ctx.opts.lenientIf);
|
|
6285
|
-
if (equals(target, value)) {
|
|
6137
|
+
if (yield equals(target, value)) {
|
|
6286
6138
|
yield r.renderTemplates(branch.templates, ctx, emitter);
|
|
6287
6139
|
branchHit = true;
|
|
6288
6140
|
break;
|
|
@@ -6346,7 +6198,11 @@ var RenderTag = class extends Tag {
|
|
|
6346
6198
|
alias = tokenizer.readIdentifier();
|
|
6347
6199
|
else
|
|
6348
6200
|
tokenizer.p = beforeAs;
|
|
6349
|
-
|
|
6201
|
+
const binding = { value, alias: alias && alias.content };
|
|
6202
|
+
if (keyword.content === "with")
|
|
6203
|
+
this.with = binding;
|
|
6204
|
+
else
|
|
6205
|
+
this.forBinding = binding;
|
|
6350
6206
|
tokenizer.skipBlank();
|
|
6351
6207
|
if (tokenizer.peek() === ",")
|
|
6352
6208
|
tokenizer.advance();
|
|
@@ -6361,56 +6217,56 @@ var RenderTag = class extends Tag {
|
|
|
6361
6217
|
}
|
|
6362
6218
|
*render(ctx, emitter) {
|
|
6363
6219
|
const { liquid, hash } = this;
|
|
6364
|
-
const filepath = yield renderFilePath(this
|
|
6220
|
+
const filepath = yield renderFilePath(this.file, ctx, liquid);
|
|
6365
6221
|
assert(filepath, () => `illegal file path "${filepath}"`);
|
|
6366
6222
|
const childCtx = ctx.spawn();
|
|
6367
6223
|
const scope = childCtx.bottom();
|
|
6368
6224
|
__assign(scope, yield hash.render(ctx));
|
|
6369
|
-
if (this
|
|
6370
|
-
const { value, alias } = this
|
|
6225
|
+
if (this.with) {
|
|
6226
|
+
const { value, alias } = this.with;
|
|
6371
6227
|
scope[alias || filepath] = yield evalToken(value, ctx);
|
|
6372
6228
|
}
|
|
6373
|
-
if (this
|
|
6374
|
-
const { value, alias } = this
|
|
6229
|
+
if (this.forBinding) {
|
|
6230
|
+
const { value, alias } = this.forBinding;
|
|
6375
6231
|
const collection = toEnumerable(yield evalToken(value, ctx));
|
|
6376
6232
|
scope["forloop"] = new ForloopDrop(collection.length, value.getText(), alias);
|
|
6377
6233
|
for (const item of collection) {
|
|
6378
6234
|
scope[alias] = item;
|
|
6379
|
-
const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this
|
|
6235
|
+
const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile);
|
|
6380
6236
|
yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
|
|
6381
6237
|
scope["forloop"].next();
|
|
6382
6238
|
}
|
|
6383
6239
|
} else {
|
|
6384
|
-
const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this
|
|
6240
|
+
const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile);
|
|
6385
6241
|
yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
|
|
6386
6242
|
}
|
|
6387
6243
|
}
|
|
6388
6244
|
*children(partials, sync) {
|
|
6389
|
-
if (partials && isString(this
|
|
6390
|
-
return yield this.liquid._parsePartialFile(this
|
|
6245
|
+
if (partials && isString(this.file)) {
|
|
6246
|
+
return yield this.liquid._parsePartialFile(this.file, sync, this.currentFile);
|
|
6391
6247
|
}
|
|
6392
6248
|
return [];
|
|
6393
6249
|
}
|
|
6394
6250
|
partialScope() {
|
|
6395
|
-
if (isString(this
|
|
6396
|
-
const
|
|
6397
|
-
if (this
|
|
6398
|
-
const { value, alias } = this
|
|
6251
|
+
if (isString(this.file)) {
|
|
6252
|
+
const names2 = Object.keys(this.hash.hash);
|
|
6253
|
+
if (this.with) {
|
|
6254
|
+
const { value, alias } = this.with;
|
|
6399
6255
|
if (isString(alias)) {
|
|
6400
|
-
|
|
6256
|
+
names2.push([alias, value]);
|
|
6401
6257
|
} else if (isString(this.file)) {
|
|
6402
|
-
|
|
6258
|
+
names2.push([this.file, value]);
|
|
6403
6259
|
}
|
|
6404
6260
|
}
|
|
6405
|
-
if (this
|
|
6406
|
-
const { value, alias } = this
|
|
6261
|
+
if (this.forBinding) {
|
|
6262
|
+
const { value, alias } = this.forBinding;
|
|
6407
6263
|
if (isString(alias)) {
|
|
6408
|
-
|
|
6264
|
+
names2.push([alias, value]);
|
|
6409
6265
|
} else if (isString(this.file)) {
|
|
6410
|
-
|
|
6266
|
+
names2.push([this.file, value]);
|
|
6411
6267
|
}
|
|
6412
6268
|
}
|
|
6413
|
-
return { name: this
|
|
6269
|
+
return { name: this.file, isolated: true, scope: names2 };
|
|
6414
6270
|
}
|
|
6415
6271
|
}
|
|
6416
6272
|
*arguments() {
|
|
@@ -6419,14 +6275,14 @@ var RenderTag = class extends Tag {
|
|
|
6419
6275
|
yield v;
|
|
6420
6276
|
}
|
|
6421
6277
|
}
|
|
6422
|
-
if (this
|
|
6423
|
-
const { value } = this
|
|
6278
|
+
if (this.with) {
|
|
6279
|
+
const { value } = this.with;
|
|
6424
6280
|
if (isValueToken(value)) {
|
|
6425
6281
|
yield value;
|
|
6426
6282
|
}
|
|
6427
6283
|
}
|
|
6428
|
-
if (this
|
|
6429
|
-
const { value } = this
|
|
6284
|
+
if (this.forBinding) {
|
|
6285
|
+
const { value } = this.forBinding;
|
|
6430
6286
|
if (isValueToken(value)) {
|
|
6431
6287
|
yield value;
|
|
6432
6288
|
}
|
|
@@ -6471,8 +6327,8 @@ var IncludeTag = class extends Tag {
|
|
|
6471
6327
|
constructor(token, remainTokens, liquid, parser) {
|
|
6472
6328
|
super(token, remainTokens, liquid);
|
|
6473
6329
|
const { tokenizer } = token;
|
|
6474
|
-
this
|
|
6475
|
-
this
|
|
6330
|
+
this.file = parseFilePath(tokenizer, this.liquid, parser);
|
|
6331
|
+
this.currentFile = token.file;
|
|
6476
6332
|
const begin = tokenizer.p;
|
|
6477
6333
|
const withStr = tokenizer.readIdentifier();
|
|
6478
6334
|
if (withStr.content === "with") {
|
|
@@ -6488,44 +6344,44 @@ var IncludeTag = class extends Tag {
|
|
|
6488
6344
|
*render(ctx, emitter) {
|
|
6489
6345
|
const { liquid, hash, withVar } = this;
|
|
6490
6346
|
const { renderer } = liquid;
|
|
6491
|
-
const filepath = yield renderFilePath(this
|
|
6347
|
+
const filepath = yield renderFilePath(this.file, ctx, liquid);
|
|
6492
6348
|
assert(filepath, () => `illegal file path "${filepath}"`);
|
|
6493
6349
|
const saved = ctx.saveRegister("blocks", "blockMode");
|
|
6494
6350
|
ctx.setRegister("blocks", {});
|
|
6495
6351
|
ctx.setRegister("blockMode", BlockMode.OUTPUT);
|
|
6496
|
-
const scope = yield hash.render(ctx);
|
|
6352
|
+
const scope = createScope(yield hash.render(ctx));
|
|
6497
6353
|
if (withVar)
|
|
6498
6354
|
scope[filepath] = yield evalToken(withVar, ctx);
|
|
6499
|
-
const templates = yield liquid._parsePartialFile(filepath, ctx.sync, this
|
|
6500
|
-
ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
|
|
6355
|
+
const templates = yield liquid._parsePartialFile(filepath, ctx.sync, this.currentFile);
|
|
6356
|
+
ctx.push(ctx.opts.jekyllInclude ? createScope({ include: scope }) : scope);
|
|
6501
6357
|
yield renderer.renderTemplates(templates, ctx, emitter);
|
|
6502
6358
|
ctx.pop();
|
|
6503
6359
|
ctx.restoreRegister(saved);
|
|
6504
6360
|
}
|
|
6505
6361
|
*children(partials, sync) {
|
|
6506
|
-
if (partials && isString(this
|
|
6507
|
-
return yield this.liquid._parsePartialFile(this
|
|
6362
|
+
if (partials && isString(this.file)) {
|
|
6363
|
+
return yield this.liquid._parsePartialFile(this.file, sync, this.currentFile);
|
|
6508
6364
|
}
|
|
6509
6365
|
return [];
|
|
6510
6366
|
}
|
|
6511
6367
|
partialScope() {
|
|
6512
|
-
if (isString(this
|
|
6513
|
-
let
|
|
6368
|
+
if (isString(this.file)) {
|
|
6369
|
+
let names2;
|
|
6514
6370
|
if (this.liquid.options.jekyllInclude) {
|
|
6515
|
-
|
|
6371
|
+
names2 = ["include"];
|
|
6516
6372
|
} else {
|
|
6517
|
-
|
|
6373
|
+
names2 = Object.keys(this.hash.hash);
|
|
6518
6374
|
if (this.withVar) {
|
|
6519
|
-
|
|
6375
|
+
names2.push([this.file, this.withVar]);
|
|
6520
6376
|
}
|
|
6521
6377
|
}
|
|
6522
|
-
return { name: this
|
|
6378
|
+
return { name: this.file, isolated: false, scope: names2 };
|
|
6523
6379
|
}
|
|
6524
6380
|
}
|
|
6525
6381
|
*arguments() {
|
|
6526
6382
|
yield* Object.values(this.hash.hash).filter(isValueToken);
|
|
6527
|
-
if (isValueToken(this
|
|
6528
|
-
yield this
|
|
6383
|
+
if (isValueToken(this.file)) {
|
|
6384
|
+
yield this.file;
|
|
6529
6385
|
}
|
|
6530
6386
|
if (isValueToken(this.withVar)) {
|
|
6531
6387
|
yield this.withVar;
|
|
@@ -6559,6 +6415,7 @@ var CycleTag = class extends Tag {
|
|
|
6559
6415
|
constructor(token, remainTokens, liquid) {
|
|
6560
6416
|
super(token, remainTokens, liquid);
|
|
6561
6417
|
this.candidates = [];
|
|
6418
|
+
const begin = this.tokenizer.p;
|
|
6562
6419
|
const group = this.tokenizer.readValue();
|
|
6563
6420
|
this.tokenizer.skipBlank();
|
|
6564
6421
|
if (group) {
|
|
@@ -6566,28 +6423,33 @@ var CycleTag = class extends Tag {
|
|
|
6566
6423
|
this.group = group;
|
|
6567
6424
|
this.tokenizer.advance();
|
|
6568
6425
|
} else
|
|
6569
|
-
this.
|
|
6426
|
+
this.tokenizer.p = begin;
|
|
6570
6427
|
}
|
|
6571
6428
|
while (!this.tokenizer.end()) {
|
|
6572
|
-
const value = this.tokenizer.
|
|
6573
|
-
|
|
6574
|
-
this.candidates.push(value);
|
|
6429
|
+
const value = this.tokenizer.readFilteredValue();
|
|
6430
|
+
this.candidates.push(value);
|
|
6575
6431
|
this.tokenizer.readTo(",");
|
|
6576
6432
|
}
|
|
6577
6433
|
this.tokenizer.assert(this.candidates.length, () => `empty candidates: "${token.getText()}"`);
|
|
6578
6434
|
}
|
|
6579
6435
|
*render(ctx, emitter) {
|
|
6436
|
+
var _a;
|
|
6580
6437
|
const group = yield evalToken(this.group, ctx);
|
|
6581
|
-
const fingerprint = `cycle:${group}:` + this.candidates.join(",");
|
|
6582
|
-
const groups = ctx.getRegister("cycle");
|
|
6438
|
+
const fingerprint = `cycle:${group}:` + this.candidates.map((c) => c.getText()).join(",");
|
|
6439
|
+
const groups = ctx.getRegister("cycle", {});
|
|
6583
6440
|
let idx = groups[fingerprint];
|
|
6584
6441
|
if (idx === void 0) {
|
|
6585
6442
|
idx = groups[fingerprint] = 0;
|
|
6586
6443
|
}
|
|
6587
|
-
const candidate = this.candidates[idx];
|
|
6444
|
+
const candidate = new Value(this.candidates[idx], this.liquid);
|
|
6588
6445
|
idx = (idx + 1) % this.candidates.length;
|
|
6589
6446
|
groups[fingerprint] = idx;
|
|
6590
|
-
|
|
6447
|
+
let val = yield toValue(yield candidate.value(ctx, false));
|
|
6448
|
+
const outputEscape = this.liquid.options.outputEscape;
|
|
6449
|
+
if (outputEscape && !((_a = candidate.filters[candidate.filters.length - 1]) === null || _a === void 0 ? void 0 : _a.raw)) {
|
|
6450
|
+
val = yield outputEscape.call({ context: ctx, token: this.token, liquid: this.liquid }, val);
|
|
6451
|
+
}
|
|
6452
|
+
return val;
|
|
6591
6453
|
}
|
|
6592
6454
|
*arguments() {
|
|
6593
6455
|
yield* this.candidates;
|
|
@@ -6627,7 +6489,7 @@ var IfTag = class extends Tag {
|
|
|
6627
6489
|
*render(ctx, emitter) {
|
|
6628
6490
|
const r = this.liquid.renderer;
|
|
6629
6491
|
for (const { value, templates } of this.branches) {
|
|
6630
|
-
const v = yield value.value(ctx, ctx.opts.lenientIf);
|
|
6492
|
+
const v = yield toValue(yield value.value(ctx, ctx.opts.lenientIf));
|
|
6631
6493
|
if (isTruthy(v, ctx)) {
|
|
6632
6494
|
yield r.renderTemplates(templates, ctx, emitter);
|
|
6633
6495
|
return;
|
|
@@ -6675,7 +6537,7 @@ var LayoutTag = class extends Tag {
|
|
|
6675
6537
|
constructor(token, remainTokens, liquid, parser) {
|
|
6676
6538
|
super(token, remainTokens, liquid);
|
|
6677
6539
|
this.file = parseFilePath(this.tokenizer, this.liquid, parser);
|
|
6678
|
-
this
|
|
6540
|
+
this.currentFile = token.file;
|
|
6679
6541
|
this.args = new Hash(this.tokenizer, liquid.options.keyValueSeparator);
|
|
6680
6542
|
this.templates = parser.parseTokens(remainTokens);
|
|
6681
6543
|
}
|
|
@@ -6689,21 +6551,21 @@ var LayoutTag = class extends Tag {
|
|
|
6689
6551
|
}
|
|
6690
6552
|
const filepath = yield renderFilePath(this.file, ctx, liquid);
|
|
6691
6553
|
assert(filepath, () => `illegal file path "${filepath}"`);
|
|
6692
|
-
const templates = yield liquid._parseLayoutFile(filepath, ctx.sync, this
|
|
6554
|
+
const templates = yield liquid._parseLayoutFile(filepath, ctx.sync, this.currentFile);
|
|
6693
6555
|
ctx.setRegister("blockMode", BlockMode.STORE);
|
|
6694
6556
|
const html = yield renderer.renderTemplates(this.templates, ctx);
|
|
6695
|
-
const blocks = ctx.getRegister("blocks");
|
|
6557
|
+
const blocks = ctx.getRegister("blocks", {});
|
|
6696
6558
|
if (blocks[""] === void 0)
|
|
6697
6559
|
blocks[""] = (parent, emitter2) => emitter2.write(html);
|
|
6698
6560
|
ctx.setRegister("blockMode", BlockMode.OUTPUT);
|
|
6699
|
-
ctx.push(yield args.render(ctx));
|
|
6561
|
+
ctx.push(createScope(yield args.render(ctx)));
|
|
6700
6562
|
yield renderer.renderTemplates(templates, ctx, emitter);
|
|
6701
6563
|
ctx.pop();
|
|
6702
6564
|
}
|
|
6703
6565
|
*children(partials) {
|
|
6704
6566
|
const templates = this.templates.slice();
|
|
6705
6567
|
if (partials && isString(this.file)) {
|
|
6706
|
-
templates.push(...yield this.liquid._parsePartialFile(this.file, true, this
|
|
6568
|
+
templates.push(...yield this.liquid._parsePartialFile(this.file, true, this.currentFile));
|
|
6707
6569
|
}
|
|
6708
6570
|
return templates;
|
|
6709
6571
|
}
|
|
@@ -6744,18 +6606,24 @@ var BlockTag = class extends Tag {
|
|
|
6744
6606
|
*render(ctx, emitter) {
|
|
6745
6607
|
const blockRender = this.getBlockRender(ctx);
|
|
6746
6608
|
if (ctx.getRegister("blockMode") === BlockMode.STORE) {
|
|
6747
|
-
ctx.getRegister("blocks")[this.block] = blockRender;
|
|
6609
|
+
ctx.getRegister("blocks", {})[this.block] = blockRender;
|
|
6748
6610
|
} else {
|
|
6749
6611
|
yield blockRender(new BlockDrop(), emitter);
|
|
6750
6612
|
}
|
|
6751
6613
|
}
|
|
6752
6614
|
getBlockRender(ctx) {
|
|
6615
|
+
const self = this;
|
|
6753
6616
|
const { liquid, templates } = this;
|
|
6754
|
-
const renderChild = ctx.getRegister("blocks")[this.block];
|
|
6617
|
+
const renderChild = ctx.getRegister("blocks", {})[this.block];
|
|
6755
6618
|
const renderCurrent = /* @__PURE__ */ __name(function* (superBlock, emitter) {
|
|
6756
|
-
ctx.
|
|
6619
|
+
const stack = ctx.getRegister("blockStack", []);
|
|
6620
|
+
if (stack.includes(self))
|
|
6621
|
+
throw new Error("block tag cannot be nested");
|
|
6622
|
+
stack.push(self);
|
|
6623
|
+
ctx.push(createScope({ block: superBlock }));
|
|
6757
6624
|
yield liquid.renderer.renderTemplates(templates, ctx, emitter);
|
|
6758
6625
|
ctx.pop();
|
|
6626
|
+
stack.pop();
|
|
6759
6627
|
}, "renderCurrent");
|
|
6760
6628
|
return renderChild ? (superBlock, emitter) => renderChild(new BlockDrop((emitter2) => renderCurrent(superBlock, emitter2)), emitter) : renderCurrent;
|
|
6761
6629
|
}
|
|
@@ -6842,7 +6710,7 @@ var TablerowTag = class extends Tag {
|
|
|
6842
6710
|
const cols = args.cols || collection.length;
|
|
6843
6711
|
const r = this.liquid.renderer;
|
|
6844
6712
|
const tablerowloop = new TablerowloopDrop(collection.length, cols, this.collection.getText(), this.variable);
|
|
6845
|
-
const scope = { tablerowloop };
|
|
6713
|
+
const scope = createScope({ tablerowloop });
|
|
6846
6714
|
ctx.push(scope);
|
|
6847
6715
|
for (let idx = 0; idx < collection.length; idx++, tablerowloop.next()) {
|
|
6848
6716
|
scope[this.variable] = collection[idx];
|
|
@@ -6914,7 +6782,7 @@ var UnlessTag = class extends Tag {
|
|
|
6914
6782
|
*render(ctx, emitter) {
|
|
6915
6783
|
const r = this.liquid.renderer;
|
|
6916
6784
|
for (const { value, test, templates } of this.branches) {
|
|
6917
|
-
const v = yield value.value(ctx, ctx.opts.lenientIf);
|
|
6785
|
+
const v = yield toValue(yield value.value(ctx, ctx.opts.lenientIf));
|
|
6918
6786
|
if (test(v, ctx)) {
|
|
6919
6787
|
yield r.renderTemplates(templates, ctx, emitter);
|
|
6920
6788
|
return;
|
|
@@ -6961,9 +6829,14 @@ var EchoTag = class extends Tag {
|
|
|
6961
6829
|
}
|
|
6962
6830
|
}
|
|
6963
6831
|
*render(ctx, emitter) {
|
|
6832
|
+
var _a;
|
|
6964
6833
|
if (!this.value)
|
|
6965
6834
|
return;
|
|
6966
|
-
|
|
6835
|
+
let val = yield toValue(yield this.value.value(ctx, false));
|
|
6836
|
+
const outputEscape = this.liquid.options.outputEscape;
|
|
6837
|
+
if (outputEscape && !((_a = this.value.filters[this.value.filters.length - 1]) === null || _a === void 0 ? void 0 : _a.raw)) {
|
|
6838
|
+
val = yield outputEscape.call({ context: ctx, token: this.token, liquid: this.liquid }, val);
|
|
6839
|
+
}
|
|
6967
6840
|
emitter.write(val);
|
|
6968
6841
|
}
|
|
6969
6842
|
*arguments() {
|
|
@@ -7030,8 +6903,8 @@ var Liquid = class _Liquid {
|
|
|
7030
6903
|
}
|
|
7031
6904
|
constructor(opts = {}) {
|
|
7032
6905
|
this.renderer = new Render();
|
|
7033
|
-
this.filters =
|
|
7034
|
-
this.tags =
|
|
6906
|
+
this.filters = /* @__PURE__ */ Object.create(null);
|
|
6907
|
+
this.tags = /* @__PURE__ */ Object.create(null);
|
|
7035
6908
|
this.options = normalize(opts);
|
|
7036
6909
|
this.parser = new Parser(this);
|
|
7037
6910
|
forOwn(tags, (conf, name) => this.registerTag(name, conf));
|
|
@@ -7042,7 +6915,7 @@ var Liquid = class _Liquid {
|
|
|
7042
6915
|
return parser.parse(html, filepath);
|
|
7043
6916
|
}
|
|
7044
6917
|
_render(tpl, scope, renderOptions) {
|
|
7045
|
-
const ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions);
|
|
6918
|
+
const ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions, { liquid: this });
|
|
7046
6919
|
return this.renderer.renderTemplates(tpl, ctx);
|
|
7047
6920
|
}
|
|
7048
6921
|
render(tpl, scope, renderOptions) {
|
|
@@ -7054,7 +6927,7 @@ var Liquid = class _Liquid {
|
|
|
7054
6927
|
return toValueSync(this._render(tpl, scope, Object.assign(Object.assign({}, renderOptions), { sync: true })));
|
|
7055
6928
|
}
|
|
7056
6929
|
renderToNodeStream(tpl, scope, renderOptions = {}) {
|
|
7057
|
-
const ctx = new Context(scope, this.options, renderOptions);
|
|
6930
|
+
const ctx = new Context(scope, this.options, renderOptions, { liquid: this });
|
|
7058
6931
|
return this.renderer.renderTemplatesToNodeStream(tpl, ctx);
|
|
7059
6932
|
}
|
|
7060
6933
|
_parseAndRender(html, scope, renderOptions) {
|
|
@@ -7106,7 +6979,7 @@ var Liquid = class _Liquid {
|
|
|
7106
6979
|
}
|
|
7107
6980
|
_evalValue(str, scope) {
|
|
7108
6981
|
const value = new Value(str, this);
|
|
7109
|
-
const ctx = scope instanceof Context ? scope : new Context(scope, this.options);
|
|
6982
|
+
const ctx = scope instanceof Context ? scope : new Context(scope, this.options, {}, { liquid: this });
|
|
7110
6983
|
return value.value(ctx);
|
|
7111
6984
|
}
|
|
7112
6985
|
evalValue(str, scope) {
|
|
@@ -7120,6 +6993,9 @@ var Liquid = class _Liquid {
|
|
|
7120
6993
|
registerFilter(name, filter2) {
|
|
7121
6994
|
this.filters[name] = filter2;
|
|
7122
6995
|
}
|
|
6996
|
+
unregisterFilter(name) {
|
|
6997
|
+
delete this.filters[name];
|
|
6998
|
+
}
|
|
7123
6999
|
registerTag(name, tag) {
|
|
7124
7000
|
this.tags[name] = isFunction(tag) ? tag : createTagClass(tag);
|
|
7125
7001
|
}
|
|
@@ -7233,21 +7109,296 @@ var Liquid = class _Liquid {
|
|
|
7233
7109
|
// ../../src/Engines/Liquid.js
|
|
7234
7110
|
var import_eleventy_utils = __toESM(require_eleventy_utils(), 1);
|
|
7235
7111
|
|
|
7236
|
-
// ../../node_modules
|
|
7237
|
-
function
|
|
7238
|
-
|
|
7112
|
+
// ../../node_modules/obug/dist/core.js
|
|
7113
|
+
function coerce(value) {
|
|
7114
|
+
if (value instanceof Error) return value.stack || value.message;
|
|
7115
|
+
return value;
|
|
7116
|
+
}
|
|
7117
|
+
__name(coerce, "coerce");
|
|
7118
|
+
function selectColor(colors2, namespace) {
|
|
7119
|
+
let hash = 0;
|
|
7120
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
7121
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
7122
|
+
hash |= 0;
|
|
7123
|
+
}
|
|
7124
|
+
return colors2[Math.abs(hash) % colors2.length];
|
|
7125
|
+
}
|
|
7126
|
+
__name(selectColor, "selectColor");
|
|
7127
|
+
function matchesTemplate(search2, template) {
|
|
7128
|
+
let searchIndex = 0;
|
|
7129
|
+
let templateIndex = 0;
|
|
7130
|
+
let starIndex = -1;
|
|
7131
|
+
let matchIndex = 0;
|
|
7132
|
+
while (searchIndex < search2.length) if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) {
|
|
7133
|
+
if (template[templateIndex] === "*") {
|
|
7134
|
+
starIndex = templateIndex;
|
|
7135
|
+
matchIndex = searchIndex;
|
|
7136
|
+
templateIndex++;
|
|
7137
|
+
} else {
|
|
7138
|
+
searchIndex++;
|
|
7139
|
+
templateIndex++;
|
|
7140
|
+
}
|
|
7141
|
+
} else if (starIndex !== -1) {
|
|
7142
|
+
templateIndex = starIndex + 1;
|
|
7143
|
+
matchIndex++;
|
|
7144
|
+
searchIndex = matchIndex;
|
|
7145
|
+
} else return false;
|
|
7146
|
+
while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
|
|
7147
|
+
return templateIndex === template.length;
|
|
7148
|
+
}
|
|
7149
|
+
__name(matchesTemplate, "matchesTemplate");
|
|
7150
|
+
function humanize(value) {
|
|
7151
|
+
if (value >= 1e3) return `${(value / 1e3).toFixed(1)}s`;
|
|
7152
|
+
return `${value}ms`;
|
|
7153
|
+
}
|
|
7154
|
+
__name(humanize, "humanize");
|
|
7155
|
+
var globalNamespaces = "";
|
|
7156
|
+
function createDebug(namespace, options) {
|
|
7157
|
+
let prevTime;
|
|
7158
|
+
let enableOverride;
|
|
7159
|
+
let namespacesCache;
|
|
7160
|
+
let enabledCache;
|
|
7161
|
+
const debug2 = /* @__PURE__ */ __name(((...args) => {
|
|
7162
|
+
if (!debug2.enabled) return;
|
|
7163
|
+
const curr = Date.now();
|
|
7164
|
+
const diff = curr - (prevTime || curr);
|
|
7165
|
+
prevTime = curr;
|
|
7166
|
+
args[0] = coerce(args[0]);
|
|
7167
|
+
if (typeof args[0] !== "string") args.unshift("%O");
|
|
7168
|
+
let index = 0;
|
|
7169
|
+
args[0] = args[0].replace(/%([a-z%])/gi, (match, format2) => {
|
|
7170
|
+
if (match === "%%") return "%";
|
|
7171
|
+
index++;
|
|
7172
|
+
const formatter = options.formatters[format2];
|
|
7173
|
+
if (typeof formatter === "function") {
|
|
7174
|
+
const value = args[index];
|
|
7175
|
+
match = formatter.call(debug2, value);
|
|
7176
|
+
args.splice(index, 1);
|
|
7177
|
+
index--;
|
|
7178
|
+
}
|
|
7179
|
+
return match;
|
|
7180
|
+
});
|
|
7181
|
+
options.formatArgs.call(debug2, diff, args);
|
|
7182
|
+
debug2.log(...args);
|
|
7183
|
+
}), "debug");
|
|
7184
|
+
debug2.extend = function(namespace2, delimiter = ":") {
|
|
7185
|
+
return createDebug(this.namespace + delimiter + namespace2, {
|
|
7186
|
+
useColors: this.useColors,
|
|
7187
|
+
color: this.color,
|
|
7188
|
+
formatArgs: this.formatArgs,
|
|
7189
|
+
formatters: this.formatters,
|
|
7190
|
+
inspectOpts: this.inspectOpts,
|
|
7191
|
+
log: this.log,
|
|
7192
|
+
humanize: this.humanize
|
|
7193
|
+
});
|
|
7239
7194
|
};
|
|
7195
|
+
Object.assign(debug2, options);
|
|
7196
|
+
debug2.namespace = namespace;
|
|
7197
|
+
Object.defineProperty(debug2, "enabled", {
|
|
7198
|
+
enumerable: true,
|
|
7199
|
+
configurable: false,
|
|
7200
|
+
get: /* @__PURE__ */ __name(() => {
|
|
7201
|
+
if (enableOverride != null) return enableOverride;
|
|
7202
|
+
if (namespacesCache !== globalNamespaces) {
|
|
7203
|
+
namespacesCache = globalNamespaces;
|
|
7204
|
+
enabledCache = enabled(namespace);
|
|
7205
|
+
}
|
|
7206
|
+
return enabledCache;
|
|
7207
|
+
}, "get"),
|
|
7208
|
+
set: /* @__PURE__ */ __name((v) => {
|
|
7209
|
+
enableOverride = v;
|
|
7210
|
+
}, "set")
|
|
7211
|
+
});
|
|
7212
|
+
return debug2;
|
|
7213
|
+
}
|
|
7214
|
+
__name(createDebug, "createDebug");
|
|
7215
|
+
var names = [];
|
|
7216
|
+
var skips = [];
|
|
7217
|
+
function enable(namespaces2) {
|
|
7218
|
+
globalNamespaces = namespaces2;
|
|
7219
|
+
names = [];
|
|
7220
|
+
skips = [];
|
|
7221
|
+
const split2 = globalNamespaces.trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
7222
|
+
for (const ns of split2) if (ns[0] === "-") skips.push(ns.slice(1));
|
|
7223
|
+
else names.push(ns);
|
|
7224
|
+
}
|
|
7225
|
+
__name(enable, "enable");
|
|
7226
|
+
function enabled(name) {
|
|
7227
|
+
for (const skip of skips) if (matchesTemplate(name, skip)) return false;
|
|
7228
|
+
for (const ns of names) if (matchesTemplate(name, ns)) return true;
|
|
7229
|
+
return false;
|
|
7230
|
+
}
|
|
7231
|
+
__name(enabled, "enabled");
|
|
7232
|
+
|
|
7233
|
+
// ../../node_modules/obug/dist/plain.js
|
|
7234
|
+
function formatArgs(diff, args) {
|
|
7235
|
+
args[0] = `${this.namespace} ${args[0]} +${this.humanize(diff)}`;
|
|
7236
|
+
}
|
|
7237
|
+
__name(formatArgs, "formatArgs");
|
|
7238
|
+
var defaultOptions2 = {
|
|
7239
|
+
useColors: false,
|
|
7240
|
+
color: "",
|
|
7241
|
+
formatArgs,
|
|
7242
|
+
formatters: {
|
|
7243
|
+
/**
|
|
7244
|
+
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
7245
|
+
*/
|
|
7246
|
+
j(v) {
|
|
7247
|
+
try {
|
|
7248
|
+
return JSON.stringify(v);
|
|
7249
|
+
} catch (error) {
|
|
7250
|
+
return `[UnexpectedJSONParseError]: ${error.message}`;
|
|
7251
|
+
}
|
|
7252
|
+
}
|
|
7253
|
+
},
|
|
7254
|
+
inspectOpts: {},
|
|
7255
|
+
humanize,
|
|
7256
|
+
log: console.debug || console.log || (() => {
|
|
7257
|
+
})
|
|
7258
|
+
};
|
|
7259
|
+
function createDebug2(namespace, options) {
|
|
7260
|
+
return createDebug(namespace, Object.assign({}, defaultOptions2, options));
|
|
7261
|
+
}
|
|
7262
|
+
__name(createDebug2, "createDebug");
|
|
7263
|
+
function load() {
|
|
7264
|
+
let r;
|
|
7265
|
+
try {
|
|
7266
|
+
r = localStorage.getItem("debug") || localStorage.getItem("DEBUG");
|
|
7267
|
+
} catch (_unused) {
|
|
7268
|
+
}
|
|
7269
|
+
if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
|
|
7270
|
+
return r || "";
|
|
7240
7271
|
}
|
|
7241
|
-
__name(
|
|
7272
|
+
__name(load, "load");
|
|
7273
|
+
enable(load());
|
|
7274
|
+
|
|
7275
|
+
// ../../node_modules/obug/dist/browser.js
|
|
7276
|
+
var colors = [
|
|
7277
|
+
"#0000CC",
|
|
7278
|
+
"#0000FF",
|
|
7279
|
+
"#0033CC",
|
|
7280
|
+
"#0033FF",
|
|
7281
|
+
"#0066CC",
|
|
7282
|
+
"#0066FF",
|
|
7283
|
+
"#0099CC",
|
|
7284
|
+
"#0099FF",
|
|
7285
|
+
"#00CC00",
|
|
7286
|
+
"#00CC33",
|
|
7287
|
+
"#00CC66",
|
|
7288
|
+
"#00CC99",
|
|
7289
|
+
"#00CCCC",
|
|
7290
|
+
"#00CCFF",
|
|
7291
|
+
"#3300CC",
|
|
7292
|
+
"#3300FF",
|
|
7293
|
+
"#3333CC",
|
|
7294
|
+
"#3333FF",
|
|
7295
|
+
"#3366CC",
|
|
7296
|
+
"#3366FF",
|
|
7297
|
+
"#3399CC",
|
|
7298
|
+
"#3399FF",
|
|
7299
|
+
"#33CC00",
|
|
7300
|
+
"#33CC33",
|
|
7301
|
+
"#33CC66",
|
|
7302
|
+
"#33CC99",
|
|
7303
|
+
"#33CCCC",
|
|
7304
|
+
"#33CCFF",
|
|
7305
|
+
"#6600CC",
|
|
7306
|
+
"#6600FF",
|
|
7307
|
+
"#6633CC",
|
|
7308
|
+
"#6633FF",
|
|
7309
|
+
"#66CC00",
|
|
7310
|
+
"#66CC33",
|
|
7311
|
+
"#9900CC",
|
|
7312
|
+
"#9900FF",
|
|
7313
|
+
"#9933CC",
|
|
7314
|
+
"#9933FF",
|
|
7315
|
+
"#99CC00",
|
|
7316
|
+
"#99CC33",
|
|
7317
|
+
"#CC0000",
|
|
7318
|
+
"#CC0033",
|
|
7319
|
+
"#CC0066",
|
|
7320
|
+
"#CC0099",
|
|
7321
|
+
"#CC00CC",
|
|
7322
|
+
"#CC00FF",
|
|
7323
|
+
"#CC3300",
|
|
7324
|
+
"#CC3333",
|
|
7325
|
+
"#CC3366",
|
|
7326
|
+
"#CC3399",
|
|
7327
|
+
"#CC33CC",
|
|
7328
|
+
"#CC33FF",
|
|
7329
|
+
"#CC6600",
|
|
7330
|
+
"#CC6633",
|
|
7331
|
+
"#CC9900",
|
|
7332
|
+
"#CC9933",
|
|
7333
|
+
"#CCCC00",
|
|
7334
|
+
"#CCCC33",
|
|
7335
|
+
"#FF0000",
|
|
7336
|
+
"#FF0033",
|
|
7337
|
+
"#FF0066",
|
|
7338
|
+
"#FF0099",
|
|
7339
|
+
"#FF00CC",
|
|
7340
|
+
"#FF00FF",
|
|
7341
|
+
"#FF3300",
|
|
7342
|
+
"#FF3333",
|
|
7343
|
+
"#FF3366",
|
|
7344
|
+
"#FF3399",
|
|
7345
|
+
"#FF33CC",
|
|
7346
|
+
"#FF33FF",
|
|
7347
|
+
"#FF6600",
|
|
7348
|
+
"#FF6633",
|
|
7349
|
+
"#FF9900",
|
|
7350
|
+
"#FF9933",
|
|
7351
|
+
"#FFCC00",
|
|
7352
|
+
"#FFCC33"
|
|
7353
|
+
];
|
|
7354
|
+
function formatArgs2(diff, args) {
|
|
7355
|
+
const { useColors } = this;
|
|
7356
|
+
args[0] = `${(useColors ? "%c" : "") + this.namespace + (useColors ? " %c" : " ") + args[0] + (useColors ? "%c " : " ")}+${this.humanize(diff)}`;
|
|
7357
|
+
if (!useColors) return;
|
|
7358
|
+
const c = `color: ${this.color}`;
|
|
7359
|
+
args.splice(1, 0, c, "color: inherit");
|
|
7360
|
+
let index = 0;
|
|
7361
|
+
let lastC = 0;
|
|
7362
|
+
args[0].replace(/%[a-z%]/gi, (match) => {
|
|
7363
|
+
if (match === "%%") return;
|
|
7364
|
+
index++;
|
|
7365
|
+
if (match === "%c") lastC = index;
|
|
7366
|
+
});
|
|
7367
|
+
args.splice(lastC, 0, c);
|
|
7368
|
+
}
|
|
7369
|
+
__name(formatArgs2, "formatArgs");
|
|
7370
|
+
function createDebug3(namespace, options) {
|
|
7371
|
+
var _ref;
|
|
7372
|
+
const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace);
|
|
7373
|
+
return createDebug2(namespace, Object.assign({
|
|
7374
|
+
useColors: true,
|
|
7375
|
+
color,
|
|
7376
|
+
formatArgs: formatArgs2
|
|
7377
|
+
}, options));
|
|
7378
|
+
}
|
|
7379
|
+
__name(createDebug3, "createDebug");
|
|
7242
7380
|
|
|
7243
|
-
// ../../src/
|
|
7244
|
-
|
|
7381
|
+
// ../../src/Util/IsBuildAwesome.js
|
|
7382
|
+
function isUsingBuildAwesome() {
|
|
7383
|
+
return process?.env?.BUILDAWESOME_PACKAGE === "@awesome.me/buildawesome";
|
|
7384
|
+
}
|
|
7385
|
+
__name(isUsingBuildAwesome, "isUsingBuildAwesome");
|
|
7386
|
+
|
|
7387
|
+
// ../../src/Util/DebugLogUtil.js
|
|
7388
|
+
var PREFIX = isUsingBuildAwesome() ? "BuildAwesome:" : "Eleventy:";
|
|
7389
|
+
function createDebug4(name) {
|
|
7390
|
+
return createDebug3(`${PREFIX}${name}`);
|
|
7391
|
+
}
|
|
7392
|
+
__name(createDebug4, "createDebug");
|
|
7393
|
+
|
|
7394
|
+
// ../../src/Errors/BaseError.js
|
|
7395
|
+
var BaseError = class extends Error {
|
|
7245
7396
|
static {
|
|
7246
|
-
__name(this, "
|
|
7397
|
+
__name(this, "BaseError");
|
|
7247
7398
|
}
|
|
7248
7399
|
/**
|
|
7249
7400
|
* @param {string} message - The error message to display.
|
|
7250
|
-
* @param {
|
|
7401
|
+
* @param {Error} [originalError] - The original error caught.
|
|
7251
7402
|
*/
|
|
7252
7403
|
constructor(message, originalError) {
|
|
7253
7404
|
if (originalError) {
|
|
@@ -7263,16 +7414,23 @@ var EleventyBaseError = class extends Error {
|
|
|
7263
7414
|
this.originalError = originalError;
|
|
7264
7415
|
}
|
|
7265
7416
|
}
|
|
7417
|
+
/**
|
|
7418
|
+
* @param {string} filePath - The file that caused the error.
|
|
7419
|
+
* @returns {this}
|
|
7420
|
+
*/
|
|
7421
|
+
setFilePath(filePath) {
|
|
7422
|
+
this.filePath = filePath;
|
|
7423
|
+
return this;
|
|
7424
|
+
}
|
|
7266
7425
|
};
|
|
7267
|
-
var EleventyBaseError_default = EleventyBaseError;
|
|
7268
7426
|
|
|
7269
7427
|
// ../../src/Engines/TemplateEngine.js
|
|
7270
|
-
var TemplateEngineConfigError = class extends
|
|
7428
|
+
var TemplateEngineConfigError = class extends BaseError {
|
|
7271
7429
|
static {
|
|
7272
7430
|
__name(this, "TemplateEngineConfigError");
|
|
7273
7431
|
}
|
|
7274
7432
|
};
|
|
7275
|
-
var debug =
|
|
7433
|
+
var debug = createDebug4("TemplateEngine");
|
|
7276
7434
|
var AMENDED_INSTANCES = /* @__PURE__ */ new Set();
|
|
7277
7435
|
var TemplateEngine = class {
|
|
7278
7436
|
static {
|
|
@@ -7281,6 +7439,7 @@ var TemplateEngine = class {
|
|
|
7281
7439
|
#extensionMap;
|
|
7282
7440
|
#engineManager;
|
|
7283
7441
|
#benchmarks;
|
|
7442
|
+
#configEventListeners = [];
|
|
7284
7443
|
constructor(name, eleventyConfig) {
|
|
7285
7444
|
this.name = name;
|
|
7286
7445
|
this.engineLib = null;
|
|
@@ -7292,6 +7451,18 @@ var TemplateEngine = class {
|
|
|
7292
7451
|
get cacheable() {
|
|
7293
7452
|
return false;
|
|
7294
7453
|
}
|
|
7454
|
+
// Engine instances are replaced on each build, so their listeners must not outlive them
|
|
7455
|
+
addConfigEventListener(eventName, fn) {
|
|
7456
|
+
let events = this.config.events;
|
|
7457
|
+
this.#configEventListeners.push([events, eventName, fn]);
|
|
7458
|
+
events.on(eventName, fn);
|
|
7459
|
+
}
|
|
7460
|
+
removeConfigEventListeners() {
|
|
7461
|
+
for (let [events, eventName, fn] of this.#configEventListeners) {
|
|
7462
|
+
events.off(eventName, fn);
|
|
7463
|
+
}
|
|
7464
|
+
this.#configEventListeners = [];
|
|
7465
|
+
}
|
|
7295
7466
|
get dirs() {
|
|
7296
7467
|
return this.eleventyConfig.directories;
|
|
7297
7468
|
}
|
|
@@ -7407,6 +7578,9 @@ var TemplateEngine = class {
|
|
|
7407
7578
|
needsCompilation(str) {
|
|
7408
7579
|
return true;
|
|
7409
7580
|
}
|
|
7581
|
+
// Runs at compile time for pipeline steps that compile later, during render
|
|
7582
|
+
async ready() {
|
|
7583
|
+
}
|
|
7410
7584
|
/**
|
|
7411
7585
|
* Make sure compile is implemented downstream.
|
|
7412
7586
|
* @abstract
|
|
@@ -7425,13 +7599,21 @@ var TemplateEngine = class {
|
|
|
7425
7599
|
}
|
|
7426
7600
|
return true;
|
|
7427
7601
|
}
|
|
7602
|
+
// e.g. a template’s include, import, extends, or layout file, recorded when it is used
|
|
7603
|
+
// `from` is the engine name for string templates (e.g. the Render plugin’s `renderTemplate`)
|
|
7604
|
+
addDependency(from, to) {
|
|
7605
|
+
if (!from || !to) {
|
|
7606
|
+
return;
|
|
7607
|
+
}
|
|
7608
|
+
this.config.uses.addDependency(from, [to]);
|
|
7609
|
+
}
|
|
7428
7610
|
isFileRelevantTo(inputPath, comparisonFile) {
|
|
7429
7611
|
return this.config.uses.isFileRelevantTo(inputPath, comparisonFile);
|
|
7430
7612
|
}
|
|
7431
7613
|
};
|
|
7432
7614
|
|
|
7433
7615
|
// ../../src/Engines/Util/ContextAugmenter.js
|
|
7434
|
-
var DATA_KEYS = ["page", "eleventy"];
|
|
7616
|
+
var DATA_KEYS = ["page", "eleventy", "buildawesome", "collections"];
|
|
7435
7617
|
function augmentObject(targetObject, options = {}) {
|
|
7436
7618
|
options = Object.assign(
|
|
7437
7619
|
{
|
|
@@ -7482,19 +7664,12 @@ var Liquid2 = class _Liquid extends TemplateEngine {
|
|
|
7482
7664
|
static {
|
|
7483
7665
|
__name(this, "Liquid");
|
|
7484
7666
|
}
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
doubleQuoteString: /"(?:\\["\\]|[^\n"\\])*"/,
|
|
7488
|
-
singleQuoteString: /'(?:\\['\\]|[^\n'\\])*'/,
|
|
7489
|
-
keyword: /[a-zA-Z0-9.\-_]+/,
|
|
7490
|
-
"ignore:whitespace": /[, \t]+/
|
|
7491
|
-
// includes comma separator
|
|
7492
|
-
};
|
|
7667
|
+
// Legacy argument tokens (number, double/single quoted string, keyword), separated by commas or whitespace.
|
|
7668
|
+
static argumentLexer = /([0-9]+\.*[0-9]*|"(?:\\["\\]|[^\n"\\])*"|'(?:\\['\\]|[^\n'\\])*'|[a-zA-Z0-9.\-_]+)|[, \t]+/y;
|
|
7493
7669
|
constructor(name, eleventyConfig) {
|
|
7494
7670
|
super(name, eleventyConfig);
|
|
7495
7671
|
this.liquidOptions = this.config.liquidOptions || {};
|
|
7496
7672
|
this.setLibrary(this.config.libraryOverrides.liquid);
|
|
7497
|
-
this.argLexer = import_moo.default.compile(_Liquid.argumentLexerOptions);
|
|
7498
7673
|
}
|
|
7499
7674
|
get cacheable() {
|
|
7500
7675
|
return true;
|
|
@@ -7502,6 +7677,7 @@ var Liquid2 = class _Liquid extends TemplateEngine {
|
|
|
7502
7677
|
setLibrary(override) {
|
|
7503
7678
|
this.liquidLib = override || new Liquid(this.getLiquidOptions());
|
|
7504
7679
|
this.setEngineLib(this.liquidLib, Boolean(this.config.libraryOverrides.liquid));
|
|
7680
|
+
this.#trackPartialFiles();
|
|
7505
7681
|
this.addFilters(this.config.liquidFilters);
|
|
7506
7682
|
this.addCustomTags(this.config.liquidTags);
|
|
7507
7683
|
this.addAllShortcodes(this.config.liquidShortcodes);
|
|
@@ -7510,15 +7686,46 @@ var Liquid2 = class _Liquid extends TemplateEngine {
|
|
|
7510
7686
|
getLiquidOptions() {
|
|
7511
7687
|
let defaults = {
|
|
7512
7688
|
root: [this.dirs.includes, this.dirs.input],
|
|
7513
|
-
// supplemented in compile with inputPath below
|
|
7514
7689
|
extname: ".liquid",
|
|
7515
|
-
strictFilters: true
|
|
7516
|
-
// TODO?
|
|
7690
|
+
strictFilters: true,
|
|
7517
7691
|
// cache: true,
|
|
7692
|
+
jsTruthy: true,
|
|
7693
|
+
// Breaking in v4 #3507
|
|
7694
|
+
timezoneOffset: this.config.dateTimeZone?.zone ?? 0
|
|
7695
|
+
// Match `setDateTimeZone` (or UTC) when parsing dates, breaking in v4 #1905
|
|
7518
7696
|
};
|
|
7697
|
+
if (this.dirs.layouts) {
|
|
7698
|
+
defaults.layouts = [this.dirs.layouts, ...defaults.root];
|
|
7699
|
+
}
|
|
7519
7700
|
let options = Object.assign(defaults, this.liquidOptions || {});
|
|
7520
7701
|
return options;
|
|
7521
7702
|
}
|
|
7703
|
+
// Records `include`, `render`, and `layout` files in the dependency graph for incremental builds
|
|
7704
|
+
#trackPartialFiles() {
|
|
7705
|
+
let lib = this.liquidLib;
|
|
7706
|
+
if (typeof lib._parsePartialFile !== "function" || typeof lib._parseLayoutFile !== "function") {
|
|
7707
|
+
return;
|
|
7708
|
+
}
|
|
7709
|
+
let engine = this;
|
|
7710
|
+
let track = /* @__PURE__ */ __name((lookupType) => function(file, sync, currentFile) {
|
|
7711
|
+
let parser = new Parser(this);
|
|
7712
|
+
let lookup = parser.loader.lookup;
|
|
7713
|
+
parser.loader.lookup = function* (...args) {
|
|
7714
|
+
let filepath = yield* lookup.apply(this, args);
|
|
7715
|
+
engine.addDependency(currentFile || engine.name, filepath);
|
|
7716
|
+
return filepath;
|
|
7717
|
+
};
|
|
7718
|
+
if (parser.cache) {
|
|
7719
|
+
return (function* () {
|
|
7720
|
+
yield parser.loader.lookup(file, lookupType, sync, currentFile);
|
|
7721
|
+
return yield parser.parseFile(file, sync, lookupType, currentFile);
|
|
7722
|
+
})();
|
|
7723
|
+
}
|
|
7724
|
+
return parser.parseFile(file, sync, lookupType, currentFile);
|
|
7725
|
+
}, "track");
|
|
7726
|
+
lib._parsePartialFile = track(LookupType.Partials);
|
|
7727
|
+
lib._parseLayoutFile = track(LookupType.Layouts);
|
|
7728
|
+
}
|
|
7522
7729
|
static wrapFilter(name, fn) {
|
|
7523
7730
|
return function(...args) {
|
|
7524
7731
|
if (typeof this.context?.get === "function") {
|
|
@@ -7578,38 +7785,66 @@ var Liquid2 = class _Liquid extends TemplateEngine {
|
|
|
7578
7785
|
this.addPairedShortcode(name, shortcodes[name]);
|
|
7579
7786
|
}
|
|
7580
7787
|
}
|
|
7581
|
-
static parseArguments(
|
|
7788
|
+
static parseArguments(str) {
|
|
7582
7789
|
let argArray = [];
|
|
7583
|
-
if (
|
|
7584
|
-
|
|
7790
|
+
if (typeof str !== "string") {
|
|
7791
|
+
return argArray;
|
|
7585
7792
|
}
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
let
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7793
|
+
let lexer = new RegExp(_Liquid.argumentLexer);
|
|
7794
|
+
while (lexer.lastIndex < str.length) {
|
|
7795
|
+
let index = lexer.lastIndex;
|
|
7796
|
+
let match = lexer.exec(str);
|
|
7797
|
+
if (!match) {
|
|
7798
|
+
throw new Error(`Invalid Liquid shortcode argument syntax at col ${index + 1}: ${str}`);
|
|
7799
|
+
}
|
|
7800
|
+
if (match[1] !== void 0) {
|
|
7801
|
+
argArray.push(match[1]);
|
|
7594
7802
|
}
|
|
7595
7803
|
}
|
|
7596
7804
|
return argArray;
|
|
7597
7805
|
}
|
|
7806
|
+
// Reads a `key: value` keyword argument, falling back to a positional value
|
|
7807
|
+
static readArgumentBuiltin(tokenizer) {
|
|
7808
|
+
let begin = tokenizer.p;
|
|
7809
|
+
let hash = tokenizer.readHash();
|
|
7810
|
+
if (hash?.value) {
|
|
7811
|
+
return hash;
|
|
7812
|
+
}
|
|
7813
|
+
tokenizer.p = begin;
|
|
7814
|
+
return tokenizer.readValue();
|
|
7815
|
+
}
|
|
7598
7816
|
static parseArgumentsBuiltin(args) {
|
|
7599
7817
|
let tokenizer = new Tokenizer(args);
|
|
7600
7818
|
let parsedArgs = [];
|
|
7601
|
-
let value =
|
|
7819
|
+
let value = _Liquid.readArgumentBuiltin(tokenizer);
|
|
7602
7820
|
while (value) {
|
|
7603
7821
|
parsedArgs.push(value);
|
|
7604
7822
|
tokenizer.skipBlank();
|
|
7605
7823
|
if (tokenizer.peek() === ",") {
|
|
7606
7824
|
tokenizer.advance();
|
|
7607
7825
|
}
|
|
7608
|
-
value =
|
|
7826
|
+
value = _Liquid.readArgumentBuiltin(tokenizer);
|
|
7609
7827
|
}
|
|
7610
7828
|
tokenizer.end();
|
|
7611
7829
|
return parsedArgs;
|
|
7612
7830
|
}
|
|
7831
|
+
// Keyword arguments are passed as a trailing object marked with a non-enumerable `__keywords` (Nunjucks-compatible)
|
|
7832
|
+
static *evalArgumentsBuiltin(tokens, ctx) {
|
|
7833
|
+
let args = [];
|
|
7834
|
+
let kwargs;
|
|
7835
|
+
for (let token of tokens) {
|
|
7836
|
+
if (token.kind === TokenKind.Hash) {
|
|
7837
|
+
kwargs ??= Object.defineProperty({}, "__keywords", { value: true });
|
|
7838
|
+
kwargs[token.name.content] = yield evalToken(token.value, ctx);
|
|
7839
|
+
} else {
|
|
7840
|
+
args.push(yield evalToken(token, ctx));
|
|
7841
|
+
}
|
|
7842
|
+
}
|
|
7843
|
+
if (kwargs) {
|
|
7844
|
+
args.push(kwargs);
|
|
7845
|
+
}
|
|
7846
|
+
return args;
|
|
7847
|
+
}
|
|
7613
7848
|
addShortcode(shortcodeName, shortcodeFn) {
|
|
7614
7849
|
let _t = this;
|
|
7615
7850
|
this.addTag(shortcodeName, function(liquidEngine) {
|
|
@@ -7625,16 +7860,13 @@ var Liquid2 = class _Liquid extends TemplateEngine {
|
|
|
7625
7860
|
render: /* @__PURE__ */ __name(function* (ctx) {
|
|
7626
7861
|
let argArray = [];
|
|
7627
7862
|
if (this.legacyArgs) {
|
|
7628
|
-
let rawArgs = _Liquid.parseArguments(
|
|
7863
|
+
let rawArgs = _Liquid.parseArguments(this.legacyArgs);
|
|
7629
7864
|
for (let arg of rawArgs) {
|
|
7630
7865
|
let b = yield liquidEngine.evalValue(arg, ctx);
|
|
7631
7866
|
argArray.push(b);
|
|
7632
7867
|
}
|
|
7633
7868
|
} else if (this.orderedArgs) {
|
|
7634
|
-
|
|
7635
|
-
let b = yield evalToken(arg, ctx);
|
|
7636
|
-
argArray.push(b);
|
|
7637
|
-
}
|
|
7869
|
+
argArray = yield* _Liquid.evalArgumentsBuiltin(this.orderedArgs, ctx);
|
|
7638
7870
|
}
|
|
7639
7871
|
let ret = yield shortcodeFn.call(_Liquid.normalizeScope(ctx), ...argArray);
|
|
7640
7872
|
return ret;
|
|
@@ -7662,16 +7894,13 @@ var Liquid2 = class _Liquid extends TemplateEngine {
|
|
|
7662
7894
|
render: /* @__PURE__ */ __name(function* (ctx) {
|
|
7663
7895
|
let argArray = [];
|
|
7664
7896
|
if (this.legacyArgs) {
|
|
7665
|
-
let rawArgs = _Liquid.parseArguments(
|
|
7897
|
+
let rawArgs = _Liquid.parseArguments(this.legacyArgs);
|
|
7666
7898
|
for (let arg of rawArgs) {
|
|
7667
7899
|
let b = yield liquidEngine.evalValue(arg, ctx);
|
|
7668
7900
|
argArray.push(b);
|
|
7669
7901
|
}
|
|
7670
7902
|
} else if (this.orderedArgs) {
|
|
7671
|
-
|
|
7672
|
-
let b = yield evalToken(arg, ctx);
|
|
7673
|
-
argArray.push(b);
|
|
7674
|
-
}
|
|
7903
|
+
argArray = yield* _Liquid.evalArgumentsBuiltin(this.orderedArgs, ctx);
|
|
7675
7904
|
}
|
|
7676
7905
|
const html = yield liquidEngine.renderer.renderTemplates(this.templates, ctx);
|
|
7677
7906
|
let ret = yield shortcodeFn.call(_Liquid.normalizeScope(ctx), html, ...argArray);
|
|
@@ -7704,6 +7933,7 @@ var Liquid2 = class _Liquid extends TemplateEngine {
|
|
|
7704
7933
|
}
|
|
7705
7934
|
async compile(str, inputPath) {
|
|
7706
7935
|
let engine = this.liquidLib;
|
|
7936
|
+
let liquidOptions = this.liquidOptions;
|
|
7707
7937
|
let tmplReady = engine.parse(str, inputPath);
|
|
7708
7938
|
let options = {};
|
|
7709
7939
|
if (!inputPath || inputPath === "liquid" || inputPath === "md") {
|
|
@@ -7712,6 +7942,15 @@ var Liquid2 = class _Liquid extends TemplateEngine {
|
|
|
7712
7942
|
}
|
|
7713
7943
|
return async function(data) {
|
|
7714
7944
|
let tmpl = await tmplReady;
|
|
7945
|
+
options.globals = Object.assign(
|
|
7946
|
+
{
|
|
7947
|
+
page: data?.page,
|
|
7948
|
+
eleventy: data?.eleventy,
|
|
7949
|
+
buildawesome: data?.buildawesome,
|
|
7950
|
+
collections: data?.collections
|
|
7951
|
+
},
|
|
7952
|
+
liquidOptions?.globals
|
|
7953
|
+
);
|
|
7715
7954
|
return engine.render(tmpl, data, options);
|
|
7716
7955
|
};
|
|
7717
7956
|
}
|