@kosatyi/ejs 0.0.61 → 0.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -526,15 +526,14 @@ var Cache = /*#__PURE__*/function () {
526
526
  _classCallCheck(this, Cache);
527
527
  _defineProperty(this, "list", {});
528
528
  this.configure(config);
529
- if (isNode() === false) {
530
- this.load(global[this.namespace]);
531
- }
532
529
  }
533
530
  _createClass(Cache, [{
534
531
  key: "configure",
535
532
  value: function configure(config) {
536
533
  this.list = {};
537
- this.namespace = config["export"];
534
+ if (isNode() === false) {
535
+ this.load(global[config["export"]]);
536
+ }
538
537
  }
539
538
  }, {
540
539
  key: "load",
package/dist/esm/index.js CHANGED
@@ -443,13 +443,12 @@ class Cache {
443
443
  list = {}
444
444
  constructor(config) {
445
445
  this.configure(config);
446
- if (isNode() === false) {
447
- this.load(global[this.namespace]);
448
- }
449
446
  }
450
447
  configure(config) {
451
448
  this.list = {};
452
- this.namespace = config.export;
449
+ if (isNode() === false) {
450
+ this.load(global[config.export]);
451
+ }
453
452
  }
454
453
  load(data) {
455
454
  extend(this.list, data);
package/dist/umd/index.js CHANGED
@@ -529,15 +529,14 @@
529
529
  _classCallCheck(this, Cache);
530
530
  _defineProperty(this, "list", {});
531
531
  this.configure(config);
532
- if (isNode() === false) {
533
- this.load(global[this.namespace]);
534
- }
535
532
  }
536
533
  _createClass(Cache, [{
537
534
  key: "configure",
538
535
  value: function configure(config) {
539
536
  this.list = {};
540
- this.namespace = config["export"];
537
+ if (isNode() === false) {
538
+ this.load(global[config["export"]]);
539
+ }
541
540
  }
542
541
  }, {
543
542
  key: "load",
@@ -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).ejs={})}(this,(function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,s(r.key),r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e,n){return(e=s(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function u(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){s=!0,o=t},f:function(){try{u||null==n.return||n.return()}finally{if(s)throw o}}}}function s(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");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:String(e)}var a=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},h=function(t){return"function"==typeof t},f=function(t){return"string"==typeof t},l=function(t){return"boolean"==typeof t},p=function(t){return"object"===e(t)},v=function(t){return void 0===t},d="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),m=function(){return d},g={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},y={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},b=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},w=b(y),k=b(g),x=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(w,(function(t){return y[t]}))},j=function(t,e,n){return null==(n=t)?"":e?x(n):n},E=function(t,e,n){var r,i=t,o=String(e).split("."),c=o.pop(),s=u(o);try{for(s.s();!(r=s.n()).done;){var a=r.value;if(n&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}}catch(t){s.e(t)}finally{s.f()}return[i,c]},O=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},S=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),r)},F=function(){},B=function(t,e){var n;for(n in t)R(t,n)&&e(t[n],n,t)},P=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return B(t,(function(t,n,o){var c=e(t,n,o);!1===v(c)&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},A=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},R=function(t,e){return t&&t.hasOwnProperty(e)},$={export:"ejsPrecompiled",watch:!1,chokidar:null,path:"views",resolver:null,extension:"ejs",rmWhitespace:!0,withObject:!0,vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},T=function(t,e){S(t,{path:a(f,$.path,t.path,e.path),export:a(f,$.export,t.export,e.export),resolver:a(h,$.resolver,t.resolver,e.resolver),extension:a(f,$.extension,t.extension,e.extension),withObject:a(l,$.withObject,t.withObject,e.withObject),rmWhitespace:a(l,$.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:a(l,$.watch,t.watch,e.watch),chokidar:a(p,$.export,t.export,e.export),token:S({},$.token,t.token,e.token),vars:S({},$.vars,t.vars,e.vars)})},C={},M=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},U=function(t,e){return fetch(M(t,e)).then((function(t){return t.text()}))},_=function(t,e){return new Promise((function(n,r){C.readFile(M(t,e),(function(t,e){t?r(t):n(e.toString())}))}))},L=function(){function t(e,r,i){n(this,t),this.cache=r,this.watcher={unwatch:function(){},on:function(){}},this.compiler=i,this.configure(e)}return i(t,[{key:"configure",value:function(t){var e=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=h(t.resolver)?t.resolver:m()?_:U,t.watch&&m()&&(this.watcher&&this.watcher.unwatch("."),this.chokidar&&(this.watcher=this.chokidar.watch(".",{cwd:this.path}).on("change",(function(t){e.cache.remove(t)}))))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return h(t)?t:this.compiler.compile(t,e)}},{key:"get",value:function(t){var e=this;if(this.cache.exist(t))return this.cache.resolve(t);var n=this.resolve(t).then((function(n){return e.result(t,e.compile(n,t))}));return this.result(t,n)}}]),t}(),N=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}],W=function(){function t(e){n(this,t),this.configure(e)}return i(t,[{key:"configure",value:function(t){var e=this;this.withObject=t.withObject,this.rmWhitespace=t.rmWhitespace,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},N.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start.join("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),this.slurp.match].join(""),"gm")}},{key:"truncate",value:function(t){return t&&t.replace(/^(?:\r\n|\r|\n)/,"")}},{key:"compile",value:function(t,e){var n=this,r=this.vars,i=r.SCOPE,o=r.SAFE,c=r.BUFFER,u=r.COMPONENT;this.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(this.slurpStart,this.token.start).replace(this.slurpEnd,this.token.end);var s,a,h,f="".concat(c,"('");s=this.regex,a=function(e,r,i){f+=(""+t.slice(r,i)).replace(k,(function(t){return"\\"+g[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},h=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,h,e),h=e+n.length,n})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(i,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(i,u,c,o,f)).source="(function(".concat(i,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),q="undefined"!=typeof globalThis?globalThis:window||self,I=function(){function t(e){n(this,t),o(this,"list",{}),this.configure(e),!1===m()&&this.load(q[this.namespace])}return i(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return S(this.list,t),this}},{key:"exist",value:function(t){return R(this.list,t)}},{key:"get",value:function(t){return this.list[t]}},{key:"remove",value:function(t){delete this.list[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"set",value:function(t,e){return this.list[t]=e,this}}]),t}(),D=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],K=" ",X='"',Y="/",J="<",V=">",z=function(t,e,n){var r=[],i=-1===D.indexOf(t),o=function(t,e,n){var r=[];return B(t,(function(t,n,i){var o=e(t,n,i);!1===v(o)&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[x(e),[X,x(t),X].join("")].join("=")})).join(K);return r.push([J,t,K,o,V].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([J,Y,t,V].join("")),r.join("")},G=function(t){return Promise.all(t).then((function(t){return t.join("")}))},H=function(){function t(e){n(this,t),this.configure(e)}return i(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,i=n.LAYOUT,o=n.BLOCKS,c=n.BUFFER,u=n.MACRO,s=n.COMPONENT;function a(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),S(this,t)}this.create=function(t){return new a(t)},this.helpers=function(t){S(a.prototype,t)},a.prototype=S({},e||{}),a.define=a.method=function(t,e,n,r,i){return Object.defineProperty(a.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:i||!1})},a.define(c,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),G(n)},n.error=function(t){throw t},n.end=function(){return G(e)},n}()),a.define(o,{},!0),a.define(u,{},!0),a.define(i,!1,!0),a.define(r,!1,!0),a.method("initBlocks",(function(){this[o]={}})),a.method("initMacro",(function(){this[u]={}})),a.method("getMacro",(function(){return this[u]})),a.method("getBuffer",(function(){return this[c]})),a.method("getComponent",(function(){var t=this;return s in t?function(){return t[s].apply(t,arguments)}:function(){console.log("%s function not defined",s)}})),a.method("getBlocks",(function(){return this[o]})),a.method("setExtend",(function(t){this[r]=t})),a.method("getExtend",(function(){return this[r]})),a.method("setLayout",(function(t){this[i]=t})),a.method("getLayout",(function(){return this[i]})),a.method("clone",(function(t){var e=[i,r,c];return!0===t&&e.push(o),P(this,e)})),a.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),a.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),a.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),h(t)&&t.apply(n,arguments),e.restore()}})),a.method("get",(function(t,e){var n=E(this,t,!0),r=n.shift(),i=n.pop();return R(r,i)?r[i]:e})),a.method("set",(function(t,e){var n=E(this,t,!1),r=n.shift(),i=n.pop();return this.getExtend()&&R(r,i)?r[i]:r[i]=e})),a.method("macro",(function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}})),a.method("call",(function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(h(e))return e.apply(e,n)})),a.method("block",(function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()};this.echo(o()(function t(){var e=o();return e?function(){n.echo(e(t()))}:F}()))}})),a.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=S(r,e||{}),o=this.render(t,i);this.echo(o)})),a.method("use",(function(t,e){var n=this.require(t);this.echo(A(n,(function(t){var n=this.getMacro();B(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),a.method("async",(function(t,e){this.echo(A(t,(function(t){return this.fn(e)(t)}),this))})),a.method("node",(function(t,e,n){return z(t,e,n)})),a.method("el",(function(t,e,n){h(n)&&(n=this.fn(n)()),this.echo(A(n,(function(n){return z(t,e,n)}),this))})),a.method("each",(function(t,e){f(t)&&(t=this.get(t,[])),B(t,e)}))}}]),t}(),Q=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),o(this,"export",["cache","render","require","helpers","configure","preload","compile","create","__express"]),this.config={},this.scope={},T(this.config,e),function(t,e){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]).forEach((function(n){n in t&&(t[n]=t[n].bind(e))}))}(this,this,this.export),this.context=new H(this.config),this.compiler=new W(this.config),this.cache=new I(this.config),this.template=new L(this.config,this.cache,this.compiler),this.helpers({require:this.require,render:this.render})}return i(t,[{key:"configure",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return T(this.config,t),this.context.configure(this.config,this.scope),this.compiler.configure(this.config),this.cache.configure(this.config),this.template.configure(this.config),this.config}},{key:"output",value:function(t,e){return this.template.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),j)}))}},{key:"render",value:function(t,e){var n=this,r=O(t,this.config.extension),i=this.context.create(e);return this.output(r,i).then((function(t){if(i.getExtend()){i.setExtend(!1);var e=i.getLayout(),r=i.clone();return n.render(e,r)}return t}))}},{key:"require",value:function(t){var e=O(t,this.config.extension),n=this.context.create({});return this.output(e,n).then((function(){return n.getMacro()}))}},{key:"create",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"helpers",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.context.helpers(S(this.scope,t))}},{key:"preload",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.cache.load(t)}},{key:"compile",value:function(t,e){return this.compiler.compile(t,e)}},{key:"__express",value:function(t,e,n){h(e)&&(n=e,e={});var r=S({},(e=e||{}).settings),i=a(f,$.path,r.views),o=a(l,$.cache,r["view cache"]),c=S({},r["view options"]),u=C.relative(i,t);return c.path=i,c.cache=o,this.configure(c),this.render(u,e).then((function(t){n(null,t)})).catch((function(t){n(t)}))}}]),t}(),Z=new Q({}),tt=Z.__express,et=Z.render,nt=Z.context,rt=Z.compile,it=Z.helpers,ot=Z.preload,ct=Z.configure,ut=Z.create;t.EJS=Q,t.__express=tt,t.compile=rt,t.configure=ct,t.context=nt,t.create=ut,t.element=z,t.helpers=it,t.preload=ot,t.render=et,t.safeValue=j}));
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).ejs={})}(this,(function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,s(r.key),r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e,n){return(e=s(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function u(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){s=!0,o=t},f:function(){try{u||null==n.return||n.return()}finally{if(s)throw o}}}}function s(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");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:String(e)}var a=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},h=function(t){return"function"==typeof t},f=function(t){return"string"==typeof t},l=function(t){return"boolean"==typeof t},p=function(t){return"object"===e(t)},v=function(t){return void 0===t},d="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),m=function(){return d},g={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},y={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},b=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},w=b(y),k=b(g),x=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(w,(function(t){return y[t]}))},j=function(t,e,n){return null==(n=t)?"":e?x(n):n},E=function(t,e,n){var r,i=t,o=String(e).split("."),c=o.pop(),s=u(o);try{for(s.s();!(r=s.n()).done;){var a=r.value;if(n&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}}catch(t){s.e(t)}finally{s.f()}return[i,c]},O=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},S=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),r)},F=function(){},B=function(t,e){var n;for(n in t)R(t,n)&&e(t[n],n,t)},P=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return B(t,(function(t,n,o){var c=e(t,n,o);!1===v(c)&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},A=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},R=function(t,e){return t&&t.hasOwnProperty(e)},$={export:"ejsPrecompiled",watch:!1,chokidar:null,path:"views",resolver:null,extension:"ejs",rmWhitespace:!0,withObject:!0,vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},T=function(t,e){S(t,{path:a(f,$.path,t.path,e.path),export:a(f,$.export,t.export,e.export),resolver:a(h,$.resolver,t.resolver,e.resolver),extension:a(f,$.extension,t.extension,e.extension),withObject:a(l,$.withObject,t.withObject,e.withObject),rmWhitespace:a(l,$.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:a(l,$.watch,t.watch,e.watch),chokidar:a(p,$.export,t.export,e.export),token:S({},$.token,t.token,e.token),vars:S({},$.vars,t.vars,e.vars)})},C={},M=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},U=function(t,e){return fetch(M(t,e)).then((function(t){return t.text()}))},_=function(t,e){return new Promise((function(n,r){C.readFile(M(t,e),(function(t,e){t?r(t):n(e.toString())}))}))},L=function(){function t(e,r,i){n(this,t),this.cache=r,this.watcher={unwatch:function(){},on:function(){}},this.compiler=i,this.configure(e)}return i(t,[{key:"configure",value:function(t){var e=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=h(t.resolver)?t.resolver:m()?_:U,t.watch&&m()&&(this.watcher&&this.watcher.unwatch("."),this.chokidar&&(this.watcher=this.chokidar.watch(".",{cwd:this.path}).on("change",(function(t){e.cache.remove(t)}))))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return h(t)?t:this.compiler.compile(t,e)}},{key:"get",value:function(t){var e=this;if(this.cache.exist(t))return this.cache.resolve(t);var n=this.resolve(t).then((function(n){return e.result(t,e.compile(n,t))}));return this.result(t,n)}}]),t}(),N=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}],W=function(){function t(e){n(this,t),this.configure(e)}return i(t,[{key:"configure",value:function(t){var e=this;this.withObject=t.withObject,this.rmWhitespace=t.rmWhitespace,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},N.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start.join("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),this.slurp.match].join(""),"gm")}},{key:"truncate",value:function(t){return t&&t.replace(/^(?:\r\n|\r|\n)/,"")}},{key:"compile",value:function(t,e){var n=this,r=this.vars,i=r.SCOPE,o=r.SAFE,c=r.BUFFER,u=r.COMPONENT;this.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(this.slurpStart,this.token.start).replace(this.slurpEnd,this.token.end);var s,a,h,f="".concat(c,"('");s=this.regex,a=function(e,r,i){f+=(""+t.slice(r,i)).replace(k,(function(t){return"\\"+g[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},h=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,h,e),h=e+n.length,n})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(i,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(i,u,c,o,f)).source="(function(".concat(i,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),q="undefined"!=typeof globalThis?globalThis:window||self,I=function(){function t(e){n(this,t),o(this,"list",{}),this.configure(e)}return i(t,[{key:"configure",value:function(t){this.list={},!1===m()&&this.load(q[t.export])}},{key:"load",value:function(t){return S(this.list,t),this}},{key:"exist",value:function(t){return R(this.list,t)}},{key:"get",value:function(t){return this.list[t]}},{key:"remove",value:function(t){delete this.list[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"set",value:function(t,e){return this.list[t]=e,this}}]),t}(),D=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],K=" ",X='"',Y="/",J="<",V=">",z=function(t,e,n){var r=[],i=-1===D.indexOf(t),o=function(t,e,n){var r=[];return B(t,(function(t,n,i){var o=e(t,n,i);!1===v(o)&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[x(e),[X,x(t),X].join("")].join("=")})).join(K);return r.push([J,t,K,o,V].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([J,Y,t,V].join("")),r.join("")},G=function(t){return Promise.all(t).then((function(t){return t.join("")}))},H=function(){function t(e){n(this,t),this.configure(e)}return i(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,i=n.LAYOUT,o=n.BLOCKS,c=n.BUFFER,u=n.MACRO,s=n.COMPONENT;function a(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),S(this,t)}this.create=function(t){return new a(t)},this.helpers=function(t){S(a.prototype,t)},a.prototype=S({},e||{}),a.define=a.method=function(t,e,n,r,i){return Object.defineProperty(a.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:i||!1})},a.define(c,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),G(n)},n.error=function(t){throw t},n.end=function(){return G(e)},n}()),a.define(o,{},!0),a.define(u,{},!0),a.define(i,!1,!0),a.define(r,!1,!0),a.method("initBlocks",(function(){this[o]={}})),a.method("initMacro",(function(){this[u]={}})),a.method("getMacro",(function(){return this[u]})),a.method("getBuffer",(function(){return this[c]})),a.method("getComponent",(function(){var t=this;return s in t?function(){return t[s].apply(t,arguments)}:function(){console.log("%s function not defined",s)}})),a.method("getBlocks",(function(){return this[o]})),a.method("setExtend",(function(t){this[r]=t})),a.method("getExtend",(function(){return this[r]})),a.method("setLayout",(function(t){this[i]=t})),a.method("getLayout",(function(){return this[i]})),a.method("clone",(function(t){var e=[i,r,c];return!0===t&&e.push(o),P(this,e)})),a.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),a.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),a.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),h(t)&&t.apply(n,arguments),e.restore()}})),a.method("get",(function(t,e){var n=E(this,t,!0),r=n.shift(),i=n.pop();return R(r,i)?r[i]:e})),a.method("set",(function(t,e){var n=E(this,t,!1),r=n.shift(),i=n.pop();return this.getExtend()&&R(r,i)?r[i]:r[i]=e})),a.method("macro",(function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}})),a.method("call",(function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(h(e))return e.apply(e,n)})),a.method("block",(function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()};this.echo(o()(function t(){var e=o();return e?function(){n.echo(e(t()))}:F}()))}})),a.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=S(r,e||{}),o=this.render(t,i);this.echo(o)})),a.method("use",(function(t,e){var n=this.require(t);this.echo(A(n,(function(t){var n=this.getMacro();B(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),a.method("async",(function(t,e){this.echo(A(t,(function(t){return this.fn(e)(t)}),this))})),a.method("node",(function(t,e,n){return z(t,e,n)})),a.method("el",(function(t,e,n){h(n)&&(n=this.fn(n)()),this.echo(A(n,(function(n){return z(t,e,n)}),this))})),a.method("each",(function(t,e){f(t)&&(t=this.get(t,[])),B(t,e)}))}}]),t}(),Q=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),o(this,"export",["cache","render","require","helpers","configure","preload","compile","create","__express"]),this.config={},this.scope={},T(this.config,e),function(t,e){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]).forEach((function(n){n in t&&(t[n]=t[n].bind(e))}))}(this,this,this.export),this.context=new H(this.config),this.compiler=new W(this.config),this.cache=new I(this.config),this.template=new L(this.config,this.cache,this.compiler),this.helpers({require:this.require,render:this.render})}return i(t,[{key:"configure",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return T(this.config,t),this.context.configure(this.config,this.scope),this.compiler.configure(this.config),this.cache.configure(this.config),this.template.configure(this.config),this.config}},{key:"output",value:function(t,e){return this.template.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),j)}))}},{key:"render",value:function(t,e){var n=this,r=O(t,this.config.extension),i=this.context.create(e);return this.output(r,i).then((function(t){if(i.getExtend()){i.setExtend(!1);var e=i.getLayout(),r=i.clone();return n.render(e,r)}return t}))}},{key:"require",value:function(t){var e=O(t,this.config.extension),n=this.context.create({});return this.output(e,n).then((function(){return n.getMacro()}))}},{key:"create",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"helpers",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.context.helpers(S(this.scope,t))}},{key:"preload",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.cache.load(t)}},{key:"compile",value:function(t,e){return this.compiler.compile(t,e)}},{key:"__express",value:function(t,e,n){h(e)&&(n=e,e={});var r=S({},(e=e||{}).settings),i=a(f,$.path,r.views),o=a(l,$.cache,r["view cache"]),c=S({},r["view options"]),u=C.relative(i,t);return c.path=i,c.cache=o,this.configure(c),this.render(u,e).then((function(t){n(null,t)})).catch((function(t){n(t)}))}}]),t}(),Z=new Q({}),tt=Z.__express,et=Z.render,nt=Z.context,rt=Z.compile,it=Z.helpers,ot=Z.preload,ct=Z.configure,ut=Z.create;t.EJS=Q,t.__express=tt,t.compile=rt,t.configure=ct,t.context=nt,t.create=ut,t.element=z,t.helpers=it,t.preload=ot,t.render=et,t.safeValue=j}));
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.61",
6
+ "version": "0.0.62",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "browser": "dist/umd/index.js",