@kosatyi/ejs 0.0.33 → 0.0.34
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/ejs.cjs +0 -40
- package/dist/ejs.js +0 -40
- package/dist/ejs.min.js +1 -1
- package/dist/ejs.mjs +0 -36
- package/package.json +1 -1
package/dist/ejs.cjs
CHANGED
|
@@ -348,40 +348,6 @@ var Compiler = /*#__PURE__*/function () {
|
|
|
348
348
|
return Compiler;
|
|
349
349
|
}();
|
|
350
350
|
|
|
351
|
-
var Bundler = /*#__PURE__*/function () {
|
|
352
|
-
function Bundler(config) {
|
|
353
|
-
_classCallCheck(this, Bundler);
|
|
354
|
-
this.configure(config);
|
|
355
|
-
}
|
|
356
|
-
_createClass(Bundler, [{
|
|
357
|
-
key: "configure",
|
|
358
|
-
value: function configure(config) {
|
|
359
|
-
this.namespace = config["export"];
|
|
360
|
-
this.useStrict = config.withObject === false;
|
|
361
|
-
}
|
|
362
|
-
}, {
|
|
363
|
-
key: "wrapper",
|
|
364
|
-
value: function wrapper(list) {
|
|
365
|
-
var out = '';
|
|
366
|
-
out += '(function(global,factory){';
|
|
367
|
-
out += 'typeof exports === "object" && typeof module !== "undefined" ?';
|
|
368
|
-
out += 'module.exports = factory():';
|
|
369
|
-
out += 'typeof define === "function" && define.amd ? define(factory):';
|
|
370
|
-
out += '(global = typeof globalThis !== "undefined" ? globalThis:';
|
|
371
|
-
out += 'global || self,global["' + this.namespace + '"] = factory())';
|
|
372
|
-
out += '})(this,(function(){';
|
|
373
|
-
if (this.useStrict) out += "'use strict';\n";
|
|
374
|
-
out += 'var list = {};\n';
|
|
375
|
-
list.forEach(function (item) {
|
|
376
|
-
out += 'list[' + JSON.stringify(item.name) + ']=' + String(item.content) + ';\n';
|
|
377
|
-
});
|
|
378
|
-
out += 'return list;}));\n';
|
|
379
|
-
return out;
|
|
380
|
-
}
|
|
381
|
-
}]);
|
|
382
|
-
return Bundler;
|
|
383
|
-
}();
|
|
384
|
-
|
|
385
351
|
var resolvePath = function resolvePath(path, template) {
|
|
386
352
|
template = [path, template].join('/');
|
|
387
353
|
template = template.replace(/\/\//g, '/');
|
|
@@ -769,14 +735,12 @@ var init = function init(options) {
|
|
|
769
735
|
configSchema(config, options || {});
|
|
770
736
|
var context = new Context(config);
|
|
771
737
|
var compiler = new Compiler(config);
|
|
772
|
-
var bundler = new Bundler(config);
|
|
773
738
|
var cache = new Cache(config);
|
|
774
739
|
var template = new Template(config, cache, compiler);
|
|
775
740
|
var configure = function configure(options) {
|
|
776
741
|
configSchema(config, options);
|
|
777
742
|
context.configure(config, scope);
|
|
778
743
|
compiler.configure(config);
|
|
779
|
-
bundler.configure(config);
|
|
780
744
|
cache.configure(config);
|
|
781
745
|
template.configure(config);
|
|
782
746
|
return config;
|
|
@@ -832,9 +796,6 @@ var init = function init(options) {
|
|
|
832
796
|
var preload = function preload(list) {
|
|
833
797
|
return cache.load(list);
|
|
834
798
|
};
|
|
835
|
-
var wrapper = function wrapper(list) {
|
|
836
|
-
return bundler.wrapper(list);
|
|
837
|
-
};
|
|
838
799
|
var compile = function compile(content, path) {
|
|
839
800
|
return compiler.compile(content, path);
|
|
840
801
|
};
|
|
@@ -853,7 +814,6 @@ var init = function init(options) {
|
|
|
853
814
|
render: _render,
|
|
854
815
|
helpers: helpers,
|
|
855
816
|
configure: configure,
|
|
856
|
-
wrapper: wrapper,
|
|
857
817
|
compile: compile,
|
|
858
818
|
create: create,
|
|
859
819
|
preload: preload,
|
package/dist/ejs.js
CHANGED
|
@@ -342,40 +342,6 @@
|
|
|
342
342
|
return Compiler;
|
|
343
343
|
}();
|
|
344
344
|
|
|
345
|
-
var Bundler = /*#__PURE__*/function () {
|
|
346
|
-
function Bundler(config) {
|
|
347
|
-
_classCallCheck(this, Bundler);
|
|
348
|
-
this.configure(config);
|
|
349
|
-
}
|
|
350
|
-
_createClass(Bundler, [{
|
|
351
|
-
key: "configure",
|
|
352
|
-
value: function configure(config) {
|
|
353
|
-
this.namespace = config["export"];
|
|
354
|
-
this.useStrict = config.withObject === false;
|
|
355
|
-
}
|
|
356
|
-
}, {
|
|
357
|
-
key: "wrapper",
|
|
358
|
-
value: function wrapper(list) {
|
|
359
|
-
var out = '';
|
|
360
|
-
out += '(function(global,factory){';
|
|
361
|
-
out += 'typeof exports === "object" && typeof module !== "undefined" ?';
|
|
362
|
-
out += 'module.exports = factory():';
|
|
363
|
-
out += 'typeof define === "function" && define.amd ? define(factory):';
|
|
364
|
-
out += '(global = typeof globalThis !== "undefined" ? globalThis:';
|
|
365
|
-
out += 'global || self,global["' + this.namespace + '"] = factory())';
|
|
366
|
-
out += '})(this,(function(){';
|
|
367
|
-
if (this.useStrict) out += "'use strict';\n";
|
|
368
|
-
out += 'var list = {};\n';
|
|
369
|
-
list.forEach(function (item) {
|
|
370
|
-
out += 'list[' + JSON.stringify(item.name) + ']=' + String(item.content) + ';\n';
|
|
371
|
-
});
|
|
372
|
-
out += 'return list;}));\n';
|
|
373
|
-
return out;
|
|
374
|
-
}
|
|
375
|
-
}]);
|
|
376
|
-
return Bundler;
|
|
377
|
-
}();
|
|
378
|
-
|
|
379
345
|
var resolvePath = function resolvePath(path, template) {
|
|
380
346
|
template = [path, template].join('/');
|
|
381
347
|
template = template.replace(/\/\//g, '/');
|
|
@@ -763,14 +729,12 @@
|
|
|
763
729
|
configSchema(config, options || {});
|
|
764
730
|
var context = new Context(config);
|
|
765
731
|
var compiler = new Compiler(config);
|
|
766
|
-
var bundler = new Bundler(config);
|
|
767
732
|
var cache = new Cache(config);
|
|
768
733
|
var template = new Template(config, cache, compiler);
|
|
769
734
|
var configure = function configure(options) {
|
|
770
735
|
configSchema(config, options);
|
|
771
736
|
context.configure(config, scope);
|
|
772
737
|
compiler.configure(config);
|
|
773
|
-
bundler.configure(config);
|
|
774
738
|
cache.configure(config);
|
|
775
739
|
template.configure(config);
|
|
776
740
|
return config;
|
|
@@ -826,9 +790,6 @@
|
|
|
826
790
|
var preload = function preload(list) {
|
|
827
791
|
return cache.load(list);
|
|
828
792
|
};
|
|
829
|
-
var wrapper = function wrapper(list) {
|
|
830
|
-
return bundler.wrapper(list);
|
|
831
|
-
};
|
|
832
793
|
var compile = function compile(content, path) {
|
|
833
794
|
return compiler.compile(content, path);
|
|
834
795
|
};
|
|
@@ -847,7 +808,6 @@
|
|
|
847
808
|
render: _render,
|
|
848
809
|
helpers: helpers,
|
|
849
810
|
configure: configure,
|
|
850
|
-
wrapper: wrapper,
|
|
851
811
|
compile: compile,
|
|
852
812
|
create: create,
|
|
853
813
|
preload: preload,
|
package/dist/ejs.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={export:"ejsPrecompiled",cache:!0,path:"views",resolver:null,extension:"ejs",rmWhitespace:!0,withObject:!1,vars:{SCOPE:"ejs",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},r=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},i=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},c=function(t){return"boolean"==typeof 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={"&":"&","<":"<",">":">",'"':""","'":"'"},h=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},l=h(f),p=h(a),v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(l,(function(t){return f[t]}))},d=function(t,e,n){return null==(n=t)?"":e?v(n):n},m=function(t,e){var n=t,r=e.split("."),i=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,i]},g=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},y=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)},b=function(){},w=function(t,e){var n;for(n in t)k(t,n)&&e(t[n],n,t)},j=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return w(t,(function(t,n,o){var c=e(t,n,o);void 0!==c&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},x=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},k=function(t,e){return t&&t.hasOwnProperty(e)},E=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],O=" ",F='"',P="/",S="<",B=">",R=function(t,e,n){var r=[],i=-1===E.indexOf(t),o=function(t,e,n){var r=[];return w(t,(function(t,n,i){var o=e(t,n,i);void 0!==o&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[v(e),[F,v(t),F].join("")].join("=")})).join(O);return r.push([S,t,O,o,B].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([S,P,t,B].join("")),r.join("")};function $(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function T(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,A(r.key),r)}}function U(t,e,n){return e&&T(t.prototype,e),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function A(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 M=[{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(){function t(e){$(this,t),this.configure(e)}return U(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]},M.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;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 u,s,f,h="".concat(c,"('");u=this.regex,s=function(e,r,i){h+=(""+t.slice(r,i)).replace(p,(function(t){return"\\"+a[t]})),e.forEach((function(t,e){t&&(h+=n.formats[e](t))}))},f=0,t.replace(u,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return s(t,f,e),f=e+n.length,n})),h="try{".concat(h+="');","}catch(e){console.info(e)}"),this.withObject&&(h="with(".concat(i,"){").concat(h,"}")),h="".concat(c,".start();").concat(h,"return ").concat(c,".end();"),h+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(i,c,o,h)).source="(function(".concat(i,",").concat(c,",").concat(o,"){\n").concat(h,"\n})")}catch(t){throw t.filename=e,t.source=h,t}return l}}]),t}(),L=function(){function t(e){$(this,t),this.configure(e)}return U(t,[{key:"configure",value:function(t){this.namespace=t.export,this.useStrict=!1===t.withObject}},{key:"wrapper",value:function(t){var e="";return e+="(function(global,factory){",e+='typeof exports === "object" && typeof module !== "undefined" ?',e+="module.exports = factory():",e+='typeof define === "function" && define.amd ? define(factory):',e+='(global = typeof globalThis !== "undefined" ? globalThis:',e+='global || self,global["'+this.namespace+'"] = factory())',e+="})(this,(function(){",this.useStrict&&(e+="'use strict';\n"),e+="var list = {};\n",t.forEach((function(t){e+="list["+JSON.stringify(t.name)+"]="+String(t.content)+";\n"})),e+="return list;}));\n"}}]),t}(),W=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},C=function(t,e){return fetch(W(t,e)).then((function(t){return t.text()}))},N=function(t,n){return new Promise((function(r,i){e.readFile(W(t,n),(function(t,e){t?i(t):r(e.toString())}))}))},q=function(){function t(e,n,r){$(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return U(t,[{key:"configure",value:function(t){var n,r,o;this.path=t.path,this.resolver=i(t.resolver)?t.resolver:s()?N:C,(n=this.watcher)&&n.unwatch("."),t.watch&&s()&&(this.watcher=(r=this.cache,o=this.path,e.watch(".",{cwd:r}).on("change",(function(t){o.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 i(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}(),D=function(t){return Promise.all(t).then((function(t){return t.join("")}))},K=function(){function t(e){$(this,t),this.configure(e)}return U(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,c=n.LAYOUT,u=n.BLOCKS,s=n.BUFFER,a=n.MACRO;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),y(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){y(f.prototype,t)},f.prototype=y({},e||{}),f.defineProp=f.method=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Object.defineProperty(f.prototype,t,{value:e,writable:n,configurable:r,enumerable:i})},f.defineProp(s,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(),D(n)},n.error=function(t){throw t},n.end=function(){return D(e)},n}()),f.defineProp(u,{},!0),f.defineProp(a,{},!0),f.defineProp(c,!1,!0),f.defineProp(r,!1,!0),f.method("initBlocks",(function(){this[u]={}})),f.method("initMacro",(function(){this[a]={}})),f.method("getMacro",(function(){return this[a]})),f.method("getBuffer",(function(){return this[s]})),f.method("getBlocks",(function(){return this[u]})),f.method("setExtend",(function(t){this[r]=t})),f.method("getExtend",(function(){return this[r]})),f.method("setLayout",(function(t){this[c]=t})),f.method("getLayout",(function(){return this[c]})),f.method("clone",(function(t){var e=[c,r,s];return!0===t&&e.push(u),j(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(),i(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=m(this,t),r=n.shift(),i=n.pop();return k(r,i)?r[i]:e})),f.method("set",(function(t,e){var n=m(this,t),r=n.shift(),i=n.pop();return this.getExtend()&&k(r,i)?r[i]:r[i]=e})),f.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))}})),f.method("call",(function(t){var e=this.getMacro(),n=e[t],r=[].slice.call(arguments,1);if(i(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 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()))}:b}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=y(r,e||{}),o=this.render(t,i);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(x(n,(function(t){var n=this.getMacro();w(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(x(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return R(t,e,n)})),f.method("el",(function(t,e,n){i(n)&&(n=this.fn(n)()),this.echo(x(n,(function(n){return R(t,e,n)}),this))})),f.method("each",(function(t,e){o(t)&&(t=this.get(t,[])),w(t,e)}))}}]),t}(),X="undefined"!=typeof globalThis?globalThis:window||self,Y=function(){function t(e){var n,r,i;$(this,t),n=this,i={},(r=A(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!1===s()&&this.load(X[this.namespace])}return U(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return y(this.list,t),this}},{key:"exist",value:function(t){return k(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}(),J=function(t,e){y(t,{export:r(o,n.export,t.export,e.export),path:r(o,n.path,t.path,e.path),resolver:r(i,n.resolver,t.resolver,e.resolver),extension:r(o,n.extension,t.extension,e.extension),withObject:r(c,n.withObject,t.withObject,e.withObject),rmWhitespace:r(c,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),token:y({},n.token,t.token,e.token),vars:y({},n.vars,t.vars,e.vars)})},V=function t(u){var s={},a={};J(s,u||{});var f=new K(s),h=new _(s),l=new L(s),p=new Y(s),v=new q(s,p,h),m=function(t){return J(s,t),f.configure(s,a),h.configure(s),l.configure(s),p.configure(s),v.configure(s),s},b=function(t,e){return v.get(t).then((function(t){return t.call(e,e,e.getBuffer(),d)}))},w=function(t,e){var n=g(t,s.extension),r=f.create(e);return b(n,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),n=r.clone();return w(e,n)}return t}))},j=function(t){f.helpers(y(a,t||{}))};return j({require:function(t){return function(t){var e=g(t,s.extension),n=f.create({});return b(e,n).then((function(){return n.getMacro()}))}(t)},render:function(t,e){return w(t,e)}}),{render:w,helpers:j,configure:m,wrapper:function(t){return l.wrapper(t)},compile:function(t,e){return h.compile(t,e)},create:function(e){return t(e)},preload:function(t){return p.load(t)},__express:function(t,u,s){i(u)&&(s=u,u={});var a=y({},(u=u||{}).settings),f=r(o,n.path,a.views),h=r(c,n.cache,a["view cache"]),l=y({},a["view options"]),p=e.relative(f,t);return l.path=f,l.cache=h,m(l),w(p,u).then((function(t){s(null,t)})).catch((function(t){s(t)}))}}}({}),z=V.render,G=V.helpers,H=V.configure,I=V.wrapper,Q=V.compile,Z=V.create,tt=V.preload,et=V.__express;t.__express=et,t.compile=Q,t.configure=H,t.create=Z,t.element=R,t.helpers=G,t.preload=tt,t.render=z,t.safeValue=d,t.wrapper=I,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
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={export:"ejsPrecompiled",cache:!0,path:"views",resolver:null,extension:"ejs",rmWhitespace:!0,withObject:!1,vars:{SCOPE:"ejs",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},r=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},i=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},c=function(t){return"boolean"==typeof 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"},h={"&":"&","<":"<",">":">",'"':""","'":"'"},f=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},l=f(h),p=f(a),v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(l,(function(t){return h[t]}))},d=function(t,e,n){return null==(n=t)?"":e?v(n):n},m=function(t,e){var n=t,r=e.split("."),i=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,i]},g=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},y=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)},b=function(){},w=function(t,e){var n;for(n in t)x(t,n)&&e(t[n],n,t)},j=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return w(t,(function(t,n,o){var c=e(t,n,o);void 0!==c&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},k=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},x=function(t,e){return t&&t.hasOwnProperty(e)},E=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],O=" ",F='"',P="/",B="<",R=">",S=function(t,e,n){var r=[],i=-1===E.indexOf(t),o=function(t,e,n){var r=[];return w(t,(function(t,n,i){var o=e(t,n,i);void 0!==o&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[v(e),[F,v(t),F].join("")].join("=")})).join(O);return r.push([B,t,O,o,R].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([B,P,t,R].join("")),r.join("")};function $(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function U(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,M(r.key),r)}}function A(t,e,n){return e&&U(t.prototype,e),n&&U(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function M(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 T=[{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(){function t(e){$(this,t),this.configure(e)}return A(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]},T.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;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 u,s,h,f="".concat(c,"('");u=this.regex,s=function(e,r,i){f+=(""+t.slice(r,i)).replace(p,(function(t){return"\\"+a[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},h=0,t.replace(u,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return s(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,c,o,f)).source="(function(".concat(i,",").concat(c,",").concat(o,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),L=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},W=function(t,e){return fetch(L(t,e)).then((function(t){return t.text()}))},C=function(t,n){return new Promise((function(r,i){e.readFile(L(t,n),(function(t,e){t?i(t):r(e.toString())}))}))},q=function(){function t(e,n,r){$(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return A(t,[{key:"configure",value:function(t){var n,r,o;this.path=t.path,this.resolver=i(t.resolver)?t.resolver:s()?C:W,(n=this.watcher)&&n.unwatch("."),t.watch&&s()&&(this.watcher=(r=this.cache,o=this.path,e.watch(".",{cwd:r}).on("change",(function(t){o.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 i(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=function(t){return Promise.all(t).then((function(t){return t.join("")}))},D=function(){function t(e){$(this,t),this.configure(e)}return A(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,c=n.LAYOUT,u=n.BLOCKS,s=n.BUFFER,a=n.MACRO;function h(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),y(this,t)}this.create=function(t){return new h(t)},this.helpers=function(t){y(h.prototype,t)},h.prototype=y({},e||{}),h.defineProp=h.method=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Object.defineProperty(h.prototype,t,{value:e,writable:n,configurable:r,enumerable:i})},h.defineProp(s,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(),N(n)},n.error=function(t){throw t},n.end=function(){return N(e)},n}()),h.defineProp(u,{},!0),h.defineProp(a,{},!0),h.defineProp(c,!1,!0),h.defineProp(r,!1,!0),h.method("initBlocks",(function(){this[u]={}})),h.method("initMacro",(function(){this[a]={}})),h.method("getMacro",(function(){return this[a]})),h.method("getBuffer",(function(){return this[s]})),h.method("getBlocks",(function(){return this[u]})),h.method("setExtend",(function(t){this[r]=t})),h.method("getExtend",(function(){return this[r]})),h.method("setLayout",(function(t){this[c]=t})),h.method("getLayout",(function(){return this[c]})),h.method("clone",(function(t){var e=[c,r,s];return!0===t&&e.push(u),j(this,e)})),h.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),h.method("echo",(function(){var t=this.getBuffer(),e=[].slice.call(arguments);e.forEach(t)})),h.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),i(t)&&t.apply(n,arguments),e.restore()}})),h.method("get",(function(t,e){var n=m(this,t),r=n.shift(),i=n.pop();return x(r,i)?r[i]:e})),h.method("set",(function(t,e){var n=m(this,t),r=n.shift(),i=n.pop();return this.getExtend()&&x(r,i)?r[i]:r[i]=e})),h.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))}})),h.method("call",(function(t){var e=this.getMacro(),n=e[t],r=[].slice.call(arguments,1);if(i(n))return n.apply(n,r)})),h.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()))}:b}()))}})),h.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=y(r,e||{}),o=this.render(t,i);this.echo(o)})),h.method("use",(function(t,e){var n=this.require(t);this.echo(k(n,(function(t){var n=this.getMacro();w(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),h.method("async",(function(t,e){this.echo(k(t,(function(t){return this.fn(e)(t)}),this))})),h.method("node",(function(t,e,n){return S(t,e,n)})),h.method("el",(function(t,e,n){i(n)&&(n=this.fn(n)()),this.echo(k(n,(function(n){return S(t,e,n)}),this))})),h.method("each",(function(t,e){o(t)&&(t=this.get(t,[])),w(t,e)}))}}]),t}(),K="undefined"!=typeof globalThis?globalThis:window||self,X=function(){function t(e){var n,r,i;$(this,t),n=this,i={},(r=M(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!1===s()&&this.load(K[this.namespace])}return A(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return y(this.list,t),this}},{key:"exist",value:function(t){return x(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}(),Y=function(t,e){y(t,{export:r(o,n.export,t.export,e.export),path:r(o,n.path,t.path,e.path),resolver:r(i,n.resolver,t.resolver,e.resolver),extension:r(o,n.extension,t.extension,e.extension),withObject:r(c,n.withObject,t.withObject,e.withObject),rmWhitespace:r(c,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),token:y({},n.token,t.token,e.token),vars:y({},n.vars,t.vars,e.vars)})},V=function t(u){var s={},a={};Y(s,u||{});var h=new D(s),f=new _(s),l=new X(s),p=new q(s,l,f),v=function(t){return Y(s,t),h.configure(s,a),f.configure(s),l.configure(s),p.configure(s),s},m=function(t,e){return p.get(t).then((function(t){return t.call(e,e,e.getBuffer(),d)}))},b=function(t,e){var n=g(t,s.extension),r=h.create(e);return m(n,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),n=r.clone();return b(e,n)}return t}))},w=function(t){h.helpers(y(a,t||{}))};return w({require:function(t){return function(t){var e=g(t,s.extension),n=h.create({});return m(e,n).then((function(){return n.getMacro()}))}(t)},render:function(t,e){return b(t,e)}}),{render:b,helpers:w,configure:v,compile:function(t,e){return f.compile(t,e)},create:function(e){return t(e)},preload:function(t){return l.load(t)},__express:function(t,u,s){i(u)&&(s=u,u={});var a=y({},(u=u||{}).settings),h=r(o,n.path,a.views),f=r(c,n.cache,a["view cache"]),l=y({},a["view options"]),p=e.relative(h,t);return l.path=h,l.cache=f,v(l),b(p,u).then((function(t){s(null,t)})).catch((function(t){s(t)}))}}}({}),z=V.render,G=V.helpers,H=V.configure,I=V.wrapper,J=V.compile,Q=V.create,Z=V.preload,tt=V.__express;t.__express=tt,t.compile=J,t.configure=H,t.create=Q,t.element=S,t.helpers=G,t.preload=Z,t.render=z,t.safeValue=d,t.wrapper=I,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/dist/ejs.mjs
CHANGED
|
@@ -335,38 +335,6 @@ class Compiler {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
class Bundler {
|
|
339
|
-
constructor(config) {
|
|
340
|
-
this.configure(config);
|
|
341
|
-
}
|
|
342
|
-
configure(config) {
|
|
343
|
-
this.namespace = config.export;
|
|
344
|
-
this.useStrict = config.withObject === false;
|
|
345
|
-
}
|
|
346
|
-
wrapper(list) {
|
|
347
|
-
let out = '';
|
|
348
|
-
out += '(function(global,factory){';
|
|
349
|
-
out += 'typeof exports === "object" && typeof module !== "undefined" ?';
|
|
350
|
-
out += 'module.exports = factory():';
|
|
351
|
-
out += 'typeof define === "function" && define.amd ? define(factory):';
|
|
352
|
-
out += '(global = typeof globalThis !== "undefined" ? globalThis:';
|
|
353
|
-
out += 'global || self,global["' + this.namespace + '"] = factory())';
|
|
354
|
-
out += '})(this,(function(){';
|
|
355
|
-
if (this.useStrict) out += "'use strict';\n";
|
|
356
|
-
out += 'var list = {};\n';
|
|
357
|
-
list.forEach((item) => {
|
|
358
|
-
out +=
|
|
359
|
-
'list[' +
|
|
360
|
-
JSON.stringify(item.name) +
|
|
361
|
-
']=' +
|
|
362
|
-
String(item.content) +
|
|
363
|
-
';\n';
|
|
364
|
-
});
|
|
365
|
-
out += 'return list;}));\n';
|
|
366
|
-
return out
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
338
|
const resolvePath = (path, template) => {
|
|
371
339
|
template = [path, template].join('/');
|
|
372
340
|
template = template.replace(/\/\//g, '/');
|
|
@@ -770,7 +738,6 @@ const init = (options) => {
|
|
|
770
738
|
|
|
771
739
|
const context = new Context(config);
|
|
772
740
|
const compiler = new Compiler(config);
|
|
773
|
-
const bundler = new Bundler(config);
|
|
774
741
|
const cache = new Cache(config);
|
|
775
742
|
const template = new Template(config, cache, compiler);
|
|
776
743
|
|
|
@@ -778,7 +745,6 @@ const init = (options) => {
|
|
|
778
745
|
configSchema(config, options);
|
|
779
746
|
context.configure(config, scope);
|
|
780
747
|
compiler.configure(config);
|
|
781
|
-
bundler.configure(config);
|
|
782
748
|
cache.configure(config);
|
|
783
749
|
template.configure(config);
|
|
784
750
|
return config
|
|
@@ -843,7 +809,6 @@ const init = (options) => {
|
|
|
843
809
|
})
|
|
844
810
|
};
|
|
845
811
|
const preload = (list) => cache.load(list);
|
|
846
|
-
const wrapper = (list) => bundler.wrapper(list);
|
|
847
812
|
const compile = (content, path) => compiler.compile(content, path);
|
|
848
813
|
const create = (options) => {
|
|
849
814
|
return init(options)
|
|
@@ -860,7 +825,6 @@ const init = (options) => {
|
|
|
860
825
|
render,
|
|
861
826
|
helpers,
|
|
862
827
|
configure,
|
|
863
|
-
wrapper,
|
|
864
828
|
compile,
|
|
865
829
|
create,
|
|
866
830
|
preload,
|