@kosatyi/ejs 0.0.62 → 0.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +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)}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}));
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";var n={},e=function(){var t=[].slice.call(arguments),n=t.shift();return t.filter(n).pop()},r=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},i=function(t){return"boolean"==typeof t},c=function(t){return void 0===t},u="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),s=function(){return u},a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},h=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},l=h(f),p=h(a),d=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(l,(function(t){return f[t]}))},m=function(t){return(""+t).replace(p,(function(t){return"\\"+a[t]}))},v=function(t,n){var e=t;return null==e?"":!0===n?d(e):e},g=function(t,n){return t instanceof n},b=function(t,n,e){for(var o=t,i=String(n).split("."),c=i.pop(),u=0;u<i.length;u++){var s=i[u];if(r(o.toJSON)&&(o=o.toJSON()),e&&!1===o.hasOwnProperty(s)){o={};break}o=o[s]=o[s]||{}}return r(o.toJSON)&&(o=o.toJSON()),[o,c]},w=function(t,n){var e=t.split(".").pop();return e!==n&&(t=[t,n].join(".")),t},x=function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];var r=n.shift();return n.filter((function(t){return t})).reduce((function(t,n){return Object.assign(t,n)}),r)},E=function(){},j=function(t,n){var e;for(e in t)k(t,e)&&n(t[e],e,t)},y=function(t,n){return function(t,n,e){var r=t instanceof Array,o=r?[]:{};return j(t,(function(t,e,i){var u=n(t,e,i);!1===c(u)&&(r?o.push(u):o[e]=u)})),o}(t,(function(t,e){if(-1===n.indexOf(e))return t}))},O=function(t,n,e){return Promise.resolve(t).then(n.bind(e))},k=function(t,n){return t&&t.hasOwnProperty(n)},F={export:"ejsPrecompiled",cache:!0,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]+?)"}},S=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],B=" ",R='"',$="/",P="<",N=">",U=function(t,n,e){var r=[],o=-1===S.indexOf(t),i=function(t,n,e){var r=[];return j(t,(function(t,e,o){var i=n(t,e,o);!1===c(i)&&r.push(i)})),r}(n,(function(t,n){if(null!=t)return[d(n),[R,d(t),R].join("")].join("=")})).join(B);return r.push([P,t,B,i,N].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([P,$,t,N].join("")),r.join("")},A=function(t,n){x(t,{path:e(o,F.path,t.path,n.path),export:e(o,F.export,t.export,n.export),resolver:e(r,F.resolver,t.resolver,n.resolver),extension:e(o,F.extension,t.extension,n.extension),withObject:e(i,F.withObject,t.withObject,n.withObject),rmWhitespace:e(i,F.rmWhitespace,t.rmWhitespace,n.rmWhitespace),cache:e(i,F.watch,t.watch,n.watch),token:x({},F.token,t.token,n.token),vars:x({},F.vars,t.vars,n.vars)})},C=function(t,n){return n=(n=[t,n].join("/")).replace(/\/\//g,"/")},T=function(t,n){return fetch(C(t,n)).then((function(t){return t.text()}))},M=function(t,e){return new Promise((function(r,o){n.readFile(C(t,e),(function(t,n){t?o(t):r(n.toString())}))}))},L=function(t){return r(t)?t:s()?M:T};function W(t,n,e){if(!1===g(this,W))return new W(t,n,e);var o={},i=function(t,e){return n.set(t,e),e},c=function(t){return o.resolver(o.path,t)};this.configure=function(t){o.path=t.path,o.cache=t.cache,o.resolver=L(t.resolver)},this.get=function(t){return n.exist(t)?n.resolve(t):i(t,c(t).then((function(n){return i(t,function(t,n){return r(t)?t:e.compile(t,n)}(n,t))})))},this.configure(t)}var J=[{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,"('")}}];function _(t){if(!1===g(this,_))return new _(t);var n={};this.configure=function(t){n.withObject=t.withObject,n.rmWhitespace=t.rmWhitespace,n.token=t.token,n.vars=t.vars,n.matches=[],n.formats=[],n.slurp={match:"[ \\t]*",start:[n.token.start,"_"],end:["_",n.token.end]},J.forEach((function(t){n.matches.push(n.token.start.concat(t.symbol).concat(n.token.regex).concat(n.token.end)),n.formats.push(t.format.bind(n.vars))})),n.regex=new RegExp(n.matches.join("|").concat("|$"),"g"),n.slurpStart=new RegExp([n.slurp.match,n.slurp.start.join("")].join(""),"gm"),n.slurpEnd=new RegExp([n.slurp.end.join(""),n.slurp.match].join(""),"gm")},this.compile=function(t,e){var r=n.vars,o=r.SCOPE,i=r.SAFE,c=r.BUFFER,u=r.COMPONENT;n.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(n.slurpStart,n.token.start).replace(n.slurpEnd,n.token.end);var s,a,f,h="".concat(c,"('");s=n.regex,a=function(e,r,o){h+=m(t.slice(r,o)),e.forEach((function(t,e){t&&(h+=n.formats[e](t))}))},f=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),n=t.pop(),e=t.shift();return a(t,f,n),f=n+e.length,e})),h="try{".concat(h+="');","}catch(e){console.info(e)}"),n.withObject&&(h="with(".concat(o,"){").concat(h,"}")),h="".concat(c,".start();").concat(h,"return ").concat(c,".end();"),h+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(o,u,c,i,h)).source="(function(".concat(o,",").concat(u,",").concat(c,",").concat(i,"){\n").concat(h,"\n})")}catch(t){throw t.filename=e,t.source=h,t}return l},this.configure(t)}var q="undefined"!=typeof globalThis?globalThis:window||self;function D(t){if(!1===g(this,D))return new D;var n={enabled:!0,list:{}};this.configure=function(t){n.list={},n.enabled=t.cache,!1===s()&&this.load(q[t.export])},this.load=function(t){return n.enabled&&x(n.list,t||{}),this},this.get=function(t){if(n.enabled)return n.list[t]},this.set=function(t,e){return n.enabled&&(n.list[t]=e),this},this.resolve=function(t){return Promise.resolve(this.get(t))},this.remove=function(t){delete n.list[t]},this.exist=function(t){return k(n.list,t)}}function K(t){return Promise.all(t||[]).then((function(t){return t.join("")}))}var X=function(){var t=[],n=[];function e(t){n.push(t)}return e.start=function(){n=[]},e.backup=function(){t.push(n.concat()),n=[]},e.restore=function(){var e=n.concat();return n=t.pop(),K(e)},e.error=function(t){throw t},e.end=function(){return K(n)},e};function Y(t){if(!1===g(this,Y))return new Y(t);this.configure=function(t,n){var e=t.vars,i=e.BLOCKS,c=e.MACRO,u=e.EXTEND,s=e.LAYOUT,a=e.BUFFER,f=e.COMPONENT;function h(t){this[i]={},this[c]={},x(this,t||{})}this.create=function(t){return new h(t)},this.helpers=function(t){x(h.prototype,t||{})},h.prototype=x({},n||{}),h.method=h.define=function(t,n,e,r,o){Object.defineProperty(h.prototype,t,{value:n,writable:e||!1,configurable:r||!1,enumerable:o||!1})},h.define(a,X()),h.define(i,{},!0),h.define(c,{},!0),h.define(s,!1,!0),h.define(u,!1,!0),h.method("getMacro",(function(){return this[c]})),h.method("getBuffer",(function(){return this[a]})),h.method("getComponent",(function(){var t=this;return f in t?function(){return t[f].apply(t,arguments)}:function(){console.log("%s function not defined",f)}})),h.method("getBlocks",(function(){return this[i]})),h.method("setExtend",(function(t){this[u]=t})),h.method("getExtend",(function(){return this[u]})),h.method("setLayout",(function(t){this[s]=t})),h.method("getLayout",(function(){return this[s]})),h.method("clone",(function(t){var n=[s,u,a];return!0===t&&n.push(i),y(this,n)})),h.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),h.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),h.method("fn",(function(t){var n=this.getBuffer(),e=this;return function(){return n.backup(),r(t)&&t.apply(e,arguments),n.restore()}})),h.method("get",(function(t,n){var e=b(this,t,!0),r=e.shift(),o=e.pop();return k(r,o)?r[o]:n})),h.method("set",(function(t,n){var e=b(this,t,!1),r=e.shift(),o=e.pop();return this.getExtend()&&k(r,o)?r[o]:r[o]=n})),h.method("macro",(function(t,n){var e=this.getMacro(),r=this.fn(n),o=this;e[t]=function(){return o.echo(r.apply(void 0,arguments))}})),h.method("call",(function(t){var n=this.getMacro()[t],e=[].slice.call(arguments,1);if(r(n))return n.apply(n,e)})),h.method("block",(function(t,n){var e=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(n)),!this.getExtend()){var o=Object.assign([],r[t]),i=function(){return o.shift()};this.echo(i()(function t(){var n=i();return n?function(){e.echo(n(t()))}:E}()))}})),h.method("include",(function(t,n,e){var r=!1===e?{}:this.clone(!0),o=x(r,n||{}),i=this.render(t,o);this.echo(i)})),h.method("use",(function(t,n){var e=this.require(t);this.echo(O(e,(function(t){var e=this.getMacro();j(t,(function(t,r){e[[n,r].join(".")]=t}))}),this))})),h.method("async",(function(t,n){this.echo(O(t,(function(t){return this.fn(n)(t)}),this))})),h.method("node",(function(t,n,e){return U(t,n,e)})),h.method("el",(function(t,n,e){r(e)&&(e=this.fn(e)()),this.echo(O(e,(function(e){return U(t,n,e)}),this))})),h.method("each",(function(t,n){o(t)&&(t=this.get(t,[])),j(t,n)}))},this.configure(t)}function V(t){if(!1===g(this,V))return new V(t);var n={},e={};A(e,t||{});var r=new Y(e),o=new _(e),i=new D,c=new W(e,i,o),u=function(t,n){return c.get(t).then((function(t){return t.call(n,n,n.getComponent(),n.getBuffer(),v)}))},s=function t(n,o){var i=w(n,e.extension),c=r.create(o);return u(i,c).then((function(n){if(c.getExtend()){c.setExtend(!1);var e=c.getLayout(),r=c.clone();return t(e,r)}return n}))};this.configure=function(t){return A(e,t=t||{}),r.configure(e,n),o.configure(e),i.configure(e),c.configure(e),e},this.render=function(t,n){return s(t,n)},this.helpers=function(t){r.helpers(Object.assign(n,t||{}))},this.preload=function(t){return i.load(t||{})},this.create=function(t){return new V(t)},this.compile=function(t,n){return o.compile(t,n)},this.context=function(t){return r.create(t)},this.helpers({require:function(t){var n=w(t,e.extension),o=r.create({});return u(n,o).then((function(){return o.getMacro()}))},render:s})}var z=new V,G=z.render,H=z.context,I=z.compile,Q=z.helpers,Z=z.preload,tt=z.configure,nt=z.create;t.EJS=V,t.__express=function(t,c,u){r(c)&&(u=c,c={});var s=x({},(c=c||{}).settings),a=e(o,F.path,s.views),f=e(i,F.cache,s["view cache"]),h=x({},s["view options"]),l=n.relative(a,t);return h.path=a,h.cache=f,tt(h),this.render(l,c).then((function(t){u(null,t)})).catch((function(t){u(t)}))},t.compile=I,t.configure=tt,t.context=H,t.create=nt,t.element=U,t.helpers=Q,t.preload=Z,t.render=G,t.safeValue=v}));
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.62",
6
+ "version": "0.0.64",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "browser": "dist/umd/index.js",
@@ -51,6 +51,7 @@
51
51
  ],
52
52
  "dependencies": {
53
53
  "@kosatyi/is-type": "^0.0.5",
54
- "chokidar": "^3.5.3"
54
+ "chokidar": "^3.5.3",
55
+ "ejs": "npm:@kosatyi/ejs@^0.0.62"
55
56
  }
56
57
  }
package/type/global.d.ts DELETED
@@ -1,101 +0,0 @@
1
- declare global {
2
- /**
3
- * extend layout with blocks in current template file
4
- * @param layout
5
- */
6
- function extend(layout: string): any
7
-
8
- /**
9
- * define block with custom **name** and callback
10
- * @param name
11
- * @param [callback]
12
- */
13
- function block(name: string, callback?: Function): any
14
-
15
- /**
16
- * set property in current scope
17
- * @param path
18
- * @param value
19
- */
20
- function set(path: string, value: any): any
21
-
22
- /**
23
- * get property in current scope
24
- * @param path
25
- * @param defaults
26
- */
27
- function get(path: string, defaults?: any): any
28
-
29
- /**
30
- * import macro from file **path** and set to current scope **name** property
31
- * @param path
32
- * @param name
33
- */
34
- function use(path: string, name: string): any
35
-
36
- /**
37
- * define macro function with custom **name**
38
- * @param name
39
- * @param callback
40
- */
41
- function macro(name: string, callback: any): any
42
-
43
- /**
44
- * call macro function
45
- * @param name
46
- * @param props
47
- * @param callback
48
- */
49
- function call(name: string, props?: object, callback?: any): any
50
-
51
- /**
52
- * asynchronous template execution
53
- * @param promise
54
- * @param callback
55
- */
56
- function async(promise: Promise<any>, callback?: any): any
57
-
58
- /**
59
- * asynchronous template execution
60
- * @param callback
61
- */
62
- function fn(callback: Function): any
63
-
64
- /**
65
- *
66
- * @param {string} tag
67
- * @param {object} attrs
68
- * @param {function} content
69
- */
70
- function el(tag: string, attrs?: object, content?: any): any
71
-
72
- /**
73
- * buffer output
74
- * @param args
75
- */
76
- function echo(...args: any[]): any
77
-
78
- /**
79
- * append rendered template from file
80
- * @param path
81
- * @param data
82
- * @param cx
83
- */
84
- function include(path: string, data?: object, cx?: boolean): any
85
-
86
- /**
87
- *
88
- * @param value
89
- * @param callback
90
- */
91
- function each(value: any, callback: Function): any
92
-
93
- /**
94
- * define block with custom **name** and callback
95
- * @param {string} name
96
- * @param {object} [props]
97
- */
98
- function ui(name: string, props?: object): any
99
- }
100
-
101
- export = global
package/type/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import * as ejs from './global'
2
-
3
- export as namespace ejs
4
-
5
- export = ejs