@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.
@@ -1,12 +1,7 @@
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;
3
+ function _OverloadYield(e, d) {
4
+ this.v = e, this.k = d;
10
5
  }
11
6
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
12
7
  try {
@@ -33,431 +28,246 @@ function _asyncToGenerator(n) {
33
28
  });
34
29
  };
35
30
  }
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);
31
+ function _regenerator() {
32
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
33
+ var e,
34
+ t,
35
+ r = "function" == typeof Symbol ? Symbol : {},
36
+ n = r.iterator || "@@iterator",
37
+ o = r.toStringTag || "@@toStringTag";
38
+ function i(r, n, o, i) {
39
+ var c = n && n.prototype instanceof Generator ? n : Generator,
40
+ u = Object.create(c.prototype);
41
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
42
+ var i,
43
+ c,
44
+ u,
45
+ f = 0,
46
+ p = o || [],
47
+ y = !1,
48
+ G = {
49
+ p: 0,
50
+ n: 0,
51
+ v: e,
52
+ a: d,
53
+ f: d.bind(e, 4),
54
+ d: function (t, r) {
55
+ return i = t, c = 0, u = e, G.n = r, a;
56
+ }
57
+ };
58
+ function d(r, n) {
59
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
60
+ var o,
61
+ i = p[t],
62
+ d = G.p,
63
+ l = i[2];
64
+ 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));
65
+ }
66
+ if (o || r > 1) return a;
67
+ throw y = !0, n;
68
+ }
69
+ return function (o, p, l) {
70
+ if (f > 1) throw TypeError("Generator is already running");
71
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
72
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
73
+ try {
74
+ if (f = 2, i) {
75
+ if (c || (o = "next"), t = i[o]) {
76
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
77
+ if (!t.done) return t;
78
+ u = t.value, c < 2 && (c = 0);
79
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
80
+ i = e;
81
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
82
+ } catch (t) {
83
+ i = e, c = 1, u = t;
84
+ } finally {
85
+ f = 1;
86
+ }
87
+ }
88
+ return {
89
+ value: t,
90
+ done: y
91
+ };
92
+ };
93
+ }(r, o, i), !0), u;
68
94
  }
69
- }
70
- function _createClass(e, r, t) {
71
- return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
72
- writable: !1
73
- }), e;
74
- }
75
- function _defineProperty(e, r, t) {
76
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
77
- value: t,
78
- enumerable: !0,
79
- configurable: !0,
80
- writable: !0
81
- }) : e[r] = t, e;
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;
95
+ var a = {};
96
+ function Generator() {}
97
+ function GeneratorFunction() {}
98
+ function GeneratorFunctionPrototype() {}
99
+ t = Object.getPrototypeOf;
100
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
101
+ return this;
102
+ }), t),
103
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
104
+ function f(e) {
105
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
105
106
  }
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;
107
+ 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 () {
108
+ return this;
109
+ }), _regeneratorDefine(u, "toString", function () {
110
+ return "[object Generator]";
111
+ }), (_regenerator = function () {
112
+ return {
113
+ w: i,
114
+ m: f
115
+ };
113
116
  })();
114
117
  }
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);
118
+ function _regeneratorAsync(n, e, r, t, o) {
119
+ var a = _regeneratorAsyncGen(n, e, r, t, o);
120
+ return a.next().then(function (n) {
121
+ return n.done ? n.value : a.next();
122
+ });
119
123
  }
120
- function _regeneratorRuntime() {
121
- _regeneratorRuntime = function () {
122
- return e;
123
- };
124
- var t,
125
- e = {},
126
- r = Object.prototype,
127
- n = r.hasOwnProperty,
128
- o = Object.defineProperty || function (t, e, r) {
129
- t[e] = r.value;
130
- },
131
- i = "function" == typeof Symbol ? Symbol : {},
132
- a = i.iterator || "@@iterator",
133
- c = i.asyncIterator || "@@asyncIterator",
134
- u = i.toStringTag || "@@toStringTag";
135
- function define(t, e, r) {
136
- return Object.defineProperty(t, e, {
137
- value: r,
138
- enumerable: !0,
139
- configurable: !0,
140
- writable: !0
141
- }), t[e];
142
- }
143
- try {
144
- define({}, "");
145
- } catch (t) {
146
- define = function (t, e, r) {
147
- return t[e] = r;
148
- };
149
- }
150
- function wrap(t, e, r, n) {
151
- var i = e && e.prototype instanceof Generator ? e : Generator,
152
- a = Object.create(i.prototype),
153
- c = new Context(n || []);
154
- return o(a, "_invoke", {
155
- value: makeInvokeMethod(t, r, c)
156
- }), a;
157
- }
158
- function tryCatch(t, e, r) {
124
+ function _regeneratorAsyncGen(r, e, t, o, n) {
125
+ return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise);
126
+ }
127
+ function _regeneratorAsyncIterator(t, e) {
128
+ function n(r, o, i, f) {
159
129
  try {
160
- return {
161
- type: "normal",
162
- arg: t.call(e, r)
163
- };
130
+ var c = t[r](o),
131
+ u = c.value;
132
+ return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) {
133
+ n("next", t, i, f);
134
+ }, function (t) {
135
+ n("throw", t, i, f);
136
+ }) : e.resolve(u).then(function (t) {
137
+ c.value = t, i(c);
138
+ }, function (t) {
139
+ return n("throw", t, i, f);
140
+ });
164
141
  } catch (t) {
165
- return {
166
- type: "throw",
167
- arg: t
168
- };
142
+ f(t);
169
143
  }
170
144
  }
171
- e.wrap = wrap;
172
- var h = "suspendedStart",
173
- l = "suspendedYield",
174
- f = "executing",
175
- s = "completed",
176
- y = {};
177
- function Generator() {}
178
- function GeneratorFunction() {}
179
- function GeneratorFunctionPrototype() {}
180
- var p = {};
181
- define(p, a, function () {
145
+ var r;
146
+ this.next || (_regeneratorDefine(_regeneratorAsyncIterator.prototype), _regeneratorDefine(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
182
147
  return this;
183
- });
184
- var d = Object.getPrototypeOf,
185
- v = d && d(d(values([])));
186
- v && v !== r && n.call(v, a) && (p = v);
187
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
188
- function defineIteratorMethods(t) {
189
- ["next", "throw", "return"].forEach(function (e) {
190
- define(t, e, function (t) {
191
- return this._invoke(e, t);
148
+ })), _regeneratorDefine(this, "_invoke", function (t, o, i) {
149
+ function f() {
150
+ return new e(function (e, r) {
151
+ n(t, i, e, r);
192
152
  });
193
- });
194
- }
195
- function AsyncIterator(t, e) {
196
- function invoke(r, o, i, a) {
197
- var c = tryCatch(t[r], t, o);
198
- if ("throw" !== c.type) {
199
- var u = c.arg,
200
- h = u.value;
201
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
202
- invoke("next", t, i, a);
203
- }, function (t) {
204
- invoke("throw", t, i, a);
205
- }) : e.resolve(h).then(function (t) {
206
- u.value = t, i(u);
207
- }, function (t) {
208
- return invoke("throw", t, i, a);
209
- });
210
- }
211
- a(c.arg);
212
153
  }
213
- var r;
214
- o(this, "_invoke", {
215
- value: function (t, n) {
216
- function callInvokeWithMethodAndArg() {
217
- return new e(function (e, r) {
218
- invoke(t, n, e, r);
219
- });
220
- }
221
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
222
- }
223
- });
154
+ return r = r ? r.then(f, f) : f();
155
+ }, !0);
156
+ }
157
+ function _regeneratorDefine(e, r, n, t) {
158
+ var i = Object.defineProperty;
159
+ try {
160
+ i({}, "", {});
161
+ } catch (e) {
162
+ i = 0;
224
163
  }
225
- function makeInvokeMethod(e, r, n) {
226
- var o = h;
227
- return function (i, a) {
228
- if (o === f) throw Error("Generator is already running");
229
- if (o === s) {
230
- if ("throw" === i) throw a;
231
- return {
232
- value: t,
233
- done: !0
164
+ _regeneratorDefine = function (e, r, n, t) {
165
+ function o(r, n) {
166
+ _regeneratorDefine(e, r, function (e) {
167
+ return this._invoke(r, n, e);
168
+ });
169
+ }
170
+ r ? i ? i(e, r, {
171
+ value: n,
172
+ enumerable: !t,
173
+ configurable: !t,
174
+ writable: !t
175
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
176
+ }, _regeneratorDefine(e, r, n, t);
177
+ }
178
+ function _regeneratorKeys(e) {
179
+ var n = Object(e),
180
+ r = [];
181
+ for (var t in n) r.unshift(t);
182
+ return function e() {
183
+ for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
184
+ return e.done = !0, e;
185
+ };
186
+ }
187
+ function _regeneratorValues(e) {
188
+ if (null != e) {
189
+ var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
190
+ r = 0;
191
+ if (t) return t.call(e);
192
+ if ("function" == typeof e.next) return e;
193
+ if (!isNaN(e.length)) return {
194
+ next: function () {
195
+ return e && r >= e.length && (e = void 0), {
196
+ value: e && e[r++],
197
+ done: !e
234
198
  };
235
199
  }
236
- for (n.method = i, n.arg = a;;) {
237
- var c = n.delegate;
238
- if (c) {
239
- var u = maybeInvokeDelegate(c, n);
240
- if (u) {
241
- if (u === y) continue;
242
- return u;
243
- }
244
- }
245
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
246
- if (o === h) throw o = s, n.arg;
247
- n.dispatchException(n.arg);
248
- } else "return" === n.method && n.abrupt("return", n.arg);
249
- o = f;
250
- var p = tryCatch(e, r, n);
251
- if ("normal" === p.type) {
252
- if (o = n.done ? s : l, p.arg === y) continue;
253
- return {
254
- value: p.arg,
255
- done: n.done
256
- };
257
- }
258
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
259
- }
260
200
  };
261
201
  }
262
- function maybeInvokeDelegate(e, r) {
263
- var n = r.method,
264
- o = e.iterator[n];
265
- 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;
266
- var i = tryCatch(o, e.iterator, r.arg);
267
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
268
- var a = i.arg;
269
- 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);
270
- }
271
- function pushTryEntry(t) {
272
- var e = {
273
- tryLoc: t[0]
274
- };
275
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
276
- }
277
- function resetTryEntry(t) {
278
- var e = t.completion || {};
279
- e.type = "normal", delete e.arg, t.completion = e;
280
- }
281
- function Context(t) {
282
- this.tryEntries = [{
283
- tryLoc: "root"
284
- }], t.forEach(pushTryEntry, this), this.reset(!0);
285
- }
286
- function values(e) {
287
- if (e || "" === e) {
288
- var r = e[a];
289
- if (r) return r.call(e);
290
- if ("function" == typeof e.next) return e;
291
- if (!isNaN(e.length)) {
292
- var o = -1,
293
- i = function next() {
294
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
295
- return next.value = t, next.done = !0, next;
296
- };
297
- return i.next = i;
298
- }
299
- }
300
- throw new TypeError(typeof e + " is not iterable");
202
+ throw new TypeError(typeof e + " is not iterable");
203
+ }
204
+ function _regeneratorRuntime() {
205
+
206
+ var r = _regenerator(),
207
+ e = r.m(_regeneratorRuntime),
208
+ t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
209
+ function n(r) {
210
+ var e = "function" == typeof r && r.constructor;
211
+ return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
301
212
  }
302
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
303
- value: GeneratorFunctionPrototype,
304
- configurable: !0
305
- }), o(GeneratorFunctionPrototype, "constructor", {
306
- value: GeneratorFunction,
307
- configurable: !0
308
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
309
- var e = "function" == typeof t && t.constructor;
310
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
311
- }, e.mark = function (t) {
312
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
313
- }, e.awrap = function (t) {
314
- return {
315
- __await: t
316
- };
317
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
318
- return this;
319
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
320
- void 0 === i && (i = Promise);
321
- var a = new AsyncIterator(wrap(t, r, n, o), i);
322
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
323
- return t.done ? t.value : a.next();
324
- });
325
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
326
- return this;
327
- }), define(g, "toString", function () {
328
- return "[object Generator]";
329
- }), e.keys = function (t) {
330
- var e = Object(t),
331
- r = [];
332
- for (var n in e) r.push(n);
333
- return r.reverse(), function next() {
334
- for (; r.length;) {
335
- var t = r.pop();
336
- if (t in e) return next.value = t, next.done = !1, next;
337
- }
338
- return next.done = !0, next;
339
- };
340
- }, e.values = values, Context.prototype = {
341
- constructor: Context,
342
- reset: function (e) {
343
- 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);
344
- },
345
- stop: function () {
346
- this.done = !0;
347
- var t = this.tryEntries[0].completion;
348
- if ("throw" === t.type) throw t.arg;
349
- return this.rval;
350
- },
351
- dispatchException: function (e) {
352
- if (this.done) throw e;
353
- var r = this;
354
- function handle(n, o) {
355
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
356
- }
357
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
358
- var i = this.tryEntries[o],
359
- a = i.completion;
360
- if ("root" === i.tryLoc) return handle("end");
361
- if (i.tryLoc <= this.prev) {
362
- var c = n.call(i, "catchLoc"),
363
- u = n.call(i, "finallyLoc");
364
- if (c && u) {
365
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
366
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
367
- } else if (c) {
368
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
369
- } else {
370
- if (!u) throw Error("try statement without catch or finally");
371
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
372
- }
373
- }
374
- }
375
- },
376
- abrupt: function (t, e) {
377
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
378
- var o = this.tryEntries[r];
379
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
380
- var i = o;
381
- break;
213
+ var o = {
214
+ throw: 1,
215
+ return: 2,
216
+ break: 3,
217
+ continue: 3
218
+ };
219
+ function a(r) {
220
+ var e, t;
221
+ return function (n) {
222
+ e || (e = {
223
+ stop: function () {
224
+ return t(n.a, 2);
225
+ },
226
+ catch: function () {
227
+ return n.v;
228
+ },
229
+ abrupt: function (r, e) {
230
+ return t(n.a, o[r], e);
231
+ },
232
+ delegateYield: function (r, o, a) {
233
+ return e.resultName = o, t(n.d, _regeneratorValues(r), a);
234
+ },
235
+ finish: function (r) {
236
+ return t(n.f, r);
382
237
  }
383
- }
384
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
385
- var a = i ? i.completion : {};
386
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
387
- },
388
- complete: function (t, e) {
389
- if ("throw" === t.type) throw t.arg;
390
- 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;
391
- },
392
- finish: function (t) {
393
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
394
- var r = this.tryEntries[e];
395
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
396
- }
397
- },
398
- catch: function (t) {
399
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
400
- var r = this.tryEntries[e];
401
- if (r.tryLoc === t) {
402
- var n = r.completion;
403
- if ("throw" === n.type) {
404
- var o = n.arg;
405
- resetTryEntry(r);
406
- }
407
- return o;
238
+ }, t = function (r, t, o) {
239
+ n.p = e.prev, n.n = e.next;
240
+ try {
241
+ return r(t, o);
242
+ } finally {
243
+ e.next = n.n;
408
244
  }
245
+ }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
246
+ try {
247
+ return r.call(this, e);
248
+ } finally {
249
+ n.p = e.prev, n.n = e.next;
409
250
  }
410
- throw Error("illegal catch attempt");
411
- },
412
- delegateYield: function (e, r, n) {
413
- return this.delegate = {
414
- iterator: values(e),
415
- resultName: r,
416
- nextLoc: n
417
- }, "next" === this.method && (this.arg = t), y;
418
- }
419
- }, e;
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
- }
426
- function _toPrimitive(t, r) {
427
- if ("object" != typeof t || !t) return t;
428
- var e = t[Symbol.toPrimitive];
429
- if (void 0 !== e) {
430
- var i = e.call(t, r);
431
- if ("object" != typeof i) return i;
432
- throw new TypeError("@@toPrimitive must return a primitive value.");
251
+ };
433
252
  }
434
- return (String )(t);
435
- }
436
- function _toPropertyKey(t) {
437
- var i = _toPrimitive(t, "string");
438
- return "symbol" == typeof i ? i : i + "";
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);
253
+ return (_regeneratorRuntime = function () {
254
+ return {
255
+ wrap: function (e, t, n, o) {
256
+ return r.w(a(e), t, n, o && o.reverse());
257
+ },
258
+ isGeneratorFunction: n,
259
+ mark: r.m,
260
+ awrap: function (r, e) {
261
+ return new _OverloadYield(r, e);
262
+ },
263
+ AsyncIterator: _regeneratorAsyncIterator,
264
+ async: function (r, e, t, o, u) {
265
+ return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u);
266
+ },
267
+ keys: _regeneratorKeys,
268
+ values: _regeneratorValues
269
+ };
270
+ })();
461
271
  }
462
272
 
463
273
  var typeProp = function typeProp() {
@@ -521,12 +331,6 @@ var safeValue = function safeValue(value, escape) {
521
331
  var check = value;
522
332
  return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
523
333
  };
524
- var instanceOf = function instanceOf(object, instance) {
525
- return Boolean(object instanceof instance);
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
- };
530
334
  var getPath = function getPath(context, name, strict) {
531
335
  var data = context;
532
336
  var chunks = String(name).split('.');
@@ -547,14 +351,6 @@ var getPath = function getPath(context, name, strict) {
547
351
  }
548
352
  return [data, prop];
549
353
  };
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
- };
558
354
  var ext = function ext(path, defaults) {
559
355
  var ext = path.split('.').pop();
560
356
  if (ext !== defaults) {
@@ -669,7 +465,7 @@ defaults.token = {
669
465
  };
670
466
 
671
467
  var configSchema = function configSchema(config, options) {
672
- extend(config, {
468
+ return extend(config, {
673
469
  path: typeProp(isString, defaults.path, config.path, options.path),
674
470
  "export": typeProp(isString, defaults["export"], config["export"], options["export"]),
675
471
  resolver: typeProp(isFunction, defaults.resolver, config.resolver, options.resolver),
@@ -683,223 +479,192 @@ var configSchema = function configSchema(config, options) {
683
479
  });
684
480
  };
685
481
 
686
- var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
687
- var _enabled = /*#__PURE__*/new WeakMap();
688
- var _list = /*#__PURE__*/new WeakMap();
689
- var Cache = /*#__PURE__*/function () {
690
- function Cache(config) {
691
- _classCallCheck(this, Cache);
692
- _classPrivateFieldInitSpec(this, _enabled, true);
693
- _classPrivateFieldInitSpec(this, _list, {});
694
- this.configure(config);
695
- }
696
- return _createClass(Cache, [{
697
- key: "load",
698
- value: function load(data) {
699
- if (_classPrivateFieldGet2(_enabled, this)) {
700
- extend(_classPrivateFieldGet2(_list, this), data || {});
701
- }
702
- }
703
- }, {
704
- key: "get",
705
- value: function get(key) {
706
- if (_classPrivateFieldGet2(_enabled, this)) {
707
- return _classPrivateFieldGet2(_list, this)[key];
708
- }
709
- }
710
- }, {
711
- key: "set",
712
- value: function set(key, value) {
713
- if (_classPrivateFieldGet2(_enabled, this)) {
714
- _classPrivateFieldGet2(_list, this)[key] = value;
715
- }
716
- }
717
- }, {
718
- key: "exist",
719
- value: function exist(key) {
720
- if (_classPrivateFieldGet2(_enabled, this)) {
721
- return hasProp(_classPrivateFieldGet2(_list, this), key);
722
- }
723
- }
724
- }, {
725
- key: "clear",
726
- value: function clear() {
727
- _classPrivateFieldSet2(_list, this, {});
728
- }
729
- }, {
730
- key: "remove",
731
- value: function remove(key) {
732
- delete _classPrivateFieldGet2(_list, this)[key];
482
+ var Template = function Template(options, cache, compiler) {
483
+ var config = {
484
+ path: null,
485
+ resolver: null
486
+ };
487
+ var resolve = function resolve(path) {
488
+ return config.resolver(config.path, path);
489
+ };
490
+ var result = function result(template, content) {
491
+ cache.set(template, content);
492
+ return content;
493
+ };
494
+ var compile = function compile(content, template) {
495
+ if (isFunction(content)) {
496
+ return content;
497
+ } else {
498
+ return compiler.compile(content, template);
733
499
  }
734
- }, {
735
- key: "resolve",
736
- value: function resolve(key) {
737
- return Promise.resolve(this.get(key));
500
+ };
501
+ var get = function get(template) {
502
+ if (cache.exist(template)) {
503
+ return cache.resolve(template);
738
504
  }
739
- }, {
740
- key: "configure",
741
- value: function configure(config) {
742
- _classPrivateFieldSet2(_enabled, this, config.cache);
743
- if (isNode() === false) {
744
- this.load(global[config["export"]]);
745
- }
505
+ return resolve(template).then(function (content) {
506
+ return result(template, compile(content, template));
507
+ });
508
+ };
509
+ var configure = function configure(options) {
510
+ config.path = options.path;
511
+ if (isFunction(options.resolver)) {
512
+ config.resolver = options.resolver;
746
513
  }
747
- }]);
748
- }();
514
+ };
515
+ configure(options);
516
+ return {
517
+ get: get,
518
+ configure: configure,
519
+ compile: compile
520
+ };
521
+ };
749
522
 
750
- var _config$1 = /*#__PURE__*/new WeakMap();
751
- var _symbols = /*#__PURE__*/new WeakMap();
752
- var Compiler = /*#__PURE__*/function () {
753
- function Compiler(config) {
754
- _classCallCheck(this, Compiler);
755
- _classPrivateFieldInitSpec(this, _config$1, {});
756
- _classPrivateFieldInitSpec(this, _symbols, [{
757
- symbol: '-',
758
- format: function format(value) {
759
- return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
760
- }
761
- }, {
762
- symbol: '=',
763
- format: function format(value) {
764
- return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
765
- }
766
- }, {
767
- symbol: '#',
768
- format: function format(value) {
769
- return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
770
- }
771
- }, {
772
- symbol: '',
773
- format: function format(value) {
774
- return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
775
- }
776
- }]);
777
- this.configure(config);
523
+ var configSymbols = [{
524
+ symbol: '-',
525
+ format: function format(value) {
526
+ return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
778
527
  }
779
- return _createClass(Compiler, [{
780
- key: "configure",
781
- value: function configure(config) {
782
- var _this = this;
783
- _classPrivateFieldGet2(_config$1, this).withObject = config.withObject;
784
- _classPrivateFieldGet2(_config$1, this).rmWhitespace = config.rmWhitespace;
785
- _classPrivateFieldGet2(_config$1, this).token = config.token;
786
- _classPrivateFieldGet2(_config$1, this).vars = config.vars;
787
- _classPrivateFieldGet2(_config$1, this).globalHelpers = config.globalHelpers;
788
- _classPrivateFieldGet2(_config$1, this).matches = [];
789
- _classPrivateFieldGet2(_config$1, this).formats = [];
790
- _classPrivateFieldGet2(_config$1, this).slurp = {
791
- match: '[s\t\n]*',
792
- start: [_classPrivateFieldGet2(_config$1, this).token.start, '_'],
793
- end: ['_', _classPrivateFieldGet2(_config$1, this).token.end]
794
- };
795
- _classPrivateFieldGet2(_symbols, this).forEach(function (item) {
796
- _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));
797
- _classPrivateFieldGet2(_config$1, _this).formats.push(item.format.bind(_classPrivateFieldGet2(_config$1, _this).vars));
798
- });
799
- _classPrivateFieldGet2(_config$1, this).regex = new RegExp(_classPrivateFieldGet2(_config$1, this).matches.join('|').concat('|$'), 'g');
800
- _classPrivateFieldGet2(_config$1, this).slurpStart = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.match, _classPrivateFieldGet2(_config$1, this).slurp.start.join('')].join(''), 'gm');
801
- _classPrivateFieldGet2(_config$1, this).slurpEnd = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.end.join(''), _classPrivateFieldGet2(_config$1, this).slurp.match].join(''), 'gm');
528
+ }, {
529
+ symbol: '=',
530
+ format: function format(value) {
531
+ return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
532
+ }
533
+ }, {
534
+ symbol: '#',
535
+ format: function format(value) {
536
+ return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
537
+ }
538
+ }, {
539
+ symbol: '',
540
+ format: function format(value) {
541
+ return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
542
+ }
543
+ }];
544
+ var Compiler = function Compiler(options) {
545
+ var config = {};
546
+ var configure = function configure(options) {
547
+ config.withObject = options.withObject;
548
+ config.rmWhitespace = options.rmWhitespace;
549
+ config.token = options.token;
550
+ config.vars = options.vars;
551
+ config.globalHelpers = options.globalHelpers;
552
+ config.matches = [];
553
+ config.formats = [];
554
+ config.slurp = {
555
+ match: '[s\t\n]*',
556
+ start: [config.token.start, '_'],
557
+ end: ['_', config.token.end]
558
+ };
559
+ configSymbols.forEach(function (item) {
560
+ config.matches.push(config.token.start.concat(item.symbol).concat(config.token.regex).concat(config.token.end));
561
+ config.formats.push(item.format.bind(config.vars));
562
+ });
563
+ config.regex = new RegExp(config.matches.join('|').concat('|$'), 'g');
564
+ config.slurpStart = new RegExp([config.slurp.match, config.slurp.start.join('')].join(''), 'gm');
565
+ config.slurpEnd = new RegExp([config.slurp.end.join(''), config.slurp.match].join(''), 'gm');
566
+ };
567
+ var compile = function compile(content, path) {
568
+ var _config$vars = config.vars,
569
+ SCOPE = _config$vars.SCOPE,
570
+ SAFE = _config$vars.SAFE,
571
+ BUFFER = _config$vars.BUFFER,
572
+ COMPONENT = _config$vars.COMPONENT,
573
+ ELEMENT = _config$vars.ELEMENT;
574
+ var GLOBALS = config.globalHelpers;
575
+ if (config.rmWhitespace) {
576
+ content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
802
577
  }
803
- }, {
804
- key: "compile",
805
- value: function compile(content, path) {
806
- var _this2 = this;
807
- var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config$1, this).vars,
808
- SCOPE = _classPrivateFieldGet2$1.SCOPE,
809
- SAFE = _classPrivateFieldGet2$1.SAFE,
810
- BUFFER = _classPrivateFieldGet2$1.BUFFER,
811
- COMPONENT = _classPrivateFieldGet2$1.COMPONENT,
812
- ELEMENT = _classPrivateFieldGet2$1.ELEMENT;
813
- var GLOBALS = _classPrivateFieldGet2(_config$1, this).globalHelpers;
814
- if (_classPrivateFieldGet2(_config$1, this).rmWhitespace) {
815
- content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
816
- }
817
- 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);
818
- var source = "".concat(BUFFER, "('");
819
- matchTokens(_classPrivateFieldGet2(_config$1, this).regex, content, function (params, index, offset) {
820
- source += symbols(content.slice(index, offset));
821
- params.forEach(function (value, index) {
822
- if (value) {
823
- source += _classPrivateFieldGet2(_config$1, _this2).formats[index](value);
824
- }
825
- });
578
+ content = String(content).replace(config.slurpStart, config.token.start).replace(config.slurpEnd, config.token.end);
579
+ var source = "".concat(BUFFER, "('");
580
+ matchTokens(config.regex, content, function (params, index, offset) {
581
+ source += symbols(content.slice(index, offset));
582
+ params.forEach(function (value, index) {
583
+ if (value) {
584
+ source += config.formats[index](value);
585
+ }
826
586
  });
827
- source += "');";
828
- source = "try{".concat(source, "}catch(e){return ").concat(BUFFER, ".error(e)}");
829
- if (_classPrivateFieldGet2(_config$1, this).withObject) {
830
- source = "with(".concat(SCOPE, "){").concat(source, "}");
831
- }
832
- source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
833
- source += "\n//# sourceURL=".concat(path);
834
- var result = null;
835
- var params = [SCOPE, COMPONENT, ELEMENT, BUFFER, SAFE].concat(GLOBALS);
836
- try {
837
- result = Function.apply(null, params.concat(source));
838
- result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
839
- } catch (e) {
840
- e.filename = path;
841
- e.source = source;
842
- throw e;
843
- }
844
- return result;
587
+ });
588
+ source += "');";
589
+ source = "try{".concat(source, "}catch(e){return ").concat(BUFFER, ".error(e)}");
590
+ if (config.withObject) {
591
+ source = "with(".concat(SCOPE, "){").concat(source, "}");
845
592
  }
846
- }]);
847
- }();
593
+ source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
594
+ source += "\n//# sourceURL=".concat(path);
595
+ var result = null;
596
+ var params = [SCOPE, COMPONENT, ELEMENT, BUFFER, SAFE].concat(GLOBALS);
597
+ try {
598
+ result = Function.apply(null, params.concat(source));
599
+ result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
600
+ } catch (e) {
601
+ e.filename = path;
602
+ e.source = source;
603
+ throw e;
604
+ }
605
+ return result;
606
+ };
607
+ configure(options);
608
+ return {
609
+ configure: configure,
610
+ compile: compile
611
+ };
612
+ };
848
613
 
849
- var _path = /*#__PURE__*/new WeakMap();
850
- var _cache$1 = /*#__PURE__*/new WeakMap();
851
- var _compiler$1 = /*#__PURE__*/new WeakMap();
852
- var _resolver = /*#__PURE__*/new WeakMap();
853
- var _Template_brand = /*#__PURE__*/new WeakSet();
854
- var Template = /*#__PURE__*/function () {
855
- function Template(config, cache, compiler) {
856
- _classCallCheck(this, Template);
857
- _classPrivateMethodInitSpec(this, _Template_brand);
858
- _classPrivateFieldInitSpec(this, _path, void 0);
859
- _classPrivateFieldInitSpec(this, _cache$1, void 0);
860
- _classPrivateFieldInitSpec(this, _compiler$1, void 0);
861
- _classPrivateFieldInitSpec(this, _resolver, void 0);
862
- assertInstanceOf(cache, Cache);
863
- assertInstanceOf(compiler, Compiler);
864
- _classPrivateFieldSet2(_cache$1, this, cache);
865
- _classPrivateFieldSet2(_compiler$1, this, compiler);
866
- this.configure(config);
867
- }
868
- return _createClass(Template, [{
869
- key: "configure",
870
- value: function configure(config) {
871
- _classPrivateFieldSet2(_path, this, config.path);
872
- if (isFunction(config.resolver)) {
873
- _classPrivateFieldSet2(_resolver, this, config.resolver);
874
- }
614
+ var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
615
+ var Cache = function Cache() {
616
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
617
+ var config = {};
618
+ var list = {};
619
+ var load = function load(data) {
620
+ if (config.enabled) {
621
+ extend(list, data || {});
875
622
  }
876
- }, {
877
- key: "get",
878
- value: function get(template) {
879
- var _this = this;
880
- if (_classPrivateFieldGet2(_cache$1, this).exist(template)) {
881
- return _classPrivateFieldGet2(_cache$1, this).resolve(template);
882
- }
883
- return _assertClassBrand(_Template_brand, this, _resolve).call(this, template).then(function (content) {
884
- return _assertClassBrand(_Template_brand, _this, _result).call(_this, template, _assertClassBrand(_Template_brand, _this, _compile).call(_this, content, template));
885
- });
623
+ };
624
+ var get = function get(key) {
625
+ if (config.enabled) {
626
+ return list[key];
886
627
  }
887
- }]);
888
- }();
889
- function _resolve(path) {
890
- return _classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path, this), path);
891
- }
892
- function _result(template, content) {
893
- _classPrivateFieldGet2(_cache$1, this).set(template, content);
894
- return content;
895
- }
896
- function _compile(content, template) {
897
- if (isFunction(content)) {
898
- return content;
899
- } else {
900
- return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
901
- }
902
- }
628
+ };
629
+ var set = function set(key, value) {
630
+ if (config.enabled) {
631
+ list[key] = value;
632
+ }
633
+ };
634
+ var exist = function exist(key) {
635
+ if (config.enabled) {
636
+ return hasProp(list, key);
637
+ }
638
+ };
639
+ var clear = function clear() {
640
+ Object.keys(list).forEach(remove);
641
+ };
642
+ var remove = function remove(key) {
643
+ delete list[key];
644
+ };
645
+ var resolve = function resolve(key) {
646
+ return Promise.resolve(get(key));
647
+ };
648
+ var configure = function configure() {
649
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
650
+ config.enabled = options.cache;
651
+ config["export"] = options["export"];
652
+ if (isNode() === false) {
653
+ load(global[config["export"]]);
654
+ }
655
+ };
656
+ configure(options);
657
+ return {
658
+ configure: configure,
659
+ load: load,
660
+ set: set,
661
+ get: get,
662
+ exist: exist,
663
+ clear: clear,
664
+ remove: remove,
665
+ resolve: resolve
666
+ };
667
+ };
903
668
 
904
669
  var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
905
670
  var space = ' ';
@@ -926,61 +691,50 @@ var element = function element(tag, attrs, content) {
926
691
  return result.join('');
927
692
  };
928
693
 
929
- var TemplateError = /*#__PURE__*/function (_Error) {
930
- function TemplateError(message) {
931
- var _this;
932
- _classCallCheck(this, TemplateError);
933
- _this = _callSuper(this, TemplateError);
934
- _defineProperty(_this, "code", 0);
935
- _this.message = message;
936
- return _this;
937
- }
938
- _inherits(TemplateError, _Error);
939
- return _createClass(TemplateError, [{
940
- key: "getCode",
941
- value: function getCode() {
942
- return this.code;
943
- }
944
- }, {
945
- key: "getMessage",
946
- value: function getMessage() {
947
- return this.message;
948
- }
949
- }, {
950
- key: "toString",
951
- value: function toString() {
952
- return this.getMessage();
953
- }
954
- }]);
955
- }(/*#__PURE__*/_wrapNativeSuper(Error));
956
- var TemplateNotFound = /*#__PURE__*/function (_TemplateError2) {
957
- function TemplateNotFound() {
958
- var _this2;
959
- _classCallCheck(this, TemplateNotFound);
960
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
961
- args[_key] = arguments[_key];
962
- }
963
- _this2 = _callSuper(this, TemplateNotFound, [].concat(args));
964
- _defineProperty(_this2, "code", 404);
965
- return _this2;
966
- }
967
- _inherits(TemplateNotFound, _TemplateError2);
968
- return _createClass(TemplateNotFound);
969
- }(TemplateError);
970
- var TemplateSyntaxError = /*#__PURE__*/function (_TemplateError3) {
971
- function TemplateSyntaxError() {
972
- var _this3;
973
- _classCallCheck(this, TemplateSyntaxError);
974
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
975
- args[_key2] = arguments[_key2];
976
- }
977
- _this3 = _callSuper(this, TemplateSyntaxError, [].concat(args));
978
- _defineProperty(_this3, "code", 500);
979
- return _this3;
694
+ /**
695
+ *
696
+ * @constructor
697
+ */
698
+ function TemplateError() {
699
+ TemplateError.call(this);
700
+ }
701
+ Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
702
+ Object.assign(TemplateError.prototype, {
703
+ code: 0,
704
+ getCode: function getCode() {
705
+ return this.code;
706
+ },
707
+ getMessage: function getMessage() {
708
+ return this.message;
709
+ },
710
+ toString: function toString() {
711
+ return this.getMessage();
980
712
  }
981
- _inherits(TemplateSyntaxError, _TemplateError3);
982
- return _createClass(TemplateSyntaxError);
983
- }(TemplateError);
713
+ });
714
+
715
+ /**
716
+ *
717
+ * @constructor
718
+ */
719
+ function TemplateNotFound() {
720
+ TemplateError.call(this);
721
+ }
722
+ Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
723
+ Object.assign(TemplateNotFound.prototype, {
724
+ code: 404
725
+ });
726
+
727
+ /**
728
+ *
729
+ * @constructor
730
+ */
731
+ function TemplateSyntaxError() {
732
+ TemplateError.call(this);
733
+ }
734
+ Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
735
+ Object.assign(TemplateSyntaxError.prototype, {
736
+ code: 500
737
+ });
984
738
 
985
739
  function resolve(list) {
986
740
  return Promise.all(list || []).then(function (list) {
@@ -1036,6 +790,7 @@ var createContextScope = function createContextScope(config, methods) {
1036
790
  SCOPE = _config$vars.SCOPE,
1037
791
  COMPONENT = _config$vars.COMPONENT,
1038
792
  ELEMENT = _config$vars.ELEMENT;
793
+
1039
794
  /**
1040
795
  *
1041
796
  * @type {symbol}
@@ -1332,149 +1087,113 @@ var createContextScope = function createContextScope(config, methods) {
1332
1087
  });
1333
1088
  return ContextScope;
1334
1089
  };
1335
- var _scope = /*#__PURE__*/new WeakMap();
1336
- var Context = /*#__PURE__*/function () {
1337
- function Context(config, methods) {
1338
- _classCallCheck(this, Context);
1339
- _classPrivateFieldInitSpec(this, _scope, void 0);
1340
- this.configure(config, methods);
1341
- }
1342
- return _createClass(Context, [{
1343
- key: "create",
1344
- value: function create(data) {
1345
- return new (_classPrivateFieldGet2(_scope, this))(data);
1346
- }
1347
- }, {
1348
- key: "configure",
1349
- value: function configure(config, methods) {
1350
- _classPrivateFieldSet2(_scope, this, createContextScope(config, methods));
1351
- }
1352
- }, {
1353
- key: "helpers",
1354
- value: function helpers(methods) {
1355
- extend(_classPrivateFieldGet2(_scope, this).prototype, methods || {});
1356
- }
1357
- }]);
1358
- }();
1090
+ var Context = function Context(options, methods) {
1091
+ /**
1092
+ * @type {InstanceType<ContextScope>}
1093
+ */
1094
+ var Scope;
1095
+ var create = function create(data) {
1096
+ return new Scope(data);
1097
+ };
1098
+ var helpers = function helpers(methods) {
1099
+ extend(Scope.prototype, methods || {});
1100
+ };
1101
+ var configure = function configure(options, methods) {
1102
+ Scope = createContextScope(options, methods);
1103
+ };
1104
+ configure(options, methods);
1105
+ return {
1106
+ configure: configure,
1107
+ create: create,
1108
+ helpers: helpers
1109
+ };
1110
+ };
1359
1111
 
1360
- var _config = /*#__PURE__*/new WeakMap();
1361
- var _extend = /*#__PURE__*/new WeakMap();
1362
- var _context = /*#__PURE__*/new WeakMap();
1363
- var _compiler = /*#__PURE__*/new WeakMap();
1364
- var _cache = /*#__PURE__*/new WeakMap();
1365
- var _template = /*#__PURE__*/new WeakMap();
1366
- var _EJS_brand = /*#__PURE__*/new WeakSet();
1367
- var EJS = /*#__PURE__*/function () {
1368
- function EJS(options) {
1369
- _classCallCheck(this, EJS);
1370
- _classPrivateMethodInitSpec(this, _EJS_brand);
1371
- _classPrivateFieldInitSpec(this, _config, {});
1372
- _classPrivateFieldInitSpec(this, _extend, {});
1373
- _classPrivateFieldInitSpec(this, _context, void 0);
1374
- _classPrivateFieldInitSpec(this, _compiler, void 0);
1375
- _classPrivateFieldInitSpec(this, _cache, void 0);
1376
- _classPrivateFieldInitSpec(this, _template, void 0);
1377
- configSchema(_classPrivateFieldGet2(_config, this), options || {});
1378
- _classPrivateFieldSet2(_context, this, new Context(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this)));
1379
- _classPrivateFieldSet2(_compiler, this, new Compiler(_classPrivateFieldGet2(_config, this)));
1380
- _classPrivateFieldSet2(_cache, this, new Cache(_classPrivateFieldGet2(_config, this)));
1381
- _classPrivateFieldSet2(_template, this, new Template(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_cache, this), _classPrivateFieldGet2(_compiler, this)));
1382
- //
1383
- bindContext(this, ['configure', 'create', 'render', 'require', 'context', 'preload', 'compile', 'helpers']);
1384
- //
1385
- this.helpers({
1386
- require: this.require,
1387
- render: this.render
1112
+ var _EJS$1 = function EJS() {
1113
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1114
+ var config = configSchema({}, options);
1115
+ var methods = {};
1116
+ var context = Context(config, methods);
1117
+ var compiler = Compiler(config);
1118
+ var cache = Cache(config);
1119
+ var template = Template(config, cache, compiler);
1120
+ var configure = function configure() {
1121
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1122
+ configSchema(config, options || {});
1123
+ context.configure(config, methods);
1124
+ compiler.configure(config);
1125
+ cache.configure(config);
1126
+ template.configure(config);
1127
+ return config;
1128
+ };
1129
+ var filePath = function filePath(name) {
1130
+ return ext(name, config.extension);
1131
+ };
1132
+ var require = function require(name) {
1133
+ var scope = createContext({});
1134
+ return output(filePath(name), scope).then(function () {
1135
+ return scope.getMacro();
1388
1136
  });
1389
- }
1390
- return _createClass(EJS, [{
1391
- key: "configure",
1392
- value: function configure(options) {
1393
- configSchema(_classPrivateFieldGet2(_config, this), options || {});
1394
- _classPrivateFieldGet2(_context, this).configure(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this));
1395
- _classPrivateFieldGet2(_compiler, this).configure(_classPrivateFieldGet2(_config, this));
1396
- _classPrivateFieldGet2(_cache, this).configure(_classPrivateFieldGet2(_config, this));
1397
- _classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
1398
- return _classPrivateFieldGet2(_config, this);
1399
- }
1400
- }, {
1401
- key: "filePath",
1402
- value: function filePath(name) {
1403
- return ext(name, _classPrivateFieldGet2(_config, this).extension);
1404
- }
1405
- }, {
1406
- key: "require",
1407
- value: function require(name) {
1408
- var scope = this.context({});
1409
- return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(function () {
1410
- return scope.getMacro();
1411
- });
1412
- }
1413
- }, {
1414
- key: "render",
1415
- value: function render(name, data) {
1416
- var scope = this.context(data);
1417
- return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
1418
- }
1419
- }, {
1420
- key: "outputContent",
1421
- value: function outputContent(name, scope) {
1422
- var _this = this;
1423
- return function (content) {
1424
- if (scope.getExtend()) {
1425
- scope.setExtend(false);
1426
- return _this.renderLayout(scope.getLayout(), scope, name);
1427
- }
1428
- return content;
1429
- };
1430
- }
1431
- }, {
1432
- key: "renderLayout",
1433
- value: function renderLayout(name, data, parent) {
1434
- var scope = this.context(data);
1435
- if (parent) scope.setParentTemplate(parent);
1436
- return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
1437
- }
1438
- }, {
1439
- key: "helpers",
1440
- value: function helpers(methods) {
1441
- _classPrivateFieldGet2(_context, this).helpers(extend(_classPrivateFieldGet2(_extend, this), methods));
1442
- }
1443
- }, {
1444
- key: "context",
1445
- value: function context(data) {
1446
- return _classPrivateFieldGet2(_context, this).create(data);
1447
- }
1448
- }, {
1449
- key: "compile",
1450
- value: function compile(content, path) {
1451
- return _classPrivateFieldGet2(_compiler, this).compile(content, path);
1452
- }
1453
- }, {
1454
- key: "preload",
1455
- value: function preload(list) {
1456
- return _classPrivateFieldGet2(_cache, this).load(list || {});
1457
- }
1458
- }, {
1459
- key: "create",
1460
- value: function create(options) {
1461
- return new this.constructor(options);
1462
- }
1463
- }]);
1464
- }();
1465
- function _output(path, scope) {
1466
- var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
1467
- globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
1468
- var params = [scope, scope.useComponent, scope.useElement, scope.getBuffer(), scope.useSafeValue];
1469
- var globals = globalHelpers.filter(function (name) {
1470
- return isFunction(scope[name]);
1471
- }).map(function (name) {
1472
- return scope[name].bind(scope);
1473
- });
1474
- return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
1475
- return callback.apply(scope, params.concat(globals));
1137
+ };
1138
+ var render = function render(name, data) {
1139
+ var scope = createContext(data);
1140
+ return output(filePath(name), scope).then(outputContent(name, scope));
1141
+ };
1142
+ var outputContent = function outputContent(name, scope) {
1143
+ return function (content) {
1144
+ if (scope.getExtend()) {
1145
+ scope.setExtend(false);
1146
+ return renderLayout(scope.getLayout(), scope, name);
1147
+ }
1148
+ return content;
1149
+ };
1150
+ };
1151
+ var renderLayout = function renderLayout(name, data, parent) {
1152
+ var scope = createContext(data);
1153
+ if (parent) scope.setParentTemplate(parent);
1154
+ return output(filePath(name), scope).then(outputContent(name, scope));
1155
+ };
1156
+ var helpers = function helpers(extendMethods) {
1157
+ context.helpers(extend(methods, extendMethods));
1158
+ };
1159
+ var createContext = function createContext(data) {
1160
+ return context.create(data);
1161
+ };
1162
+ var compile = function compile(content, path) {
1163
+ return compiler.compile(content, path);
1164
+ };
1165
+ var preload = function preload(list) {
1166
+ return cache.load(list || {});
1167
+ };
1168
+ var create = function create(config) {
1169
+ return _EJS$1(config);
1170
+ };
1171
+ var output = function output(path, scope) {
1172
+ var params = [scope, scope.useComponent, scope.useElement, scope.getBuffer(), scope.useSafeValue];
1173
+ var globals = config.globalHelpers.filter(function (name) {
1174
+ return isFunction(scope[name]);
1175
+ }).map(function (name) {
1176
+ return scope[name].bind(scope);
1177
+ });
1178
+ return template.get(path).then(function (callback) {
1179
+ return callback.apply(scope, params.concat(globals));
1180
+ });
1181
+ };
1182
+ helpers({
1183
+ render: render,
1184
+ require: require
1476
1185
  });
1477
- }
1186
+ return {
1187
+ configure: configure,
1188
+ create: create,
1189
+ createContext: createContext,
1190
+ render: render,
1191
+ require: require,
1192
+ preload: preload,
1193
+ compile: compile,
1194
+ helpers: helpers
1195
+ };
1196
+ };
1478
1197
 
1479
1198
  var templateCache = {};
1480
1199
  var getOrigin = function getOrigin(url, secure) {
@@ -1482,7 +1201,7 @@ var getOrigin = function getOrigin(url, secure) {
1482
1201
  url.protocol = secure ? 'https:' : 'http:';
1483
1202
  return url.origin;
1484
1203
  };
1485
- var _EJS = new EJS({
1204
+ var _EJS = _EJS$1({
1486
1205
  cache: false,
1487
1206
  withObject: false,
1488
1207
  resolver: function resolver(path, name) {
@@ -1490,13 +1209,13 @@ var _EJS = new EJS({
1490
1209
  if (isFunction(templateCache[name])) {
1491
1210
  resolve(templateCache[name]);
1492
1211
  } else {
1493
- reject(new TemplateNotFound("template ".concat(name, " not found")));
1212
+ reject(new TemplateNotFound());
1494
1213
  }
1495
1214
  });
1496
1215
  }
1497
1216
  }),
1498
1217
  render = _EJS.render,
1499
- context = _EJS.context,
1218
+ createContext = _EJS.createContext,
1500
1219
  helpers = _EJS.helpers,
1501
1220
  configure = _EJS.configure;
1502
1221
  function useTemplates() {
@@ -1537,7 +1256,7 @@ function useRenderer() {
1537
1256
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1538
1257
  while (1) switch (_context.prev = _context.next) {
1539
1258
  case 0:
1540
- c.data = context({});
1259
+ c.data = createContext({});
1541
1260
  c.data.set('version', version);
1542
1261
  c.data.set('origin', getOrigin(c.req.url, secure));
1543
1262
  c.data.set('path', c.req.path);
@@ -1576,7 +1295,7 @@ exports.TemplateError = TemplateError;
1576
1295
  exports.TemplateNotFound = TemplateNotFound;
1577
1296
  exports.TemplateSyntaxError = TemplateSyntaxError;
1578
1297
  exports.configure = configure;
1579
- exports.context = context;
1298
+ exports.createContext = createContext;
1580
1299
  exports.helpers = helpers;
1581
1300
  exports.render = render;
1582
1301
  exports.setRenderer = setRenderer;