@kosatyi/ejs 0.0.96 → 0.0.98
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 +923 -649
- package/dist/cjs/bundler.js +28 -22
- package/dist/cjs/element.js +8 -1
- package/dist/cjs/index.js +932 -657
- package/dist/cjs/worker.js +919 -647
- package/dist/esm/browser.js +691 -609
- package/dist/esm/bundler.js +21 -15
- package/dist/esm/element.js +12 -2
- package/dist/esm/index.js +700 -618
- package/dist/esm/worker.js +707 -626
- package/dist/umd/browser.js +1136 -862
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/element.js +8 -1
- package/dist/umd/element.min.js +1 -1
- package/dist/umd/index.js +1170 -895
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +919 -647
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
- 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';
|
|
@@ -543,183 +683,221 @@ var configSchema = function configSchema(config, options) {
|
|
|
543
683
|
};
|
|
544
684
|
|
|
545
685
|
var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
686
|
+
var _enabled = /*#__PURE__*/new WeakMap();
|
|
687
|
+
var _list = /*#__PURE__*/new WeakMap();
|
|
688
|
+
var Cache = /*#__PURE__*/function () {
|
|
689
|
+
function Cache(config) {
|
|
690
|
+
_classCallCheck(this, Cache);
|
|
691
|
+
_classPrivateFieldInitSpec(this, _enabled, true);
|
|
692
|
+
_classPrivateFieldInitSpec(this, _list, {});
|
|
693
|
+
bindContext(this, ['configure']);
|
|
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
|
+
bindContext(this, ['configure', 'compile']);
|
|
776
|
+
this.configure(config);
|
|
608
777
|
}
|
|
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
|
-
}
|
|
778
|
+
return _createClass(Compiler, [{
|
|
779
|
+
key: "configure",
|
|
780
|
+
value: function configure(config) {
|
|
781
|
+
var _this = this;
|
|
782
|
+
_classPrivateFieldGet2(_config$1, this).withObject = config.withObject;
|
|
783
|
+
_classPrivateFieldGet2(_config$1, this).rmWhitespace = config.rmWhitespace;
|
|
784
|
+
_classPrivateFieldGet2(_config$1, this).token = config.token;
|
|
785
|
+
_classPrivateFieldGet2(_config$1, this).vars = config.vars;
|
|
786
|
+
_classPrivateFieldGet2(_config$1, this).globalHelpers = config.globalHelpers;
|
|
787
|
+
_classPrivateFieldGet2(_config$1, this).matches = [];
|
|
788
|
+
_classPrivateFieldGet2(_config$1, this).formats = [];
|
|
789
|
+
_classPrivateFieldGet2(_config$1, this).slurp = {
|
|
790
|
+
match: '[s\t\n]*',
|
|
791
|
+
start: [_classPrivateFieldGet2(_config$1, this).token.start, '_'],
|
|
792
|
+
end: ['_', _classPrivateFieldGet2(_config$1, this).token.end]
|
|
793
|
+
};
|
|
794
|
+
_classPrivateFieldGet2(_symbols, this).forEach(function (item) {
|
|
795
|
+
_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));
|
|
796
|
+
_classPrivateFieldGet2(_config$1, _this).formats.push(item.format.bind(_classPrivateFieldGet2(_config$1, _this).vars));
|
|
664
797
|
});
|
|
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);
|
|
798
|
+
_classPrivateFieldGet2(_config$1, this).regex = new RegExp(_classPrivateFieldGet2(_config$1, this).matches.join('|').concat('|$'), 'g');
|
|
799
|
+
_classPrivateFieldGet2(_config$1, this).slurpStart = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.match, _classPrivateFieldGet2(_config$1, this).slurp.start.join('')].join(''), 'gm');
|
|
800
|
+
_classPrivateFieldGet2(_config$1, this).slurpEnd = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.end.join(''), _classPrivateFieldGet2(_config$1, this).slurp.match].join(''), 'gm');
|
|
705
801
|
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
802
|
+
}, {
|
|
803
|
+
key: "compile",
|
|
804
|
+
value: function compile(content, path) {
|
|
805
|
+
var _this2 = this;
|
|
806
|
+
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config$1, this).vars,
|
|
807
|
+
SCOPE = _classPrivateFieldGet2$1.SCOPE,
|
|
808
|
+
SAFE = _classPrivateFieldGet2$1.SAFE,
|
|
809
|
+
BUFFER = _classPrivateFieldGet2$1.BUFFER,
|
|
810
|
+
COMPONENT = _classPrivateFieldGet2$1.COMPONENT;
|
|
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, COMPONENT, BUFFER, SAFE].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
|
+
bindContext(this, ['configure', 'get']);
|
|
865
|
+
this.configure(config);
|
|
866
|
+
}
|
|
867
|
+
return _createClass(Template, [{
|
|
868
|
+
key: "configure",
|
|
869
|
+
value: function configure(config) {
|
|
870
|
+
_classPrivateFieldSet2(_path, this, config.path);
|
|
871
|
+
if (isFunction(config.resolver)) {
|
|
872
|
+
_classPrivateFieldSet2(_resolver, this, config.resolver);
|
|
873
|
+
}
|
|
717
874
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
875
|
+
}, {
|
|
876
|
+
key: "get",
|
|
877
|
+
value: function get(template) {
|
|
878
|
+
var _this = this;
|
|
879
|
+
if (_classPrivateFieldGet2(_cache$1, this).exist(template)) {
|
|
880
|
+
return _classPrivateFieldGet2(_cache$1, this).resolve(template);
|
|
881
|
+
}
|
|
882
|
+
return _assertClassBrand(_Template_brand, this, _resolve).call(this, template).then(function (content) {
|
|
883
|
+
return _assertClassBrand(_Template_brand, _this, _result).call(_this, template, _assertClassBrand(_Template_brand, _this, _compile).call(_this, content, template));
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
}]);
|
|
887
|
+
}();
|
|
888
|
+
function _resolve(path) {
|
|
889
|
+
return _classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path, this), path);
|
|
890
|
+
}
|
|
891
|
+
function _result(template, content) {
|
|
892
|
+
_classPrivateFieldGet2(_cache$1, this).set(template, content);
|
|
893
|
+
return content;
|
|
894
|
+
}
|
|
895
|
+
function _compile(content, template) {
|
|
896
|
+
if (isFunction(content)) {
|
|
897
|
+
return content;
|
|
898
|
+
} else {
|
|
899
|
+
return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
|
|
900
|
+
}
|
|
723
901
|
}
|
|
724
902
|
|
|
725
903
|
var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
@@ -738,7 +916,7 @@ var element = function element(tag, attrs, content) {
|
|
|
738
916
|
}
|
|
739
917
|
}).join(space);
|
|
740
918
|
result.push([lt, tag, space, attributes, gt].join(''));
|
|
741
|
-
if (content) {
|
|
919
|
+
if (content && hasClosedTag) {
|
|
742
920
|
result.push(content instanceof Array ? content.join('') : content);
|
|
743
921
|
}
|
|
744
922
|
if (hasClosedTag) {
|
|
@@ -747,82 +925,61 @@ var element = function element(tag, attrs, content) {
|
|
|
747
925
|
return result.join('');
|
|
748
926
|
};
|
|
749
927
|
|
|
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
|
-
});
|
|
928
|
+
var TemplateError = /*#__PURE__*/function (_Error) {
|
|
929
|
+
function TemplateError(message) {
|
|
930
|
+
var _this;
|
|
931
|
+
_classCallCheck(this, TemplateError);
|
|
932
|
+
_this = _callSuper(this, TemplateError);
|
|
933
|
+
_defineProperty(_this, "code", 0);
|
|
934
|
+
_this.message = message;
|
|
935
|
+
return _this;
|
|
936
|
+
}
|
|
937
|
+
_inherits(TemplateError, _Error);
|
|
938
|
+
return _createClass(TemplateError, [{
|
|
939
|
+
key: "getCode",
|
|
940
|
+
value: function getCode() {
|
|
941
|
+
return this.code;
|
|
942
|
+
}
|
|
943
|
+
}, {
|
|
944
|
+
key: "getMessage",
|
|
945
|
+
value: function getMessage() {
|
|
946
|
+
return this.message;
|
|
947
|
+
}
|
|
948
|
+
}, {
|
|
949
|
+
key: "toString",
|
|
950
|
+
value: function toString() {
|
|
951
|
+
return this.getMessage();
|
|
952
|
+
}
|
|
953
|
+
}]);
|
|
954
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
955
|
+
var TemplateNotFound = /*#__PURE__*/function (_TemplateError2) {
|
|
956
|
+
function TemplateNotFound() {
|
|
957
|
+
var _this2;
|
|
958
|
+
_classCallCheck(this, TemplateNotFound);
|
|
959
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
960
|
+
args[_key] = arguments[_key];
|
|
961
|
+
}
|
|
962
|
+
_this2 = _callSuper(this, TemplateNotFound, [].concat(args));
|
|
963
|
+
_defineProperty(_this2, "code", 404);
|
|
964
|
+
return _this2;
|
|
965
|
+
}
|
|
966
|
+
_inherits(TemplateNotFound, _TemplateError2);
|
|
967
|
+
return _createClass(TemplateNotFound);
|
|
968
|
+
}(TemplateError);
|
|
969
|
+
var TemplateSyntaxError = /*#__PURE__*/function (_TemplateError3) {
|
|
970
|
+
function TemplateSyntaxError() {
|
|
971
|
+
var _this3;
|
|
972
|
+
_classCallCheck(this, TemplateSyntaxError);
|
|
973
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
974
|
+
args[_key2] = arguments[_key2];
|
|
975
|
+
}
|
|
976
|
+
_this3 = _callSuper(this, TemplateSyntaxError, [].concat(args));
|
|
977
|
+
_defineProperty(_this3, "code", 500);
|
|
978
|
+
return _this3;
|
|
979
|
+
}
|
|
980
|
+
_inherits(TemplateSyntaxError, _TemplateError3);
|
|
981
|
+
return _createClass(TemplateSyntaxError);
|
|
982
|
+
}(TemplateError);
|
|
826
983
|
|
|
827
984
|
function resolve(list) {
|
|
828
985
|
return Promise.all(list || []).then(function (list) {
|
|
@@ -834,12 +991,17 @@ function resolve(list) {
|
|
|
834
991
|
function reject(error) {
|
|
835
992
|
return Promise.reject(new TemplateSyntaxError(error.message));
|
|
836
993
|
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
*
|
|
997
|
+
* @return {buffer}
|
|
998
|
+
*/
|
|
837
999
|
function createBuffer() {
|
|
838
1000
|
var store = [],
|
|
839
1001
|
array = [];
|
|
840
|
-
function buffer(value) {
|
|
1002
|
+
var buffer = function buffer(value) {
|
|
841
1003
|
array.push(value);
|
|
842
|
-
}
|
|
1004
|
+
};
|
|
843
1005
|
buffer.start = function () {
|
|
844
1006
|
array = [];
|
|
845
1007
|
};
|
|
@@ -861,420 +1023,531 @@ function createBuffer() {
|
|
|
861
1023
|
return buffer;
|
|
862
1024
|
}
|
|
863
1025
|
|
|
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
|
-
|
|
911
|
-
|
|
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
|
-
}
|
|
1026
|
+
var createScope = function createScope(config, methods) {
|
|
1027
|
+
var _Object$definePropert;
|
|
1028
|
+
var _config$vars = config.vars,
|
|
1029
|
+
BLOCKS = _config$vars.BLOCKS,
|
|
1030
|
+
MACRO = _config$vars.MACRO,
|
|
1031
|
+
EXTEND = _config$vars.EXTEND,
|
|
1032
|
+
LAYOUT = _config$vars.LAYOUT,
|
|
1033
|
+
BUFFER = _config$vars.BUFFER,
|
|
1034
|
+
COMPONENT = _config$vars.COMPONENT,
|
|
1035
|
+
SAFE = _config$vars.SAFE,
|
|
1036
|
+
SCOPE = _config$vars.SCOPE;
|
|
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]));
|
|
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
|
+
}), "getMacro", {
|
|
1063
|
+
value: function value() {
|
|
1064
|
+
return this[MACRO];
|
|
1065
|
+
}
|
|
1066
|
+
}), "getBuffer", {
|
|
1067
|
+
value: function value() {
|
|
1068
|
+
return this[BUFFER];
|
|
1069
|
+
}
|
|
1070
|
+
}), "getComponent", {
|
|
1071
|
+
value: function value() {
|
|
1072
|
+
var context = this;
|
|
1073
|
+
if (COMPONENT in context) {
|
|
939
1074
|
return function () {
|
|
940
|
-
|
|
1075
|
+
return context[COMPONENT].apply(context, arguments);
|
|
941
1076
|
};
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1077
|
+
}
|
|
1078
|
+
return function () {
|
|
1079
|
+
console.log('%s function not defined', COMPONENT);
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
}), "getBlocks", {
|
|
1083
|
+
value: function value() {
|
|
1084
|
+
return this[BLOCKS];
|
|
1085
|
+
}
|
|
1086
|
+
}), "setExtend", {
|
|
1087
|
+
value: function value(_value) {
|
|
1088
|
+
this[EXTEND] = _value;
|
|
1089
|
+
}
|
|
1090
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getExtend", {
|
|
1091
|
+
value: function value() {
|
|
1092
|
+
return this[EXTEND];
|
|
1093
|
+
}
|
|
1094
|
+
}), "setLayout", {
|
|
1095
|
+
value: function value(layout) {
|
|
1096
|
+
this[LAYOUT] = layout;
|
|
1097
|
+
}
|
|
1098
|
+
}), "getLayout", {
|
|
1099
|
+
value: function value() {
|
|
1100
|
+
return this[LAYOUT];
|
|
1101
|
+
}
|
|
1102
|
+
}), "clone", {
|
|
1103
|
+
value: function value(exclude_blocks) {
|
|
1104
|
+
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
1105
|
+
if (exclude_blocks === true) {
|
|
1106
|
+
filter.push(BLOCKS);
|
|
1107
|
+
}
|
|
1108
|
+
return omit(this, filter);
|
|
1109
|
+
}
|
|
1110
|
+
}), "extend", {
|
|
1111
|
+
value: function value(layout) {
|
|
1112
|
+
this.setExtend(true);
|
|
1113
|
+
this.setLayout(layout);
|
|
1114
|
+
}
|
|
1115
|
+
}), "echo", {
|
|
1116
|
+
value: function value(layout) {
|
|
1117
|
+
var buffer = this.getBuffer();
|
|
1118
|
+
var params = [].slice.call(arguments);
|
|
1119
|
+
params.forEach(buffer);
|
|
1120
|
+
}
|
|
1121
|
+
}), "fn", {
|
|
1122
|
+
value: function value(callback) {
|
|
1123
|
+
var buffer = this.getBuffer();
|
|
1124
|
+
var context = this;
|
|
1125
|
+
return function () {
|
|
1126
|
+
buffer.backup();
|
|
1127
|
+
if (isFunction(callback)) {
|
|
1128
|
+
callback.apply(context, arguments);
|
|
986
1129
|
}
|
|
987
|
-
return
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
return
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
var
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1130
|
+
return buffer.restore();
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
}), "get", {
|
|
1134
|
+
value: function value(name, defaults) {
|
|
1135
|
+
var path = getPath(this, name, true);
|
|
1136
|
+
var result = path.shift();
|
|
1137
|
+
var prop = path.pop();
|
|
1138
|
+
return hasProp(result, prop) ? result[prop] : defaults;
|
|
1139
|
+
}
|
|
1140
|
+
}), "set", {
|
|
1141
|
+
value: function value(name, _value2) {
|
|
1142
|
+
var path = getPath(this, name, false);
|
|
1143
|
+
var result = path.shift();
|
|
1144
|
+
var prop = path.pop();
|
|
1145
|
+
if (this.getExtend() && hasProp(result, prop)) {
|
|
1146
|
+
return result[prop];
|
|
1147
|
+
}
|
|
1148
|
+
return result[prop] = _value2;
|
|
1149
|
+
}
|
|
1150
|
+
}), "macro", {
|
|
1151
|
+
value: function value(name, callback) {
|
|
1152
|
+
var list = this.getMacro();
|
|
1153
|
+
var macro = this.fn(callback);
|
|
1154
|
+
var context = this;
|
|
1155
|
+
list[name] = function () {
|
|
1156
|
+
return context.echo(macro.apply(undefined, arguments));
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
|
|
1160
|
+
value: function value(name) {
|
|
1161
|
+
var list = this.getMacro();
|
|
1162
|
+
var macro = list[name];
|
|
1163
|
+
var params = [].slice.call(arguments, 1);
|
|
1164
|
+
if (isFunction(macro)) {
|
|
1165
|
+
return macro.apply(macro, params);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}), "block", {
|
|
1169
|
+
value: function value(name, callback) {
|
|
1170
|
+
var _this = this;
|
|
1171
|
+
var blocks = this.getBlocks();
|
|
1172
|
+
blocks[name] = blocks[name] || [];
|
|
1173
|
+
blocks[name].push(this.fn(callback));
|
|
1174
|
+
if (this.getExtend()) return;
|
|
1175
|
+
var list = Object.assign([], blocks[name]);
|
|
1176
|
+
var current = function current() {
|
|
1177
|
+
return list.shift();
|
|
1178
|
+
};
|
|
1179
|
+
var _next = function next() {
|
|
1180
|
+
var parent = current();
|
|
1181
|
+
if (parent) {
|
|
1182
|
+
return function () {
|
|
1183
|
+
_this.echo(parent(_next()));
|
|
1184
|
+
};
|
|
1185
|
+
} else {
|
|
1186
|
+
return noop;
|
|
1041
1187
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1188
|
+
};
|
|
1189
|
+
this.echo(current()(_next()));
|
|
1190
|
+
}
|
|
1191
|
+
}), "hasBlock", {
|
|
1192
|
+
value: function value(name) {
|
|
1193
|
+
return this.getBlocks().hasOwnProperty(name);
|
|
1194
|
+
}
|
|
1195
|
+
}), "include", {
|
|
1196
|
+
value: function value(path, data, cx) {
|
|
1197
|
+
var context = cx === false ? {} : this.clone(true);
|
|
1198
|
+
var params = extend(context, data || {});
|
|
1199
|
+
var promise = this.render(path, params);
|
|
1200
|
+
this.echo(promise);
|
|
1201
|
+
}
|
|
1202
|
+
}), "promiseResolve", {
|
|
1203
|
+
value: function value(_value3, callback) {
|
|
1204
|
+
return Promise.resolve(isFunction(_value3) ? this.fn(_value3)() : _value3).then(callback.bind(this));
|
|
1205
|
+
}
|
|
1206
|
+
}), "use", {
|
|
1207
|
+
value: function value(path, namespace) {
|
|
1208
|
+
this.echo(this.promiseResolve(this.require(path), function (exports) {
|
|
1061
1209
|
var list = this.getMacro();
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
if (this.getExtend()) return;
|
|
1078
|
-
var list = Object.assign([], blocks[name]);
|
|
1079
|
-
var current = function current() {
|
|
1080
|
-
return list.shift();
|
|
1081
|
-
};
|
|
1082
|
-
var _next = function next() {
|
|
1083
|
-
var parent = current();
|
|
1084
|
-
if (parent) {
|
|
1085
|
-
return function () {
|
|
1086
|
-
_this.echo(parent(_next()));
|
|
1087
|
-
};
|
|
1088
|
-
} else {
|
|
1089
|
-
return noop;
|
|
1090
|
-
}
|
|
1091
|
-
};
|
|
1092
|
-
this.echo(current()(_next()));
|
|
1093
|
-
},
|
|
1094
|
-
writable: false,
|
|
1095
|
-
configurable: false,
|
|
1096
|
-
enumerable: false
|
|
1097
|
-
}), "hasBlock", {
|
|
1098
|
-
value: function value(name) {
|
|
1099
|
-
return this.getBlocks().hasOwnProperty(name);
|
|
1100
|
-
},
|
|
1101
|
-
writable: false,
|
|
1102
|
-
configurable: false,
|
|
1103
|
-
enumerable: false
|
|
1104
|
-
}), "include", {
|
|
1105
|
-
value: function value(path, data, cx) {
|
|
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, []);
|
|
1146
|
-
}
|
|
1147
|
-
each(object, callback);
|
|
1148
|
-
},
|
|
1149
|
-
writable: false,
|
|
1150
|
-
configurable: false,
|
|
1151
|
-
enumerable: false
|
|
1152
|
-
}), "element", {
|
|
1153
|
-
value: function value(tag, attr, content) {
|
|
1154
|
-
return element(tag, attr, content);
|
|
1155
|
-
},
|
|
1156
|
-
writable: false,
|
|
1157
|
-
configurable: false,
|
|
1158
|
-
enumerable: false
|
|
1159
|
-
}), "el", {
|
|
1160
|
-
value: function value(tag, attr, content) {
|
|
1161
|
-
this.echo(this.promiseResolve(content, function (content) {
|
|
1162
|
-
return this.element(tag, attr, content);
|
|
1163
|
-
}));
|
|
1164
|
-
},
|
|
1165
|
-
writable: false,
|
|
1166
|
-
configurable: false,
|
|
1167
|
-
enumerable: false
|
|
1168
|
-
})));
|
|
1169
|
-
};
|
|
1170
|
-
this.configure(config);
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
function EJS(options) {
|
|
1174
|
-
if (instanceOf(this, EJS) === false) return new EJS(options);
|
|
1175
|
-
var scope = {};
|
|
1176
|
-
var config = {};
|
|
1177
|
-
configSchema(config, options || {});
|
|
1178
|
-
var context = new Context(config);
|
|
1179
|
-
var compiler = new Compiler(config);
|
|
1180
|
-
var cache = new Cache();
|
|
1181
|
-
var template = new Template(config, cache, compiler);
|
|
1182
|
-
var output = function output(path, scope) {
|
|
1183
|
-
var globalHelpers = config.globalHelpers;
|
|
1184
|
-
var params = [scope, scope.getComponent(), scope.getBuffer(), safeValue].concat(globalHelpers.filter(function (name) {
|
|
1185
|
-
return isFunction(scope[name]);
|
|
1186
|
-
}).map(function (name) {
|
|
1187
|
-
return scope[name].bind(scope);
|
|
1188
|
-
}));
|
|
1189
|
-
return template.get(path).then(function (callback) {
|
|
1190
|
-
return callback.apply(scope, params);
|
|
1191
|
-
});
|
|
1192
|
-
};
|
|
1193
|
-
var require = function require(name) {
|
|
1194
|
-
var filepath = ext(name, config.extension);
|
|
1195
|
-
var scope = context.create({});
|
|
1196
|
-
return output(filepath, scope).then(function () {
|
|
1197
|
-
return scope.getMacro();
|
|
1198
|
-
});
|
|
1199
|
-
};
|
|
1200
|
-
var _render = function render(name, data) {
|
|
1201
|
-
var filepath = ext(name, config.extension);
|
|
1202
|
-
var scope = context.create(data);
|
|
1203
|
-
return output(filepath, scope).then(function (content) {
|
|
1204
|
-
if (scope.getExtend()) {
|
|
1205
|
-
scope.setExtend(false);
|
|
1206
|
-
var layout = scope.getLayout();
|
|
1207
|
-
var _data = scope.clone();
|
|
1208
|
-
return _render(layout, _data);
|
|
1210
|
+
each(exports, function (macro, name) {
|
|
1211
|
+
list[[namespace, name].join('.')] = macro;
|
|
1212
|
+
});
|
|
1213
|
+
}));
|
|
1214
|
+
}
|
|
1215
|
+
}), "async", {
|
|
1216
|
+
value: function value(promise, callback) {
|
|
1217
|
+
this.echo(this.promiseResolve(promise, function (data) {
|
|
1218
|
+
return this.fn(callback)(data);
|
|
1219
|
+
}));
|
|
1220
|
+
}
|
|
1221
|
+
}), "each", {
|
|
1222
|
+
value: function value(object, callback) {
|
|
1223
|
+
if (isString(object)) {
|
|
1224
|
+
object = this.get(object, []);
|
|
1209
1225
|
}
|
|
1210
|
-
|
|
1226
|
+
each(object, callback);
|
|
1227
|
+
}
|
|
1228
|
+
}), "element", {
|
|
1229
|
+
value: function value(tag, attr, content) {
|
|
1230
|
+
return element(tag, attr, content);
|
|
1231
|
+
}
|
|
1232
|
+
}), "el", {
|
|
1233
|
+
value: function value(tag, attr, content) {
|
|
1234
|
+
this.echo(this.promiseResolve(content, function (content) {
|
|
1235
|
+
return this.element(tag, attr, content);
|
|
1236
|
+
}));
|
|
1237
|
+
}
|
|
1238
|
+
})));
|
|
1239
|
+
return ContextScope;
|
|
1240
|
+
};
|
|
1241
|
+
var _scope = /*#__PURE__*/new WeakMap();
|
|
1242
|
+
var Context = /*#__PURE__*/function () {
|
|
1243
|
+
function Context(config, methods) {
|
|
1244
|
+
_classCallCheck(this, Context);
|
|
1245
|
+
_classPrivateFieldInitSpec(this, _scope, void 0);
|
|
1246
|
+
bindContext(this, ['create', 'helpers', 'configure']);
|
|
1247
|
+
this.configure(config, methods);
|
|
1248
|
+
}
|
|
1249
|
+
return _createClass(Context, [{
|
|
1250
|
+
key: "create",
|
|
1251
|
+
value: function create(data) {
|
|
1252
|
+
return new (_classPrivateFieldGet2(_scope, this))(data);
|
|
1253
|
+
}
|
|
1254
|
+
}, {
|
|
1255
|
+
key: "configure",
|
|
1256
|
+
value: function configure(config, methods) {
|
|
1257
|
+
_classPrivateFieldSet2(_scope, this, createScope(config, methods));
|
|
1258
|
+
}
|
|
1259
|
+
}, {
|
|
1260
|
+
key: "helpers",
|
|
1261
|
+
value: function helpers(methods) {
|
|
1262
|
+
extend(_classPrivateFieldGet2(_scope, this).prototype, methods || {});
|
|
1263
|
+
}
|
|
1264
|
+
}]);
|
|
1265
|
+
}();
|
|
1266
|
+
|
|
1267
|
+
var _config = /*#__PURE__*/new WeakMap();
|
|
1268
|
+
var _extend = /*#__PURE__*/new WeakMap();
|
|
1269
|
+
var _context = /*#__PURE__*/new WeakMap();
|
|
1270
|
+
var _compiler = /*#__PURE__*/new WeakMap();
|
|
1271
|
+
var _cache = /*#__PURE__*/new WeakMap();
|
|
1272
|
+
var _template = /*#__PURE__*/new WeakMap();
|
|
1273
|
+
var _EJS_brand = /*#__PURE__*/new WeakSet();
|
|
1274
|
+
var EJS = /*#__PURE__*/function () {
|
|
1275
|
+
function EJS(options) {
|
|
1276
|
+
_classCallCheck(this, EJS);
|
|
1277
|
+
_classPrivateMethodInitSpec(this, _EJS_brand);
|
|
1278
|
+
_classPrivateFieldInitSpec(this, _config, {});
|
|
1279
|
+
_classPrivateFieldInitSpec(this, _extend, {});
|
|
1280
|
+
_classPrivateFieldInitSpec(this, _context, void 0);
|
|
1281
|
+
_classPrivateFieldInitSpec(this, _compiler, void 0);
|
|
1282
|
+
_classPrivateFieldInitSpec(this, _cache, void 0);
|
|
1283
|
+
_classPrivateFieldInitSpec(this, _template, void 0);
|
|
1284
|
+
configSchema(_classPrivateFieldGet2(_config, this), options || {});
|
|
1285
|
+
_classPrivateFieldSet2(_context, this, new Context(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this)));
|
|
1286
|
+
_classPrivateFieldSet2(_compiler, this, new Compiler(_classPrivateFieldGet2(_config, this)));
|
|
1287
|
+
_classPrivateFieldSet2(_cache, this, new Cache(_classPrivateFieldGet2(_config, this)));
|
|
1288
|
+
_classPrivateFieldSet2(_template, this, new Template(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_cache, this), _classPrivateFieldGet2(_compiler, this)));
|
|
1289
|
+
//
|
|
1290
|
+
bindContext(this, ['configure', 'create', 'render', 'context', 'preload', 'compile', 'helpers']);
|
|
1291
|
+
//
|
|
1292
|
+
this.helpers({
|
|
1293
|
+
require: _assertClassBrand(_EJS_brand, this, _require),
|
|
1294
|
+
render: this.render
|
|
1211
1295
|
});
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1296
|
+
}
|
|
1297
|
+
return _createClass(EJS, [{
|
|
1298
|
+
key: "configure",
|
|
1299
|
+
value: function configure(options) {
|
|
1300
|
+
configSchema(_classPrivateFieldGet2(_config, this), options || {});
|
|
1301
|
+
_classPrivateFieldGet2(_context, this).configure(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this));
|
|
1302
|
+
_classPrivateFieldGet2(_compiler, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1303
|
+
_classPrivateFieldGet2(_cache, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1304
|
+
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1305
|
+
return _classPrivateFieldGet2(_config, this);
|
|
1306
|
+
}
|
|
1307
|
+
}, {
|
|
1308
|
+
key: "render",
|
|
1309
|
+
value: function render(name, data) {
|
|
1310
|
+
var _this = this;
|
|
1311
|
+
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1312
|
+
var scope = this.context(data);
|
|
1313
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function (content) {
|
|
1314
|
+
if (scope.getExtend()) {
|
|
1315
|
+
scope.setExtend(false);
|
|
1316
|
+
var layout = scope.getLayout();
|
|
1317
|
+
var _data = scope.clone();
|
|
1318
|
+
return _this.render(layout, _data);
|
|
1319
|
+
}
|
|
1320
|
+
return content;
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
}, {
|
|
1324
|
+
key: "helpers",
|
|
1325
|
+
value: function helpers(methods) {
|
|
1326
|
+
_classPrivateFieldGet2(_context, this).helpers(extend(_classPrivateFieldGet2(_extend, this), methods));
|
|
1327
|
+
}
|
|
1328
|
+
}, {
|
|
1329
|
+
key: "context",
|
|
1330
|
+
value: function context(data) {
|
|
1331
|
+
return _classPrivateFieldGet2(_context, this).create(data);
|
|
1332
|
+
}
|
|
1333
|
+
}, {
|
|
1334
|
+
key: "compile",
|
|
1335
|
+
value: function compile(content, path) {
|
|
1336
|
+
return _classPrivateFieldGet2(_compiler, this).compile(content, path);
|
|
1337
|
+
}
|
|
1338
|
+
}, {
|
|
1339
|
+
key: "preload",
|
|
1340
|
+
value: function preload(list) {
|
|
1341
|
+
return _classPrivateFieldGet2(_cache, this).load(list || {});
|
|
1342
|
+
}
|
|
1343
|
+
}, {
|
|
1344
|
+
key: "create",
|
|
1345
|
+
value: function create(options) {
|
|
1346
|
+
return new this.constructor(options);
|
|
1347
|
+
}
|
|
1348
|
+
}]);
|
|
1349
|
+
}();
|
|
1350
|
+
|
|
1351
|
+
// export function EJS2(options) {
|
|
1352
|
+
// const self = {
|
|
1353
|
+
// config: {},
|
|
1354
|
+
// helpers: {},
|
|
1355
|
+
// /**
|
|
1356
|
+
// * @type {Context}
|
|
1357
|
+
// */
|
|
1358
|
+
// context: null,
|
|
1359
|
+
// /**
|
|
1360
|
+
// * @type {Compiler}
|
|
1361
|
+
// */
|
|
1362
|
+
// compiler: null,
|
|
1363
|
+
// /**
|
|
1364
|
+
// * @type {Template}
|
|
1365
|
+
// */
|
|
1366
|
+
// template: null,
|
|
1367
|
+
// /**
|
|
1368
|
+
// * @type {Cache}
|
|
1369
|
+
// */
|
|
1370
|
+
// cache: null,
|
|
1371
|
+
// }
|
|
1372
|
+
// /**
|
|
1373
|
+
// *
|
|
1374
|
+
// */
|
|
1375
|
+
// configSchema(self.config, options || {})
|
|
1376
|
+
// self.context = useContext(self.config, self.helpers)
|
|
1377
|
+
// self.compiler = useCompiler(self.config)
|
|
1378
|
+
// self.cache = useCache(self.config)
|
|
1379
|
+
// self.template = useTemplate(self.config, self.cache, self.compiler)
|
|
1380
|
+
// /**
|
|
1381
|
+
// *
|
|
1382
|
+
// * @param {string} path
|
|
1383
|
+
// * @param {ContextScope} scope
|
|
1384
|
+
// * @return {Promise<string>}
|
|
1385
|
+
// */
|
|
1386
|
+
// const output = (path, scope) => {
|
|
1387
|
+
// const { globalHelpers } = self.config
|
|
1388
|
+
// const params = [
|
|
1389
|
+
// scope,
|
|
1390
|
+
// scope.getComponent(),
|
|
1391
|
+
// scope.getBuffer(),
|
|
1392
|
+
// safeValue,
|
|
1393
|
+
// ].concat(
|
|
1394
|
+
// globalHelpers
|
|
1395
|
+
// .filter((name) => isFunction(scope[name]))
|
|
1396
|
+
// .map((name) => scope[name].bind(scope))
|
|
1397
|
+
// )
|
|
1398
|
+
// return self.template
|
|
1399
|
+
// .get(path)
|
|
1400
|
+
// .then((callback) => callback.apply(scope, params))
|
|
1401
|
+
// }
|
|
1402
|
+
// /**
|
|
1403
|
+
// *
|
|
1404
|
+
// * @param name
|
|
1405
|
+
// * @return {Promise<string>}
|
|
1406
|
+
// */
|
|
1407
|
+
// const require = (name) => {
|
|
1408
|
+
// const filepath = ext(name, self.config.extension)
|
|
1409
|
+
// const scope = context({})
|
|
1410
|
+
// return output(filepath, scope).then(() => scope.getMacro())
|
|
1411
|
+
// }
|
|
1412
|
+
// /**
|
|
1413
|
+
// *
|
|
1414
|
+
// * @param {string} name
|
|
1415
|
+
// * @param {{}} [data]
|
|
1416
|
+
// * @return {Promise<string>}
|
|
1417
|
+
// */
|
|
1418
|
+
// const render = (name, data) => {
|
|
1419
|
+
// const filepath = ext(name, self.config.extension)
|
|
1420
|
+
// const scope = context(data)
|
|
1421
|
+
// return output(filepath, scope).then((content) => {
|
|
1422
|
+
// if (scope.getExtend()) {
|
|
1423
|
+
// scope.setExtend(false)
|
|
1424
|
+
// const layout = scope.getLayout()
|
|
1425
|
+
// const data = scope.clone()
|
|
1426
|
+
// return render(layout, data)
|
|
1427
|
+
// }
|
|
1428
|
+
// return content
|
|
1429
|
+
// })
|
|
1430
|
+
// }
|
|
1431
|
+
// /**
|
|
1432
|
+
// *
|
|
1433
|
+
// * @param options
|
|
1434
|
+
// * @return {{}}
|
|
1435
|
+
// */
|
|
1436
|
+
// const configure = (options = {}) => {
|
|
1437
|
+
// configSchema(self.config, options || {})
|
|
1438
|
+
// self.context.configure(self.config, self.helpers)
|
|
1439
|
+
// self.compiler.configure(self.config)
|
|
1440
|
+
// self.cache.configure(self.config)
|
|
1441
|
+
// self.template.configure(self.config)
|
|
1442
|
+
// return self.config
|
|
1443
|
+
// }
|
|
1444
|
+
// /**
|
|
1445
|
+
// *
|
|
1446
|
+
// * @param methods
|
|
1447
|
+
// */
|
|
1448
|
+
// const helpers = (methods) => {
|
|
1449
|
+
// self.context.helpers(extend(self.helpers, methods))
|
|
1450
|
+
// }
|
|
1451
|
+
// /**
|
|
1452
|
+
// *
|
|
1453
|
+
// * @param list
|
|
1454
|
+
// * @return {*}
|
|
1455
|
+
// */
|
|
1456
|
+
// const preload = (list) => {
|
|
1457
|
+
// return self.cache.load(list || {})
|
|
1458
|
+
// }
|
|
1459
|
+
// /**
|
|
1460
|
+
// *
|
|
1461
|
+
// * @param options
|
|
1462
|
+
// * @return {any}
|
|
1463
|
+
// */
|
|
1464
|
+
// const create = (options) => {
|
|
1465
|
+
// return EJS(options)
|
|
1466
|
+
// }
|
|
1467
|
+
// /**
|
|
1468
|
+
// *
|
|
1469
|
+
// * @param content
|
|
1470
|
+
// * @param path
|
|
1471
|
+
// * @return {Function}
|
|
1472
|
+
// */
|
|
1473
|
+
// const compile = (content, path) => {
|
|
1474
|
+
// return self.compiler.compile(content, path)
|
|
1475
|
+
// }
|
|
1476
|
+
// /**
|
|
1477
|
+
// *
|
|
1478
|
+
// * @param data
|
|
1479
|
+
// * @return {ContextScope}
|
|
1480
|
+
// */
|
|
1481
|
+
// const context = (data = {}) => {
|
|
1482
|
+
// return self.context.create(data)
|
|
1483
|
+
// }
|
|
1484
|
+
// /**
|
|
1485
|
+
// *
|
|
1486
|
+
// */
|
|
1487
|
+
// helpers({ require, render })
|
|
1488
|
+
// /**
|
|
1489
|
+
// *
|
|
1490
|
+
// */
|
|
1491
|
+
// return {
|
|
1492
|
+
// configure,
|
|
1493
|
+
// helpers,
|
|
1494
|
+
// preload,
|
|
1495
|
+
// context,
|
|
1496
|
+
// compile,
|
|
1497
|
+
// create,
|
|
1498
|
+
// render,
|
|
1499
|
+
// }
|
|
1500
|
+
// }
|
|
1501
|
+
function _output(path, scope) {
|
|
1502
|
+
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1503
|
+
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1504
|
+
var params = [scope, scope.getComponent(), scope.getBuffer(), safeValue].concat(globalHelpers.filter(function (name) {
|
|
1505
|
+
return isFunction(scope[name]);
|
|
1506
|
+
}).map(function (name) {
|
|
1507
|
+
return scope[name].bind(scope);
|
|
1508
|
+
}));
|
|
1509
|
+
return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
|
|
1510
|
+
return callback.apply(scope, params);
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
function _require(name) {
|
|
1514
|
+
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1515
|
+
var scope = this.context({});
|
|
1516
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1517
|
+
return scope.getMacro();
|
|
1243
1518
|
});
|
|
1244
|
-
return this;
|
|
1245
1519
|
}
|
|
1246
1520
|
|
|
1247
|
-
var hash = Math.floor(Math.random() * 1e12).toString(36);
|
|
1248
1521
|
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
1522
|
var getOrigin = function getOrigin(url, secure) {
|
|
1268
1523
|
url = new URL(url);
|
|
1269
|
-
|
|
1524
|
+
url.protocol = secure ? 'https:' : 'http:';
|
|
1270
1525
|
return url.origin;
|
|
1271
1526
|
};
|
|
1527
|
+
var _EJS = new EJS({
|
|
1528
|
+
cache: false,
|
|
1529
|
+
withObject: false,
|
|
1530
|
+
resolver: function resolver(path, name) {
|
|
1531
|
+
return new Promise(function (resolve, reject) {
|
|
1532
|
+
if (templates.hasOwnProperty(name)) {
|
|
1533
|
+
resolve(templates[name]);
|
|
1534
|
+
} else {
|
|
1535
|
+
reject(new TemplateNotFound("template ".concat(name, " not found")));
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
}),
|
|
1540
|
+
render = _EJS.render,
|
|
1541
|
+
context = _EJS.context,
|
|
1542
|
+
helpers = _EJS.helpers,
|
|
1543
|
+
configure = _EJS.configure,
|
|
1544
|
+
create = _EJS.create;
|
|
1272
1545
|
function setTemplates(list) {
|
|
1273
1546
|
Object.assign(templates, list || {});
|
|
1274
1547
|
}
|
|
1275
1548
|
|
|
1276
1549
|
/**
|
|
1277
|
-
* @typedef {
|
|
1550
|
+
* @typedef {{}} HonoContext
|
|
1278
1551
|
* @property {function(*):Promise<Response>} html
|
|
1279
1552
|
* @property {function():Promise<Response>} notFound
|
|
1280
1553
|
* @property {function(methods:{}):void} helpers
|
|
@@ -1285,12 +1558,11 @@ function setTemplates(list) {
|
|
|
1285
1558
|
|
|
1286
1559
|
/**
|
|
1287
1560
|
* @param {Object<string,any>} options
|
|
1288
|
-
* @return {(function(c:
|
|
1561
|
+
* @return {(function(c:HonoContext, next): Promise<any>)|*}
|
|
1289
1562
|
*/
|
|
1290
1563
|
function setRenderer() {
|
|
1291
1564
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1292
|
-
|
|
1293
|
-
version = _ref$version === void 0 ? hash : _ref$version,
|
|
1565
|
+
version = _ref.version,
|
|
1294
1566
|
_ref$secure = _ref.secure,
|
|
1295
1567
|
secure = _ref$secure === void 0 ? true : _ref$secure;
|
|
1296
1568
|
return /*#__PURE__*/function () {
|
|
@@ -1327,7 +1599,8 @@ function setRenderer() {
|
|
|
1327
1599
|
};
|
|
1328
1600
|
}();
|
|
1329
1601
|
}
|
|
1330
|
-
|
|
1602
|
+
|
|
1603
|
+
//export { render, context, helpers, configure, create }
|
|
1331
1604
|
|
|
1332
1605
|
exports.TemplateError = TemplateError;
|
|
1333
1606
|
exports.TemplateNotFound = TemplateNotFound;
|
|
@@ -1339,4 +1612,3 @@ exports.helpers = helpers;
|
|
|
1339
1612
|
exports.render = render;
|
|
1340
1613
|
exports.setRenderer = setRenderer;
|
|
1341
1614
|
exports.setTemplates = setTemplates;
|
|
1342
|
-
exports.version = version;
|