@skeptools/skep-organization-project 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +22 -2139
- package/API.md +533 -418
- package/lib/skep-organization-project.js +36 -5
- package/node_modules/liquidjs/README.md +110 -67
- package/node_modules/liquidjs/dist/build/base64-impl-browser.d.ts +2 -0
- package/node_modules/liquidjs/dist/build/base64-impl-browser.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/build/crypto-impl-browser.d.ts +2 -0
- package/node_modules/liquidjs/dist/build/crypto-impl-browser.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/context/context.d.ts +10 -4
- package/node_modules/liquidjs/dist/context/scope.d.ts +2 -2
- package/node_modules/liquidjs/dist/drop/blank-drop.d.ts +1 -1
- package/node_modules/liquidjs/dist/drop/block-drop.d.ts +3 -2
- package/node_modules/liquidjs/dist/drop/comparable.d.ts +11 -5
- package/node_modules/liquidjs/dist/drop/drop.d.ts +3 -1
- package/node_modules/liquidjs/dist/drop/empty-drop.d.ts +1 -1
- package/node_modules/liquidjs/dist/drop/null-drop.d.ts +1 -1
- package/node_modules/liquidjs/dist/filters/array.d.ts +9 -3
- package/node_modules/liquidjs/dist/filters/base64-impl.d.ts +2 -0
- package/node_modules/liquidjs/dist/filters/base64.d.ts +9 -0
- package/node_modules/liquidjs/dist/filters/crypto-impl.d.ts +2 -0
- package/node_modules/liquidjs/dist/filters/crypto.d.ts +8 -0
- package/node_modules/liquidjs/dist/filters/math.d.ts +1 -1
- package/node_modules/liquidjs/dist/filters/misc.d.ts +2 -2
- package/node_modules/liquidjs/dist/filters/string.d.ts +2 -1
- package/node_modules/liquidjs/dist/fs/fs-impl.d.ts +2 -1
- package/node_modules/liquidjs/dist/fs/fs.d.ts +4 -2
- package/node_modules/liquidjs/dist/fs/loader.d.ts +2 -1
- package/node_modules/liquidjs/dist/index.d.ts +8 -3
- package/node_modules/liquidjs/dist/liquid-options.d.ts +8 -2
- package/node_modules/liquidjs/dist/liquid.browser.min.js +1 -1
- package/node_modules/liquidjs/dist/liquid.browser.min.js.map +1 -1
- package/node_modules/liquidjs/dist/liquid.browser.mjs +836 -406
- package/node_modules/liquidjs/dist/liquid.browser.umd.js +1683 -788
- package/node_modules/liquidjs/dist/liquid.browser.umd.js.map +1 -1
- package/node_modules/liquidjs/dist/liquid.d.ts +1 -0
- package/node_modules/liquidjs/dist/liquid.node.js +848 -426
- package/node_modules/liquidjs/dist/liquid.node.mjs +849 -422
- package/node_modules/liquidjs/dist/parser/parser.d.ts +1 -0
- package/node_modules/liquidjs/dist/parser/token-kind.d.ts +1 -0
- package/node_modules/liquidjs/dist/parser/tokenizer.d.ts +4 -3
- package/node_modules/liquidjs/dist/render/expression.d.ts +11 -1
- package/node_modules/liquidjs/dist/render/operator.d.ts +11 -4
- package/node_modules/liquidjs/dist/tags/case.d.ts +2 -2
- package/node_modules/liquidjs/dist/tags/for.d.ts +2 -2
- package/node_modules/liquidjs/dist/tags/include.d.ts +2 -0
- package/node_modules/liquidjs/dist/tags/layout.d.ts +1 -0
- package/node_modules/liquidjs/dist/tags/render.d.ts +2 -0
- package/node_modules/liquidjs/dist/tags/tablerow.d.ts +2 -2
- package/node_modules/liquidjs/dist/tokens/literal-token.d.ts +2 -2
- package/node_modules/liquidjs/dist/tokens/operator-token.d.ts +3 -2
- package/node_modules/liquidjs/dist/tokens/property-access-token.d.ts +3 -2
- package/node_modules/liquidjs/dist/tokens/tag-token.d.ts +1 -1
- package/node_modules/liquidjs/dist/tokens/value-token.d.ts +2 -1
- package/node_modules/liquidjs/dist/util/async.d.ts +2 -0
- package/node_modules/liquidjs/dist/util/liquid-date.d.ts +7 -0
- package/node_modules/liquidjs/dist/util/operator-trie.d.ts +4 -8
- package/node_modules/liquidjs/dist/util/strftime.d.ts +2 -1
- package/node_modules/liquidjs/dist/util/type-guards.d.ts +2 -1
- package/node_modules/liquidjs/dist/util/underscore.d.ts +5 -1
- package/node_modules/liquidjs/package.json +20 -14
- package/package.json +47 -41
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* liquidjs@10.
|
|
3
|
-
* (c) 2016-
|
|
2
|
+
* liquidjs@10.30.1, https://github.com/harttle/liquidjs
|
|
3
|
+
* (c) 2016-2026 harttle
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
var Drop = /** @class */ (function () {
|
|
161
161
|
function Drop() {
|
|
162
162
|
}
|
|
163
|
-
Drop.prototype.liquidMethodMissing = function (key) {
|
|
163
|
+
Drop.prototype.liquidMethodMissing = function (key, context) {
|
|
164
164
|
return undefined;
|
|
165
165
|
};
|
|
166
166
|
return Drop;
|
|
@@ -182,9 +182,6 @@
|
|
|
182
182
|
function isIterator(val) {
|
|
183
183
|
return val && isFunction(val.next) && isFunction(val.throw) && isFunction(val.return);
|
|
184
184
|
}
|
|
185
|
-
function escapeRegex(str) {
|
|
186
|
-
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
187
|
-
}
|
|
188
185
|
function stringify(value) {
|
|
189
186
|
value = toValue(value);
|
|
190
187
|
if (isString(value))
|
|
@@ -195,6 +192,25 @@
|
|
|
195
192
|
return value.map(function (x) { return stringify(x); }).join('');
|
|
196
193
|
return String(value);
|
|
197
194
|
}
|
|
195
|
+
function advanceCodePoints(str, from, count) {
|
|
196
|
+
var index = from;
|
|
197
|
+
for (var i = 0; i < count && index < str.length; i++)
|
|
198
|
+
index += str.codePointAt(index) > 0xFFFF ? 2 : 1;
|
|
199
|
+
return index;
|
|
200
|
+
}
|
|
201
|
+
function codePointLength(str) {
|
|
202
|
+
var length = 0;
|
|
203
|
+
for (var index = 0; index < str.length; index = advanceCodePoints(str, index, 1))
|
|
204
|
+
length++;
|
|
205
|
+
return length;
|
|
206
|
+
}
|
|
207
|
+
function readArrayElement(arr, index, ownPropertyOnly) {
|
|
208
|
+
if (index < 0)
|
|
209
|
+
index = arr.length + index;
|
|
210
|
+
if (ownPropertyOnly && !hasOwnProperty.call(arr, index))
|
|
211
|
+
return undefined;
|
|
212
|
+
return arr[index];
|
|
213
|
+
}
|
|
198
214
|
function toEnumerable(val) {
|
|
199
215
|
val = toValue(val);
|
|
200
216
|
if (isArray(val))
|
|
@@ -219,8 +235,7 @@
|
|
|
219
235
|
return (value instanceof Drop && isFunction(value.valueOf)) ? value.valueOf() : value;
|
|
220
236
|
}
|
|
221
237
|
function toNumber(value) {
|
|
222
|
-
|
|
223
|
-
return isNaN(value) ? 0 : value;
|
|
238
|
+
return +toValue(value) || 0;
|
|
224
239
|
}
|
|
225
240
|
function isNumber(value) {
|
|
226
241
|
return typeof value === 'number';
|
|
@@ -296,9 +311,9 @@
|
|
|
296
311
|
function pad(str, length, ch, add) {
|
|
297
312
|
str = String(str);
|
|
298
313
|
var n = length - str.length;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return str;
|
|
314
|
+
if (n <= 0)
|
|
315
|
+
return str;
|
|
316
|
+
return add(str, ch.repeat(n));
|
|
302
317
|
}
|
|
303
318
|
function identify(val) {
|
|
304
319
|
return val;
|
|
@@ -310,13 +325,26 @@
|
|
|
310
325
|
function ellipsis(str, N) {
|
|
311
326
|
return str.length > N ? str.slice(0, N - 3) + '...' : str;
|
|
312
327
|
}
|
|
328
|
+
function orderedCompare(a, b) {
|
|
329
|
+
if (isNil(a) && isNil(b))
|
|
330
|
+
return 0;
|
|
331
|
+
if (isNil(a))
|
|
332
|
+
return 1;
|
|
333
|
+
if (isNil(b))
|
|
334
|
+
return -1;
|
|
335
|
+
if (a < b)
|
|
336
|
+
return -1;
|
|
337
|
+
if (a > b)
|
|
338
|
+
return 1;
|
|
339
|
+
return 0;
|
|
340
|
+
}
|
|
313
341
|
// compare string in case-insensitive way, undefined values to the tail
|
|
314
342
|
function caseInsensitiveCompare(a, b) {
|
|
315
|
-
if (a
|
|
343
|
+
if (isNil(a) && isNil(b))
|
|
316
344
|
return 0;
|
|
317
|
-
if (a
|
|
345
|
+
if (isNil(a))
|
|
318
346
|
return 1;
|
|
319
|
-
if (b
|
|
347
|
+
if (isNil(b))
|
|
320
348
|
return -1;
|
|
321
349
|
a = toLowerCase.call(a);
|
|
322
350
|
b = toLowerCase.call(b);
|
|
@@ -335,8 +363,14 @@
|
|
|
335
363
|
return fn.call.apply(fn, __spreadArray([this], __read(args.map(toValue)), false));
|
|
336
364
|
};
|
|
337
365
|
}
|
|
338
|
-
function
|
|
339
|
-
return
|
|
366
|
+
function argumentsToNumber(fn) {
|
|
367
|
+
return function () {
|
|
368
|
+
var args = [];
|
|
369
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
370
|
+
args[_i] = arguments[_i];
|
|
371
|
+
}
|
|
372
|
+
return fn.call.apply(fn, __spreadArray([this], __read(args.map(toNumber)), false));
|
|
373
|
+
};
|
|
340
374
|
}
|
|
341
375
|
/** Return an array containing unique elements from _array_. Works with nested arrays and objects. */
|
|
342
376
|
function strictUniq(array) {
|
|
@@ -563,7 +597,15 @@
|
|
|
563
597
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
564
598
|
}
|
|
565
599
|
NullDrop.prototype.equals = function (value) {
|
|
566
|
-
|
|
600
|
+
var _a;
|
|
601
|
+
return __generator(this, function (_b) {
|
|
602
|
+
switch (_b.label) {
|
|
603
|
+
case 0:
|
|
604
|
+
_a = isNil;
|
|
605
|
+
return [4 /*yield*/, toValue(value)];
|
|
606
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
|
|
607
|
+
}
|
|
608
|
+
});
|
|
567
609
|
};
|
|
568
610
|
NullDrop.prototype.gt = function () {
|
|
569
611
|
return false;
|
|
@@ -589,14 +631,21 @@
|
|
|
589
631
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
590
632
|
}
|
|
591
633
|
EmptyDrop.prototype.equals = function (value) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
634
|
+
return __generator(this, function (_a) {
|
|
635
|
+
switch (_a.label) {
|
|
636
|
+
case 0:
|
|
637
|
+
if (value instanceof EmptyDrop)
|
|
638
|
+
return [2 /*return*/, false];
|
|
639
|
+
return [4 /*yield*/, toValue(value)];
|
|
640
|
+
case 1:
|
|
641
|
+
value = _a.sent();
|
|
642
|
+
if (isString(value) || isArray(value))
|
|
643
|
+
return [2 /*return*/, value.length === 0];
|
|
644
|
+
if (isObject(value))
|
|
645
|
+
return [2 /*return*/, Object.keys(value).length === 0];
|
|
646
|
+
return [2 /*return*/, false];
|
|
647
|
+
}
|
|
648
|
+
});
|
|
600
649
|
};
|
|
601
650
|
EmptyDrop.prototype.gt = function () {
|
|
602
651
|
return false;
|
|
@@ -625,13 +674,23 @@
|
|
|
625
674
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
626
675
|
}
|
|
627
676
|
BlankDrop.prototype.equals = function (value) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
677
|
+
var _a;
|
|
678
|
+
return __generator(this, function (_b) {
|
|
679
|
+
switch (_b.label) {
|
|
680
|
+
case 0:
|
|
681
|
+
if (value === false)
|
|
682
|
+
return [2 /*return*/, true];
|
|
683
|
+
_a = isNil;
|
|
684
|
+
return [4 /*yield*/, toValue(value)];
|
|
685
|
+
case 1:
|
|
686
|
+
if (_a.apply(void 0, [_b.sent()]))
|
|
687
|
+
return [2 /*return*/, true];
|
|
688
|
+
if (isString(value))
|
|
689
|
+
return [2 /*return*/, /^\s*$/.test(value)];
|
|
690
|
+
return [4 /*yield*/, _super.prototype.equals.call(this, value)];
|
|
691
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
692
|
+
}
|
|
693
|
+
});
|
|
635
694
|
};
|
|
636
695
|
BlankDrop.is = function (value) {
|
|
637
696
|
return value instanceof BlankDrop;
|
|
@@ -675,6 +734,45 @@
|
|
|
675
734
|
return ForloopDrop;
|
|
676
735
|
}(Drop));
|
|
677
736
|
|
|
737
|
+
var SimpleEmitter = /** @class */ (function () {
|
|
738
|
+
function SimpleEmitter() {
|
|
739
|
+
this.buffer = '';
|
|
740
|
+
}
|
|
741
|
+
SimpleEmitter.prototype.write = function (html) {
|
|
742
|
+
this.buffer += stringify(html);
|
|
743
|
+
};
|
|
744
|
+
return SimpleEmitter;
|
|
745
|
+
}());
|
|
746
|
+
|
|
747
|
+
var StreamedEmitter = /** @class */ (function () {
|
|
748
|
+
function StreamedEmitter() {
|
|
749
|
+
this.buffer = '';
|
|
750
|
+
this.stream = null;
|
|
751
|
+
throw new Error('streaming not supported in browser');
|
|
752
|
+
}
|
|
753
|
+
return StreamedEmitter;
|
|
754
|
+
}());
|
|
755
|
+
|
|
756
|
+
var KeepingTypeEmitter = /** @class */ (function () {
|
|
757
|
+
function KeepingTypeEmitter() {
|
|
758
|
+
this.buffer = '';
|
|
759
|
+
}
|
|
760
|
+
KeepingTypeEmitter.prototype.write = function (html) {
|
|
761
|
+
html = toValue(html);
|
|
762
|
+
// This will only preserve the type if the value is isolated.
|
|
763
|
+
// I.E:
|
|
764
|
+
// {{ my-port }} -> 42
|
|
765
|
+
// {{ my-host }}:{{ my-port }} -> 'host:42'
|
|
766
|
+
if (typeof html !== 'string' && this.buffer === '') {
|
|
767
|
+
this.buffer = html;
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
this.buffer = stringify(this.buffer) + stringify(html);
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
return KeepingTypeEmitter;
|
|
774
|
+
}());
|
|
775
|
+
|
|
678
776
|
var BlockDrop = /** @class */ (function (_super) {
|
|
679
777
|
__extends(BlockDrop, _super);
|
|
680
778
|
function BlockDrop(
|
|
@@ -690,7 +788,17 @@
|
|
|
690
788
|
* {{ block.super }}
|
|
691
789
|
*/
|
|
692
790
|
BlockDrop.prototype.super = function () {
|
|
693
|
-
|
|
791
|
+
var emitter;
|
|
792
|
+
return __generator(this, function (_a) {
|
|
793
|
+
switch (_a.label) {
|
|
794
|
+
case 0:
|
|
795
|
+
emitter = new SimpleEmitter();
|
|
796
|
+
return [4 /*yield*/, this.superBlockRender(emitter)];
|
|
797
|
+
case 1:
|
|
798
|
+
_a.sent();
|
|
799
|
+
return [2 /*return*/, emitter.buffer];
|
|
800
|
+
}
|
|
801
|
+
});
|
|
694
802
|
};
|
|
695
803
|
return BlockDrop;
|
|
696
804
|
}(Drop));
|
|
@@ -714,8 +822,17 @@
|
|
|
714
822
|
'blank': new BlankDrop()
|
|
715
823
|
};
|
|
716
824
|
|
|
825
|
+
// Tries are built once per input object and reused: the Tokenizer rebuilds them
|
|
826
|
+
// on every instantiation, but `input` (operators/literalValues) is a stable
|
|
827
|
+
// reference. WeakMap-keying by `input` lets short-lived operator objects (and
|
|
828
|
+
// their tries) be garbage collected. The returned trie is treated as read-only
|
|
829
|
+
// by callers (matchTrie only reads it); do not mutate it.
|
|
830
|
+
var trieCache = new WeakMap();
|
|
717
831
|
function createTrie(input) {
|
|
718
832
|
var e_1, _a;
|
|
833
|
+
var cached = trieCache.get(input);
|
|
834
|
+
if (cached)
|
|
835
|
+
return cached;
|
|
719
836
|
var trie = {};
|
|
720
837
|
try {
|
|
721
838
|
for (var _b = __values(Object.entries(input)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -740,9 +857,20 @@
|
|
|
740
857
|
}
|
|
741
858
|
finally { if (e_1) throw e_1.error; }
|
|
742
859
|
}
|
|
860
|
+
trieCache.set(input, trie);
|
|
743
861
|
return trie;
|
|
744
862
|
}
|
|
745
863
|
|
|
864
|
+
function toLiquidAsync(asyncFn, syncFn) {
|
|
865
|
+
var syncImpl = syncFn || asyncFn;
|
|
866
|
+
return function (sync) {
|
|
867
|
+
var args = [];
|
|
868
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
869
|
+
args[_i - 1] = arguments[_i];
|
|
870
|
+
}
|
|
871
|
+
return sync ? syncImpl.apply(void 0, __spreadArray([], __read(args), false)) : asyncFn.apply(void 0, __spreadArray([], __read(args), false));
|
|
872
|
+
};
|
|
873
|
+
}
|
|
746
874
|
// convert an async iterator to a Promise
|
|
747
875
|
function toPromise(val) {
|
|
748
876
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -757,7 +885,7 @@
|
|
|
757
885
|
_a.label = 1;
|
|
758
886
|
case 1:
|
|
759
887
|
state = val[next](value);
|
|
760
|
-
done = state.done;
|
|
888
|
+
done = !!state.done;
|
|
761
889
|
value = state.value;
|
|
762
890
|
next = 'next';
|
|
763
891
|
_a.label = 2;
|
|
@@ -793,7 +921,7 @@
|
|
|
793
921
|
var next = 'next';
|
|
794
922
|
do {
|
|
795
923
|
var state = val[next](value);
|
|
796
|
-
done = state.done;
|
|
924
|
+
done = !!state.done;
|
|
797
925
|
value = state.value;
|
|
798
926
|
next = 'next';
|
|
799
927
|
if (isIterator(value)) {
|
|
@@ -823,12 +951,9 @@
|
|
|
823
951
|
return num + d.getDate();
|
|
824
952
|
}
|
|
825
953
|
function getWeekOfYear(d, startDay) {
|
|
826
|
-
//
|
|
827
|
-
var
|
|
828
|
-
|
|
829
|
-
var jan1 = new Date(d.getFullYear(), 0, 1);
|
|
830
|
-
var then = (7 - jan1.getDay() + startDay);
|
|
831
|
-
return String(Math.floor((now - then) / 7) + 1);
|
|
954
|
+
// Days before the first startDay of the year belong to week 0
|
|
955
|
+
var daysSinceStartDay = (d.getDay() - startDay + 7) % 7;
|
|
956
|
+
return String(Math.floor((getDayOfYear(d) - 1 - daysSinceStartDay + 7) / 7));
|
|
832
957
|
}
|
|
833
958
|
function isLeapYear(d) {
|
|
834
959
|
var year = d.getFullYear();
|
|
@@ -846,10 +971,11 @@
|
|
|
846
971
|
}
|
|
847
972
|
}
|
|
848
973
|
function century(d) {
|
|
849
|
-
return
|
|
974
|
+
return Math.floor(d.getFullYear() / 100);
|
|
850
975
|
}
|
|
851
976
|
// default to 0
|
|
852
977
|
var padWidths = {
|
|
978
|
+
C: 2,
|
|
853
979
|
d: 2,
|
|
854
980
|
e: 2,
|
|
855
981
|
H: 2,
|
|
@@ -862,7 +988,9 @@
|
|
|
862
988
|
M: 2,
|
|
863
989
|
S: 2,
|
|
864
990
|
U: 2,
|
|
865
|
-
W: 2
|
|
991
|
+
W: 2,
|
|
992
|
+
y: 2,
|
|
993
|
+
Y: 4
|
|
866
994
|
};
|
|
867
995
|
var padSpaceChars = new Set('aAbBceklpP');
|
|
868
996
|
function getTimezoneOffset(d, opts) {
|
|
@@ -892,14 +1020,16 @@
|
|
|
892
1020
|
m: function (d) { return d.getMonth() + 1; },
|
|
893
1021
|
M: function (d) { return d.getMinutes(); },
|
|
894
1022
|
N: function (d, opts) {
|
|
1023
|
+
var _a;
|
|
895
1024
|
var width = Number(opts.width) || 9;
|
|
896
|
-
var str = String(d.getMilliseconds()).slice(0, width);
|
|
1025
|
+
var str = padStart(String(d.getMilliseconds()), 3, '0').slice(0, width);
|
|
1026
|
+
(_a = opts.memoryLimit) === null || _a === void 0 ? void 0 : _a.use(width - str.length);
|
|
897
1027
|
return padEnd(str, width, '0');
|
|
898
1028
|
},
|
|
899
1029
|
p: function (d) { return (d.getHours() < 12 ? 'AM' : 'PM'); },
|
|
900
1030
|
P: function (d) { return (d.getHours() < 12 ? 'am' : 'pm'); },
|
|
901
1031
|
q: function (d) { return ordinal(d); },
|
|
902
|
-
s: function (d) { return Math.
|
|
1032
|
+
s: function (d) { return Math.floor(d.dateValue() / 1000); },
|
|
903
1033
|
S: function (d) { return d.getSeconds(); },
|
|
904
1034
|
u: function (d) { return d.getDay() || 7; },
|
|
905
1035
|
U: function (d) { return getWeekOfYear(d, 0); },
|
|
@@ -907,7 +1037,7 @@
|
|
|
907
1037
|
W: function (d) { return getWeekOfYear(d, 1); },
|
|
908
1038
|
x: function (d) { return d.toLocaleDateString(); },
|
|
909
1039
|
X: function (d) { return d.toLocaleTimeString(); },
|
|
910
|
-
y: function (d) { return d.getFullYear()
|
|
1040
|
+
y: function (d) { return (d.getFullYear() % 100 + 100) % 100; },
|
|
911
1041
|
Y: function (d) { return d.getFullYear(); },
|
|
912
1042
|
z: getTimezoneOffset,
|
|
913
1043
|
Z: function (d, opts) { return d.getTimeZoneName() || getTimezoneOffset(d, opts); },
|
|
@@ -916,18 +1046,18 @@
|
|
|
916
1046
|
'%': function () { return '%'; }
|
|
917
1047
|
};
|
|
918
1048
|
formatCodes.h = formatCodes.b;
|
|
919
|
-
function strftime(d, formatStr) {
|
|
1049
|
+
function strftime(d, formatStr, memoryLimit) {
|
|
920
1050
|
var output = '';
|
|
921
1051
|
var remaining = formatStr;
|
|
922
1052
|
var match;
|
|
923
1053
|
while ((match = rFormat.exec(remaining))) {
|
|
924
1054
|
output += remaining.slice(0, match.index);
|
|
925
1055
|
remaining = remaining.slice(match.index + match[0].length);
|
|
926
|
-
output += format(d, match);
|
|
1056
|
+
output += format(d, match, memoryLimit);
|
|
927
1057
|
}
|
|
928
1058
|
return output + remaining;
|
|
929
1059
|
}
|
|
930
|
-
function format(d, match) {
|
|
1060
|
+
function format(d, match, memoryLimit) {
|
|
931
1061
|
var e_1, _a;
|
|
932
1062
|
var _b = __read(match, 5), input = _b[0], _c = _b[1], flagStr = _c === void 0 ? '' : _c, width = _b[2], modifier = _b[3], conversion = _b[4];
|
|
933
1063
|
var convert = formatCodes[conversion];
|
|
@@ -947,9 +1077,9 @@
|
|
|
947
1077
|
}
|
|
948
1078
|
finally { if (e_1) throw e_1.error; }
|
|
949
1079
|
}
|
|
950
|
-
var ret = String(convert(d, { flags: flags, width: width, modifier: modifier }));
|
|
1080
|
+
var ret = String(convert(d, { flags: flags, width: width, modifier: modifier, memoryLimit: memoryLimit }));
|
|
951
1081
|
var padChar = padSpaceChars.has(conversion) ? ' ' : '0';
|
|
952
|
-
var padWidth = width || padWidths[conversion] || 0;
|
|
1082
|
+
var padWidth = Number(width) || padWidths[conversion] || 0;
|
|
953
1083
|
if (flags['^'])
|
|
954
1084
|
ret = ret.toUpperCase();
|
|
955
1085
|
else if (flags['#'])
|
|
@@ -960,6 +1090,9 @@
|
|
|
960
1090
|
padChar = '0';
|
|
961
1091
|
if (flags['-'])
|
|
962
1092
|
padWidth = 0;
|
|
1093
|
+
memoryLimit === null || memoryLimit === void 0 ? void 0 : memoryLimit.use(Number(padWidth) - ret.length);
|
|
1094
|
+
if (padChar === '0' && ret[0] === '-')
|
|
1095
|
+
return '-' + padStart(ret.slice(1), padWidth - 1, padChar);
|
|
963
1096
|
return padStart(ret, padWidth, padChar);
|
|
964
1097
|
}
|
|
965
1098
|
|
|
@@ -1008,6 +1141,15 @@
|
|
|
1008
1141
|
LiquidDate.prototype.getTime = function () {
|
|
1009
1142
|
return this.displayDate.getTime();
|
|
1010
1143
|
};
|
|
1144
|
+
/**
|
|
1145
|
+
* The underlying UTC timestamp in milliseconds, unaffected by the display
|
|
1146
|
+
* timezone. Use this (not `getTime()`) for timezone-invariant values like
|
|
1147
|
+
* `%s`: `getTime()` reads `displayDate`, which is deliberately shifted by
|
|
1148
|
+
* the display timezone offset so wall-clock getters can delegate to Date.
|
|
1149
|
+
*/
|
|
1150
|
+
LiquidDate.prototype.dateValue = function () {
|
|
1151
|
+
return this.date.getTime();
|
|
1152
|
+
};
|
|
1011
1153
|
LiquidDate.prototype.getMilliseconds = function () {
|
|
1012
1154
|
return this.displayDate.getMilliseconds();
|
|
1013
1155
|
};
|
|
@@ -1120,13 +1262,15 @@
|
|
|
1120
1262
|
this.limit = limit;
|
|
1121
1263
|
}
|
|
1122
1264
|
Limiter.prototype.use = function (count) {
|
|
1123
|
-
count
|
|
1124
|
-
|
|
1125
|
-
|
|
1265
|
+
if (+count > 0) {
|
|
1266
|
+
assert(this.base + +count <= this.limit, this.message);
|
|
1267
|
+
this.base += +count;
|
|
1268
|
+
}
|
|
1126
1269
|
};
|
|
1127
1270
|
Limiter.prototype.check = function (count) {
|
|
1128
|
-
count
|
|
1129
|
-
|
|
1271
|
+
if (+count > 0) {
|
|
1272
|
+
assert(+count <= this.limit, this.message);
|
|
1273
|
+
}
|
|
1130
1274
|
};
|
|
1131
1275
|
return Limiter;
|
|
1132
1276
|
}());
|
|
@@ -1168,19 +1312,13 @@
|
|
|
1168
1312
|
var trimTagLeft = options.trimTagLeft, trimTagRight = options.trimTagRight, tagDelimiterLeft = options.tagDelimiterLeft, tagDelimiterRight = options.tagDelimiterRight;
|
|
1169
1313
|
var _a = __read([begin + tagDelimiterLeft.length, end - tagDelimiterRight.length], 2), valueBegin = _a[0], valueEnd = _a[1];
|
|
1170
1314
|
_this = _super.call(this, exports.TokenKind.Tag, [valueBegin, valueEnd], input, begin, end, trimTagLeft, trimTagRight, file) || this;
|
|
1171
|
-
_this.tokenizer = new Tokenizer(input, options.operators, file, _this.contentRange);
|
|
1315
|
+
_this.tokenizer = new Tokenizer(input, options.operators, file, _this.contentRange, options.groupedExpressions);
|
|
1172
1316
|
_this.name = _this.tokenizer.readTagName();
|
|
1173
1317
|
_this.tokenizer.assert(_this.name, "illegal tag syntax, tag name expected");
|
|
1174
1318
|
_this.tokenizer.skipBlank();
|
|
1319
|
+
_this.args = _this.tokenizer.input.slice(_this.tokenizer.p, _this.contentRange[1]);
|
|
1175
1320
|
return _this;
|
|
1176
1321
|
}
|
|
1177
|
-
Object.defineProperty(TagToken.prototype, "args", {
|
|
1178
|
-
get: function () {
|
|
1179
|
-
return this.tokenizer.input.slice(this.tokenizer.p, this.contentRange[1]);
|
|
1180
|
-
},
|
|
1181
|
-
enumerable: false,
|
|
1182
|
-
configurable: true
|
|
1183
|
-
});
|
|
1184
1322
|
return TagToken;
|
|
1185
1323
|
}(DelimitedToken));
|
|
1186
1324
|
|
|
@@ -1291,8 +1429,7 @@
|
|
|
1291
1429
|
return _this;
|
|
1292
1430
|
}
|
|
1293
1431
|
OperatorToken.prototype.getPrecedence = function () {
|
|
1294
|
-
|
|
1295
|
-
return key in operatorPrecedences ? operatorPrecedences[key] : 1;
|
|
1432
|
+
return this.operator in operatorPrecedences ? operatorPrecedences[this.operator] : 1;
|
|
1296
1433
|
};
|
|
1297
1434
|
return OperatorToken;
|
|
1298
1435
|
}(Token));
|
|
@@ -1423,7 +1560,7 @@
|
|
|
1423
1560
|
__extends(LiquidTagToken, _super);
|
|
1424
1561
|
function LiquidTagToken(input, begin, end, options, file) {
|
|
1425
1562
|
var _this = _super.call(this, exports.TokenKind.Tag, [begin, end], input, begin, end, false, false, file) || this;
|
|
1426
|
-
_this.tokenizer = new Tokenizer(input, options.operators, file, _this.contentRange);
|
|
1563
|
+
_this.tokenizer = new Tokenizer(input, options.operators, file, _this.contentRange, options.groupedExpressions);
|
|
1427
1564
|
_this.name = _this.tokenizer.readTagName();
|
|
1428
1565
|
_this.tokenizer.assert(_this.name, 'illegal liquid tag syntax');
|
|
1429
1566
|
_this.tokenizer.skipBlank();
|
|
@@ -1468,45 +1605,6 @@
|
|
|
1468
1605
|
polyfill;
|
|
1469
1606
|
}
|
|
1470
1607
|
|
|
1471
|
-
var SimpleEmitter = /** @class */ (function () {
|
|
1472
|
-
function SimpleEmitter() {
|
|
1473
|
-
this.buffer = '';
|
|
1474
|
-
}
|
|
1475
|
-
SimpleEmitter.prototype.write = function (html) {
|
|
1476
|
-
this.buffer += stringify(html);
|
|
1477
|
-
};
|
|
1478
|
-
return SimpleEmitter;
|
|
1479
|
-
}());
|
|
1480
|
-
|
|
1481
|
-
var StreamedEmitter = /** @class */ (function () {
|
|
1482
|
-
function StreamedEmitter() {
|
|
1483
|
-
this.buffer = '';
|
|
1484
|
-
this.stream = null;
|
|
1485
|
-
throw new Error('streaming not supported in browser');
|
|
1486
|
-
}
|
|
1487
|
-
return StreamedEmitter;
|
|
1488
|
-
}());
|
|
1489
|
-
|
|
1490
|
-
var KeepingTypeEmitter = /** @class */ (function () {
|
|
1491
|
-
function KeepingTypeEmitter() {
|
|
1492
|
-
this.buffer = '';
|
|
1493
|
-
}
|
|
1494
|
-
KeepingTypeEmitter.prototype.write = function (html) {
|
|
1495
|
-
html = toValue(html);
|
|
1496
|
-
// This will only preserve the type if the value is isolated.
|
|
1497
|
-
// I.E:
|
|
1498
|
-
// {{ my-port }} -> 42
|
|
1499
|
-
// {{ my-host }}:{{ my-port }} -> 'host:42'
|
|
1500
|
-
if (typeof html !== 'string' && this.buffer === '') {
|
|
1501
|
-
this.buffer = html;
|
|
1502
|
-
}
|
|
1503
|
-
else {
|
|
1504
|
-
this.buffer = stringify(this.buffer) + stringify(html);
|
|
1505
|
-
}
|
|
1506
|
-
};
|
|
1507
|
-
return KeepingTypeEmitter;
|
|
1508
|
-
}());
|
|
1509
|
-
|
|
1510
1608
|
var Render = /** @class */ (function () {
|
|
1511
1609
|
function Render() {
|
|
1512
1610
|
}
|
|
@@ -1526,6 +1624,7 @@
|
|
|
1526
1624
|
if (!emitter) {
|
|
1527
1625
|
emitter = ctx.opts.keepOutputType ? new KeepingTypeEmitter() : new SimpleEmitter();
|
|
1528
1626
|
}
|
|
1627
|
+
ctx.renderLimit.check(getPerformance().now());
|
|
1529
1628
|
errors = [];
|
|
1530
1629
|
_b.label = 1;
|
|
1531
1630
|
case 1:
|
|
@@ -1582,6 +1681,71 @@
|
|
|
1582
1681
|
return Render;
|
|
1583
1682
|
}());
|
|
1584
1683
|
|
|
1684
|
+
function isKeyValuePair(arr) {
|
|
1685
|
+
return isArray(arr);
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
var Filter = /** @class */ (function () {
|
|
1689
|
+
function Filter(token, options, liquid) {
|
|
1690
|
+
this.token = token;
|
|
1691
|
+
this.name = token.name;
|
|
1692
|
+
this.handler = isFunction(options)
|
|
1693
|
+
? options
|
|
1694
|
+
: (isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify);
|
|
1695
|
+
this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
|
|
1696
|
+
this.args = token.args;
|
|
1697
|
+
this.liquid = liquid;
|
|
1698
|
+
}
|
|
1699
|
+
Filter.prototype.render = function (value, context) {
|
|
1700
|
+
var argv, _a, _b, arg, _c, _d, _e, _f, _g, e_1_1;
|
|
1701
|
+
var e_1, _h;
|
|
1702
|
+
return __generator(this, function (_j) {
|
|
1703
|
+
switch (_j.label) {
|
|
1704
|
+
case 0:
|
|
1705
|
+
argv = [];
|
|
1706
|
+
_j.label = 1;
|
|
1707
|
+
case 1:
|
|
1708
|
+
_j.trys.push([1, 8, 9, 10]);
|
|
1709
|
+
_a = __values(this.args), _b = _a.next();
|
|
1710
|
+
_j.label = 2;
|
|
1711
|
+
case 2:
|
|
1712
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
1713
|
+
arg = _b.value;
|
|
1714
|
+
if (!isKeyValuePair(arg)) return [3 /*break*/, 4];
|
|
1715
|
+
_d = (_c = argv).push;
|
|
1716
|
+
_e = [arg[0]];
|
|
1717
|
+
return [4 /*yield*/, evalToken(arg[1], context)];
|
|
1718
|
+
case 3:
|
|
1719
|
+
_d.apply(_c, [_e.concat([_j.sent()])]);
|
|
1720
|
+
return [3 /*break*/, 6];
|
|
1721
|
+
case 4:
|
|
1722
|
+
_g = (_f = argv).push;
|
|
1723
|
+
return [4 /*yield*/, evalToken(arg, context)];
|
|
1724
|
+
case 5:
|
|
1725
|
+
_g.apply(_f, [_j.sent()]);
|
|
1726
|
+
_j.label = 6;
|
|
1727
|
+
case 6:
|
|
1728
|
+
_b = _a.next();
|
|
1729
|
+
return [3 /*break*/, 2];
|
|
1730
|
+
case 7: return [3 /*break*/, 10];
|
|
1731
|
+
case 8:
|
|
1732
|
+
e_1_1 = _j.sent();
|
|
1733
|
+
e_1 = { error: e_1_1 };
|
|
1734
|
+
return [3 /*break*/, 10];
|
|
1735
|
+
case 9:
|
|
1736
|
+
try {
|
|
1737
|
+
if (_b && !_b.done && (_h = _a.return)) _h.call(_a);
|
|
1738
|
+
}
|
|
1739
|
+
finally { if (e_1) throw e_1.error; }
|
|
1740
|
+
return [7 /*endfinally*/];
|
|
1741
|
+
case 10: return [4 /*yield*/, this.handler.apply({ context: context, token: this.token, liquid: this.liquid }, __spreadArray([value], __read(argv), false))];
|
|
1742
|
+
case 11: return [2 /*return*/, _j.sent()];
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
};
|
|
1746
|
+
return Filter;
|
|
1747
|
+
}());
|
|
1748
|
+
|
|
1585
1749
|
var Expression = /** @class */ (function () {
|
|
1586
1750
|
function Expression(tokens) {
|
|
1587
1751
|
this.postfix = __spreadArray([], __read(toPostfix(tokens)), false);
|
|
@@ -1648,6 +1812,11 @@
|
|
|
1648
1812
|
};
|
|
1649
1813
|
return Expression;
|
|
1650
1814
|
}());
|
|
1815
|
+
/**
|
|
1816
|
+
* Evaluate `token`, preserving Drops.
|
|
1817
|
+
* Operators use this so `Comparable` drops (`empty`, `nil`, `blank`) and custom drops
|
|
1818
|
+
* are compared as drops rather than as their `valueOf()` result.
|
|
1819
|
+
*/
|
|
1651
1820
|
function evalToken(token, ctx, lenient) {
|
|
1652
1821
|
if (lenient === void 0) { lenient = false; }
|
|
1653
1822
|
return __generator(this, function (_a) {
|
|
@@ -1664,13 +1833,90 @@
|
|
|
1664
1833
|
if (!isRangeToken(token)) return [3 /*break*/, 4];
|
|
1665
1834
|
return [4 /*yield*/, evalRangeToken(token, ctx)];
|
|
1666
1835
|
case 3: return [2 /*return*/, _a.sent()];
|
|
1667
|
-
case 4:
|
|
1836
|
+
case 4:
|
|
1837
|
+
if (!isFilteredValueToken(token)) return [3 /*break*/, 6];
|
|
1838
|
+
return [4 /*yield*/, evalFilteredValueToken(token, ctx, lenient)];
|
|
1839
|
+
case 5: return [2 /*return*/, _a.sent()];
|
|
1840
|
+
case 6: return [2 /*return*/];
|
|
1841
|
+
}
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
function evalFilteredValueToken(token, ctx, lenient) {
|
|
1845
|
+
var val, _loop_1, _a, _b, filterToken, e_2_1;
|
|
1846
|
+
var e_2, _c;
|
|
1847
|
+
return __generator(this, function (_d) {
|
|
1848
|
+
switch (_d.label) {
|
|
1849
|
+
case 0:
|
|
1850
|
+
assert(ctx.liquid, 'FilteredValueToken evaluation requires liquid instance in context');
|
|
1851
|
+
lenient = lenient || (ctx.opts.lenientIf && token.filters.length > 0 && token.filters[0].name === 'default');
|
|
1852
|
+
return [4 /*yield*/, token.initial.evaluate(ctx, lenient)];
|
|
1853
|
+
case 1:
|
|
1854
|
+
val = _d.sent();
|
|
1855
|
+
_loop_1 = function (filterToken) {
|
|
1856
|
+
var filterImpl, filter;
|
|
1857
|
+
return __generator(this, function (_e) {
|
|
1858
|
+
switch (_e.label) {
|
|
1859
|
+
case 0:
|
|
1860
|
+
filterImpl = ctx.liquid.filters[filterToken.name];
|
|
1861
|
+
assert(filterImpl || !ctx.liquid.options.strictFilters, function () { return "undefined filter: ".concat(filterToken.name); });
|
|
1862
|
+
filter = new Filter(filterToken, filterImpl, ctx.liquid);
|
|
1863
|
+
return [4 /*yield*/, filter.render(val, ctx)];
|
|
1864
|
+
case 1:
|
|
1865
|
+
val = _e.sent();
|
|
1866
|
+
return [2 /*return*/];
|
|
1867
|
+
}
|
|
1868
|
+
});
|
|
1869
|
+
};
|
|
1870
|
+
_d.label = 2;
|
|
1871
|
+
case 2:
|
|
1872
|
+
_d.trys.push([2, 7, 8, 9]);
|
|
1873
|
+
_a = __values(token.filters), _b = _a.next();
|
|
1874
|
+
_d.label = 3;
|
|
1875
|
+
case 3:
|
|
1876
|
+
if (!!_b.done) return [3 /*break*/, 6];
|
|
1877
|
+
filterToken = _b.value;
|
|
1878
|
+
return [5 /*yield**/, _loop_1(filterToken)];
|
|
1879
|
+
case 4:
|
|
1880
|
+
_d.sent();
|
|
1881
|
+
_d.label = 5;
|
|
1882
|
+
case 5:
|
|
1883
|
+
_b = _a.next();
|
|
1884
|
+
return [3 /*break*/, 3];
|
|
1885
|
+
case 6: return [3 /*break*/, 9];
|
|
1886
|
+
case 7:
|
|
1887
|
+
e_2_1 = _d.sent();
|
|
1888
|
+
e_2 = { error: e_2_1 };
|
|
1889
|
+
return [3 /*break*/, 9];
|
|
1890
|
+
case 8:
|
|
1891
|
+
try {
|
|
1892
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1893
|
+
}
|
|
1894
|
+
finally { if (e_2) throw e_2.error; }
|
|
1895
|
+
return [7 /*endfinally*/];
|
|
1896
|
+
case 9: return [2 /*return*/, val];
|
|
1897
|
+
}
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Evaluate `token` to the value filters and tags consume.
|
|
1902
|
+
* Awaits a promise returned by `Drop.valueOf()`.
|
|
1903
|
+
*/
|
|
1904
|
+
function evalTokenValue(token, ctx, lenient) {
|
|
1905
|
+
var _a;
|
|
1906
|
+
if (lenient === void 0) { lenient = false; }
|
|
1907
|
+
return __generator(this, function (_b) {
|
|
1908
|
+
switch (_b.label) {
|
|
1909
|
+
case 0:
|
|
1910
|
+
_a = toValue;
|
|
1911
|
+
return [4 /*yield*/, evalToken(token, ctx, lenient)];
|
|
1912
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, [_b.sent()])];
|
|
1913
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
1668
1914
|
}
|
|
1669
1915
|
});
|
|
1670
1916
|
}
|
|
1671
1917
|
function evalPropertyAccessToken(token, ctx, lenient) {
|
|
1672
|
-
var props, _a, _b, prop, _c, _d,
|
|
1673
|
-
var
|
|
1918
|
+
var props, _a, _b, prop, _c, _d, e_3_1, variable, e_4;
|
|
1919
|
+
var e_3, _e;
|
|
1674
1920
|
return __generator(this, function (_f) {
|
|
1675
1921
|
switch (_f.label) {
|
|
1676
1922
|
case 0:
|
|
@@ -1684,7 +1930,7 @@
|
|
|
1684
1930
|
if (!!_b.done) return [3 /*break*/, 5];
|
|
1685
1931
|
prop = _b.value;
|
|
1686
1932
|
_d = (_c = props).push;
|
|
1687
|
-
return [4 /*yield*/,
|
|
1933
|
+
return [4 /*yield*/, evalTokenValue(prop, ctx, false)];
|
|
1688
1934
|
case 3:
|
|
1689
1935
|
_d.apply(_c, [(_f.sent())]);
|
|
1690
1936
|
_f.label = 4;
|
|
@@ -1693,14 +1939,14 @@
|
|
|
1693
1939
|
return [3 /*break*/, 2];
|
|
1694
1940
|
case 5: return [3 /*break*/, 8];
|
|
1695
1941
|
case 6:
|
|
1696
|
-
|
|
1697
|
-
|
|
1942
|
+
e_3_1 = _f.sent();
|
|
1943
|
+
e_3 = { error: e_3_1 };
|
|
1698
1944
|
return [3 /*break*/, 8];
|
|
1699
1945
|
case 7:
|
|
1700
1946
|
try {
|
|
1701
1947
|
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
1702
1948
|
}
|
|
1703
|
-
finally { if (
|
|
1949
|
+
finally { if (e_3) throw e_3.error; }
|
|
1704
1950
|
return [7 /*endfinally*/];
|
|
1705
1951
|
case 8:
|
|
1706
1952
|
_f.trys.push([8, 14, , 15]);
|
|
@@ -1714,10 +1960,10 @@
|
|
|
1714
1960
|
case 12: return [2 /*return*/, _f.sent()];
|
|
1715
1961
|
case 13: return [3 /*break*/, 15];
|
|
1716
1962
|
case 14:
|
|
1717
|
-
|
|
1718
|
-
if (lenient &&
|
|
1963
|
+
e_4 = _f.sent();
|
|
1964
|
+
if (lenient && e_4.name === 'InternalUndefinedVariableError')
|
|
1719
1965
|
return [2 /*return*/, null];
|
|
1720
|
-
throw (new UndefinedVariableError(
|
|
1966
|
+
throw (new UndefinedVariableError(e_4, token));
|
|
1721
1967
|
case 15: return [2 /*return*/];
|
|
1722
1968
|
}
|
|
1723
1969
|
});
|
|
@@ -1729,20 +1975,20 @@
|
|
|
1729
1975
|
var low, high;
|
|
1730
1976
|
return __generator(this, function (_a) {
|
|
1731
1977
|
switch (_a.label) {
|
|
1732
|
-
case 0: return [4 /*yield*/,
|
|
1978
|
+
case 0: return [4 /*yield*/, evalTokenValue(token.lhs, ctx)];
|
|
1733
1979
|
case 1:
|
|
1734
|
-
low = _a.sent();
|
|
1735
|
-
return [4 /*yield*/,
|
|
1980
|
+
low = (_a.sent());
|
|
1981
|
+
return [4 /*yield*/, evalTokenValue(token.rhs, ctx)];
|
|
1736
1982
|
case 2:
|
|
1737
|
-
high = _a.sent();
|
|
1983
|
+
high = (_a.sent());
|
|
1738
1984
|
ctx.memoryLimit.use(high - low + 1);
|
|
1739
1985
|
return [2 /*return*/, range(+low, +high + 1)];
|
|
1740
1986
|
}
|
|
1741
1987
|
});
|
|
1742
1988
|
}
|
|
1743
1989
|
function toPostfix(tokens) {
|
|
1744
|
-
var ops, tokens_1, tokens_1_1, token,
|
|
1745
|
-
var
|
|
1990
|
+
var ops, tokens_1, tokens_1_1, token, e_5_1;
|
|
1991
|
+
var e_5, _a;
|
|
1746
1992
|
return __generator(this, function (_b) {
|
|
1747
1993
|
switch (_b.label) {
|
|
1748
1994
|
case 0:
|
|
@@ -1775,14 +2021,14 @@
|
|
|
1775
2021
|
return [3 /*break*/, 2];
|
|
1776
2022
|
case 9: return [3 /*break*/, 12];
|
|
1777
2023
|
case 10:
|
|
1778
|
-
|
|
1779
|
-
|
|
2024
|
+
e_5_1 = _b.sent();
|
|
2025
|
+
e_5 = { error: e_5_1 };
|
|
1780
2026
|
return [3 /*break*/, 12];
|
|
1781
2027
|
case 11:
|
|
1782
2028
|
try {
|
|
1783
2029
|
if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
|
|
1784
2030
|
}
|
|
1785
|
-
finally { if (
|
|
2031
|
+
finally { if (e_5) throw e_5.error; }
|
|
1786
2032
|
return [7 /*endfinally*/];
|
|
1787
2033
|
case 12:
|
|
1788
2034
|
if (!ops.length) return [3 /*break*/, 14];
|
|
@@ -1809,67 +2055,245 @@
|
|
|
1809
2055
|
}
|
|
1810
2056
|
|
|
1811
2057
|
var defaultOperators = {
|
|
1812
|
-
'==':
|
|
1813
|
-
|
|
2058
|
+
'==': function (l, r) { return __generator(this, function (_a) {
|
|
2059
|
+
switch (_a.label) {
|
|
2060
|
+
case 0: return [4 /*yield*/, equals(l, r)];
|
|
2061
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
2062
|
+
}
|
|
2063
|
+
}); },
|
|
2064
|
+
'!=': function (l, r) { return __generator(this, function (_a) {
|
|
2065
|
+
switch (_a.label) {
|
|
2066
|
+
case 0: return [4 /*yield*/, equals(l, r)];
|
|
2067
|
+
case 1: return [2 /*return*/, !(_a.sent())];
|
|
2068
|
+
}
|
|
2069
|
+
}); },
|
|
1814
2070
|
'>': function (l, r) {
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
2071
|
+
var _a;
|
|
2072
|
+
return __generator(this, function (_b) {
|
|
2073
|
+
switch (_b.label) {
|
|
2074
|
+
case 0:
|
|
2075
|
+
if (!isComparable(l)) return [3 /*break*/, 2];
|
|
2076
|
+
return [4 /*yield*/, l.gt(r)];
|
|
2077
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
2078
|
+
case 2:
|
|
2079
|
+
if (!isComparable(r)) return [3 /*break*/, 4];
|
|
2080
|
+
return [4 /*yield*/, r.lt(l)];
|
|
2081
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
2082
|
+
case 4: return [4 /*yield*/, toValue(l)];
|
|
2083
|
+
case 5:
|
|
2084
|
+
_a = (_b.sent());
|
|
2085
|
+
return [4 /*yield*/, toValue(r)];
|
|
2086
|
+
case 6: return [2 /*return*/, _a > (_b.sent())];
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
1820
2089
|
},
|
|
1821
2090
|
'<': function (l, r) {
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
2091
|
+
var _a;
|
|
2092
|
+
return __generator(this, function (_b) {
|
|
2093
|
+
switch (_b.label) {
|
|
2094
|
+
case 0:
|
|
2095
|
+
if (!isComparable(l)) return [3 /*break*/, 2];
|
|
2096
|
+
return [4 /*yield*/, l.lt(r)];
|
|
2097
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
2098
|
+
case 2:
|
|
2099
|
+
if (!isComparable(r)) return [3 /*break*/, 4];
|
|
2100
|
+
return [4 /*yield*/, r.gt(l)];
|
|
2101
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
2102
|
+
case 4: return [4 /*yield*/, toValue(l)];
|
|
2103
|
+
case 5:
|
|
2104
|
+
_a = (_b.sent());
|
|
2105
|
+
return [4 /*yield*/, toValue(r)];
|
|
2106
|
+
case 6: return [2 /*return*/, _a < (_b.sent())];
|
|
2107
|
+
}
|
|
2108
|
+
});
|
|
1827
2109
|
},
|
|
1828
2110
|
'>=': function (l, r) {
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
2111
|
+
var _a;
|
|
2112
|
+
return __generator(this, function (_b) {
|
|
2113
|
+
switch (_b.label) {
|
|
2114
|
+
case 0:
|
|
2115
|
+
if (!isComparable(l)) return [3 /*break*/, 2];
|
|
2116
|
+
return [4 /*yield*/, l.geq(r)];
|
|
2117
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
2118
|
+
case 2:
|
|
2119
|
+
if (!isComparable(r)) return [3 /*break*/, 4];
|
|
2120
|
+
return [4 /*yield*/, r.leq(l)];
|
|
2121
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
2122
|
+
case 4: return [4 /*yield*/, toValue(l)];
|
|
2123
|
+
case 5:
|
|
2124
|
+
_a = (_b.sent());
|
|
2125
|
+
return [4 /*yield*/, toValue(r)];
|
|
2126
|
+
case 6: return [2 /*return*/, _a >= (_b.sent())];
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
1834
2129
|
},
|
|
1835
2130
|
'<=': function (l, r) {
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
2131
|
+
var _a;
|
|
2132
|
+
return __generator(this, function (_b) {
|
|
2133
|
+
switch (_b.label) {
|
|
2134
|
+
case 0:
|
|
2135
|
+
if (!isComparable(l)) return [3 /*break*/, 2];
|
|
2136
|
+
return [4 /*yield*/, l.leq(r)];
|
|
2137
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
2138
|
+
case 2:
|
|
2139
|
+
if (!isComparable(r)) return [3 /*break*/, 4];
|
|
2140
|
+
return [4 /*yield*/, r.geq(l)];
|
|
2141
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
2142
|
+
case 4: return [4 /*yield*/, toValue(l)];
|
|
2143
|
+
case 5:
|
|
2144
|
+
_a = (_b.sent());
|
|
2145
|
+
return [4 /*yield*/, toValue(r)];
|
|
2146
|
+
case 6: return [2 /*return*/, _a <= (_b.sent())];
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
1841
2149
|
},
|
|
1842
2150
|
'contains': function (l, r) {
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
2151
|
+
var _a, _b;
|
|
2152
|
+
return __generator(this, function (_c) {
|
|
2153
|
+
switch (_c.label) {
|
|
2154
|
+
case 0: return [4 /*yield*/, toValue(l)];
|
|
2155
|
+
case 1:
|
|
2156
|
+
l = _c.sent();
|
|
2157
|
+
if (!isArray(l)) return [3 /*break*/, 3];
|
|
2158
|
+
return [4 /*yield*/, arrayIncludes(l, r)];
|
|
2159
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
2160
|
+
case 3:
|
|
2161
|
+
if (!isFunction(l === null || l === void 0 ? void 0 : l.indexOf)) return [3 /*break*/, 5];
|
|
2162
|
+
_b = (_a = l).indexOf;
|
|
2163
|
+
return [4 /*yield*/, toValue(r)];
|
|
2164
|
+
case 4: return [2 /*return*/, _b.apply(_a, [_c.sent()]) > -1];
|
|
2165
|
+
case 5: return [2 /*return*/, false];
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
1849
2168
|
},
|
|
1850
|
-
'not': function (v, ctx) { return
|
|
1851
|
-
|
|
1852
|
-
|
|
2169
|
+
'not': function (v, ctx) { var _a; return __generator(this, function (_b) {
|
|
2170
|
+
switch (_b.label) {
|
|
2171
|
+
case 0:
|
|
2172
|
+
_a = isFalsy;
|
|
2173
|
+
return [4 /*yield*/, toValue(v)];
|
|
2174
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), ctx])];
|
|
2175
|
+
}
|
|
2176
|
+
}); },
|
|
2177
|
+
'and': function (l, r, ctx) { var _a, _b, _c; return __generator(this, function (_d) {
|
|
2178
|
+
switch (_d.label) {
|
|
2179
|
+
case 0:
|
|
2180
|
+
_b = isTruthy;
|
|
2181
|
+
return [4 /*yield*/, toValue(l)];
|
|
2182
|
+
case 1:
|
|
2183
|
+
_a = _b.apply(void 0, [_d.sent(), ctx]);
|
|
2184
|
+
if (!_a) return [3 /*break*/, 3];
|
|
2185
|
+
_c = isTruthy;
|
|
2186
|
+
return [4 /*yield*/, toValue(r)];
|
|
2187
|
+
case 2:
|
|
2188
|
+
_a = _c.apply(void 0, [_d.sent(), ctx]);
|
|
2189
|
+
_d.label = 3;
|
|
2190
|
+
case 3: return [2 /*return*/, _a];
|
|
2191
|
+
}
|
|
2192
|
+
}); },
|
|
2193
|
+
'or': function (l, r, ctx) { var _a, _b, _c; return __generator(this, function (_d) {
|
|
2194
|
+
switch (_d.label) {
|
|
2195
|
+
case 0:
|
|
2196
|
+
_b = isTruthy;
|
|
2197
|
+
return [4 /*yield*/, toValue(l)];
|
|
2198
|
+
case 1:
|
|
2199
|
+
_a = _b.apply(void 0, [_d.sent(), ctx]);
|
|
2200
|
+
if (_a) return [3 /*break*/, 3];
|
|
2201
|
+
_c = isTruthy;
|
|
2202
|
+
return [4 /*yield*/, toValue(r)];
|
|
2203
|
+
case 2:
|
|
2204
|
+
_a = _c.apply(void 0, [_d.sent(), ctx]);
|
|
2205
|
+
_d.label = 3;
|
|
2206
|
+
case 3: return [2 /*return*/, _a];
|
|
2207
|
+
}
|
|
2208
|
+
}); }
|
|
1853
2209
|
};
|
|
1854
2210
|
function equals(lhs, rhs) {
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
2211
|
+
var _a;
|
|
2212
|
+
return __generator(this, function (_b) {
|
|
2213
|
+
switch (_b.label) {
|
|
2214
|
+
case 0:
|
|
2215
|
+
if (!isComparable(lhs)) return [3 /*break*/, 2];
|
|
2216
|
+
return [4 /*yield*/, lhs.equals(rhs)];
|
|
2217
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
2218
|
+
case 2:
|
|
2219
|
+
if (!isComparable(rhs)) return [3 /*break*/, 4];
|
|
2220
|
+
return [4 /*yield*/, rhs.equals(lhs)];
|
|
2221
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
2222
|
+
case 4: return [4 /*yield*/, toValue(lhs)];
|
|
2223
|
+
case 5:
|
|
2224
|
+
lhs = _b.sent();
|
|
2225
|
+
return [4 /*yield*/, toValue(rhs)];
|
|
2226
|
+
case 6:
|
|
2227
|
+
rhs = _b.sent();
|
|
2228
|
+
if (!isArray(lhs)) return [3 /*break*/, 9];
|
|
2229
|
+
_a = isArray(rhs);
|
|
2230
|
+
if (!_a) return [3 /*break*/, 8];
|
|
2231
|
+
return [4 /*yield*/, arrayEquals(lhs, rhs)];
|
|
2232
|
+
case 7:
|
|
2233
|
+
_a = (_b.sent());
|
|
2234
|
+
_b.label = 8;
|
|
2235
|
+
case 8: return [2 /*return*/, _a];
|
|
2236
|
+
case 9: return [2 /*return*/, lhs === rhs];
|
|
2237
|
+
}
|
|
2238
|
+
});
|
|
1865
2239
|
}
|
|
1866
2240
|
function arrayEquals(lhs, rhs) {
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
2241
|
+
var i;
|
|
2242
|
+
return __generator(this, function (_a) {
|
|
2243
|
+
switch (_a.label) {
|
|
2244
|
+
case 0:
|
|
2245
|
+
if (lhs.length !== rhs.length)
|
|
2246
|
+
return [2 /*return*/, false];
|
|
2247
|
+
i = 0;
|
|
2248
|
+
_a.label = 1;
|
|
2249
|
+
case 1:
|
|
2250
|
+
if (!(i < lhs.length)) return [3 /*break*/, 4];
|
|
2251
|
+
return [4 /*yield*/, equals(lhs[i], rhs[i])];
|
|
2252
|
+
case 2:
|
|
2253
|
+
if (!(_a.sent()))
|
|
2254
|
+
return [2 /*return*/, false];
|
|
2255
|
+
_a.label = 3;
|
|
2256
|
+
case 3:
|
|
2257
|
+
i++;
|
|
2258
|
+
return [3 /*break*/, 1];
|
|
2259
|
+
case 4: return [2 /*return*/, true];
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
1870
2262
|
}
|
|
1871
2263
|
function arrayIncludes(arr, item) {
|
|
1872
|
-
|
|
2264
|
+
var arr_1, arr_1_1, value, e_1_1;
|
|
2265
|
+
var e_1, _a;
|
|
2266
|
+
return __generator(this, function (_b) {
|
|
2267
|
+
switch (_b.label) {
|
|
2268
|
+
case 0:
|
|
2269
|
+
_b.trys.push([0, 5, 6, 7]);
|
|
2270
|
+
arr_1 = __values(arr), arr_1_1 = arr_1.next();
|
|
2271
|
+
_b.label = 1;
|
|
2272
|
+
case 1:
|
|
2273
|
+
if (!!arr_1_1.done) return [3 /*break*/, 4];
|
|
2274
|
+
value = arr_1_1.value;
|
|
2275
|
+
return [4 /*yield*/, equals(value, item)];
|
|
2276
|
+
case 2:
|
|
2277
|
+
if (_b.sent())
|
|
2278
|
+
return [2 /*return*/, true];
|
|
2279
|
+
_b.label = 3;
|
|
2280
|
+
case 3:
|
|
2281
|
+
arr_1_1 = arr_1.next();
|
|
2282
|
+
return [3 /*break*/, 1];
|
|
2283
|
+
case 4: return [3 /*break*/, 7];
|
|
2284
|
+
case 5:
|
|
2285
|
+
e_1_1 = _b.sent();
|
|
2286
|
+
e_1 = { error: e_1_1 };
|
|
2287
|
+
return [3 /*break*/, 7];
|
|
2288
|
+
case 6:
|
|
2289
|
+
try {
|
|
2290
|
+
if (arr_1_1 && !arr_1_1.done && (_a = arr_1.return)) _a.call(arr_1);
|
|
2291
|
+
}
|
|
2292
|
+
finally { if (e_1) throw e_1.error; }
|
|
2293
|
+
return [7 /*endfinally*/];
|
|
2294
|
+
case 7: return [2 /*return*/, false];
|
|
2295
|
+
}
|
|
2296
|
+
});
|
|
1873
2297
|
}
|
|
1874
2298
|
|
|
1875
2299
|
var Node = /** @class */ (function () {
|
|
@@ -2012,6 +2436,20 @@
|
|
|
2012
2436
|
sep: sep
|
|
2013
2437
|
});
|
|
2014
2438
|
|
|
2439
|
+
function chargeJsonReplacerValue(memoryLimit, val) {
|
|
2440
|
+
if (typeof val === 'string') {
|
|
2441
|
+
memoryLimit.use(val.length);
|
|
2442
|
+
}
|
|
2443
|
+
else if (val === null || typeof val === 'number' || typeof val === 'boolean') {
|
|
2444
|
+
memoryLimit.use(JSON.stringify(val).length);
|
|
2445
|
+
}
|
|
2446
|
+
else if (Array.isArray(val)) {
|
|
2447
|
+
memoryLimit.use(val.length + 1);
|
|
2448
|
+
}
|
|
2449
|
+
else if (typeof val === 'object') {
|
|
2450
|
+
memoryLimit.use(2);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2015
2453
|
function defaultFilter(value, defaultValue) {
|
|
2016
2454
|
var args = [];
|
|
2017
2455
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
@@ -2026,20 +2464,30 @@
|
|
|
2026
2464
|
}
|
|
2027
2465
|
function json(value, space) {
|
|
2028
2466
|
if (space === void 0) { space = 0; }
|
|
2029
|
-
|
|
2467
|
+
var memoryLimit = this.context.memoryLimit;
|
|
2468
|
+
return JSON.stringify(value, function (_key, val) {
|
|
2469
|
+
chargeJsonReplacerValue(memoryLimit, val);
|
|
2470
|
+
return val;
|
|
2471
|
+
}, space);
|
|
2030
2472
|
}
|
|
2031
2473
|
function inspect(value, space) {
|
|
2032
2474
|
if (space === void 0) { space = 0; }
|
|
2475
|
+
var memoryLimit = this.context.memoryLimit;
|
|
2033
2476
|
var ancestors = [];
|
|
2034
2477
|
return JSON.stringify(value, function (_key, value) {
|
|
2035
|
-
if (typeof value !== 'object' || value === null)
|
|
2478
|
+
if (typeof value !== 'object' || value === null) {
|
|
2479
|
+
chargeJsonReplacerValue(memoryLimit, value);
|
|
2036
2480
|
return value;
|
|
2481
|
+
}
|
|
2037
2482
|
// `this` is the object that value is contained in, i.e., its direct parent.
|
|
2038
2483
|
while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
|
|
2039
2484
|
ancestors.pop();
|
|
2040
|
-
if (ancestors.includes(value))
|
|
2485
|
+
if (ancestors.includes(value)) {
|
|
2486
|
+
memoryLimit.use('[Circular]'.length);
|
|
2041
2487
|
return '[Circular]';
|
|
2488
|
+
}
|
|
2042
2489
|
ancestors.push(value);
|
|
2490
|
+
chargeJsonReplacerValue(memoryLimit, value);
|
|
2043
2491
|
return value;
|
|
2044
2492
|
}, space);
|
|
2045
2493
|
}
|
|
@@ -2094,10 +2542,44 @@
|
|
|
2094
2542
|
this.context.memoryLimit.use(str.length);
|
|
2095
2543
|
return str.replace(/\r?\n/gm, '<br />\n');
|
|
2096
2544
|
}
|
|
2545
|
+
// Raw-text blocks (HTML5) plus '<...>' as the catch-all kind; a regex
|
|
2546
|
+
// equivalent is O(n^2) in V8 on unclosed openers.
|
|
2097
2547
|
function strip_html(v) {
|
|
2548
|
+
var e_1, _a;
|
|
2098
2549
|
var str = stringify(v);
|
|
2099
2550
|
this.context.memoryLimit.use(str.length);
|
|
2100
|
-
|
|
2551
|
+
var blocks = new Map([['<script', '</script>'], ['<style', '</style>'], ['<!--', '-->'], ['<', '>']]);
|
|
2552
|
+
var out = '';
|
|
2553
|
+
var i = 0;
|
|
2554
|
+
while (i < str.length) {
|
|
2555
|
+
var lt = str.indexOf('<', i);
|
|
2556
|
+
if (lt < 0)
|
|
2557
|
+
return out + str.slice(i);
|
|
2558
|
+
out += str.slice(i, lt);
|
|
2559
|
+
try {
|
|
2560
|
+
for (var blocks_1 = (e_1 = void 0, __values(blocks)), blocks_1_1 = blocks_1.next(); !blocks_1_1.done; blocks_1_1 = blocks_1.next()) {
|
|
2561
|
+
var _b = __read(blocks_1_1.value, 2), opener_1 = _b[0], closer = _b[1];
|
|
2562
|
+
if (!str.startsWith(opener_1, lt))
|
|
2563
|
+
continue;
|
|
2564
|
+
var e = str.indexOf(closer, lt + opener_1.length);
|
|
2565
|
+
if (e >= 0) {
|
|
2566
|
+
i = e + closer.length;
|
|
2567
|
+
break;
|
|
2568
|
+
}
|
|
2569
|
+
blocks.delete(opener_1);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2573
|
+
finally {
|
|
2574
|
+
try {
|
|
2575
|
+
if (blocks_1_1 && !blocks_1_1.done && (_a = blocks_1.return)) _a.call(blocks_1);
|
|
2576
|
+
}
|
|
2577
|
+
finally { if (e_1) throw e_1.error; }
|
|
2578
|
+
}
|
|
2579
|
+
if (i <= lt)
|
|
2580
|
+
return out + str.slice(lt);
|
|
2581
|
+
}
|
|
2582
|
+
return out;
|
|
2101
2583
|
}
|
|
2102
2584
|
|
|
2103
2585
|
var htmlFilters = /*#__PURE__*/Object.freeze({
|
|
@@ -2204,6 +2686,7 @@
|
|
|
2204
2686
|
globals: {},
|
|
2205
2687
|
keepOutputType: false,
|
|
2206
2688
|
operators: defaultOperators,
|
|
2689
|
+
groupedExpressions: false,
|
|
2207
2690
|
memoryLimit: Infinity,
|
|
2208
2691
|
parseLimit: Infinity,
|
|
2209
2692
|
renderLimit: Infinity
|
|
@@ -2300,8 +2783,9 @@
|
|
|
2300
2783
|
}
|
|
2301
2784
|
|
|
2302
2785
|
var Tokenizer = /** @class */ (function () {
|
|
2303
|
-
function Tokenizer(input, operators, file, range) {
|
|
2786
|
+
function Tokenizer(input, operators, file, range, groupedExpressions) {
|
|
2304
2787
|
if (operators === void 0) { operators = defaultOptions.operators; }
|
|
2788
|
+
if (groupedExpressions === void 0) { groupedExpressions = false; }
|
|
2305
2789
|
this.input = input;
|
|
2306
2790
|
this.file = file;
|
|
2307
2791
|
this.rawBeginAt = -1;
|
|
@@ -2309,6 +2793,7 @@
|
|
|
2309
2793
|
this.N = range ? range[1] : input.length;
|
|
2310
2794
|
this.opTrie = createTrie(operators);
|
|
2311
2795
|
this.literalTrie = createTrie(literalValues);
|
|
2796
|
+
this.groupedExpressions = groupedExpressions;
|
|
2312
2797
|
}
|
|
2313
2798
|
Tokenizer.prototype.readExpression = function () {
|
|
2314
2799
|
return new Expression(this.readExpressionTokens());
|
|
@@ -2380,6 +2865,8 @@
|
|
|
2380
2865
|
this.skipBlank();
|
|
2381
2866
|
if (this.end())
|
|
2382
2867
|
return null;
|
|
2868
|
+
if (this.peek() === ')' || this.peek() === ',')
|
|
2869
|
+
return null;
|
|
2383
2870
|
this.assert(this.read() === '|', "expected \"|\" before filter");
|
|
2384
2871
|
var name = this.readIdentifier();
|
|
2385
2872
|
if (!name.size()) {
|
|
@@ -2394,10 +2881,10 @@
|
|
|
2394
2881
|
var arg = this.readFilterArg();
|
|
2395
2882
|
arg && args.push(arg);
|
|
2396
2883
|
this.skipBlank();
|
|
2397
|
-
this.assert(this.end() || this.peek() === ',' || this.peek() === '|', function () { return "unexpected character ".concat(_this.snapshot()); });
|
|
2884
|
+
this.assert(this.end() || this.peek() === ',' || this.peek() === '|' || this.peek() === ')', function () { return "unexpected character ".concat(_this.snapshot()); });
|
|
2398
2885
|
} while (this.peek() === ',');
|
|
2399
2886
|
}
|
|
2400
|
-
else if (this.peek() === '|' || this.end()) ;
|
|
2887
|
+
else if (this.peek() === '|' || this.peek() === ')' || this.peek() === ',' || this.end()) ;
|
|
2401
2888
|
else {
|
|
2402
2889
|
throw this.error('expected ":" after filter name');
|
|
2403
2890
|
}
|
|
@@ -2611,7 +3098,10 @@
|
|
|
2611
3098
|
Tokenizer.prototype.readValue = function () {
|
|
2612
3099
|
this.skipBlank();
|
|
2613
3100
|
var begin = this.p;
|
|
2614
|
-
var variable = this.readLiteral() || this.readQuoted() || this.
|
|
3101
|
+
var variable = this.readLiteral() || this.readQuoted() || this.readNumber();
|
|
3102
|
+
if (!variable && this.peek() === '(') {
|
|
3103
|
+
variable = this.readGroupOrRange();
|
|
3104
|
+
}
|
|
2615
3105
|
var props = this.readProperties(!variable);
|
|
2616
3106
|
if (!props.length)
|
|
2617
3107
|
return variable;
|
|
@@ -2691,17 +3181,31 @@
|
|
|
2691
3181
|
this.p = end;
|
|
2692
3182
|
return literal;
|
|
2693
3183
|
};
|
|
2694
|
-
Tokenizer.prototype.
|
|
3184
|
+
Tokenizer.prototype.readGroupOrRange = function () {
|
|
3185
|
+
var _this = this;
|
|
2695
3186
|
this.skipBlank();
|
|
2696
3187
|
var begin = this.p;
|
|
2697
3188
|
if (this.peek() !== '(')
|
|
2698
3189
|
return;
|
|
2699
3190
|
++this.p;
|
|
2700
3191
|
var lhs = this.readValueOrThrow();
|
|
2701
|
-
this.
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
3192
|
+
this.skipBlank();
|
|
3193
|
+
if (this.peek() === '.' && this.peek(1) === '.') {
|
|
3194
|
+
this.p += 2;
|
|
3195
|
+
var rhs = this.readValueOrThrow();
|
|
3196
|
+
this.skipBlank();
|
|
3197
|
+
this.assert(this.read() === ')', 'invalid range syntax');
|
|
3198
|
+
return new RangeToken(this.input, begin, this.p, lhs, rhs, this.file);
|
|
3199
|
+
}
|
|
3200
|
+
if (this.groupedExpressions) {
|
|
3201
|
+
var initial = new Expression(__spreadArray([lhs], __read(this.readExpressionTokens()), false));
|
|
3202
|
+
this.assert(initial.valid(), function () { return "invalid value expression: ".concat(_this.snapshot()); });
|
|
3203
|
+
var filters = this.readFilters();
|
|
3204
|
+
this.skipBlank();
|
|
3205
|
+
this.assert(this.read() === ')', 'unbalanced parentheses');
|
|
3206
|
+
return new FilteredValueToken(initial, filters, this.input, begin, this.p, this.file);
|
|
3207
|
+
}
|
|
3208
|
+
throw this.error('invalid range syntax');
|
|
2705
3209
|
};
|
|
2706
3210
|
Tokenizer.prototype.readValueOrThrow = function () {
|
|
2707
3211
|
var _this = this;
|
|
@@ -2733,7 +3237,7 @@
|
|
|
2733
3237
|
switch (_a.label) {
|
|
2734
3238
|
case 0:
|
|
2735
3239
|
outputDelimiterLeft = options.outputDelimiterLeft;
|
|
2736
|
-
htmlStopStrings = [',', ' ', outputDelimiterLeft];
|
|
3240
|
+
htmlStopStrings = [',', ' ', '\r', '\n', '\t', outputDelimiterLeft];
|
|
2737
3241
|
htmlStopStringSet = new Set(htmlStopStrings);
|
|
2738
3242
|
_a.label = 1;
|
|
2739
3243
|
case 1:
|
|
@@ -2935,71 +3439,6 @@
|
|
|
2935
3439
|
}(Tag));
|
|
2936
3440
|
}
|
|
2937
3441
|
|
|
2938
|
-
function isKeyValuePair(arr) {
|
|
2939
|
-
return isArray(arr);
|
|
2940
|
-
}
|
|
2941
|
-
|
|
2942
|
-
var Filter = /** @class */ (function () {
|
|
2943
|
-
function Filter(token, options, liquid) {
|
|
2944
|
-
this.token = token;
|
|
2945
|
-
this.name = token.name;
|
|
2946
|
-
this.handler = isFunction(options)
|
|
2947
|
-
? options
|
|
2948
|
-
: (isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify);
|
|
2949
|
-
this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
|
|
2950
|
-
this.args = token.args;
|
|
2951
|
-
this.liquid = liquid;
|
|
2952
|
-
}
|
|
2953
|
-
Filter.prototype.render = function (value, context) {
|
|
2954
|
-
var argv, _a, _b, arg, _c, _d, _e, _f, _g, e_1_1;
|
|
2955
|
-
var e_1, _h;
|
|
2956
|
-
return __generator(this, function (_j) {
|
|
2957
|
-
switch (_j.label) {
|
|
2958
|
-
case 0:
|
|
2959
|
-
argv = [];
|
|
2960
|
-
_j.label = 1;
|
|
2961
|
-
case 1:
|
|
2962
|
-
_j.trys.push([1, 8, 9, 10]);
|
|
2963
|
-
_a = __values(this.args), _b = _a.next();
|
|
2964
|
-
_j.label = 2;
|
|
2965
|
-
case 2:
|
|
2966
|
-
if (!!_b.done) return [3 /*break*/, 7];
|
|
2967
|
-
arg = _b.value;
|
|
2968
|
-
if (!isKeyValuePair(arg)) return [3 /*break*/, 4];
|
|
2969
|
-
_d = (_c = argv).push;
|
|
2970
|
-
_e = [arg[0]];
|
|
2971
|
-
return [4 /*yield*/, evalToken(arg[1], context)];
|
|
2972
|
-
case 3:
|
|
2973
|
-
_d.apply(_c, [_e.concat([_j.sent()])]);
|
|
2974
|
-
return [3 /*break*/, 6];
|
|
2975
|
-
case 4:
|
|
2976
|
-
_g = (_f = argv).push;
|
|
2977
|
-
return [4 /*yield*/, evalToken(arg, context)];
|
|
2978
|
-
case 5:
|
|
2979
|
-
_g.apply(_f, [_j.sent()]);
|
|
2980
|
-
_j.label = 6;
|
|
2981
|
-
case 6:
|
|
2982
|
-
_b = _a.next();
|
|
2983
|
-
return [3 /*break*/, 2];
|
|
2984
|
-
case 7: return [3 /*break*/, 10];
|
|
2985
|
-
case 8:
|
|
2986
|
-
e_1_1 = _j.sent();
|
|
2987
|
-
e_1 = { error: e_1_1 };
|
|
2988
|
-
return [3 /*break*/, 10];
|
|
2989
|
-
case 9:
|
|
2990
|
-
try {
|
|
2991
|
-
if (_b && !_b.done && (_h = _a.return)) _h.call(_a);
|
|
2992
|
-
}
|
|
2993
|
-
finally { if (e_1) throw e_1.error; }
|
|
2994
|
-
return [7 /*endfinally*/];
|
|
2995
|
-
case 10: return [4 /*yield*/, this.handler.apply({ context: context, token: this.token, liquid: this.liquid }, __spreadArray([value], __read(argv), false))];
|
|
2996
|
-
case 11: return [2 /*return*/, _j.sent()];
|
|
2997
|
-
}
|
|
2998
|
-
});
|
|
2999
|
-
};
|
|
3000
|
-
return Filter;
|
|
3001
|
-
}());
|
|
3002
|
-
|
|
3003
3442
|
var Value = /** @class */ (function () {
|
|
3004
3443
|
/**
|
|
3005
3444
|
* @param str the value to be valuated, eg.: "foobar" | truncate: 3
|
|
@@ -3008,7 +3447,7 @@
|
|
|
3008
3447
|
var _this = this;
|
|
3009
3448
|
this.filters = [];
|
|
3010
3449
|
var token = typeof input === 'string'
|
|
3011
|
-
? new Tokenizer(input, liquid.options.operators).readFilteredValue()
|
|
3450
|
+
? new Tokenizer(input, liquid.options.operators, undefined, undefined, liquid.options.groupedExpressions).readFilteredValue()
|
|
3012
3451
|
: input;
|
|
3013
3452
|
this.initial = token.initial;
|
|
3014
3453
|
this.filters = token.filters.map(function (token) { return new Filter(token, _this.getFilter(liquid, token.name), liquid); });
|
|
@@ -3067,7 +3506,7 @@
|
|
|
3067
3506
|
var _this = this;
|
|
3068
3507
|
var _a;
|
|
3069
3508
|
_this = _super.call(this, token) || this;
|
|
3070
|
-
var tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange);
|
|
3509
|
+
var tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange, liquid.options.groupedExpressions);
|
|
3071
3510
|
_this.value = new Value(tokenizer.readFilteredValue(), liquid);
|
|
3072
3511
|
var filters = _this.value.filters;
|
|
3073
3512
|
var outputEscape = liquid.options.outputEscape;
|
|
@@ -3078,12 +3517,15 @@
|
|
|
3078
3517
|
return _this;
|
|
3079
3518
|
}
|
|
3080
3519
|
Output.prototype.render = function (ctx, emitter) {
|
|
3081
|
-
var val;
|
|
3082
|
-
return __generator(this, function (
|
|
3083
|
-
switch (
|
|
3084
|
-
case 0:
|
|
3085
|
-
|
|
3086
|
-
|
|
3520
|
+
var val, _a;
|
|
3521
|
+
return __generator(this, function (_b) {
|
|
3522
|
+
switch (_b.label) {
|
|
3523
|
+
case 0:
|
|
3524
|
+
_a = toValue;
|
|
3525
|
+
return [4 /*yield*/, this.value.value(ctx, false)];
|
|
3526
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, [_b.sent()])];
|
|
3527
|
+
case 2:
|
|
3528
|
+
val = _b.sent();
|
|
3087
3529
|
emitter.write(val);
|
|
3088
3530
|
return [2 /*return*/];
|
|
3089
3531
|
}
|
|
@@ -3688,60 +4130,159 @@
|
|
|
3688
4130
|
return [5 /*yield**/, __values(extractValueTokenVariables(token.rhs))];
|
|
3689
4131
|
case 2:
|
|
3690
4132
|
_a.sent();
|
|
3691
|
-
return [3 /*break*/,
|
|
4133
|
+
return [3 /*break*/, 7];
|
|
3692
4134
|
case 3:
|
|
3693
|
-
if (!
|
|
3694
|
-
return [
|
|
4135
|
+
if (!isFilteredValueToken(token)) return [3 /*break*/, 5];
|
|
4136
|
+
return [5 /*yield**/, __values(extractGroupedExpressionTokenVariables(token))];
|
|
3695
4137
|
case 4:
|
|
3696
4138
|
_a.sent();
|
|
3697
|
-
|
|
3698
|
-
case 5:
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
// token is not guaranteed to have `file` set. We'll try to get it from a prop if not.
|
|
3706
|
-
var file = token.file;
|
|
3707
|
-
// Here we're flattening the first segment of a path if it is a nested path.
|
|
3708
|
-
var root = token.props[0];
|
|
3709
|
-
file = file || root.file;
|
|
3710
|
-
if (isQuotedToken(root) || isNumberToken(root) || isWordToken(root)) {
|
|
3711
|
-
segments.push(root.content);
|
|
3712
|
-
}
|
|
3713
|
-
else if (isPropertyAccessToken(root)) {
|
|
3714
|
-
// Flatten paths that start with a nested path.
|
|
3715
|
-
segments.push.apply(segments, __spreadArray([], __read(extractPropertyAccessVariable(root).segments), false));
|
|
3716
|
-
}
|
|
3717
|
-
try {
|
|
3718
|
-
for (var _b = __values(token.props.slice(1)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3719
|
-
var prop = _c.value;
|
|
3720
|
-
file = file || prop.file;
|
|
3721
|
-
if (isQuotedToken(prop) || isNumberToken(prop) || isWordToken(prop)) {
|
|
3722
|
-
segments.push(prop.content);
|
|
3723
|
-
}
|
|
3724
|
-
else if (isPropertyAccessToken(prop)) {
|
|
3725
|
-
segments.push(extractPropertyAccessVariable(prop));
|
|
3726
|
-
}
|
|
3727
|
-
}
|
|
3728
|
-
}
|
|
3729
|
-
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
3730
|
-
finally {
|
|
3731
|
-
try {
|
|
3732
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
4139
|
+
return [3 /*break*/, 7];
|
|
4140
|
+
case 5:
|
|
4141
|
+
if (!isPropertyAccessToken(token)) return [3 /*break*/, 7];
|
|
4142
|
+
return [4 /*yield*/, extractPropertyAccessVariable(token)];
|
|
4143
|
+
case 6:
|
|
4144
|
+
_a.sent();
|
|
4145
|
+
_a.label = 7;
|
|
4146
|
+
case 7: return [2 /*return*/];
|
|
3733
4147
|
}
|
|
3734
|
-
finally { if (e_16) throw e_16.error; }
|
|
3735
|
-
}
|
|
3736
|
-
var _d = __read(token.getPosition(), 2), row = _d[0], col = _d[1];
|
|
3737
|
-
return new Variable(segments, {
|
|
3738
|
-
row: row,
|
|
3739
|
-
col: col,
|
|
3740
|
-
file: file
|
|
3741
4148
|
});
|
|
3742
4149
|
}
|
|
3743
|
-
|
|
3744
|
-
|
|
4150
|
+
function extractGroupedExpressionTokenVariables(token) {
|
|
4151
|
+
var _a, _b, t, e_16_1, _c, _d, filter, _e, _f, arg, e_17_1, e_18_1;
|
|
4152
|
+
var e_16, _g, e_18, _h, e_17, _j;
|
|
4153
|
+
return __generator(this, function (_k) {
|
|
4154
|
+
switch (_k.label) {
|
|
4155
|
+
case 0:
|
|
4156
|
+
if (!isFilteredValueToken(token))
|
|
4157
|
+
return [2 /*return*/];
|
|
4158
|
+
_k.label = 1;
|
|
4159
|
+
case 1:
|
|
4160
|
+
_k.trys.push([1, 6, 7, 8]);
|
|
4161
|
+
_a = __values(token.initial.postfix), _b = _a.next();
|
|
4162
|
+
_k.label = 2;
|
|
4163
|
+
case 2:
|
|
4164
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
4165
|
+
t = _b.value;
|
|
4166
|
+
if (!isValueToken(t)) return [3 /*break*/, 4];
|
|
4167
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(t))];
|
|
4168
|
+
case 3:
|
|
4169
|
+
_k.sent();
|
|
4170
|
+
_k.label = 4;
|
|
4171
|
+
case 4:
|
|
4172
|
+
_b = _a.next();
|
|
4173
|
+
return [3 /*break*/, 2];
|
|
4174
|
+
case 5: return [3 /*break*/, 8];
|
|
4175
|
+
case 6:
|
|
4176
|
+
e_16_1 = _k.sent();
|
|
4177
|
+
e_16 = { error: e_16_1 };
|
|
4178
|
+
return [3 /*break*/, 8];
|
|
4179
|
+
case 7:
|
|
4180
|
+
try {
|
|
4181
|
+
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
|
|
4182
|
+
}
|
|
4183
|
+
finally { if (e_16) throw e_16.error; }
|
|
4184
|
+
return [7 /*endfinally*/];
|
|
4185
|
+
case 8:
|
|
4186
|
+
_k.trys.push([8, 21, 22, 23]);
|
|
4187
|
+
_c = __values(token.filters), _d = _c.next();
|
|
4188
|
+
_k.label = 9;
|
|
4189
|
+
case 9:
|
|
4190
|
+
if (!!_d.done) return [3 /*break*/, 20];
|
|
4191
|
+
filter = _d.value;
|
|
4192
|
+
_k.label = 10;
|
|
4193
|
+
case 10:
|
|
4194
|
+
_k.trys.push([10, 17, 18, 19]);
|
|
4195
|
+
_e = (e_17 = void 0, __values(filter.args)), _f = _e.next();
|
|
4196
|
+
_k.label = 11;
|
|
4197
|
+
case 11:
|
|
4198
|
+
if (!!_f.done) return [3 /*break*/, 16];
|
|
4199
|
+
arg = _f.value;
|
|
4200
|
+
if (!(isKeyValuePair(arg) && arg[1])) return [3 /*break*/, 13];
|
|
4201
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(arg[1]))];
|
|
4202
|
+
case 12:
|
|
4203
|
+
_k.sent();
|
|
4204
|
+
return [3 /*break*/, 15];
|
|
4205
|
+
case 13:
|
|
4206
|
+
if (!isValueToken(arg)) return [3 /*break*/, 15];
|
|
4207
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(arg))];
|
|
4208
|
+
case 14:
|
|
4209
|
+
_k.sent();
|
|
4210
|
+
_k.label = 15;
|
|
4211
|
+
case 15:
|
|
4212
|
+
_f = _e.next();
|
|
4213
|
+
return [3 /*break*/, 11];
|
|
4214
|
+
case 16: return [3 /*break*/, 19];
|
|
4215
|
+
case 17:
|
|
4216
|
+
e_17_1 = _k.sent();
|
|
4217
|
+
e_17 = { error: e_17_1 };
|
|
4218
|
+
return [3 /*break*/, 19];
|
|
4219
|
+
case 18:
|
|
4220
|
+
try {
|
|
4221
|
+
if (_f && !_f.done && (_j = _e.return)) _j.call(_e);
|
|
4222
|
+
}
|
|
4223
|
+
finally { if (e_17) throw e_17.error; }
|
|
4224
|
+
return [7 /*endfinally*/];
|
|
4225
|
+
case 19:
|
|
4226
|
+
_d = _c.next();
|
|
4227
|
+
return [3 /*break*/, 9];
|
|
4228
|
+
case 20: return [3 /*break*/, 23];
|
|
4229
|
+
case 21:
|
|
4230
|
+
e_18_1 = _k.sent();
|
|
4231
|
+
e_18 = { error: e_18_1 };
|
|
4232
|
+
return [3 /*break*/, 23];
|
|
4233
|
+
case 22:
|
|
4234
|
+
try {
|
|
4235
|
+
if (_d && !_d.done && (_h = _c.return)) _h.call(_c);
|
|
4236
|
+
}
|
|
4237
|
+
finally { if (e_18) throw e_18.error; }
|
|
4238
|
+
return [7 /*endfinally*/];
|
|
4239
|
+
case 23: return [2 /*return*/];
|
|
4240
|
+
}
|
|
4241
|
+
});
|
|
4242
|
+
}
|
|
4243
|
+
function extractPropertyAccessVariable(token) {
|
|
4244
|
+
var e_19, _a;
|
|
4245
|
+
var segments = [];
|
|
4246
|
+
// token is not guaranteed to have `file` set. We'll try to get it from a prop if not.
|
|
4247
|
+
var file = token.file;
|
|
4248
|
+
// Here we're flattening the first segment of a path if it is a nested path.
|
|
4249
|
+
var root = token.props[0];
|
|
4250
|
+
file = file || root.file;
|
|
4251
|
+
if (isQuotedToken(root) || isNumberToken(root) || isWordToken(root)) {
|
|
4252
|
+
segments.push(root.content);
|
|
4253
|
+
}
|
|
4254
|
+
else if (isPropertyAccessToken(root)) {
|
|
4255
|
+
// Flatten paths that start with a nested path.
|
|
4256
|
+
segments.push.apply(segments, __spreadArray([], __read(extractPropertyAccessVariable(root).segments), false));
|
|
4257
|
+
}
|
|
4258
|
+
try {
|
|
4259
|
+
for (var _b = __values(token.props.slice(1)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
4260
|
+
var prop = _c.value;
|
|
4261
|
+
file = file || prop.file;
|
|
4262
|
+
if (isQuotedToken(prop) || isNumberToken(prop) || isWordToken(prop)) {
|
|
4263
|
+
segments.push(prop.content);
|
|
4264
|
+
}
|
|
4265
|
+
else if (isPropertyAccessToken(prop)) {
|
|
4266
|
+
segments.push(extractPropertyAccessVariable(prop));
|
|
4267
|
+
}
|
|
4268
|
+
}
|
|
4269
|
+
}
|
|
4270
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
4271
|
+
finally {
|
|
4272
|
+
try {
|
|
4273
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
4274
|
+
}
|
|
4275
|
+
finally { if (e_19) throw e_19.error; }
|
|
4276
|
+
}
|
|
4277
|
+
var _d = __read(token.getPosition(), 2), row = _d[0], col = _d[1];
|
|
4278
|
+
return new Variable(segments, {
|
|
4279
|
+
row: row,
|
|
4280
|
+
col: col,
|
|
4281
|
+
file: file
|
|
4282
|
+
});
|
|
4283
|
+
}
|
|
4284
|
+
// This is used to detect segments that can be represented with dot notation
|
|
4285
|
+
// when creating a string representation of VariableSegments.
|
|
3745
4286
|
var RE_PROPERTY = /^[\u0080-\uFFFFa-zA-Z_][\u0080-\uFFFFa-zA-Z0-9_-]*$/;
|
|
3746
4287
|
/**
|
|
3747
4288
|
* Return a string representation of segments using dot notation where possible.
|
|
@@ -3749,7 +4290,7 @@
|
|
|
3749
4290
|
* @param bracketedRoot - If false (the default), don't surround the root segment with square brackets.
|
|
3750
4291
|
*/
|
|
3751
4292
|
function segmentsString(segments, bracketedRoot) {
|
|
3752
|
-
var
|
|
4293
|
+
var e_20, _a;
|
|
3753
4294
|
if (bracketedRoot === void 0) { bracketedRoot = false; }
|
|
3754
4295
|
var buf = [];
|
|
3755
4296
|
var root = segments[0];
|
|
@@ -3780,66 +4321,77 @@
|
|
|
3780
4321
|
}
|
|
3781
4322
|
}
|
|
3782
4323
|
}
|
|
3783
|
-
catch (
|
|
4324
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
3784
4325
|
finally {
|
|
3785
4326
|
try {
|
|
3786
4327
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3787
4328
|
}
|
|
3788
|
-
finally { if (
|
|
4329
|
+
finally { if (e_20) throw e_20.error; }
|
|
3789
4330
|
}
|
|
3790
4331
|
return buf.join('');
|
|
3791
4332
|
}
|
|
3792
4333
|
|
|
3793
|
-
var LookupType;
|
|
3794
4334
|
(function (LookupType) {
|
|
3795
4335
|
LookupType["Partials"] = "partials";
|
|
3796
4336
|
LookupType["Layouts"] = "layouts";
|
|
3797
4337
|
LookupType["Root"] = "root";
|
|
3798
|
-
})(LookupType || (LookupType = {}));
|
|
4338
|
+
})(exports.LookupType || (exports.LookupType = {}));
|
|
3799
4339
|
var Loader = /** @class */ (function () {
|
|
3800
4340
|
function Loader(options) {
|
|
4341
|
+
var _this = this;
|
|
4342
|
+
var _a, _b, _c, _d;
|
|
3801
4343
|
this.options = options;
|
|
3802
4344
|
if (options.relativeReference) {
|
|
3803
4345
|
var sep = options.fs.sep;
|
|
3804
4346
|
assert(sep, '`fs.sep` is required for relative reference');
|
|
3805
|
-
var
|
|
3806
|
-
this.shouldLoadRelative = function (referencedFile) { return
|
|
4347
|
+
var prefixes_1 = ['.' + sep, '..' + sep, './', '../'];
|
|
4348
|
+
this.shouldLoadRelative = function (referencedFile) { return prefixes_1.some(function (prefix) { return referencedFile.startsWith(prefix); }); };
|
|
3807
4349
|
}
|
|
3808
4350
|
else {
|
|
3809
4351
|
this.shouldLoadRelative = function (_referencedFile) { return false; };
|
|
3810
4352
|
}
|
|
3811
|
-
|
|
4353
|
+
var fs = options.fs;
|
|
4354
|
+
this.contains = toLiquidAsync(((_a = fs.contains) === null || _a === void 0 ? void 0 : _a.bind(fs)) || (function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
4355
|
+
return [2 /*return*/, true];
|
|
4356
|
+
}); }); }), ((_b = fs.containsSync) === null || _b === void 0 ? void 0 : _b.bind(fs)) || (function () { return true; }));
|
|
4357
|
+
this.exists = toLiquidAsync(((_c = fs.exists) === null || _c === void 0 ? void 0 : _c.bind(fs)) || (function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
4358
|
+
return [2 /*return*/, false];
|
|
4359
|
+
}); }); }), (_d = fs.existsSync) === null || _d === void 0 ? void 0 : _d.bind(fs));
|
|
3812
4360
|
}
|
|
3813
4361
|
Loader.prototype.lookup = function (file, type, sync, currentFile) {
|
|
3814
|
-
var
|
|
3815
|
-
var e_1, _d;
|
|
4362
|
+
var dirs, _a, _b, filepath, allowed, dirs_1, dirs_1_1, dir, e_1_1, e_2_1;
|
|
4363
|
+
var e_2, _c, e_1, _d;
|
|
3816
4364
|
return __generator(this, function (_e) {
|
|
3817
4365
|
switch (_e.label) {
|
|
3818
4366
|
case 0:
|
|
3819
|
-
fs = this.options.fs;
|
|
3820
4367
|
dirs = this.options[type];
|
|
3821
4368
|
_e.label = 1;
|
|
3822
4369
|
case 1:
|
|
3823
|
-
_e.trys.push([1,
|
|
3824
|
-
_a = __values(this.candidates(file, dirs, currentFile
|
|
4370
|
+
_e.trys.push([1, 14, 15, 16]);
|
|
4371
|
+
_a = __values(this.candidates(file, dirs, currentFile)), _b = _a.next();
|
|
3825
4372
|
_e.label = 2;
|
|
3826
4373
|
case 2:
|
|
3827
|
-
if (!!_b.done) return [3 /*break*/,
|
|
4374
|
+
if (!!_b.done) return [3 /*break*/, 13];
|
|
3828
4375
|
filepath = _b.value;
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
4376
|
+
allowed = false;
|
|
4377
|
+
_e.label = 3;
|
|
4378
|
+
case 3:
|
|
4379
|
+
_e.trys.push([3, 8, 9, 10]);
|
|
4380
|
+
dirs_1 = (e_1 = void 0, __values(dirs)), dirs_1_1 = dirs_1.next();
|
|
4381
|
+
_e.label = 4;
|
|
3833
4382
|
case 4:
|
|
3834
|
-
|
|
3835
|
-
|
|
4383
|
+
if (!!dirs_1_1.done) return [3 /*break*/, 7];
|
|
4384
|
+
dir = dirs_1_1.value;
|
|
4385
|
+
return [4 /*yield*/, this.contains(!!sync, dir, filepath)];
|
|
3836
4386
|
case 5:
|
|
3837
|
-
if (
|
|
3838
|
-
|
|
4387
|
+
if (_e.sent()) {
|
|
4388
|
+
allowed = true;
|
|
4389
|
+
return [3 /*break*/, 7];
|
|
4390
|
+
}
|
|
3839
4391
|
_e.label = 6;
|
|
3840
4392
|
case 6:
|
|
3841
|
-
|
|
3842
|
-
return [3 /*break*/,
|
|
4393
|
+
dirs_1_1 = dirs_1.next();
|
|
4394
|
+
return [3 /*break*/, 4];
|
|
3843
4395
|
case 7: return [3 /*break*/, 10];
|
|
3844
4396
|
case 8:
|
|
3845
4397
|
e_1_1 = _e.sent();
|
|
@@ -3847,88 +4399,84 @@
|
|
|
3847
4399
|
return [3 /*break*/, 10];
|
|
3848
4400
|
case 9:
|
|
3849
4401
|
try {
|
|
3850
|
-
if (
|
|
4402
|
+
if (dirs_1_1 && !dirs_1_1.done && (_d = dirs_1.return)) _d.call(dirs_1);
|
|
3851
4403
|
}
|
|
3852
4404
|
finally { if (e_1) throw e_1.error; }
|
|
3853
4405
|
return [7 /*endfinally*/];
|
|
3854
|
-
case 10:
|
|
4406
|
+
case 10:
|
|
4407
|
+
if (!allowed)
|
|
4408
|
+
return [3 /*break*/, 12];
|
|
4409
|
+
return [4 /*yield*/, this.exists(!!sync, filepath)];
|
|
4410
|
+
case 11:
|
|
4411
|
+
if (_e.sent())
|
|
4412
|
+
return [2 /*return*/, filepath];
|
|
4413
|
+
_e.label = 12;
|
|
4414
|
+
case 12:
|
|
4415
|
+
_b = _a.next();
|
|
4416
|
+
return [3 /*break*/, 2];
|
|
4417
|
+
case 13: return [3 /*break*/, 16];
|
|
4418
|
+
case 14:
|
|
4419
|
+
e_2_1 = _e.sent();
|
|
4420
|
+
e_2 = { error: e_2_1 };
|
|
4421
|
+
return [3 /*break*/, 16];
|
|
4422
|
+
case 15:
|
|
4423
|
+
try {
|
|
4424
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
4425
|
+
}
|
|
4426
|
+
finally { if (e_2) throw e_2.error; }
|
|
4427
|
+
return [7 /*endfinally*/];
|
|
4428
|
+
case 16: throw this.lookupError(file, dirs);
|
|
3855
4429
|
}
|
|
3856
4430
|
});
|
|
3857
4431
|
};
|
|
3858
|
-
Loader.prototype.candidates = function (file, dirs, currentFile
|
|
3859
|
-
var _a, fs, extname, referenced,
|
|
3860
|
-
var
|
|
3861
|
-
return __generator(this, function (
|
|
3862
|
-
switch (
|
|
4432
|
+
Loader.prototype.candidates = function (file, dirs, currentFile) {
|
|
4433
|
+
var _a, fs, extname, referenced, dirs_2, dirs_2_1, dir, referenced, e_3_1, filepath;
|
|
4434
|
+
var e_3, _b;
|
|
4435
|
+
return __generator(this, function (_c) {
|
|
4436
|
+
switch (_c.label) {
|
|
3863
4437
|
case 0:
|
|
3864
4438
|
_a = this.options, fs = _a.fs, extname = _a.extname;
|
|
3865
|
-
if (!(this.shouldLoadRelative(file) && currentFile)) return [3 /*break*/,
|
|
4439
|
+
if (!(this.shouldLoadRelative(file) && currentFile)) return [3 /*break*/, 2];
|
|
3866
4440
|
referenced = fs.resolve(this.dirname(currentFile), file, extname);
|
|
3867
|
-
|
|
4441
|
+
return [4 /*yield*/, referenced];
|
|
3868
4442
|
case 1:
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
_d.label = 2;
|
|
4443
|
+
_c.sent();
|
|
4444
|
+
_c.label = 2;
|
|
3872
4445
|
case 2:
|
|
3873
|
-
|
|
3874
|
-
dir = dirs_1_1.value;
|
|
3875
|
-
if (!(!enforceRoot || this.contains(dir, referenced))) return [3 /*break*/, 4];
|
|
3876
|
-
// the relatively referenced file is within one of root dirs
|
|
3877
|
-
return [4 /*yield*/, referenced];
|
|
3878
|
-
case 3:
|
|
3879
|
-
// the relatively referenced file is within one of root dirs
|
|
3880
|
-
_d.sent();
|
|
3881
|
-
return [3 /*break*/, 5];
|
|
3882
|
-
case 4:
|
|
3883
|
-
dirs_1_1 = dirs_1.next();
|
|
3884
|
-
return [3 /*break*/, 2];
|
|
3885
|
-
case 5: return [3 /*break*/, 8];
|
|
3886
|
-
case 6:
|
|
3887
|
-
e_2_1 = _d.sent();
|
|
3888
|
-
e_2 = { error: e_2_1 };
|
|
3889
|
-
return [3 /*break*/, 8];
|
|
3890
|
-
case 7:
|
|
3891
|
-
try {
|
|
3892
|
-
if (dirs_1_1 && !dirs_1_1.done && (_b = dirs_1.return)) _b.call(dirs_1);
|
|
3893
|
-
}
|
|
3894
|
-
finally { if (e_2) throw e_2.error; }
|
|
3895
|
-
return [7 /*endfinally*/];
|
|
3896
|
-
case 8:
|
|
3897
|
-
_d.trys.push([8, 13, 14, 15]);
|
|
4446
|
+
_c.trys.push([2, 7, 8, 9]);
|
|
3898
4447
|
dirs_2 = __values(dirs), dirs_2_1 = dirs_2.next();
|
|
3899
|
-
|
|
3900
|
-
case
|
|
3901
|
-
if (!!dirs_2_1.done) return [3 /*break*/,
|
|
4448
|
+
_c.label = 3;
|
|
4449
|
+
case 3:
|
|
4450
|
+
if (!!dirs_2_1.done) return [3 /*break*/, 6];
|
|
3902
4451
|
dir = dirs_2_1.value;
|
|
3903
4452
|
referenced = fs.resolve(dir, file, extname);
|
|
3904
|
-
if (!(!enforceRoot || this.contains(dir, referenced))) return [3 /*break*/, 11];
|
|
3905
4453
|
return [4 /*yield*/, referenced];
|
|
3906
|
-
case
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
case
|
|
4454
|
+
case 4:
|
|
4455
|
+
_c.sent();
|
|
4456
|
+
_c.label = 5;
|
|
4457
|
+
case 5:
|
|
3910
4458
|
dirs_2_1 = dirs_2.next();
|
|
3911
|
-
return [3 /*break*/,
|
|
3912
|
-
case
|
|
3913
|
-
case
|
|
3914
|
-
e_3_1 =
|
|
4459
|
+
return [3 /*break*/, 3];
|
|
4460
|
+
case 6: return [3 /*break*/, 9];
|
|
4461
|
+
case 7:
|
|
4462
|
+
e_3_1 = _c.sent();
|
|
3915
4463
|
e_3 = { error: e_3_1 };
|
|
3916
|
-
return [3 /*break*/,
|
|
3917
|
-
case
|
|
4464
|
+
return [3 /*break*/, 9];
|
|
4465
|
+
case 8:
|
|
3918
4466
|
try {
|
|
3919
|
-
if (dirs_2_1 && !dirs_2_1.done && (
|
|
4467
|
+
if (dirs_2_1 && !dirs_2_1.done && (_b = dirs_2.return)) _b.call(dirs_2);
|
|
3920
4468
|
}
|
|
3921
4469
|
finally { if (e_3) throw e_3.error; }
|
|
3922
4470
|
return [7 /*endfinally*/];
|
|
3923
|
-
case
|
|
3924
|
-
if (!(fs.fallback !== undefined)) return [3 /*break*/,
|
|
4471
|
+
case 9:
|
|
4472
|
+
if (!(fs.fallback !== undefined)) return [3 /*break*/, 11];
|
|
3925
4473
|
filepath = fs.fallback(file);
|
|
3926
|
-
if (!(filepath !== undefined)) return [3 /*break*/,
|
|
4474
|
+
if (!(filepath !== undefined)) return [3 /*break*/, 11];
|
|
3927
4475
|
return [4 /*yield*/, filepath];
|
|
3928
|
-
case
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
case
|
|
4476
|
+
case 10:
|
|
4477
|
+
_c.sent();
|
|
4478
|
+
_c.label = 11;
|
|
4479
|
+
case 11: return [2 /*return*/];
|
|
3932
4480
|
}
|
|
3933
4481
|
});
|
|
3934
4482
|
};
|
|
@@ -3948,17 +4496,22 @@
|
|
|
3948
4496
|
|
|
3949
4497
|
var Parser = /** @class */ (function () {
|
|
3950
4498
|
function Parser(liquid) {
|
|
4499
|
+
var _this = this;
|
|
4500
|
+
var _a, _b;
|
|
3951
4501
|
this.liquid = liquid;
|
|
3952
4502
|
this.cache = this.liquid.options.cache;
|
|
3953
4503
|
this.fs = this.liquid.options.fs;
|
|
3954
4504
|
this.parseFile = this.cache ? this._parseFileCached : this._parseFile;
|
|
3955
4505
|
this.loader = new Loader(this.liquid.options);
|
|
3956
4506
|
this.parseLimit = new Limiter('parse length', liquid.options.parseLimit);
|
|
4507
|
+
this.readFile = toLiquidAsync(((_a = this.fs.readFile) === null || _a === void 0 ? void 0 : _a.bind(this.fs)) || (function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
4508
|
+
throw new Error('readFile not implemented');
|
|
4509
|
+
}); }); }), (_b = this.fs.readFileSync) === null || _b === void 0 ? void 0 : _b.bind(this.fs));
|
|
3957
4510
|
}
|
|
3958
4511
|
Parser.prototype.parse = function (html, filepath) {
|
|
3959
4512
|
html = String(html);
|
|
3960
4513
|
this.parseLimit.use(html.length);
|
|
3961
|
-
var tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath);
|
|
4514
|
+
var tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath, undefined, this.liquid.options.groupedExpressions);
|
|
3962
4515
|
var tokens = tokenizer.readTopLevelTokens(this.liquid.options);
|
|
3963
4516
|
return this.parseTokens(tokens);
|
|
3964
4517
|
};
|
|
@@ -4005,7 +4558,7 @@
|
|
|
4005
4558
|
};
|
|
4006
4559
|
Parser.prototype._parseFileCached = function (file, sync, type, currentFile) {
|
|
4007
4560
|
var cache, key, tpls, task, taskOrTpl, _a, err_1;
|
|
4008
|
-
if (type === void 0) { type = LookupType.Root; }
|
|
4561
|
+
if (type === void 0) { type = exports.LookupType.Root; }
|
|
4009
4562
|
return __generator(this, function (_b) {
|
|
4010
4563
|
switch (_b.label) {
|
|
4011
4564
|
case 0:
|
|
@@ -4042,22 +4595,16 @@
|
|
|
4042
4595
|
});
|
|
4043
4596
|
};
|
|
4044
4597
|
Parser.prototype._parseFile = function (file, sync, type, currentFile) {
|
|
4045
|
-
var filepath, _a
|
|
4046
|
-
if (type === void 0) { type = LookupType.Root; }
|
|
4047
|
-
return __generator(this, function (
|
|
4048
|
-
switch (
|
|
4598
|
+
var filepath, _a;
|
|
4599
|
+
if (type === void 0) { type = exports.LookupType.Root; }
|
|
4600
|
+
return __generator(this, function (_b) {
|
|
4601
|
+
switch (_b.label) {
|
|
4049
4602
|
case 0: return [4 /*yield*/, this.loader.lookup(file, type, sync, currentFile)];
|
|
4050
4603
|
case 1:
|
|
4051
|
-
filepath =
|
|
4604
|
+
filepath = _b.sent();
|
|
4052
4605
|
_a = this.parse;
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
return [3 /*break*/, 4];
|
|
4056
|
-
case 2: return [4 /*yield*/, this.fs.readFile(filepath)];
|
|
4057
|
-
case 3:
|
|
4058
|
-
_b = _c.sent();
|
|
4059
|
-
_c.label = 4;
|
|
4060
|
-
case 4: return [2 /*return*/, _a.apply(this, [_b, filepath])];
|
|
4606
|
+
return [4 /*yield*/, this.readFile(!!sync, filepath)];
|
|
4607
|
+
case 2: return [2 /*return*/, _a.apply(this, [_b.sent(), filepath])];
|
|
4061
4608
|
}
|
|
4062
4609
|
});
|
|
4063
4610
|
};
|
|
@@ -4078,6 +4625,7 @@
|
|
|
4078
4625
|
TokenKind[TokenKind["Quoted"] = 1024] = "Quoted";
|
|
4079
4626
|
TokenKind[TokenKind["Operator"] = 2048] = "Operator";
|
|
4080
4627
|
TokenKind[TokenKind["FilteredValue"] = 4096] = "FilteredValue";
|
|
4628
|
+
TokenKind[TokenKind["GroupedExpression"] = 8192] = "GroupedExpression";
|
|
4081
4629
|
TokenKind[TokenKind["Delimited"] = 12] = "Delimited";
|
|
4082
4630
|
})(exports.TokenKind || (exports.TokenKind = {}));
|
|
4083
4631
|
|
|
@@ -4114,9 +4662,12 @@
|
|
|
4114
4662
|
function isRangeToken(val) {
|
|
4115
4663
|
return getKind(val) === exports.TokenKind.Range;
|
|
4116
4664
|
}
|
|
4665
|
+
function isFilteredValueToken(val) {
|
|
4666
|
+
return getKind(val) === exports.TokenKind.FilteredValue;
|
|
4667
|
+
}
|
|
4117
4668
|
function isValueToken(val) {
|
|
4118
|
-
// valueTokenBitMask = TokenKind.Number | TokenKind.Literal | TokenKind.Quoted | TokenKind.PropertyAccess | TokenKind.Range
|
|
4119
|
-
return (getKind(val) &
|
|
4669
|
+
// valueTokenBitMask = TokenKind.Number | TokenKind.Literal | TokenKind.Quoted | TokenKind.PropertyAccess | TokenKind.Range | TokenKind.FilteredValue
|
|
4670
|
+
return (getKind(val) & 5763) > 0;
|
|
4120
4671
|
}
|
|
4121
4672
|
function getKind(val) {
|
|
4122
4673
|
return val ? val.kind : -1;
|
|
@@ -4135,21 +4686,29 @@
|
|
|
4135
4686
|
isPropertyAccessToken: isPropertyAccessToken,
|
|
4136
4687
|
isWordToken: isWordToken,
|
|
4137
4688
|
isRangeToken: isRangeToken,
|
|
4689
|
+
isFilteredValueToken: isFilteredValueToken,
|
|
4138
4690
|
isValueToken: isValueToken
|
|
4139
4691
|
});
|
|
4140
4692
|
|
|
4693
|
+
function createScope(from) {
|
|
4694
|
+
var scope = Object.create(null);
|
|
4695
|
+
if (from)
|
|
4696
|
+
Object.assign(scope, from);
|
|
4697
|
+
return scope;
|
|
4698
|
+
}
|
|
4699
|
+
|
|
4141
4700
|
var Context = /** @class */ (function () {
|
|
4142
4701
|
function Context(env, opts, renderOptions, _a) {
|
|
4143
4702
|
if (env === void 0) { env = {}; }
|
|
4144
4703
|
if (opts === void 0) { opts = defaultOptions; }
|
|
4145
4704
|
if (renderOptions === void 0) { renderOptions = {}; }
|
|
4146
|
-
var _b = _a === void 0 ? {} : _a, memoryLimit = _b.memoryLimit, renderLimit = _b.renderLimit;
|
|
4705
|
+
var _b = _a === void 0 ? {} : _a, memoryLimit = _b.memoryLimit, renderLimit = _b.renderLimit, liquid = _b.liquid;
|
|
4147
4706
|
var _c, _d, _e, _f, _g;
|
|
4148
4707
|
/**
|
|
4149
4708
|
* insert a Context-level empty scope,
|
|
4150
4709
|
* for tags like `{% capture %}` `{% assign %}` to operate
|
|
4151
4710
|
*/
|
|
4152
|
-
this.scopes = [
|
|
4711
|
+
this.scopes = [createScope()];
|
|
4153
4712
|
this.registers = {};
|
|
4154
4713
|
this.breakCalled = false;
|
|
4155
4714
|
this.continueCalled = false;
|
|
@@ -4161,9 +4720,11 @@
|
|
|
4161
4720
|
this.ownPropertyOnly = (_e = renderOptions.ownPropertyOnly) !== null && _e !== void 0 ? _e : opts.ownPropertyOnly;
|
|
4162
4721
|
this.memoryLimit = memoryLimit !== null && memoryLimit !== void 0 ? memoryLimit : new Limiter('memory alloc', (_f = renderOptions.memoryLimit) !== null && _f !== void 0 ? _f : opts.memoryLimit);
|
|
4163
4722
|
this.renderLimit = renderLimit !== null && renderLimit !== void 0 ? renderLimit : new Limiter('template render', getPerformance().now() + ((_g = renderOptions.renderLimit) !== null && _g !== void 0 ? _g : opts.renderLimit));
|
|
4723
|
+
this.liquid = liquid;
|
|
4164
4724
|
}
|
|
4165
|
-
Context.prototype.getRegister = function (key) {
|
|
4166
|
-
|
|
4725
|
+
Context.prototype.getRegister = function (key, defaultValue) {
|
|
4726
|
+
if (defaultValue === void 0) { defaultValue = undefined; }
|
|
4727
|
+
return (this.registers[key] = this.registers[key] || defaultValue);
|
|
4167
4728
|
};
|
|
4168
4729
|
Context.prototype.setRegister = function (key, value) {
|
|
4169
4730
|
return (this.registers[key] = value);
|
|
@@ -4226,7 +4787,7 @@
|
|
|
4226
4787
|
_a.label = 1;
|
|
4227
4788
|
case 1:
|
|
4228
4789
|
if (!(i < paths.length)) return [3 /*break*/, 4];
|
|
4229
|
-
return [4 /*yield*/, readProperty(scope, paths[i]
|
|
4790
|
+
return [4 /*yield*/, this.readProperty(scope, paths[i])];
|
|
4230
4791
|
case 2:
|
|
4231
4792
|
scope = _a.sent();
|
|
4232
4793
|
if (strictVariables && isUndefined(scope)) {
|
|
@@ -4254,10 +4815,12 @@
|
|
|
4254
4815
|
return new Context(scope, this.opts, {
|
|
4255
4816
|
sync: this.sync,
|
|
4256
4817
|
globals: this.globals,
|
|
4257
|
-
strictVariables: this.strictVariables
|
|
4818
|
+
strictVariables: this.strictVariables,
|
|
4819
|
+
ownPropertyOnly: this.ownPropertyOnly
|
|
4258
4820
|
}, {
|
|
4259
4821
|
renderLimit: this.renderLimit,
|
|
4260
|
-
memoryLimit: this.memoryLimit
|
|
4822
|
+
memoryLimit: this.memoryLimit,
|
|
4823
|
+
liquid: this.liquid
|
|
4261
4824
|
});
|
|
4262
4825
|
};
|
|
4263
4826
|
Context.prototype.findScope = function (key) {
|
|
@@ -4270,42 +4833,42 @@
|
|
|
4270
4833
|
return this.environments;
|
|
4271
4834
|
return this.globals;
|
|
4272
4835
|
};
|
|
4836
|
+
Context.prototype.readProperty = function (obj, key) {
|
|
4837
|
+
obj = toLiquid(obj);
|
|
4838
|
+
key = toValue(key);
|
|
4839
|
+
if (isNil(obj))
|
|
4840
|
+
return obj;
|
|
4841
|
+
if (isArray(obj) && isNumber(key))
|
|
4842
|
+
return readArrayElement(obj, key, this.ownPropertyOnly);
|
|
4843
|
+
var value = readJSProperty(obj, key, this.ownPropertyOnly);
|
|
4844
|
+
if (value === undefined && obj instanceof Drop)
|
|
4845
|
+
return obj.liquidMethodMissing(key, this);
|
|
4846
|
+
if (isFunction(value))
|
|
4847
|
+
return value.call(obj);
|
|
4848
|
+
if (key === 'size')
|
|
4849
|
+
return readSize(obj);
|
|
4850
|
+
else if (key === 'first')
|
|
4851
|
+
return readFirst(obj, this.ownPropertyOnly);
|
|
4852
|
+
else if (key === 'last')
|
|
4853
|
+
return readLast(obj, this.ownPropertyOnly);
|
|
4854
|
+
return value;
|
|
4855
|
+
};
|
|
4273
4856
|
return Context;
|
|
4274
4857
|
}());
|
|
4275
|
-
function readProperty(obj, key, ownPropertyOnly) {
|
|
4276
|
-
obj = toLiquid(obj);
|
|
4277
|
-
key = toValue(key);
|
|
4278
|
-
if (isNil(obj))
|
|
4279
|
-
return obj;
|
|
4280
|
-
if (isArray(obj) && key < 0)
|
|
4281
|
-
return obj[obj.length + +key];
|
|
4282
|
-
var value = readJSProperty(obj, key, ownPropertyOnly);
|
|
4283
|
-
if (value === undefined && obj instanceof Drop)
|
|
4284
|
-
return obj.liquidMethodMissing(key);
|
|
4285
|
-
if (isFunction(value))
|
|
4286
|
-
return value.call(obj);
|
|
4287
|
-
if (key === 'size')
|
|
4288
|
-
return readSize(obj);
|
|
4289
|
-
else if (key === 'first')
|
|
4290
|
-
return readFirst(obj);
|
|
4291
|
-
else if (key === 'last')
|
|
4292
|
-
return readLast(obj);
|
|
4293
|
-
return value;
|
|
4294
|
-
}
|
|
4295
4858
|
function readJSProperty(obj, key, ownPropertyOnly) {
|
|
4296
4859
|
if (ownPropertyOnly && !hasOwnProperty.call(obj, key) && !(obj instanceof Drop))
|
|
4297
4860
|
return undefined;
|
|
4298
4861
|
return obj[key];
|
|
4299
4862
|
}
|
|
4300
|
-
function readFirst(obj) {
|
|
4863
|
+
function readFirst(obj, ownPropertyOnly) {
|
|
4301
4864
|
if (isArray(obj))
|
|
4302
|
-
return obj
|
|
4303
|
-
return obj
|
|
4865
|
+
return readArrayElement(obj, 0, ownPropertyOnly);
|
|
4866
|
+
return readJSProperty(obj, 'first', ownPropertyOnly);
|
|
4304
4867
|
}
|
|
4305
|
-
function readLast(obj) {
|
|
4868
|
+
function readLast(obj, ownPropertyOnly) {
|
|
4306
4869
|
if (isArray(obj))
|
|
4307
|
-
return obj
|
|
4308
|
-
return obj
|
|
4870
|
+
return readArrayElement(obj, -1, ownPropertyOnly);
|
|
4871
|
+
return readJSProperty(obj, 'last', ownPropertyOnly);
|
|
4309
4872
|
}
|
|
4310
4873
|
function readSize(obj) {
|
|
4311
4874
|
if (hasOwnProperty.call(obj, 'size') || obj['size'] !== undefined)
|
|
@@ -4324,29 +4887,32 @@
|
|
|
4324
4887
|
BlockMode[BlockMode["STORE"] = 1] = "STORE";
|
|
4325
4888
|
})(BlockMode || (BlockMode = {}));
|
|
4326
4889
|
|
|
4327
|
-
var abs =
|
|
4328
|
-
var at_least =
|
|
4329
|
-
var at_most =
|
|
4330
|
-
var ceil =
|
|
4331
|
-
var divided_by =
|
|
4890
|
+
var abs = argumentsToNumber(Math.abs);
|
|
4891
|
+
var at_least = argumentsToNumber(Math.max);
|
|
4892
|
+
var at_most = argumentsToNumber(Math.min);
|
|
4893
|
+
var ceil = argumentsToNumber(Math.ceil);
|
|
4894
|
+
var divided_by = argumentsToNumber(function (dividend, divisor, integerArithmetic) {
|
|
4332
4895
|
if (integerArithmetic === void 0) { integerArithmetic = false; }
|
|
4333
4896
|
return integerArithmetic ? Math.floor(dividend / divisor) : dividend / divisor;
|
|
4334
4897
|
});
|
|
4335
|
-
var floor =
|
|
4336
|
-
var minus =
|
|
4337
|
-
var
|
|
4338
|
-
var
|
|
4898
|
+
var floor = argumentsToNumber(Math.floor);
|
|
4899
|
+
var minus = argumentsToNumber(function (v, arg) { return v - arg; });
|
|
4900
|
+
var plus = argumentsToNumber(function (lhs, rhs) { return lhs + rhs; });
|
|
4901
|
+
var modulo = argumentsToNumber(function (v, arg) { return ((v % arg) + arg) % arg; });
|
|
4902
|
+
var times = argumentsToNumber(function (v, arg) { return v * arg; });
|
|
4903
|
+
function shiftDecimal(n, exponent) {
|
|
4904
|
+
var _a = __read(String(n).split('e'), 2), mantissa = _a[0], _b = _a[1], power = _b === void 0 ? '0' : _b;
|
|
4905
|
+
return Number("".concat(mantissa, "e").concat(Number(power) + exponent));
|
|
4906
|
+
}
|
|
4339
4907
|
function round(v, arg) {
|
|
4340
4908
|
if (arg === void 0) { arg = 0; }
|
|
4341
|
-
v =
|
|
4342
|
-
arg =
|
|
4343
|
-
var
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
v
|
|
4348
|
-
arg = toValue(arg);
|
|
4349
|
-
return Number(v) + Number(arg);
|
|
4909
|
+
v = toNumber(v);
|
|
4910
|
+
arg = toNumber(arg);
|
|
4911
|
+
var scaled = shiftDecimal(Math.abs(v), arg);
|
|
4912
|
+
if (!(scaled <= Number.MAX_SAFE_INTEGER))
|
|
4913
|
+
return v;
|
|
4914
|
+
var rounded = shiftDecimal(Math.round(scaled), -arg);
|
|
4915
|
+
return v < 0 ? -rounded : rounded;
|
|
4350
4916
|
}
|
|
4351
4917
|
|
|
4352
4918
|
var mathFilters = /*#__PURE__*/Object.freeze({
|
|
@@ -4358,13 +4924,13 @@
|
|
|
4358
4924
|
divided_by: divided_by,
|
|
4359
4925
|
floor: floor,
|
|
4360
4926
|
minus: minus,
|
|
4927
|
+
plus: plus,
|
|
4361
4928
|
modulo: modulo,
|
|
4362
4929
|
times: times,
|
|
4363
|
-
round: round
|
|
4364
|
-
plus: plus
|
|
4930
|
+
round: round
|
|
4365
4931
|
});
|
|
4366
4932
|
|
|
4367
|
-
var url_decode = function (x) { return decodeURIComponent(stringify(x)
|
|
4933
|
+
var url_decode = function (x) { return decodeURIComponent(stringify(x).replace(/\+/g, ' ')); };
|
|
4368
4934
|
var url_encode = function (x) { return encodeURIComponent(stringify(x)).replace(/%20/g, '+'); };
|
|
4369
4935
|
var cgi_escape = function (x) { return encodeURIComponent(stringify(x))
|
|
4370
4936
|
.replace(/%20/g, '+')
|
|
@@ -4424,18 +4990,24 @@
|
|
|
4424
4990
|
var join = argumentsToValue(function (v, arg) {
|
|
4425
4991
|
var array = toArray(v);
|
|
4426
4992
|
var sep = isNil(arg) ? ' ' : stringify(arg);
|
|
4427
|
-
var
|
|
4428
|
-
|
|
4429
|
-
|
|
4993
|
+
var outputSize = sep.length * Math.max(array.length - 1, 0);
|
|
4994
|
+
for (var i = 0; i < array.length; i++)
|
|
4995
|
+
outputSize += String(array[i]).length;
|
|
4996
|
+
this.context.memoryLimit.use(outputSize);
|
|
4997
|
+
return Array.prototype.join.call(array, sep);
|
|
4998
|
+
});
|
|
4999
|
+
var last$1 = argumentsToValue(function (v) {
|
|
5000
|
+
return isArrayLike(v) ? readArrayElement(v, -1, this.context.ownPropertyOnly) : '';
|
|
5001
|
+
});
|
|
5002
|
+
var first = argumentsToValue(function (v) {
|
|
5003
|
+
return isArrayLike(v) ? readArrayElement(v, 0, this.context.ownPropertyOnly) : '';
|
|
4430
5004
|
});
|
|
4431
|
-
var last$1 = argumentsToValue(function (v) { return isArrayLike(v) ? last(v) : ''; });
|
|
4432
|
-
var first = argumentsToValue(function (v) { return isArrayLike(v) ? v[0] : ''; });
|
|
4433
5005
|
var reverse = argumentsToValue(function (v) {
|
|
4434
5006
|
var array = toArray(v);
|
|
4435
5007
|
this.context.memoryLimit.use(array.length);
|
|
4436
5008
|
return __spreadArray([], __read(array), false).reverse();
|
|
4437
5009
|
});
|
|
4438
|
-
function
|
|
5010
|
+
function sortBy(arr, property, comparator) {
|
|
4439
5011
|
var values, array, array_1, array_1_1, item, _a, _b, _c, _d, e_1_1;
|
|
4440
5012
|
var e_1, _e;
|
|
4441
5013
|
return __generator(this, function (_f) {
|
|
@@ -4481,22 +5053,25 @@
|
|
|
4481
5053
|
}
|
|
4482
5054
|
finally { if (e_1) throw e_1.error; }
|
|
4483
5055
|
return [7 /*endfinally*/];
|
|
4484
|
-
case 10: return [2 /*return*/, values.sort(function (lhs, rhs) {
|
|
4485
|
-
var lvalue = lhs[1];
|
|
4486
|
-
var rvalue = rhs[1];
|
|
4487
|
-
return lvalue < rvalue ? -1 : (lvalue > rvalue ? 1 : 0);
|
|
4488
|
-
}).map(function (tuple) { return tuple[0]; })];
|
|
5056
|
+
case 10: return [2 /*return*/, values.sort(function (lhs, rhs) { return comparator(lhs[1], rhs[1]); }).map(function (tuple) { return tuple[0]; })];
|
|
4489
5057
|
}
|
|
4490
5058
|
});
|
|
4491
5059
|
}
|
|
4492
|
-
function
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
5060
|
+
function sort(arr, property) {
|
|
5061
|
+
return __generator(this, function (_a) {
|
|
5062
|
+
switch (_a.label) {
|
|
5063
|
+
case 0: return [5 /*yield**/, __values(sortBy.call(this, arr, property, orderedCompare))];
|
|
5064
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5065
|
+
}
|
|
5066
|
+
});
|
|
5067
|
+
}
|
|
5068
|
+
function sort_natural(arr, property) {
|
|
5069
|
+
return __generator(this, function (_a) {
|
|
5070
|
+
switch (_a.label) {
|
|
5071
|
+
case 0: return [5 /*yield**/, __values(sortBy.call(this, arr, property, caseInsensitiveCompare))];
|
|
5072
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5073
|
+
}
|
|
5074
|
+
});
|
|
4500
5075
|
}
|
|
4501
5076
|
var size = function (v) { return (v && v.length) || 0; };
|
|
4502
5077
|
function map(arr, property) {
|
|
@@ -4589,14 +5164,14 @@
|
|
|
4589
5164
|
function compact(arr) {
|
|
4590
5165
|
var array = toArray(arr);
|
|
4591
5166
|
this.context.memoryLimit.use(array.length);
|
|
4592
|
-
return
|
|
5167
|
+
return Array.prototype.filter.call(array, function (x) { return !isNil(toValue(x)); });
|
|
4593
5168
|
}
|
|
4594
5169
|
function concat(v, arg) {
|
|
4595
5170
|
if (arg === void 0) { arg = []; }
|
|
4596
5171
|
var lhs = toArray(v);
|
|
4597
5172
|
var rhs = toArray(arg);
|
|
4598
5173
|
this.context.memoryLimit.use(lhs.length + rhs.length);
|
|
4599
|
-
return
|
|
5174
|
+
return Array.prototype.concat.call(lhs, rhs);
|
|
4600
5175
|
}
|
|
4601
5176
|
function push(v, arg) {
|
|
4602
5177
|
return concat.call(this, v, [arg]);
|
|
@@ -4609,7 +5184,9 @@
|
|
|
4609
5184
|
return clone;
|
|
4610
5185
|
}
|
|
4611
5186
|
function pop(v) {
|
|
4612
|
-
var
|
|
5187
|
+
var array = toArray(v);
|
|
5188
|
+
this.context.memoryLimit.use(array.length);
|
|
5189
|
+
var clone = __spreadArray([], __read(array), false);
|
|
4613
5190
|
clone.pop();
|
|
4614
5191
|
return clone;
|
|
4615
5192
|
}
|
|
@@ -4627,61 +5204,82 @@
|
|
|
4627
5204
|
return [];
|
|
4628
5205
|
if (!isArray(v))
|
|
4629
5206
|
v = stringify(v);
|
|
4630
|
-
begin = begin < 0 ? v.length + begin : begin;
|
|
5207
|
+
begin = begin < 0 ? (isArray(v) ? v.length : codePointLength(v)) + begin : begin;
|
|
5208
|
+
if (begin < 0 || length < 0)
|
|
5209
|
+
return isArray(v) ? [] : '';
|
|
4631
5210
|
this.context.memoryLimit.use(length);
|
|
4632
|
-
|
|
5211
|
+
if (isArray(v))
|
|
5212
|
+
return Array.prototype.slice.call(v, begin, begin + length);
|
|
5213
|
+
var start = advanceCodePoints(v, 0, begin);
|
|
5214
|
+
return v.slice(start, advanceCodePoints(v, start, length));
|
|
4633
5215
|
}
|
|
4634
|
-
function
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
5216
|
+
function matches(value, expected) {
|
|
5217
|
+
return __generator(this, function (_a) {
|
|
5218
|
+
switch (_a.label) {
|
|
5219
|
+
case 0:
|
|
5220
|
+
if (!this.context.opts.jekyllWhere) return [3 /*break*/, 6];
|
|
5221
|
+
if (!EmptyDrop.is(expected)) return [3 /*break*/, 2];
|
|
5222
|
+
return [4 /*yield*/, equals(value, expected)];
|
|
5223
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5224
|
+
case 2:
|
|
5225
|
+
if (!isArray(value)) return [3 /*break*/, 4];
|
|
5226
|
+
return [4 /*yield*/, arrayIncludes(value, expected)];
|
|
5227
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
5228
|
+
case 4: return [4 /*yield*/, equals(value, expected)];
|
|
5229
|
+
case 5: return [2 /*return*/, _a.sent()];
|
|
5230
|
+
case 6:
|
|
5231
|
+
if (expected === undefined)
|
|
5232
|
+
return [2 /*return*/, isTruthy(value, this.context)];
|
|
5233
|
+
return [4 /*yield*/, equals(value, expected)];
|
|
5234
|
+
case 7: return [2 /*return*/, _a.sent()];
|
|
5235
|
+
}
|
|
5236
|
+
});
|
|
5237
|
+
}
|
|
5238
|
+
function filter(include, arr, property, expected) {
|
|
5239
|
+
var token, result, arr_1, arr_1_1, item, value, e_4_1;
|
|
5240
|
+
var e_4, _a;
|
|
5241
|
+
return __generator(this, function (_b) {
|
|
5242
|
+
switch (_b.label) {
|
|
4640
5243
|
case 0:
|
|
4641
|
-
values = [];
|
|
4642
5244
|
arr = toArray(arr);
|
|
4643
5245
|
this.context.memoryLimit.use(arr.length);
|
|
4644
5246
|
token = new Tokenizer(stringify(property)).readScopeValue();
|
|
4645
|
-
|
|
5247
|
+
result = [];
|
|
5248
|
+
_b.label = 1;
|
|
4646
5249
|
case 1:
|
|
4647
|
-
|
|
5250
|
+
_b.trys.push([1, 7, 8, 9]);
|
|
4648
5251
|
arr_1 = __values(arr), arr_1_1 = arr_1.next();
|
|
4649
|
-
|
|
5252
|
+
_b.label = 2;
|
|
4650
5253
|
case 2:
|
|
4651
|
-
if (!!arr_1_1.done) return [3 /*break*/,
|
|
5254
|
+
if (!!arr_1_1.done) return [3 /*break*/, 6];
|
|
4652
5255
|
item = arr_1_1.value;
|
|
4653
|
-
_b = (_a = values).push;
|
|
4654
5256
|
return [4 /*yield*/, evalToken(token, this.context.spawn(item))];
|
|
4655
5257
|
case 3:
|
|
4656
|
-
_b.
|
|
4657
|
-
|
|
5258
|
+
value = _b.sent();
|
|
5259
|
+
return [4 /*yield*/, matches.call(this, value, expected)];
|
|
4658
5260
|
case 4:
|
|
5261
|
+
if ((_b.sent()) === include)
|
|
5262
|
+
result.push(item);
|
|
5263
|
+
_b.label = 5;
|
|
5264
|
+
case 5:
|
|
4659
5265
|
arr_1_1 = arr_1.next();
|
|
4660
5266
|
return [3 /*break*/, 2];
|
|
4661
|
-
case
|
|
4662
|
-
case 6:
|
|
4663
|
-
e_4_1 = _d.sent();
|
|
4664
|
-
e_4 = { error: e_4_1 };
|
|
4665
|
-
return [3 /*break*/, 8];
|
|
5267
|
+
case 6: return [3 /*break*/, 9];
|
|
4666
5268
|
case 7:
|
|
5269
|
+
e_4_1 = _b.sent();
|
|
5270
|
+
e_4 = { error: e_4_1 };
|
|
5271
|
+
return [3 /*break*/, 9];
|
|
5272
|
+
case 8:
|
|
4667
5273
|
try {
|
|
4668
|
-
if (arr_1_1 && !arr_1_1.done && (
|
|
5274
|
+
if (arr_1_1 && !arr_1_1.done && (_a = arr_1.return)) _a.call(arr_1);
|
|
4669
5275
|
}
|
|
4670
5276
|
finally { if (e_4) throw e_4.error; }
|
|
4671
5277
|
return [7 /*endfinally*/];
|
|
4672
|
-
case
|
|
4673
|
-
matcher = this.context.opts.jekyllWhere
|
|
4674
|
-
? function (v) { return EmptyDrop.is(expected) ? equals(v, expected) : (isArray(v) ? arrayIncludes(v, expected) : equals(v, expected)); }
|
|
4675
|
-
: function (v) { return equals(v, expected); };
|
|
4676
|
-
return [2 /*return*/, arr.filter(function (_, i) {
|
|
4677
|
-
if (expected === undefined)
|
|
4678
|
-
return isTruthy(values[i], _this.context);
|
|
4679
|
-
return matcher(values[i]);
|
|
4680
|
-
})];
|
|
5278
|
+
case 9: return [2 /*return*/, result];
|
|
4681
5279
|
}
|
|
4682
5280
|
});
|
|
4683
5281
|
}
|
|
4684
|
-
function
|
|
5282
|
+
function filter_exp(include, arr, itemName, exp) {
|
|
4685
5283
|
var filtered, keyTemplate, array, array_4, array_4_1, item, value, e_5_1;
|
|
4686
5284
|
var e_5, _a, _b;
|
|
4687
5285
|
return __generator(this, function (_c) {
|
|
@@ -4699,10 +5297,12 @@
|
|
|
4699
5297
|
case 2:
|
|
4700
5298
|
if (!!array_4_1.done) return [3 /*break*/, 5];
|
|
4701
5299
|
item = array_4_1.value;
|
|
4702
|
-
|
|
5300
|
+
this.context.push((_b = {}, _b[itemName] = item, _b));
|
|
5301
|
+
return [4 /*yield*/, keyTemplate.value(this.context)];
|
|
4703
5302
|
case 3:
|
|
4704
5303
|
value = _c.sent();
|
|
4705
|
-
|
|
5304
|
+
this.context.pop();
|
|
5305
|
+
if (value === include)
|
|
4706
5306
|
filtered.push(item);
|
|
4707
5307
|
_c.label = 4;
|
|
4708
5308
|
case 4:
|
|
@@ -4723,6 +5323,38 @@
|
|
|
4723
5323
|
}
|
|
4724
5324
|
});
|
|
4725
5325
|
}
|
|
5326
|
+
function where(arr, property, expected) {
|
|
5327
|
+
return __generator(this, function (_a) {
|
|
5328
|
+
switch (_a.label) {
|
|
5329
|
+
case 0: return [5 /*yield**/, __values(filter.call(this, true, arr, property, expected))];
|
|
5330
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5331
|
+
}
|
|
5332
|
+
});
|
|
5333
|
+
}
|
|
5334
|
+
function reject(arr, property, expected) {
|
|
5335
|
+
return __generator(this, function (_a) {
|
|
5336
|
+
switch (_a.label) {
|
|
5337
|
+
case 0: return [5 /*yield**/, __values(filter.call(this, false, arr, property, expected))];
|
|
5338
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5339
|
+
}
|
|
5340
|
+
});
|
|
5341
|
+
}
|
|
5342
|
+
function where_exp(arr, itemName, exp) {
|
|
5343
|
+
return __generator(this, function (_a) {
|
|
5344
|
+
switch (_a.label) {
|
|
5345
|
+
case 0: return [5 /*yield**/, __values(filter_exp.call(this, true, arr, itemName, exp))];
|
|
5346
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5347
|
+
}
|
|
5348
|
+
});
|
|
5349
|
+
}
|
|
5350
|
+
function reject_exp(arr, itemName, exp) {
|
|
5351
|
+
return __generator(this, function (_a) {
|
|
5352
|
+
switch (_a.label) {
|
|
5353
|
+
case 0: return [5 /*yield**/, __values(filter_exp.call(this, false, arr, itemName, exp))];
|
|
5354
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5355
|
+
}
|
|
5356
|
+
});
|
|
5357
|
+
}
|
|
4726
5358
|
function group_by(arr, property) {
|
|
4727
5359
|
var map, token, arr_2, arr_2_1, item, key, e_6_1;
|
|
4728
5360
|
var e_6, _a;
|
|
@@ -4787,9 +5419,11 @@
|
|
|
4787
5419
|
case 2:
|
|
4788
5420
|
if (!!arr_3_1.done) return [3 /*break*/, 5];
|
|
4789
5421
|
item = arr_3_1.value;
|
|
4790
|
-
|
|
5422
|
+
this.context.push((_b = {}, _b[itemName] = item, _b));
|
|
5423
|
+
return [4 /*yield*/, keyTemplate.value(this.context)];
|
|
4791
5424
|
case 3:
|
|
4792
5425
|
key = _c.sent();
|
|
5426
|
+
this.context.pop();
|
|
4793
5427
|
if (!map.has(key))
|
|
4794
5428
|
map.set(key, []);
|
|
4795
5429
|
map.get(key).push(item);
|
|
@@ -4815,83 +5449,122 @@
|
|
|
4815
5449
|
}
|
|
4816
5450
|
});
|
|
4817
5451
|
}
|
|
4818
|
-
function
|
|
4819
|
-
var token, array,
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
switch (_b.label) {
|
|
5452
|
+
function search(arr, property, expected) {
|
|
5453
|
+
var token, array, index, value;
|
|
5454
|
+
return __generator(this, function (_a) {
|
|
5455
|
+
switch (_a.label) {
|
|
4823
5456
|
case 0:
|
|
4824
5457
|
token = new Tokenizer(stringify(property)).readScopeValue();
|
|
4825
5458
|
array = toArray(arr);
|
|
4826
|
-
|
|
5459
|
+
index = 0;
|
|
5460
|
+
_a.label = 1;
|
|
4827
5461
|
case 1:
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
_b.label = 2;
|
|
5462
|
+
if (!(index < array.length)) return [3 /*break*/, 5];
|
|
5463
|
+
return [4 /*yield*/, evalToken(token, this.context.spawn(array[index]))];
|
|
4831
5464
|
case 2:
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
return [4 /*yield*/, evalToken(token, this.context.spawn(item))];
|
|
5465
|
+
value = _a.sent();
|
|
5466
|
+
return [4 /*yield*/, matches.call(this, value, expected)];
|
|
4835
5467
|
case 3:
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
_b.label = 4;
|
|
5468
|
+
if (_a.sent())
|
|
5469
|
+
return [2 /*return*/, [index, array[index]]];
|
|
5470
|
+
_a.label = 4;
|
|
4840
5471
|
case 4:
|
|
4841
|
-
|
|
4842
|
-
return [3 /*break*/,
|
|
4843
|
-
case 5: return [
|
|
4844
|
-
case 6:
|
|
4845
|
-
e_8_1 = _b.sent();
|
|
4846
|
-
e_8 = { error: e_8_1 };
|
|
4847
|
-
return [3 /*break*/, 8];
|
|
4848
|
-
case 7:
|
|
4849
|
-
try {
|
|
4850
|
-
if (array_5_1 && !array_5_1.done && (_a = array_5.return)) _a.call(array_5);
|
|
4851
|
-
}
|
|
4852
|
-
finally { if (e_8) throw e_8.error; }
|
|
4853
|
-
return [7 /*endfinally*/];
|
|
4854
|
-
case 8: return [2 /*return*/];
|
|
5472
|
+
index++;
|
|
5473
|
+
return [3 /*break*/, 1];
|
|
5474
|
+
case 5: return [2 /*return*/];
|
|
4855
5475
|
}
|
|
4856
5476
|
});
|
|
4857
5477
|
}
|
|
4858
|
-
function
|
|
4859
|
-
var predicate, array,
|
|
4860
|
-
var
|
|
4861
|
-
return __generator(this, function (
|
|
4862
|
-
switch (
|
|
5478
|
+
function search_exp(arr, itemName, exp) {
|
|
5479
|
+
var predicate, array, index, value;
|
|
5480
|
+
var _a;
|
|
5481
|
+
return __generator(this, function (_b) {
|
|
5482
|
+
switch (_b.label) {
|
|
4863
5483
|
case 0:
|
|
4864
5484
|
predicate = new Value(stringify(exp), this.liquid);
|
|
4865
5485
|
array = toArray(arr);
|
|
4866
|
-
|
|
5486
|
+
index = 0;
|
|
5487
|
+
_b.label = 1;
|
|
5488
|
+
case 1:
|
|
5489
|
+
if (!(index < array.length)) return [3 /*break*/, 4];
|
|
5490
|
+
this.context.push((_a = {}, _a[itemName] = array[index], _a));
|
|
5491
|
+
return [4 /*yield*/, predicate.value(this.context)];
|
|
5492
|
+
case 2:
|
|
5493
|
+
value = _b.sent();
|
|
5494
|
+
this.context.pop();
|
|
5495
|
+
if (value)
|
|
5496
|
+
return [2 /*return*/, [index, array[index]]];
|
|
5497
|
+
_b.label = 3;
|
|
5498
|
+
case 3:
|
|
5499
|
+
index++;
|
|
5500
|
+
return [3 /*break*/, 1];
|
|
5501
|
+
case 4: return [2 /*return*/];
|
|
5502
|
+
}
|
|
5503
|
+
});
|
|
5504
|
+
}
|
|
5505
|
+
function has(arr, property, expected) {
|
|
5506
|
+
var result;
|
|
5507
|
+
return __generator(this, function (_a) {
|
|
5508
|
+
switch (_a.label) {
|
|
5509
|
+
case 0: return [5 /*yield**/, __values(search.call(this, arr, property, expected))];
|
|
5510
|
+
case 1:
|
|
5511
|
+
result = _a.sent();
|
|
5512
|
+
return [2 /*return*/, !!result];
|
|
5513
|
+
}
|
|
5514
|
+
});
|
|
5515
|
+
}
|
|
5516
|
+
function has_exp(arr, itemName, exp) {
|
|
5517
|
+
var result;
|
|
5518
|
+
return __generator(this, function (_a) {
|
|
5519
|
+
switch (_a.label) {
|
|
5520
|
+
case 0: return [5 /*yield**/, __values(search_exp.call(this, arr, itemName, exp))];
|
|
5521
|
+
case 1:
|
|
5522
|
+
result = _a.sent();
|
|
5523
|
+
return [2 /*return*/, !!result];
|
|
5524
|
+
}
|
|
5525
|
+
});
|
|
5526
|
+
}
|
|
5527
|
+
function find_index(arr, property, expected) {
|
|
5528
|
+
var result;
|
|
5529
|
+
return __generator(this, function (_a) {
|
|
5530
|
+
switch (_a.label) {
|
|
5531
|
+
case 0: return [5 /*yield**/, __values(search.call(this, arr, property, expected))];
|
|
5532
|
+
case 1:
|
|
5533
|
+
result = _a.sent();
|
|
5534
|
+
return [2 /*return*/, result ? result[0] : undefined];
|
|
5535
|
+
}
|
|
5536
|
+
});
|
|
5537
|
+
}
|
|
5538
|
+
function find_index_exp(arr, itemName, exp) {
|
|
5539
|
+
var result;
|
|
5540
|
+
return __generator(this, function (_a) {
|
|
5541
|
+
switch (_a.label) {
|
|
5542
|
+
case 0: return [5 /*yield**/, __values(search_exp.call(this, arr, itemName, exp))];
|
|
5543
|
+
case 1:
|
|
5544
|
+
result = _a.sent();
|
|
5545
|
+
return [2 /*return*/, result ? result[0] : undefined];
|
|
5546
|
+
}
|
|
5547
|
+
});
|
|
5548
|
+
}
|
|
5549
|
+
function find(arr, property, expected) {
|
|
5550
|
+
var result;
|
|
5551
|
+
return __generator(this, function (_a) {
|
|
5552
|
+
switch (_a.label) {
|
|
5553
|
+
case 0: return [5 /*yield**/, __values(search.call(this, arr, property, expected))];
|
|
4867
5554
|
case 1:
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
array_6_1 = array_6.next();
|
|
4882
|
-
return [3 /*break*/, 2];
|
|
4883
|
-
case 5: return [3 /*break*/, 8];
|
|
4884
|
-
case 6:
|
|
4885
|
-
e_9_1 = _c.sent();
|
|
4886
|
-
e_9 = { error: e_9_1 };
|
|
4887
|
-
return [3 /*break*/, 8];
|
|
4888
|
-
case 7:
|
|
4889
|
-
try {
|
|
4890
|
-
if (array_6_1 && !array_6_1.done && (_a = array_6.return)) _a.call(array_6);
|
|
4891
|
-
}
|
|
4892
|
-
finally { if (e_9) throw e_9.error; }
|
|
4893
|
-
return [7 /*endfinally*/];
|
|
4894
|
-
case 8: return [2 /*return*/];
|
|
5555
|
+
result = _a.sent();
|
|
5556
|
+
return [2 /*return*/, result ? result[1] : undefined];
|
|
5557
|
+
}
|
|
5558
|
+
});
|
|
5559
|
+
}
|
|
5560
|
+
function find_exp(arr, itemName, exp) {
|
|
5561
|
+
var result;
|
|
5562
|
+
return __generator(this, function (_a) {
|
|
5563
|
+
switch (_a.label) {
|
|
5564
|
+
case 0: return [5 /*yield**/, __values(search_exp.call(this, arr, itemName, exp))];
|
|
5565
|
+
case 1:
|
|
5566
|
+
result = _a.sent();
|
|
5567
|
+
return [2 /*return*/, result ? result[1] : undefined];
|
|
4895
5568
|
}
|
|
4896
5569
|
});
|
|
4897
5570
|
}
|
|
@@ -4907,7 +5580,7 @@
|
|
|
4907
5580
|
return [];
|
|
4908
5581
|
if (!isArray(v))
|
|
4909
5582
|
v = stringify(v);
|
|
4910
|
-
this.context.memoryLimit.use(
|
|
5583
|
+
this.context.memoryLimit.use(v.length);
|
|
4911
5584
|
var shuffled = __spreadArray([], __read(v), false).sort(function () { return Math.random() - 0.5; });
|
|
4912
5585
|
if (count === 1)
|
|
4913
5586
|
return shuffled[0];
|
|
@@ -4933,9 +5606,15 @@
|
|
|
4933
5606
|
shift: shift,
|
|
4934
5607
|
slice: slice,
|
|
4935
5608
|
where: where,
|
|
5609
|
+
reject: reject,
|
|
4936
5610
|
where_exp: where_exp,
|
|
5611
|
+
reject_exp: reject_exp,
|
|
4937
5612
|
group_by: group_by,
|
|
4938
5613
|
group_by_exp: group_by_exp,
|
|
5614
|
+
has: has,
|
|
5615
|
+
has_exp: has_exp,
|
|
5616
|
+
find_index: find_index,
|
|
5617
|
+
find_index_exp: find_index_exp,
|
|
4939
5618
|
find: find,
|
|
4940
5619
|
find_exp: find_exp,
|
|
4941
5620
|
uniq: uniq,
|
|
@@ -4943,21 +5622,25 @@
|
|
|
4943
5622
|
});
|
|
4944
5623
|
|
|
4945
5624
|
function date(v, format, timezoneOffset) {
|
|
4946
|
-
var _a, _b
|
|
4947
|
-
var size = ((_a = v === null || v === void 0 ? void 0 : v.length) !== null && _a !== void 0 ? _a : 0) + ((_b =
|
|
5625
|
+
var _a, _b;
|
|
5626
|
+
var size = ((_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);
|
|
4948
5627
|
this.context.memoryLimit.use(size);
|
|
4949
5628
|
var date = parseDate(v, this.context.opts, timezoneOffset);
|
|
4950
5629
|
if (!date)
|
|
4951
5630
|
return v;
|
|
4952
5631
|
format = toValue(format);
|
|
4953
5632
|
format = isNil(format) ? this.context.opts.dateFormat : stringify(format);
|
|
4954
|
-
|
|
5633
|
+
this.context.memoryLimit.use(format.length);
|
|
5634
|
+
return strftime(date, format, this.context.memoryLimit);
|
|
4955
5635
|
}
|
|
4956
5636
|
function date_to_xmlschema(v) {
|
|
4957
5637
|
return date.call(this, v, '%Y-%m-%dT%H:%M:%S%:z');
|
|
4958
5638
|
}
|
|
4959
5639
|
function date_to_rfc822(v) {
|
|
4960
|
-
|
|
5640
|
+
var date = parseDate(v, this.context.opts, undefined, 'en-US');
|
|
5641
|
+
if (!date)
|
|
5642
|
+
return v;
|
|
5643
|
+
return strftime(date, '%a, %d %b %Y %H:%M:%S %z', this.context.memoryLimit);
|
|
4961
5644
|
}
|
|
4962
5645
|
function date_to_string(v, type, style) {
|
|
4963
5646
|
return stringify_date.call(this, v, '%b', type, style);
|
|
@@ -4969,20 +5652,24 @@
|
|
|
4969
5652
|
var date = parseDate(v, this.context.opts);
|
|
4970
5653
|
if (!date)
|
|
4971
5654
|
return v;
|
|
5655
|
+
var ml = this.context.memoryLimit;
|
|
4972
5656
|
if (type === 'ordinal') {
|
|
4973
5657
|
var d = date.getDate();
|
|
4974
5658
|
return style === 'US'
|
|
4975
|
-
? strftime(date, "".concat(month_type, " ").concat(d, "%q, %Y"))
|
|
4976
|
-
: strftime(date, "".concat(d, "%q ").concat(month_type, " %Y"));
|
|
5659
|
+
? strftime(date, "".concat(month_type, " ").concat(d, "%q, %Y"), ml)
|
|
5660
|
+
: strftime(date, "".concat(d, "%q ").concat(month_type, " %Y"), ml);
|
|
4977
5661
|
}
|
|
4978
|
-
return strftime(date, "%d ".concat(month_type, " %Y"));
|
|
5662
|
+
return strftime(date, "%d ".concat(month_type, " %Y"), ml);
|
|
4979
5663
|
}
|
|
4980
|
-
function parseDate(v, opts, timezoneOffset) {
|
|
5664
|
+
function parseDate(v, opts, timezoneOffset, locale) {
|
|
5665
|
+
if (locale === void 0) { locale = opts.locale; }
|
|
4981
5666
|
var date;
|
|
4982
5667
|
var defaultTimezoneOffset = timezoneOffset !== null && timezoneOffset !== void 0 ? timezoneOffset : opts.timezoneOffset;
|
|
4983
|
-
var locale = opts.locale;
|
|
4984
5668
|
v = toValue(v);
|
|
4985
|
-
if (v
|
|
5669
|
+
if (isNil(v)) {
|
|
5670
|
+
return undefined;
|
|
5671
|
+
}
|
|
5672
|
+
else if (v === 'now' || v === 'today') {
|
|
4986
5673
|
date = new LiquidDate(Date.now(), locale, defaultTimezoneOffset);
|
|
4987
5674
|
}
|
|
4988
5675
|
else if (isNumber(v)) {
|
|
@@ -5036,14 +5723,46 @@
|
|
|
5036
5723
|
this.context.memoryLimit.use(lhs.length + rhs.length);
|
|
5037
5724
|
return rhs + lhs;
|
|
5038
5725
|
}
|
|
5726
|
+
function getTrimStart(str, chars) {
|
|
5727
|
+
var e_1, _a;
|
|
5728
|
+
var start = 0;
|
|
5729
|
+
try {
|
|
5730
|
+
for (var str_1 = __values(str), str_1_1 = str_1.next(); !str_1_1.done; str_1_1 = str_1.next()) {
|
|
5731
|
+
var char = str_1_1.value;
|
|
5732
|
+
if (!chars.has(char))
|
|
5733
|
+
break;
|
|
5734
|
+
start += char.length;
|
|
5735
|
+
}
|
|
5736
|
+
}
|
|
5737
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5738
|
+
finally {
|
|
5739
|
+
try {
|
|
5740
|
+
if (str_1_1 && !str_1_1.done && (_a = str_1.return)) _a.call(str_1);
|
|
5741
|
+
}
|
|
5742
|
+
finally { if (e_1) throw e_1.error; }
|
|
5743
|
+
}
|
|
5744
|
+
return start;
|
|
5745
|
+
}
|
|
5746
|
+
function getTrimEnd(str, chars, start) {
|
|
5747
|
+
if (start === void 0) { start = 0; }
|
|
5748
|
+
var end = str.length;
|
|
5749
|
+
while (end > start) {
|
|
5750
|
+
var size = end - start >= 2 && str.codePointAt(end - 2) > 0xFFFF ? 2 : 1;
|
|
5751
|
+
if (!chars.has(str.slice(end - size, end)))
|
|
5752
|
+
break;
|
|
5753
|
+
end -= size;
|
|
5754
|
+
}
|
|
5755
|
+
return end;
|
|
5756
|
+
}
|
|
5039
5757
|
function lstrip(v, chars) {
|
|
5040
5758
|
var str = stringify(v);
|
|
5041
5759
|
this.context.memoryLimit.use(str.length);
|
|
5042
5760
|
if (chars) {
|
|
5043
|
-
chars =
|
|
5044
|
-
|
|
5761
|
+
chars = stringify(chars);
|
|
5762
|
+
this.context.memoryLimit.use(chars.length);
|
|
5763
|
+
return str.slice(getTrimStart(str, new Set(chars)));
|
|
5045
5764
|
}
|
|
5046
|
-
return str.
|
|
5765
|
+
return str.trimStart();
|
|
5047
5766
|
}
|
|
5048
5767
|
function downcase(v) {
|
|
5049
5768
|
var str = stringify(v);
|
|
@@ -5057,18 +5776,20 @@
|
|
|
5057
5776
|
}
|
|
5058
5777
|
function remove(v, arg) {
|
|
5059
5778
|
var str = stringify(v);
|
|
5060
|
-
|
|
5061
|
-
|
|
5779
|
+
arg = stringify(arg);
|
|
5780
|
+
this.context.memoryLimit.use(str.length + arg.length);
|
|
5781
|
+
return str.split(arg).join('');
|
|
5062
5782
|
}
|
|
5063
5783
|
function remove_first(v, l) {
|
|
5064
5784
|
var str = stringify(v);
|
|
5065
|
-
|
|
5066
|
-
|
|
5785
|
+
l = stringify(l);
|
|
5786
|
+
this.context.memoryLimit.use(str.length + l.length);
|
|
5787
|
+
return str.replace(l, '');
|
|
5067
5788
|
}
|
|
5068
5789
|
function remove_last(v, l) {
|
|
5069
5790
|
var str = stringify(v);
|
|
5070
|
-
this.context.memoryLimit.use(str.length);
|
|
5071
5791
|
var pattern = stringify(l);
|
|
5792
|
+
this.context.memoryLimit.use(str.length + pattern.length);
|
|
5072
5793
|
var index = str.lastIndexOf(pattern);
|
|
5073
5794
|
if (index === -1)
|
|
5074
5795
|
return str;
|
|
@@ -5078,10 +5799,11 @@
|
|
|
5078
5799
|
str = stringify(str);
|
|
5079
5800
|
this.context.memoryLimit.use(str.length);
|
|
5080
5801
|
if (chars) {
|
|
5081
|
-
chars =
|
|
5082
|
-
|
|
5802
|
+
chars = stringify(chars);
|
|
5803
|
+
this.context.memoryLimit.use(chars.length);
|
|
5804
|
+
return str.slice(0, getTrimEnd(str, new Set(chars)));
|
|
5083
5805
|
}
|
|
5084
|
-
return str.
|
|
5806
|
+
return str.trimEnd();
|
|
5085
5807
|
}
|
|
5086
5808
|
function split(v, arg) {
|
|
5087
5809
|
var str = stringify(v);
|
|
@@ -5097,10 +5819,10 @@
|
|
|
5097
5819
|
var str = stringify(v);
|
|
5098
5820
|
this.context.memoryLimit.use(str.length);
|
|
5099
5821
|
if (chars) {
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5822
|
+
var set = new Set(stringify(chars));
|
|
5823
|
+
this.context.memoryLimit.use(set.size);
|
|
5824
|
+
var start = getTrimStart(str, set);
|
|
5825
|
+
return str.slice(start, getTrimEnd(str, set, start));
|
|
5104
5826
|
}
|
|
5105
5827
|
return str.trim();
|
|
5106
5828
|
}
|
|
@@ -5109,6 +5831,11 @@
|
|
|
5109
5831
|
this.context.memoryLimit.use(str.length);
|
|
5110
5832
|
return str.replace(/\r?\n/gm, '');
|
|
5111
5833
|
}
|
|
5834
|
+
function squish(v) {
|
|
5835
|
+
var str = stringify(v);
|
|
5836
|
+
this.context.memoryLimit.use(str.length);
|
|
5837
|
+
return str.replace(/\s+/g, ' ').trim();
|
|
5838
|
+
}
|
|
5112
5839
|
function capitalize(str) {
|
|
5113
5840
|
str = stringify(str);
|
|
5114
5841
|
this.context.memoryLimit.use(str.length);
|
|
@@ -5116,39 +5843,47 @@
|
|
|
5116
5843
|
}
|
|
5117
5844
|
function replace(v, pattern, replacement) {
|
|
5118
5845
|
var str = stringify(v);
|
|
5119
|
-
|
|
5120
|
-
|
|
5846
|
+
pattern = stringify(pattern);
|
|
5847
|
+
replacement = stringify(replacement);
|
|
5848
|
+
var parts = str.split(pattern);
|
|
5849
|
+
var outputSize = str.length + (parts.length - 1) * (replacement.length - pattern.length);
|
|
5850
|
+
this.context.memoryLimit.use(outputSize);
|
|
5851
|
+
return parts.join(replacement);
|
|
5121
5852
|
}
|
|
5122
5853
|
function replace_first(v, arg1, arg2) {
|
|
5123
5854
|
var str = stringify(v);
|
|
5124
|
-
|
|
5125
|
-
|
|
5855
|
+
arg1 = stringify(arg1);
|
|
5856
|
+
arg2 = stringify(arg2);
|
|
5857
|
+
this.context.memoryLimit.use(str.length + arg1.length + arg2.length);
|
|
5858
|
+
return str.replace(arg1, function () { return arg2; });
|
|
5126
5859
|
}
|
|
5127
5860
|
function replace_last(v, arg1, arg2) {
|
|
5128
5861
|
var str = stringify(v);
|
|
5129
|
-
this.context.memoryLimit.use(str.length);
|
|
5130
5862
|
var pattern = stringify(arg1);
|
|
5863
|
+
var replacement = stringify(arg2);
|
|
5864
|
+
this.context.memoryLimit.use(str.length + pattern.length + replacement.length);
|
|
5131
5865
|
var index = str.lastIndexOf(pattern);
|
|
5132
5866
|
if (index === -1)
|
|
5133
5867
|
return str;
|
|
5134
|
-
var replacement = stringify(arg2);
|
|
5135
5868
|
return str.substring(0, index) + replacement + str.substring(index + pattern.length);
|
|
5136
5869
|
}
|
|
5137
5870
|
function truncate(v, l, o) {
|
|
5138
5871
|
if (l === void 0) { l = 50; }
|
|
5139
5872
|
if (o === void 0) { o = '...'; }
|
|
5140
5873
|
var str = stringify(v);
|
|
5141
|
-
|
|
5142
|
-
|
|
5874
|
+
o = stringify(o);
|
|
5875
|
+
this.context.memoryLimit.use(str.length + o.length);
|
|
5876
|
+
if (str.length <= l || advanceCodePoints(str, 0, l) >= str.length)
|
|
5143
5877
|
return v;
|
|
5144
|
-
return str.
|
|
5878
|
+
return str.slice(0, advanceCodePoints(str, 0, Math.max(l - codePointLength(o), 0))) + o;
|
|
5145
5879
|
}
|
|
5146
5880
|
function truncatewords(v, words, o) {
|
|
5147
5881
|
if (words === void 0) { words = 15; }
|
|
5148
5882
|
if (o === void 0) { o = '...'; }
|
|
5149
5883
|
var str = stringify(v);
|
|
5150
|
-
|
|
5151
|
-
|
|
5884
|
+
o = stringify(o);
|
|
5885
|
+
this.context.memoryLimit.use(str.length + o.length);
|
|
5886
|
+
var arr = str.trimStart().split(/\s+/);
|
|
5152
5887
|
if (words <= 0)
|
|
5153
5888
|
words = 1;
|
|
5154
5889
|
var ret = arr.slice(0, words).join(' ');
|
|
@@ -5181,9 +5916,14 @@
|
|
|
5181
5916
|
return input.split(/\s+/).length;
|
|
5182
5917
|
}
|
|
5183
5918
|
}
|
|
5184
|
-
function array_to_sentence_string(
|
|
5919
|
+
function array_to_sentence_string(input, connector) {
|
|
5185
5920
|
if (connector === void 0) { connector = 'and'; }
|
|
5186
|
-
|
|
5921
|
+
var array = toArray(input);
|
|
5922
|
+
connector = stringify(connector);
|
|
5923
|
+
var outputSize = connector.length + array.length * 2;
|
|
5924
|
+
for (var i = 0; i < array.length; i++)
|
|
5925
|
+
outputSize += stringify(array[i]).length;
|
|
5926
|
+
this.context.memoryLimit.use(outputSize);
|
|
5187
5927
|
switch (array.length) {
|
|
5188
5928
|
case 0:
|
|
5189
5929
|
return '';
|
|
@@ -5210,6 +5950,7 @@
|
|
|
5210
5950
|
split: split,
|
|
5211
5951
|
strip: strip,
|
|
5212
5952
|
strip_newlines: strip_newlines,
|
|
5953
|
+
squish: squish,
|
|
5213
5954
|
capitalize: capitalize,
|
|
5214
5955
|
replace: replace,
|
|
5215
5956
|
replace_first: replace_first,
|
|
@@ -5221,7 +5962,117 @@
|
|
|
5221
5962
|
array_to_sentence_string: array_to_sentence_string
|
|
5222
5963
|
});
|
|
5223
5964
|
|
|
5224
|
-
|
|
5965
|
+
function base64Encode(str) {
|
|
5966
|
+
var bytes = new TextEncoder().encode(str);
|
|
5967
|
+
var binary = '';
|
|
5968
|
+
for (var i = 0; i < bytes.length; i += 0x8000) {
|
|
5969
|
+
binary += String.fromCharCode.apply(String, __spreadArray([], __read(bytes.subarray(i, i + 0x8000)), false));
|
|
5970
|
+
}
|
|
5971
|
+
return btoa(binary);
|
|
5972
|
+
}
|
|
5973
|
+
function base64Decode(str) {
|
|
5974
|
+
return new TextDecoder().decode(Uint8Array.from(atob(str), function (c) { return c.charCodeAt(0); }));
|
|
5975
|
+
}
|
|
5976
|
+
|
|
5977
|
+
/**
|
|
5978
|
+
* Base64 related filters
|
|
5979
|
+
*
|
|
5980
|
+
* Implements base64_encode and base64_decode filters for Shopify compatibility
|
|
5981
|
+
*/
|
|
5982
|
+
function base64_encode(value) {
|
|
5983
|
+
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {
|
|
5984
|
+
this.context.memoryLimit.use(value.byteLength);
|
|
5985
|
+
return value.toString('base64');
|
|
5986
|
+
}
|
|
5987
|
+
var str = stringify(value);
|
|
5988
|
+
this.context.memoryLimit.use(str.length);
|
|
5989
|
+
return base64Encode(str);
|
|
5990
|
+
}
|
|
5991
|
+
function base64_decode(value) {
|
|
5992
|
+
var str = stringify(value);
|
|
5993
|
+
this.context.memoryLimit.use(str.length);
|
|
5994
|
+
assert(isBase64(str), 'invalid base64 provided to base64_decode');
|
|
5995
|
+
return base64Decode(str);
|
|
5996
|
+
}
|
|
5997
|
+
function isBase64(str) {
|
|
5998
|
+
str = str.replace(/[\t\n\f\r ]/g, '');
|
|
5999
|
+
if (str.length % 4 === 0)
|
|
6000
|
+
str = str.replace(/==?$/, '');
|
|
6001
|
+
return str.length % 4 !== 1 && /^[A-Za-z0-9+/]*$/.test(str);
|
|
6002
|
+
}
|
|
6003
|
+
|
|
6004
|
+
var base64Filters = /*#__PURE__*/Object.freeze({
|
|
6005
|
+
__proto__: null,
|
|
6006
|
+
base64_encode: base64_encode,
|
|
6007
|
+
base64_decode: base64_decode
|
|
6008
|
+
});
|
|
6009
|
+
|
|
6010
|
+
function bufferToHex(buffer) {
|
|
6011
|
+
var bytes = new Uint8Array(buffer);
|
|
6012
|
+
var hex = '';
|
|
6013
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
6014
|
+
hex += bytes[i].toString(16).padStart(2, '0');
|
|
6015
|
+
}
|
|
6016
|
+
return hex;
|
|
6017
|
+
}
|
|
6018
|
+
function sha256(str) {
|
|
6019
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6020
|
+
var data, digest;
|
|
6021
|
+
return __generator(this, function (_a) {
|
|
6022
|
+
switch (_a.label) {
|
|
6023
|
+
case 0:
|
|
6024
|
+
data = new TextEncoder().encode(str);
|
|
6025
|
+
return [4 /*yield*/, crypto.subtle.digest('SHA-256', data)];
|
|
6026
|
+
case 1:
|
|
6027
|
+
digest = _a.sent();
|
|
6028
|
+
return [2 /*return*/, bufferToHex(digest)];
|
|
6029
|
+
}
|
|
6030
|
+
});
|
|
6031
|
+
});
|
|
6032
|
+
}
|
|
6033
|
+
function hmacSha256(str, key) {
|
|
6034
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6035
|
+
var encoder, cryptoKey, signature;
|
|
6036
|
+
return __generator(this, function (_a) {
|
|
6037
|
+
switch (_a.label) {
|
|
6038
|
+
case 0:
|
|
6039
|
+
encoder = new TextEncoder();
|
|
6040
|
+
return [4 /*yield*/, crypto.subtle.importKey('raw', encoder.encode(key), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign'])];
|
|
6041
|
+
case 1:
|
|
6042
|
+
cryptoKey = _a.sent();
|
|
6043
|
+
return [4 /*yield*/, crypto.subtle.sign('HMAC', cryptoKey, encoder.encode(str))];
|
|
6044
|
+
case 2:
|
|
6045
|
+
signature = _a.sent();
|
|
6046
|
+
return [2 /*return*/, bufferToHex(signature)];
|
|
6047
|
+
}
|
|
6048
|
+
});
|
|
6049
|
+
});
|
|
6050
|
+
}
|
|
6051
|
+
|
|
6052
|
+
/**
|
|
6053
|
+
* Crypto related filters
|
|
6054
|
+
*
|
|
6055
|
+
* Implements sha256 and hmac_sha256 filters for Shopify compatibility
|
|
6056
|
+
*/
|
|
6057
|
+
function sha256$1(value) {
|
|
6058
|
+
var str = stringify(value);
|
|
6059
|
+
this.context.memoryLimit.use(str.length);
|
|
6060
|
+
return sha256(str);
|
|
6061
|
+
}
|
|
6062
|
+
function hmac_sha256(value, key) {
|
|
6063
|
+
var str = stringify(value);
|
|
6064
|
+
var keyStr = stringify(key);
|
|
6065
|
+
this.context.memoryLimit.use(str.length + keyStr.length);
|
|
6066
|
+
return hmacSha256(str, keyStr);
|
|
6067
|
+
}
|
|
6068
|
+
|
|
6069
|
+
var cryptoFilters = /*#__PURE__*/Object.freeze({
|
|
6070
|
+
__proto__: null,
|
|
6071
|
+
sha256: sha256$1,
|
|
6072
|
+
hmac_sha256: hmac_sha256
|
|
6073
|
+
});
|
|
6074
|
+
|
|
6075
|
+
var filters = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, htmlFilters), mathFilters), urlFilters), arrayFilters), dateFilters), stringFilters), base64Filters), cryptoFilters), misc);
|
|
5225
6076
|
|
|
5226
6077
|
var default_1 = /** @class */ (function (_super) {
|
|
5227
6078
|
__extends(default_1, _super);
|
|
@@ -5317,10 +6168,10 @@
|
|
|
5317
6168
|
return [2 /*return*/];
|
|
5318
6169
|
case 3:
|
|
5319
6170
|
continueKey = 'continue-' + this.variable + '-' + this.collection.getText();
|
|
5320
|
-
ctx.push({ continue: ctx.getRegister(continueKey) });
|
|
6171
|
+
ctx.push(createScope({ continue: ctx.getRegister(continueKey, {}) }));
|
|
5321
6172
|
return [4 /*yield*/, this.hash.render(ctx)];
|
|
5322
6173
|
case 4:
|
|
5323
|
-
hash = _c.sent();
|
|
6174
|
+
hash = (_c.sent());
|
|
5324
6175
|
ctx.pop();
|
|
5325
6176
|
modifiers = this.liquid.options.orderedFilterParameters
|
|
5326
6177
|
? Object.keys(hash).filter(function (x) { return MODIFIERS.includes(x); })
|
|
@@ -5333,7 +6184,7 @@
|
|
|
5333
6184
|
return reversed(collection);
|
|
5334
6185
|
}, collection);
|
|
5335
6186
|
ctx.setRegister(continueKey, (hash['offset'] || 0) + collection.length);
|
|
5336
|
-
scope = { forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) };
|
|
6187
|
+
scope = createScope({ forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) });
|
|
5337
6188
|
ctx.push(scope);
|
|
5338
6189
|
_c.label = 5;
|
|
5339
6190
|
case 5:
|
|
@@ -5550,69 +6401,72 @@
|
|
|
5550
6401
|
r = this.liquid.renderer;
|
|
5551
6402
|
_a = toValue;
|
|
5552
6403
|
return [4 /*yield*/, this.value.value(ctx, ctx.opts.lenientIf)];
|
|
5553
|
-
case 1:
|
|
5554
|
-
target = _a.apply(void 0, [_h.sent()]);
|
|
5555
|
-
branchHit = false;
|
|
5556
|
-
_h.label = 2;
|
|
6404
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, [_h.sent()])];
|
|
5557
6405
|
case 2:
|
|
5558
|
-
_h.
|
|
5559
|
-
|
|
6406
|
+
target = _h.sent();
|
|
6407
|
+
branchHit = false;
|
|
5560
6408
|
_h.label = 3;
|
|
5561
6409
|
case 3:
|
|
5562
|
-
|
|
5563
|
-
|
|
6410
|
+
_h.trys.push([3, 16, 17, 18]);
|
|
6411
|
+
_b = __values(this.branches), _c = _b.next();
|
|
5564
6412
|
_h.label = 4;
|
|
5565
6413
|
case 4:
|
|
5566
|
-
|
|
5567
|
-
|
|
6414
|
+
if (!!_c.done) return [3 /*break*/, 15];
|
|
6415
|
+
branch = _c.value;
|
|
5568
6416
|
_h.label = 5;
|
|
5569
6417
|
case 5:
|
|
5570
|
-
|
|
6418
|
+
_h.trys.push([5, 12, 13, 14]);
|
|
6419
|
+
_d = (e_1 = void 0, __values(branch.values)), _e = _d.next();
|
|
6420
|
+
_h.label = 6;
|
|
6421
|
+
case 6:
|
|
6422
|
+
if (!!_e.done) return [3 /*break*/, 11];
|
|
5571
6423
|
valueToken = _e.value;
|
|
5572
6424
|
return [4 /*yield*/, evalToken(valueToken, ctx, ctx.opts.lenientIf)];
|
|
5573
|
-
case
|
|
6425
|
+
case 7:
|
|
5574
6426
|
value = _h.sent();
|
|
5575
|
-
|
|
6427
|
+
return [4 /*yield*/, equals(target, value)];
|
|
6428
|
+
case 8:
|
|
6429
|
+
if (!_h.sent()) return [3 /*break*/, 10];
|
|
5576
6430
|
return [4 /*yield*/, r.renderTemplates(branch.templates, ctx, emitter)];
|
|
5577
|
-
case
|
|
6431
|
+
case 9:
|
|
5578
6432
|
_h.sent();
|
|
5579
6433
|
branchHit = true;
|
|
5580
|
-
return [3 /*break*/,
|
|
5581
|
-
case 8:
|
|
5582
|
-
_e = _d.next();
|
|
5583
|
-
return [3 /*break*/, 5];
|
|
5584
|
-
case 9: return [3 /*break*/, 12];
|
|
6434
|
+
return [3 /*break*/, 11];
|
|
5585
6435
|
case 10:
|
|
6436
|
+
_e = _d.next();
|
|
6437
|
+
return [3 /*break*/, 6];
|
|
6438
|
+
case 11: return [3 /*break*/, 14];
|
|
6439
|
+
case 12:
|
|
5586
6440
|
e_1_1 = _h.sent();
|
|
5587
6441
|
e_1 = { error: e_1_1 };
|
|
5588
|
-
return [3 /*break*/,
|
|
5589
|
-
case
|
|
6442
|
+
return [3 /*break*/, 14];
|
|
6443
|
+
case 13:
|
|
5590
6444
|
try {
|
|
5591
6445
|
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
5592
6446
|
}
|
|
5593
6447
|
finally { if (e_1) throw e_1.error; }
|
|
5594
6448
|
return [7 /*endfinally*/];
|
|
5595
|
-
case 12:
|
|
5596
|
-
_c = _b.next();
|
|
5597
|
-
return [3 /*break*/, 3];
|
|
5598
|
-
case 13: return [3 /*break*/, 16];
|
|
5599
6449
|
case 14:
|
|
6450
|
+
_c = _b.next();
|
|
6451
|
+
return [3 /*break*/, 4];
|
|
6452
|
+
case 15: return [3 /*break*/, 18];
|
|
6453
|
+
case 16:
|
|
5600
6454
|
e_2_1 = _h.sent();
|
|
5601
6455
|
e_2 = { error: e_2_1 };
|
|
5602
|
-
return [3 /*break*/,
|
|
5603
|
-
case
|
|
6456
|
+
return [3 /*break*/, 18];
|
|
6457
|
+
case 17:
|
|
5604
6458
|
try {
|
|
5605
6459
|
if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
|
|
5606
6460
|
}
|
|
5607
6461
|
finally { if (e_2) throw e_2.error; }
|
|
5608
6462
|
return [7 /*endfinally*/];
|
|
5609
|
-
case
|
|
5610
|
-
if (!!branchHit) return [3 /*break*/,
|
|
6463
|
+
case 18:
|
|
6464
|
+
if (!!branchHit) return [3 /*break*/, 20];
|
|
5611
6465
|
return [4 /*yield*/, r.renderTemplates(this.elseTemplates, ctx, emitter)];
|
|
5612
|
-
case
|
|
6466
|
+
case 19:
|
|
5613
6467
|
_h.sent();
|
|
5614
|
-
_h.label =
|
|
5615
|
-
case
|
|
6468
|
+
_h.label = 20;
|
|
6469
|
+
case 20: return [2 /*return*/];
|
|
5616
6470
|
}
|
|
5617
6471
|
});
|
|
5618
6472
|
};
|
|
@@ -5682,7 +6536,11 @@
|
|
|
5682
6536
|
alias = tokenizer.readIdentifier();
|
|
5683
6537
|
else
|
|
5684
6538
|
tokenizer.p = beforeAs;
|
|
5685
|
-
|
|
6539
|
+
var binding = { value: value, alias: alias && alias.content };
|
|
6540
|
+
if (keyword.content === 'with')
|
|
6541
|
+
_this.with = binding;
|
|
6542
|
+
else
|
|
6543
|
+
_this.forBinding = binding;
|
|
5686
6544
|
tokenizer.skipBlank();
|
|
5687
6545
|
if (tokenizer.peek() === ',')
|
|
5688
6546
|
tokenizer.advance();
|
|
@@ -5706,7 +6564,7 @@
|
|
|
5706
6564
|
switch (_k.label) {
|
|
5707
6565
|
case 0:
|
|
5708
6566
|
_a = this, liquid = _a.liquid, hash = _a.hash;
|
|
5709
|
-
return [4 /*yield*/, renderFilePath(this
|
|
6567
|
+
return [4 /*yield*/, renderFilePath(this.file, ctx, liquid)];
|
|
5710
6568
|
case 1:
|
|
5711
6569
|
filepath = (_k.sent());
|
|
5712
6570
|
assert(filepath, function () { return "illegal file path \"".concat(filepath, "\""); });
|
|
@@ -5717,8 +6575,8 @@
|
|
|
5717
6575
|
return [4 /*yield*/, hash.render(ctx)];
|
|
5718
6576
|
case 2:
|
|
5719
6577
|
_b.apply(void 0, _c.concat([_k.sent()]));
|
|
5720
|
-
if (!this
|
|
5721
|
-
_d = this
|
|
6578
|
+
if (!this.with) return [3 /*break*/, 4];
|
|
6579
|
+
_d = this.with, value = _d.value, alias = _d.alias;
|
|
5722
6580
|
_e = scope;
|
|
5723
6581
|
_f = alias || filepath;
|
|
5724
6582
|
return [4 /*yield*/, evalToken(value, ctx)];
|
|
@@ -5726,8 +6584,8 @@
|
|
|
5726
6584
|
_e[_f] = _k.sent();
|
|
5727
6585
|
_k.label = 4;
|
|
5728
6586
|
case 4:
|
|
5729
|
-
if (!this
|
|
5730
|
-
_g = this
|
|
6587
|
+
if (!this.forBinding) return [3 /*break*/, 15];
|
|
6588
|
+
_g = this.forBinding, value = _g.value, alias = _g.alias;
|
|
5731
6589
|
_h = toEnumerable;
|
|
5732
6590
|
return [4 /*yield*/, evalToken(value, ctx)];
|
|
5733
6591
|
case 5:
|
|
@@ -5742,7 +6600,7 @@
|
|
|
5742
6600
|
if (!!collection_1_1.done) return [3 /*break*/, 11];
|
|
5743
6601
|
item = collection_1_1.value;
|
|
5744
6602
|
scope[alias] = item;
|
|
5745
|
-
return [4 /*yield*/, liquid._parsePartialFile(filepath, childCtx.sync, this
|
|
6603
|
+
return [4 /*yield*/, liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile)];
|
|
5746
6604
|
case 8:
|
|
5747
6605
|
templates = (_k.sent());
|
|
5748
6606
|
return [4 /*yield*/, liquid.renderer.renderTemplates(templates, childCtx, emitter)];
|
|
@@ -5765,7 +6623,7 @@
|
|
|
5765
6623
|
finally { if (e_1) throw e_1.error; }
|
|
5766
6624
|
return [7 /*endfinally*/];
|
|
5767
6625
|
case 14: return [3 /*break*/, 18];
|
|
5768
|
-
case 15: return [4 /*yield*/, liquid._parsePartialFile(filepath, childCtx.sync, this
|
|
6626
|
+
case 15: return [4 /*yield*/, liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile)];
|
|
5769
6627
|
case 16:
|
|
5770
6628
|
templates = (_k.sent());
|
|
5771
6629
|
return [4 /*yield*/, liquid.renderer.renderTemplates(templates, childCtx, emitter)];
|
|
@@ -5780,18 +6638,18 @@
|
|
|
5780
6638
|
return __generator(this, function (_a) {
|
|
5781
6639
|
switch (_a.label) {
|
|
5782
6640
|
case 0:
|
|
5783
|
-
if (!(partials && isString(this
|
|
5784
|
-
return [4 /*yield*/, this.liquid._parsePartialFile(this
|
|
6641
|
+
if (!(partials && isString(this.file))) return [3 /*break*/, 2];
|
|
6642
|
+
return [4 /*yield*/, this.liquid._parsePartialFile(this.file, sync, this.currentFile)];
|
|
5785
6643
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
5786
6644
|
case 2: return [2 /*return*/, []];
|
|
5787
6645
|
}
|
|
5788
6646
|
});
|
|
5789
6647
|
};
|
|
5790
6648
|
default_1.prototype.partialScope = function () {
|
|
5791
|
-
if (isString(this
|
|
6649
|
+
if (isString(this.file)) {
|
|
5792
6650
|
var names = Object.keys(this.hash.hash);
|
|
5793
|
-
if (this
|
|
5794
|
-
var _a = this
|
|
6651
|
+
if (this.with) {
|
|
6652
|
+
var _a = this.with, value = _a.value, alias = _a.alias;
|
|
5795
6653
|
if (isString(alias)) {
|
|
5796
6654
|
names.push([alias, value]);
|
|
5797
6655
|
}
|
|
@@ -5799,8 +6657,8 @@
|
|
|
5799
6657
|
names.push([this.file, value]);
|
|
5800
6658
|
}
|
|
5801
6659
|
}
|
|
5802
|
-
if (this
|
|
5803
|
-
var _b = this
|
|
6660
|
+
if (this.forBinding) {
|
|
6661
|
+
var _b = this.forBinding, value = _b.value, alias = _b.alias;
|
|
5804
6662
|
if (isString(alias)) {
|
|
5805
6663
|
names.push([alias, value]);
|
|
5806
6664
|
}
|
|
@@ -5808,7 +6666,7 @@
|
|
|
5808
6666
|
names.push([this.file, value]);
|
|
5809
6667
|
}
|
|
5810
6668
|
}
|
|
5811
|
-
return { name: this
|
|
6669
|
+
return { name: this.file, isolated: true, scope: names };
|
|
5812
6670
|
}
|
|
5813
6671
|
};
|
|
5814
6672
|
default_1.prototype.arguments = function () {
|
|
@@ -5843,16 +6701,16 @@
|
|
|
5843
6701
|
finally { if (e_2) throw e_2.error; }
|
|
5844
6702
|
return [7 /*endfinally*/];
|
|
5845
6703
|
case 7:
|
|
5846
|
-
if (!this
|
|
5847
|
-
value = this
|
|
6704
|
+
if (!this.with) return [3 /*break*/, 9];
|
|
6705
|
+
value = this.with.value;
|
|
5848
6706
|
if (!isValueToken(value)) return [3 /*break*/, 9];
|
|
5849
6707
|
return [4 /*yield*/, value];
|
|
5850
6708
|
case 8:
|
|
5851
6709
|
_d.sent();
|
|
5852
6710
|
_d.label = 9;
|
|
5853
6711
|
case 9:
|
|
5854
|
-
if (!this
|
|
5855
|
-
value = this
|
|
6712
|
+
if (!this.forBinding) return [3 /*break*/, 11];
|
|
6713
|
+
value = this.forBinding.value;
|
|
5856
6714
|
if (!isValueToken(value)) return [3 /*break*/, 11];
|
|
5857
6715
|
return [4 /*yield*/, value];
|
|
5858
6716
|
case 10:
|
|
@@ -5912,8 +6770,8 @@
|
|
|
5912
6770
|
function default_1(token, remainTokens, liquid, parser) {
|
|
5913
6771
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
5914
6772
|
var tokenizer = token.tokenizer;
|
|
5915
|
-
_this
|
|
5916
|
-
_this
|
|
6773
|
+
_this.file = parseFilePath(tokenizer, _this.liquid, parser);
|
|
6774
|
+
_this.currentFile = token.file;
|
|
5917
6775
|
var begin = tokenizer.p;
|
|
5918
6776
|
var withStr = tokenizer.readIdentifier();
|
|
5919
6777
|
if (withStr.content === 'with') {
|
|
@@ -5930,36 +6788,37 @@
|
|
|
5930
6788
|
return _this;
|
|
5931
6789
|
}
|
|
5932
6790
|
default_1.prototype.render = function (ctx, emitter) {
|
|
5933
|
-
var _a, liquid, hash, withVar, renderer, filepath, saved, scope, _b, _c, templates;
|
|
5934
|
-
return __generator(this, function (
|
|
5935
|
-
switch (
|
|
6791
|
+
var _a, liquid, hash, withVar, renderer, filepath, saved, scope, _b, _c, _d, templates;
|
|
6792
|
+
return __generator(this, function (_e) {
|
|
6793
|
+
switch (_e.label) {
|
|
5936
6794
|
case 0:
|
|
5937
6795
|
_a = this, liquid = _a.liquid, hash = _a.hash, withVar = _a.withVar;
|
|
5938
6796
|
renderer = liquid.renderer;
|
|
5939
|
-
return [4 /*yield*/, renderFilePath(this
|
|
6797
|
+
return [4 /*yield*/, renderFilePath(this.file, ctx, liquid)];
|
|
5940
6798
|
case 1:
|
|
5941
|
-
filepath = (
|
|
6799
|
+
filepath = (_e.sent());
|
|
5942
6800
|
assert(filepath, function () { return "illegal file path \"".concat(filepath, "\""); });
|
|
5943
6801
|
saved = ctx.saveRegister('blocks', 'blockMode');
|
|
5944
6802
|
ctx.setRegister('blocks', {});
|
|
5945
6803
|
ctx.setRegister('blockMode', BlockMode.OUTPUT);
|
|
6804
|
+
_b = createScope;
|
|
5946
6805
|
return [4 /*yield*/, hash.render(ctx)];
|
|
5947
6806
|
case 2:
|
|
5948
|
-
scope = (
|
|
6807
|
+
scope = _b.apply(void 0, [(_e.sent())]);
|
|
5949
6808
|
if (!withVar) return [3 /*break*/, 4];
|
|
5950
|
-
|
|
5951
|
-
|
|
6809
|
+
_c = scope;
|
|
6810
|
+
_d = filepath;
|
|
5952
6811
|
return [4 /*yield*/, evalToken(withVar, ctx)];
|
|
5953
6812
|
case 3:
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
case 4: return [4 /*yield*/, liquid._parsePartialFile(filepath, ctx.sync, this
|
|
6813
|
+
_c[_d] = _e.sent();
|
|
6814
|
+
_e.label = 4;
|
|
6815
|
+
case 4: return [4 /*yield*/, liquid._parsePartialFile(filepath, ctx.sync, this.currentFile)];
|
|
5957
6816
|
case 5:
|
|
5958
|
-
templates = (
|
|
5959
|
-
ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
|
|
6817
|
+
templates = (_e.sent());
|
|
6818
|
+
ctx.push(ctx.opts.jekyllInclude ? createScope({ include: scope }) : scope);
|
|
5960
6819
|
return [4 /*yield*/, renderer.renderTemplates(templates, ctx, emitter)];
|
|
5961
6820
|
case 6:
|
|
5962
|
-
|
|
6821
|
+
_e.sent();
|
|
5963
6822
|
ctx.pop();
|
|
5964
6823
|
ctx.restoreRegister(saved);
|
|
5965
6824
|
return [2 /*return*/];
|
|
@@ -5970,15 +6829,15 @@
|
|
|
5970
6829
|
return __generator(this, function (_a) {
|
|
5971
6830
|
switch (_a.label) {
|
|
5972
6831
|
case 0:
|
|
5973
|
-
if (!(partials && isString(this
|
|
5974
|
-
return [4 /*yield*/, this.liquid._parsePartialFile(this
|
|
6832
|
+
if (!(partials && isString(this.file))) return [3 /*break*/, 2];
|
|
6833
|
+
return [4 /*yield*/, this.liquid._parsePartialFile(this.file, sync, this.currentFile)];
|
|
5975
6834
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
5976
6835
|
case 2: return [2 /*return*/, []];
|
|
5977
6836
|
}
|
|
5978
6837
|
});
|
|
5979
6838
|
};
|
|
5980
6839
|
default_1.prototype.partialScope = function () {
|
|
5981
|
-
if (isString(this
|
|
6840
|
+
if (isString(this.file)) {
|
|
5982
6841
|
var names = void 0;
|
|
5983
6842
|
if (this.liquid.options.jekyllInclude) {
|
|
5984
6843
|
names = ['include'];
|
|
@@ -5986,10 +6845,10 @@
|
|
|
5986
6845
|
else {
|
|
5987
6846
|
names = Object.keys(this.hash.hash);
|
|
5988
6847
|
if (this.withVar) {
|
|
5989
|
-
names.push([this
|
|
6848
|
+
names.push([this.file, this.withVar]);
|
|
5990
6849
|
}
|
|
5991
6850
|
}
|
|
5992
|
-
return { name: this
|
|
6851
|
+
return { name: this.file, isolated: false, scope: names };
|
|
5993
6852
|
}
|
|
5994
6853
|
};
|
|
5995
6854
|
default_1.prototype.arguments = function () {
|
|
@@ -5998,8 +6857,8 @@
|
|
|
5998
6857
|
case 0: return [5 /*yield**/, __values(Object.values(this.hash.hash).filter(isValueToken))];
|
|
5999
6858
|
case 1:
|
|
6000
6859
|
_a.sent();
|
|
6001
|
-
if (!isValueToken(this
|
|
6002
|
-
return [4 /*yield*/, this
|
|
6860
|
+
if (!isValueToken(this.file)) return [3 /*break*/, 3];
|
|
6861
|
+
return [4 /*yield*/, this.file];
|
|
6003
6862
|
case 2:
|
|
6004
6863
|
_a.sent();
|
|
6005
6864
|
_a.label = 3;
|
|
@@ -6049,6 +6908,7 @@
|
|
|
6049
6908
|
function default_1(token, remainTokens, liquid) {
|
|
6050
6909
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
6051
6910
|
_this.candidates = [];
|
|
6911
|
+
var begin = _this.tokenizer.p;
|
|
6052
6912
|
var group = _this.tokenizer.readValue();
|
|
6053
6913
|
_this.tokenizer.skipBlank();
|
|
6054
6914
|
if (group) {
|
|
@@ -6057,35 +6917,45 @@
|
|
|
6057
6917
|
_this.tokenizer.advance();
|
|
6058
6918
|
}
|
|
6059
6919
|
else
|
|
6060
|
-
_this.
|
|
6920
|
+
_this.tokenizer.p = begin;
|
|
6061
6921
|
}
|
|
6062
6922
|
while (!_this.tokenizer.end()) {
|
|
6063
|
-
var value = _this.tokenizer.
|
|
6064
|
-
|
|
6065
|
-
_this.candidates.push(value);
|
|
6923
|
+
var value = _this.tokenizer.readFilteredValue();
|
|
6924
|
+
_this.candidates.push(value);
|
|
6066
6925
|
_this.tokenizer.readTo(',');
|
|
6067
6926
|
}
|
|
6068
6927
|
_this.tokenizer.assert(_this.candidates.length, function () { return "empty candidates: \"".concat(token.getText(), "\""); });
|
|
6069
6928
|
return _this;
|
|
6070
6929
|
}
|
|
6071
6930
|
default_1.prototype.render = function (ctx, emitter) {
|
|
6072
|
-
var group, fingerprint, groups, idx, candidate;
|
|
6073
|
-
|
|
6074
|
-
|
|
6931
|
+
var group, fingerprint, groups, idx, candidate, val, _a, outputEscape;
|
|
6932
|
+
var _b;
|
|
6933
|
+
return __generator(this, function (_c) {
|
|
6934
|
+
switch (_c.label) {
|
|
6075
6935
|
case 0: return [4 /*yield*/, evalToken(this.group, ctx)];
|
|
6076
6936
|
case 1:
|
|
6077
|
-
group = (
|
|
6078
|
-
fingerprint = "cycle:".concat(group, ":") + this.candidates.join(',');
|
|
6079
|
-
groups = ctx.getRegister('cycle');
|
|
6937
|
+
group = (_c.sent());
|
|
6938
|
+
fingerprint = "cycle:".concat(group, ":") + this.candidates.map(function (c) { return c.getText(); }).join(',');
|
|
6939
|
+
groups = ctx.getRegister('cycle', {});
|
|
6080
6940
|
idx = groups[fingerprint];
|
|
6081
6941
|
if (idx === undefined) {
|
|
6082
6942
|
idx = groups[fingerprint] = 0;
|
|
6083
6943
|
}
|
|
6084
|
-
candidate = this.candidates[idx];
|
|
6944
|
+
candidate = new Value(this.candidates[idx], this.liquid);
|
|
6085
6945
|
idx = (idx + 1) % this.candidates.length;
|
|
6086
6946
|
groups[fingerprint] = idx;
|
|
6087
|
-
|
|
6088
|
-
|
|
6947
|
+
_a = toValue;
|
|
6948
|
+
return [4 /*yield*/, candidate.value(ctx, false)];
|
|
6949
|
+
case 2: return [4 /*yield*/, _a.apply(void 0, [_c.sent()])];
|
|
6950
|
+
case 3:
|
|
6951
|
+
val = _c.sent();
|
|
6952
|
+
outputEscape = this.liquid.options.outputEscape;
|
|
6953
|
+
if (!(outputEscape && !((_b = candidate.filters[candidate.filters.length - 1]) === null || _b === void 0 ? void 0 : _b.raw))) return [3 /*break*/, 5];
|
|
6954
|
+
return [4 /*yield*/, outputEscape.call({ context: ctx, token: this.token, liquid: this.liquid }, val)];
|
|
6955
|
+
case 4:
|
|
6956
|
+
val = _c.sent();
|
|
6957
|
+
_c.label = 5;
|
|
6958
|
+
case 5: return [2 /*return*/, val];
|
|
6089
6959
|
}
|
|
6090
6960
|
});
|
|
6091
6961
|
};
|
|
@@ -6137,45 +7007,47 @@
|
|
|
6137
7007
|
return _this;
|
|
6138
7008
|
}
|
|
6139
7009
|
default_1.prototype.render = function (ctx, emitter) {
|
|
6140
|
-
var r, _a, _b, _c, value, templates, v, e_1_1;
|
|
6141
|
-
var e_1,
|
|
6142
|
-
return __generator(this, function (
|
|
6143
|
-
switch (
|
|
7010
|
+
var r, _a, _b, _c, value, templates, v, _d, e_1_1;
|
|
7011
|
+
var e_1, _e;
|
|
7012
|
+
return __generator(this, function (_f) {
|
|
7013
|
+
switch (_f.label) {
|
|
6144
7014
|
case 0:
|
|
6145
7015
|
r = this.liquid.renderer;
|
|
6146
|
-
|
|
7016
|
+
_f.label = 1;
|
|
6147
7017
|
case 1:
|
|
6148
|
-
|
|
7018
|
+
_f.trys.push([1, 8, 9, 10]);
|
|
6149
7019
|
_a = __values(this.branches), _b = _a.next();
|
|
6150
|
-
|
|
7020
|
+
_f.label = 2;
|
|
6151
7021
|
case 2:
|
|
6152
|
-
if (!!_b.done) return [3 /*break*/,
|
|
7022
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
6153
7023
|
_c = _b.value, value = _c.value, templates = _c.templates;
|
|
7024
|
+
_d = toValue;
|
|
6154
7025
|
return [4 /*yield*/, value.value(ctx, ctx.opts.lenientIf)];
|
|
6155
|
-
case 3:
|
|
6156
|
-
v = _e.sent();
|
|
6157
|
-
if (!isTruthy(v, ctx)) return [3 /*break*/, 5];
|
|
6158
|
-
return [4 /*yield*/, r.renderTemplates(templates, ctx, emitter)];
|
|
7026
|
+
case 3: return [4 /*yield*/, _d.apply(void 0, [_f.sent()])];
|
|
6159
7027
|
case 4:
|
|
6160
|
-
|
|
6161
|
-
return [
|
|
7028
|
+
v = _f.sent();
|
|
7029
|
+
if (!isTruthy(v, ctx)) return [3 /*break*/, 6];
|
|
7030
|
+
return [4 /*yield*/, r.renderTemplates(templates, ctx, emitter)];
|
|
6162
7031
|
case 5:
|
|
7032
|
+
_f.sent();
|
|
7033
|
+
return [2 /*return*/];
|
|
7034
|
+
case 6:
|
|
6163
7035
|
_b = _a.next();
|
|
6164
7036
|
return [3 /*break*/, 2];
|
|
6165
|
-
case
|
|
6166
|
-
case 7:
|
|
6167
|
-
e_1_1 = _e.sent();
|
|
6168
|
-
e_1 = { error: e_1_1 };
|
|
6169
|
-
return [3 /*break*/, 9];
|
|
7037
|
+
case 7: return [3 /*break*/, 10];
|
|
6170
7038
|
case 8:
|
|
7039
|
+
e_1_1 = _f.sent();
|
|
7040
|
+
e_1 = { error: e_1_1 };
|
|
7041
|
+
return [3 /*break*/, 10];
|
|
7042
|
+
case 9:
|
|
6171
7043
|
try {
|
|
6172
|
-
if (_b && !_b.done && (
|
|
7044
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
6173
7045
|
}
|
|
6174
7046
|
finally { if (e_1) throw e_1.error; }
|
|
6175
7047
|
return [7 /*endfinally*/];
|
|
6176
|
-
case
|
|
6177
|
-
case
|
|
6178
|
-
|
|
7048
|
+
case 10: return [4 /*yield*/, r.renderTemplates(this.elseTemplates || [], ctx, emitter)];
|
|
7049
|
+
case 11:
|
|
7050
|
+
_f.sent();
|
|
6179
7051
|
return [2 /*return*/];
|
|
6180
7052
|
}
|
|
6181
7053
|
});
|
|
@@ -6231,15 +7103,15 @@
|
|
|
6231
7103
|
function default_1(token, remainTokens, liquid, parser) {
|
|
6232
7104
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
6233
7105
|
_this.file = parseFilePath(_this.tokenizer, _this.liquid, parser);
|
|
6234
|
-
_this
|
|
7106
|
+
_this.currentFile = token.file;
|
|
6235
7107
|
_this.args = new Hash(_this.tokenizer, liquid.options.keyValueSeparator);
|
|
6236
7108
|
_this.templates = parser.parseTokens(remainTokens);
|
|
6237
7109
|
return _this;
|
|
6238
7110
|
}
|
|
6239
7111
|
default_1.prototype.render = function (ctx, emitter) {
|
|
6240
|
-
var _a, liquid, args, file, renderer, filepath, templates, html, blocks, _b, _c;
|
|
6241
|
-
return __generator(this, function (
|
|
6242
|
-
switch (
|
|
7112
|
+
var _a, liquid, args, file, renderer, filepath, templates, html, blocks, _b, _c, _d;
|
|
7113
|
+
return __generator(this, function (_e) {
|
|
7114
|
+
switch (_e.label) {
|
|
6243
7115
|
case 0:
|
|
6244
7116
|
_a = this, liquid = _a.liquid, args = _a.args, file = _a.file;
|
|
6245
7117
|
renderer = liquid.renderer;
|
|
@@ -6247,34 +7119,35 @@
|
|
|
6247
7119
|
ctx.setRegister('blockMode', BlockMode.OUTPUT);
|
|
6248
7120
|
return [4 /*yield*/, renderer.renderTemplates(this.templates, ctx, emitter)];
|
|
6249
7121
|
case 1:
|
|
6250
|
-
|
|
7122
|
+
_e.sent();
|
|
6251
7123
|
return [2 /*return*/];
|
|
6252
7124
|
case 2: return [4 /*yield*/, renderFilePath(this.file, ctx, liquid)];
|
|
6253
7125
|
case 3:
|
|
6254
|
-
filepath = (
|
|
7126
|
+
filepath = (_e.sent());
|
|
6255
7127
|
assert(filepath, function () { return "illegal file path \"".concat(filepath, "\""); });
|
|
6256
|
-
return [4 /*yield*/, liquid._parseLayoutFile(filepath, ctx.sync, this
|
|
7128
|
+
return [4 /*yield*/, liquid._parseLayoutFile(filepath, ctx.sync, this.currentFile)];
|
|
6257
7129
|
case 4:
|
|
6258
|
-
templates = (
|
|
7130
|
+
templates = (_e.sent());
|
|
6259
7131
|
// render remaining contents and store rendered results
|
|
6260
7132
|
ctx.setRegister('blockMode', BlockMode.STORE);
|
|
6261
7133
|
return [4 /*yield*/, renderer.renderTemplates(this.templates, ctx)];
|
|
6262
7134
|
case 5:
|
|
6263
|
-
html =
|
|
6264
|
-
blocks = ctx.getRegister('blocks');
|
|
7135
|
+
html = _e.sent();
|
|
7136
|
+
blocks = ctx.getRegister('blocks', {});
|
|
6265
7137
|
// set whole content to anonymous block if anonymous doesn't specified
|
|
6266
7138
|
if (blocks[''] === undefined)
|
|
6267
7139
|
blocks[''] = function (parent, emitter) { return emitter.write(html); };
|
|
6268
7140
|
ctx.setRegister('blockMode', BlockMode.OUTPUT);
|
|
6269
7141
|
// render the layout file use stored blocks
|
|
6270
7142
|
_c = (_b = ctx).push;
|
|
7143
|
+
_d = createScope;
|
|
6271
7144
|
return [4 /*yield*/, args.render(ctx)];
|
|
6272
7145
|
case 6:
|
|
6273
7146
|
// render the layout file use stored blocks
|
|
6274
|
-
_c.apply(_b, [
|
|
7147
|
+
_c.apply(_b, [_d.apply(void 0, [(_e.sent())])]);
|
|
6275
7148
|
return [4 /*yield*/, renderer.renderTemplates(templates, ctx, emitter)];
|
|
6276
7149
|
case 7:
|
|
6277
|
-
|
|
7150
|
+
_e.sent();
|
|
6278
7151
|
ctx.pop();
|
|
6279
7152
|
return [2 /*return*/];
|
|
6280
7153
|
}
|
|
@@ -6290,7 +7163,7 @@
|
|
|
6290
7163
|
_b = (_a = templates.push).apply;
|
|
6291
7164
|
_c = [templates];
|
|
6292
7165
|
_d = [[]];
|
|
6293
|
-
return [4 /*yield*/, this.liquid._parsePartialFile(this.file, true, this
|
|
7166
|
+
return [4 /*yield*/, this.liquid._parsePartialFile(this.file, true, this.currentFile)];
|
|
6294
7167
|
case 1:
|
|
6295
7168
|
_b.apply(_a, _c.concat([__spreadArray.apply(void 0, _d.concat([__read.apply(void 0, [(_e.sent())]), false]))]));
|
|
6296
7169
|
_e.label = 2;
|
|
@@ -6370,7 +7243,7 @@
|
|
|
6370
7243
|
case 0:
|
|
6371
7244
|
blockRender = this.getBlockRender(ctx);
|
|
6372
7245
|
if (!(ctx.getRegister('blockMode') === BlockMode.STORE)) return [3 /*break*/, 1];
|
|
6373
|
-
ctx.getRegister('blocks')[this.block] = blockRender;
|
|
7246
|
+
ctx.getRegister('blocks', {})[this.block] = blockRender;
|
|
6374
7247
|
return [3 /*break*/, 3];
|
|
6375
7248
|
case 1: return [4 /*yield*/, blockRender(new BlockDrop(), emitter)];
|
|
6376
7249
|
case 2:
|
|
@@ -6381,24 +7254,30 @@
|
|
|
6381
7254
|
});
|
|
6382
7255
|
};
|
|
6383
7256
|
default_1.prototype.getBlockRender = function (ctx) {
|
|
7257
|
+
var self = this;
|
|
6384
7258
|
var _a = this, liquid = _a.liquid, templates = _a.templates;
|
|
6385
|
-
var renderChild = ctx.getRegister('blocks')[this.block];
|
|
7259
|
+
var renderChild = ctx.getRegister('blocks', {})[this.block];
|
|
6386
7260
|
var renderCurrent = function (superBlock, emitter) {
|
|
7261
|
+
var stack;
|
|
6387
7262
|
return __generator(this, function (_a) {
|
|
6388
7263
|
switch (_a.label) {
|
|
6389
7264
|
case 0:
|
|
6390
|
-
|
|
6391
|
-
|
|
7265
|
+
stack = ctx.getRegister('blockStack', []);
|
|
7266
|
+
if (stack.includes(self))
|
|
7267
|
+
throw new Error('block tag cannot be nested');
|
|
7268
|
+
stack.push(self);
|
|
7269
|
+
ctx.push(createScope({ block: superBlock }));
|
|
6392
7270
|
return [4 /*yield*/, liquid.renderer.renderTemplates(templates, ctx, emitter)];
|
|
6393
7271
|
case 1:
|
|
6394
7272
|
_a.sent();
|
|
6395
7273
|
ctx.pop();
|
|
7274
|
+
stack.pop();
|
|
6396
7275
|
return [2 /*return*/];
|
|
6397
7276
|
}
|
|
6398
7277
|
});
|
|
6399
7278
|
};
|
|
6400
7279
|
return renderChild
|
|
6401
|
-
? function (superBlock, emitter) { return renderChild(new BlockDrop(function () { return renderCurrent(superBlock, emitter); }), emitter); }
|
|
7280
|
+
? function (superBlock, emitter) { return renderChild(new BlockDrop(function (emitter) { return renderCurrent(superBlock, emitter); }), emitter); }
|
|
6402
7281
|
: renderCurrent;
|
|
6403
7282
|
};
|
|
6404
7283
|
default_1.prototype.children = function () {
|
|
@@ -6501,7 +7380,7 @@
|
|
|
6501
7380
|
cols = args.cols || collection.length;
|
|
6502
7381
|
r = this.liquid.renderer;
|
|
6503
7382
|
tablerowloop = new TablerowloopDrop(collection.length, cols, this.collection.getText(), this.variable);
|
|
6504
|
-
scope = { tablerowloop: tablerowloop };
|
|
7383
|
+
scope = createScope({ tablerowloop: tablerowloop });
|
|
6505
7384
|
ctx.push(scope);
|
|
6506
7385
|
idx = 0;
|
|
6507
7386
|
_b.label = 3;
|
|
@@ -6620,45 +7499,47 @@
|
|
|
6620
7499
|
return _this;
|
|
6621
7500
|
}
|
|
6622
7501
|
default_1.prototype.render = function (ctx, emitter) {
|
|
6623
|
-
var r, _a, _b, _c, value, test_1, templates, v, e_1_1;
|
|
6624
|
-
var e_1,
|
|
6625
|
-
return __generator(this, function (
|
|
6626
|
-
switch (
|
|
7502
|
+
var r, _a, _b, _c, value, test_1, templates, v, _d, e_1_1;
|
|
7503
|
+
var e_1, _e;
|
|
7504
|
+
return __generator(this, function (_f) {
|
|
7505
|
+
switch (_f.label) {
|
|
6627
7506
|
case 0:
|
|
6628
7507
|
r = this.liquid.renderer;
|
|
6629
|
-
|
|
7508
|
+
_f.label = 1;
|
|
6630
7509
|
case 1:
|
|
6631
|
-
|
|
7510
|
+
_f.trys.push([1, 8, 9, 10]);
|
|
6632
7511
|
_a = __values(this.branches), _b = _a.next();
|
|
6633
|
-
|
|
7512
|
+
_f.label = 2;
|
|
6634
7513
|
case 2:
|
|
6635
|
-
if (!!_b.done) return [3 /*break*/,
|
|
7514
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
6636
7515
|
_c = _b.value, value = _c.value, test_1 = _c.test, templates = _c.templates;
|
|
7516
|
+
_d = toValue;
|
|
6637
7517
|
return [4 /*yield*/, value.value(ctx, ctx.opts.lenientIf)];
|
|
6638
|
-
case 3:
|
|
6639
|
-
v = _e.sent();
|
|
6640
|
-
if (!test_1(v, ctx)) return [3 /*break*/, 5];
|
|
6641
|
-
return [4 /*yield*/, r.renderTemplates(templates, ctx, emitter)];
|
|
7518
|
+
case 3: return [4 /*yield*/, _d.apply(void 0, [_f.sent()])];
|
|
6642
7519
|
case 4:
|
|
6643
|
-
|
|
6644
|
-
return [
|
|
7520
|
+
v = _f.sent();
|
|
7521
|
+
if (!test_1(v, ctx)) return [3 /*break*/, 6];
|
|
7522
|
+
return [4 /*yield*/, r.renderTemplates(templates, ctx, emitter)];
|
|
6645
7523
|
case 5:
|
|
7524
|
+
_f.sent();
|
|
7525
|
+
return [2 /*return*/];
|
|
7526
|
+
case 6:
|
|
6646
7527
|
_b = _a.next();
|
|
6647
7528
|
return [3 /*break*/, 2];
|
|
6648
|
-
case
|
|
6649
|
-
case 7:
|
|
6650
|
-
e_1_1 = _e.sent();
|
|
6651
|
-
e_1 = { error: e_1_1 };
|
|
6652
|
-
return [3 /*break*/, 9];
|
|
7529
|
+
case 7: return [3 /*break*/, 10];
|
|
6653
7530
|
case 8:
|
|
7531
|
+
e_1_1 = _f.sent();
|
|
7532
|
+
e_1 = { error: e_1_1 };
|
|
7533
|
+
return [3 /*break*/, 10];
|
|
7534
|
+
case 9:
|
|
6654
7535
|
try {
|
|
6655
|
-
if (_b && !_b.done && (
|
|
7536
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
6656
7537
|
}
|
|
6657
7538
|
finally { if (e_1) throw e_1.error; }
|
|
6658
7539
|
return [7 /*endfinally*/];
|
|
6659
|
-
case
|
|
6660
|
-
case
|
|
6661
|
-
|
|
7540
|
+
case 10: return [4 /*yield*/, r.renderTemplates(this.elseTemplates, ctx, emitter)];
|
|
7541
|
+
case 11:
|
|
7542
|
+
_f.sent();
|
|
6662
7543
|
return [2 /*return*/];
|
|
6663
7544
|
}
|
|
6664
7545
|
});
|
|
@@ -6712,15 +7593,25 @@
|
|
|
6712
7593
|
return _this;
|
|
6713
7594
|
}
|
|
6714
7595
|
default_1.prototype.render = function (ctx, emitter) {
|
|
6715
|
-
var val;
|
|
6716
|
-
|
|
6717
|
-
|
|
7596
|
+
var val, _a, outputEscape;
|
|
7597
|
+
var _b;
|
|
7598
|
+
return __generator(this, function (_c) {
|
|
7599
|
+
switch (_c.label) {
|
|
6718
7600
|
case 0:
|
|
6719
7601
|
if (!this.value)
|
|
6720
7602
|
return [2 /*return*/];
|
|
7603
|
+
_a = toValue;
|
|
6721
7604
|
return [4 /*yield*/, this.value.value(ctx, false)];
|
|
6722
|
-
case 1:
|
|
6723
|
-
|
|
7605
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, [_c.sent()])];
|
|
7606
|
+
case 2:
|
|
7607
|
+
val = _c.sent();
|
|
7608
|
+
outputEscape = this.liquid.options.outputEscape;
|
|
7609
|
+
if (!(outputEscape && !((_b = this.value.filters[this.value.filters.length - 1]) === null || _b === void 0 ? void 0 : _b.raw))) return [3 /*break*/, 4];
|
|
7610
|
+
return [4 /*yield*/, outputEscape.call({ context: ctx, token: this.token, liquid: this.liquid }, val)];
|
|
7611
|
+
case 3:
|
|
7612
|
+
val = _c.sent();
|
|
7613
|
+
_c.label = 4;
|
|
7614
|
+
case 4:
|
|
6724
7615
|
emitter.write(val);
|
|
6725
7616
|
return [2 /*return*/];
|
|
6726
7617
|
}
|
|
@@ -6810,8 +7701,8 @@
|
|
|
6810
7701
|
if (opts === void 0) { opts = {}; }
|
|
6811
7702
|
var _this = this;
|
|
6812
7703
|
this.renderer = new Render();
|
|
6813
|
-
this.filters =
|
|
6814
|
-
this.tags =
|
|
7704
|
+
this.filters = Object.create(null);
|
|
7705
|
+
this.tags = Object.create(null);
|
|
6815
7706
|
this.options = normalize(opts);
|
|
6816
7707
|
// eslint-disable-next-line deprecation/deprecation
|
|
6817
7708
|
this.parser = new Parser(this);
|
|
@@ -6823,7 +7714,7 @@
|
|
|
6823
7714
|
return parser.parse(html, filepath);
|
|
6824
7715
|
};
|
|
6825
7716
|
Liquid.prototype._render = function (tpl, scope, renderOptions) {
|
|
6826
|
-
var ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions);
|
|
7717
|
+
var ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions, { liquid: this });
|
|
6827
7718
|
return this.renderer.renderTemplates(tpl, ctx);
|
|
6828
7719
|
};
|
|
6829
7720
|
Liquid.prototype.render = function (tpl, scope, renderOptions) {
|
|
@@ -6838,7 +7729,7 @@
|
|
|
6838
7729
|
};
|
|
6839
7730
|
Liquid.prototype.renderToNodeStream = function (tpl, scope, renderOptions) {
|
|
6840
7731
|
if (renderOptions === void 0) { renderOptions = {}; }
|
|
6841
|
-
var ctx = new Context(scope, this.options, renderOptions);
|
|
7732
|
+
var ctx = new Context(scope, this.options, renderOptions, { liquid: this });
|
|
6842
7733
|
return this.renderer.renderTemplatesToNodeStream(tpl, ctx);
|
|
6843
7734
|
};
|
|
6844
7735
|
Liquid.prototype._parseAndRender = function (html, scope, renderOptions) {
|
|
@@ -6856,10 +7747,10 @@
|
|
|
6856
7747
|
return toValueSync(this._parseAndRender(html, scope, __assign(__assign({}, renderOptions), { sync: true })));
|
|
6857
7748
|
};
|
|
6858
7749
|
Liquid.prototype._parsePartialFile = function (file, sync, currentFile) {
|
|
6859
|
-
return new Parser(this).parseFile(file, sync, LookupType.Partials, currentFile);
|
|
7750
|
+
return new Parser(this).parseFile(file, sync, exports.LookupType.Partials, currentFile);
|
|
6860
7751
|
};
|
|
6861
7752
|
Liquid.prototype._parseLayoutFile = function (file, sync, currentFile) {
|
|
6862
|
-
return new Parser(this).parseFile(file, sync, LookupType.Layouts, currentFile);
|
|
7753
|
+
return new Parser(this).parseFile(file, sync, exports.LookupType.Layouts, currentFile);
|
|
6863
7754
|
};
|
|
6864
7755
|
Liquid.prototype._parseFile = function (file, sync, lookupType, currentFile) {
|
|
6865
7756
|
return new Parser(this).parseFile(file, sync, lookupType, currentFile);
|
|
@@ -6911,7 +7802,7 @@
|
|
|
6911
7802
|
};
|
|
6912
7803
|
Liquid.prototype._evalValue = function (str, scope) {
|
|
6913
7804
|
var value = new Value(str, this);
|
|
6914
|
-
var ctx = scope instanceof Context ? scope : new Context(scope, this.options);
|
|
7805
|
+
var ctx = scope instanceof Context ? scope : new Context(scope, this.options, {}, { liquid: this });
|
|
6915
7806
|
return value.value(ctx);
|
|
6916
7807
|
};
|
|
6917
7808
|
Liquid.prototype.evalValue = function (str, scope) {
|
|
@@ -6927,6 +7818,9 @@
|
|
|
6927
7818
|
Liquid.prototype.registerFilter = function (name, filter) {
|
|
6928
7819
|
this.filters[name] = filter;
|
|
6929
7820
|
};
|
|
7821
|
+
Liquid.prototype.unregisterFilter = function (name) {
|
|
7822
|
+
delete this.filters[name];
|
|
7823
|
+
};
|
|
6930
7824
|
Liquid.prototype.registerTag = function (name, tag) {
|
|
6931
7825
|
this.tags[name] = isFunction(tag) ? tag : createTagClass(tag);
|
|
6932
7826
|
};
|
|
@@ -7102,7 +7996,7 @@
|
|
|
7102
7996
|
}());
|
|
7103
7997
|
|
|
7104
7998
|
/* istanbul ignore file */
|
|
7105
|
-
var version = '10.
|
|
7999
|
+
var version = '10.30.1';
|
|
7106
8000
|
|
|
7107
8001
|
exports.AssertionError = AssertionError;
|
|
7108
8002
|
exports.AssignTag = default_1;
|
|
@@ -7155,6 +8049,7 @@
|
|
|
7155
8049
|
exports.defaultOptions = defaultOptions;
|
|
7156
8050
|
exports.evalQuotedToken = evalQuotedToken;
|
|
7157
8051
|
exports.evalToken = evalToken;
|
|
8052
|
+
exports.evalTokenValue = evalTokenValue;
|
|
7158
8053
|
exports.filters = filters;
|
|
7159
8054
|
exports.isFalsy = isFalsy;
|
|
7160
8055
|
exports.isTruthy = isTruthy;
|