@kosatyi/ejs 0.0.114 → 0.0.116

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.
@@ -250,28 +250,25 @@ class EjsTemplate {
250
250
  }
251
251
  }
252
252
  get(template) {
253
+ const callback = _classPrivateFieldGet2(_cache$2, this).get(template);
254
+ if (callback) return Promise.resolve(callback);
253
255
  return _assertClassBrand(_EjsTemplate_brand, this, _resolve).call(this, template).then(content => {
254
- return _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
256
+ const callback = _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
257
+ _classPrivateFieldGet2(_cache$2, this).set(template, callback);
258
+ return callback;
255
259
  });
256
260
  }
257
261
  }
258
262
  function _resolve(template) {
259
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
260
- if (cached instanceof Promise) return cached;
261
- const result = Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
262
- _classPrivateFieldGet2(_cache$2, this).set(template, result);
263
- return result;
263
+ return Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
264
264
  }
265
265
  function _compile(content, template) {
266
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
267
- if (typeof cached === 'function') return cached;
268
- if (typeof content === 'string') {
269
- content = _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
270
- }
271
266
  if (typeof content === 'function') {
272
- _classPrivateFieldGet2(_cache$2, this).set(template, content);
273
267
  return content;
274
268
  }
269
+ if (typeof content === 'string') {
270
+ return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
271
+ }
275
272
  }
276
273
  _defineProperty(EjsTemplate, "exports", ['configure', 'get']);
277
274
 
@@ -792,7 +789,7 @@ var _EjsInstance_brand = /*#__PURE__*/new WeakSet();
792
789
  class EjsInstance {
793
790
  /**
794
791
  *
795
- * @param {EjsConfig} options
792
+ * @param {Partial<EjsConfig>} options
796
793
  */
797
794
  constructor() {
798
795
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -876,7 +873,8 @@ function _outputContent(name, data) {
876
873
  _defineProperty(EjsInstance, "exports", ['configure', 'create', 'createContext', 'render', 'require', 'preload', 'compile', 'helpers']);
877
874
 
878
875
  const resolver = async (path, template, error) => {
879
- return fetch(joinPath(path, template)).then(response => {
876
+ const url = new URL(joinPath(path, template), location.origin);
877
+ return fetch(url).then(response => {
880
878
  if (response.ok) return response.text();
881
879
  return error(1, "template ".concat(template, " not found"));
882
880
  }, reason => error(0, reason));
package/dist/cjs/index.js CHANGED
@@ -253,28 +253,25 @@ class EjsTemplate {
253
253
  }
254
254
  }
255
255
  get(template) {
256
+ const callback = _classPrivateFieldGet2(_cache$2, this).get(template);
257
+ if (callback) return Promise.resolve(callback);
256
258
  return _assertClassBrand(_EjsTemplate_brand, this, _resolve).call(this, template).then(content => {
257
- return _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
259
+ const callback = _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
260
+ _classPrivateFieldGet2(_cache$2, this).set(template, callback);
261
+ return callback;
258
262
  });
259
263
  }
260
264
  }
261
265
  function _resolve(template) {
262
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
263
- if (cached instanceof Promise) return cached;
264
- const result = Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
265
- _classPrivateFieldGet2(_cache$2, this).set(template, result);
266
- return result;
266
+ return Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
267
267
  }
268
268
  function _compile(content, template) {
269
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
270
- if (typeof cached === 'function') return cached;
271
- if (typeof content === 'string') {
272
- content = _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
273
- }
274
269
  if (typeof content === 'function') {
275
- _classPrivateFieldGet2(_cache$2, this).set(template, content);
276
270
  return content;
277
271
  }
272
+ if (typeof content === 'string') {
273
+ return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
274
+ }
278
275
  }
279
276
  _defineProperty(EjsTemplate, "exports", ['configure', 'get']);
280
277
 
@@ -795,7 +792,7 @@ var _EjsInstance_brand = /*#__PURE__*/new WeakSet();
795
792
  class EjsInstance {
796
793
  /**
797
794
  *
798
- * @param {EjsConfig} options
795
+ * @param {Partial<EjsConfig>} options
799
796
  */
800
797
  constructor() {
801
798
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -245,28 +245,25 @@ class EjsTemplate {
245
245
  }
246
246
  }
247
247
  get(template) {
248
+ const callback = _classPrivateFieldGet2(_cache$2, this).get(template);
249
+ if (callback) return Promise.resolve(callback);
248
250
  return _assertClassBrand(_EjsTemplate_brand, this, _resolve).call(this, template).then(content => {
249
- return _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
251
+ const callback = _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
252
+ _classPrivateFieldGet2(_cache$2, this).set(template, callback);
253
+ return callback;
250
254
  });
251
255
  }
252
256
  }
253
257
  function _resolve(template) {
254
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
255
- if (cached instanceof Promise) return cached;
256
- const result = Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
257
- _classPrivateFieldGet2(_cache$2, this).set(template, result);
258
- return result;
258
+ return Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
259
259
  }
260
260
  function _compile(content, template) {
261
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
262
- if (typeof cached === 'function') return cached;
263
- if (typeof content === 'string') {
264
- content = _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
265
- }
266
261
  if (typeof content === 'function') {
267
- _classPrivateFieldGet2(_cache$2, this).set(template, content);
268
262
  return content;
269
263
  }
264
+ if (typeof content === 'string') {
265
+ return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
266
+ }
270
267
  }
271
268
  _defineProperty(EjsTemplate, "exports", ['configure', 'get']);
272
269
 
@@ -787,7 +784,7 @@ var _EjsInstance_brand = /*#__PURE__*/new WeakSet();
787
784
  class EjsInstance {
788
785
  /**
789
786
  *
790
- * @param {EjsConfig} options
787
+ * @param {Partial<EjsConfig>} options
791
788
  */
792
789
  constructor() {
793
790
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -236,12 +236,14 @@ class EjsTemplate {
236
236
  #cache
237
237
  #compiler
238
238
  static exports = ['configure', 'get']
239
+
239
240
  constructor(options, cache, compiler) {
240
241
  bindContext(this, this.constructor.exports);
241
242
  this.#cache = cache;
242
243
  this.#compiler = compiler;
243
244
  this.configure(options ?? {});
244
245
  }
246
+
245
247
  configure(options) {
246
248
  this.#path = options.path;
247
249
  if (isFunction(options.resolver)) {
@@ -249,28 +251,23 @@ class EjsTemplate {
249
251
  }
250
252
  }
251
253
  #resolve(template) {
252
- const cached = this.#cache.get(template);
253
- if (cached instanceof Promise) return cached
254
- const result = Promise.resolve(
255
- this.#resolver(this.#path, template, error),
256
- );
257
- this.#cache.set(template, result);
258
- return result
254
+ return Promise.resolve(this.#resolver(this.#path, template, error))
259
255
  }
260
256
  #compile(content, template) {
261
- const cached = this.#cache.get(template);
262
- if (typeof cached === 'function') return cached
263
- if (typeof content === 'string') {
264
- content = this.#compiler.compile(content, template);
265
- }
266
257
  if (typeof content === 'function') {
267
- this.#cache.set(template, content);
268
258
  return content
269
259
  }
260
+ if (typeof content === 'string') {
261
+ return this.#compiler.compile(content, template)
262
+ }
270
263
  }
271
264
  get(template) {
265
+ const callback = this.#cache.get(template);
266
+ if (callback) return Promise.resolve(callback)
272
267
  return this.#resolve(template).then((content) => {
273
- return this.#compile(content, template)
268
+ const callback = this.#compile(content, template);
269
+ this.#cache.set(template, callback);
270
+ return callback
274
271
  })
275
272
  }
276
273
  }
@@ -868,7 +865,7 @@ class EjsInstance {
868
865
  ]
869
866
  /**
870
867
  *
871
- * @param {EjsConfig} options
868
+ * @param {Partial<EjsConfig>} options
872
869
  */
873
870
  constructor(options = {}) {
874
871
  bindContext(this, this.constructor.exports);
@@ -958,7 +955,8 @@ class EjsInstance {
958
955
  }
959
956
 
960
957
  const resolver = async (path, template, error) => {
961
- return fetch(joinPath(path, template)).then(
958
+ const url = new URL(joinPath(path, template), location.origin);
959
+ return fetch(url).then(
962
960
  (response) => {
963
961
  if (response.ok) return response.text()
964
962
  return error(1, `template ${template} not found`)
package/dist/esm/index.js CHANGED
@@ -239,12 +239,14 @@ class EjsTemplate {
239
239
  #cache
240
240
  #compiler
241
241
  static exports = ['configure', 'get']
242
+
242
243
  constructor(options, cache, compiler) {
243
244
  bindContext(this, this.constructor.exports);
244
245
  this.#cache = cache;
245
246
  this.#compiler = compiler;
246
247
  this.configure(options ?? {});
247
248
  }
249
+
248
250
  configure(options) {
249
251
  this.#path = options.path;
250
252
  if (isFunction(options.resolver)) {
@@ -252,28 +254,23 @@ class EjsTemplate {
252
254
  }
253
255
  }
254
256
  #resolve(template) {
255
- const cached = this.#cache.get(template);
256
- if (cached instanceof Promise) return cached
257
- const result = Promise.resolve(
258
- this.#resolver(this.#path, template, error),
259
- );
260
- this.#cache.set(template, result);
261
- return result
257
+ return Promise.resolve(this.#resolver(this.#path, template, error))
262
258
  }
263
259
  #compile(content, template) {
264
- const cached = this.#cache.get(template);
265
- if (typeof cached === 'function') return cached
266
- if (typeof content === 'string') {
267
- content = this.#compiler.compile(content, template);
268
- }
269
260
  if (typeof content === 'function') {
270
- this.#cache.set(template, content);
271
261
  return content
272
262
  }
263
+ if (typeof content === 'string') {
264
+ return this.#compiler.compile(content, template)
265
+ }
273
266
  }
274
267
  get(template) {
268
+ const callback = this.#cache.get(template);
269
+ if (callback) return Promise.resolve(callback)
275
270
  return this.#resolve(template).then((content) => {
276
- return this.#compile(content, template)
271
+ const callback = this.#compile(content, template);
272
+ this.#cache.set(template, callback);
273
+ return callback
277
274
  })
278
275
  }
279
276
  }
@@ -871,7 +868,7 @@ class EjsInstance {
871
868
  ]
872
869
  /**
873
870
  *
874
- * @param {EjsConfig} options
871
+ * @param {Partial<EjsConfig>} options
875
872
  */
876
873
  constructor(options = {}) {
877
874
  bindContext(this, this.constructor.exports);
@@ -230,12 +230,14 @@ class EjsTemplate {
230
230
  #cache
231
231
  #compiler
232
232
  static exports = ['configure', 'get']
233
+
233
234
  constructor(options, cache, compiler) {
234
235
  bindContext(this, this.constructor.exports);
235
236
  this.#cache = cache;
236
237
  this.#compiler = compiler;
237
238
  this.configure(options ?? {});
238
239
  }
240
+
239
241
  configure(options) {
240
242
  this.#path = options.path;
241
243
  if (isFunction(options.resolver)) {
@@ -243,28 +245,23 @@ class EjsTemplate {
243
245
  }
244
246
  }
245
247
  #resolve(template) {
246
- const cached = this.#cache.get(template);
247
- if (cached instanceof Promise) return cached
248
- const result = Promise.resolve(
249
- this.#resolver(this.#path, template, error),
250
- );
251
- this.#cache.set(template, result);
252
- return result
248
+ return Promise.resolve(this.#resolver(this.#path, template, error))
253
249
  }
254
250
  #compile(content, template) {
255
- const cached = this.#cache.get(template);
256
- if (typeof cached === 'function') return cached
257
- if (typeof content === 'string') {
258
- content = this.#compiler.compile(content, template);
259
- }
260
251
  if (typeof content === 'function') {
261
- this.#cache.set(template, content);
262
252
  return content
263
253
  }
254
+ if (typeof content === 'string') {
255
+ return this.#compiler.compile(content, template)
256
+ }
264
257
  }
265
258
  get(template) {
259
+ const callback = this.#cache.get(template);
260
+ if (callback) return Promise.resolve(callback)
266
261
  return this.#resolve(template).then((content) => {
267
- return this.#compile(content, template)
262
+ const callback = this.#compile(content, template);
263
+ this.#cache.set(template, callback);
264
+ return callback
268
265
  })
269
266
  }
270
267
  }
@@ -862,7 +859,7 @@ class EjsInstance {
862
859
  ]
863
860
  /**
864
861
  *
865
- * @param {EjsConfig} options
862
+ * @param {Partial<EjsConfig>} options
866
863
  */
867
864
  constructor(options = {}) {
868
865
  bindContext(this, this.constructor.exports);
@@ -254,28 +254,25 @@
254
254
  }
255
255
  }
256
256
  get(template) {
257
+ const callback = _classPrivateFieldGet2(_cache$2, this).get(template);
258
+ if (callback) return Promise.resolve(callback);
257
259
  return _assertClassBrand(_EjsTemplate_brand, this, _resolve).call(this, template).then(content => {
258
- return _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
260
+ const callback = _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
261
+ _classPrivateFieldGet2(_cache$2, this).set(template, callback);
262
+ return callback;
259
263
  });
260
264
  }
261
265
  }
262
266
  function _resolve(template) {
263
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
264
- if (cached instanceof Promise) return cached;
265
- const result = Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
266
- _classPrivateFieldGet2(_cache$2, this).set(template, result);
267
- return result;
267
+ return Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
268
268
  }
269
269
  function _compile(content, template) {
270
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
271
- if (typeof cached === 'function') return cached;
272
- if (typeof content === 'string') {
273
- content = _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
274
- }
275
270
  if (typeof content === 'function') {
276
- _classPrivateFieldGet2(_cache$2, this).set(template, content);
277
271
  return content;
278
272
  }
273
+ if (typeof content === 'string') {
274
+ return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
275
+ }
279
276
  }
280
277
  _defineProperty(EjsTemplate, "exports", ['configure', 'get']);
281
278
 
@@ -796,7 +793,7 @@
796
793
  class EjsInstance {
797
794
  /**
798
795
  *
799
- * @param {EjsConfig} options
796
+ * @param {Partial<EjsConfig>} options
800
797
  */
801
798
  constructor() {
802
799
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -880,7 +877,8 @@
880
877
  _defineProperty(EjsInstance, "exports", ['configure', 'create', 'createContext', 'render', 'require', 'preload', 'compile', 'helpers']);
881
878
 
882
879
  const resolver = async (path, template, error) => {
883
- return fetch(joinPath(path, template)).then(response => {
880
+ const url = new URL(joinPath(path, template), location.origin);
881
+ return fetch(url).then(response => {
884
882
  if (response.ok) return response.text();
885
883
  return error(1, "template ".concat(template, " not found"));
886
884
  }, reason => error(0, reason));
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejsInstance={})}(this,(function(t){"use strict";function e(t,e,s){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:s;throw new TypeError("Private element is not present on this object")}function s(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function n(t,s){return t.get(e(t,s))}function r(t,e,n){s(t,e),e.set(t,n)}function i(t,s,n){return t.set(e(t,s),n),n}function o(t,e){s(t,e),e.add(t)}function c(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var n=s.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function a(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,n)}return s}const h="ejsPrecompiled",l=!0,u="views",p="ejs",f=!0,g=!0,v=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),b=[],d={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},m={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},w=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,y=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},j=t=>Array.isArray(t),O=t=>"function"==typeof t,E=t=>"string"==typeof t,x=t=>"boolean"==typeof t,k=(t,e)=>{return Object.assign(t,{path:y(E,u,t.path,e.path),precompiled:y(E,h,t.export,e.export),resolver:y(O,v,t.resolver,e.resolver),extension:y(E,p,t.extension,e.extension),strict:y(x,g,t.strict,e.strict),rmWhitespace:y(x,f,t.rmWhitespace,e.rmWhitespace),cache:y(x,l,t.cache,e.cache),globals:y(j,b,t.globals,(s=e.globals,!!j(s)&&s.filter((t=>{const e=w.test(t);return!1===e&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),e})))),token:Object.assign({},m,t.token,e.token),vars:Object.assign({},d,t.vars,e.vars)});var s},P={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},S=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),C=S(M),W=S(P),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(C,(t=>M[t]))},$=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?T(s):s},N=(t,e,s)=>{let n=t,r=String(e).split("."),i=r.pop();for(let t=0;t<r.length;t++){const e=r[t];if(O(n.toJSON)&&(n=n.toJSON()),s&&!1===n.hasOwnProperty(e)){n={};break}n=n[e]=n[e]||{}}return O(n.toJSON)&&(n=n.toJSON()),[n,i]},B=(t,e)=>{let s;for(s in t)L(t,s)&&e(t[s],s,t)},A=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?a(Object(s),!0).forEach((function(e){c(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):a(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}({},t);for(const t of e)delete s[t];return s},L=(t,e)=>t&&Object.hasOwn(t,e),F=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for(let s=0,n=e.length;s<n;s++){const n=e[s];n in t&&(t[n]=t[n].bind(t))}};class R extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const q=(t,e)=>{throw new R(t,e)};var D=new WeakMap,U=new WeakMap,V=new WeakMap,J=new WeakMap,_=new WeakSet;class z{constructor(t,e,s){o(this,_),r(this,D,void 0),r(this,U,void 0),r(this,V,void 0),r(this,J,void 0),F(this,this.constructor.exports),i(V,this,e),i(J,this,s),this.configure(null!=t?t:{})}configure(t){i(D,this,t.path),O(t.resolver)&&i(U,this,t.resolver)}get(t){return e(_,this,K).call(this,t).then((s=>e(_,this,X).call(this,s,t)))}}function K(t){const e=n(V,this).get(t);if(e instanceof Promise)return e;const s=Promise.resolve(n(U,this).call(this,n(D,this),t,q));return n(V,this).set(t,s),s}function X(t,e){const s=n(V,this).get(e);return"function"==typeof s?s:("string"==typeof t&&(t=n(J,this).compile(t,e)),"function"==typeof t?(n(V,this).set(e,t),t):void 0)}c(z,"exports",["configure","get"]);const Y=[["-",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,",1))\n").concat(e,"('")],["=",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,"))\n").concat(e,"('")],["#",(t,e)=>"')\n/**".concat(t,"**/\n").concat(e,"('")],["",(t,e)=>"')\n".concat(t,"\n").concat(e,"('")]];var Z=new WeakMap;class I{constructor(t){r(this,Z,{}),F(this,this.constructor.exports),this.configure(t)}configure(t){var e;n(Z,this).strict=t.strict,n(Z,this).rmWhitespace=t.rmWhitespace,n(Z,this).token=t.token,n(Z,this).vars=t.vars,n(Z,this).globals=t.globals,n(Z,this).legacy=null===(e=t.legacy)||void 0===e||e,n(Z,this).slurp={match:"[s\t\n]*",start:[n(Z,this).token.start,"_"],end:["_",n(Z,this).token.end]},n(Z,this).matches=[],n(Z,this).formats=[];for(const[t,e]of Y)n(Z,this).matches.push(n(Z,this).token.start.concat(t).concat(n(Z,this).token.regex).concat(n(Z,this).token.end)),n(Z,this).formats.push(e);n(Z,this).regex=new RegExp(n(Z,this).matches.join("|").concat("|$"),"g"),n(Z,this).slurpStart=new RegExp([n(Z,this).slurp.match,n(Z,this).slurp.start.join("")].join(""),"gm"),n(Z,this).slurpEnd=new RegExp([n(Z,this).slurp.end.join(""),n(Z,this).slurp.match].join(""),"gm"),n(Z,this).globals.length&&(n(Z,this).legacy?n(Z,this).globalVariables="const ".concat(n(Z,this).globals.map((t=>"".concat(t,"=").concat(n(Z,this).vars.SCOPE,".").concat(t))).join(","),";"):n(Z,this).globalVariables="const {".concat(n(Z,this).globals.join(","),"} = ").concat(n(Z,this).vars.SCOPE,";"))}compile(t,e){const s=n(Z,this).globalVariables,{SCOPE:r,SAFE:i,BUFFER:o,COMPONENT:c,ELEMENT:a}=n(Z,this).vars;n(Z,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(n(Z,this).slurpStart,n(Z,this).token.start).replace(n(Z,this).slurpEnd,n(Z,this).token.end);let h="".concat(o,"('");((t,e,s)=>{let n=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),r=t.shift();return s(t,n,e),n=e+r.length,r}))})(n(Z,this).regex,t,((e,s,r)=>{h+=(""+t.slice(s,r)).replace(W,(t=>"\\"+P[t])),e.forEach(((t,e)=>{t&&(h+=n(Z,this).formats[e](t.trim(),o,i))}))})),h+="');",h="try{".concat(h,"}catch(e){return ").concat(o,".error(e)}"),!1===n(Z,this).strict&&(h="with(".concat(r,"){").concat(h,"}")),h="".concat(o,".start();").concat(h,"return ").concat(o,".end();"),h+="\n//# sourceURL=".concat(e),s&&(h="".concat(s,"\n").concat(h));try{const t=[r,c,a,o,i],e=Function.apply(null,t.concat(h));return e.source="(function(".concat(t.join(","),"){\n").concat(h,"\n});"),e}catch(t){t.filename=e,t.source=h,q(0,t)}}}c(I,"exports",["configure","compile"]);var G=new WeakMap,H=new WeakMap,Q=new WeakMap;class tt{constructor(t){r(this,G,!0),r(this,H,void 0),r(this,Q,{}),F(this,this.constructor.exports),this.configure(t)}get(t){if(n(G,this))return n(Q,this)[t]}set(t,e){n(G,this)&&(n(Q,this)[t]=e)}exist(t){if(n(G,this))return n(Q,this).hasOwnProperty(t)}clear(){Object.keys(n(Q,this)).forEach(this.remove)}remove(t){delete n(Q,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){n(G,this)&&Object.assign(n(Q,this),t||{})}configure(t){i(G,this,t.cache),i(H,this,t.precompiled),"object"==typeof window&&this.load(window[n(H,this)])}}c(tt,"exports",["load","set","get","exist","clear","remove","resolve"]);const et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],st=" ",nt='"',rt="/",it="<",ot=">",ct=t=>{let[e,s]=t;if(null!=s)return[T(e),[nt,T(s),nt].join("")].join("=")},at=(t,e,s)=>{const n=[],r=-1===et.indexOf(t),i=Object.entries(null!=e?e:{}).map(ct).filter((t=>t)).join(st);return n.push([it,t,st,i,ot].join("")),s&&r&&n.push(Array.isArray(s)?s.join(""):s),r&&n.push([it,rt,t,ot].join("")),n.join("")},ht=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>q(0,t))),lt=()=>{let t=[],e=[];const s=t=>{e.push(t)};return s.start=()=>{e=[]},s.backup=()=>{t.push(e.concat()),e=[]},s.restore=()=>{const s=e.concat();return e=t.pop(),ht(s)},s.error=t=>(t=>Promise.reject(q(0,t)))(t),s.end=()=>ht(e),s},ut=Symbol("EjsContext.parentTemplate"),pt=(t,e)=>{const s=t.globals||[],{BLOCKS:n,MACRO:r,EXTEND:i,LAYOUT:o,BUFFER:c,SAFE:a,SCOPE:h,COMPONENT:l,ELEMENT:u}=t.vars;class p{constructor(t){this[ut]=null,this[n]={},this[r]={},Object.assign(this,A(t,[h,c,a,l,u]))}}return Object.defineProperties(p.prototype,{[c]:{value:lt()},[n]:{value:{},writable:!0},[r]:{value:{},writable:!0},[o]:{value:!1,writable:!0},[i]:{value:!1,writable:!0},[ut]:{value:null,writable:!0},setParentTemplate:{value(t){return this[ut]=t,this}},getParentTemplate:{value(){return this[ut]}},useEscapeValue:{value:()=>$},useComponent:{value(){return O(this[l])?this[l].bind(this):function(){q(2,"".concat(l," must be a function"))}}},useElement:{value(){return O(this[u])?this[u].bind(this):()=>{q(2,"".concat(u," must be a function"))}}},useBuffer:{value(){return this[c]}},getMacro:{value(){return this[r]}},getBlocks:{value(){return this[n]}},setExtend:{value(t){return this[i]=t,this}},getExtend:{value(){return this[i]}},setLayout:{value(t){return this[o]=t,this}},getLayout:{value(){return this[o]}},clone:{value(t){const e=[o,i,c];return!0===t&&e.push(n),A(this,e)}},extend:{value(t){this.setExtend(!0),this.setLayout(t)}},echo:{value(){return[].slice.call(arguments).forEach(this.useBuffer())}},fn:{value(t){const e=this.useBuffer(),s=this;return function(){if(O(t))return e.backup(),e(t.apply(s,arguments)),e.restore()}}},macro:{value(t,e){const s=this.getMacro(),n=this.fn(e),r=this;s[t]=function(){return r.echo(n.apply(void 0,arguments))}}},call:{value(t){const e=this.getMacro()[t],s=[].slice.call(arguments,1);if(O(e))return e.apply(e,s)}},block:{value(t,e){const s=this.getBlocks();if(s[t]=s[t]||[],s[t].push(this.fn(e)),this.getExtend())return;const n=this,r=Object.assign([],s[t]),i=function(){return r.shift()},o=function(){const t=i();return t?function(){n.echo(t(o()))}:function(){}};this.echo(i()(o()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const n=!1===s?{}:this.clone(!0),r=Object.assign(n,e||{}),i=this.render(t,r);this.echo(i)}},use:{value(t,e){this.echo(Promise.resolve(this.require(t)).then((t=>{const s=this.getMacro();B(t,((t,n)=>{s[[e,n].join(".")]=t}))})))}},get:{value(t,e){const s=N(this,t,!0),n=s.shift(),r=s.pop();return L(n,r)?n[r]:e}},set:{value(t,e){const s=N(this,t,!1),n=s.shift(),r=s.pop();return this.getParentTemplate()&&L(n,r)?n[r]:n[r]=e}},each:{value(t,e){E(t)&&(t=this.get(t,[])),B(t,e)},writable:!0},el:{value(t,e,s){s=O(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>at(t,e,s))))},writable:!0},ui:{value(){},writable:!0},require:{value(){},writable:!0},render:{value(){},writable:!0}}),Object.entries(e).forEach((t=>{let[e,n]=t;O(n)&&s.includes(e)&&(n=n.bind(p.prototype)),p.prototype[e]=n})),p};var ft=new WeakMap;class gt{constructor(t,e){r(this,ft,void 0),F(this,this.constructor.exports),this.configure(t,e)}create(t){return new(n(ft,this))(t)}helpers(t){Object.assign(n(ft,this).prototype,t)}configure(t,e){i(ft,this,pt(t,e))}}c(gt,"exports",["create","globals","helpers"]);var vt=new WeakMap,bt=new WeakMap,dt=new WeakMap,mt=new WeakMap,wt=new WeakMap,yt=new WeakMap,jt=new WeakSet;class Ot{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,jt),r(this,vt,void 0),r(this,bt,void 0),r(this,dt,void 0),r(this,mt,void 0),r(this,wt,{}),r(this,yt,{}),F(this,this.constructor.exports),i(yt,this,{}),i(wt,this,k({},t)),i(bt,this,new gt(n(wt,this),n(yt,this))),i(dt,this,new I(n(wt,this))),i(vt,this,new tt(n(wt,this))),i(mt,this,new z(n(wt,this),n(vt,this),n(dt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(k(n(wt,this),t),n(bt,this).configure(n(wt,this),n(yt,this)),n(dt,this).configure(n(wt,this)),n(vt,this).configure(n(wt,this)),n(mt,this).configure(n(wt,this))),n(wt,this)}createContext(t){return n(bt,this).create(t)}preload(t){return n(vt,this).load(t||{})}compile(t,e){return n(dt,this).compile(t,e)}helpers(t){n(bt,this).helpers(Object.assign(n(yt,this),t))}async render(t,s){const n=this.createContext(s);return e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),n).then(e(jt,this,Pt).call(this,t,n))}async require(t){const s=this.createContext({});return e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),s).then((()=>s.getMacro()))}}function Et(t){return t.split(".").pop()!==n(wt,this).extension&&(t=[t,n(wt,this).extension].join(".")),t}function xt(t,e){return n(mt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function kt(t,s,n){const r=this.createContext(s);return n&&r.setParentTemplate(n),e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),r).then(e(jt,this,Pt).call(this,t,r))}function Pt(t,s){return n=>s.getExtend()?(s.setExtend(!1),e(jt,this,kt).call(this,s.getLayout(),s,t)):n}c(Ot,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const{render:Mt,configure:St,create:Ct,helpers:Wt,createContext:Tt,compile:$t,preload:Nt}=new Ot({resolver:async(t,e,s)=>fetch(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,e)).then((t=>t.ok?t.text():s(1,"template ".concat(e," not found"))),(t=>s(0,t)))});t.compile=$t,t.configure=St,t.create=Ct,t.createContext=Tt,t.element=at,t.escapeValue=$,t.helpers=Wt,t.preload=Nt,t.render=Mt}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejsInstance={})}(this,(function(t){"use strict";function e(t,e,s){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:s;throw new TypeError("Private element is not present on this object")}function s(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function n(t,s){return t.get(e(t,s))}function r(t,e,n){s(t,e),e.set(t,n)}function i(t,s,n){return t.set(e(t,s),n),n}function o(t,e){s(t,e),e.add(t)}function c(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var n=s.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function a(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,n)}return s}const h="ejsPrecompiled",l=!0,u="views",p="ejs",f=!0,g=!0,v=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),b=[],d={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},m={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},w=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,j=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},y=t=>Array.isArray(t),O=t=>"function"==typeof t,E=t=>"string"==typeof t,x=t=>"boolean"==typeof t,k=(t,e)=>{return Object.assign(t,{path:j(E,u,t.path,e.path),precompiled:j(E,h,t.export,e.export),resolver:j(O,v,t.resolver,e.resolver),extension:j(E,p,t.extension,e.extension),strict:j(x,g,t.strict,e.strict),rmWhitespace:j(x,f,t.rmWhitespace,e.rmWhitespace),cache:j(x,l,t.cache,e.cache),globals:j(y,b,t.globals,(s=e.globals,!!y(s)&&s.filter((t=>{const e=w.test(t);return!1===e&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),e})))),token:Object.assign({},m,t.token,e.token),vars:Object.assign({},d,t.vars,e.vars)});var s},P={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},S=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),C=S(M),W=S(P),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(C,(t=>M[t]))},$=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?T(s):s},N=(t,e,s)=>{let n=t,r=String(e).split("."),i=r.pop();for(let t=0;t<r.length;t++){const e=r[t];if(O(n.toJSON)&&(n=n.toJSON()),s&&!1===n.hasOwnProperty(e)){n={};break}n=n[e]=n[e]||{}}return O(n.toJSON)&&(n=n.toJSON()),[n,i]},B=(t,e)=>{let s;for(s in t)L(t,s)&&e(t[s],s,t)},A=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?a(Object(s),!0).forEach((function(e){c(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):a(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}({},t);for(const t of e)delete s[t];return s},L=(t,e)=>t&&Object.hasOwn(t,e),R=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for(let s=0,n=e.length;s<n;s++){const n=e[s];n in t&&(t[n]=t[n].bind(t))}};class F extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const q=(t,e)=>{throw new F(t,e)};var U=new WeakMap,D=new WeakMap,V=new WeakMap,J=new WeakMap,_=new WeakSet;class z{constructor(t,e,s){o(this,_),r(this,U,void 0),r(this,D,void 0),r(this,V,void 0),r(this,J,void 0),R(this,this.constructor.exports),i(V,this,e),i(J,this,s),this.configure(null!=t?t:{})}configure(t){i(U,this,t.path),O(t.resolver)&&i(D,this,t.resolver)}get(t){const s=n(V,this).get(t);return s?Promise.resolve(s):e(_,this,K).call(this,t).then((s=>{const r=e(_,this,X).call(this,s,t);return n(V,this).set(t,r),r}))}}function K(t){return Promise.resolve(n(D,this).call(this,n(U,this),t,q))}function X(t,e){return"function"==typeof t?t:"string"==typeof t?n(J,this).compile(t,e):void 0}c(z,"exports",["configure","get"]);const Y=[["-",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,",1))\n").concat(e,"('")],["=",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,"))\n").concat(e,"('")],["#",(t,e)=>"')\n/**".concat(t,"**/\n").concat(e,"('")],["",(t,e)=>"')\n".concat(t,"\n").concat(e,"('")]];var Z=new WeakMap;class I{constructor(t){r(this,Z,{}),R(this,this.constructor.exports),this.configure(t)}configure(t){var e;n(Z,this).strict=t.strict,n(Z,this).rmWhitespace=t.rmWhitespace,n(Z,this).token=t.token,n(Z,this).vars=t.vars,n(Z,this).globals=t.globals,n(Z,this).legacy=null===(e=t.legacy)||void 0===e||e,n(Z,this).slurp={match:"[s\t\n]*",start:[n(Z,this).token.start,"_"],end:["_",n(Z,this).token.end]},n(Z,this).matches=[],n(Z,this).formats=[];for(const[t,e]of Y)n(Z,this).matches.push(n(Z,this).token.start.concat(t).concat(n(Z,this).token.regex).concat(n(Z,this).token.end)),n(Z,this).formats.push(e);n(Z,this).regex=new RegExp(n(Z,this).matches.join("|").concat("|$"),"g"),n(Z,this).slurpStart=new RegExp([n(Z,this).slurp.match,n(Z,this).slurp.start.join("")].join(""),"gm"),n(Z,this).slurpEnd=new RegExp([n(Z,this).slurp.end.join(""),n(Z,this).slurp.match].join(""),"gm"),n(Z,this).globals.length&&(n(Z,this).legacy?n(Z,this).globalVariables="const ".concat(n(Z,this).globals.map((t=>"".concat(t,"=").concat(n(Z,this).vars.SCOPE,".").concat(t))).join(","),";"):n(Z,this).globalVariables="const {".concat(n(Z,this).globals.join(","),"} = ").concat(n(Z,this).vars.SCOPE,";"))}compile(t,e){const s=n(Z,this).globalVariables,{SCOPE:r,SAFE:i,BUFFER:o,COMPONENT:c,ELEMENT:a}=n(Z,this).vars;n(Z,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(n(Z,this).slurpStart,n(Z,this).token.start).replace(n(Z,this).slurpEnd,n(Z,this).token.end);let h="".concat(o,"('");((t,e,s)=>{let n=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),r=t.shift();return s(t,n,e),n=e+r.length,r}))})(n(Z,this).regex,t,((e,s,r)=>{h+=(""+t.slice(s,r)).replace(W,(t=>"\\"+P[t])),e.forEach(((t,e)=>{t&&(h+=n(Z,this).formats[e](t.trim(),o,i))}))})),h+="');",h="try{".concat(h,"}catch(e){return ").concat(o,".error(e)}"),!1===n(Z,this).strict&&(h="with(".concat(r,"){").concat(h,"}")),h="".concat(o,".start();").concat(h,"return ").concat(o,".end();"),h+="\n//# sourceURL=".concat(e),s&&(h="".concat(s,"\n").concat(h));try{const t=[r,c,a,o,i],e=Function.apply(null,t.concat(h));return e.source="(function(".concat(t.join(","),"){\n").concat(h,"\n});"),e}catch(t){t.filename=e,t.source=h,q(0,t)}}}c(I,"exports",["configure","compile"]);var G=new WeakMap,H=new WeakMap,Q=new WeakMap;class tt{constructor(t){r(this,G,!0),r(this,H,void 0),r(this,Q,{}),R(this,this.constructor.exports),this.configure(t)}get(t){if(n(G,this))return n(Q,this)[t]}set(t,e){n(G,this)&&(n(Q,this)[t]=e)}exist(t){if(n(G,this))return n(Q,this).hasOwnProperty(t)}clear(){Object.keys(n(Q,this)).forEach(this.remove)}remove(t){delete n(Q,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){n(G,this)&&Object.assign(n(Q,this),t||{})}configure(t){i(G,this,t.cache),i(H,this,t.precompiled),"object"==typeof window&&this.load(window[n(H,this)])}}c(tt,"exports",["load","set","get","exist","clear","remove","resolve"]);const et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],st=" ",nt='"',rt="/",it="<",ot=">",ct=t=>{let[e,s]=t;if(null!=s)return[T(e),[nt,T(s),nt].join("")].join("=")},at=(t,e,s)=>{const n=[],r=-1===et.indexOf(t),i=Object.entries(null!=e?e:{}).map(ct).filter((t=>t)).join(st);return n.push([it,t,st,i,ot].join("")),s&&r&&n.push(Array.isArray(s)?s.join(""):s),r&&n.push([it,rt,t,ot].join("")),n.join("")},ht=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>q(0,t))),lt=()=>{let t=[],e=[];const s=t=>{e.push(t)};return s.start=()=>{e=[]},s.backup=()=>{t.push(e.concat()),e=[]},s.restore=()=>{const s=e.concat();return e=t.pop(),ht(s)},s.error=t=>(t=>Promise.reject(q(0,t)))(t),s.end=()=>ht(e),s},ut=Symbol("EjsContext.parentTemplate"),pt=(t,e)=>{const s=t.globals||[],{BLOCKS:n,MACRO:r,EXTEND:i,LAYOUT:o,BUFFER:c,SAFE:a,SCOPE:h,COMPONENT:l,ELEMENT:u}=t.vars;class p{constructor(t){this[ut]=null,this[n]={},this[r]={},Object.assign(this,A(t,[h,c,a,l,u]))}}return Object.defineProperties(p.prototype,{[c]:{value:lt()},[n]:{value:{},writable:!0},[r]:{value:{},writable:!0},[o]:{value:!1,writable:!0},[i]:{value:!1,writable:!0},[ut]:{value:null,writable:!0},setParentTemplate:{value(t){return this[ut]=t,this}},getParentTemplate:{value(){return this[ut]}},useEscapeValue:{value:()=>$},useComponent:{value(){return O(this[l])?this[l].bind(this):function(){q(2,"".concat(l," must be a function"))}}},useElement:{value(){return O(this[u])?this[u].bind(this):()=>{q(2,"".concat(u," must be a function"))}}},useBuffer:{value(){return this[c]}},getMacro:{value(){return this[r]}},getBlocks:{value(){return this[n]}},setExtend:{value(t){return this[i]=t,this}},getExtend:{value(){return this[i]}},setLayout:{value(t){return this[o]=t,this}},getLayout:{value(){return this[o]}},clone:{value(t){const e=[o,i,c];return!0===t&&e.push(n),A(this,e)}},extend:{value(t){this.setExtend(!0),this.setLayout(t)}},echo:{value(){return[].slice.call(arguments).forEach(this.useBuffer())}},fn:{value(t){const e=this.useBuffer(),s=this;return function(){if(O(t))return e.backup(),e(t.apply(s,arguments)),e.restore()}}},macro:{value(t,e){const s=this.getMacro(),n=this.fn(e),r=this;s[t]=function(){return r.echo(n.apply(void 0,arguments))}}},call:{value(t){const e=this.getMacro()[t],s=[].slice.call(arguments,1);if(O(e))return e.apply(e,s)}},block:{value(t,e){const s=this.getBlocks();if(s[t]=s[t]||[],s[t].push(this.fn(e)),this.getExtend())return;const n=this,r=Object.assign([],s[t]),i=function(){return r.shift()},o=function(){const t=i();return t?function(){n.echo(t(o()))}:function(){}};this.echo(i()(o()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const n=!1===s?{}:this.clone(!0),r=Object.assign(n,e||{}),i=this.render(t,r);this.echo(i)}},use:{value(t,e){this.echo(Promise.resolve(this.require(t)).then((t=>{const s=this.getMacro();B(t,((t,n)=>{s[[e,n].join(".")]=t}))})))}},get:{value(t,e){const s=N(this,t,!0),n=s.shift(),r=s.pop();return L(n,r)?n[r]:e}},set:{value(t,e){const s=N(this,t,!1),n=s.shift(),r=s.pop();return this.getParentTemplate()&&L(n,r)?n[r]:n[r]=e}},each:{value(t,e){E(t)&&(t=this.get(t,[])),B(t,e)},writable:!0},el:{value(t,e,s){s=O(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>at(t,e,s))))},writable:!0},ui:{value(){},writable:!0},require:{value(){},writable:!0},render:{value(){},writable:!0}}),Object.entries(e).forEach((t=>{let[e,n]=t;O(n)&&s.includes(e)&&(n=n.bind(p.prototype)),p.prototype[e]=n})),p};var ft=new WeakMap;class gt{constructor(t,e){r(this,ft,void 0),R(this,this.constructor.exports),this.configure(t,e)}create(t){return new(n(ft,this))(t)}helpers(t){Object.assign(n(ft,this).prototype,t)}configure(t,e){i(ft,this,pt(t,e))}}c(gt,"exports",["create","globals","helpers"]);var vt=new WeakMap,bt=new WeakMap,dt=new WeakMap,mt=new WeakMap,wt=new WeakMap,jt=new WeakMap,yt=new WeakSet;class Ot{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,yt),r(this,vt,void 0),r(this,bt,void 0),r(this,dt,void 0),r(this,mt,void 0),r(this,wt,{}),r(this,jt,{}),R(this,this.constructor.exports),i(jt,this,{}),i(wt,this,k({},t)),i(bt,this,new gt(n(wt,this),n(jt,this))),i(dt,this,new I(n(wt,this))),i(vt,this,new tt(n(wt,this))),i(mt,this,new z(n(wt,this),n(vt,this),n(dt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(k(n(wt,this),t),n(bt,this).configure(n(wt,this),n(jt,this)),n(dt,this).configure(n(wt,this)),n(vt,this).configure(n(wt,this)),n(mt,this).configure(n(wt,this))),n(wt,this)}createContext(t){return n(bt,this).create(t)}preload(t){return n(vt,this).load(t||{})}compile(t,e){return n(dt,this).compile(t,e)}helpers(t){n(bt,this).helpers(Object.assign(n(jt,this),t))}async render(t,s){const n=this.createContext(s);return e(yt,this,xt).call(this,e(yt,this,Et).call(this,t),n).then(e(yt,this,Pt).call(this,t,n))}async require(t){const s=this.createContext({});return e(yt,this,xt).call(this,e(yt,this,Et).call(this,t),s).then((()=>s.getMacro()))}}function Et(t){return t.split(".").pop()!==n(wt,this).extension&&(t=[t,n(wt,this).extension].join(".")),t}function xt(t,e){return n(mt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function kt(t,s,n){const r=this.createContext(s);return n&&r.setParentTemplate(n),e(yt,this,xt).call(this,e(yt,this,Et).call(this,t),r).then(e(yt,this,Pt).call(this,t,r))}function Pt(t,s){return n=>s.getExtend()?(s.setExtend(!1),e(yt,this,kt).call(this,s.getLayout(),s,t)):n}c(Ot,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const{render:Mt,configure:St,create:Ct,helpers:Wt,createContext:Tt,compile:$t,preload:Nt}=new Ot({resolver:async(t,e,s)=>{const n=new URL(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,e),location.origin);return fetch(n).then((t=>t.ok?t.text():s(1,"template ".concat(e," not found"))),(t=>s(0,t)))}});t.compile=$t,t.configure=St,t.create=Ct,t.createContext=Tt,t.element=at,t.escapeValue=$,t.helpers=Wt,t.preload=Nt,t.render=Mt}));
package/dist/umd/index.js CHANGED
@@ -256,28 +256,25 @@
256
256
  }
257
257
  }
258
258
  get(template) {
259
+ const callback = _classPrivateFieldGet2(_cache$2, this).get(template);
260
+ if (callback) return Promise.resolve(callback);
259
261
  return _assertClassBrand(_EjsTemplate_brand, this, _resolve).call(this, template).then(content => {
260
- return _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
262
+ const callback = _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
263
+ _classPrivateFieldGet2(_cache$2, this).set(template, callback);
264
+ return callback;
261
265
  });
262
266
  }
263
267
  }
264
268
  function _resolve(template) {
265
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
266
- if (cached instanceof Promise) return cached;
267
- const result = Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
268
- _classPrivateFieldGet2(_cache$2, this).set(template, result);
269
- return result;
269
+ return Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
270
270
  }
271
271
  function _compile(content, template) {
272
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
273
- if (typeof cached === 'function') return cached;
274
- if (typeof content === 'string') {
275
- content = _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
276
- }
277
272
  if (typeof content === 'function') {
278
- _classPrivateFieldGet2(_cache$2, this).set(template, content);
279
273
  return content;
280
274
  }
275
+ if (typeof content === 'string') {
276
+ return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
277
+ }
281
278
  }
282
279
  _defineProperty(EjsTemplate, "exports", ['configure', 'get']);
283
280
 
@@ -798,7 +795,7 @@
798
795
  class EjsInstance {
799
796
  /**
800
797
  *
801
- * @param {EjsConfig} options
798
+ * @param {Partial<EjsConfig>} options
802
799
  */
803
800
  constructor() {
804
801
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejsInstance={})}(this,(function(t){"use strict";var e={};function s(t,e,s){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:s;throw new TypeError("Private element is not present on this object")}function n(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function r(t,e){return t.get(s(t,e))}function i(t,e,s){n(t,e),e.set(t,s)}function o(t,e,n){return t.set(s(t,e),n),n}function c(t,e){n(t,e),e.add(t)}function a(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var n=s.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function h(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,n)}return s}const l=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,u=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},p=t=>Array.isArray(t),f=t=>"function"==typeof t,g=t=>"string"==typeof t,v=t=>"boolean"==typeof t,b={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},m=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),w=m(d),j=m(b),y=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(w,(t=>d[t]))},O=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?y(s):s},E=(t,e,s)=>{let n=t,r=String(e).split("."),i=r.pop();for(let t=0;t<r.length;t++){const e=r[t];if(f(n.toJSON)&&(n=n.toJSON()),s&&!1===n.hasOwnProperty(e)){n={};break}n=n[e]=n[e]||{}}return f(n.toJSON)&&(n=n.toJSON()),[n,i]},x=(t,e)=>{let s;for(s in t)P(t,s)&&e(t[s],s,t)},k=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?h(Object(s),!0).forEach((function(e){a(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):h(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}({},t);for(const t of e)delete s[t];return s},P=(t,e)=>t&&Object.hasOwn(t,e),M=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for(let s=0,n=e.length;s<n;s++){const n=e[s];n in t&&(t[n]=t[n].bind(t))}},S="ejsPrecompiled",C=!0,W="views",T="ejs",N=!0,$=!0,B=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),A=[],L={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},F={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},R=(t,e)=>{return Object.assign(t,{path:u(g,W,t.path,e.path),precompiled:u(g,S,t.export,e.export),resolver:u(f,B,t.resolver,e.resolver),extension:u(g,T,t.extension,e.extension),strict:u(v,$,t.strict,e.strict),rmWhitespace:u(v,N,t.rmWhitespace,e.rmWhitespace),cache:u(v,C,t.cache,e.cache),globals:u(p,A,t.globals,(s=e.globals,!!p(s)&&s.filter((t=>{const e=l.test(t);return!1===e&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),e})))),token:Object.assign({},F,t.token,e.token),vars:Object.assign({},L,t.vars,e.vars)});var s};class q extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const D=(t,e)=>{throw new q(t,e)};var U=new WeakMap,V=new WeakMap,_=new WeakMap,J=new WeakMap,z=new WeakSet;class K{constructor(t,e,s){c(this,z),i(this,U,void 0),i(this,V,void 0),i(this,_,void 0),i(this,J,void 0),M(this,this.constructor.exports),o(_,this,e),o(J,this,s),this.configure(null!=t?t:{})}configure(t){o(U,this,t.path),f(t.resolver)&&o(V,this,t.resolver)}get(t){return s(z,this,X).call(this,t).then((e=>s(z,this,Y).call(this,e,t)))}}function X(t){const e=r(_,this).get(t);if(e instanceof Promise)return e;const s=Promise.resolve(r(V,this).call(this,r(U,this),t,D));return r(_,this).set(t,s),s}function Y(t,e){const s=r(_,this).get(e);return"function"==typeof s?s:("string"==typeof t&&(t=r(J,this).compile(t,e)),"function"==typeof t?(r(_,this).set(e,t),t):void 0)}a(K,"exports",["configure","get"]);const Z=[["-",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,",1))\n").concat(e,"('")],["=",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,"))\n").concat(e,"('")],["#",(t,e)=>"')\n/**".concat(t,"**/\n").concat(e,"('")],["",(t,e)=>"')\n".concat(t,"\n").concat(e,"('")]];var I=new WeakMap;class G{constructor(t){i(this,I,{}),M(this,this.constructor.exports),this.configure(t)}configure(t){var e;r(I,this).strict=t.strict,r(I,this).rmWhitespace=t.rmWhitespace,r(I,this).token=t.token,r(I,this).vars=t.vars,r(I,this).globals=t.globals,r(I,this).legacy=null===(e=t.legacy)||void 0===e||e,r(I,this).slurp={match:"[s\t\n]*",start:[r(I,this).token.start,"_"],end:["_",r(I,this).token.end]},r(I,this).matches=[],r(I,this).formats=[];for(const[t,e]of Z)r(I,this).matches.push(r(I,this).token.start.concat(t).concat(r(I,this).token.regex).concat(r(I,this).token.end)),r(I,this).formats.push(e);r(I,this).regex=new RegExp(r(I,this).matches.join("|").concat("|$"),"g"),r(I,this).slurpStart=new RegExp([r(I,this).slurp.match,r(I,this).slurp.start.join("")].join(""),"gm"),r(I,this).slurpEnd=new RegExp([r(I,this).slurp.end.join(""),r(I,this).slurp.match].join(""),"gm"),r(I,this).globals.length&&(r(I,this).legacy?r(I,this).globalVariables="const ".concat(r(I,this).globals.map((t=>"".concat(t,"=").concat(r(I,this).vars.SCOPE,".").concat(t))).join(","),";"):r(I,this).globalVariables="const {".concat(r(I,this).globals.join(","),"} = ").concat(r(I,this).vars.SCOPE,";"))}compile(t,e){const s=r(I,this).globalVariables,{SCOPE:n,SAFE:i,BUFFER:o,COMPONENT:c,ELEMENT:a}=r(I,this).vars;r(I,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(r(I,this).slurpStart,r(I,this).token.start).replace(r(I,this).slurpEnd,r(I,this).token.end);let h="".concat(o,"('");((t,e,s)=>{let n=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),r=t.shift();return s(t,n,e),n=e+r.length,r}))})(r(I,this).regex,t,((e,s,n)=>{h+=(""+t.slice(s,n)).replace(j,(t=>"\\"+b[t])),e.forEach(((t,e)=>{t&&(h+=r(I,this).formats[e](t.trim(),o,i))}))})),h+="');",h="try{".concat(h,"}catch(e){return ").concat(o,".error(e)}"),!1===r(I,this).strict&&(h="with(".concat(n,"){").concat(h,"}")),h="".concat(o,".start();").concat(h,"return ").concat(o,".end();"),h+="\n//# sourceURL=".concat(e),s&&(h="".concat(s,"\n").concat(h));try{const t=[n,c,a,o,i],e=Function.apply(null,t.concat(h));return e.source="(function(".concat(t.join(","),"){\n").concat(h,"\n});"),e}catch(t){t.filename=e,t.source=h,D(0,t)}}}a(G,"exports",["configure","compile"]);var H=new WeakMap,Q=new WeakMap,tt=new WeakMap;class et{constructor(t){i(this,H,!0),i(this,Q,void 0),i(this,tt,{}),M(this,this.constructor.exports),this.configure(t)}get(t){if(r(H,this))return r(tt,this)[t]}set(t,e){r(H,this)&&(r(tt,this)[t]=e)}exist(t){if(r(H,this))return r(tt,this).hasOwnProperty(t)}clear(){Object.keys(r(tt,this)).forEach(this.remove)}remove(t){delete r(tt,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){r(H,this)&&Object.assign(r(tt,this),t||{})}configure(t){o(H,this,t.cache),o(Q,this,t.precompiled),"object"==typeof window&&this.load(window[r(Q,this)])}}a(et,"exports",["load","set","get","exist","clear","remove","resolve"]);const st=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],nt=" ",rt='"',it="/",ot="<",ct=">",at=t=>{let[e,s]=t;if(null!=s)return[y(e),[rt,y(s),rt].join("")].join("=")},ht=(t,e,s)=>{const n=[],r=-1===st.indexOf(t),i=Object.entries(null!=e?e:{}).map(at).filter((t=>t)).join(nt);return n.push([ot,t,nt,i,ct].join("")),s&&r&&n.push(Array.isArray(s)?s.join(""):s),r&&n.push([ot,it,t,ct].join("")),n.join("")},lt=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>D(0,t))),ut=()=>{let t=[],e=[];const s=t=>{e.push(t)};return s.start=()=>{e=[]},s.backup=()=>{t.push(e.concat()),e=[]},s.restore=()=>{const s=e.concat();return e=t.pop(),lt(s)},s.error=t=>(t=>Promise.reject(D(0,t)))(t),s.end=()=>lt(e),s},pt=Symbol("EjsContext.parentTemplate"),ft=(t,e)=>{const s=t.globals||[],{BLOCKS:n,MACRO:r,EXTEND:i,LAYOUT:o,BUFFER:c,SAFE:a,SCOPE:h,COMPONENT:l,ELEMENT:u}=t.vars;class p{constructor(t){this[pt]=null,this[n]={},this[r]={},Object.assign(this,k(t,[h,c,a,l,u]))}}return Object.defineProperties(p.prototype,{[c]:{value:ut()},[n]:{value:{},writable:!0},[r]:{value:{},writable:!0},[o]:{value:!1,writable:!0},[i]:{value:!1,writable:!0},[pt]:{value:null,writable:!0},setParentTemplate:{value(t){return this[pt]=t,this}},getParentTemplate:{value(){return this[pt]}},useEscapeValue:{value:()=>O},useComponent:{value(){return f(this[l])?this[l].bind(this):function(){D(2,"".concat(l," must be a function"))}}},useElement:{value(){return f(this[u])?this[u].bind(this):()=>{D(2,"".concat(u," must be a function"))}}},useBuffer:{value(){return this[c]}},getMacro:{value(){return this[r]}},getBlocks:{value(){return this[n]}},setExtend:{value(t){return this[i]=t,this}},getExtend:{value(){return this[i]}},setLayout:{value(t){return this[o]=t,this}},getLayout:{value(){return this[o]}},clone:{value(t){const e=[o,i,c];return!0===t&&e.push(n),k(this,e)}},extend:{value(t){this.setExtend(!0),this.setLayout(t)}},echo:{value(){return[].slice.call(arguments).forEach(this.useBuffer())}},fn:{value(t){const e=this.useBuffer(),s=this;return function(){if(f(t))return e.backup(),e(t.apply(s,arguments)),e.restore()}}},macro:{value(t,e){const s=this.getMacro(),n=this.fn(e),r=this;s[t]=function(){return r.echo(n.apply(void 0,arguments))}}},call:{value(t){const e=this.getMacro()[t],s=[].slice.call(arguments,1);if(f(e))return e.apply(e,s)}},block:{value(t,e){const s=this.getBlocks();if(s[t]=s[t]||[],s[t].push(this.fn(e)),this.getExtend())return;const n=this,r=Object.assign([],s[t]),i=function(){return r.shift()},o=function(){const t=i();return t?function(){n.echo(t(o()))}:function(){}};this.echo(i()(o()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const n=!1===s?{}:this.clone(!0),r=Object.assign(n,e||{}),i=this.render(t,r);this.echo(i)}},use:{value(t,e){this.echo(Promise.resolve(this.require(t)).then((t=>{const s=this.getMacro();x(t,((t,n)=>{s[[e,n].join(".")]=t}))})))}},get:{value(t,e){const s=E(this,t,!0),n=s.shift(),r=s.pop();return P(n,r)?n[r]:e}},set:{value(t,e){const s=E(this,t,!1),n=s.shift(),r=s.pop();return this.getParentTemplate()&&P(n,r)?n[r]:n[r]=e}},each:{value(t,e){g(t)&&(t=this.get(t,[])),x(t,e)},writable:!0},el:{value(t,e,s){s=f(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>ht(t,e,s))))},writable:!0},ui:{value(){},writable:!0},require:{value(){},writable:!0},render:{value(){},writable:!0}}),Object.entries(e).forEach((t=>{let[e,n]=t;f(n)&&s.includes(e)&&(n=n.bind(p.prototype)),p.prototype[e]=n})),p};var gt=new WeakMap;class vt{constructor(t,e){i(this,gt,void 0),M(this,this.constructor.exports),this.configure(t,e)}create(t){return new(r(gt,this))(t)}helpers(t){Object.assign(r(gt,this).prototype,t)}configure(t,e){o(gt,this,ft(t,e))}}a(vt,"exports",["create","globals","helpers"]);var bt=new WeakMap,dt=new WeakMap,mt=new WeakMap,wt=new WeakMap,jt=new WeakMap,yt=new WeakMap,Ot=new WeakSet;class Et{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,Ot),i(this,bt,void 0),i(this,dt,void 0),i(this,mt,void 0),i(this,wt,void 0),i(this,jt,{}),i(this,yt,{}),M(this,this.constructor.exports),o(yt,this,{}),o(jt,this,R({},t)),o(dt,this,new vt(r(jt,this),r(yt,this))),o(mt,this,new G(r(jt,this))),o(bt,this,new et(r(jt,this))),o(wt,this,new K(r(jt,this),r(bt,this),r(mt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(R(r(jt,this),t),r(dt,this).configure(r(jt,this),r(yt,this)),r(mt,this).configure(r(jt,this)),r(bt,this).configure(r(jt,this)),r(wt,this).configure(r(jt,this))),r(jt,this)}createContext(t){return r(dt,this).create(t)}preload(t){return r(bt,this).load(t||{})}compile(t,e){return r(mt,this).compile(t,e)}helpers(t){r(dt,this).helpers(Object.assign(r(yt,this),t))}async render(t,e){const n=this.createContext(e);return s(Ot,this,kt).call(this,s(Ot,this,xt).call(this,t),n).then(s(Ot,this,Mt).call(this,t,n))}async require(t){const e=this.createContext({});return s(Ot,this,kt).call(this,s(Ot,this,xt).call(this,t),e).then((()=>e.getMacro()))}}function xt(t){return t.split(".").pop()!==r(jt,this).extension&&(t=[t,r(jt,this).extension].join(".")),t}function kt(t,e){return r(wt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function Pt(t,e,n){const r=this.createContext(e);return n&&r.setParentTemplate(n),s(Ot,this,kt).call(this,s(Ot,this,xt).call(this,t),r).then(s(Ot,this,Mt).call(this,t,r))}function Mt(t,e){return n=>e.getExtend()?(e.setExtend(!1),s(Ot,this,Pt).call(this,e.getLayout(),e,t)):n}a(Et,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const{render:St,helpers:Ct,configure:Wt,create:Tt,createContext:Nt,compile:$t,preload:Bt}=new Et({resolver:async(t,s,n)=>e.readFile(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,s)).then((t=>t.toString())).catch((t=>"ENOENT"===t.code?n(1,"template ".concat(s," not found")):n(0,t)))});t.__express=function(t,s,n){f(s)&&(n=s,s={}),s=s||{};const r=Object.assign({},s.settings),i=u(g,W,r.views),o=u(v,C,r["view cache"]),c=Object.assign({},r["view options"]),a=e.relative(i,t);return c.path=i,c.cache=o,Wt(c),St(a,s).then((t=>{n(null,t)})).catch((t=>{n(t)}))},t.compile=$t,t.configure=Wt,t.create=Tt,t.createContext=Nt,t.element=ht,t.escapeValue=O,t.helpers=Ct,t.preload=Bt,t.render=St}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejsInstance={})}(this,(function(t){"use strict";var e={};function s(t,e,s){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:s;throw new TypeError("Private element is not present on this object")}function n(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function r(t,e){return t.get(s(t,e))}function i(t,e,s){n(t,e),e.set(t,s)}function o(t,e,n){return t.set(s(t,e),n),n}function c(t,e){n(t,e),e.add(t)}function a(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var n=s.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function h(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,n)}return s}const l=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,u=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},p=t=>Array.isArray(t),f=t=>"function"==typeof t,g=t=>"string"==typeof t,v=t=>"boolean"==typeof t,b={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},m=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),w=m(d),j=m(b),y=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(w,(t=>d[t]))},O=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?y(s):s},E=(t,e,s)=>{let n=t,r=String(e).split("."),i=r.pop();for(let t=0;t<r.length;t++){const e=r[t];if(f(n.toJSON)&&(n=n.toJSON()),s&&!1===n.hasOwnProperty(e)){n={};break}n=n[e]=n[e]||{}}return f(n.toJSON)&&(n=n.toJSON()),[n,i]},x=(t,e)=>{let s;for(s in t)P(t,s)&&e(t[s],s,t)},k=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?h(Object(s),!0).forEach((function(e){a(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):h(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}({},t);for(const t of e)delete s[t];return s},P=(t,e)=>t&&Object.hasOwn(t,e),M=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for(let s=0,n=e.length;s<n;s++){const n=e[s];n in t&&(t[n]=t[n].bind(t))}},S="ejsPrecompiled",C=!0,W="views",T="ejs",N=!0,$=!0,B=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),A=[],L={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},F={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},R=(t,e)=>{return Object.assign(t,{path:u(g,W,t.path,e.path),precompiled:u(g,S,t.export,e.export),resolver:u(f,B,t.resolver,e.resolver),extension:u(g,T,t.extension,e.extension),strict:u(v,$,t.strict,e.strict),rmWhitespace:u(v,N,t.rmWhitespace,e.rmWhitespace),cache:u(v,C,t.cache,e.cache),globals:u(p,A,t.globals,(s=e.globals,!!p(s)&&s.filter((t=>{const e=l.test(t);return!1===e&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),e})))),token:Object.assign({},F,t.token,e.token),vars:Object.assign({},L,t.vars,e.vars)});var s};class q extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const D=(t,e)=>{throw new q(t,e)};var U=new WeakMap,V=new WeakMap,_=new WeakMap,J=new WeakMap,z=new WeakSet;class K{constructor(t,e,s){c(this,z),i(this,U,void 0),i(this,V,void 0),i(this,_,void 0),i(this,J,void 0),M(this,this.constructor.exports),o(_,this,e),o(J,this,s),this.configure(null!=t?t:{})}configure(t){o(U,this,t.path),f(t.resolver)&&o(V,this,t.resolver)}get(t){const e=r(_,this).get(t);return e?Promise.resolve(e):s(z,this,X).call(this,t).then((e=>{const n=s(z,this,Y).call(this,e,t);return r(_,this).set(t,n),n}))}}function X(t){return Promise.resolve(r(V,this).call(this,r(U,this),t,D))}function Y(t,e){return"function"==typeof t?t:"string"==typeof t?r(J,this).compile(t,e):void 0}a(K,"exports",["configure","get"]);const Z=[["-",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,",1))\n").concat(e,"('")],["=",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,"))\n").concat(e,"('")],["#",(t,e)=>"')\n/**".concat(t,"**/\n").concat(e,"('")],["",(t,e)=>"')\n".concat(t,"\n").concat(e,"('")]];var I=new WeakMap;class G{constructor(t){i(this,I,{}),M(this,this.constructor.exports),this.configure(t)}configure(t){var e;r(I,this).strict=t.strict,r(I,this).rmWhitespace=t.rmWhitespace,r(I,this).token=t.token,r(I,this).vars=t.vars,r(I,this).globals=t.globals,r(I,this).legacy=null===(e=t.legacy)||void 0===e||e,r(I,this).slurp={match:"[s\t\n]*",start:[r(I,this).token.start,"_"],end:["_",r(I,this).token.end]},r(I,this).matches=[],r(I,this).formats=[];for(const[t,e]of Z)r(I,this).matches.push(r(I,this).token.start.concat(t).concat(r(I,this).token.regex).concat(r(I,this).token.end)),r(I,this).formats.push(e);r(I,this).regex=new RegExp(r(I,this).matches.join("|").concat("|$"),"g"),r(I,this).slurpStart=new RegExp([r(I,this).slurp.match,r(I,this).slurp.start.join("")].join(""),"gm"),r(I,this).slurpEnd=new RegExp([r(I,this).slurp.end.join(""),r(I,this).slurp.match].join(""),"gm"),r(I,this).globals.length&&(r(I,this).legacy?r(I,this).globalVariables="const ".concat(r(I,this).globals.map((t=>"".concat(t,"=").concat(r(I,this).vars.SCOPE,".").concat(t))).join(","),";"):r(I,this).globalVariables="const {".concat(r(I,this).globals.join(","),"} = ").concat(r(I,this).vars.SCOPE,";"))}compile(t,e){const s=r(I,this).globalVariables,{SCOPE:n,SAFE:i,BUFFER:o,COMPONENT:c,ELEMENT:a}=r(I,this).vars;r(I,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(r(I,this).slurpStart,r(I,this).token.start).replace(r(I,this).slurpEnd,r(I,this).token.end);let h="".concat(o,"('");((t,e,s)=>{let n=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),r=t.shift();return s(t,n,e),n=e+r.length,r}))})(r(I,this).regex,t,((e,s,n)=>{h+=(""+t.slice(s,n)).replace(j,(t=>"\\"+b[t])),e.forEach(((t,e)=>{t&&(h+=r(I,this).formats[e](t.trim(),o,i))}))})),h+="');",h="try{".concat(h,"}catch(e){return ").concat(o,".error(e)}"),!1===r(I,this).strict&&(h="with(".concat(n,"){").concat(h,"}")),h="".concat(o,".start();").concat(h,"return ").concat(o,".end();"),h+="\n//# sourceURL=".concat(e),s&&(h="".concat(s,"\n").concat(h));try{const t=[n,c,a,o,i],e=Function.apply(null,t.concat(h));return e.source="(function(".concat(t.join(","),"){\n").concat(h,"\n});"),e}catch(t){t.filename=e,t.source=h,D(0,t)}}}a(G,"exports",["configure","compile"]);var H=new WeakMap,Q=new WeakMap,tt=new WeakMap;class et{constructor(t){i(this,H,!0),i(this,Q,void 0),i(this,tt,{}),M(this,this.constructor.exports),this.configure(t)}get(t){if(r(H,this))return r(tt,this)[t]}set(t,e){r(H,this)&&(r(tt,this)[t]=e)}exist(t){if(r(H,this))return r(tt,this).hasOwnProperty(t)}clear(){Object.keys(r(tt,this)).forEach(this.remove)}remove(t){delete r(tt,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){r(H,this)&&Object.assign(r(tt,this),t||{})}configure(t){o(H,this,t.cache),o(Q,this,t.precompiled),"object"==typeof window&&this.load(window[r(Q,this)])}}a(et,"exports",["load","set","get","exist","clear","remove","resolve"]);const st=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],nt=" ",rt='"',it="/",ot="<",ct=">",at=t=>{let[e,s]=t;if(null!=s)return[y(e),[rt,y(s),rt].join("")].join("=")},ht=(t,e,s)=>{const n=[],r=-1===st.indexOf(t),i=Object.entries(null!=e?e:{}).map(at).filter((t=>t)).join(nt);return n.push([ot,t,nt,i,ct].join("")),s&&r&&n.push(Array.isArray(s)?s.join(""):s),r&&n.push([ot,it,t,ct].join("")),n.join("")},lt=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>D(0,t))),ut=()=>{let t=[],e=[];const s=t=>{e.push(t)};return s.start=()=>{e=[]},s.backup=()=>{t.push(e.concat()),e=[]},s.restore=()=>{const s=e.concat();return e=t.pop(),lt(s)},s.error=t=>(t=>Promise.reject(D(0,t)))(t),s.end=()=>lt(e),s},pt=Symbol("EjsContext.parentTemplate"),ft=(t,e)=>{const s=t.globals||[],{BLOCKS:n,MACRO:r,EXTEND:i,LAYOUT:o,BUFFER:c,SAFE:a,SCOPE:h,COMPONENT:l,ELEMENT:u}=t.vars;class p{constructor(t){this[pt]=null,this[n]={},this[r]={},Object.assign(this,k(t,[h,c,a,l,u]))}}return Object.defineProperties(p.prototype,{[c]:{value:ut()},[n]:{value:{},writable:!0},[r]:{value:{},writable:!0},[o]:{value:!1,writable:!0},[i]:{value:!1,writable:!0},[pt]:{value:null,writable:!0},setParentTemplate:{value(t){return this[pt]=t,this}},getParentTemplate:{value(){return this[pt]}},useEscapeValue:{value:()=>O},useComponent:{value(){return f(this[l])?this[l].bind(this):function(){D(2,"".concat(l," must be a function"))}}},useElement:{value(){return f(this[u])?this[u].bind(this):()=>{D(2,"".concat(u," must be a function"))}}},useBuffer:{value(){return this[c]}},getMacro:{value(){return this[r]}},getBlocks:{value(){return this[n]}},setExtend:{value(t){return this[i]=t,this}},getExtend:{value(){return this[i]}},setLayout:{value(t){return this[o]=t,this}},getLayout:{value(){return this[o]}},clone:{value(t){const e=[o,i,c];return!0===t&&e.push(n),k(this,e)}},extend:{value(t){this.setExtend(!0),this.setLayout(t)}},echo:{value(){return[].slice.call(arguments).forEach(this.useBuffer())}},fn:{value(t){const e=this.useBuffer(),s=this;return function(){if(f(t))return e.backup(),e(t.apply(s,arguments)),e.restore()}}},macro:{value(t,e){const s=this.getMacro(),n=this.fn(e),r=this;s[t]=function(){return r.echo(n.apply(void 0,arguments))}}},call:{value(t){const e=this.getMacro()[t],s=[].slice.call(arguments,1);if(f(e))return e.apply(e,s)}},block:{value(t,e){const s=this.getBlocks();if(s[t]=s[t]||[],s[t].push(this.fn(e)),this.getExtend())return;const n=this,r=Object.assign([],s[t]),i=function(){return r.shift()},o=function(){const t=i();return t?function(){n.echo(t(o()))}:function(){}};this.echo(i()(o()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const n=!1===s?{}:this.clone(!0),r=Object.assign(n,e||{}),i=this.render(t,r);this.echo(i)}},use:{value(t,e){this.echo(Promise.resolve(this.require(t)).then((t=>{const s=this.getMacro();x(t,((t,n)=>{s[[e,n].join(".")]=t}))})))}},get:{value(t,e){const s=E(this,t,!0),n=s.shift(),r=s.pop();return P(n,r)?n[r]:e}},set:{value(t,e){const s=E(this,t,!1),n=s.shift(),r=s.pop();return this.getParentTemplate()&&P(n,r)?n[r]:n[r]=e}},each:{value(t,e){g(t)&&(t=this.get(t,[])),x(t,e)},writable:!0},el:{value(t,e,s){s=f(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>ht(t,e,s))))},writable:!0},ui:{value(){},writable:!0},require:{value(){},writable:!0},render:{value(){},writable:!0}}),Object.entries(e).forEach((t=>{let[e,n]=t;f(n)&&s.includes(e)&&(n=n.bind(p.prototype)),p.prototype[e]=n})),p};var gt=new WeakMap;class vt{constructor(t,e){i(this,gt,void 0),M(this,this.constructor.exports),this.configure(t,e)}create(t){return new(r(gt,this))(t)}helpers(t){Object.assign(r(gt,this).prototype,t)}configure(t,e){o(gt,this,ft(t,e))}}a(vt,"exports",["create","globals","helpers"]);var bt=new WeakMap,dt=new WeakMap,mt=new WeakMap,wt=new WeakMap,jt=new WeakMap,yt=new WeakMap,Ot=new WeakSet;class Et{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,Ot),i(this,bt,void 0),i(this,dt,void 0),i(this,mt,void 0),i(this,wt,void 0),i(this,jt,{}),i(this,yt,{}),M(this,this.constructor.exports),o(yt,this,{}),o(jt,this,R({},t)),o(dt,this,new vt(r(jt,this),r(yt,this))),o(mt,this,new G(r(jt,this))),o(bt,this,new et(r(jt,this))),o(wt,this,new K(r(jt,this),r(bt,this),r(mt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(R(r(jt,this),t),r(dt,this).configure(r(jt,this),r(yt,this)),r(mt,this).configure(r(jt,this)),r(bt,this).configure(r(jt,this)),r(wt,this).configure(r(jt,this))),r(jt,this)}createContext(t){return r(dt,this).create(t)}preload(t){return r(bt,this).load(t||{})}compile(t,e){return r(mt,this).compile(t,e)}helpers(t){r(dt,this).helpers(Object.assign(r(yt,this),t))}async render(t,e){const n=this.createContext(e);return s(Ot,this,kt).call(this,s(Ot,this,xt).call(this,t),n).then(s(Ot,this,Mt).call(this,t,n))}async require(t){const e=this.createContext({});return s(Ot,this,kt).call(this,s(Ot,this,xt).call(this,t),e).then((()=>e.getMacro()))}}function xt(t){return t.split(".").pop()!==r(jt,this).extension&&(t=[t,r(jt,this).extension].join(".")),t}function kt(t,e){return r(wt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function Pt(t,e,n){const r=this.createContext(e);return n&&r.setParentTemplate(n),s(Ot,this,kt).call(this,s(Ot,this,xt).call(this,t),r).then(s(Ot,this,Mt).call(this,t,r))}function Mt(t,e){return n=>e.getExtend()?(e.setExtend(!1),s(Ot,this,Pt).call(this,e.getLayout(),e,t)):n}a(Et,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const{render:St,helpers:Ct,configure:Wt,create:Tt,createContext:Nt,compile:$t,preload:Bt}=new Et({resolver:async(t,s,n)=>e.readFile(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,s)).then((t=>t.toString())).catch((t=>"ENOENT"===t.code?n(1,"template ".concat(s," not found")):n(0,t)))});t.__express=function(t,s,n){f(s)&&(n=s,s={}),s=s||{};const r=Object.assign({},s.settings),i=u(g,W,r.views),o=u(v,C,r["view cache"]),c=Object.assign({},r["view options"]),a=e.relative(i,t);return c.path=i,c.cache=o,Wt(c),St(a,s).then((t=>{n(null,t)})).catch((t=>{n(t)}))},t.compile=$t,t.configure=Wt,t.create=Tt,t.createContext=Nt,t.element=ht,t.escapeValue=O,t.helpers=Ct,t.preload=Bt,t.render=St}));
@@ -249,28 +249,25 @@
249
249
  }
250
250
  }
251
251
  get(template) {
252
+ const callback = _classPrivateFieldGet2(_cache$2, this).get(template);
253
+ if (callback) return Promise.resolve(callback);
252
254
  return _assertClassBrand(_EjsTemplate_brand, this, _resolve).call(this, template).then(content => {
253
- return _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
255
+ const callback = _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
256
+ _classPrivateFieldGet2(_cache$2, this).set(template, callback);
257
+ return callback;
254
258
  });
255
259
  }
256
260
  }
257
261
  function _resolve(template) {
258
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
259
- if (cached instanceof Promise) return cached;
260
- const result = Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
261
- _classPrivateFieldGet2(_cache$2, this).set(template, result);
262
- return result;
262
+ return Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
263
263
  }
264
264
  function _compile(content, template) {
265
- const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
266
- if (typeof cached === 'function') return cached;
267
- if (typeof content === 'string') {
268
- content = _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
269
- }
270
265
  if (typeof content === 'function') {
271
- _classPrivateFieldGet2(_cache$2, this).set(template, content);
272
266
  return content;
273
267
  }
268
+ if (typeof content === 'string') {
269
+ return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
270
+ }
274
271
  }
275
272
  _defineProperty(EjsTemplate, "exports", ['configure', 'get']);
276
273
 
@@ -791,7 +788,7 @@
791
788
  class EjsInstance {
792
789
  /**
793
790
  *
794
- * @param {EjsConfig} options
791
+ * @param {Partial<EjsConfig>} options
795
792
  */
796
793
  constructor() {
797
794
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejsInstance={})}(this,(function(t){"use strict";const e=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,s=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},n=t=>Array.isArray(t),r=t=>"function"==typeof t,i=t=>"string"==typeof t,o=t=>"boolean"==typeof t;function c(t,e,s){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:s;throw new TypeError("Private element is not present on this object")}function a(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function h(t,e){return t.get(c(t,e))}function l(t,e,s){a(t,e),e.set(t,s)}function u(t,e,s){return t.set(c(t,e),s),s}function p(t,e){a(t,e),e.add(t)}function f(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var n=s.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function g(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,n)}return s}const v="ejsPrecompiled",d=!0,b="views",m="ejs",y=!0,w=!0,j=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),O=[],E={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},x={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},k=(t,c)=>{return Object.assign(t,{path:s(i,b,t.path,c.path),precompiled:s(i,v,t.export,c.export),resolver:s(r,j,t.resolver,c.resolver),extension:s(i,m,t.extension,c.extension),strict:s(o,w,t.strict,c.strict),rmWhitespace:s(o,y,t.rmWhitespace,c.rmWhitespace),cache:s(o,d,t.cache,c.cache),globals:s(n,O,t.globals,(a=c.globals,!!n(a)&&a.filter((t=>{const s=e.test(t);return!1===s&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),s})))),token:Object.assign({},x,t.token,c.token),vars:Object.assign({},E,t.vars,c.vars)});var a},P={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},S=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),C=S(M),W=S(P),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(C,(t=>M[t]))},$=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?T(s):s},N=(t,e,s)=>{let n=t,i=String(e).split("."),o=i.pop();for(let t=0;t<i.length;t++){const e=i[t];if(r(n.toJSON)&&(n=n.toJSON()),s&&!1===n.hasOwnProperty(e)){n={};break}n=n[e]=n[e]||{}}return r(n.toJSON)&&(n=n.toJSON()),[n,o]},B=(t,e)=>{let s;for(s in t)A(t,s)&&e(t[s],s,t)},q=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?g(Object(s),!0).forEach((function(e){f(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):g(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}({},t);for(const t of e)delete s[t];return s},A=(t,e)=>t&&Object.hasOwn(t,e),L=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for(let s=0,n=e.length;s<n;s++){const n=e[s];n in t&&(t[n]=t[n].bind(t))}};class R extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const F=(t,e)=>{throw new R(t,e)};var U=new WeakMap,D=new WeakMap,V=new WeakMap,J=new WeakMap,_=new WeakSet;class z{constructor(t,e,s){p(this,_),l(this,U,void 0),l(this,D,void 0),l(this,V,void 0),l(this,J,void 0),L(this,this.constructor.exports),u(V,this,e),u(J,this,s),this.configure(null!=t?t:{})}configure(t){u(U,this,t.path),r(t.resolver)&&u(D,this,t.resolver)}get(t){return c(_,this,K).call(this,t).then((e=>c(_,this,X).call(this,e,t)))}}function K(t){const e=h(V,this).get(t);if(e instanceof Promise)return e;const s=Promise.resolve(h(D,this).call(this,h(U,this),t,F));return h(V,this).set(t,s),s}function X(t,e){const s=h(V,this).get(e);return"function"==typeof s?s:("string"==typeof t&&(t=h(J,this).compile(t,e)),"function"==typeof t?(h(V,this).set(e,t),t):void 0)}f(z,"exports",["configure","get"]);const Y=[["-",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,",1))\n").concat(e,"('")],["=",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,"))\n").concat(e,"('")],["#",(t,e)=>"')\n/**".concat(t,"**/\n").concat(e,"('")],["",(t,e)=>"')\n".concat(t,"\n").concat(e,"('")]];var Z=new WeakMap;class I{constructor(t){l(this,Z,{}),L(this,this.constructor.exports),this.configure(t)}configure(t){var e;h(Z,this).strict=t.strict,h(Z,this).rmWhitespace=t.rmWhitespace,h(Z,this).token=t.token,h(Z,this).vars=t.vars,h(Z,this).globals=t.globals,h(Z,this).legacy=null===(e=t.legacy)||void 0===e||e,h(Z,this).slurp={match:"[s\t\n]*",start:[h(Z,this).token.start,"_"],end:["_",h(Z,this).token.end]},h(Z,this).matches=[],h(Z,this).formats=[];for(const[t,e]of Y)h(Z,this).matches.push(h(Z,this).token.start.concat(t).concat(h(Z,this).token.regex).concat(h(Z,this).token.end)),h(Z,this).formats.push(e);h(Z,this).regex=new RegExp(h(Z,this).matches.join("|").concat("|$"),"g"),h(Z,this).slurpStart=new RegExp([h(Z,this).slurp.match,h(Z,this).slurp.start.join("")].join(""),"gm"),h(Z,this).slurpEnd=new RegExp([h(Z,this).slurp.end.join(""),h(Z,this).slurp.match].join(""),"gm"),h(Z,this).globals.length&&(h(Z,this).legacy?h(Z,this).globalVariables="const ".concat(h(Z,this).globals.map((t=>"".concat(t,"=").concat(h(Z,this).vars.SCOPE,".").concat(t))).join(","),";"):h(Z,this).globalVariables="const {".concat(h(Z,this).globals.join(","),"} = ").concat(h(Z,this).vars.SCOPE,";"))}compile(t,e){const s=h(Z,this).globalVariables,{SCOPE:n,SAFE:r,BUFFER:i,COMPONENT:o,ELEMENT:c}=h(Z,this).vars;h(Z,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(h(Z,this).slurpStart,h(Z,this).token.start).replace(h(Z,this).slurpEnd,h(Z,this).token.end);let a="".concat(i,"('");((t,e,s)=>{let n=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),r=t.shift();return s(t,n,e),n=e+r.length,r}))})(h(Z,this).regex,t,((e,s,n)=>{a+=(""+t.slice(s,n)).replace(W,(t=>"\\"+P[t])),e.forEach(((t,e)=>{t&&(a+=h(Z,this).formats[e](t.trim(),i,r))}))})),a+="');",a="try{".concat(a,"}catch(e){return ").concat(i,".error(e)}"),!1===h(Z,this).strict&&(a="with(".concat(n,"){").concat(a,"}")),a="".concat(i,".start();").concat(a,"return ").concat(i,".end();"),a+="\n//# sourceURL=".concat(e),s&&(a="".concat(s,"\n").concat(a));try{const t=[n,o,c,i,r],e=Function.apply(null,t.concat(a));return e.source="(function(".concat(t.join(","),"){\n").concat(a,"\n});"),e}catch(t){t.filename=e,t.source=a,F(0,t)}}}f(I,"exports",["configure","compile"]);var G=new WeakMap,H=new WeakMap,Q=new WeakMap;class tt{constructor(t){l(this,G,!0),l(this,H,void 0),l(this,Q,{}),L(this,this.constructor.exports),this.configure(t)}get(t){if(h(G,this))return h(Q,this)[t]}set(t,e){h(G,this)&&(h(Q,this)[t]=e)}exist(t){if(h(G,this))return h(Q,this).hasOwnProperty(t)}clear(){Object.keys(h(Q,this)).forEach(this.remove)}remove(t){delete h(Q,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){h(G,this)&&Object.assign(h(Q,this),t||{})}configure(t){u(G,this,t.cache),u(H,this,t.precompiled),"object"==typeof window&&this.load(window[h(H,this)])}}f(tt,"exports",["load","set","get","exist","clear","remove","resolve"]);const et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],st=" ",nt='"',rt="/",it="<",ot=">",ct=t=>{let[e,s]=t;if(null!=s)return[T(e),[nt,T(s),nt].join("")].join("=")},at=(t,e,s)=>{const n=[],r=-1===et.indexOf(t),i=Object.entries(null!=e?e:{}).map(ct).filter((t=>t)).join(st);return n.push([it,t,st,i,ot].join("")),s&&r&&n.push(Array.isArray(s)?s.join(""):s),r&&n.push([it,rt,t,ot].join("")),n.join("")},ht=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>F(0,t))),lt=()=>{let t=[],e=[];const s=t=>{e.push(t)};return s.start=()=>{e=[]},s.backup=()=>{t.push(e.concat()),e=[]},s.restore=()=>{const s=e.concat();return e=t.pop(),ht(s)},s.error=t=>(t=>Promise.reject(F(0,t)))(t),s.end=()=>ht(e),s},ut=Symbol("EjsContext.parentTemplate"),pt=(t,e)=>{const s=t.globals||[],{BLOCKS:n,MACRO:o,EXTEND:c,LAYOUT:a,BUFFER:h,SAFE:l,SCOPE:u,COMPONENT:p,ELEMENT:f}=t.vars;class g{constructor(t){this[ut]=null,this[n]={},this[o]={},Object.assign(this,q(t,[u,h,l,p,f]))}}return Object.defineProperties(g.prototype,{[h]:{value:lt()},[n]:{value:{},writable:!0},[o]:{value:{},writable:!0},[a]:{value:!1,writable:!0},[c]:{value:!1,writable:!0},[ut]:{value:null,writable:!0},setParentTemplate:{value(t){return this[ut]=t,this}},getParentTemplate:{value(){return this[ut]}},useEscapeValue:{value:()=>$},useComponent:{value(){return r(this[p])?this[p].bind(this):function(){F(2,"".concat(p," must be a function"))}}},useElement:{value(){return r(this[f])?this[f].bind(this):()=>{F(2,"".concat(f," must be a function"))}}},useBuffer:{value(){return this[h]}},getMacro:{value(){return this[o]}},getBlocks:{value(){return this[n]}},setExtend:{value(t){return this[c]=t,this}},getExtend:{value(){return this[c]}},setLayout:{value(t){return this[a]=t,this}},getLayout:{value(){return this[a]}},clone:{value(t){const e=[a,c,h];return!0===t&&e.push(n),q(this,e)}},extend:{value(t){this.setExtend(!0),this.setLayout(t)}},echo:{value(){return[].slice.call(arguments).forEach(this.useBuffer())}},fn:{value(t){const e=this.useBuffer(),s=this;return function(){if(r(t))return e.backup(),e(t.apply(s,arguments)),e.restore()}}},macro:{value(t,e){const s=this.getMacro(),n=this.fn(e),r=this;s[t]=function(){return r.echo(n.apply(void 0,arguments))}}},call:{value(t){const e=this.getMacro()[t],s=[].slice.call(arguments,1);if(r(e))return e.apply(e,s)}},block:{value(t,e){const s=this.getBlocks();if(s[t]=s[t]||[],s[t].push(this.fn(e)),this.getExtend())return;const n=this,r=Object.assign([],s[t]),i=function(){return r.shift()},o=function(){const t=i();return t?function(){n.echo(t(o()))}:function(){}};this.echo(i()(o()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const n=!1===s?{}:this.clone(!0),r=Object.assign(n,e||{}),i=this.render(t,r);this.echo(i)}},use:{value(t,e){this.echo(Promise.resolve(this.require(t)).then((t=>{const s=this.getMacro();B(t,((t,n)=>{s[[e,n].join(".")]=t}))})))}},get:{value(t,e){const s=N(this,t,!0),n=s.shift(),r=s.pop();return A(n,r)?n[r]:e}},set:{value(t,e){const s=N(this,t,!1),n=s.shift(),r=s.pop();return this.getParentTemplate()&&A(n,r)?n[r]:n[r]=e}},each:{value(t,e){i(t)&&(t=this.get(t,[])),B(t,e)},writable:!0},el:{value(t,e,s){s=r(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>at(t,e,s))))},writable:!0},ui:{value(){},writable:!0},require:{value(){},writable:!0},render:{value(){},writable:!0}}),Object.entries(e).forEach((t=>{let[e,n]=t;r(n)&&s.includes(e)&&(n=n.bind(g.prototype)),g.prototype[e]=n})),g};var ft=new WeakMap;class gt{constructor(t,e){l(this,ft,void 0),L(this,this.constructor.exports),this.configure(t,e)}create(t){return new(h(ft,this))(t)}helpers(t){Object.assign(h(ft,this).prototype,t)}configure(t,e){u(ft,this,pt(t,e))}}f(gt,"exports",["create","globals","helpers"]);var vt=new WeakMap,dt=new WeakMap,bt=new WeakMap,mt=new WeakMap,yt=new WeakMap,wt=new WeakMap,jt=new WeakSet;class Ot{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,jt),l(this,vt,void 0),l(this,dt,void 0),l(this,bt,void 0),l(this,mt,void 0),l(this,yt,{}),l(this,wt,{}),L(this,this.constructor.exports),u(wt,this,{}),u(yt,this,k({},t)),u(dt,this,new gt(h(yt,this),h(wt,this))),u(bt,this,new I(h(yt,this))),u(vt,this,new tt(h(yt,this))),u(mt,this,new z(h(yt,this),h(vt,this),h(bt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(k(h(yt,this),t),h(dt,this).configure(h(yt,this),h(wt,this)),h(bt,this).configure(h(yt,this)),h(vt,this).configure(h(yt,this)),h(mt,this).configure(h(yt,this))),h(yt,this)}createContext(t){return h(dt,this).create(t)}preload(t){return h(vt,this).load(t||{})}compile(t,e){return h(bt,this).compile(t,e)}helpers(t){h(dt,this).helpers(Object.assign(h(wt,this),t))}async render(t,e){const s=this.createContext(e);return c(jt,this,xt).call(this,c(jt,this,Et).call(this,t),s).then(c(jt,this,Pt).call(this,t,s))}async require(t){const e=this.createContext({});return c(jt,this,xt).call(this,c(jt,this,Et).call(this,t),e).then((()=>e.getMacro()))}}function Et(t){return t.split(".").pop()!==h(yt,this).extension&&(t=[t,h(yt,this).extension].join(".")),t}function xt(t,e){return h(mt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function kt(t,e,s){const n=this.createContext(e);return s&&n.setParentTemplate(s),c(jt,this,xt).call(this,c(jt,this,Et).call(this,t),n).then(c(jt,this,Pt).call(this,t,n))}function Pt(t,e){return s=>e.getExtend()?(e.setExtend(!1),c(jt,this,kt).call(this,e.getLayout(),e,t)):s}f(Ot,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const Mt={},{render:St,createContext:Ct,helpers:Wt,configure:Tt}=new Ot({cache:!1,strict:!0,resolver:async(t,e,s)=>{if(r(Mt[e]))return Mt[e];s(1,"template ".concat(e," not found"))}});function $t(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(Mt,t)}t.configure=Tt,t.createContext=Ct,t.element=at,t.escapeValue=$,t.helpers=Wt,t.render=St,t.useRenderer=function(){var t;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return $t(null!==(t=e.templates)&&void 0!==t?t:{}),async(t,s)=>{var n,r,i;t.data=Ct({}),t.data.set("version",e.version),t.data.set("origin",(r=t.req.url,i=null===(n=e.secure)||void 0===n||n,(r=URL.parse(r)).protocol=i?"https:":"http:",r.origin)),t.data.set("path",t.req.path),t.data.set("query",t.req.query()),t.ejs=async(e,s)=>St(e,Object.assign({param:t.req.param()},t.data,s)),t.helpers=t=>Wt(t),t.render=async(e,s)=>t.html(t.ejs(e,s)),await s()}},t.useTemplates=$t}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejsInstance={})}(this,(function(t){"use strict";const e=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,s=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},r=t=>Array.isArray(t),n=t=>"function"==typeof t,i=t=>"string"==typeof t,o=t=>"boolean"==typeof t;function c(t,e,s){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:s;throw new TypeError("Private element is not present on this object")}function a(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function h(t,e){return t.get(c(t,e))}function l(t,e,s){a(t,e),e.set(t,s)}function u(t,e,s){return t.set(c(t,e),s),s}function p(t,e){a(t,e),e.add(t)}function f(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var r=s.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function g(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,r)}return s}const v="ejsPrecompiled",d=!0,b="views",m="ejs",y=!0,w=!0,j=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),O=[],E={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},x={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},k=(t,c)=>{return Object.assign(t,{path:s(i,b,t.path,c.path),precompiled:s(i,v,t.export,c.export),resolver:s(n,j,t.resolver,c.resolver),extension:s(i,m,t.extension,c.extension),strict:s(o,w,t.strict,c.strict),rmWhitespace:s(o,y,t.rmWhitespace,c.rmWhitespace),cache:s(o,d,t.cache,c.cache),globals:s(r,O,t.globals,(a=c.globals,!!r(a)&&a.filter((t=>{const s=e.test(t);return!1===s&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),s})))),token:Object.assign({},x,t.token,c.token),vars:Object.assign({},E,t.vars,c.vars)});var a},P={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},S=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),C=S(M),W=S(P),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(C,(t=>M[t]))},$=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?T(s):s},N=(t,e,s)=>{let r=t,i=String(e).split("."),o=i.pop();for(let t=0;t<i.length;t++){const e=i[t];if(n(r.toJSON)&&(r=r.toJSON()),s&&!1===r.hasOwnProperty(e)){r={};break}r=r[e]=r[e]||{}}return n(r.toJSON)&&(r=r.toJSON()),[r,o]},B=(t,e)=>{let s;for(s in t)A(t,s)&&e(t[s],s,t)},q=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?g(Object(s),!0).forEach((function(e){f(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):g(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}({},t);for(const t of e)delete s[t];return s},A=(t,e)=>t&&Object.hasOwn(t,e),L=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for(let s=0,r=e.length;s<r;s++){const r=e[s];r in t&&(t[r]=t[r].bind(t))}};class R extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const F=(t,e)=>{throw new R(t,e)};var U=new WeakMap,D=new WeakMap,V=new WeakMap,J=new WeakMap,_=new WeakSet;class z{constructor(t,e,s){p(this,_),l(this,U,void 0),l(this,D,void 0),l(this,V,void 0),l(this,J,void 0),L(this,this.constructor.exports),u(V,this,e),u(J,this,s),this.configure(null!=t?t:{})}configure(t){u(U,this,t.path),n(t.resolver)&&u(D,this,t.resolver)}get(t){const e=h(V,this).get(t);return e?Promise.resolve(e):c(_,this,K).call(this,t).then((e=>{const s=c(_,this,X).call(this,e,t);return h(V,this).set(t,s),s}))}}function K(t){return Promise.resolve(h(D,this).call(this,h(U,this),t,F))}function X(t,e){return"function"==typeof t?t:"string"==typeof t?h(J,this).compile(t,e):void 0}f(z,"exports",["configure","get"]);const Y=[["-",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,",1))\n").concat(e,"('")],["=",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,"))\n").concat(e,"('")],["#",(t,e)=>"')\n/**".concat(t,"**/\n").concat(e,"('")],["",(t,e)=>"')\n".concat(t,"\n").concat(e,"('")]];var Z=new WeakMap;class I{constructor(t){l(this,Z,{}),L(this,this.constructor.exports),this.configure(t)}configure(t){var e;h(Z,this).strict=t.strict,h(Z,this).rmWhitespace=t.rmWhitespace,h(Z,this).token=t.token,h(Z,this).vars=t.vars,h(Z,this).globals=t.globals,h(Z,this).legacy=null===(e=t.legacy)||void 0===e||e,h(Z,this).slurp={match:"[s\t\n]*",start:[h(Z,this).token.start,"_"],end:["_",h(Z,this).token.end]},h(Z,this).matches=[],h(Z,this).formats=[];for(const[t,e]of Y)h(Z,this).matches.push(h(Z,this).token.start.concat(t).concat(h(Z,this).token.regex).concat(h(Z,this).token.end)),h(Z,this).formats.push(e);h(Z,this).regex=new RegExp(h(Z,this).matches.join("|").concat("|$"),"g"),h(Z,this).slurpStart=new RegExp([h(Z,this).slurp.match,h(Z,this).slurp.start.join("")].join(""),"gm"),h(Z,this).slurpEnd=new RegExp([h(Z,this).slurp.end.join(""),h(Z,this).slurp.match].join(""),"gm"),h(Z,this).globals.length&&(h(Z,this).legacy?h(Z,this).globalVariables="const ".concat(h(Z,this).globals.map((t=>"".concat(t,"=").concat(h(Z,this).vars.SCOPE,".").concat(t))).join(","),";"):h(Z,this).globalVariables="const {".concat(h(Z,this).globals.join(","),"} = ").concat(h(Z,this).vars.SCOPE,";"))}compile(t,e){const s=h(Z,this).globalVariables,{SCOPE:r,SAFE:n,BUFFER:i,COMPONENT:o,ELEMENT:c}=h(Z,this).vars;h(Z,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(h(Z,this).slurpStart,h(Z,this).token.start).replace(h(Z,this).slurpEnd,h(Z,this).token.end);let a="".concat(i,"('");((t,e,s)=>{let r=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return s(t,r,e),r=e+n.length,n}))})(h(Z,this).regex,t,((e,s,r)=>{a+=(""+t.slice(s,r)).replace(W,(t=>"\\"+P[t])),e.forEach(((t,e)=>{t&&(a+=h(Z,this).formats[e](t.trim(),i,n))}))})),a+="');",a="try{".concat(a,"}catch(e){return ").concat(i,".error(e)}"),!1===h(Z,this).strict&&(a="with(".concat(r,"){").concat(a,"}")),a="".concat(i,".start();").concat(a,"return ").concat(i,".end();"),a+="\n//# sourceURL=".concat(e),s&&(a="".concat(s,"\n").concat(a));try{const t=[r,o,c,i,n],e=Function.apply(null,t.concat(a));return e.source="(function(".concat(t.join(","),"){\n").concat(a,"\n});"),e}catch(t){t.filename=e,t.source=a,F(0,t)}}}f(I,"exports",["configure","compile"]);var G=new WeakMap,H=new WeakMap,Q=new WeakMap;class tt{constructor(t){l(this,G,!0),l(this,H,void 0),l(this,Q,{}),L(this,this.constructor.exports),this.configure(t)}get(t){if(h(G,this))return h(Q,this)[t]}set(t,e){h(G,this)&&(h(Q,this)[t]=e)}exist(t){if(h(G,this))return h(Q,this).hasOwnProperty(t)}clear(){Object.keys(h(Q,this)).forEach(this.remove)}remove(t){delete h(Q,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){h(G,this)&&Object.assign(h(Q,this),t||{})}configure(t){u(G,this,t.cache),u(H,this,t.precompiled),"object"==typeof window&&this.load(window[h(H,this)])}}f(tt,"exports",["load","set","get","exist","clear","remove","resolve"]);const et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],st=" ",rt='"',nt="/",it="<",ot=">",ct=t=>{let[e,s]=t;if(null!=s)return[T(e),[rt,T(s),rt].join("")].join("=")},at=(t,e,s)=>{const r=[],n=-1===et.indexOf(t),i=Object.entries(null!=e?e:{}).map(ct).filter((t=>t)).join(st);return r.push([it,t,st,i,ot].join("")),s&&n&&r.push(Array.isArray(s)?s.join(""):s),n&&r.push([it,nt,t,ot].join("")),r.join("")},ht=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>F(0,t))),lt=()=>{let t=[],e=[];const s=t=>{e.push(t)};return s.start=()=>{e=[]},s.backup=()=>{t.push(e.concat()),e=[]},s.restore=()=>{const s=e.concat();return e=t.pop(),ht(s)},s.error=t=>(t=>Promise.reject(F(0,t)))(t),s.end=()=>ht(e),s},ut=Symbol("EjsContext.parentTemplate"),pt=(t,e)=>{const s=t.globals||[],{BLOCKS:r,MACRO:o,EXTEND:c,LAYOUT:a,BUFFER:h,SAFE:l,SCOPE:u,COMPONENT:p,ELEMENT:f}=t.vars;class g{constructor(t){this[ut]=null,this[r]={},this[o]={},Object.assign(this,q(t,[u,h,l,p,f]))}}return Object.defineProperties(g.prototype,{[h]:{value:lt()},[r]:{value:{},writable:!0},[o]:{value:{},writable:!0},[a]:{value:!1,writable:!0},[c]:{value:!1,writable:!0},[ut]:{value:null,writable:!0},setParentTemplate:{value(t){return this[ut]=t,this}},getParentTemplate:{value(){return this[ut]}},useEscapeValue:{value:()=>$},useComponent:{value(){return n(this[p])?this[p].bind(this):function(){F(2,"".concat(p," must be a function"))}}},useElement:{value(){return n(this[f])?this[f].bind(this):()=>{F(2,"".concat(f," must be a function"))}}},useBuffer:{value(){return this[h]}},getMacro:{value(){return this[o]}},getBlocks:{value(){return this[r]}},setExtend:{value(t){return this[c]=t,this}},getExtend:{value(){return this[c]}},setLayout:{value(t){return this[a]=t,this}},getLayout:{value(){return this[a]}},clone:{value(t){const e=[a,c,h];return!0===t&&e.push(r),q(this,e)}},extend:{value(t){this.setExtend(!0),this.setLayout(t)}},echo:{value(){return[].slice.call(arguments).forEach(this.useBuffer())}},fn:{value(t){const e=this.useBuffer(),s=this;return function(){if(n(t))return e.backup(),e(t.apply(s,arguments)),e.restore()}}},macro:{value(t,e){const s=this.getMacro(),r=this.fn(e),n=this;s[t]=function(){return n.echo(r.apply(void 0,arguments))}}},call:{value(t){const e=this.getMacro()[t],s=[].slice.call(arguments,1);if(n(e))return e.apply(e,s)}},block:{value(t,e){const s=this.getBlocks();if(s[t]=s[t]||[],s[t].push(this.fn(e)),this.getExtend())return;const r=this,n=Object.assign([],s[t]),i=function(){return n.shift()},o=function(){const t=i();return t?function(){r.echo(t(o()))}:function(){}};this.echo(i()(o()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const r=!1===s?{}:this.clone(!0),n=Object.assign(r,e||{}),i=this.render(t,n);this.echo(i)}},use:{value(t,e){this.echo(Promise.resolve(this.require(t)).then((t=>{const s=this.getMacro();B(t,((t,r)=>{s[[e,r].join(".")]=t}))})))}},get:{value(t,e){const s=N(this,t,!0),r=s.shift(),n=s.pop();return A(r,n)?r[n]:e}},set:{value(t,e){const s=N(this,t,!1),r=s.shift(),n=s.pop();return this.getParentTemplate()&&A(r,n)?r[n]:r[n]=e}},each:{value(t,e){i(t)&&(t=this.get(t,[])),B(t,e)},writable:!0},el:{value(t,e,s){s=n(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>at(t,e,s))))},writable:!0},ui:{value(){},writable:!0},require:{value(){},writable:!0},render:{value(){},writable:!0}}),Object.entries(e).forEach((t=>{let[e,r]=t;n(r)&&s.includes(e)&&(r=r.bind(g.prototype)),g.prototype[e]=r})),g};var ft=new WeakMap;class gt{constructor(t,e){l(this,ft,void 0),L(this,this.constructor.exports),this.configure(t,e)}create(t){return new(h(ft,this))(t)}helpers(t){Object.assign(h(ft,this).prototype,t)}configure(t,e){u(ft,this,pt(t,e))}}f(gt,"exports",["create","globals","helpers"]);var vt=new WeakMap,dt=new WeakMap,bt=new WeakMap,mt=new WeakMap,yt=new WeakMap,wt=new WeakMap,jt=new WeakSet;class Ot{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,jt),l(this,vt,void 0),l(this,dt,void 0),l(this,bt,void 0),l(this,mt,void 0),l(this,yt,{}),l(this,wt,{}),L(this,this.constructor.exports),u(wt,this,{}),u(yt,this,k({},t)),u(dt,this,new gt(h(yt,this),h(wt,this))),u(bt,this,new I(h(yt,this))),u(vt,this,new tt(h(yt,this))),u(mt,this,new z(h(yt,this),h(vt,this),h(bt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(k(h(yt,this),t),h(dt,this).configure(h(yt,this),h(wt,this)),h(bt,this).configure(h(yt,this)),h(vt,this).configure(h(yt,this)),h(mt,this).configure(h(yt,this))),h(yt,this)}createContext(t){return h(dt,this).create(t)}preload(t){return h(vt,this).load(t||{})}compile(t,e){return h(bt,this).compile(t,e)}helpers(t){h(dt,this).helpers(Object.assign(h(wt,this),t))}async render(t,e){const s=this.createContext(e);return c(jt,this,xt).call(this,c(jt,this,Et).call(this,t),s).then(c(jt,this,Pt).call(this,t,s))}async require(t){const e=this.createContext({});return c(jt,this,xt).call(this,c(jt,this,Et).call(this,t),e).then((()=>e.getMacro()))}}function Et(t){return t.split(".").pop()!==h(yt,this).extension&&(t=[t,h(yt,this).extension].join(".")),t}function xt(t,e){return h(mt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function kt(t,e,s){const r=this.createContext(e);return s&&r.setParentTemplate(s),c(jt,this,xt).call(this,c(jt,this,Et).call(this,t),r).then(c(jt,this,Pt).call(this,t,r))}function Pt(t,e){return s=>e.getExtend()?(e.setExtend(!1),c(jt,this,kt).call(this,e.getLayout(),e,t)):s}f(Ot,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const Mt={},{render:St,createContext:Ct,helpers:Wt,configure:Tt}=new Ot({cache:!1,strict:!0,resolver:async(t,e,s)=>{if(n(Mt[e]))return Mt[e];s(1,"template ".concat(e," not found"))}});function $t(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(Mt,t)}t.configure=Tt,t.createContext=Ct,t.element=at,t.escapeValue=$,t.helpers=Wt,t.render=St,t.useRenderer=function(){var t;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return $t(null!==(t=e.templates)&&void 0!==t?t:{}),async(t,s)=>{var r,n,i;t.data=Ct({}),t.data.set("version",e.version),t.data.set("origin",(n=t.req.url,i=null===(r=e.secure)||void 0===r||r,(n=URL.parse(n)).protocol=i?"https:":"http:",n.origin)),t.data.set("path",t.req.path),t.data.set("query",t.req.query()),t.ejs=async(e,s)=>St(e,Object.assign({param:t.req.param()},t.data,s)),t.helpers=t=>Wt(t),t.render=async(e,s)=>t.html(t.ejs(e,s)),await s()}},t.useTemplates=$t}));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "EJS Templates",
4
4
  "homepage": "https://github.com/kosatyi/ejs",
5
5
  "type": "module",
6
- "version": "0.0.114",
6
+ "version": "0.0.116",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "browser": "dist/umd/browser.js",