@kosatyi/ejs 0.0.97 → 0.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +778 -645
- package/dist/cjs/bundler.js +28 -22
- package/dist/cjs/element.js +7 -0
- package/dist/cjs/index.js +787 -653
- package/dist/cjs/worker.js +774 -643
- package/dist/esm/browser.js +557 -616
- package/dist/esm/bundler.js +21 -15
- package/dist/esm/element.js +11 -1
- package/dist/esm/index.js +566 -625
- package/dist/esm/worker.js +573 -633
- package/dist/umd/browser.js +996 -863
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/element.js +7 -0
- package/dist/umd/index.js +1030 -896
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +774 -643
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
- package/types/ejs.d.ts +26 -26
- package/types/global.d.ts +4 -0
package/dist/umd/worker.js
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ejs = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
function _assertClassBrand(e, t, n) {
|
|
8
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
9
|
+
throw new TypeError("Private element is not present on this object");
|
|
10
|
+
}
|
|
11
|
+
function _assertThisInitialized(e) {
|
|
12
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13
|
+
return e;
|
|
14
|
+
}
|
|
7
15
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
8
16
|
try {
|
|
9
17
|
var i = n[a](c),
|
|
@@ -29,6 +37,45 @@
|
|
|
29
37
|
});
|
|
30
38
|
};
|
|
31
39
|
}
|
|
40
|
+
function _callSuper(t, o, e) {
|
|
41
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
42
|
+
}
|
|
43
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
44
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
45
|
+
}
|
|
46
|
+
function _classCallCheck(a, n) {
|
|
47
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
48
|
+
}
|
|
49
|
+
function _classPrivateFieldGet2(s, a) {
|
|
50
|
+
return s.get(_assertClassBrand(s, a));
|
|
51
|
+
}
|
|
52
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
53
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
54
|
+
}
|
|
55
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
56
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
57
|
+
}
|
|
58
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
59
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
60
|
+
}
|
|
61
|
+
function _construct(t, e, r) {
|
|
62
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
63
|
+
var o = [null];
|
|
64
|
+
o.push.apply(o, e);
|
|
65
|
+
var p = new (t.bind.apply(t, o))();
|
|
66
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
67
|
+
}
|
|
68
|
+
function _defineProperties(e, r) {
|
|
69
|
+
for (var t = 0; t < r.length; t++) {
|
|
70
|
+
var o = r[t];
|
|
71
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function _createClass(e, r, t) {
|
|
75
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
76
|
+
writable: !1
|
|
77
|
+
}), e;
|
|
78
|
+
}
|
|
32
79
|
function _defineProperty(e, r, t) {
|
|
33
80
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
34
81
|
value: t,
|
|
@@ -37,6 +84,43 @@
|
|
|
37
84
|
writable: !0
|
|
38
85
|
}) : e[r] = t, e;
|
|
39
86
|
}
|
|
87
|
+
function _getPrototypeOf(t) {
|
|
88
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
89
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
90
|
+
}, _getPrototypeOf(t);
|
|
91
|
+
}
|
|
92
|
+
function _inherits(t, e) {
|
|
93
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
94
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
95
|
+
constructor: {
|
|
96
|
+
value: t,
|
|
97
|
+
writable: !0,
|
|
98
|
+
configurable: !0
|
|
99
|
+
}
|
|
100
|
+
}), Object.defineProperty(t, "prototype", {
|
|
101
|
+
writable: !1
|
|
102
|
+
}), e && _setPrototypeOf(t, e);
|
|
103
|
+
}
|
|
104
|
+
function _isNativeFunction(t) {
|
|
105
|
+
try {
|
|
106
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
107
|
+
} catch (n) {
|
|
108
|
+
return "function" == typeof t;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function _isNativeReflectConstruct() {
|
|
112
|
+
try {
|
|
113
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
114
|
+
} catch (t) {}
|
|
115
|
+
return (_isNativeReflectConstruct = function () {
|
|
116
|
+
return !!t;
|
|
117
|
+
})();
|
|
118
|
+
}
|
|
119
|
+
function _possibleConstructorReturn(t, e) {
|
|
120
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
121
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
122
|
+
return _assertThisInitialized(t);
|
|
123
|
+
}
|
|
40
124
|
function _regeneratorRuntime() {
|
|
41
125
|
_regeneratorRuntime = function () {
|
|
42
126
|
return e;
|
|
@@ -338,20 +422,47 @@
|
|
|
338
422
|
}
|
|
339
423
|
}, e;
|
|
340
424
|
}
|
|
425
|
+
function _setPrototypeOf(t, e) {
|
|
426
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
427
|
+
return t.__proto__ = e, t;
|
|
428
|
+
}, _setPrototypeOf(t, e);
|
|
429
|
+
}
|
|
341
430
|
function _toPrimitive(t, r) {
|
|
342
431
|
if ("object" != typeof t || !t) return t;
|
|
343
432
|
var e = t[Symbol.toPrimitive];
|
|
344
433
|
if (void 0 !== e) {
|
|
345
|
-
var i = e.call(t, r
|
|
434
|
+
var i = e.call(t, r);
|
|
346
435
|
if ("object" != typeof i) return i;
|
|
347
436
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
348
437
|
}
|
|
349
|
-
return (
|
|
438
|
+
return (String )(t);
|
|
350
439
|
}
|
|
351
440
|
function _toPropertyKey(t) {
|
|
352
441
|
var i = _toPrimitive(t, "string");
|
|
353
442
|
return "symbol" == typeof i ? i : i + "";
|
|
354
443
|
}
|
|
444
|
+
function _wrapNativeSuper(t) {
|
|
445
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
446
|
+
return _wrapNativeSuper = function (t) {
|
|
447
|
+
if (null === t || !_isNativeFunction(t)) return t;
|
|
448
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
449
|
+
if (void 0 !== r) {
|
|
450
|
+
if (r.has(t)) return r.get(t);
|
|
451
|
+
r.set(t, Wrapper);
|
|
452
|
+
}
|
|
453
|
+
function Wrapper() {
|
|
454
|
+
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
455
|
+
}
|
|
456
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
457
|
+
constructor: {
|
|
458
|
+
value: Wrapper,
|
|
459
|
+
enumerable: !1,
|
|
460
|
+
writable: !0,
|
|
461
|
+
configurable: !0
|
|
462
|
+
}
|
|
463
|
+
}), _setPrototypeOf(Wrapper, t);
|
|
464
|
+
}, _wrapNativeSuper(t);
|
|
465
|
+
}
|
|
355
466
|
|
|
356
467
|
var typeProp = function typeProp() {
|
|
357
468
|
var args = [].slice.call(arguments);
|
|
@@ -417,6 +528,9 @@
|
|
|
417
528
|
var instanceOf = function instanceOf(object, instance) {
|
|
418
529
|
return Boolean(object instanceof instance);
|
|
419
530
|
};
|
|
531
|
+
var assertInstanceOf = function assertInstanceOf(object, instance) {
|
|
532
|
+
if (instanceOf(object, instance) === false) throw new TypeError("".concat(object, " in not instance of ").concat(instance));
|
|
533
|
+
};
|
|
420
534
|
var getPath = function getPath(context, name, strict) {
|
|
421
535
|
var data = context;
|
|
422
536
|
var chunks = String(name).split('.');
|
|
@@ -437,6 +551,14 @@
|
|
|
437
551
|
}
|
|
438
552
|
return [data, prop];
|
|
439
553
|
};
|
|
554
|
+
var bindContext = function bindContext(object) {
|
|
555
|
+
var methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
556
|
+
methods.forEach(function (name) {
|
|
557
|
+
if (name in object) {
|
|
558
|
+
object[name] = object[name].bind(object);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
};
|
|
440
562
|
var ext = function ext(path, defaults) {
|
|
441
563
|
var ext = path.split('.').pop();
|
|
442
564
|
if (ext !== defaults) {
|
|
@@ -499,9 +621,27 @@
|
|
|
499
621
|
}
|
|
500
622
|
});
|
|
501
623
|
};
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
*
|
|
627
|
+
* @param object
|
|
628
|
+
* @param prop
|
|
629
|
+
* @return {boolean}
|
|
630
|
+
*/
|
|
502
631
|
var hasProp = function hasProp(object, prop) {
|
|
503
632
|
return object && object.hasOwnProperty(prop);
|
|
504
633
|
};
|
|
634
|
+
var matchTokens = function matchTokens(regex, text, callback) {
|
|
635
|
+
var index = 0;
|
|
636
|
+
text.replace(regex, function () {
|
|
637
|
+
var params = [].slice.call(arguments, 0, -1);
|
|
638
|
+
var offset = params.pop();
|
|
639
|
+
var match = params.shift();
|
|
640
|
+
callback(params, index, offset);
|
|
641
|
+
index = offset + match.length;
|
|
642
|
+
return match;
|
|
643
|
+
});
|
|
644
|
+
};
|
|
505
645
|
|
|
506
646
|
var defaults = {};
|
|
507
647
|
defaults["export"] = 'ejsPrecompiled';
|
|
@@ -518,6 +658,7 @@
|
|
|
518
658
|
defaults.vars = {
|
|
519
659
|
SCOPE: 'ejs',
|
|
520
660
|
COMPONENT: 'ui',
|
|
661
|
+
ELEMENT: 'el',
|
|
521
662
|
EXTEND: '$$e',
|
|
522
663
|
BUFFER: '$$a',
|
|
523
664
|
LAYOUT: '$$l',
|
|
@@ -547,183 +688,219 @@
|
|
|
547
688
|
};
|
|
548
689
|
|
|
549
690
|
var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
691
|
+
var _enabled = /*#__PURE__*/new WeakMap();
|
|
692
|
+
var _list = /*#__PURE__*/new WeakMap();
|
|
693
|
+
var Cache = /*#__PURE__*/function () {
|
|
694
|
+
function Cache(config) {
|
|
695
|
+
_classCallCheck(this, Cache);
|
|
696
|
+
_classPrivateFieldInitSpec(this, _enabled, true);
|
|
697
|
+
_classPrivateFieldInitSpec(this, _list, {});
|
|
698
|
+
this.configure(config);
|
|
699
|
+
}
|
|
700
|
+
return _createClass(Cache, [{
|
|
701
|
+
key: "load",
|
|
702
|
+
value: function load(data) {
|
|
703
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
704
|
+
extend(_classPrivateFieldGet2(_list, this), data || {});
|
|
705
|
+
}
|
|
560
706
|
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
extend(cache.list, data || {});
|
|
707
|
+
}, {
|
|
708
|
+
key: "get",
|
|
709
|
+
value: function get(key) {
|
|
710
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
711
|
+
return _classPrivateFieldGet2(_list, this)[key];
|
|
712
|
+
}
|
|
568
713
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
714
|
+
}, {
|
|
715
|
+
key: "set",
|
|
716
|
+
value: function set(key, value) {
|
|
717
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
718
|
+
_classPrivateFieldGet2(_list, this)[key] = value;
|
|
719
|
+
}
|
|
574
720
|
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
721
|
+
}, {
|
|
722
|
+
key: "exist",
|
|
723
|
+
value: function exist(key) {
|
|
724
|
+
return hasProp(_classPrivateFieldGet2(_list, this), key);
|
|
579
725
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
|
|
726
|
+
}, {
|
|
727
|
+
key: "clear",
|
|
728
|
+
value: function clear() {
|
|
729
|
+
_classPrivateFieldSet2(_list, this, {});
|
|
730
|
+
}
|
|
731
|
+
}, {
|
|
732
|
+
key: "remove",
|
|
733
|
+
value: function remove(key) {
|
|
734
|
+
delete _classPrivateFieldGet2(_list, this)[key];
|
|
735
|
+
}
|
|
736
|
+
}, {
|
|
737
|
+
key: "resolve",
|
|
738
|
+
value: function resolve(key) {
|
|
739
|
+
return Promise.resolve(this.get(key));
|
|
740
|
+
}
|
|
741
|
+
}, {
|
|
742
|
+
key: "configure",
|
|
743
|
+
value: function configure(config) {
|
|
744
|
+
_classPrivateFieldSet2(_enabled, this, config.cache);
|
|
745
|
+
if (isNode() === false) {
|
|
746
|
+
this.load(global[config["export"]]);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}]);
|
|
750
|
+
}();
|
|
592
751
|
|
|
593
|
-
var
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
752
|
+
var _config$1 = /*#__PURE__*/new WeakMap();
|
|
753
|
+
var _symbols = /*#__PURE__*/new WeakMap();
|
|
754
|
+
var Compiler = /*#__PURE__*/function () {
|
|
755
|
+
function Compiler(config) {
|
|
756
|
+
_classCallCheck(this, Compiler);
|
|
757
|
+
_classPrivateFieldInitSpec(this, _config$1, {});
|
|
758
|
+
_classPrivateFieldInitSpec(this, _symbols, [{
|
|
759
|
+
symbol: '-',
|
|
760
|
+
format: function format(value) {
|
|
761
|
+
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
|
|
762
|
+
}
|
|
763
|
+
}, {
|
|
764
|
+
symbol: '=',
|
|
765
|
+
format: function format(value) {
|
|
766
|
+
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
|
|
767
|
+
}
|
|
768
|
+
}, {
|
|
769
|
+
symbol: '#',
|
|
770
|
+
format: function format(value) {
|
|
771
|
+
return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
|
|
772
|
+
}
|
|
773
|
+
}, {
|
|
774
|
+
symbol: '',
|
|
775
|
+
format: function format(value) {
|
|
776
|
+
return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
|
|
777
|
+
}
|
|
778
|
+
}]);
|
|
779
|
+
this.configure(config);
|
|
612
780
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
compiler.vars = config.vars;
|
|
633
|
-
compiler.globalHelpers = config.globalHelpers;
|
|
634
|
-
compiler.matches = [];
|
|
635
|
-
compiler.formats = [];
|
|
636
|
-
compiler.slurp = {
|
|
637
|
-
match: '[\s\t\n]*',
|
|
638
|
-
start: [compiler.token.start, '_'],
|
|
639
|
-
end: ['_', compiler.token.end]
|
|
640
|
-
};
|
|
641
|
-
tagList.forEach(function (item) {
|
|
642
|
-
compiler.matches.push(compiler.token.start.concat(item.symbol).concat(compiler.token.regex).concat(compiler.token.end));
|
|
643
|
-
compiler.formats.push(item.format.bind(compiler.vars));
|
|
644
|
-
});
|
|
645
|
-
compiler.regex = new RegExp(compiler.matches.join('|').concat('|$'), 'g');
|
|
646
|
-
compiler.slurpStart = new RegExp([compiler.slurp.match, compiler.slurp.start.join('')].join(''), 'gm');
|
|
647
|
-
compiler.slurpEnd = new RegExp([compiler.slurp.end.join(''), compiler.slurp.match].join(''), 'gm');
|
|
648
|
-
};
|
|
649
|
-
this.compile = function (content, path) {
|
|
650
|
-
var _compiler$vars = compiler.vars,
|
|
651
|
-
SCOPE = _compiler$vars.SCOPE,
|
|
652
|
-
SAFE = _compiler$vars.SAFE,
|
|
653
|
-
BUFFER = _compiler$vars.BUFFER,
|
|
654
|
-
COMPONENT = _compiler$vars.COMPONENT;
|
|
655
|
-
var GLOBALS = compiler.globalHelpers;
|
|
656
|
-
content = String(content);
|
|
657
|
-
if (compiler.rmWhitespace) {
|
|
658
|
-
content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
659
|
-
}
|
|
660
|
-
content = content.replace(compiler.slurpStart, compiler.token.start).replace(compiler.slurpEnd, compiler.token.end);
|
|
661
|
-
var source = "".concat(BUFFER, "('");
|
|
662
|
-
matchTokens(compiler.regex, content, function (params, index, offset) {
|
|
663
|
-
source += symbols(content.slice(index, offset));
|
|
664
|
-
params.forEach(function (value, index) {
|
|
665
|
-
if (value) {
|
|
666
|
-
source += compiler.formats[index](value);
|
|
667
|
-
}
|
|
781
|
+
return _createClass(Compiler, [{
|
|
782
|
+
key: "configure",
|
|
783
|
+
value: function configure(config) {
|
|
784
|
+
var _this = this;
|
|
785
|
+
_classPrivateFieldGet2(_config$1, this).withObject = config.withObject;
|
|
786
|
+
_classPrivateFieldGet2(_config$1, this).rmWhitespace = config.rmWhitespace;
|
|
787
|
+
_classPrivateFieldGet2(_config$1, this).token = config.token;
|
|
788
|
+
_classPrivateFieldGet2(_config$1, this).vars = config.vars;
|
|
789
|
+
_classPrivateFieldGet2(_config$1, this).globalHelpers = config.globalHelpers;
|
|
790
|
+
_classPrivateFieldGet2(_config$1, this).matches = [];
|
|
791
|
+
_classPrivateFieldGet2(_config$1, this).formats = [];
|
|
792
|
+
_classPrivateFieldGet2(_config$1, this).slurp = {
|
|
793
|
+
match: '[s\t\n]*',
|
|
794
|
+
start: [_classPrivateFieldGet2(_config$1, this).token.start, '_'],
|
|
795
|
+
end: ['_', _classPrivateFieldGet2(_config$1, this).token.end]
|
|
796
|
+
};
|
|
797
|
+
_classPrivateFieldGet2(_symbols, this).forEach(function (item) {
|
|
798
|
+
_classPrivateFieldGet2(_config$1, _this).matches.push(_classPrivateFieldGet2(_config$1, _this).token.start.concat(item.symbol).concat(_classPrivateFieldGet2(_config$1, _this).token.regex).concat(_classPrivateFieldGet2(_config$1, _this).token.end));
|
|
799
|
+
_classPrivateFieldGet2(_config$1, _this).formats.push(item.format.bind(_classPrivateFieldGet2(_config$1, _this).vars));
|
|
668
800
|
});
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
if (compiler.withObject) {
|
|
673
|
-
source = "with(".concat(SCOPE, "){").concat(source, "}");
|
|
674
|
-
}
|
|
675
|
-
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
676
|
-
source += "\n//# sourceURL=".concat(path);
|
|
677
|
-
var result = null;
|
|
678
|
-
var params = [SCOPE, COMPONENT, BUFFER, SAFE].concat(GLOBALS);
|
|
679
|
-
try {
|
|
680
|
-
result = Function.apply(null, params.concat(source));
|
|
681
|
-
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
682
|
-
} catch (e) {
|
|
683
|
-
e.filename = path;
|
|
684
|
-
e.source = source;
|
|
685
|
-
throw e;
|
|
686
|
-
}
|
|
687
|
-
return result;
|
|
688
|
-
};
|
|
689
|
-
this.configure(config);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
function Template(config, cache, compiler) {
|
|
693
|
-
if (instanceOf(this, Template) === false) return new Template(config, cache, compiler);
|
|
694
|
-
if (instanceOf(cache, Cache) === false) throw new TypeError('cache is not instance of Cache');
|
|
695
|
-
if (instanceOf(compiler, Compiler) === false) throw new TypeError('compiler is not instance of Compiler');
|
|
696
|
-
var template = {};
|
|
697
|
-
var result = function result(template, content) {
|
|
698
|
-
cache.set(template, content);
|
|
699
|
-
return content;
|
|
700
|
-
};
|
|
701
|
-
var resolve = function resolve(path) {
|
|
702
|
-
return template.resolver(template.path, path);
|
|
703
|
-
};
|
|
704
|
-
var compile = function compile(content, template) {
|
|
705
|
-
if (isFunction(content)) {
|
|
706
|
-
return content;
|
|
707
|
-
} else {
|
|
708
|
-
return compiler.compile(content, template);
|
|
801
|
+
_classPrivateFieldGet2(_config$1, this).regex = new RegExp(_classPrivateFieldGet2(_config$1, this).matches.join('|').concat('|$'), 'g');
|
|
802
|
+
_classPrivateFieldGet2(_config$1, this).slurpStart = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.match, _classPrivateFieldGet2(_config$1, this).slurp.start.join('')].join(''), 'gm');
|
|
803
|
+
_classPrivateFieldGet2(_config$1, this).slurpEnd = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.end.join(''), _classPrivateFieldGet2(_config$1, this).slurp.match].join(''), 'gm');
|
|
709
804
|
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
805
|
+
}, {
|
|
806
|
+
key: "compile",
|
|
807
|
+
value: function compile(content, path) {
|
|
808
|
+
var _this2 = this;
|
|
809
|
+
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config$1, this).vars,
|
|
810
|
+
SCOPE = _classPrivateFieldGet2$1.SCOPE,
|
|
811
|
+
SAFE = _classPrivateFieldGet2$1.SAFE,
|
|
812
|
+
BUFFER = _classPrivateFieldGet2$1.BUFFER,
|
|
813
|
+
COMPONENT = _classPrivateFieldGet2$1.COMPONENT,
|
|
814
|
+
ELEMENT = _classPrivateFieldGet2$1.ELEMENT;
|
|
815
|
+
var GLOBALS = _classPrivateFieldGet2(_config$1, this).globalHelpers;
|
|
816
|
+
if (_classPrivateFieldGet2(_config$1, this).rmWhitespace) {
|
|
817
|
+
content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
818
|
+
}
|
|
819
|
+
content = String(content).replace(_classPrivateFieldGet2(_config$1, this).slurpStart, _classPrivateFieldGet2(_config$1, this).token.start).replace(_classPrivateFieldGet2(_config$1, this).slurpEnd, _classPrivateFieldGet2(_config$1, this).token.end);
|
|
820
|
+
var source = "".concat(BUFFER, "('");
|
|
821
|
+
matchTokens(_classPrivateFieldGet2(_config$1, this).regex, content, function (params, index, offset) {
|
|
822
|
+
source += symbols(content.slice(index, offset));
|
|
823
|
+
params.forEach(function (value, index) {
|
|
824
|
+
if (value) {
|
|
825
|
+
source += _classPrivateFieldGet2(_config$1, _this2).formats[index](value);
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
source += "');";
|
|
830
|
+
source = "try{".concat(source, "}catch(e){return ").concat(BUFFER, ".error(e)}");
|
|
831
|
+
if (_classPrivateFieldGet2(_config$1, this).withObject) {
|
|
832
|
+
source = "with(".concat(SCOPE, "){").concat(source, "}");
|
|
833
|
+
}
|
|
834
|
+
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
835
|
+
source += "\n//# sourceURL=".concat(path);
|
|
836
|
+
var result = null;
|
|
837
|
+
var params = [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT].concat(GLOBALS);
|
|
838
|
+
try {
|
|
839
|
+
result = Function.apply(null, params.concat(source));
|
|
840
|
+
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
841
|
+
} catch (e) {
|
|
842
|
+
e.filename = path;
|
|
843
|
+
e.source = source;
|
|
844
|
+
throw e;
|
|
845
|
+
}
|
|
846
|
+
return result;
|
|
716
847
|
}
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
848
|
+
}]);
|
|
849
|
+
}();
|
|
850
|
+
|
|
851
|
+
var _path = /*#__PURE__*/new WeakMap();
|
|
852
|
+
var _cache$1 = /*#__PURE__*/new WeakMap();
|
|
853
|
+
var _compiler$1 = /*#__PURE__*/new WeakMap();
|
|
854
|
+
var _resolver = /*#__PURE__*/new WeakMap();
|
|
855
|
+
var _Template_brand = /*#__PURE__*/new WeakSet();
|
|
856
|
+
var Template = /*#__PURE__*/function () {
|
|
857
|
+
function Template(config, cache, compiler) {
|
|
858
|
+
_classCallCheck(this, Template);
|
|
859
|
+
_classPrivateMethodInitSpec(this, _Template_brand);
|
|
860
|
+
_classPrivateFieldInitSpec(this, _path, void 0);
|
|
861
|
+
_classPrivateFieldInitSpec(this, _cache$1, void 0);
|
|
862
|
+
_classPrivateFieldInitSpec(this, _compiler$1, void 0);
|
|
863
|
+
_classPrivateFieldInitSpec(this, _resolver, void 0);
|
|
864
|
+
assertInstanceOf(cache, Cache);
|
|
865
|
+
assertInstanceOf(compiler, Compiler);
|
|
866
|
+
_classPrivateFieldSet2(_cache$1, this, cache);
|
|
867
|
+
_classPrivateFieldSet2(_compiler$1, this, compiler);
|
|
868
|
+
this.configure(config);
|
|
869
|
+
}
|
|
870
|
+
return _createClass(Template, [{
|
|
871
|
+
key: "configure",
|
|
872
|
+
value: function configure(config) {
|
|
873
|
+
_classPrivateFieldSet2(_path, this, config.path);
|
|
874
|
+
if (isFunction(config.resolver)) {
|
|
875
|
+
_classPrivateFieldSet2(_resolver, this, config.resolver);
|
|
876
|
+
}
|
|
721
877
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
878
|
+
}, {
|
|
879
|
+
key: "get",
|
|
880
|
+
value: function get(template) {
|
|
881
|
+
var _this = this;
|
|
882
|
+
if (_classPrivateFieldGet2(_cache$1, this).exist(template)) {
|
|
883
|
+
return _classPrivateFieldGet2(_cache$1, this).resolve(template);
|
|
884
|
+
}
|
|
885
|
+
return _assertClassBrand(_Template_brand, this, _resolve).call(this, template).then(function (content) {
|
|
886
|
+
return _assertClassBrand(_Template_brand, _this, _result).call(_this, template, _assertClassBrand(_Template_brand, _this, _compile).call(_this, content, template));
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
}]);
|
|
890
|
+
}();
|
|
891
|
+
function _resolve(path) {
|
|
892
|
+
return _classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path, this), path);
|
|
893
|
+
}
|
|
894
|
+
function _result(template, content) {
|
|
895
|
+
_classPrivateFieldGet2(_cache$1, this).set(template, content);
|
|
896
|
+
return content;
|
|
897
|
+
}
|
|
898
|
+
function _compile(content, template) {
|
|
899
|
+
if (isFunction(content)) {
|
|
900
|
+
return content;
|
|
901
|
+
} else {
|
|
902
|
+
return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
|
|
903
|
+
}
|
|
727
904
|
}
|
|
728
905
|
|
|
729
906
|
var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
@@ -751,82 +928,61 @@
|
|
|
751
928
|
return result.join('');
|
|
752
929
|
};
|
|
753
930
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
Object.assign(TemplateNotFound.prototype, {
|
|
810
|
-
code: 404
|
|
811
|
-
});
|
|
812
|
-
/**
|
|
813
|
-
* @extends TemplateError
|
|
814
|
-
* @param {string} message
|
|
815
|
-
* @constructor
|
|
816
|
-
*/
|
|
817
|
-
function TemplateSyntaxError(message) {
|
|
818
|
-
TemplateError.call(this);
|
|
819
|
-
this.name = 'TemplateSyntaxError';
|
|
820
|
-
this.message = message;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
*
|
|
825
|
-
*/
|
|
826
|
-
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
827
|
-
Object.assign(TemplateSyntaxError.prototype, {
|
|
828
|
-
code: 500
|
|
829
|
-
});
|
|
931
|
+
var TemplateError = /*#__PURE__*/function (_Error) {
|
|
932
|
+
function TemplateError(message) {
|
|
933
|
+
var _this;
|
|
934
|
+
_classCallCheck(this, TemplateError);
|
|
935
|
+
_this = _callSuper(this, TemplateError);
|
|
936
|
+
_defineProperty(_this, "code", 0);
|
|
937
|
+
_this.message = message;
|
|
938
|
+
return _this;
|
|
939
|
+
}
|
|
940
|
+
_inherits(TemplateError, _Error);
|
|
941
|
+
return _createClass(TemplateError, [{
|
|
942
|
+
key: "getCode",
|
|
943
|
+
value: function getCode() {
|
|
944
|
+
return this.code;
|
|
945
|
+
}
|
|
946
|
+
}, {
|
|
947
|
+
key: "getMessage",
|
|
948
|
+
value: function getMessage() {
|
|
949
|
+
return this.message;
|
|
950
|
+
}
|
|
951
|
+
}, {
|
|
952
|
+
key: "toString",
|
|
953
|
+
value: function toString() {
|
|
954
|
+
return this.getMessage();
|
|
955
|
+
}
|
|
956
|
+
}]);
|
|
957
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
958
|
+
var TemplateNotFound = /*#__PURE__*/function (_TemplateError2) {
|
|
959
|
+
function TemplateNotFound() {
|
|
960
|
+
var _this2;
|
|
961
|
+
_classCallCheck(this, TemplateNotFound);
|
|
962
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
963
|
+
args[_key] = arguments[_key];
|
|
964
|
+
}
|
|
965
|
+
_this2 = _callSuper(this, TemplateNotFound, [].concat(args));
|
|
966
|
+
_defineProperty(_this2, "code", 404);
|
|
967
|
+
return _this2;
|
|
968
|
+
}
|
|
969
|
+
_inherits(TemplateNotFound, _TemplateError2);
|
|
970
|
+
return _createClass(TemplateNotFound);
|
|
971
|
+
}(TemplateError);
|
|
972
|
+
var TemplateSyntaxError = /*#__PURE__*/function (_TemplateError3) {
|
|
973
|
+
function TemplateSyntaxError() {
|
|
974
|
+
var _this3;
|
|
975
|
+
_classCallCheck(this, TemplateSyntaxError);
|
|
976
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
977
|
+
args[_key2] = arguments[_key2];
|
|
978
|
+
}
|
|
979
|
+
_this3 = _callSuper(this, TemplateSyntaxError, [].concat(args));
|
|
980
|
+
_defineProperty(_this3, "code", 500);
|
|
981
|
+
return _this3;
|
|
982
|
+
}
|
|
983
|
+
_inherits(TemplateSyntaxError, _TemplateError3);
|
|
984
|
+
return _createClass(TemplateSyntaxError);
|
|
985
|
+
}(TemplateError);
|
|
830
986
|
|
|
831
987
|
function resolve(list) {
|
|
832
988
|
return Promise.all(list || []).then(function (list) {
|
|
@@ -838,12 +994,17 @@
|
|
|
838
994
|
function reject(error) {
|
|
839
995
|
return Promise.reject(new TemplateSyntaxError(error.message));
|
|
840
996
|
}
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
*
|
|
1000
|
+
* @return {buffer}
|
|
1001
|
+
*/
|
|
841
1002
|
function createBuffer() {
|
|
842
1003
|
var store = [],
|
|
843
1004
|
array = [];
|
|
844
|
-
function buffer(value) {
|
|
1005
|
+
var buffer = function buffer(value) {
|
|
845
1006
|
array.push(value);
|
|
846
|
-
}
|
|
1007
|
+
};
|
|
847
1008
|
buffer.start = function () {
|
|
848
1009
|
array = [];
|
|
849
1010
|
};
|
|
@@ -865,420 +1026,391 @@
|
|
|
865
1026
|
return buffer;
|
|
866
1027
|
}
|
|
867
1028
|
|
|
868
|
-
function
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
configurable: false,
|
|
915
|
-
enumerable: false
|
|
916
|
-
}), EXTEND, {
|
|
917
|
-
value: false,
|
|
918
|
-
writable: true,
|
|
919
|
-
configurable: false,
|
|
920
|
-
enumerable: false
|
|
921
|
-
}), "getMacro", {
|
|
922
|
-
value: function value() {
|
|
923
|
-
return this[MACRO];
|
|
924
|
-
},
|
|
925
|
-
writable: false,
|
|
926
|
-
configurable: false,
|
|
927
|
-
enumerable: false
|
|
928
|
-
}), "getBuffer", {
|
|
929
|
-
value: function value() {
|
|
930
|
-
return this[BUFFER];
|
|
931
|
-
},
|
|
932
|
-
writable: false,
|
|
933
|
-
configurable: false,
|
|
934
|
-
enumerable: false
|
|
935
|
-
}), "getComponent", {
|
|
936
|
-
value: function value() {
|
|
937
|
-
var context = this;
|
|
938
|
-
if (COMPONENT in context) {
|
|
939
|
-
return function () {
|
|
940
|
-
return context[COMPONENT].apply(context, arguments);
|
|
941
|
-
};
|
|
942
|
-
}
|
|
1029
|
+
var createContextScope = function createContextScope(config, methods) {
|
|
1030
|
+
var _Object$definePropert;
|
|
1031
|
+
var _config$vars = config.vars,
|
|
1032
|
+
BLOCKS = _config$vars.BLOCKS,
|
|
1033
|
+
MACRO = _config$vars.MACRO,
|
|
1034
|
+
EXTEND = _config$vars.EXTEND,
|
|
1035
|
+
LAYOUT = _config$vars.LAYOUT,
|
|
1036
|
+
BUFFER = _config$vars.BUFFER,
|
|
1037
|
+
SAFE = _config$vars.SAFE,
|
|
1038
|
+
SCOPE = _config$vars.SCOPE,
|
|
1039
|
+
COMPONENT = _config$vars.COMPONENT,
|
|
1040
|
+
ELEMENT = _config$vars.ELEMENT;
|
|
1041
|
+
/**
|
|
1042
|
+
* @name ContextScope
|
|
1043
|
+
* @param data
|
|
1044
|
+
* @constructor
|
|
1045
|
+
*/
|
|
1046
|
+
function ContextScope(data) {
|
|
1047
|
+
this[BLOCKS] = {};
|
|
1048
|
+
this[MACRO] = {};
|
|
1049
|
+
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
1050
|
+
}
|
|
1051
|
+
Object.assign(ContextScope.prototype, methods);
|
|
1052
|
+
Object.defineProperties(ContextScope.prototype, (_Object$definePropert = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, BUFFER, {
|
|
1053
|
+
value: createBuffer()
|
|
1054
|
+
}), BLOCKS, {
|
|
1055
|
+
value: {},
|
|
1056
|
+
writable: true
|
|
1057
|
+
}), MACRO, {
|
|
1058
|
+
value: {},
|
|
1059
|
+
writable: true
|
|
1060
|
+
}), LAYOUT, {
|
|
1061
|
+
value: false,
|
|
1062
|
+
writable: true
|
|
1063
|
+
}), EXTEND, {
|
|
1064
|
+
value: false,
|
|
1065
|
+
writable: true
|
|
1066
|
+
}), "useSafeValue", {
|
|
1067
|
+
get: function get() {
|
|
1068
|
+
return safeValue;
|
|
1069
|
+
}
|
|
1070
|
+
}), "useComponent", {
|
|
1071
|
+
get: function get() {
|
|
1072
|
+
if (isFunction(this[COMPONENT])) {
|
|
1073
|
+
return this[COMPONENT].bind(this);
|
|
1074
|
+
} else {
|
|
943
1075
|
return function () {
|
|
944
|
-
|
|
1076
|
+
throw new Error("".concat(COMPONENT, " must be a function"));
|
|
945
1077
|
};
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
},
|
|
954
|
-
writable: false,
|
|
955
|
-
configurable: false,
|
|
956
|
-
enumerable: false
|
|
957
|
-
}), "setExtend", {
|
|
958
|
-
value: function value(_value) {
|
|
959
|
-
this[EXTEND] = _value;
|
|
960
|
-
},
|
|
961
|
-
writable: false,
|
|
962
|
-
configurable: false,
|
|
963
|
-
enumerable: false
|
|
964
|
-
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getExtend", {
|
|
965
|
-
value: function value() {
|
|
966
|
-
return this[EXTEND];
|
|
967
|
-
},
|
|
968
|
-
writable: false,
|
|
969
|
-
configurable: false,
|
|
970
|
-
enumerable: false
|
|
971
|
-
}), "setLayout", {
|
|
972
|
-
value: function value(layout) {
|
|
973
|
-
this[LAYOUT] = layout;
|
|
974
|
-
},
|
|
975
|
-
writable: false,
|
|
976
|
-
configurable: false,
|
|
977
|
-
enumerable: false
|
|
978
|
-
}), "getLayout", {
|
|
979
|
-
value: function value() {
|
|
980
|
-
return this[LAYOUT];
|
|
981
|
-
},
|
|
982
|
-
writable: false,
|
|
983
|
-
configurable: false,
|
|
984
|
-
enumerable: false
|
|
985
|
-
}), "clone", {
|
|
986
|
-
value: function value(exclude_blocks) {
|
|
987
|
-
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
988
|
-
if (exclude_blocks === true) {
|
|
989
|
-
filter.push(BLOCKS);
|
|
990
|
-
}
|
|
991
|
-
return omit(this, filter);
|
|
992
|
-
},
|
|
993
|
-
writable: false,
|
|
994
|
-
configurable: false,
|
|
995
|
-
enumerable: false
|
|
996
|
-
}), "extend", {
|
|
997
|
-
value: function value(layout) {
|
|
998
|
-
this.setExtend(true);
|
|
999
|
-
this.setLayout(layout);
|
|
1000
|
-
},
|
|
1001
|
-
writable: false,
|
|
1002
|
-
configurable: false,
|
|
1003
|
-
enumerable: false
|
|
1004
|
-
}), "echo", {
|
|
1005
|
-
value: function value(layout) {
|
|
1006
|
-
var buffer = this.getBuffer();
|
|
1007
|
-
var params = [].slice.call(arguments);
|
|
1008
|
-
params.forEach(buffer);
|
|
1009
|
-
},
|
|
1010
|
-
writable: false,
|
|
1011
|
-
configurable: false,
|
|
1012
|
-
enumerable: false
|
|
1013
|
-
}), "fn", {
|
|
1014
|
-
value: function value(callback) {
|
|
1015
|
-
var buffer = this.getBuffer();
|
|
1016
|
-
var context = this;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}), "useElement", {
|
|
1081
|
+
get: function get() {
|
|
1082
|
+
if (isFunction(this[ELEMENT])) {
|
|
1083
|
+
return this[ELEMENT].bind(this);
|
|
1084
|
+
} else {
|
|
1017
1085
|
return function () {
|
|
1086
|
+
throw new Error("".concat(ELEMENT, " must be a function"));
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}), "getMacro", {
|
|
1091
|
+
value: function value() {
|
|
1092
|
+
return this[MACRO];
|
|
1093
|
+
}
|
|
1094
|
+
}), "getBuffer", {
|
|
1095
|
+
value: function value() {
|
|
1096
|
+
return this[BUFFER];
|
|
1097
|
+
}
|
|
1098
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getBlocks", {
|
|
1099
|
+
value: function value() {
|
|
1100
|
+
return this[BLOCKS];
|
|
1101
|
+
}
|
|
1102
|
+
}), "setExtend", {
|
|
1103
|
+
value: function value(_value) {
|
|
1104
|
+
this[EXTEND] = _value;
|
|
1105
|
+
}
|
|
1106
|
+
}), "getExtend", {
|
|
1107
|
+
value: function value() {
|
|
1108
|
+
return this[EXTEND];
|
|
1109
|
+
}
|
|
1110
|
+
}), "setLayout", {
|
|
1111
|
+
value: function value(layout) {
|
|
1112
|
+
this[LAYOUT] = layout;
|
|
1113
|
+
}
|
|
1114
|
+
}), "getLayout", {
|
|
1115
|
+
value: function value() {
|
|
1116
|
+
return this[LAYOUT];
|
|
1117
|
+
}
|
|
1118
|
+
}), "clone", {
|
|
1119
|
+
value: function value(exclude_blocks) {
|
|
1120
|
+
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
1121
|
+
if (exclude_blocks === true) {
|
|
1122
|
+
filter.push(BLOCKS);
|
|
1123
|
+
}
|
|
1124
|
+
return omit(this, filter);
|
|
1125
|
+
}
|
|
1126
|
+
}), "extend", {
|
|
1127
|
+
value: function value(layout) {
|
|
1128
|
+
this.setExtend(true);
|
|
1129
|
+
this.setLayout(layout);
|
|
1130
|
+
}
|
|
1131
|
+
}), "echo", {
|
|
1132
|
+
value: function value(layout) {
|
|
1133
|
+
var buffer = this.getBuffer();
|
|
1134
|
+
var params = [].slice.call(arguments);
|
|
1135
|
+
params.forEach(buffer);
|
|
1136
|
+
}
|
|
1137
|
+
}), "fn", {
|
|
1138
|
+
value: function value(callback) {
|
|
1139
|
+
var buffer = this.getBuffer();
|
|
1140
|
+
var context = this;
|
|
1141
|
+
return function () {
|
|
1142
|
+
if (isFunction(callback)) {
|
|
1018
1143
|
buffer.backup();
|
|
1019
|
-
|
|
1020
|
-
callback.apply(context, arguments);
|
|
1021
|
-
}
|
|
1144
|
+
buffer(callback.apply(context, arguments));
|
|
1022
1145
|
return buffer.restore();
|
|
1023
|
-
};
|
|
1024
|
-
},
|
|
1025
|
-
writable: false,
|
|
1026
|
-
configurable: false,
|
|
1027
|
-
enumerable: false
|
|
1028
|
-
}), "get", {
|
|
1029
|
-
value: function value(name, defaults) {
|
|
1030
|
-
var path = getPath(this, name, true);
|
|
1031
|
-
var result = path.shift();
|
|
1032
|
-
var prop = path.pop();
|
|
1033
|
-
return hasProp(result, prop) ? result[prop] : defaults;
|
|
1034
|
-
},
|
|
1035
|
-
writable: true,
|
|
1036
|
-
configurable: true,
|
|
1037
|
-
enumerable: false
|
|
1038
|
-
}), "set", {
|
|
1039
|
-
value: function value(name, _value2) {
|
|
1040
|
-
var path = getPath(this, name, false);
|
|
1041
|
-
var result = path.shift();
|
|
1042
|
-
var prop = path.pop();
|
|
1043
|
-
if (this.getExtend() && hasProp(result, prop)) {
|
|
1044
|
-
return result[prop];
|
|
1045
|
-
}
|
|
1046
|
-
return result[prop] = _value2;
|
|
1047
|
-
},
|
|
1048
|
-
writable: false,
|
|
1049
|
-
configurable: false,
|
|
1050
|
-
enumerable: false
|
|
1051
|
-
}), "macro", {
|
|
1052
|
-
value: function value(name, callback) {
|
|
1053
|
-
var list = this.getMacro();
|
|
1054
|
-
var macro = this.fn(callback);
|
|
1055
|
-
var context = this;
|
|
1056
|
-
list[name] = function () {
|
|
1057
|
-
return context.echo(macro.apply(undefined, arguments));
|
|
1058
|
-
};
|
|
1059
|
-
},
|
|
1060
|
-
writable: false,
|
|
1061
|
-
configurable: false,
|
|
1062
|
-
enumerable: false
|
|
1063
|
-
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
|
|
1064
|
-
value: function value(name) {
|
|
1065
|
-
var list = this.getMacro();
|
|
1066
|
-
var macro = list[name];
|
|
1067
|
-
var params = [].slice.call(arguments, 1);
|
|
1068
|
-
if (isFunction(macro)) {
|
|
1069
|
-
return macro.apply(macro, params);
|
|
1070
1146
|
}
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
var context = cx === false ? {} : this.clone(true);
|
|
1111
|
-
var params = extend(context, data || {});
|
|
1112
|
-
var promise = this.render(path, params);
|
|
1113
|
-
this.echo(promise);
|
|
1114
|
-
},
|
|
1115
|
-
writable: false,
|
|
1116
|
-
configurable: false,
|
|
1117
|
-
enumerable: false
|
|
1118
|
-
}), "promiseResolve", {
|
|
1119
|
-
value: function value(_value3, callback) {
|
|
1120
|
-
return Promise.resolve(isFunction(_value3) ? this.fn(_value3)() : _value3).then(callback.bind(this));
|
|
1121
|
-
},
|
|
1122
|
-
writable: false,
|
|
1123
|
-
configurable: false,
|
|
1124
|
-
enumerable: false
|
|
1125
|
-
}), "use", {
|
|
1126
|
-
value: function value(path, namespace) {
|
|
1127
|
-
this.echo(this.promiseResolve(this.require(path), function (exports) {
|
|
1128
|
-
var list = this.getMacro();
|
|
1129
|
-
each(exports, function (macro, name) {
|
|
1130
|
-
list[[namespace, name].join('.')] = macro;
|
|
1131
|
-
});
|
|
1132
|
-
}));
|
|
1133
|
-
},
|
|
1134
|
-
writable: false,
|
|
1135
|
-
configurable: false,
|
|
1136
|
-
enumerable: false
|
|
1137
|
-
}), "async", {
|
|
1138
|
-
value: function value(promise, callback) {
|
|
1139
|
-
this.echo(this.promiseResolve(promise, function (data) {
|
|
1140
|
-
return this.fn(callback)(data);
|
|
1141
|
-
}));
|
|
1142
|
-
},
|
|
1143
|
-
writable: false,
|
|
1144
|
-
configurable: false,
|
|
1145
|
-
enumerable: false
|
|
1146
|
-
}), "each", {
|
|
1147
|
-
value: function value(object, callback) {
|
|
1148
|
-
if (isString(object)) {
|
|
1149
|
-
object = this.get(object, []);
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
}), "macro", {
|
|
1150
|
+
value: function value(name, callback) {
|
|
1151
|
+
var list = this.getMacro();
|
|
1152
|
+
var macro = this.fn(callback);
|
|
1153
|
+
var context = this;
|
|
1154
|
+
list[name] = function () {
|
|
1155
|
+
return context.echo(macro.apply(undefined, arguments));
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
|
|
1159
|
+
value: function value(name) {
|
|
1160
|
+
var list = this.getMacro();
|
|
1161
|
+
var macro = list[name];
|
|
1162
|
+
var params = [].slice.call(arguments, 1);
|
|
1163
|
+
if (isFunction(macro)) {
|
|
1164
|
+
return macro.apply(macro, params);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
}), "block", {
|
|
1168
|
+
value: function value(name, callback) {
|
|
1169
|
+
var _this = this;
|
|
1170
|
+
var blocks = this.getBlocks();
|
|
1171
|
+
blocks[name] = blocks[name] || [];
|
|
1172
|
+
blocks[name].push(this.fn(callback));
|
|
1173
|
+
if (this.getExtend()) return;
|
|
1174
|
+
var list = Object.assign([], blocks[name]);
|
|
1175
|
+
var current = function current() {
|
|
1176
|
+
return list.shift();
|
|
1177
|
+
};
|
|
1178
|
+
var _next = function next() {
|
|
1179
|
+
var parent = current();
|
|
1180
|
+
if (parent) {
|
|
1181
|
+
return function () {
|
|
1182
|
+
_this.echo(parent(_next()));
|
|
1183
|
+
};
|
|
1184
|
+
} else {
|
|
1185
|
+
return noop;
|
|
1150
1186
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1187
|
+
};
|
|
1188
|
+
this.echo(current()(_next()));
|
|
1189
|
+
}
|
|
1190
|
+
}), "hasBlock", {
|
|
1191
|
+
value: function value(name) {
|
|
1192
|
+
return this.getBlocks().hasOwnProperty(name);
|
|
1193
|
+
}
|
|
1194
|
+
}), "include", {
|
|
1195
|
+
value: function value(path, data, cx) {
|
|
1196
|
+
var context = cx === false ? {} : this.clone(true);
|
|
1197
|
+
var params = extend(context, data || {});
|
|
1198
|
+
var promise = this.render(path, params);
|
|
1199
|
+
this.echo(promise);
|
|
1200
|
+
}
|
|
1201
|
+
}), "use", {
|
|
1202
|
+
value: function value(path, namespace) {
|
|
1203
|
+
var _this2 = this;
|
|
1204
|
+
this.echo(Promise.resolve(this.require(path)).then(function (exports) {
|
|
1205
|
+
var list = _this2.getMacro();
|
|
1206
|
+
each(exports, function (macro, name) {
|
|
1207
|
+
list[[namespace, name].join('.')] = macro;
|
|
1208
|
+
});
|
|
1209
|
+
}));
|
|
1210
|
+
}
|
|
1211
|
+
}), "async", {
|
|
1212
|
+
value: function value(promise, callback) {
|
|
1213
|
+
this.echo(Promise.resolve(promise).then(callback));
|
|
1214
|
+
}
|
|
1215
|
+
}), "get", {
|
|
1216
|
+
value: function value(name, defaults) {
|
|
1217
|
+
var path = getPath(this, name, true);
|
|
1218
|
+
var result = path.shift();
|
|
1219
|
+
var prop = path.pop();
|
|
1220
|
+
return hasProp(result, prop) ? result[prop] : defaults;
|
|
1221
|
+
}
|
|
1222
|
+
}), "set", {
|
|
1223
|
+
value: function value(name, _value2) {
|
|
1224
|
+
var path = getPath(this, name, false);
|
|
1225
|
+
var result = path.shift();
|
|
1226
|
+
var prop = path.pop();
|
|
1227
|
+
if (this.getExtend() && hasProp(result, prop)) {
|
|
1228
|
+
return result[prop];
|
|
1229
|
+
}
|
|
1230
|
+
return result[prop] = _value2;
|
|
1231
|
+
}
|
|
1232
|
+
}), "each", {
|
|
1233
|
+
value: function value(object, callback) {
|
|
1234
|
+
if (isString(object)) {
|
|
1235
|
+
object = this.get(object, []);
|
|
1236
|
+
}
|
|
1237
|
+
each(object, callback);
|
|
1238
|
+
},
|
|
1239
|
+
writable: true
|
|
1240
|
+
}), "el", {
|
|
1241
|
+
value: function value(tag, attr, content) {
|
|
1242
|
+
content = isFunction(content) ? this.fn(content)() : content;
|
|
1243
|
+
this.echo(Promise.resolve(content).then(function (content) {
|
|
1158
1244
|
return element(tag, attr, content);
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1245
|
+
}));
|
|
1246
|
+
},
|
|
1247
|
+
writable: true
|
|
1248
|
+
}), _defineProperty(_Object$definePropert, "ui", {
|
|
1249
|
+
value: function value(layout) {},
|
|
1250
|
+
writable: true
|
|
1251
|
+
})));
|
|
1252
|
+
return ContextScope;
|
|
1253
|
+
};
|
|
1254
|
+
var _scope = /*#__PURE__*/new WeakMap();
|
|
1255
|
+
var Context = /*#__PURE__*/function () {
|
|
1256
|
+
function Context(config, methods) {
|
|
1257
|
+
_classCallCheck(this, Context);
|
|
1258
|
+
_classPrivateFieldInitSpec(this, _scope, void 0);
|
|
1259
|
+
this.configure(config, methods);
|
|
1260
|
+
}
|
|
1261
|
+
return _createClass(Context, [{
|
|
1262
|
+
key: "create",
|
|
1263
|
+
value: function create(data) {
|
|
1264
|
+
return new (_classPrivateFieldGet2(_scope, this))(data);
|
|
1265
|
+
}
|
|
1266
|
+
}, {
|
|
1267
|
+
key: "configure",
|
|
1268
|
+
value: function configure(config, methods) {
|
|
1269
|
+
_classPrivateFieldSet2(_scope, this, createContextScope(config, methods));
|
|
1270
|
+
}
|
|
1271
|
+
}, {
|
|
1272
|
+
key: "helpers",
|
|
1273
|
+
value: function helpers(methods) {
|
|
1274
|
+
extend(_classPrivateFieldGet2(_scope, this).prototype, methods || {});
|
|
1275
|
+
}
|
|
1276
|
+
}]);
|
|
1277
|
+
}();
|
|
1176
1278
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1279
|
+
var _config = /*#__PURE__*/new WeakMap();
|
|
1280
|
+
var _extend = /*#__PURE__*/new WeakMap();
|
|
1281
|
+
var _context = /*#__PURE__*/new WeakMap();
|
|
1282
|
+
var _compiler = /*#__PURE__*/new WeakMap();
|
|
1283
|
+
var _cache = /*#__PURE__*/new WeakMap();
|
|
1284
|
+
var _template = /*#__PURE__*/new WeakMap();
|
|
1285
|
+
var _EJS_brand = /*#__PURE__*/new WeakSet();
|
|
1286
|
+
var EJS = /*#__PURE__*/function () {
|
|
1287
|
+
function EJS(options) {
|
|
1288
|
+
_classCallCheck(this, EJS);
|
|
1289
|
+
_classPrivateMethodInitSpec(this, _EJS_brand);
|
|
1290
|
+
_classPrivateFieldInitSpec(this, _config, {});
|
|
1291
|
+
_classPrivateFieldInitSpec(this, _extend, {});
|
|
1292
|
+
_classPrivateFieldInitSpec(this, _context, void 0);
|
|
1293
|
+
_classPrivateFieldInitSpec(this, _compiler, void 0);
|
|
1294
|
+
_classPrivateFieldInitSpec(this, _cache, void 0);
|
|
1295
|
+
_classPrivateFieldInitSpec(this, _template, void 0);
|
|
1296
|
+
configSchema(_classPrivateFieldGet2(_config, this), options || {});
|
|
1297
|
+
_classPrivateFieldSet2(_context, this, new Context(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this)));
|
|
1298
|
+
_classPrivateFieldSet2(_compiler, this, new Compiler(_classPrivateFieldGet2(_config, this)));
|
|
1299
|
+
_classPrivateFieldSet2(_cache, this, new Cache(_classPrivateFieldGet2(_config, this)));
|
|
1300
|
+
_classPrivateFieldSet2(_template, this, new Template(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_cache, this), _classPrivateFieldGet2(_compiler, this)));
|
|
1301
|
+
//
|
|
1302
|
+
bindContext(this, ['configure', 'create', 'render', 'require', 'context', 'preload', 'compile', 'helpers']);
|
|
1303
|
+
//
|
|
1304
|
+
this.helpers({
|
|
1305
|
+
require: this.require,
|
|
1306
|
+
render: this.render
|
|
1195
1307
|
});
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
context
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1308
|
+
}
|
|
1309
|
+
return _createClass(EJS, [{
|
|
1310
|
+
key: "configure",
|
|
1311
|
+
value: function configure(options) {
|
|
1312
|
+
configSchema(_classPrivateFieldGet2(_config, this), options || {});
|
|
1313
|
+
_classPrivateFieldGet2(_context, this).configure(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this));
|
|
1314
|
+
_classPrivateFieldGet2(_compiler, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1315
|
+
_classPrivateFieldGet2(_cache, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1316
|
+
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1317
|
+
return _classPrivateFieldGet2(_config, this);
|
|
1318
|
+
}
|
|
1319
|
+
}, {
|
|
1320
|
+
key: "render",
|
|
1321
|
+
value: function render(name, data) {
|
|
1322
|
+
var _this = this;
|
|
1323
|
+
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1324
|
+
var scope = this.context(data);
|
|
1325
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function (content) {
|
|
1326
|
+
if (scope.getExtend()) {
|
|
1327
|
+
scope.setExtend(false);
|
|
1328
|
+
var layout = scope.getLayout();
|
|
1329
|
+
var _data = scope.clone();
|
|
1330
|
+
return _this.render(layout, _data);
|
|
1331
|
+
}
|
|
1332
|
+
return content;
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
}, {
|
|
1336
|
+
key: "helpers",
|
|
1337
|
+
value: function helpers(methods) {
|
|
1338
|
+
_classPrivateFieldGet2(_context, this).helpers(extend(_classPrivateFieldGet2(_extend, this), methods));
|
|
1339
|
+
}
|
|
1340
|
+
}, {
|
|
1341
|
+
key: "context",
|
|
1342
|
+
value: function context(data) {
|
|
1343
|
+
return _classPrivateFieldGet2(_context, this).create(data);
|
|
1344
|
+
}
|
|
1345
|
+
}, {
|
|
1346
|
+
key: "compile",
|
|
1347
|
+
value: function compile(content, path) {
|
|
1348
|
+
return _classPrivateFieldGet2(_compiler, this).compile(content, path);
|
|
1349
|
+
}
|
|
1350
|
+
}, {
|
|
1351
|
+
key: "preload",
|
|
1352
|
+
value: function preload(list) {
|
|
1353
|
+
return _classPrivateFieldGet2(_cache, this).load(list || {});
|
|
1354
|
+
}
|
|
1355
|
+
}, {
|
|
1356
|
+
key: "create",
|
|
1357
|
+
value: function create(options) {
|
|
1358
|
+
return new this.constructor(options);
|
|
1359
|
+
}
|
|
1360
|
+
}, {
|
|
1361
|
+
key: "require",
|
|
1362
|
+
value: function require(name) {
|
|
1363
|
+
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1364
|
+
var scope = this.context({});
|
|
1365
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1366
|
+
return scope.getMacro();
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
}]);
|
|
1370
|
+
}();
|
|
1371
|
+
function _output(path, scope) {
|
|
1372
|
+
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1373
|
+
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1374
|
+
var params = [scope, scope.getBuffer(), scope.useSafeValue, scope.useComponent, scope.useElement].concat(globalHelpers.filter(function (name) {
|
|
1375
|
+
return isFunction(scope[name]);
|
|
1376
|
+
}).map(function (name) {
|
|
1377
|
+
return scope[name].bind(scope);
|
|
1378
|
+
}));
|
|
1379
|
+
return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
|
|
1380
|
+
return callback.apply(scope, params);
|
|
1247
1381
|
});
|
|
1248
|
-
return this;
|
|
1249
1382
|
}
|
|
1250
1383
|
|
|
1251
|
-
var hash = Math.floor(Math.random() * 1e12).toString(36);
|
|
1252
1384
|
var templates = {};
|
|
1253
|
-
var ejs = new EJS({
|
|
1254
|
-
cache: false,
|
|
1255
|
-
withObject: false,
|
|
1256
|
-
resolver: function resolver(path, name) {
|
|
1257
|
-
return new Promise(function (resolve, reject) {
|
|
1258
|
-
if (templates.hasOwnProperty(name)) {
|
|
1259
|
-
resolve(templates[name]);
|
|
1260
|
-
} else {
|
|
1261
|
-
reject(new TemplateNotFound("template ".concat(name, " not found")));
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
|
-
});
|
|
1266
|
-
var render = ejs.render,
|
|
1267
|
-
context = ejs.context,
|
|
1268
|
-
helpers = ejs.helpers,
|
|
1269
|
-
configure = ejs.configure,
|
|
1270
|
-
create = ejs.create;
|
|
1271
1385
|
var getOrigin = function getOrigin(url, secure) {
|
|
1272
1386
|
url = new URL(url);
|
|
1273
|
-
|
|
1387
|
+
url.protocol = secure ? 'https:' : 'http:';
|
|
1274
1388
|
return url.origin;
|
|
1275
1389
|
};
|
|
1390
|
+
var _EJS = new EJS({
|
|
1391
|
+
cache: false,
|
|
1392
|
+
withObject: false,
|
|
1393
|
+
resolver: function resolver(path, name) {
|
|
1394
|
+
return new Promise(function (resolve, reject) {
|
|
1395
|
+
if (templates.hasOwnProperty(name)) {
|
|
1396
|
+
resolve(templates[name]);
|
|
1397
|
+
} else {
|
|
1398
|
+
reject(new TemplateNotFound("template ".concat(name, " not found")));
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
}),
|
|
1403
|
+
render = _EJS.render,
|
|
1404
|
+
context = _EJS.context,
|
|
1405
|
+
helpers = _EJS.helpers,
|
|
1406
|
+
configure = _EJS.configure,
|
|
1407
|
+
create = _EJS.create;
|
|
1276
1408
|
function setTemplates(list) {
|
|
1277
1409
|
Object.assign(templates, list || {});
|
|
1278
1410
|
}
|
|
1279
1411
|
|
|
1280
1412
|
/**
|
|
1281
|
-
* @typedef {
|
|
1413
|
+
* @typedef {{}} HonoContext
|
|
1282
1414
|
* @property {function(*):Promise<Response>} html
|
|
1283
1415
|
* @property {function():Promise<Response>} notFound
|
|
1284
1416
|
* @property {function(methods:{}):void} helpers
|
|
@@ -1289,12 +1421,11 @@
|
|
|
1289
1421
|
|
|
1290
1422
|
/**
|
|
1291
1423
|
* @param {Object<string,any>} options
|
|
1292
|
-
* @return {(function(c:
|
|
1424
|
+
* @return {(function(c:HonoContext, next): Promise<any>)|*}
|
|
1293
1425
|
*/
|
|
1294
1426
|
function setRenderer() {
|
|
1295
1427
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1296
|
-
|
|
1297
|
-
version = _ref$version === void 0 ? hash : _ref$version,
|
|
1428
|
+
version = _ref.version,
|
|
1298
1429
|
_ref$secure = _ref.secure,
|
|
1299
1430
|
secure = _ref$secure === void 0 ? true : _ref$secure;
|
|
1300
1431
|
return /*#__PURE__*/function () {
|
|
@@ -1331,7 +1462,8 @@
|
|
|
1331
1462
|
};
|
|
1332
1463
|
}();
|
|
1333
1464
|
}
|
|
1334
|
-
|
|
1465
|
+
|
|
1466
|
+
//export { render, context, helpers, configure, create }
|
|
1335
1467
|
|
|
1336
1468
|
exports.TemplateError = TemplateError;
|
|
1337
1469
|
exports.TemplateNotFound = TemplateNotFound;
|
|
@@ -1343,6 +1475,5 @@
|
|
|
1343
1475
|
exports.render = render;
|
|
1344
1476
|
exports.setRenderer = setRenderer;
|
|
1345
1477
|
exports.setTemplates = setTemplates;
|
|
1346
|
-
exports.version = version;
|
|
1347
1478
|
|
|
1348
1479
|
}));
|