@kosatyi/ejs 0.0.54 → 0.0.55
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/README.md +1 -1
- package/dist/cjs/index.js +298 -264
- package/dist/esm/index.js +289 -290
- package/dist/umd/element.js +92 -0
- package/dist/umd/element.min.js +1 -0
- package/dist/umd/index.js +812 -778
- package/dist/umd/index.min.js +1 -1
- package/package.json +7 -8
- package/{global.d.ts → type/global.d.ts} +1 -48
- package/element.d.ts +0 -11
- /package/{index.d.ts → type/index.d.ts} +0 -0
package/dist/umd/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 r(t){return r="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},r(t)}function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function i(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,u(r.key),r)}}function c(t,n,e){return n&&i(t.prototype,n),e&&i(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t){var n=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==typeof n?n:String(n)}e.export="ejsPrecompiled",e.watch=!1,e.path="views",e.resolver=null,e.extension="ejs",e.rmWhitespace=!0,e.withObject=!0,e.vars={SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},e.token={start:"<%",end:"%>",regex:"([\\s\\S]+?)"};var s=function(){var t=[].slice.call(arguments),n=t.shift();return t.filter(n).pop()},a=function(t){return"function"==typeof t},h=function(t){return"string"==typeof t},f=function(t){return"boolean"==typeof t},l=function(t){return"object"===r(t)},p=function(t){return void 0===t},v="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),m=function(){return v},d={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},g={"&":"&","<":"<",">":">",'"':""","'":"'"},y=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},b=y(g),w=y(d),x=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(b,(function(t){return g[t]}))},k=function(t,n,e){return null==(e=t)?"":n?x(e):e},j=function(t,n){var e=t,r=n.split("."),o=r.pop();return r.forEach((function(t){e=e[t]=e[t]||{}})),[e,o]},E=function(t,n){var e=t.split(".").pop();return e!==n&&(t=[t,n].join(".")),t},O=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)},F=function(){},S=function(t,n){var e;for(e in t)R(t,e)&&n(t[e],e,t)},B=function(t,n){return function(t,n,e){var r=t instanceof Array,o=r?[]:{};return S(t,(function(t,e,i){var c=n(t,e,i);!1===p(c)&&(r?o.push(c):o[e]=c)})),o}(t,(function(t,e){if(-1===n.indexOf(e))return t}))},P=function(t,n,e){return Promise.resolve(t).then(n.bind(e))},R=function(t,n){return t&&t.hasOwnProperty(n)},$=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],T=" ",C='"',M="/",U="<",A=">",L=function(t,n,e){var r=[],o=-1===$.indexOf(t),i=function(t,n,e){var r=[];return S(t,(function(t,e,o){var i=n(t,e,o);!1===p(i)&&r.push(i)})),r}(n,(function(t,n){if(null!=t)return[x(n),[C,x(t),C].join("")].join("=")})).join(T);return r.push([U,t,T,i,A].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([U,M,t,A].join("")),r.join("")},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(n){o(this,t),this.configure(n)}return c(t,[{key:"configure",value:function(t){var n=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){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))})),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,n){var e=this,r=this.vars,o=r.SCOPE,i=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(n,r,o){f+=(""+t.slice(r,o)).replace(w,(function(t){return"\\"+d[t]})),n.forEach((function(t,n){t&&(f+=e.formats[n](t))}))},h=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),n=t.pop(),e=t.shift();return a(t,h,n),h=n+e.length,e})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(o,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(n);var l=null;try{(l=new Function(o,u,c,i,f)).source="(function(".concat(o,",").concat(u,",").concat(c,",").concat(i,"){\n").concat(f,"\n})")}catch(t){throw t.filename=n,t.source=f,t}return l}}]),t}(),_=function(t,n){return n=(n=[t,n].join("/")).replace(/\/\//g,"/")},q=function(t,n){return fetch(_(t,n)).then((function(t){return t.text()}))},D=function(t,e){return new Promise((function(r,o){n.readFile(_(t,e),(function(t,n){t?o(t):r(n.toString())}))}))},K=function(){function t(n,e,r){o(this,t),this.cache=e,this.watcher=null,this.compiler=r,this.configure(n)}return c(t,[{key:"configure",value:function(t){var n=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=a(t.resolver)?t.resolver:m()?D:q,t.watch&&t.chokidar&&m()&&(this.watcher&&this.watcher.unwatch("."),this.watcher=this.chokidar.watch(".",{cwd:this.path}).on("change",(function(t){n.cache.remove(t)})).on("error",(function(t){console.log("watcher error: "+t)})))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,n){return this.cache.set(t,n),n}},{key:"compile",value:function(t,n){return a(t)?t:this.compiler.compile(t,n)}},{key:"get",value:function(t){var n=this;if(this.cache.exist(t))return this.cache.resolve(t);var e=this.resolve(t).then((function(e){return n.result(t,n.compile(e,t))}));return this.result(t,e)}}]),t}(),X=function(t){return Promise.all(t).then((function(t){return t.join("")}))},Y=function(){function t(n){o(this,t),this.configure(n)}return c(t,[{key:"configure",value:function(t,n){var e=t.vars,r=e.EXTEND,o=e.LAYOUT,i=e.BLOCKS,c=e.BUFFER,u=e.MACRO,s=e.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),O(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){O(f.prototype,t)},f.prototype=O({},n||{}),f.define=f.method=function(t,n,e,r,o){return Object.defineProperty(f.prototype,t,{value:n,writable:e||!1,configurable:r||!1,enumerable:o||!1})},f.define(c,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(),X(e)},e.error=function(t){throw t},e.end=function(){return X(n)},e}()),f.define(i,{},!0),f.define(u,{},!0),f.define(o,!1,!0),f.define(r,!1,!0),f.method("initBlocks",(function(){this[i]={}})),f.method("initMacro",(function(){this[u]={}})),f.method("getMacro",(function(){return this[u]})),f.method("getBuffer",(function(){return this[c]})),f.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)}})),f.method("getBlocks",(function(){return this[i]})),f.method("setExtend",(function(t){this[r]=t})),f.method("getExtend",(function(){return this[r]})),f.method("setLayout",(function(t){this[o]=t})),f.method("getLayout",(function(){return this[o]})),f.method("clone",(function(t){var n=[o,r,c];return!0===t&&n.push(i),B(this,n)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),f.method("fn",(function(t){var n=this.getBuffer(),e=this;return function(){return n.backup(),a(t)&&t.apply(e,arguments),n.restore()}})),f.method("get",(function(t,n){var e=j(this,t),r=e.shift(),o=e.pop();return R(r,o)?r[o]:n})),f.method("set",(function(t,n){var e=j(this,t),r=e.shift(),o=e.pop();return this.getExtend()&&R(r,o)?r[o]:r[o]=n})),f.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))}})),f.method("call",(function(t){var n=this.getMacro()[t],e=[].slice.call(arguments,1);if(a(n))return n.apply(n,e)})),f.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()))}:F}()))}})),f.method("include",(function(t,n,e){var r=!1===e?{}:this.clone(!0),o=O(r,n||{}),i=this.render(t,o);this.echo(i)})),f.method("use",(function(t,n){var e=this.require(t);this.echo(P(e,(function(t){var e=this.getMacro();S(t,(function(t,r){e[[n,r].join(".")]=t}))}),this))})),f.method("async",(function(t,n){this.echo(P(t,(function(t){return this.fn(n)(t)}),this))})),f.method("node",(function(t,n,e){return L(t,n,e)})),f.method("el",(function(t,n,e){a(e)&&(e=this.fn(e)()),this.echo(P(e,(function(e){return L(t,n,e)}),this))})),f.method("each",(function(t,n){h(t)&&(t=this.get(t,[])),S(t,n)}))}}]),t}(),V="undefined"!=typeof globalThis?globalThis:window||self,z=function(){function t(n){var e,r,i;o(this,t),e=this,i={},(r=u(r="list"))in e?Object.defineProperty(e,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[r]=i,this.configure(n),!1===m()&&this.load(V[this.namespace])}return c(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return O(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,n){return this.list[t]=n,this}}]),t}(),G=function(t,n){O(t,{path:s(h,e.path,t.path,n.path),export:s(h,e.export,t.export,n.export),resolver:s(a,e.resolver,t.resolver,n.resolver),extension:s(h,e.extension,t.extension,n.extension),withObject:s(f,e.withObject,t.withObject,n.withObject),rmWhitespace:s(f,e.rmWhitespace,t.rmWhitespace,n.rmWhitespace),watch:s(f,e.watch,t.watch,n.watch),chokidar:s(l,e.export,t.export,n.export),token:O({},e.token,t.token,n.token),vars:O({},e.vars,t.vars,n.vars)})},H=function t(r){var o={},i={};G(o,r||{});var c=new Y(o),u=new W(o),l=new z(o),p=new K(o,l,u),v=function(t){return G(o,t),c.configure(o,i),u.configure(o),l.configure(o),p.configure(o),o},m=function(t,n){return p.get(t).then((function(t){return t.call(n,n,n.getComponent(),n.getBuffer(),k)}))},d=function t(n,e){var r=E(n,o.extension),i=c.create(e);return m(r,i).then((function(n){if(i.getExtend()){i.setExtend(!1);var e=i.getLayout(),r=i.clone();return t(e,r)}return n}))},g=function(t){c.helpers(O(i,t||{}))};return g({require:function(t){var n=E(t,o.extension),e=c.create({});return m(n,e).then((function(){return e.getMacro()}))},render:d}),{context:c,render:d,helpers:g,configure:v,compile:function(t,n){return u.compile(t,n)},create:t,preload:function(t){return l.load(t)},__express:function(t,r,o){a(r)&&(o=r,r={});var i=O({},(r=r||{}).settings),c=s(h,e.path,i.views),u=s(f,e.cache,i["view cache"]),l=O({},i["view options"]),p=n.relative(c,t);return l.path=c,l.cache=u,v(l),d(p,r).then((function(t){o(null,t)})).catch((function(t){o(t)}))}}},I=H({}),J=I.context,Q=I.render,Z=I.helpers,tt=I.configure,nt=I.compile,et=I.preload,rt=I.__express;t.__express=rt,t.compile=nt,t.configure=tt,t.context=J,t.create=H,t.element=L,t.helpers=Z,t.preload=et,t.render=Q,t.safeValue=k}));
|
|
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 i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,o(i.key),i)}}function r(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;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 c=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},u=function(t){return"function"==typeof t},s=function(t){return"string"==typeof t},h=function(t){return"boolean"==typeof t},a=function(t){return"object"===e(t)},f=function(t){return void 0===t},l="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),p=function(){return l},v={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},d={"&":"&","<":"<",">":">",'"':""","'":"'"},m=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},g=m(d),y=m(v),b=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(g,(function(t){return d[t]}))},k=function(t,e,n){return null==(n=t)?"":e?b(n):n},w=function(t,e){var n=t,i=e.split("."),r=i.pop();return i.forEach((function(t){n=n[t]=n[t]||{}})),[n,r]},x=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},j=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),i)},E=function(){},O=function(t,e){var n;for(n in t)B(t,n)&&e(t[n],n,t)},F=function(t,e){return function(t,e,n){var i=t instanceof Array,r=i?[]:{};return O(t,(function(t,n,o){var c=e(t,n,o);!1===f(c)&&(i?r.push(c):r[n]=c)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},S=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},B=function(t,e){return t&&t.hasOwnProperty(e)},P={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]+?)"}},R=function(t,e){j(t,{path:c(s,P.path,t.path,e.path),export:c(s,P.export,t.export,e.export),resolver:c(u,P.resolver,t.resolver,e.resolver),extension:c(s,P.extension,t.extension,e.extension),withObject:c(h,P.withObject,t.withObject,e.withObject),rmWhitespace:c(h,P.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:c(h,P.watch,t.watch,e.watch),chokidar:c(a,P.export,t.export,e.export),token:j({},P.token,t.token,e.token),vars:j({},P.vars,t.vars,e.vars)})},$={},T=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},C=function(t,e){return fetch(T(t,e)).then((function(t){return t.text()}))},M=function(t,e){return new Promise((function(n,i){$.readFile(T(t,e),(function(t,e){t?i(t):n(e.toString())}))}))},U=function(){function t(e,i,r){n(this,t),this.cache=i,this.watcher={unwatch:function(){},on:function(){}},this.compiler=r,this.configure(e)}return r(t,[{key:"configure",value:function(t){var e=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=u(t.resolver)?t.resolver:p()?M:C,t.watch&&p()&&(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 u(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}(),A=[{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,"('")}}],L=function(){function t(e){n(this,t),this.configure(e)}return r(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]},A.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,i=this.vars,r=i.SCOPE,o=i.SAFE,c=i.BUFFER,u=i.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,h,a,f="".concat(c,"('");s=this.regex,h=function(e,i,r){f+=(""+t.slice(i,r)).replace(y,(function(t){return"\\"+v[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},a=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return h(t,a,e),a=e+n.length,n})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(r,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(r,u,c,o,f)).source="(function(".concat(r,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),N="undefined"!=typeof globalThis?globalThis:window||self,W=function(){function t(e){var i,r,c;n(this,t),i=this,c={},(r=o(r="list"))in i?Object.defineProperty(i,r,{value:c,enumerable:!0,configurable:!0,writable:!0}):i[r]=c,this.configure(e),!1===p()&&this.load(N[this.namespace])}return r(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return j(this.list,t),this}},{key:"exist",value:function(t){return B(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}(),_=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],q=" ",D='"',K="/",X="<",Y=">",J=function(t,e,n){var i=[],r=-1===_.indexOf(t),o=function(t,e,n){var i=[];return O(t,(function(t,n,r){var o=e(t,n,r);!1===f(o)&&i.push(o)})),i}(e,(function(t,e){if(null!=t)return[b(e),[D,b(t),D].join("")].join("=")})).join(q);return i.push([X,t,q,o,Y].join("")),n&&i.push(n instanceof Array?n.join(""):n),r&&i.push([X,K,t,Y].join("")),i.join("")},V=function(t){return Promise.all(t).then((function(t){return t.join("")}))},z=function(){function t(e){n(this,t),this.configure(e)}return r(t,[{key:"configure",value:function(t,e){var n=t.vars,i=n.EXTEND,r=n.LAYOUT,o=n.BLOCKS,c=n.BUFFER,h=n.MACRO,a=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),j(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){j(f.prototype,t)},f.prototype=j({},e||{}),f.define=f.method=function(t,e,n,i,r){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:i||!1,enumerable:r||!1})},f.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(),V(n)},n.error=function(t){throw t},n.end=function(){return V(e)},n}()),f.define(o,{},!0),f.define(h,{},!0),f.define(r,!1,!0),f.define(i,!1,!0),f.method("initBlocks",(function(){this[o]={}})),f.method("initMacro",(function(){this[h]={}})),f.method("getMacro",(function(){return this[h]})),f.method("getBuffer",(function(){return this[c]})),f.method("getComponent",(function(){var t=this;return a in t?function(){return t[a].apply(t,arguments)}:function(){console.log("%s function not defined",a)}})),f.method("getBlocks",(function(){return this[o]})),f.method("setExtend",(function(t){this[i]=t})),f.method("getExtend",(function(){return this[i]})),f.method("setLayout",(function(t){this[r]=t})),f.method("getLayout",(function(){return this[r]})),f.method("clone",(function(t){var e=[r,i,c];return!0===t&&e.push(o),F(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),u(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=w(this,t),i=n.shift(),r=n.pop();return B(i,r)?i[r]:e})),f.method("set",(function(t,e){var n=w(this,t),i=n.shift(),r=n.pop();return this.getExtend()&&B(i,r)?i[r]:i[r]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),i=this.fn(e),r=this;n[t]=function(){return r.echo(i.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(u(e))return e.apply(e,n)})),f.method("block",(function(t,e){var n=this,i=this.getBlocks();if(i[t]=i[t]||[],i[t].push(this.fn(e)),!this.getExtend()){var r=Object.assign([],i[t]),o=function(){return r.shift()};this.echo(o()(function t(){var e=o();return e?function(){n.echo(e(t()))}:E}()))}})),f.method("include",(function(t,e,n){var i=!1===n?{}:this.clone(!0),r=j(i,e||{}),o=this.render(t,r);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(S(n,(function(t){var n=this.getMacro();O(t,(function(t,i){n[[e,i].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(S(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return J(t,e,n)})),f.method("el",(function(t,e,n){u(n)&&(n=this.fn(n)()),this.echo(S(n,(function(n){return J(t,e,n)}),this))})),f.method("each",(function(t,e){s(t)&&(t=this.get(t,[])),O(t,e)}))}}]),t}(),G=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),this.config={},this.scope={},R(this.config,e),this.context=new z(this.config),this.compiler=new L(this.config),this.cache=new W(this.config),this.template=new U(this.config,this.cache,this.compiler);var i=this.render.bind(this),r=this.require.bind(this);this.helpers({require:r,render:i})}return r(t,[{key:"configure",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return R(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(),k)}))}},{key:"render",value:function(t,e){var n=this,i=x(t,this.config.extension),r=this.context.create(e);return this.output(i,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),i=r.clone();return n.render(e,i)}return t}))}},{key:"require",value:function(t){var e=x(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(j(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){u(e)&&(n=e,e={});var i=j({},(e=e||{}).settings),r=c(s,P.path,i.views),o=c(h,P.cache,i["view cache"]),a=j({},i["view options"]),f=$.relative(r,t);return a.path=r,a.cache=o,this.configure(a),this.render(f,e).then((function(t){n(null,t)})).catch((function(t){n(t)}))}}]),t}(),H=new G({}),I=H.__express,Q=H.render,Z=H.context,tt=H.compile,et=H.helpers,nt=H.preload,it=H.configure,rt=H.create;t.EJS=G,t.__express=I,t.compile=tt,t.configure=it,t.context=Z,t.create=rt,t.element=J,t.helpers=et,t.preload=nt,t.render=Q,t.safeValue=k}));
|
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.
|
|
6
|
+
"version": "0.0.55",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"browser": "dist/umd/index.js",
|
|
@@ -11,22 +11,17 @@
|
|
|
11
11
|
"author": "Stepan Kosatyi (https://kosatyi.com)",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./index.d.ts",
|
|
15
14
|
"import": "./dist/esm/index.js",
|
|
16
15
|
"require": "./dist/cjs/index.js"
|
|
17
16
|
},
|
|
18
17
|
"./element": {
|
|
19
|
-
"types": "./element.d.ts",
|
|
20
18
|
"import": "./dist/esm/element.js",
|
|
21
19
|
"require": "./dist/cjs/element.js"
|
|
22
20
|
}
|
|
23
21
|
},
|
|
24
22
|
"files": [
|
|
25
23
|
"dist",
|
|
26
|
-
"
|
|
27
|
-
"index.d.ts",
|
|
28
|
-
"element.d.ts",
|
|
29
|
-
"global.d.ts"
|
|
24
|
+
"type"
|
|
30
25
|
],
|
|
31
26
|
"scripts": {
|
|
32
27
|
"build": "rollup -c",
|
|
@@ -53,5 +48,9 @@
|
|
|
53
48
|
"ejs",
|
|
54
49
|
"template-engine",
|
|
55
50
|
"nodejs"
|
|
56
|
-
]
|
|
51
|
+
],
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@kosatyi/is-type": "^0.0.5",
|
|
54
|
+
"chokidar": "^3.5.3"
|
|
55
|
+
}
|
|
57
56
|
}
|
|
@@ -1,51 +1,4 @@
|
|
|
1
|
-
declare function expressCallback(
|
|
2
|
-
error: null | object,
|
|
3
|
-
content: string
|
|
4
|
-
): undefined
|
|
5
|
-
|
|
6
1
|
declare global {
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export const context: any
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param name
|
|
15
|
-
* @param options
|
|
16
|
-
* @param callback
|
|
17
|
-
*/
|
|
18
|
-
export function __express(
|
|
19
|
-
name: string,
|
|
20
|
-
options: object,
|
|
21
|
-
callback: typeof expressCallback
|
|
22
|
-
): Promise<any>
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param name
|
|
27
|
-
* @param data
|
|
28
|
-
*/
|
|
29
|
-
export function render(name: string, data: object): Promise<any>
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param options
|
|
34
|
-
*/
|
|
35
|
-
export function configure(options: object): object
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param methods
|
|
40
|
-
*/
|
|
41
|
-
export function helpers(methods: object): any
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param list
|
|
46
|
-
*/
|
|
47
|
-
export function preload(list: object): any
|
|
48
|
-
|
|
49
2
|
/**
|
|
50
3
|
* extend layout with blocks in current template file
|
|
51
4
|
* @param layout
|
|
@@ -57,7 +10,7 @@ declare global {
|
|
|
57
10
|
* @param name
|
|
58
11
|
* @param [callback]
|
|
59
12
|
*/
|
|
60
|
-
function block(name: string, callback
|
|
13
|
+
function block(name: string, callback?: Function): any
|
|
61
14
|
|
|
62
15
|
/**
|
|
63
16
|
* set property in current scope
|
package/element.d.ts
DELETED
|
File without changes
|