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