@kosatyi/ejs 0.0.105 → 0.0.106
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/bin/bundler.js +1 -1
- package/dist/cjs/browser.js +329 -554
- package/dist/cjs/bundler.js +61 -68
- package/dist/cjs/index.js +333 -558
- package/dist/cjs/worker.js +329 -553
- package/dist/esm/browser.js +276 -276
- package/dist/esm/bundler.js +62 -69
- package/dist/esm/index.js +280 -280
- package/dist/esm/worker.js +276 -276
- package/dist/umd/browser.js +868 -1093
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/index.js +901 -1126
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +329 -553
- package/dist/umd/worker.min.js +2 -2
- package/package.json +1 -1
package/dist/umd/worker.js
CHANGED
|
@@ -7,14 +7,6 @@
|
|
|
7
7
|
function _OverloadYield(e, d) {
|
|
8
8
|
this.v = e, this.k = d;
|
|
9
9
|
}
|
|
10
|
-
function _assertClassBrand(e, t, n) {
|
|
11
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
12
|
-
throw new TypeError("Private element is not present on this object");
|
|
13
|
-
}
|
|
14
|
-
function _assertThisInitialized(e) {
|
|
15
|
-
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
16
|
-
return e;
|
|
17
|
-
}
|
|
18
10
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
19
11
|
try {
|
|
20
12
|
var i = n[a](c),
|
|
@@ -40,90 +32,6 @@
|
|
|
40
32
|
});
|
|
41
33
|
};
|
|
42
34
|
}
|
|
43
|
-
function _callSuper(t, o, e) {
|
|
44
|
-
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
45
|
-
}
|
|
46
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
47
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
48
|
-
}
|
|
49
|
-
function _classCallCheck(a, n) {
|
|
50
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
51
|
-
}
|
|
52
|
-
function _classPrivateFieldGet2(s, a) {
|
|
53
|
-
return s.get(_assertClassBrand(s, a));
|
|
54
|
-
}
|
|
55
|
-
function _classPrivateFieldInitSpec(e, t, a) {
|
|
56
|
-
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
57
|
-
}
|
|
58
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
59
|
-
return s.set(_assertClassBrand(s, a), r), r;
|
|
60
|
-
}
|
|
61
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
62
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
63
|
-
}
|
|
64
|
-
function _construct(t, e, r) {
|
|
65
|
-
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
66
|
-
var o = [null];
|
|
67
|
-
o.push.apply(o, e);
|
|
68
|
-
var p = new (t.bind.apply(t, o))();
|
|
69
|
-
return r && _setPrototypeOf(p, r.prototype), p;
|
|
70
|
-
}
|
|
71
|
-
function _defineProperties(e, r) {
|
|
72
|
-
for (var t = 0; t < r.length; t++) {
|
|
73
|
-
var o = r[t];
|
|
74
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function _createClass(e, r, t) {
|
|
78
|
-
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
79
|
-
writable: !1
|
|
80
|
-
}), e;
|
|
81
|
-
}
|
|
82
|
-
function _defineProperty(e, r, t) {
|
|
83
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
84
|
-
value: t,
|
|
85
|
-
enumerable: !0,
|
|
86
|
-
configurable: !0,
|
|
87
|
-
writable: !0
|
|
88
|
-
}) : e[r] = t, e;
|
|
89
|
-
}
|
|
90
|
-
function _getPrototypeOf(t) {
|
|
91
|
-
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
92
|
-
return t.__proto__ || Object.getPrototypeOf(t);
|
|
93
|
-
}, _getPrototypeOf(t);
|
|
94
|
-
}
|
|
95
|
-
function _inherits(t, e) {
|
|
96
|
-
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
97
|
-
t.prototype = Object.create(e && e.prototype, {
|
|
98
|
-
constructor: {
|
|
99
|
-
value: t,
|
|
100
|
-
writable: !0,
|
|
101
|
-
configurable: !0
|
|
102
|
-
}
|
|
103
|
-
}), Object.defineProperty(t, "prototype", {
|
|
104
|
-
writable: !1
|
|
105
|
-
}), e && _setPrototypeOf(t, e);
|
|
106
|
-
}
|
|
107
|
-
function _isNativeFunction(t) {
|
|
108
|
-
try {
|
|
109
|
-
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
110
|
-
} catch (n) {
|
|
111
|
-
return "function" == typeof t;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function _isNativeReflectConstruct() {
|
|
115
|
-
try {
|
|
116
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
117
|
-
} catch (t) {}
|
|
118
|
-
return (_isNativeReflectConstruct = function () {
|
|
119
|
-
return !!t;
|
|
120
|
-
})();
|
|
121
|
-
}
|
|
122
|
-
function _possibleConstructorReturn(t, e) {
|
|
123
|
-
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
124
|
-
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
125
|
-
return _assertThisInitialized(t);
|
|
126
|
-
}
|
|
127
35
|
function _regenerator() {
|
|
128
36
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
129
37
|
var e,
|
|
@@ -297,47 +205,6 @@
|
|
|
297
205
|
}
|
|
298
206
|
throw new TypeError(typeof e + " is not iterable");
|
|
299
207
|
}
|
|
300
|
-
function _setPrototypeOf(t, e) {
|
|
301
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
302
|
-
return t.__proto__ = e, t;
|
|
303
|
-
}, _setPrototypeOf(t, e);
|
|
304
|
-
}
|
|
305
|
-
function _toPrimitive(t, r) {
|
|
306
|
-
if ("object" != typeof t || !t) return t;
|
|
307
|
-
var e = t[Symbol.toPrimitive];
|
|
308
|
-
if (void 0 !== e) {
|
|
309
|
-
var i = e.call(t, r);
|
|
310
|
-
if ("object" != typeof i) return i;
|
|
311
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
312
|
-
}
|
|
313
|
-
return (String )(t);
|
|
314
|
-
}
|
|
315
|
-
function _toPropertyKey(t) {
|
|
316
|
-
var i = _toPrimitive(t, "string");
|
|
317
|
-
return "symbol" == typeof i ? i : i + "";
|
|
318
|
-
}
|
|
319
|
-
function _wrapNativeSuper(t) {
|
|
320
|
-
var r = "function" == typeof Map ? new Map() : void 0;
|
|
321
|
-
return _wrapNativeSuper = function (t) {
|
|
322
|
-
if (null === t || !_isNativeFunction(t)) return t;
|
|
323
|
-
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
324
|
-
if (void 0 !== r) {
|
|
325
|
-
if (r.has(t)) return r.get(t);
|
|
326
|
-
r.set(t, Wrapper);
|
|
327
|
-
}
|
|
328
|
-
function Wrapper() {
|
|
329
|
-
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
330
|
-
}
|
|
331
|
-
return Wrapper.prototype = Object.create(t.prototype, {
|
|
332
|
-
constructor: {
|
|
333
|
-
value: Wrapper,
|
|
334
|
-
enumerable: !1,
|
|
335
|
-
writable: !0,
|
|
336
|
-
configurable: !0
|
|
337
|
-
}
|
|
338
|
-
}), _setPrototypeOf(Wrapper, t);
|
|
339
|
-
}, _wrapNativeSuper(t);
|
|
340
|
-
}
|
|
341
208
|
function _regeneratorRuntime() {
|
|
342
209
|
|
|
343
210
|
var r = _regenerator(),
|
|
@@ -468,12 +335,6 @@
|
|
|
468
335
|
var check = value;
|
|
469
336
|
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
470
337
|
};
|
|
471
|
-
var instanceOf = function instanceOf(object, instance) {
|
|
472
|
-
return Boolean(object instanceof instance);
|
|
473
|
-
};
|
|
474
|
-
var assertInstanceOf = function assertInstanceOf(object, instance) {
|
|
475
|
-
if (instanceOf(object, instance) === false) throw new TypeError("".concat(object, " in not instance of ").concat(instance));
|
|
476
|
-
};
|
|
477
338
|
var getPath = function getPath(context, name, strict) {
|
|
478
339
|
var data = context;
|
|
479
340
|
var chunks = String(name).split('.');
|
|
@@ -494,14 +355,6 @@
|
|
|
494
355
|
}
|
|
495
356
|
return [data, prop];
|
|
496
357
|
};
|
|
497
|
-
var bindContext = function bindContext(object) {
|
|
498
|
-
var methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
499
|
-
methods.forEach(function (name) {
|
|
500
|
-
if (name in object) {
|
|
501
|
-
object[name] = object[name].bind(object);
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
};
|
|
505
358
|
var ext = function ext(path, defaults) {
|
|
506
359
|
var ext = path.split('.').pop();
|
|
507
360
|
if (ext !== defaults) {
|
|
@@ -616,7 +469,7 @@
|
|
|
616
469
|
};
|
|
617
470
|
|
|
618
471
|
var configSchema = function configSchema(config, options) {
|
|
619
|
-
extend(config, {
|
|
472
|
+
return extend(config, {
|
|
620
473
|
path: typeProp(isString, defaults.path, config.path, options.path),
|
|
621
474
|
"export": typeProp(isString, defaults["export"], config["export"], options["export"]),
|
|
622
475
|
resolver: typeProp(isFunction, defaults.resolver, config.resolver, options.resolver),
|
|
@@ -630,223 +483,192 @@
|
|
|
630
483
|
});
|
|
631
484
|
};
|
|
632
485
|
|
|
633
|
-
var
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}, {
|
|
651
|
-
key: "get",
|
|
652
|
-
value: function get(key) {
|
|
653
|
-
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
654
|
-
return _classPrivateFieldGet2(_list, this)[key];
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}, {
|
|
658
|
-
key: "set",
|
|
659
|
-
value: function set(key, value) {
|
|
660
|
-
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
661
|
-
_classPrivateFieldGet2(_list, this)[key] = value;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}, {
|
|
665
|
-
key: "exist",
|
|
666
|
-
value: function exist(key) {
|
|
667
|
-
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
668
|
-
return hasProp(_classPrivateFieldGet2(_list, this), key);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}, {
|
|
672
|
-
key: "clear",
|
|
673
|
-
value: function clear() {
|
|
674
|
-
_classPrivateFieldSet2(_list, this, {});
|
|
675
|
-
}
|
|
676
|
-
}, {
|
|
677
|
-
key: "remove",
|
|
678
|
-
value: function remove(key) {
|
|
679
|
-
delete _classPrivateFieldGet2(_list, this)[key];
|
|
486
|
+
var Template = function Template(options, cache, compiler) {
|
|
487
|
+
var config = {
|
|
488
|
+
path: null,
|
|
489
|
+
resolver: null
|
|
490
|
+
};
|
|
491
|
+
var resolve = function resolve(path) {
|
|
492
|
+
return config.resolver(config.path, path);
|
|
493
|
+
};
|
|
494
|
+
var result = function result(template, content) {
|
|
495
|
+
cache.set(template, content);
|
|
496
|
+
return content;
|
|
497
|
+
};
|
|
498
|
+
var compile = function compile(content, template) {
|
|
499
|
+
if (isFunction(content)) {
|
|
500
|
+
return content;
|
|
501
|
+
} else {
|
|
502
|
+
return compiler.compile(content, template);
|
|
680
503
|
}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
return
|
|
504
|
+
};
|
|
505
|
+
var get = function get(template) {
|
|
506
|
+
if (cache.exist(template)) {
|
|
507
|
+
return cache.resolve(template);
|
|
685
508
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
509
|
+
return resolve(template).then(function (content) {
|
|
510
|
+
return result(template, compile(content, template));
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
var configure = function configure(options) {
|
|
514
|
+
config.path = options.path;
|
|
515
|
+
if (isFunction(options.resolver)) {
|
|
516
|
+
config.resolver = options.resolver;
|
|
693
517
|
}
|
|
694
|
-
}
|
|
695
|
-
|
|
518
|
+
};
|
|
519
|
+
configure(options);
|
|
520
|
+
return {
|
|
521
|
+
get: get,
|
|
522
|
+
configure: configure,
|
|
523
|
+
compile: compile
|
|
524
|
+
};
|
|
525
|
+
};
|
|
696
526
|
|
|
697
|
-
var
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
_classCallCheck(this, Compiler);
|
|
702
|
-
_classPrivateFieldInitSpec(this, _config$1, {});
|
|
703
|
-
_classPrivateFieldInitSpec(this, _symbols, [{
|
|
704
|
-
symbol: '-',
|
|
705
|
-
format: function format(value) {
|
|
706
|
-
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
|
|
707
|
-
}
|
|
708
|
-
}, {
|
|
709
|
-
symbol: '=',
|
|
710
|
-
format: function format(value) {
|
|
711
|
-
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
|
|
712
|
-
}
|
|
713
|
-
}, {
|
|
714
|
-
symbol: '#',
|
|
715
|
-
format: function format(value) {
|
|
716
|
-
return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
|
|
717
|
-
}
|
|
718
|
-
}, {
|
|
719
|
-
symbol: '',
|
|
720
|
-
format: function format(value) {
|
|
721
|
-
return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
|
|
722
|
-
}
|
|
723
|
-
}]);
|
|
724
|
-
this.configure(config);
|
|
527
|
+
var configSymbols = [{
|
|
528
|
+
symbol: '-',
|
|
529
|
+
format: function format(value) {
|
|
530
|
+
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
|
|
725
531
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
532
|
+
}, {
|
|
533
|
+
symbol: '=',
|
|
534
|
+
format: function format(value) {
|
|
535
|
+
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
|
|
536
|
+
}
|
|
537
|
+
}, {
|
|
538
|
+
symbol: '#',
|
|
539
|
+
format: function format(value) {
|
|
540
|
+
return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
|
|
541
|
+
}
|
|
542
|
+
}, {
|
|
543
|
+
symbol: '',
|
|
544
|
+
format: function format(value) {
|
|
545
|
+
return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
|
|
546
|
+
}
|
|
547
|
+
}];
|
|
548
|
+
var Compiler = function Compiler(options) {
|
|
549
|
+
var config = {};
|
|
550
|
+
var configure = function configure(options) {
|
|
551
|
+
config.withObject = options.withObject;
|
|
552
|
+
config.rmWhitespace = options.rmWhitespace;
|
|
553
|
+
config.token = options.token;
|
|
554
|
+
config.vars = options.vars;
|
|
555
|
+
config.globalHelpers = options.globalHelpers;
|
|
556
|
+
config.matches = [];
|
|
557
|
+
config.formats = [];
|
|
558
|
+
config.slurp = {
|
|
559
|
+
match: '[s\t\n]*',
|
|
560
|
+
start: [config.token.start, '_'],
|
|
561
|
+
end: ['_', config.token.end]
|
|
562
|
+
};
|
|
563
|
+
configSymbols.forEach(function (item) {
|
|
564
|
+
config.matches.push(config.token.start.concat(item.symbol).concat(config.token.regex).concat(config.token.end));
|
|
565
|
+
config.formats.push(item.format.bind(config.vars));
|
|
566
|
+
});
|
|
567
|
+
config.regex = new RegExp(config.matches.join('|').concat('|$'), 'g');
|
|
568
|
+
config.slurpStart = new RegExp([config.slurp.match, config.slurp.start.join('')].join(''), 'gm');
|
|
569
|
+
config.slurpEnd = new RegExp([config.slurp.end.join(''), config.slurp.match].join(''), 'gm');
|
|
570
|
+
};
|
|
571
|
+
var compile = function compile(content, path) {
|
|
572
|
+
var _config$vars = config.vars,
|
|
573
|
+
SCOPE = _config$vars.SCOPE,
|
|
574
|
+
SAFE = _config$vars.SAFE,
|
|
575
|
+
BUFFER = _config$vars.BUFFER,
|
|
576
|
+
COMPONENT = _config$vars.COMPONENT,
|
|
577
|
+
ELEMENT = _config$vars.ELEMENT;
|
|
578
|
+
var GLOBALS = config.globalHelpers;
|
|
579
|
+
if (config.rmWhitespace) {
|
|
580
|
+
content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
749
581
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
COMPONENT = _classPrivateFieldGet2$1.COMPONENT,
|
|
759
|
-
ELEMENT = _classPrivateFieldGet2$1.ELEMENT;
|
|
760
|
-
var GLOBALS = _classPrivateFieldGet2(_config$1, this).globalHelpers;
|
|
761
|
-
if (_classPrivateFieldGet2(_config$1, this).rmWhitespace) {
|
|
762
|
-
content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
763
|
-
}
|
|
764
|
-
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);
|
|
765
|
-
var source = "".concat(BUFFER, "('");
|
|
766
|
-
matchTokens(_classPrivateFieldGet2(_config$1, this).regex, content, function (params, index, offset) {
|
|
767
|
-
source += symbols(content.slice(index, offset));
|
|
768
|
-
params.forEach(function (value, index) {
|
|
769
|
-
if (value) {
|
|
770
|
-
source += _classPrivateFieldGet2(_config$1, _this2).formats[index](value);
|
|
771
|
-
}
|
|
772
|
-
});
|
|
582
|
+
content = String(content).replace(config.slurpStart, config.token.start).replace(config.slurpEnd, config.token.end);
|
|
583
|
+
var source = "".concat(BUFFER, "('");
|
|
584
|
+
matchTokens(config.regex, content, function (params, index, offset) {
|
|
585
|
+
source += symbols(content.slice(index, offset));
|
|
586
|
+
params.forEach(function (value, index) {
|
|
587
|
+
if (value) {
|
|
588
|
+
source += config.formats[index](value);
|
|
589
|
+
}
|
|
773
590
|
});
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
return result;
|
|
591
|
+
});
|
|
592
|
+
source += "');";
|
|
593
|
+
source = "try{".concat(source, "}catch(e){return ").concat(BUFFER, ".error(e)}");
|
|
594
|
+
if (config.withObject) {
|
|
595
|
+
source = "with(".concat(SCOPE, "){").concat(source, "}");
|
|
596
|
+
}
|
|
597
|
+
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
598
|
+
source += "\n//# sourceURL=".concat(path);
|
|
599
|
+
var result = null;
|
|
600
|
+
var params = [SCOPE, COMPONENT, ELEMENT, BUFFER, SAFE].concat(GLOBALS);
|
|
601
|
+
try {
|
|
602
|
+
result = Function.apply(null, params.concat(source));
|
|
603
|
+
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
604
|
+
} catch (e) {
|
|
605
|
+
e.filename = path;
|
|
606
|
+
e.source = source;
|
|
607
|
+
throw e;
|
|
792
608
|
}
|
|
793
|
-
|
|
794
|
-
|
|
609
|
+
return result;
|
|
610
|
+
};
|
|
611
|
+
configure(options);
|
|
612
|
+
return {
|
|
613
|
+
configure: configure,
|
|
614
|
+
compile: compile
|
|
615
|
+
};
|
|
616
|
+
};
|
|
795
617
|
|
|
796
|
-
var
|
|
797
|
-
var
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
_classPrivateMethodInitSpec(this, _Template_brand);
|
|
805
|
-
_classPrivateFieldInitSpec(this, _path, void 0);
|
|
806
|
-
_classPrivateFieldInitSpec(this, _cache$1, void 0);
|
|
807
|
-
_classPrivateFieldInitSpec(this, _compiler$1, void 0);
|
|
808
|
-
_classPrivateFieldInitSpec(this, _resolver, void 0);
|
|
809
|
-
assertInstanceOf(cache, Cache);
|
|
810
|
-
assertInstanceOf(compiler, Compiler);
|
|
811
|
-
_classPrivateFieldSet2(_cache$1, this, cache);
|
|
812
|
-
_classPrivateFieldSet2(_compiler$1, this, compiler);
|
|
813
|
-
this.configure(config);
|
|
814
|
-
}
|
|
815
|
-
return _createClass(Template, [{
|
|
816
|
-
key: "configure",
|
|
817
|
-
value: function configure(config) {
|
|
818
|
-
_classPrivateFieldSet2(_path, this, config.path);
|
|
819
|
-
if (isFunction(config.resolver)) {
|
|
820
|
-
_classPrivateFieldSet2(_resolver, this, config.resolver);
|
|
821
|
-
}
|
|
618
|
+
var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
|
|
619
|
+
var Cache = function Cache() {
|
|
620
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
621
|
+
var config = {};
|
|
622
|
+
var list = {};
|
|
623
|
+
var load = function load(data) {
|
|
624
|
+
if (config.enabled) {
|
|
625
|
+
extend(list, data || {});
|
|
822
626
|
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
if (_classPrivateFieldGet2(_cache$1, this).exist(template)) {
|
|
828
|
-
return _classPrivateFieldGet2(_cache$1, this).resolve(template);
|
|
829
|
-
}
|
|
830
|
-
return _assertClassBrand(_Template_brand, this, _resolve).call(this, template).then(function (content) {
|
|
831
|
-
return _assertClassBrand(_Template_brand, _this, _result).call(_this, template, _assertClassBrand(_Template_brand, _this, _compile).call(_this, content, template));
|
|
832
|
-
});
|
|
627
|
+
};
|
|
628
|
+
var get = function get(key) {
|
|
629
|
+
if (config.enabled) {
|
|
630
|
+
return list[key];
|
|
833
631
|
}
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
632
|
+
};
|
|
633
|
+
var set = function set(key, value) {
|
|
634
|
+
if (config.enabled) {
|
|
635
|
+
list[key] = value;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
var exist = function exist(key) {
|
|
639
|
+
if (config.enabled) {
|
|
640
|
+
return hasProp(list, key);
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
var clear = function clear() {
|
|
644
|
+
Object.keys(list).forEach(remove);
|
|
645
|
+
};
|
|
646
|
+
var remove = function remove(key) {
|
|
647
|
+
delete list[key];
|
|
648
|
+
};
|
|
649
|
+
var resolve = function resolve(key) {
|
|
650
|
+
return Promise.resolve(get(key));
|
|
651
|
+
};
|
|
652
|
+
var configure = function configure() {
|
|
653
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
654
|
+
config.enabled = options.cache;
|
|
655
|
+
config["export"] = options["export"];
|
|
656
|
+
if (isNode() === false) {
|
|
657
|
+
load(global[config["export"]]);
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
configure(options);
|
|
661
|
+
return {
|
|
662
|
+
configure: configure,
|
|
663
|
+
load: load,
|
|
664
|
+
set: set,
|
|
665
|
+
get: get,
|
|
666
|
+
exist: exist,
|
|
667
|
+
clear: clear,
|
|
668
|
+
remove: remove,
|
|
669
|
+
resolve: resolve
|
|
670
|
+
};
|
|
671
|
+
};
|
|
850
672
|
|
|
851
673
|
var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
852
674
|
var space = ' ';
|
|
@@ -873,61 +695,50 @@
|
|
|
873
695
|
return result.join('');
|
|
874
696
|
};
|
|
875
697
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
},
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
return this.message;
|
|
895
|
-
}
|
|
896
|
-
}, {
|
|
897
|
-
key: "toString",
|
|
898
|
-
value: function toString() {
|
|
899
|
-
return this.getMessage();
|
|
900
|
-
}
|
|
901
|
-
}]);
|
|
902
|
-
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
903
|
-
var TemplateNotFound = /*#__PURE__*/function (_TemplateError2) {
|
|
904
|
-
function TemplateNotFound() {
|
|
905
|
-
var _this2;
|
|
906
|
-
_classCallCheck(this, TemplateNotFound);
|
|
907
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
908
|
-
args[_key] = arguments[_key];
|
|
909
|
-
}
|
|
910
|
-
_this2 = _callSuper(this, TemplateNotFound, [].concat(args));
|
|
911
|
-
_defineProperty(_this2, "code", 404);
|
|
912
|
-
return _this2;
|
|
913
|
-
}
|
|
914
|
-
_inherits(TemplateNotFound, _TemplateError2);
|
|
915
|
-
return _createClass(TemplateNotFound);
|
|
916
|
-
}(TemplateError);
|
|
917
|
-
var TemplateSyntaxError = /*#__PURE__*/function (_TemplateError3) {
|
|
918
|
-
function TemplateSyntaxError() {
|
|
919
|
-
var _this3;
|
|
920
|
-
_classCallCheck(this, TemplateSyntaxError);
|
|
921
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
922
|
-
args[_key2] = arguments[_key2];
|
|
923
|
-
}
|
|
924
|
-
_this3 = _callSuper(this, TemplateSyntaxError, [].concat(args));
|
|
925
|
-
_defineProperty(_this3, "code", 500);
|
|
926
|
-
return _this3;
|
|
698
|
+
/**
|
|
699
|
+
*
|
|
700
|
+
* @constructor
|
|
701
|
+
*/
|
|
702
|
+
function TemplateError() {
|
|
703
|
+
TemplateError.call(this);
|
|
704
|
+
}
|
|
705
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
706
|
+
Object.assign(TemplateError.prototype, {
|
|
707
|
+
code: 0,
|
|
708
|
+
getCode: function getCode() {
|
|
709
|
+
return this.code;
|
|
710
|
+
},
|
|
711
|
+
getMessage: function getMessage() {
|
|
712
|
+
return this.message;
|
|
713
|
+
},
|
|
714
|
+
toString: function toString() {
|
|
715
|
+
return this.getMessage();
|
|
927
716
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
*
|
|
721
|
+
* @constructor
|
|
722
|
+
*/
|
|
723
|
+
function TemplateNotFound() {
|
|
724
|
+
TemplateError.call(this);
|
|
725
|
+
}
|
|
726
|
+
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
727
|
+
Object.assign(TemplateNotFound.prototype, {
|
|
728
|
+
code: 404
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
*
|
|
733
|
+
* @constructor
|
|
734
|
+
*/
|
|
735
|
+
function TemplateSyntaxError() {
|
|
736
|
+
TemplateError.call(this);
|
|
737
|
+
}
|
|
738
|
+
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
739
|
+
Object.assign(TemplateSyntaxError.prototype, {
|
|
740
|
+
code: 500
|
|
741
|
+
});
|
|
931
742
|
|
|
932
743
|
function resolve(list) {
|
|
933
744
|
return Promise.all(list || []).then(function (list) {
|
|
@@ -983,6 +794,7 @@
|
|
|
983
794
|
SCOPE = _config$vars.SCOPE,
|
|
984
795
|
COMPONENT = _config$vars.COMPONENT,
|
|
985
796
|
ELEMENT = _config$vars.ELEMENT;
|
|
797
|
+
|
|
986
798
|
/**
|
|
987
799
|
*
|
|
988
800
|
* @type {symbol}
|
|
@@ -1279,149 +1091,113 @@
|
|
|
1279
1091
|
});
|
|
1280
1092
|
return ContextScope;
|
|
1281
1093
|
};
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
}
|
|
1304
|
-
}]);
|
|
1305
|
-
}();
|
|
1094
|
+
var Context = function Context(options, methods) {
|
|
1095
|
+
/**
|
|
1096
|
+
* @type {InstanceType<ContextScope>}
|
|
1097
|
+
*/
|
|
1098
|
+
var Scope;
|
|
1099
|
+
var create = function create(data) {
|
|
1100
|
+
return new Scope(data);
|
|
1101
|
+
};
|
|
1102
|
+
var helpers = function helpers(methods) {
|
|
1103
|
+
extend(Scope.prototype, methods || {});
|
|
1104
|
+
};
|
|
1105
|
+
var configure = function configure(options, methods) {
|
|
1106
|
+
Scope = createContextScope(options, methods);
|
|
1107
|
+
};
|
|
1108
|
+
configure(options, methods);
|
|
1109
|
+
return {
|
|
1110
|
+
configure: configure,
|
|
1111
|
+
create: create,
|
|
1112
|
+
helpers: helpers
|
|
1113
|
+
};
|
|
1114
|
+
};
|
|
1306
1115
|
|
|
1307
|
-
var
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
function
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
//
|
|
1332
|
-
this.helpers({
|
|
1333
|
-
require: this.require,
|
|
1334
|
-
render: this.render
|
|
1116
|
+
var _EJS$1 = function EJS() {
|
|
1117
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1118
|
+
var config = configSchema({}, options);
|
|
1119
|
+
var methods = {};
|
|
1120
|
+
var context = Context(config, methods);
|
|
1121
|
+
var compiler = Compiler(config);
|
|
1122
|
+
var cache = Cache(config);
|
|
1123
|
+
var template = Template(config, cache, compiler);
|
|
1124
|
+
var configure = function configure() {
|
|
1125
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1126
|
+
configSchema(config, options || {});
|
|
1127
|
+
context.configure(config, methods);
|
|
1128
|
+
compiler.configure(config);
|
|
1129
|
+
cache.configure(config);
|
|
1130
|
+
template.configure(config);
|
|
1131
|
+
return config;
|
|
1132
|
+
};
|
|
1133
|
+
var filePath = function filePath(name) {
|
|
1134
|
+
return ext(name, config.extension);
|
|
1135
|
+
};
|
|
1136
|
+
var require = function require(name) {
|
|
1137
|
+
var scope = createContext({});
|
|
1138
|
+
return output(filePath(name), scope).then(function () {
|
|
1139
|
+
return scope.getMacro();
|
|
1335
1140
|
});
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
}
|
|
1385
|
-
}, {
|
|
1386
|
-
key: "helpers",
|
|
1387
|
-
value: function helpers(methods) {
|
|
1388
|
-
_classPrivateFieldGet2(_context, this).helpers(extend(_classPrivateFieldGet2(_extend, this), methods));
|
|
1389
|
-
}
|
|
1390
|
-
}, {
|
|
1391
|
-
key: "context",
|
|
1392
|
-
value: function context(data) {
|
|
1393
|
-
return _classPrivateFieldGet2(_context, this).create(data);
|
|
1394
|
-
}
|
|
1395
|
-
}, {
|
|
1396
|
-
key: "compile",
|
|
1397
|
-
value: function compile(content, path) {
|
|
1398
|
-
return _classPrivateFieldGet2(_compiler, this).compile(content, path);
|
|
1399
|
-
}
|
|
1400
|
-
}, {
|
|
1401
|
-
key: "preload",
|
|
1402
|
-
value: function preload(list) {
|
|
1403
|
-
return _classPrivateFieldGet2(_cache, this).load(list || {});
|
|
1404
|
-
}
|
|
1405
|
-
}, {
|
|
1406
|
-
key: "create",
|
|
1407
|
-
value: function create(options) {
|
|
1408
|
-
return new this.constructor(options);
|
|
1409
|
-
}
|
|
1410
|
-
}]);
|
|
1411
|
-
}();
|
|
1412
|
-
function _output(path, scope) {
|
|
1413
|
-
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1414
|
-
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1415
|
-
var params = [scope, scope.useComponent, scope.useElement, scope.getBuffer(), scope.useSafeValue];
|
|
1416
|
-
var globals = globalHelpers.filter(function (name) {
|
|
1417
|
-
return isFunction(scope[name]);
|
|
1418
|
-
}).map(function (name) {
|
|
1419
|
-
return scope[name].bind(scope);
|
|
1420
|
-
});
|
|
1421
|
-
return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
|
|
1422
|
-
return callback.apply(scope, params.concat(globals));
|
|
1141
|
+
};
|
|
1142
|
+
var render = function render(name, data) {
|
|
1143
|
+
var scope = createContext(data);
|
|
1144
|
+
return output(filePath(name), scope).then(outputContent(name, scope));
|
|
1145
|
+
};
|
|
1146
|
+
var outputContent = function outputContent(name, scope) {
|
|
1147
|
+
return function (content) {
|
|
1148
|
+
if (scope.getExtend()) {
|
|
1149
|
+
scope.setExtend(false);
|
|
1150
|
+
return renderLayout(scope.getLayout(), scope, name);
|
|
1151
|
+
}
|
|
1152
|
+
return content;
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
var renderLayout = function renderLayout(name, data, parent) {
|
|
1156
|
+
var scope = createContext(data);
|
|
1157
|
+
if (parent) scope.setParentTemplate(parent);
|
|
1158
|
+
return output(filePath(name), scope).then(outputContent(name, scope));
|
|
1159
|
+
};
|
|
1160
|
+
var helpers = function helpers(extendMethods) {
|
|
1161
|
+
context.helpers(extend(methods, extendMethods));
|
|
1162
|
+
};
|
|
1163
|
+
var createContext = function createContext(data) {
|
|
1164
|
+
return context.create(data);
|
|
1165
|
+
};
|
|
1166
|
+
var compile = function compile(content, path) {
|
|
1167
|
+
return compiler.compile(content, path);
|
|
1168
|
+
};
|
|
1169
|
+
var preload = function preload(list) {
|
|
1170
|
+
return cache.load(list || {});
|
|
1171
|
+
};
|
|
1172
|
+
var create = function create(config) {
|
|
1173
|
+
return _EJS$1(config);
|
|
1174
|
+
};
|
|
1175
|
+
var output = function output(path, scope) {
|
|
1176
|
+
var params = [scope, scope.useComponent, scope.useElement, scope.getBuffer(), scope.useSafeValue];
|
|
1177
|
+
var globals = config.globalHelpers.filter(function (name) {
|
|
1178
|
+
return isFunction(scope[name]);
|
|
1179
|
+
}).map(function (name) {
|
|
1180
|
+
return scope[name].bind(scope);
|
|
1181
|
+
});
|
|
1182
|
+
return template.get(path).then(function (callback) {
|
|
1183
|
+
return callback.apply(scope, params.concat(globals));
|
|
1184
|
+
});
|
|
1185
|
+
};
|
|
1186
|
+
helpers({
|
|
1187
|
+
render: render,
|
|
1188
|
+
require: require
|
|
1423
1189
|
});
|
|
1424
|
-
|
|
1190
|
+
return {
|
|
1191
|
+
configure: configure,
|
|
1192
|
+
create: create,
|
|
1193
|
+
createContext: createContext,
|
|
1194
|
+
render: render,
|
|
1195
|
+
require: require,
|
|
1196
|
+
preload: preload,
|
|
1197
|
+
compile: compile,
|
|
1198
|
+
helpers: helpers
|
|
1199
|
+
};
|
|
1200
|
+
};
|
|
1425
1201
|
|
|
1426
1202
|
var templateCache = {};
|
|
1427
1203
|
var getOrigin = function getOrigin(url, secure) {
|
|
@@ -1429,7 +1205,7 @@
|
|
|
1429
1205
|
url.protocol = secure ? 'https:' : 'http:';
|
|
1430
1206
|
return url.origin;
|
|
1431
1207
|
};
|
|
1432
|
-
var _EJS =
|
|
1208
|
+
var _EJS = _EJS$1({
|
|
1433
1209
|
cache: false,
|
|
1434
1210
|
withObject: false,
|
|
1435
1211
|
resolver: function resolver(path, name) {
|
|
@@ -1437,13 +1213,13 @@
|
|
|
1437
1213
|
if (isFunction(templateCache[name])) {
|
|
1438
1214
|
resolve(templateCache[name]);
|
|
1439
1215
|
} else {
|
|
1440
|
-
reject(new TemplateNotFound(
|
|
1216
|
+
reject(new TemplateNotFound());
|
|
1441
1217
|
}
|
|
1442
1218
|
});
|
|
1443
1219
|
}
|
|
1444
1220
|
}),
|
|
1445
1221
|
render = _EJS.render,
|
|
1446
|
-
|
|
1222
|
+
createContext = _EJS.createContext,
|
|
1447
1223
|
helpers = _EJS.helpers,
|
|
1448
1224
|
configure = _EJS.configure;
|
|
1449
1225
|
function useTemplates() {
|
|
@@ -1484,7 +1260,7 @@
|
|
|
1484
1260
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1485
1261
|
while (1) switch (_context.prev = _context.next) {
|
|
1486
1262
|
case 0:
|
|
1487
|
-
c.data =
|
|
1263
|
+
c.data = createContext({});
|
|
1488
1264
|
c.data.set('version', version);
|
|
1489
1265
|
c.data.set('origin', getOrigin(c.req.url, secure));
|
|
1490
1266
|
c.data.set('path', c.req.path);
|
|
@@ -1523,7 +1299,7 @@
|
|
|
1523
1299
|
exports.TemplateNotFound = TemplateNotFound;
|
|
1524
1300
|
exports.TemplateSyntaxError = TemplateSyntaxError;
|
|
1525
1301
|
exports.configure = configure;
|
|
1526
|
-
exports.
|
|
1302
|
+
exports.createContext = createContext;
|
|
1527
1303
|
exports.helpers = helpers;
|
|
1528
1304
|
exports.render = render;
|
|
1529
1305
|
exports.setRenderer = setRenderer;
|