@kosatyi/ejs 0.0.51 → 0.0.54
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/element.js +0 -2
- package/dist/cjs/index.js +2 -9
- package/dist/cjs/package.json +3 -0
- package/dist/umd/index.js +0 -2
- package/dist/umd/index.min.js +1 -1
- package/package.json +3 -3
package/dist/cjs/element.js
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var path = require('path');
|
|
6
4
|
var fs = require('fs');
|
|
7
5
|
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
11
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
12
|
-
|
|
13
6
|
var defaults = {};
|
|
14
7
|
defaults["export"] = 'ejsPrecompiled';
|
|
15
8
|
defaults.watch = false;
|
|
@@ -375,7 +368,7 @@ var httpRequest = function httpRequest(path, template) {
|
|
|
375
368
|
};
|
|
376
369
|
var fileSystem = function fileSystem(path, template) {
|
|
377
370
|
return new Promise(function (resolve, reject) {
|
|
378
|
-
|
|
371
|
+
fs.readFile(resolvePath(path, template), function (error, data) {
|
|
379
372
|
if (error) {
|
|
380
373
|
reject(error);
|
|
381
374
|
} else {
|
|
@@ -808,7 +801,7 @@ var create = function create(options) {
|
|
|
808
801
|
var viewPath = typeProp(isString, defaults.path, settings['views']);
|
|
809
802
|
var viewCache = typeProp(isBoolean, defaults.cache, settings['view cache']);
|
|
810
803
|
var viewOptions = extend({}, settings['view options']);
|
|
811
|
-
var filename =
|
|
804
|
+
var filename = path.relative(viewPath, name);
|
|
812
805
|
viewOptions.path = viewPath;
|
|
813
806
|
viewOptions.cache = viewCache;
|
|
814
807
|
configure(viewOptions);
|
package/dist/umd/index.js
CHANGED
package/dist/umd/index.min.js
CHANGED
|
@@ -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";var e={},n={};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,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 r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,u(r.key),r)}}function c(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(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)}n.export="ejsPrecompiled",n.watch=!1,n.path="views",n.resolver=null,n.extension="ejs",n.rmWhitespace=!0,n.withObject=!0,n.vars={SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},n.token={start:"<%",end:"%>",regex:"([\\s\\S]+?)"};var s=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).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(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(b,(function(t){return g[t]}))},k=function(t,e,n){return null==(n=t)?"":e?x(n):n},j=function(t,e){var n=t,r=e.split("."),o=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,o]},E=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},O=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(){},S=function(t,e){var n;for(n in t)R(t,n)&&e(t[n],n,t)},B=function(t,e){return function(t,e,n){var r=t instanceof Array,o=r?[]:{};return S(t,(function(t,n,i){var c=e(t,n,i);!1===p(c)&&(r?o.push(c):o[n]=c)})),o}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},P=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},R=function(t,e){return t&&t.hasOwnProperty(e)},$=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],M=" ",T='"',C="/",U="<",A=">",_=function(t,e,n){var r=[],o=-1===$.indexOf(t),i=function(t,e,n){var r=[];return S(t,(function(t,n,o){var i=e(t,n,o);!1===p(i)&&r.push(i)})),r}(e,(function(t,e){if(null!=t)return[x(e),[T,x(t),T].join("")].join("=")})).join(M);return r.push([U,t,M,i,A].join("")),n&&r.push(n instanceof Array?n.join(""):n),o&&r.push([U,C,t,A].join("")),r.join("")},L=[{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,"('")}}],N=function(){function t(e){o(this,t),this.configure(e)}return c(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]},L.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,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(e,r,o){f+=(""+t.slice(r,o)).replace(w,(function(t){return"\\"+d[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(o,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);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=e,t.source=f,t}return l}}]),t}(),W=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},q=function(t,e){return fetch(W(t,e)).then((function(t){return t.text()}))},D=function(t,n){return new Promise((function(r,o){e.readFile(W(t,n),(function(t,e){t?o(t):r(e.toString())}))}))},K=function(){function t(e,n,r){o(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return c(t,[{key:"configure",value:function(t){var e=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){e.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,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return a(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}(),X=function(t){return Promise.all(t).then((function(t){return t.join("")}))},Y=function(){function t(e){o(this,t),this.configure(e)}return c(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,o=n.LAYOUT,i=n.BLOCKS,c=n.BUFFER,u=n.MACRO,s=n.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({},e||{}),f.define=f.method=function(t,e,n,r,o){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:o||!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(),X(n)},n.error=function(t){throw t},n.end=function(){return X(e)},n}()),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 e=[o,r,c];return!0===t&&e.push(i),B(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer(),e=[].slice.call(arguments);e.forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),a(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=j(this,t),r=n.shift(),o=n.pop();return R(r,o)?r[o]:e})),f.method("set",(function(t,e){var n=j(this,t),r=n.shift(),o=n.pop();return this.getExtend()&&R(r,o)?r[o]:r[o]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),r=this.fn(e),o=this;n[t]=function(){return o.echo(r.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro(),n=e[t],r=[].slice.call(arguments,1);if(a(n))return n.apply(n,r)})),f.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 o=Object.assign([],r[t]),i=function(){return o.shift()};this.echo(i()(function t(){var e=i();return e?function(){n.echo(e(t()))}:F}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),o=O(r,e||{}),i=this.render(t,o);this.echo(i)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(P(n,(function(t){var n=this.getMacro();S(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(P(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return _(t,e,n)})),f.method("el",(function(t,e,n){a(n)&&(n=this.fn(n)()),this.echo(P(n,(function(n){return _(t,e,n)}),this))})),f.method("each",(function(t,e){h(t)&&(t=this.get(t,[])),S(t,e)}))}}]),t}(),V="undefined"!=typeof globalThis?globalThis:window||self,z=function(){function t(e){var n,r,i;o(this,t),n=this,i={},(r=u(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!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,e){return this.list[t]=e,this}}]),t}(),G=function(t,e){O(t,{path:s(h,n.path,t.path,e.path),export:s(h,n.export,t.export,e.export),resolver:s(a,n.resolver,t.resolver,e.resolver),extension:s(h,n.extension,t.extension,e.extension),withObject:s(f,n.withObject,t.withObject,e.withObject),rmWhitespace:s(f,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:s(f,n.watch,t.watch,e.watch),chokidar:s(l,n.export,t.export,e.export),token:O({},n.token,t.token,e.token),vars:O({},n.vars,t.vars,e.vars)})},H=function t(r){var o={},i={};G(o,r||{});var c=new Y(o),u=new N(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,e){return p.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),k)}))},d=function t(e,n){var r=E(e,o.extension),i=c.create(n);return m(r,i).then((function(e){if(i.getExtend()){i.setExtend(!1);var n=i.getLayout(),r=i.clone();return t(n,r)}return e}))},g=function(t){c.helpers(O(i,t||{}))};return g({require:function(t){var e=E(t,o.extension),n=c.create({});return m(e,n).then((function(){return n.getMacro()}))},render:d}),{context:c,render:d,helpers:g,configure:v,compile:function(t,e){return u.compile(t,e)},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,n.path,i.views),u=s(f,n.cache,i["view cache"]),l=O({},i["view options"]),p=e.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,et=I.compile,nt=I.preload,rt=I.__express;t.__express=rt,t.compile=et,t.configure=tt,t.context=J,t.create=H,t.element=_,t.helpers=Z,t.preload=nt,t.render=Q,t.safeValue=k,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
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}));
|
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.54",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"browser": "dist/umd/index.js",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
+
"dist/cjs/package.json",
|
|
26
27
|
"index.d.ts",
|
|
27
28
|
"element.d.ts",
|
|
28
29
|
"global.d.ts"
|
|
@@ -38,8 +39,7 @@
|
|
|
38
39
|
"@babel/core": "^7.20.12",
|
|
39
40
|
"@babel/preset-env": "^7.20.2",
|
|
40
41
|
"@kosatyi/ejs-bundle": "^1.0.8",
|
|
41
|
-
"@kosatyi/
|
|
42
|
-
"@kosatyi/rollup": "^0.0.1"
|
|
42
|
+
"@kosatyi/rollup": "^0.0.15"
|
|
43
43
|
},
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"bugs": {
|