@kosatyi/ejs 0.0.104 → 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.
@@ -4,13 +4,8 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ejs = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- function _assertClassBrand(e, t, n) {
8
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
9
- throw new TypeError("Private element is not present on this object");
10
- }
11
- function _assertThisInitialized(e) {
12
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
13
- return e;
7
+ function _OverloadYield(e, d) {
8
+ this.v = e, this.k = d;
14
9
  }
15
10
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
16
11
  try {
@@ -37,431 +32,246 @@
37
32
  });
38
33
  };
39
34
  }
40
- function _callSuper(t, o, e) {
41
- return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
42
- }
43
- function _checkPrivateRedeclaration(e, t) {
44
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
45
- }
46
- function _classCallCheck(a, n) {
47
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
48
- }
49
- function _classPrivateFieldGet2(s, a) {
50
- return s.get(_assertClassBrand(s, a));
51
- }
52
- function _classPrivateFieldInitSpec(e, t, a) {
53
- _checkPrivateRedeclaration(e, t), t.set(e, a);
54
- }
55
- function _classPrivateFieldSet2(s, a, r) {
56
- return s.set(_assertClassBrand(s, a), r), r;
57
- }
58
- function _classPrivateMethodInitSpec(e, a) {
59
- _checkPrivateRedeclaration(e, a), a.add(e);
60
- }
61
- function _construct(t, e, r) {
62
- if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
63
- var o = [null];
64
- o.push.apply(o, e);
65
- var p = new (t.bind.apply(t, o))();
66
- return r && _setPrototypeOf(p, r.prototype), p;
67
- }
68
- function _defineProperties(e, r) {
69
- for (var t = 0; t < r.length; t++) {
70
- var o = r[t];
71
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
35
+ function _regenerator() {
36
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
37
+ var e,
38
+ t,
39
+ r = "function" == typeof Symbol ? Symbol : {},
40
+ n = r.iterator || "@@iterator",
41
+ o = r.toStringTag || "@@toStringTag";
42
+ function i(r, n, o, i) {
43
+ var c = n && n.prototype instanceof Generator ? n : Generator,
44
+ u = Object.create(c.prototype);
45
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
46
+ var i,
47
+ c,
48
+ u,
49
+ f = 0,
50
+ p = o || [],
51
+ y = !1,
52
+ G = {
53
+ p: 0,
54
+ n: 0,
55
+ v: e,
56
+ a: d,
57
+ f: d.bind(e, 4),
58
+ d: function (t, r) {
59
+ return i = t, c = 0, u = e, G.n = r, a;
60
+ }
61
+ };
62
+ function d(r, n) {
63
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
64
+ var o,
65
+ i = p[t],
66
+ d = G.p,
67
+ l = i[2];
68
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
69
+ }
70
+ if (o || r > 1) return a;
71
+ throw y = !0, n;
72
+ }
73
+ return function (o, p, l) {
74
+ if (f > 1) throw TypeError("Generator is already running");
75
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
76
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
77
+ try {
78
+ if (f = 2, i) {
79
+ if (c || (o = "next"), t = i[o]) {
80
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
81
+ if (!t.done) return t;
82
+ u = t.value, c < 2 && (c = 0);
83
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
84
+ i = e;
85
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
86
+ } catch (t) {
87
+ i = e, c = 1, u = t;
88
+ } finally {
89
+ f = 1;
90
+ }
91
+ }
92
+ return {
93
+ value: t,
94
+ done: y
95
+ };
96
+ };
97
+ }(r, o, i), !0), u;
72
98
  }
73
- }
74
- function _createClass(e, r, t) {
75
- return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
76
- writable: !1
77
- }), e;
78
- }
79
- function _defineProperty(e, r, t) {
80
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
81
- value: t,
82
- enumerable: !0,
83
- configurable: !0,
84
- writable: !0
85
- }) : e[r] = t, e;
86
- }
87
- function _getPrototypeOf(t) {
88
- return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
89
- return t.__proto__ || Object.getPrototypeOf(t);
90
- }, _getPrototypeOf(t);
91
- }
92
- function _inherits(t, e) {
93
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
94
- t.prototype = Object.create(e && e.prototype, {
95
- constructor: {
96
- value: t,
97
- writable: !0,
98
- configurable: !0
99
- }
100
- }), Object.defineProperty(t, "prototype", {
101
- writable: !1
102
- }), e && _setPrototypeOf(t, e);
103
- }
104
- function _isNativeFunction(t) {
105
- try {
106
- return -1 !== Function.toString.call(t).indexOf("[native code]");
107
- } catch (n) {
108
- return "function" == typeof t;
99
+ var a = {};
100
+ function Generator() {}
101
+ function GeneratorFunction() {}
102
+ function GeneratorFunctionPrototype() {}
103
+ t = Object.getPrototypeOf;
104
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
105
+ return this;
106
+ }), t),
107
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
108
+ function f(e) {
109
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
109
110
  }
110
- }
111
- function _isNativeReflectConstruct() {
112
- try {
113
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
114
- } catch (t) {}
115
- return (_isNativeReflectConstruct = function () {
116
- return !!t;
111
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
112
+ return this;
113
+ }), _regeneratorDefine(u, "toString", function () {
114
+ return "[object Generator]";
115
+ }), (_regenerator = function () {
116
+ return {
117
+ w: i,
118
+ m: f
119
+ };
117
120
  })();
118
121
  }
119
- function _possibleConstructorReturn(t, e) {
120
- if (e && ("object" == typeof e || "function" == typeof e)) return e;
121
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
122
- return _assertThisInitialized(t);
122
+ function _regeneratorAsync(n, e, r, t, o) {
123
+ var a = _regeneratorAsyncGen(n, e, r, t, o);
124
+ return a.next().then(function (n) {
125
+ return n.done ? n.value : a.next();
126
+ });
123
127
  }
124
- function _regeneratorRuntime() {
125
- _regeneratorRuntime = function () {
126
- return e;
127
- };
128
- var t,
129
- e = {},
130
- r = Object.prototype,
131
- n = r.hasOwnProperty,
132
- o = Object.defineProperty || function (t, e, r) {
133
- t[e] = r.value;
134
- },
135
- i = "function" == typeof Symbol ? Symbol : {},
136
- a = i.iterator || "@@iterator",
137
- c = i.asyncIterator || "@@asyncIterator",
138
- u = i.toStringTag || "@@toStringTag";
139
- function define(t, e, r) {
140
- return Object.defineProperty(t, e, {
141
- value: r,
142
- enumerable: !0,
143
- configurable: !0,
144
- writable: !0
145
- }), t[e];
146
- }
147
- try {
148
- define({}, "");
149
- } catch (t) {
150
- define = function (t, e, r) {
151
- return t[e] = r;
152
- };
153
- }
154
- function wrap(t, e, r, n) {
155
- var i = e && e.prototype instanceof Generator ? e : Generator,
156
- a = Object.create(i.prototype),
157
- c = new Context(n || []);
158
- return o(a, "_invoke", {
159
- value: makeInvokeMethod(t, r, c)
160
- }), a;
161
- }
162
- function tryCatch(t, e, r) {
128
+ function _regeneratorAsyncGen(r, e, t, o, n) {
129
+ return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise);
130
+ }
131
+ function _regeneratorAsyncIterator(t, e) {
132
+ function n(r, o, i, f) {
163
133
  try {
164
- return {
165
- type: "normal",
166
- arg: t.call(e, r)
167
- };
134
+ var c = t[r](o),
135
+ u = c.value;
136
+ return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) {
137
+ n("next", t, i, f);
138
+ }, function (t) {
139
+ n("throw", t, i, f);
140
+ }) : e.resolve(u).then(function (t) {
141
+ c.value = t, i(c);
142
+ }, function (t) {
143
+ return n("throw", t, i, f);
144
+ });
168
145
  } catch (t) {
169
- return {
170
- type: "throw",
171
- arg: t
172
- };
146
+ f(t);
173
147
  }
174
148
  }
175
- e.wrap = wrap;
176
- var h = "suspendedStart",
177
- l = "suspendedYield",
178
- f = "executing",
179
- s = "completed",
180
- y = {};
181
- function Generator() {}
182
- function GeneratorFunction() {}
183
- function GeneratorFunctionPrototype() {}
184
- var p = {};
185
- define(p, a, function () {
149
+ var r;
150
+ this.next || (_regeneratorDefine(_regeneratorAsyncIterator.prototype), _regeneratorDefine(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
186
151
  return this;
187
- });
188
- var d = Object.getPrototypeOf,
189
- v = d && d(d(values([])));
190
- v && v !== r && n.call(v, a) && (p = v);
191
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
192
- function defineIteratorMethods(t) {
193
- ["next", "throw", "return"].forEach(function (e) {
194
- define(t, e, function (t) {
195
- return this._invoke(e, t);
152
+ })), _regeneratorDefine(this, "_invoke", function (t, o, i) {
153
+ function f() {
154
+ return new e(function (e, r) {
155
+ n(t, i, e, r);
196
156
  });
197
- });
198
- }
199
- function AsyncIterator(t, e) {
200
- function invoke(r, o, i, a) {
201
- var c = tryCatch(t[r], t, o);
202
- if ("throw" !== c.type) {
203
- var u = c.arg,
204
- h = u.value;
205
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
206
- invoke("next", t, i, a);
207
- }, function (t) {
208
- invoke("throw", t, i, a);
209
- }) : e.resolve(h).then(function (t) {
210
- u.value = t, i(u);
211
- }, function (t) {
212
- return invoke("throw", t, i, a);
213
- });
214
- }
215
- a(c.arg);
216
157
  }
217
- var r;
218
- o(this, "_invoke", {
219
- value: function (t, n) {
220
- function callInvokeWithMethodAndArg() {
221
- return new e(function (e, r) {
222
- invoke(t, n, e, r);
223
- });
224
- }
225
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
226
- }
227
- });
158
+ return r = r ? r.then(f, f) : f();
159
+ }, !0);
160
+ }
161
+ function _regeneratorDefine(e, r, n, t) {
162
+ var i = Object.defineProperty;
163
+ try {
164
+ i({}, "", {});
165
+ } catch (e) {
166
+ i = 0;
228
167
  }
229
- function makeInvokeMethod(e, r, n) {
230
- var o = h;
231
- return function (i, a) {
232
- if (o === f) throw Error("Generator is already running");
233
- if (o === s) {
234
- if ("throw" === i) throw a;
235
- return {
236
- value: t,
237
- done: !0
168
+ _regeneratorDefine = function (e, r, n, t) {
169
+ function o(r, n) {
170
+ _regeneratorDefine(e, r, function (e) {
171
+ return this._invoke(r, n, e);
172
+ });
173
+ }
174
+ r ? i ? i(e, r, {
175
+ value: n,
176
+ enumerable: !t,
177
+ configurable: !t,
178
+ writable: !t
179
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
180
+ }, _regeneratorDefine(e, r, n, t);
181
+ }
182
+ function _regeneratorKeys(e) {
183
+ var n = Object(e),
184
+ r = [];
185
+ for (var t in n) r.unshift(t);
186
+ return function e() {
187
+ for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
188
+ return e.done = !0, e;
189
+ };
190
+ }
191
+ function _regeneratorValues(e) {
192
+ if (null != e) {
193
+ var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
194
+ r = 0;
195
+ if (t) return t.call(e);
196
+ if ("function" == typeof e.next) return e;
197
+ if (!isNaN(e.length)) return {
198
+ next: function () {
199
+ return e && r >= e.length && (e = void 0), {
200
+ value: e && e[r++],
201
+ done: !e
238
202
  };
239
203
  }
240
- for (n.method = i, n.arg = a;;) {
241
- var c = n.delegate;
242
- if (c) {
243
- var u = maybeInvokeDelegate(c, n);
244
- if (u) {
245
- if (u === y) continue;
246
- return u;
247
- }
248
- }
249
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
250
- if (o === h) throw o = s, n.arg;
251
- n.dispatchException(n.arg);
252
- } else "return" === n.method && n.abrupt("return", n.arg);
253
- o = f;
254
- var p = tryCatch(e, r, n);
255
- if ("normal" === p.type) {
256
- if (o = n.done ? s : l, p.arg === y) continue;
257
- return {
258
- value: p.arg,
259
- done: n.done
260
- };
261
- }
262
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
263
- }
264
204
  };
265
205
  }
266
- function maybeInvokeDelegate(e, r) {
267
- var n = r.method,
268
- o = e.iterator[n];
269
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
270
- var i = tryCatch(o, e.iterator, r.arg);
271
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
272
- var a = i.arg;
273
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
274
- }
275
- function pushTryEntry(t) {
276
- var e = {
277
- tryLoc: t[0]
278
- };
279
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
280
- }
281
- function resetTryEntry(t) {
282
- var e = t.completion || {};
283
- e.type = "normal", delete e.arg, t.completion = e;
284
- }
285
- function Context(t) {
286
- this.tryEntries = [{
287
- tryLoc: "root"
288
- }], t.forEach(pushTryEntry, this), this.reset(!0);
289
- }
290
- function values(e) {
291
- if (e || "" === e) {
292
- var r = e[a];
293
- if (r) return r.call(e);
294
- if ("function" == typeof e.next) return e;
295
- if (!isNaN(e.length)) {
296
- var o = -1,
297
- i = function next() {
298
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
299
- return next.value = t, next.done = !0, next;
300
- };
301
- return i.next = i;
302
- }
303
- }
304
- throw new TypeError(typeof e + " is not iterable");
206
+ throw new TypeError(typeof e + " is not iterable");
207
+ }
208
+ function _regeneratorRuntime() {
209
+
210
+ var r = _regenerator(),
211
+ e = r.m(_regeneratorRuntime),
212
+ t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
213
+ function n(r) {
214
+ var e = "function" == typeof r && r.constructor;
215
+ return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
305
216
  }
306
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
307
- value: GeneratorFunctionPrototype,
308
- configurable: !0
309
- }), o(GeneratorFunctionPrototype, "constructor", {
310
- value: GeneratorFunction,
311
- configurable: !0
312
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
313
- var e = "function" == typeof t && t.constructor;
314
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
315
- }, e.mark = function (t) {
316
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
317
- }, e.awrap = function (t) {
318
- return {
319
- __await: t
320
- };
321
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
322
- return this;
323
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
324
- void 0 === i && (i = Promise);
325
- var a = new AsyncIterator(wrap(t, r, n, o), i);
326
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
327
- return t.done ? t.value : a.next();
328
- });
329
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
330
- return this;
331
- }), define(g, "toString", function () {
332
- return "[object Generator]";
333
- }), e.keys = function (t) {
334
- var e = Object(t),
335
- r = [];
336
- for (var n in e) r.push(n);
337
- return r.reverse(), function next() {
338
- for (; r.length;) {
339
- var t = r.pop();
340
- if (t in e) return next.value = t, next.done = !1, next;
341
- }
342
- return next.done = !0, next;
343
- };
344
- }, e.values = values, Context.prototype = {
345
- constructor: Context,
346
- reset: function (e) {
347
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
348
- },
349
- stop: function () {
350
- this.done = !0;
351
- var t = this.tryEntries[0].completion;
352
- if ("throw" === t.type) throw t.arg;
353
- return this.rval;
354
- },
355
- dispatchException: function (e) {
356
- if (this.done) throw e;
357
- var r = this;
358
- function handle(n, o) {
359
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
360
- }
361
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
362
- var i = this.tryEntries[o],
363
- a = i.completion;
364
- if ("root" === i.tryLoc) return handle("end");
365
- if (i.tryLoc <= this.prev) {
366
- var c = n.call(i, "catchLoc"),
367
- u = n.call(i, "finallyLoc");
368
- if (c && u) {
369
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
370
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
371
- } else if (c) {
372
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
373
- } else {
374
- if (!u) throw Error("try statement without catch or finally");
375
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
376
- }
377
- }
378
- }
379
- },
380
- abrupt: function (t, e) {
381
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
382
- var o = this.tryEntries[r];
383
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
384
- var i = o;
385
- break;
217
+ var o = {
218
+ throw: 1,
219
+ return: 2,
220
+ break: 3,
221
+ continue: 3
222
+ };
223
+ function a(r) {
224
+ var e, t;
225
+ return function (n) {
226
+ e || (e = {
227
+ stop: function () {
228
+ return t(n.a, 2);
229
+ },
230
+ catch: function () {
231
+ return n.v;
232
+ },
233
+ abrupt: function (r, e) {
234
+ return t(n.a, o[r], e);
235
+ },
236
+ delegateYield: function (r, o, a) {
237
+ return e.resultName = o, t(n.d, _regeneratorValues(r), a);
238
+ },
239
+ finish: function (r) {
240
+ return t(n.f, r);
386
241
  }
387
- }
388
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
389
- var a = i ? i.completion : {};
390
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
391
- },
392
- complete: function (t, e) {
393
- if ("throw" === t.type) throw t.arg;
394
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
395
- },
396
- finish: function (t) {
397
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
398
- var r = this.tryEntries[e];
399
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
400
- }
401
- },
402
- catch: function (t) {
403
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
404
- var r = this.tryEntries[e];
405
- if (r.tryLoc === t) {
406
- var n = r.completion;
407
- if ("throw" === n.type) {
408
- var o = n.arg;
409
- resetTryEntry(r);
410
- }
411
- return o;
242
+ }, t = function (r, t, o) {
243
+ n.p = e.prev, n.n = e.next;
244
+ try {
245
+ return r(t, o);
246
+ } finally {
247
+ e.next = n.n;
412
248
  }
249
+ }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
250
+ try {
251
+ return r.call(this, e);
252
+ } finally {
253
+ n.p = e.prev, n.n = e.next;
413
254
  }
414
- throw Error("illegal catch attempt");
415
- },
416
- delegateYield: function (e, r, n) {
417
- return this.delegate = {
418
- iterator: values(e),
419
- resultName: r,
420
- nextLoc: n
421
- }, "next" === this.method && (this.arg = t), y;
422
- }
423
- }, e;
424
- }
425
- function _setPrototypeOf(t, e) {
426
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
427
- return t.__proto__ = e, t;
428
- }, _setPrototypeOf(t, e);
429
- }
430
- function _toPrimitive(t, r) {
431
- if ("object" != typeof t || !t) return t;
432
- var e = t[Symbol.toPrimitive];
433
- if (void 0 !== e) {
434
- var i = e.call(t, r);
435
- if ("object" != typeof i) return i;
436
- throw new TypeError("@@toPrimitive must return a primitive value.");
255
+ };
437
256
  }
438
- return (String )(t);
439
- }
440
- function _toPropertyKey(t) {
441
- var i = _toPrimitive(t, "string");
442
- return "symbol" == typeof i ? i : i + "";
443
- }
444
- function _wrapNativeSuper(t) {
445
- var r = "function" == typeof Map ? new Map() : void 0;
446
- return _wrapNativeSuper = function (t) {
447
- if (null === t || !_isNativeFunction(t)) return t;
448
- if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
449
- if (void 0 !== r) {
450
- if (r.has(t)) return r.get(t);
451
- r.set(t, Wrapper);
452
- }
453
- function Wrapper() {
454
- return _construct(t, arguments, _getPrototypeOf(this).constructor);
455
- }
456
- return Wrapper.prototype = Object.create(t.prototype, {
457
- constructor: {
458
- value: Wrapper,
459
- enumerable: !1,
460
- writable: !0,
461
- configurable: !0
462
- }
463
- }), _setPrototypeOf(Wrapper, t);
464
- }, _wrapNativeSuper(t);
257
+ return (_regeneratorRuntime = function () {
258
+ return {
259
+ wrap: function (e, t, n, o) {
260
+ return r.w(a(e), t, n, o && o.reverse());
261
+ },
262
+ isGeneratorFunction: n,
263
+ mark: r.m,
264
+ awrap: function (r, e) {
265
+ return new _OverloadYield(r, e);
266
+ },
267
+ AsyncIterator: _regeneratorAsyncIterator,
268
+ async: function (r, e, t, o, u) {
269
+ return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u);
270
+ },
271
+ keys: _regeneratorKeys,
272
+ values: _regeneratorValues
273
+ };
274
+ })();
465
275
  }
466
276
 
467
277
  var typeProp = function typeProp() {
@@ -525,12 +335,6 @@
525
335
  var check = value;
526
336
  return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
527
337
  };
528
- var instanceOf = function instanceOf(object, instance) {
529
- return Boolean(object instanceof instance);
530
- };
531
- var assertInstanceOf = function assertInstanceOf(object, instance) {
532
- if (instanceOf(object, instance) === false) throw new TypeError("".concat(object, " in not instance of ").concat(instance));
533
- };
534
338
  var getPath = function getPath(context, name, strict) {
535
339
  var data = context;
536
340
  var chunks = String(name).split('.');
@@ -551,14 +355,6 @@
551
355
  }
552
356
  return [data, prop];
553
357
  };
554
- var bindContext = function bindContext(object) {
555
- var methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
556
- methods.forEach(function (name) {
557
- if (name in object) {
558
- object[name] = object[name].bind(object);
559
- }
560
- });
561
- };
562
358
  var ext = function ext(path, defaults) {
563
359
  var ext = path.split('.').pop();
564
360
  if (ext !== defaults) {
@@ -673,7 +469,7 @@
673
469
  };
674
470
 
675
471
  var configSchema = function configSchema(config, options) {
676
- extend(config, {
472
+ return extend(config, {
677
473
  path: typeProp(isString, defaults.path, config.path, options.path),
678
474
  "export": typeProp(isString, defaults["export"], config["export"], options["export"]),
679
475
  resolver: typeProp(isFunction, defaults.resolver, config.resolver, options.resolver),
@@ -687,223 +483,192 @@
687
483
  });
688
484
  };
689
485
 
690
- var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
691
- var _enabled = /*#__PURE__*/new WeakMap();
692
- var _list = /*#__PURE__*/new WeakMap();
693
- var Cache = /*#__PURE__*/function () {
694
- function Cache(config) {
695
- _classCallCheck(this, Cache);
696
- _classPrivateFieldInitSpec(this, _enabled, true);
697
- _classPrivateFieldInitSpec(this, _list, {});
698
- this.configure(config);
699
- }
700
- return _createClass(Cache, [{
701
- key: "load",
702
- value: function load(data) {
703
- if (_classPrivateFieldGet2(_enabled, this)) {
704
- extend(_classPrivateFieldGet2(_list, this), data || {});
705
- }
706
- }
707
- }, {
708
- key: "get",
709
- value: function get(key) {
710
- if (_classPrivateFieldGet2(_enabled, this)) {
711
- return _classPrivateFieldGet2(_list, this)[key];
712
- }
713
- }
714
- }, {
715
- key: "set",
716
- value: function set(key, value) {
717
- if (_classPrivateFieldGet2(_enabled, this)) {
718
- _classPrivateFieldGet2(_list, this)[key] = value;
719
- }
720
- }
721
- }, {
722
- key: "exist",
723
- value: function exist(key) {
724
- if (_classPrivateFieldGet2(_enabled, this)) {
725
- return hasProp(_classPrivateFieldGet2(_list, this), key);
726
- }
727
- }
728
- }, {
729
- key: "clear",
730
- value: function clear() {
731
- _classPrivateFieldSet2(_list, this, {});
732
- }
733
- }, {
734
- key: "remove",
735
- value: function remove(key) {
736
- 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);
737
503
  }
738
- }, {
739
- key: "resolve",
740
- value: function resolve(key) {
741
- return Promise.resolve(this.get(key));
504
+ };
505
+ var get = function get(template) {
506
+ if (cache.exist(template)) {
507
+ return cache.resolve(template);
742
508
  }
743
- }, {
744
- key: "configure",
745
- value: function configure(config) {
746
- _classPrivateFieldSet2(_enabled, this, config.cache);
747
- if (isNode() === false) {
748
- this.load(global[config["export"]]);
749
- }
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;
750
517
  }
751
- }]);
752
- }();
518
+ };
519
+ configure(options);
520
+ return {
521
+ get: get,
522
+ configure: configure,
523
+ compile: compile
524
+ };
525
+ };
753
526
 
754
- var _config$1 = /*#__PURE__*/new WeakMap();
755
- var _symbols = /*#__PURE__*/new WeakMap();
756
- var Compiler = /*#__PURE__*/function () {
757
- function Compiler(config) {
758
- _classCallCheck(this, Compiler);
759
- _classPrivateFieldInitSpec(this, _config$1, {});
760
- _classPrivateFieldInitSpec(this, _symbols, [{
761
- symbol: '-',
762
- format: function format(value) {
763
- return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
764
- }
765
- }, {
766
- symbol: '=',
767
- format: function format(value) {
768
- return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
769
- }
770
- }, {
771
- symbol: '#',
772
- format: function format(value) {
773
- return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
774
- }
775
- }, {
776
- symbol: '',
777
- format: function format(value) {
778
- return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
779
- }
780
- }]);
781
- 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, "('");
782
531
  }
783
- return _createClass(Compiler, [{
784
- key: "configure",
785
- value: function configure(config) {
786
- var _this = this;
787
- _classPrivateFieldGet2(_config$1, this).withObject = config.withObject;
788
- _classPrivateFieldGet2(_config$1, this).rmWhitespace = config.rmWhitespace;
789
- _classPrivateFieldGet2(_config$1, this).token = config.token;
790
- _classPrivateFieldGet2(_config$1, this).vars = config.vars;
791
- _classPrivateFieldGet2(_config$1, this).globalHelpers = config.globalHelpers;
792
- _classPrivateFieldGet2(_config$1, this).matches = [];
793
- _classPrivateFieldGet2(_config$1, this).formats = [];
794
- _classPrivateFieldGet2(_config$1, this).slurp = {
795
- match: '[s\t\n]*',
796
- start: [_classPrivateFieldGet2(_config$1, this).token.start, '_'],
797
- end: ['_', _classPrivateFieldGet2(_config$1, this).token.end]
798
- };
799
- _classPrivateFieldGet2(_symbols, this).forEach(function (item) {
800
- _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));
801
- _classPrivateFieldGet2(_config$1, _this).formats.push(item.format.bind(_classPrivateFieldGet2(_config$1, _this).vars));
802
- });
803
- _classPrivateFieldGet2(_config$1, this).regex = new RegExp(_classPrivateFieldGet2(_config$1, this).matches.join('|').concat('|$'), 'g');
804
- _classPrivateFieldGet2(_config$1, this).slurpStart = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.match, _classPrivateFieldGet2(_config$1, this).slurp.start.join('')].join(''), 'gm');
805
- _classPrivateFieldGet2(_config$1, this).slurpEnd = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.end.join(''), _classPrivateFieldGet2(_config$1, this).slurp.match].join(''), 'gm');
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, '');
806
581
  }
807
- }, {
808
- key: "compile",
809
- value: function compile(content, path) {
810
- var _this2 = this;
811
- var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config$1, this).vars,
812
- SCOPE = _classPrivateFieldGet2$1.SCOPE,
813
- SAFE = _classPrivateFieldGet2$1.SAFE,
814
- BUFFER = _classPrivateFieldGet2$1.BUFFER,
815
- COMPONENT = _classPrivateFieldGet2$1.COMPONENT,
816
- ELEMENT = _classPrivateFieldGet2$1.ELEMENT;
817
- var GLOBALS = _classPrivateFieldGet2(_config$1, this).globalHelpers;
818
- if (_classPrivateFieldGet2(_config$1, this).rmWhitespace) {
819
- content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
820
- }
821
- 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);
822
- var source = "".concat(BUFFER, "('");
823
- matchTokens(_classPrivateFieldGet2(_config$1, this).regex, content, function (params, index, offset) {
824
- source += symbols(content.slice(index, offset));
825
- params.forEach(function (value, index) {
826
- if (value) {
827
- source += _classPrivateFieldGet2(_config$1, _this2).formats[index](value);
828
- }
829
- });
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
+ }
830
590
  });
831
- source += "');";
832
- source = "try{".concat(source, "}catch(e){return ").concat(BUFFER, ".error(e)}");
833
- if (_classPrivateFieldGet2(_config$1, this).withObject) {
834
- source = "with(".concat(SCOPE, "){").concat(source, "}");
835
- }
836
- source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
837
- source += "\n//# sourceURL=".concat(path);
838
- var result = null;
839
- var params = [SCOPE, COMPONENT, ELEMENT, BUFFER, SAFE].concat(GLOBALS);
840
- try {
841
- result = Function.apply(null, params.concat(source));
842
- result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
843
- } catch (e) {
844
- e.filename = path;
845
- e.source = source;
846
- throw e;
847
- }
848
- 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, "}");
849
596
  }
850
- }]);
851
- }();
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;
608
+ }
609
+ return result;
610
+ };
611
+ configure(options);
612
+ return {
613
+ configure: configure,
614
+ compile: compile
615
+ };
616
+ };
852
617
 
853
- var _path = /*#__PURE__*/new WeakMap();
854
- var _cache$1 = /*#__PURE__*/new WeakMap();
855
- var _compiler$1 = /*#__PURE__*/new WeakMap();
856
- var _resolver = /*#__PURE__*/new WeakMap();
857
- var _Template_brand = /*#__PURE__*/new WeakSet();
858
- var Template = /*#__PURE__*/function () {
859
- function Template(config, cache, compiler) {
860
- _classCallCheck(this, Template);
861
- _classPrivateMethodInitSpec(this, _Template_brand);
862
- _classPrivateFieldInitSpec(this, _path, void 0);
863
- _classPrivateFieldInitSpec(this, _cache$1, void 0);
864
- _classPrivateFieldInitSpec(this, _compiler$1, void 0);
865
- _classPrivateFieldInitSpec(this, _resolver, void 0);
866
- assertInstanceOf(cache, Cache);
867
- assertInstanceOf(compiler, Compiler);
868
- _classPrivateFieldSet2(_cache$1, this, cache);
869
- _classPrivateFieldSet2(_compiler$1, this, compiler);
870
- this.configure(config);
871
- }
872
- return _createClass(Template, [{
873
- key: "configure",
874
- value: function configure(config) {
875
- _classPrivateFieldSet2(_path, this, config.path);
876
- if (isFunction(config.resolver)) {
877
- _classPrivateFieldSet2(_resolver, this, config.resolver);
878
- }
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 || {});
879
626
  }
880
- }, {
881
- key: "get",
882
- value: function get(template) {
883
- var _this = this;
884
- if (_classPrivateFieldGet2(_cache$1, this).exist(template)) {
885
- return _classPrivateFieldGet2(_cache$1, this).resolve(template);
886
- }
887
- return _assertClassBrand(_Template_brand, this, _resolve).call(this, template).then(function (content) {
888
- return _assertClassBrand(_Template_brand, _this, _result).call(_this, template, _assertClassBrand(_Template_brand, _this, _compile).call(_this, content, template));
889
- });
627
+ };
628
+ var get = function get(key) {
629
+ if (config.enabled) {
630
+ return list[key];
890
631
  }
891
- }]);
892
- }();
893
- function _resolve(path) {
894
- return _classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path, this), path);
895
- }
896
- function _result(template, content) {
897
- _classPrivateFieldGet2(_cache$1, this).set(template, content);
898
- return content;
899
- }
900
- function _compile(content, template) {
901
- if (isFunction(content)) {
902
- return content;
903
- } else {
904
- return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
905
- }
906
- }
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
+ };
907
672
 
908
673
  var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
909
674
  var space = ' ';
@@ -930,61 +695,50 @@
930
695
  return result.join('');
931
696
  };
932
697
 
933
- var TemplateError = /*#__PURE__*/function (_Error) {
934
- function TemplateError(message) {
935
- var _this;
936
- _classCallCheck(this, TemplateError);
937
- _this = _callSuper(this, TemplateError);
938
- _defineProperty(_this, "code", 0);
939
- _this.message = message;
940
- return _this;
941
- }
942
- _inherits(TemplateError, _Error);
943
- return _createClass(TemplateError, [{
944
- key: "getCode",
945
- value: function getCode() {
946
- return this.code;
947
- }
948
- }, {
949
- key: "getMessage",
950
- value: function getMessage() {
951
- return this.message;
952
- }
953
- }, {
954
- key: "toString",
955
- value: function toString() {
956
- return this.getMessage();
957
- }
958
- }]);
959
- }(/*#__PURE__*/_wrapNativeSuper(Error));
960
- var TemplateNotFound = /*#__PURE__*/function (_TemplateError2) {
961
- function TemplateNotFound() {
962
- var _this2;
963
- _classCallCheck(this, TemplateNotFound);
964
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
965
- args[_key] = arguments[_key];
966
- }
967
- _this2 = _callSuper(this, TemplateNotFound, [].concat(args));
968
- _defineProperty(_this2, "code", 404);
969
- return _this2;
970
- }
971
- _inherits(TemplateNotFound, _TemplateError2);
972
- return _createClass(TemplateNotFound);
973
- }(TemplateError);
974
- var TemplateSyntaxError = /*#__PURE__*/function (_TemplateError3) {
975
- function TemplateSyntaxError() {
976
- var _this3;
977
- _classCallCheck(this, TemplateSyntaxError);
978
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
979
- args[_key2] = arguments[_key2];
980
- }
981
- _this3 = _callSuper(this, TemplateSyntaxError, [].concat(args));
982
- _defineProperty(_this3, "code", 500);
983
- 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();
984
716
  }
985
- _inherits(TemplateSyntaxError, _TemplateError3);
986
- return _createClass(TemplateSyntaxError);
987
- }(TemplateError);
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
+ });
988
742
 
989
743
  function resolve(list) {
990
744
  return Promise.all(list || []).then(function (list) {
@@ -1040,6 +794,7 @@
1040
794
  SCOPE = _config$vars.SCOPE,
1041
795
  COMPONENT = _config$vars.COMPONENT,
1042
796
  ELEMENT = _config$vars.ELEMENT;
797
+
1043
798
  /**
1044
799
  *
1045
800
  * @type {symbol}
@@ -1336,149 +1091,113 @@
1336
1091
  });
1337
1092
  return ContextScope;
1338
1093
  };
1339
- var _scope = /*#__PURE__*/new WeakMap();
1340
- var Context = /*#__PURE__*/function () {
1341
- function Context(config, methods) {
1342
- _classCallCheck(this, Context);
1343
- _classPrivateFieldInitSpec(this, _scope, void 0);
1344
- this.configure(config, methods);
1345
- }
1346
- return _createClass(Context, [{
1347
- key: "create",
1348
- value: function create(data) {
1349
- return new (_classPrivateFieldGet2(_scope, this))(data);
1350
- }
1351
- }, {
1352
- key: "configure",
1353
- value: function configure(config, methods) {
1354
- _classPrivateFieldSet2(_scope, this, createContextScope(config, methods));
1355
- }
1356
- }, {
1357
- key: "helpers",
1358
- value: function helpers(methods) {
1359
- extend(_classPrivateFieldGet2(_scope, this).prototype, methods || {});
1360
- }
1361
- }]);
1362
- }();
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
+ };
1363
1115
 
1364
- var _config = /*#__PURE__*/new WeakMap();
1365
- var _extend = /*#__PURE__*/new WeakMap();
1366
- var _context = /*#__PURE__*/new WeakMap();
1367
- var _compiler = /*#__PURE__*/new WeakMap();
1368
- var _cache = /*#__PURE__*/new WeakMap();
1369
- var _template = /*#__PURE__*/new WeakMap();
1370
- var _EJS_brand = /*#__PURE__*/new WeakSet();
1371
- var EJS = /*#__PURE__*/function () {
1372
- function EJS(options) {
1373
- _classCallCheck(this, EJS);
1374
- _classPrivateMethodInitSpec(this, _EJS_brand);
1375
- _classPrivateFieldInitSpec(this, _config, {});
1376
- _classPrivateFieldInitSpec(this, _extend, {});
1377
- _classPrivateFieldInitSpec(this, _context, void 0);
1378
- _classPrivateFieldInitSpec(this, _compiler, void 0);
1379
- _classPrivateFieldInitSpec(this, _cache, void 0);
1380
- _classPrivateFieldInitSpec(this, _template, void 0);
1381
- configSchema(_classPrivateFieldGet2(_config, this), options || {});
1382
- _classPrivateFieldSet2(_context, this, new Context(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this)));
1383
- _classPrivateFieldSet2(_compiler, this, new Compiler(_classPrivateFieldGet2(_config, this)));
1384
- _classPrivateFieldSet2(_cache, this, new Cache(_classPrivateFieldGet2(_config, this)));
1385
- _classPrivateFieldSet2(_template, this, new Template(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_cache, this), _classPrivateFieldGet2(_compiler, this)));
1386
- //
1387
- bindContext(this, ['configure', 'create', 'render', 'require', 'context', 'preload', 'compile', 'helpers']);
1388
- //
1389
- this.helpers({
1390
- require: this.require,
1391
- 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();
1392
1140
  });
1393
- }
1394
- return _createClass(EJS, [{
1395
- key: "configure",
1396
- value: function configure(options) {
1397
- configSchema(_classPrivateFieldGet2(_config, this), options || {});
1398
- _classPrivateFieldGet2(_context, this).configure(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this));
1399
- _classPrivateFieldGet2(_compiler, this).configure(_classPrivateFieldGet2(_config, this));
1400
- _classPrivateFieldGet2(_cache, this).configure(_classPrivateFieldGet2(_config, this));
1401
- _classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
1402
- return _classPrivateFieldGet2(_config, this);
1403
- }
1404
- }, {
1405
- key: "filePath",
1406
- value: function filePath(name) {
1407
- return ext(name, _classPrivateFieldGet2(_config, this).extension);
1408
- }
1409
- }, {
1410
- key: "require",
1411
- value: function require(name) {
1412
- var scope = this.context({});
1413
- return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(function () {
1414
- return scope.getMacro();
1415
- });
1416
- }
1417
- }, {
1418
- key: "render",
1419
- value: function render(name, data) {
1420
- var scope = this.context(data);
1421
- return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
1422
- }
1423
- }, {
1424
- key: "outputContent",
1425
- value: function outputContent(name, scope) {
1426
- var _this = this;
1427
- return function (content) {
1428
- if (scope.getExtend()) {
1429
- scope.setExtend(false);
1430
- return _this.renderLayout(scope.getLayout(), scope, name);
1431
- }
1432
- return content;
1433
- };
1434
- }
1435
- }, {
1436
- key: "renderLayout",
1437
- value: function renderLayout(name, data, parent) {
1438
- var scope = this.context(data);
1439
- if (parent) scope.setParentTemplate(parent);
1440
- return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
1441
- }
1442
- }, {
1443
- key: "helpers",
1444
- value: function helpers(methods) {
1445
- _classPrivateFieldGet2(_context, this).helpers(extend(_classPrivateFieldGet2(_extend, this), methods));
1446
- }
1447
- }, {
1448
- key: "context",
1449
- value: function context(data) {
1450
- return _classPrivateFieldGet2(_context, this).create(data);
1451
- }
1452
- }, {
1453
- key: "compile",
1454
- value: function compile(content, path) {
1455
- return _classPrivateFieldGet2(_compiler, this).compile(content, path);
1456
- }
1457
- }, {
1458
- key: "preload",
1459
- value: function preload(list) {
1460
- return _classPrivateFieldGet2(_cache, this).load(list || {});
1461
- }
1462
- }, {
1463
- key: "create",
1464
- value: function create(options) {
1465
- return new this.constructor(options);
1466
- }
1467
- }]);
1468
- }();
1469
- function _output(path, scope) {
1470
- var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
1471
- globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
1472
- var params = [scope, scope.useComponent, scope.useElement, scope.getBuffer(), scope.useSafeValue];
1473
- var globals = globalHelpers.filter(function (name) {
1474
- return isFunction(scope[name]);
1475
- }).map(function (name) {
1476
- return scope[name].bind(scope);
1477
- });
1478
- return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
1479
- 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
1480
1189
  });
1481
- }
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
+ };
1482
1201
 
1483
1202
  var templateCache = {};
1484
1203
  var getOrigin = function getOrigin(url, secure) {
@@ -1486,7 +1205,7 @@
1486
1205
  url.protocol = secure ? 'https:' : 'http:';
1487
1206
  return url.origin;
1488
1207
  };
1489
- var _EJS = new EJS({
1208
+ var _EJS = _EJS$1({
1490
1209
  cache: false,
1491
1210
  withObject: false,
1492
1211
  resolver: function resolver(path, name) {
@@ -1494,13 +1213,13 @@
1494
1213
  if (isFunction(templateCache[name])) {
1495
1214
  resolve(templateCache[name]);
1496
1215
  } else {
1497
- reject(new TemplateNotFound("template ".concat(name, " not found")));
1216
+ reject(new TemplateNotFound());
1498
1217
  }
1499
1218
  });
1500
1219
  }
1501
1220
  }),
1502
1221
  render = _EJS.render,
1503
- context = _EJS.context,
1222
+ createContext = _EJS.createContext,
1504
1223
  helpers = _EJS.helpers,
1505
1224
  configure = _EJS.configure;
1506
1225
  function useTemplates() {
@@ -1541,7 +1260,7 @@
1541
1260
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1542
1261
  while (1) switch (_context.prev = _context.next) {
1543
1262
  case 0:
1544
- c.data = context({});
1263
+ c.data = createContext({});
1545
1264
  c.data.set('version', version);
1546
1265
  c.data.set('origin', getOrigin(c.req.url, secure));
1547
1266
  c.data.set('path', c.req.path);
@@ -1580,7 +1299,7 @@
1580
1299
  exports.TemplateNotFound = TemplateNotFound;
1581
1300
  exports.TemplateSyntaxError = TemplateSyntaxError;
1582
1301
  exports.configure = configure;
1583
- exports.context = context;
1302
+ exports.createContext = createContext;
1584
1303
  exports.helpers = helpers;
1585
1304
  exports.render = render;
1586
1305
  exports.setRenderer = setRenderer;