@kosatyi/ejs 0.0.87 → 0.0.89
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/browser.js +65 -5
- package/dist/cjs/element.js +1 -1
- package/dist/cjs/index.js +65 -5
- package/dist/cjs/worker.js +67 -5
- package/dist/esm/browser.js +60 -13
- package/dist/esm/element.js +1 -1
- package/dist/esm/index.js +60 -13
- package/dist/esm/worker.js +63 -15
- package/dist/umd/browser.js +65 -5
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/element.js +1 -1
- package/dist/umd/element.min.js +1 -1
- package/dist/umd/index.js +65 -5
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +67 -5
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
package/dist/esm/worker.js
CHANGED
|
@@ -57,7 +57,7 @@ const symbols = (string) => {
|
|
|
57
57
|
|
|
58
58
|
const safeValue = (value, escape) => {
|
|
59
59
|
const check = value;
|
|
60
|
-
return check == null ? '' : escape === true ? entities(check) : check
|
|
60
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const instanceOf = (object, instance) => {
|
|
@@ -497,34 +497,79 @@ const element = (tag, attrs, content) => {
|
|
|
497
497
|
return result.join('')
|
|
498
498
|
};
|
|
499
499
|
|
|
500
|
+
/**
|
|
501
|
+
* @extends Error
|
|
502
|
+
* @property code
|
|
503
|
+
* @param {string} message
|
|
504
|
+
* @constructor
|
|
505
|
+
*/
|
|
500
506
|
function TemplateError(message) {
|
|
501
|
-
this.code = 1;
|
|
502
507
|
this.name = 'TemplateError';
|
|
503
508
|
this.message = message;
|
|
504
509
|
Error.call(this);
|
|
505
510
|
}
|
|
506
|
-
Object.setPrototypeOf(TemplateNotFound.prototype, Error.prototype);
|
|
507
511
|
|
|
512
|
+
/**
|
|
513
|
+
*
|
|
514
|
+
*/
|
|
515
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
516
|
+
Object.assign(TemplateError.prototype, { code: 1 });
|
|
517
|
+
/**
|
|
518
|
+
*
|
|
519
|
+
* @return {number}
|
|
520
|
+
*/
|
|
521
|
+
TemplateError.prototype.getCode = function() {
|
|
522
|
+
return this.code
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
*
|
|
526
|
+
* @return {string}
|
|
527
|
+
*/
|
|
528
|
+
TemplateError.prototype.getMessage = function() {
|
|
529
|
+
return this.message
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* @return {string}
|
|
533
|
+
*/
|
|
534
|
+
TemplateError.prototype.toString = function() {
|
|
535
|
+
return this.getMessage()
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* @extends TemplateError
|
|
540
|
+
* @param {string} message
|
|
541
|
+
* @constructor
|
|
542
|
+
*/
|
|
508
543
|
function TemplateNotFound(message) {
|
|
509
544
|
TemplateError.call(this);
|
|
510
|
-
this.code = 404;
|
|
511
545
|
this.name = 'TemplateNotFound';
|
|
512
546
|
this.message = message;
|
|
513
547
|
}
|
|
514
548
|
|
|
549
|
+
/**
|
|
550
|
+
*
|
|
551
|
+
*/
|
|
515
552
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
516
|
-
|
|
553
|
+
Object.assign(TemplateNotFound.prototype, { code: 404 });
|
|
554
|
+
/**
|
|
555
|
+
* @extends TemplateError
|
|
556
|
+
* @param {string} message
|
|
557
|
+
* @constructor
|
|
558
|
+
*/
|
|
517
559
|
function TemplateSyntaxError(message) {
|
|
518
560
|
TemplateError.call(this);
|
|
519
|
-
this.code = 500;
|
|
520
561
|
this.name = 'TemplateSyntaxError';
|
|
521
562
|
this.message = message;
|
|
522
563
|
}
|
|
523
564
|
|
|
565
|
+
/**
|
|
566
|
+
*
|
|
567
|
+
*/
|
|
524
568
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
569
|
+
Object.assign(TemplateSyntaxError.prototype, { code: 500 });
|
|
525
570
|
|
|
526
571
|
function resolve(list) {
|
|
527
|
-
return Promise.all(list || []).then((list) => list.join(''))
|
|
572
|
+
return Promise.all(list || []).then((list) => list.join('')).catch((e) => e)
|
|
528
573
|
}
|
|
529
574
|
|
|
530
575
|
function reject(error) {
|
|
@@ -534,25 +579,27 @@ function reject(error) {
|
|
|
534
579
|
function createBuffer() {
|
|
535
580
|
let store = [],
|
|
536
581
|
array = [];
|
|
582
|
+
|
|
537
583
|
function buffer(value) {
|
|
538
584
|
array.push(value);
|
|
539
585
|
}
|
|
540
|
-
|
|
586
|
+
|
|
587
|
+
buffer.start = function() {
|
|
541
588
|
array = [];
|
|
542
589
|
};
|
|
543
|
-
buffer.backup = function
|
|
590
|
+
buffer.backup = function() {
|
|
544
591
|
store.push(array.concat());
|
|
545
592
|
array = [];
|
|
546
593
|
};
|
|
547
|
-
buffer.restore = function
|
|
594
|
+
buffer.restore = function() {
|
|
548
595
|
const result = array.concat();
|
|
549
596
|
array = store.pop();
|
|
550
597
|
return resolve(result)
|
|
551
598
|
};
|
|
552
|
-
buffer.error = function
|
|
599
|
+
buffer.error = function(e) {
|
|
553
600
|
return reject(e)
|
|
554
601
|
};
|
|
555
|
-
buffer.end = function
|
|
602
|
+
buffer.end = function() {
|
|
556
603
|
return resolve(array)
|
|
557
604
|
};
|
|
558
605
|
return buffer
|
|
@@ -1000,7 +1047,7 @@ const ejs = new EJS({
|
|
|
1000
1047
|
reject(new TemplateNotFound(`template ${name} not found`));
|
|
1001
1048
|
}
|
|
1002
1049
|
})
|
|
1003
|
-
}
|
|
1050
|
+
}
|
|
1004
1051
|
});
|
|
1005
1052
|
|
|
1006
1053
|
const getOrigin = (url, secure) => {
|
|
@@ -1016,6 +1063,7 @@ function setTemplates(list) {
|
|
|
1016
1063
|
/**
|
|
1017
1064
|
* @typedef {Object<string,any>} HonoContext
|
|
1018
1065
|
* @property {function(*):Promise<Response>} html
|
|
1066
|
+
* @property {function():Promise<Response>} notFound
|
|
1019
1067
|
* @property {function(name:string,data:{}):Promise<string>} render
|
|
1020
1068
|
* @property {function(name:string,data:{}):Promise<string>} ejs
|
|
1021
1069
|
* @property {ContextScope} data
|
|
@@ -1026,7 +1074,7 @@ function setTemplates(list) {
|
|
|
1026
1074
|
* @param {Object<string,any>} options
|
|
1027
1075
|
* @return {(function(c:Context, next): Promise<any>)|*}
|
|
1028
1076
|
*/
|
|
1029
|
-
function setRenderer({ secure = true, version = '1.0' }) {
|
|
1077
|
+
function setRenderer({ secure = true, version = '1.0', errorHandler }) {
|
|
1030
1078
|
return async (c, next) => {
|
|
1031
1079
|
c.data = context({});
|
|
1032
1080
|
c.data.set('version', version);
|
|
@@ -1039,4 +1087,4 @@ function setRenderer({ secure = true, version = '1.0' }) {
|
|
|
1039
1087
|
|
|
1040
1088
|
const { render, context, compile, helpers, preload, configure, create } = ejs;
|
|
1041
1089
|
|
|
1042
|
-
export { compile, configure, context, create, helpers, preload, render, setRenderer, setTemplates };
|
|
1090
|
+
export { TemplateError, TemplateNotFound, TemplateSyntaxError, compile, configure, context, create, helpers, preload, render, setRenderer, setTemplates };
|
package/dist/umd/browser.js
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
};
|
|
64
64
|
var safeValue = function safeValue(value, escape) {
|
|
65
65
|
var check = value;
|
|
66
|
-
return check == null ? '' : escape === true ? entities(check) : check;
|
|
66
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
67
67
|
};
|
|
68
68
|
var instanceOf = function instanceOf(object, instance) {
|
|
69
69
|
return Boolean(object instanceof instance);
|
|
@@ -433,31 +433,88 @@
|
|
|
433
433
|
return result.join('');
|
|
434
434
|
};
|
|
435
435
|
|
|
436
|
+
/**
|
|
437
|
+
* @extends Error
|
|
438
|
+
* @property code
|
|
439
|
+
* @param {string} message
|
|
440
|
+
* @constructor
|
|
441
|
+
*/
|
|
436
442
|
function TemplateError(message) {
|
|
437
|
-
this.code = 1;
|
|
438
443
|
this.name = 'TemplateError';
|
|
439
444
|
this.message = message;
|
|
440
445
|
Error.call(this);
|
|
441
446
|
}
|
|
442
|
-
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
*
|
|
450
|
+
*/
|
|
451
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
452
|
+
Object.assign(TemplateError.prototype, {
|
|
453
|
+
code: 1
|
|
454
|
+
});
|
|
455
|
+
/**
|
|
456
|
+
*
|
|
457
|
+
* @return {number}
|
|
458
|
+
*/
|
|
459
|
+
TemplateError.prototype.getCode = function () {
|
|
460
|
+
return this.code;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
*
|
|
464
|
+
* @return {string}
|
|
465
|
+
*/
|
|
466
|
+
TemplateError.prototype.getMessage = function () {
|
|
467
|
+
return this.message;
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* @return {string}
|
|
471
|
+
*/
|
|
472
|
+
TemplateError.prototype.toString = function () {
|
|
473
|
+
return this.getMessage();
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* @extends TemplateError
|
|
478
|
+
* @param {string} message
|
|
479
|
+
* @constructor
|
|
480
|
+
*/
|
|
443
481
|
function TemplateNotFound(message) {
|
|
444
482
|
TemplateError.call(this);
|
|
445
|
-
this.code = 404;
|
|
446
483
|
this.name = 'TemplateNotFound';
|
|
447
484
|
this.message = message;
|
|
448
485
|
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
*
|
|
489
|
+
*/
|
|
449
490
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
491
|
+
Object.assign(TemplateNotFound.prototype, {
|
|
492
|
+
code: 404
|
|
493
|
+
});
|
|
494
|
+
/**
|
|
495
|
+
* @extends TemplateError
|
|
496
|
+
* @param {string} message
|
|
497
|
+
* @constructor
|
|
498
|
+
*/
|
|
450
499
|
function TemplateSyntaxError(message) {
|
|
451
500
|
TemplateError.call(this);
|
|
452
|
-
this.code = 500;
|
|
453
501
|
this.name = 'TemplateSyntaxError';
|
|
454
502
|
this.message = message;
|
|
455
503
|
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
*
|
|
507
|
+
*/
|
|
456
508
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
509
|
+
Object.assign(TemplateSyntaxError.prototype, {
|
|
510
|
+
code: 500
|
|
511
|
+
});
|
|
457
512
|
|
|
458
513
|
function resolve(list) {
|
|
459
514
|
return Promise.all(list || []).then(function (list) {
|
|
460
515
|
return list.join('');
|
|
516
|
+
})["catch"](function (e) {
|
|
517
|
+
return e;
|
|
461
518
|
});
|
|
462
519
|
}
|
|
463
520
|
function reject(error) {
|
|
@@ -889,6 +946,9 @@
|
|
|
889
946
|
configure = ejs.configure,
|
|
890
947
|
create = ejs.create;
|
|
891
948
|
|
|
949
|
+
exports.TemplateError = TemplateError;
|
|
950
|
+
exports.TemplateNotFound = TemplateNotFound;
|
|
951
|
+
exports.TemplateSyntaxError = TemplateSyntaxError;
|
|
892
952
|
exports.compile = compile;
|
|
893
953
|
exports.configure = configure;
|
|
894
954
|
exports.context = context;
|
package/dist/umd/browser.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ejs={})}(this,(function(e){"use strict";var t=function(){var e=[].slice.call(arguments),t=e.shift();return e.filter(t).pop()},n=function(e){return Array.isArray(e)},r=function(e){return"function"==typeof e},i=function(e){return"string"==typeof e},o=function(e){return"boolean"==typeof e},u=function(e){return void 0===e},c="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},l={"&":"&","<":"<",">":">",'"':""","'":"'"},s=function(e){return new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g")},f=s(l),h=s(a),p=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(f,(function(e){return l[e]}))},b=function(e,t){var n=e;return null==n?"":!0===t?p(n):n},g=function(e,t){return Boolean(e instanceof t)},v=function(e,t,n){for(var i=e,o=String(t).split("."),u=o.pop(),c=0;c<o.length;c++){var a=o[c];if(r(i.toJSON)&&(i=i.toJSON()),n&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}return r(i.toJSON)&&(i=i.toJSON()),[i,u]},m=function(e,t){var n=e.split(".").pop();return n!==t&&(e=[e,t].join(".")),e},d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.filter((function(e){return e})).reduce((function(e,t){return Object.assign(e,t)}),e)},w=function(){},y=function(e,t){var n;for(n in e)O(e,n)&&t(e[n],n,e)},j=function(e,t){return function(e,t){var n=e instanceof Array,r=n?[]:{};return y(e,(function(e,i,o){var c=t(e,i,o);!1===u(c)&&(n?r.push(c):r[i]=c)})),r}(e,(function(e,n){if(-1===t.indexOf(n))return e}))},E=function(e,t,n){return Promise.resolve(e).then(t.bind(n))},O=function(e,t){return e&&e.hasOwnProperty(t)},x={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(e,t){return Promise.resolve(["resolver is not defined",e,t].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},k=function(e,u){d(e,{path:t(i,x.path,e.path,u.path),export:t(i,x.export,e.export,u.export),resolver:t(r,x.resolver,e.resolver,u.resolver),extension:t(i,x.extension,e.extension,u.extension),withObject:t(o,x.withObject,e.withObject,u.withObject),rmWhitespace:t(o,x.rmWhitespace,e.rmWhitespace,u.rmWhitespace),cache:t(o,x.cache,e.cache,u.cache),token:d({},x.token,e.token,u.token),vars:d({},x.vars,e.vars,u.vars),globalHelpers:t(n,x.globalHelpers,e.globalHelpers,u.globalHelpers)})},F="undefined"!=typeof globalThis?globalThis:window||self;function P(e){if(!1===g(this,P))return new P;var t={enabled:!0,list:{}};this.configure=function(e){t.enabled=e.cache,!1===c&&this.load(F[e.export])},this.clear=function(){t.list={}},this.load=function(e){return t.enabled&&d(t.list,e||{}),this},this.get=function(e){if(t.enabled)return t.list[e]},this.set=function(e,n){return t.enabled&&(t.list[e]=n),this},this.resolve=function(e){return Promise.resolve(this.get(e))},this.remove=function(e){delete t.list[e]},this.exist=function(e){return O(t.list,e)}}var S=[{symbol:"-",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(e){return"')\n/**".concat(e,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(e){return"')\n".concat(e.trim(),"\n").concat(this.BUFFER,"('")}}];function B(e){if(!1===g(this,B))return new B(e);var t={};this.configure=function(e){t.withObject=e.withObject,t.rmWhitespace=e.rmWhitespace,t.token=e.token,t.vars=e.vars,t.globalHelpers=e.globalHelpers,t.matches=[],t.formats=[],t.slurp={match:"[ \\t]*",start:[t.token.start,"_"],end:["_",t.token.end]},S.forEach((function(e){t.matches.push(t.token.start.concat(e.symbol).concat(t.token.regex).concat(t.token.end)),t.formats.push(e.format.bind(t.vars))})),t.regex=new RegExp(t.matches.join("|").concat("|$"),"g"),t.slurpStart=new RegExp([t.slurp.match,t.slurp.start.join("")].join(""),"gm"),t.slurpEnd=new RegExp([t.slurp.end.join(""),t.slurp.match].join(""),"gm")},this.compile=function(e,n){var r=t.vars,i=r.SCOPE,o=r.SAFE,u=r.BUFFER,c=r.COMPONENT,l=t.globalHelpers;e=String(e),t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),e=e.replace(t.slurpStart,t.token.start).replace(t.slurpEnd,t.token.end);var s,f,p,b="".concat(u,"('");s=t.regex,f=function(n,r,i){b+=(""+e.slice(r,i)).replace(h,(function(e){return"\\"+a[e]})),n.forEach((function(e,n){e&&(b+=t.formats[n](e))}))},p=0,e.replace(s,(function(){var e=[].slice.call(arguments,0,-1),t=e.pop(),n=e.shift();return f(e,p,t),p=t+n.length,n})),b="try{".concat(b+="');","}catch(e){return ").concat(u,".error(e)}"),t.withObject&&(b="with(".concat(i,"){").concat(b,"}")),b="".concat(u,".start();").concat(b,"return ").concat(u,".end();"),b+="\n//# sourceURL=".concat(n);var g=null,v=[i,c,u,o].concat(l);try{(g=Function.apply(null,v.concat(b))).source="(function(".concat(v.join(","),"){\n").concat(b,"\n});")}catch(e){throw e.filename=n,e.source=b,e}return g},this.configure(e)}function T(e,t,n){if(!1===g(this,T))return new T(e,t,n);if(!1===g(t,P))throw new TypeError("cache is not instance of Cache");if(!1===g(n,B))throw new TypeError("compiler is not instance of Compiler");var i={},o=function(e){return i.resolver(i.path,e)};this.configure=function(e){i.path=e.path,i.cache=e.cache,r(e.resolver)&&(i.resolver=e.resolver)},this.get=function(e){return t.exist(e)?t.resolve(e):o(e).then((function(i){return function(e,n){return t.set(e,n),n}(e,function(e,t){return r(e)?e:n.compile(e,t)}(i,e))}))},this.configure(e)}function R(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],$=" ",A='"',C="/",U="<",M=">",H=function(e,t,n){var r=[],i=-1===N.indexOf(e),o=function(e,t){var n=[];return y(e,(function(e,r,i){var o=t(e,r,i);!1===u(o)&&n.push(o)})),n}(t,(function(e,t){if(null!=e)return[p(t),[A,p(e),A].join("")].join("=")})).join($);return r.push([U,e,$,o,M].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([U,C,e,M].join("")),r.join("")};function L(e){this.code=1,this.name="TemplateError",this.message=e,Error.call(this)}function W(e){L.call(this),this.code=404,this.name="TemplateNotFound",this.message=e}function J(e){L.call(this),this.code=500,this.name="TemplateSyntaxError",this.message=e}function q(e){return Promise.all(e||[]).then((function(e){return e.join("")}))}function D(){var e=[],t=[];function n(e){t.push(e)}return n.start=function(){t=[]},n.backup=function(){e.push(t.concat()),t=[]},n.restore=function(){var n=t.concat();return t=e.pop(),q(n)},n.error=function(e){return t=e,Promise.reject(new J(t.message));var t},n.end=function(){return q(t)},n}function K(e){if(!1===g(this,K))return new K(e);this.configure=function(e,t){var n,o=e.vars,u=o.BLOCKS,c=o.MACRO,a=o.EXTEND,l=o.LAYOUT,s=o.BUFFER,f=o.COMPONENT;function h(e){this[u]={},this[c]={},d(this,e||{})}this.create=function(e){return new h(e)},this.helpers=function(e){d(h.prototype,e||{})},h.prototype=d({},t||{}),Object.defineProperties(h.prototype,(R(R(R(R(R(R(R(R(R(R(n={},s,{value:D(),writable:!0,configurable:!1,enumerable:!1}),u,{value:{},writable:!0,configurable:!1,enumerable:!1}),c,{value:{},writable:!0,configurable:!1,enumerable:!1}),l,{value:!1,writable:!0,configurable:!1,enumerable:!1}),a,{value:!1,writable:!0,configurable:!1,enumerable:!1}),"getMacro",{value:function(){return this[c]},writable:!1,configurable:!1,enumerable:!1}),"getBuffer",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),"getComponent",{value:function(){var e=this;return f in e?function(){return e[f].apply(e,arguments)}:function(){console.log("%s function not defined",f)}},writable:!1,configurable:!1,enumerable:!1}),"getBlocks",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),"setExtend",{value:function(e){this[a]=e},writable:!1,configurable:!1,enumerable:!1}),R(R(R(R(R(R(R(R(R(R(n,"getExtend",{value:function(){return this[a]},writable:!1,configurable:!1,enumerable:!1}),"setLayout",{value:function(e){this[l]=e},writable:!1,configurable:!1,enumerable:!1}),"getLayout",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),"clone",{value:function(e){var t=[l,a,s];return!0===e&&t.push(u),j(this,t)},writable:!1,configurable:!1,enumerable:!1}),"extend",{value:function(e){this.setExtend(!0),this.setLayout(e)},writable:!1,configurable:!1,enumerable:!1}),"echo",{value:function(e){var t=this.getBuffer();[].slice.call(arguments).forEach(t)},writable:!1,configurable:!1,enumerable:!1}),"fn",{value:function(e){var t=this.getBuffer(),n=this;return function(){return t.backup(),r(e)&&e.apply(n,arguments),t.restore()}},writable:!1,configurable:!1,enumerable:!1}),"get",{value:function(e,t){var n=v(this,e,!0),r=n.shift(),i=n.pop();return O(r,i)?r[i]:t},writable:!0,configurable:!0,enumerable:!1}),"set",{value:function(e,t){var n=v(this,e,!1),r=n.shift(),i=n.pop();return this.getExtend()&&O(r,i)?r[i]:r[i]=t},writable:!1,configurable:!1,enumerable:!1}),"macro",{value:function(e,t){var n=this.getMacro(),r=this.fn(t),i=this;n[e]=function(){return i.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),R(R(R(R(R(R(R(R(R(n,"call",{value:function(e){var t=this.getMacro()[e],n=[].slice.call(arguments,1);if(r(t))return t.apply(t,n)},writable:!1,configurable:!1,enumerable:!1}),"block",{value:function(e,t){var n=this,r=this.getBlocks();if(r[e]=r[e]||[],r[e].push(this.fn(t)),!this.getExtend()){var i=Object.assign([],r[e]),o=function(){return i.shift()},u=function(){var e=o();return e?function(){n.echo(e(u()))}:w};this.echo(o()(u()))}},writable:!1,configurable:!1,enumerable:!1}),"hasBlock",{value:function(e){return this.getBlocks().hasOwnProperty(e)},writable:!1,configurable:!1,enumerable:!1}),"include",{value:function(e,t,n){var r=!1===n?{}:this.clone(!0),i=d(r,t||{}),o=this.render(e,i);this.echo(o)},writable:!1,configurable:!1,enumerable:!1}),"use",{value:function(e,t){var n=this.require(e);this.echo(E(n,(function(e){var n=this.getMacro();y(e,(function(e,r){n[[t,r].join(".")]=e}))}),this))},writable:!1,configurable:!1,enumerable:!1}),"async",{value:function(e,t){this.echo(E(e,(function(e){return this.fn(t)(e)}),this))},writable:!1,configurable:!1,enumerable:!1}),"each",{value:function(e,t){i(e)&&(e=this.get(e,[])),y(e,t)},writable:!1,configurable:!1,enumerable:!1}),"element",{value:function(e,t,n){return H(e,t,n)},writable:!1,configurable:!1,enumerable:!1}),"el",{value:function(e,t,n){r(n)&&(n=this.fn(n)()),this.echo(E(n,(function(n){return this.element(e,t,n)}),this))},writable:!1,configurable:!1,enumerable:!1})))},this.configure(e)}Object.setPrototypeOf(W.prototype,Error.prototype),Object.setPrototypeOf(W.prototype,L.prototype),Object.setPrototypeOf(J.prototype,L.prototype);var X=new function e(t){if(!1===g(this,e))return new e(t);var n={},i={};k(i,t||{});var o=new K(i),u=new B(i),c=new P,a=new T(i,c,u),l=function(e,t){var n=i.globalHelpers,o=[t,t.getComponent(),t.getBuffer(),b].concat(n.filter((function(e){return r(t[e])})).map((function(e){return t[e].bind(t)})));return a.get(e).then((function(e){return e.apply(t,o)}))},s=function(e,t){var n=m(e,i.extension),r=o.create(t);return l(n,r).then((function(e){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),n=r.clone();return s(t,n)}return e}))};return this.configure=function(e){return k(i,e=e||{}),o.configure(i,n),u.configure(i),c.configure(i),a.configure(i),i},this.render=function(e,t){return s(e,t)},this.helpers=function(e){o.helpers(d(n,e))},this.preload=function(e){return c.load(e||{})},this.create=function(t){return new e(t)},this.compile=function(e,t){return u.compile(e,t)},this.context=function(e){return o.create(e)},this.helpers({require:function(e){var t=m(e,i.extension),n=o.create({});return l(t,n).then((function(){return n.getMacro()}))},render:s}),this}({resolver:function(e,t){return fetch(function(e,t){return(t=[e,t].join("/")).replace(/\/\//g,"/")}(e,t)).then((function(e){return e.text()}),(function(e){return new L(e)}))}}),Y=X.render,_=X.context,z=X.compile,G=X.helpers,I=X.preload,Q=X.configure,V=X.create;e.compile=z,e.configure=Q,e.context=_,e.create=V,e.helpers=G,e.preload=I,e.render=Y}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ejs={})}(this,(function(e){"use strict";var t=function(){var e=[].slice.call(arguments),t=e.shift();return e.filter(t).pop()},n=function(e){return Array.isArray(e)},r=function(e){return"function"==typeof e},o=function(e){return"string"==typeof e},i=function(e){return"boolean"==typeof e},u=function(e){return void 0===e},c="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},s={"&":"&","<":"<",">":">",'"':""","'":"'"},l=function(e){return new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g")},f=l(s),h=l(a),p=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(f,(function(e){return s[e]}))},b=function(e,t){var n=e;return null==n?"":!0===Boolean(t)?p(n):n},g=function(e,t){return Boolean(e instanceof t)},v=function(e,t,n){for(var o=e,i=String(t).split("."),u=i.pop(),c=0;c<i.length;c++){var a=i[c];if(r(o.toJSON)&&(o=o.toJSON()),n&&!1===o.hasOwnProperty(a)){o={};break}o=o[a]=o[a]||{}}return r(o.toJSON)&&(o=o.toJSON()),[o,u]},m=function(e,t){var n=e.split(".").pop();return n!==t&&(e=[e,t].join(".")),e},d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.filter((function(e){return e})).reduce((function(e,t){return Object.assign(e,t)}),e)},w=function(){},y=function(e,t){var n;for(n in e)O(e,n)&&t(e[n],n,e)},j=function(e,t){return function(e,t){var n=e instanceof Array,r=n?[]:{};return y(e,(function(e,o,i){var c=t(e,o,i);!1===u(c)&&(n?r.push(c):r[o]=c)})),r}(e,(function(e,n){if(-1===t.indexOf(n))return e}))},E=function(e,t,n){return Promise.resolve(e).then(t.bind(n))},O=function(e,t){return e&&e.hasOwnProperty(t)},x={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(e,t){return Promise.resolve(["resolver is not defined",e,t].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},k=function(e,u){d(e,{path:t(o,x.path,e.path,u.path),export:t(o,x.export,e.export,u.export),resolver:t(r,x.resolver,e.resolver,u.resolver),extension:t(o,x.extension,e.extension,u.extension),withObject:t(i,x.withObject,e.withObject,u.withObject),rmWhitespace:t(i,x.rmWhitespace,e.rmWhitespace,u.rmWhitespace),cache:t(i,x.cache,e.cache,u.cache),token:d({},x.token,e.token,u.token),vars:d({},x.vars,e.vars,u.vars),globalHelpers:t(n,x.globalHelpers,e.globalHelpers,u.globalHelpers)})},F="undefined"!=typeof globalThis?globalThis:window||self;function S(e){if(!1===g(this,S))return new S;var t={enabled:!0,list:{}};this.configure=function(e){t.enabled=e.cache,!1===c&&this.load(F[e.export])},this.clear=function(){t.list={}},this.load=function(e){return t.enabled&&d(t.list,e||{}),this},this.get=function(e){if(t.enabled)return t.list[e]},this.set=function(e,n){return t.enabled&&(t.list[e]=n),this},this.resolve=function(e){return Promise.resolve(this.get(e))},this.remove=function(e){delete t.list[e]},this.exist=function(e){return O(t.list,e)}}var B=[{symbol:"-",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(e){return"')\n/**".concat(e,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(e){return"')\n".concat(e.trim(),"\n").concat(this.BUFFER,"('")}}];function P(e){if(!1===g(this,P))return new P(e);var t={};this.configure=function(e){t.withObject=e.withObject,t.rmWhitespace=e.rmWhitespace,t.token=e.token,t.vars=e.vars,t.globalHelpers=e.globalHelpers,t.matches=[],t.formats=[],t.slurp={match:"[ \\t]*",start:[t.token.start,"_"],end:["_",t.token.end]},B.forEach((function(e){t.matches.push(t.token.start.concat(e.symbol).concat(t.token.regex).concat(t.token.end)),t.formats.push(e.format.bind(t.vars))})),t.regex=new RegExp(t.matches.join("|").concat("|$"),"g"),t.slurpStart=new RegExp([t.slurp.match,t.slurp.start.join("")].join(""),"gm"),t.slurpEnd=new RegExp([t.slurp.end.join(""),t.slurp.match].join(""),"gm")},this.compile=function(e,n){var r=t.vars,o=r.SCOPE,i=r.SAFE,u=r.BUFFER,c=r.COMPONENT,s=t.globalHelpers;e=String(e),t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),e=e.replace(t.slurpStart,t.token.start).replace(t.slurpEnd,t.token.end);var l,f,p,b="".concat(u,"('");l=t.regex,f=function(n,r,o){b+=(""+e.slice(r,o)).replace(h,(function(e){return"\\"+a[e]})),n.forEach((function(e,n){e&&(b+=t.formats[n](e))}))},p=0,e.replace(l,(function(){var e=[].slice.call(arguments,0,-1),t=e.pop(),n=e.shift();return f(e,p,t),p=t+n.length,n})),b="try{".concat(b+="');","}catch(e){return ").concat(u,".error(e)}"),t.withObject&&(b="with(".concat(o,"){").concat(b,"}")),b="".concat(u,".start();").concat(b,"return ").concat(u,".end();"),b+="\n//# sourceURL=".concat(n);var g=null,v=[o,c,u,i].concat(s);try{(g=Function.apply(null,v.concat(b))).source="(function(".concat(v.join(","),"){\n").concat(b,"\n});")}catch(e){throw e.filename=n,e.source=b,e}return g},this.configure(e)}function T(e,t,n){if(!1===g(this,T))return new T(e,t,n);if(!1===g(t,S))throw new TypeError("cache is not instance of Cache");if(!1===g(n,P))throw new TypeError("compiler is not instance of Compiler");var o={},i=function(e){return o.resolver(o.path,e)};this.configure=function(e){o.path=e.path,o.cache=e.cache,r(e.resolver)&&(o.resolver=e.resolver)},this.get=function(e){return t.exist(e)?t.resolve(e):i(e).then((function(o){return function(e,n){return t.set(e,n),n}(e,function(e,t){return r(e)?e:n.compile(e,t)}(o,e))}))},this.configure(e)}function R(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],C=" ",$='"',A="/",M="<",U=">",H=function(e,t,n){var r=[],o=-1===N.indexOf(e),i=function(e,t){var n=[];return y(e,(function(e,r,o){var i=t(e,r,o);!1===u(i)&&n.push(i)})),n}(t,(function(e,t){if(null!=e)return[p(t),[$,p(e),$].join("")].join("=")})).join(C);return r.push([M,e,C,i,U].join("")),n&&r.push(n instanceof Array?n.join(""):n),o&&r.push([M,A,e,U].join("")),r.join("")};function L(e){this.name="TemplateError",this.message=e,Error.call(this)}function W(e){L.call(this),this.name="TemplateNotFound",this.message=e}function J(e){L.call(this),this.name="TemplateSyntaxError",this.message=e}function q(e){return Promise.all(e||[]).then((function(e){return e.join("")})).catch((function(e){return e}))}function D(){var e=[],t=[];function n(e){t.push(e)}return n.start=function(){t=[]},n.backup=function(){e.push(t.concat()),t=[]},n.restore=function(){var n=t.concat();return t=e.pop(),q(n)},n.error=function(e){return t=e,Promise.reject(new J(t.message));var t},n.end=function(){return q(t)},n}function K(e){if(!1===g(this,K))return new K(e);this.configure=function(e,t){var n,i=e.vars,u=i.BLOCKS,c=i.MACRO,a=i.EXTEND,s=i.LAYOUT,l=i.BUFFER,f=i.COMPONENT;function h(e){this[u]={},this[c]={},d(this,e||{})}this.create=function(e){return new h(e)},this.helpers=function(e){d(h.prototype,e||{})},h.prototype=d({},t||{}),Object.defineProperties(h.prototype,(R(R(R(R(R(R(R(R(R(R(n={},l,{value:D(),writable:!0,configurable:!1,enumerable:!1}),u,{value:{},writable:!0,configurable:!1,enumerable:!1}),c,{value:{},writable:!0,configurable:!1,enumerable:!1}),s,{value:!1,writable:!0,configurable:!1,enumerable:!1}),a,{value:!1,writable:!0,configurable:!1,enumerable:!1}),"getMacro",{value:function(){return this[c]},writable:!1,configurable:!1,enumerable:!1}),"getBuffer",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),"getComponent",{value:function(){var e=this;return f in e?function(){return e[f].apply(e,arguments)}:function(){console.log("%s function not defined",f)}},writable:!1,configurable:!1,enumerable:!1}),"getBlocks",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),"setExtend",{value:function(e){this[a]=e},writable:!1,configurable:!1,enumerable:!1}),R(R(R(R(R(R(R(R(R(R(n,"getExtend",{value:function(){return this[a]},writable:!1,configurable:!1,enumerable:!1}),"setLayout",{value:function(e){this[s]=e},writable:!1,configurable:!1,enumerable:!1}),"getLayout",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),"clone",{value:function(e){var t=[s,a,l];return!0===e&&t.push(u),j(this,t)},writable:!1,configurable:!1,enumerable:!1}),"extend",{value:function(e){this.setExtend(!0),this.setLayout(e)},writable:!1,configurable:!1,enumerable:!1}),"echo",{value:function(e){var t=this.getBuffer();[].slice.call(arguments).forEach(t)},writable:!1,configurable:!1,enumerable:!1}),"fn",{value:function(e){var t=this.getBuffer(),n=this;return function(){return t.backup(),r(e)&&e.apply(n,arguments),t.restore()}},writable:!1,configurable:!1,enumerable:!1}),"get",{value:function(e,t){var n=v(this,e,!0),r=n.shift(),o=n.pop();return O(r,o)?r[o]:t},writable:!0,configurable:!0,enumerable:!1}),"set",{value:function(e,t){var n=v(this,e,!1),r=n.shift(),o=n.pop();return this.getExtend()&&O(r,o)?r[o]:r[o]=t},writable:!1,configurable:!1,enumerable:!1}),"macro",{value:function(e,t){var n=this.getMacro(),r=this.fn(t),o=this;n[e]=function(){return o.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),R(R(R(R(R(R(R(R(R(n,"call",{value:function(e){var t=this.getMacro()[e],n=[].slice.call(arguments,1);if(r(t))return t.apply(t,n)},writable:!1,configurable:!1,enumerable:!1}),"block",{value:function(e,t){var n=this,r=this.getBlocks();if(r[e]=r[e]||[],r[e].push(this.fn(t)),!this.getExtend()){var o=Object.assign([],r[e]),i=function(){return o.shift()},u=function(){var e=i();return e?function(){n.echo(e(u()))}:w};this.echo(i()(u()))}},writable:!1,configurable:!1,enumerable:!1}),"hasBlock",{value:function(e){return this.getBlocks().hasOwnProperty(e)},writable:!1,configurable:!1,enumerable:!1}),"include",{value:function(e,t,n){var r=!1===n?{}:this.clone(!0),o=d(r,t||{}),i=this.render(e,o);this.echo(i)},writable:!1,configurable:!1,enumerable:!1}),"use",{value:function(e,t){var n=this.require(e);this.echo(E(n,(function(e){var n=this.getMacro();y(e,(function(e,r){n[[t,r].join(".")]=e}))}),this))},writable:!1,configurable:!1,enumerable:!1}),"async",{value:function(e,t){this.echo(E(e,(function(e){return this.fn(t)(e)}),this))},writable:!1,configurable:!1,enumerable:!1}),"each",{value:function(e,t){o(e)&&(e=this.get(e,[])),y(e,t)},writable:!1,configurable:!1,enumerable:!1}),"element",{value:function(e,t,n){return H(e,t,n)},writable:!1,configurable:!1,enumerable:!1}),"el",{value:function(e,t,n){r(n)&&(n=this.fn(n)()),this.echo(E(n,(function(n){return this.element(e,t,n)}),this))},writable:!1,configurable:!1,enumerable:!1})))},this.configure(e)}Object.setPrototypeOf(L.prototype,Error.prototype),Object.assign(L.prototype,{code:1}),L.prototype.getCode=function(){return this.code},L.prototype.getMessage=function(){return this.message},L.prototype.toString=function(){return this.getMessage()},Object.setPrototypeOf(W.prototype,L.prototype),Object.assign(W.prototype,{code:404}),Object.setPrototypeOf(J.prototype,L.prototype),Object.assign(J.prototype,{code:500});var X=new function e(t){if(!1===g(this,e))return new e(t);var n={},o={};k(o,t||{});var i=new K(o),u=new P(o),c=new S,a=new T(o,c,u),s=function(e,t){var n=o.globalHelpers,i=[t,t.getComponent(),t.getBuffer(),b].concat(n.filter((function(e){return r(t[e])})).map((function(e){return t[e].bind(t)})));return a.get(e).then((function(e){return e.apply(t,i)}))},l=function(e,t){var n=m(e,o.extension),r=i.create(t);return s(n,r).then((function(e){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),n=r.clone();return l(t,n)}return e}))};return this.configure=function(e){return k(o,e=e||{}),i.configure(o,n),u.configure(o),c.configure(o),a.configure(o),o},this.render=function(e,t){return l(e,t)},this.helpers=function(e){i.helpers(d(n,e))},this.preload=function(e){return c.load(e||{})},this.create=function(t){return new e(t)},this.compile=function(e,t){return u.compile(e,t)},this.context=function(e){return i.create(e)},this.helpers({require:function(e){var t=m(e,o.extension),n=i.create({});return s(t,n).then((function(){return n.getMacro()}))},render:l}),this}({resolver:function(e,t){return fetch(function(e,t){return(t=[e,t].join("/")).replace(/\/\//g,"/")}(e,t)).then((function(e){return e.text()}),(function(e){return new L(e)}))}}),Y=X.render,_=X.context,z=X.compile,G=X.helpers,I=X.preload,Q=X.configure,V=X.create;e.TemplateError=L,e.TemplateNotFound=W,e.TemplateSyntaxError=J,e.compile=z,e.configure=Q,e.context=_,e.create=V,e.helpers=G,e.preload=I,e.render=Y}));
|
package/dist/umd/element.js
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
};
|
|
39
39
|
var safeValue = function safeValue(value, escape) {
|
|
40
40
|
var check = value;
|
|
41
|
-
return check == null ? '' : escape === true ? entities(check) : check;
|
|
41
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
42
42
|
};
|
|
43
43
|
var each = function each(object, callback) {
|
|
44
44
|
var prop;
|
package/dist/umd/element.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).element={})}(this,(function(n){"use strict";Object.prototype.toString.call("undefined"!=typeof process?process:0);var e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=function(n){return new RegExp(["[",Object.keys(n).join(""),"]"].join(""),"g")},o=t(e);t({"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"});var r=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(o,(function(n){return e[n]}))},i=function(n,e,t){var o=[];return function(n,e){var t;for(t in n)u(n,t)&&e(n[t],t,n)}(n,(function(n,t,r){var i=e(n,t,r);!1==(void 0===i)&&o.push(i)})),o},u=function(n,e){return n&&n.hasOwnProperty(e)},f=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],a=" ",c='"',s="/",p="<",l=">";n.element=function(n,e,t){var o=[],u=-1===f.indexOf(n),d=i(e,(function(n,e){if(null!=n)return[r(e),[c,r(n),c].join("")].join("=")})).join(a);return o.push([p,n,a,d,l].join("")),t&&o.push(t instanceof Array?t.join(""):t),u&&o.push([p,s,n,l].join("")),o.join("")},n.safeValue=function(n,e){var t=n;return null==t?"":!0===e?r(t):t}}));
|
|
1
|
+
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).element={})}(this,(function(n){"use strict";Object.prototype.toString.call("undefined"!=typeof process?process:0);var e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=function(n){return new RegExp(["[",Object.keys(n).join(""),"]"].join(""),"g")},o=t(e);t({"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"});var r=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(o,(function(n){return e[n]}))},i=function(n,e,t){var o=[];return function(n,e){var t;for(t in n)u(n,t)&&e(n[t],t,n)}(n,(function(n,t,r){var i=e(n,t,r);!1==(void 0===i)&&o.push(i)})),o},u=function(n,e){return n&&n.hasOwnProperty(e)},f=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],a=" ",c='"',s="/",p="<",l=">";n.element=function(n,e,t){var o=[],u=-1===f.indexOf(n),d=i(e,(function(n,e){if(null!=n)return[r(e),[c,r(n),c].join("")].join("=")})).join(a);return o.push([p,n,a,d,l].join("")),t&&o.push(t instanceof Array?t.join(""):t),u&&o.push([p,s,n,l].join("")),o.join("")},n.safeValue=function(n,e){var t=n;return null==t?"":!0===Boolean(e)?r(t):t}}));
|
package/dist/umd/index.js
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
};
|
|
64
64
|
var safeValue = function safeValue(value, escape) {
|
|
65
65
|
var check = value;
|
|
66
|
-
return check == null ? '' : escape === true ? entities(check) : check;
|
|
66
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
67
67
|
};
|
|
68
68
|
var instanceOf = function instanceOf(object, instance) {
|
|
69
69
|
return Boolean(object instanceof instance);
|
|
@@ -433,31 +433,88 @@
|
|
|
433
433
|
return result.join('');
|
|
434
434
|
};
|
|
435
435
|
|
|
436
|
+
/**
|
|
437
|
+
* @extends Error
|
|
438
|
+
* @property code
|
|
439
|
+
* @param {string} message
|
|
440
|
+
* @constructor
|
|
441
|
+
*/
|
|
436
442
|
function TemplateError(message) {
|
|
437
|
-
this.code = 1;
|
|
438
443
|
this.name = 'TemplateError';
|
|
439
444
|
this.message = message;
|
|
440
445
|
Error.call(this);
|
|
441
446
|
}
|
|
442
|
-
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
*
|
|
450
|
+
*/
|
|
451
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
452
|
+
Object.assign(TemplateError.prototype, {
|
|
453
|
+
code: 1
|
|
454
|
+
});
|
|
455
|
+
/**
|
|
456
|
+
*
|
|
457
|
+
* @return {number}
|
|
458
|
+
*/
|
|
459
|
+
TemplateError.prototype.getCode = function () {
|
|
460
|
+
return this.code;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
*
|
|
464
|
+
* @return {string}
|
|
465
|
+
*/
|
|
466
|
+
TemplateError.prototype.getMessage = function () {
|
|
467
|
+
return this.message;
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* @return {string}
|
|
471
|
+
*/
|
|
472
|
+
TemplateError.prototype.toString = function () {
|
|
473
|
+
return this.getMessage();
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* @extends TemplateError
|
|
478
|
+
* @param {string} message
|
|
479
|
+
* @constructor
|
|
480
|
+
*/
|
|
443
481
|
function TemplateNotFound(message) {
|
|
444
482
|
TemplateError.call(this);
|
|
445
|
-
this.code = 404;
|
|
446
483
|
this.name = 'TemplateNotFound';
|
|
447
484
|
this.message = message;
|
|
448
485
|
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
*
|
|
489
|
+
*/
|
|
449
490
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
491
|
+
Object.assign(TemplateNotFound.prototype, {
|
|
492
|
+
code: 404
|
|
493
|
+
});
|
|
494
|
+
/**
|
|
495
|
+
* @extends TemplateError
|
|
496
|
+
* @param {string} message
|
|
497
|
+
* @constructor
|
|
498
|
+
*/
|
|
450
499
|
function TemplateSyntaxError(message) {
|
|
451
500
|
TemplateError.call(this);
|
|
452
|
-
this.code = 500;
|
|
453
501
|
this.name = 'TemplateSyntaxError';
|
|
454
502
|
this.message = message;
|
|
455
503
|
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
*
|
|
507
|
+
*/
|
|
456
508
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
509
|
+
Object.assign(TemplateSyntaxError.prototype, {
|
|
510
|
+
code: 500
|
|
511
|
+
});
|
|
457
512
|
|
|
458
513
|
function resolve(list) {
|
|
459
514
|
return Promise.all(list || []).then(function (list) {
|
|
460
515
|
return list.join('');
|
|
516
|
+
})["catch"](function (e) {
|
|
517
|
+
return e;
|
|
461
518
|
});
|
|
462
519
|
}
|
|
463
520
|
function reject(error) {
|
|
@@ -924,6 +981,9 @@
|
|
|
924
981
|
create = ejs.create;
|
|
925
982
|
var __express = expressRenderer(ejs);
|
|
926
983
|
|
|
984
|
+
exports.TemplateError = TemplateError;
|
|
985
|
+
exports.TemplateNotFound = TemplateNotFound;
|
|
986
|
+
exports.TemplateSyntaxError = TemplateSyntaxError;
|
|
927
987
|
exports.__express = __express;
|
|
928
988
|
exports.compile = compile;
|
|
929
989
|
exports.configure = configure;
|
package/dist/umd/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ejs={})}(this,(function(e){"use strict";var t=function(){var e=[].slice.call(arguments),t=e.shift();return e.filter(t).pop()},n=function(e){return Array.isArray(e)},r=function(e){return"function"==typeof e},i=function(e){return"string"==typeof e},o=function(e){return"boolean"==typeof e},u=function(e){return void 0===e},c="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},l={"&":"&","<":"<",">":">",'"':""","'":"'"},s=function(e){return new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g")},f=s(l),h=s(a),p=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(f,(function(e){return l[e]}))},b=function(e,t){var n=e;return null==n?"":!0===t?p(n):n},v=function(e,t){return Boolean(e instanceof t)},g=function(e,t,n){for(var i=e,o=String(t).split("."),u=o.pop(),c=0;c<o.length;c++){var a=o[c];if(r(i.toJSON)&&(i=i.toJSON()),n&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}return r(i.toJSON)&&(i=i.toJSON()),[i,u]},m=function(e,t){var n=e.split(".").pop();return n!==t&&(e=[e,t].join(".")),e},d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.filter((function(e){return e})).reduce((function(e,t){return Object.assign(e,t)}),e)},w=function(){},y=function(e,t){var n;for(n in e)O(e,n)&&t(e[n],n,e)},j=function(e,t){return function(e,t){var n=e instanceof Array,r=n?[]:{};return y(e,(function(e,i,o){var c=t(e,i,o);!1===u(c)&&(n?r.push(c):r[i]=c)})),r}(e,(function(e,n){if(-1===t.indexOf(n))return e}))},E=function(e,t,n){return Promise.resolve(e).then(t.bind(n))},O=function(e,t){return e&&e.hasOwnProperty(t)},x={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(e,t){return Promise.resolve(["resolver is not defined",e,t].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},k=function(e,u){d(e,{path:t(i,x.path,e.path,u.path),export:t(i,x.export,e.export,u.export),resolver:t(r,x.resolver,e.resolver,u.resolver),extension:t(i,x.extension,e.extension,u.extension),withObject:t(o,x.withObject,e.withObject,u.withObject),rmWhitespace:t(o,x.rmWhitespace,e.rmWhitespace,u.rmWhitespace),cache:t(o,x.cache,e.cache,u.cache),token:d({},x.token,e.token,u.token),vars:d({},x.vars,e.vars,u.vars),globalHelpers:t(n,x.globalHelpers,e.globalHelpers,u.globalHelpers)})},F="undefined"!=typeof globalThis?globalThis:window||self;function P(e){if(!1===v(this,P))return new P;var t={enabled:!0,list:{}};this.configure=function(e){t.enabled=e.cache,!1===c&&this.load(F[e.export])},this.clear=function(){t.list={}},this.load=function(e){return t.enabled&&d(t.list,e||{}),this},this.get=function(e){if(t.enabled)return t.list[e]},this.set=function(e,n){return t.enabled&&(t.list[e]=n),this},this.resolve=function(e){return Promise.resolve(this.get(e))},this.remove=function(e){delete t.list[e]},this.exist=function(e){return O(t.list,e)}}var S=[{symbol:"-",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(e){return"')\n/**".concat(e,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(e){return"')\n".concat(e.trim(),"\n").concat(this.BUFFER,"('")}}];function B(e){if(!1===v(this,B))return new B(e);var t={};this.configure=function(e){t.withObject=e.withObject,t.rmWhitespace=e.rmWhitespace,t.token=e.token,t.vars=e.vars,t.globalHelpers=e.globalHelpers,t.matches=[],t.formats=[],t.slurp={match:"[ \\t]*",start:[t.token.start,"_"],end:["_",t.token.end]},S.forEach((function(e){t.matches.push(t.token.start.concat(e.symbol).concat(t.token.regex).concat(t.token.end)),t.formats.push(e.format.bind(t.vars))})),t.regex=new RegExp(t.matches.join("|").concat("|$"),"g"),t.slurpStart=new RegExp([t.slurp.match,t.slurp.start.join("")].join(""),"gm"),t.slurpEnd=new RegExp([t.slurp.end.join(""),t.slurp.match].join(""),"gm")},this.compile=function(e,n){var r=t.vars,i=r.SCOPE,o=r.SAFE,u=r.BUFFER,c=r.COMPONENT,l=t.globalHelpers;e=String(e),t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),e=e.replace(t.slurpStart,t.token.start).replace(t.slurpEnd,t.token.end);var s,f,p,b="".concat(u,"('");s=t.regex,f=function(n,r,i){b+=(""+e.slice(r,i)).replace(h,(function(e){return"\\"+a[e]})),n.forEach((function(e,n){e&&(b+=t.formats[n](e))}))},p=0,e.replace(s,(function(){var e=[].slice.call(arguments,0,-1),t=e.pop(),n=e.shift();return f(e,p,t),p=t+n.length,n})),b="try{".concat(b+="');","}catch(e){return ").concat(u,".error(e)}"),t.withObject&&(b="with(".concat(i,"){").concat(b,"}")),b="".concat(u,".start();").concat(b,"return ").concat(u,".end();"),b+="\n//# sourceURL=".concat(n);var v=null,g=[i,c,u,o].concat(l);try{(v=Function.apply(null,g.concat(b))).source="(function(".concat(g.join(","),"){\n").concat(b,"\n});")}catch(e){throw e.filename=n,e.source=b,e}return v},this.configure(e)}function T(e,t,n){if(!1===v(this,T))return new T(e,t,n);if(!1===v(t,P))throw new TypeError("cache is not instance of Cache");if(!1===v(n,B))throw new TypeError("compiler is not instance of Compiler");var i={},o=function(e){return i.resolver(i.path,e)};this.configure=function(e){i.path=e.path,i.cache=e.cache,r(e.resolver)&&(i.resolver=e.resolver)},this.get=function(e){return t.exist(e)?t.resolve(e):o(e).then((function(i){return function(e,n){return t.set(e,n),n}(e,function(e,t){return r(e)?e:n.compile(e,t)}(i,e))}))},this.configure(e)}function R(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],$=" ",A='"',C="/",U="<",M=">",H=function(e,t,n){var r=[],i=-1===N.indexOf(e),o=function(e,t){var n=[];return y(e,(function(e,r,i){var o=t(e,r,i);!1===u(o)&&n.push(o)})),n}(t,(function(e,t){if(null!=e)return[p(t),[A,p(e),A].join("")].join("=")})).join($);return r.push([U,e,$,o,M].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([U,C,e,M].join("")),r.join("")};function L(e){this.code=1,this.name="TemplateError",this.message=e,Error.call(this)}function W(e){L.call(this),this.code=404,this.name="TemplateNotFound",this.message=e}function J(e){L.call(this),this.code=500,this.name="TemplateSyntaxError",this.message=e}function _(e){return Promise.all(e||[]).then((function(e){return e.join("")}))}function q(){var e=[],t=[];function n(e){t.push(e)}return n.start=function(){t=[]},n.backup=function(){e.push(t.concat()),t=[]},n.restore=function(){var n=t.concat();return t=e.pop(),_(n)},n.error=function(e){return t=e,Promise.reject(new J(t.message));var t},n.end=function(){return _(t)},n}function D(e){if(!1===v(this,D))return new D(e);this.configure=function(e,t){var n,o=e.vars,u=o.BLOCKS,c=o.MACRO,a=o.EXTEND,l=o.LAYOUT,s=o.BUFFER,f=o.COMPONENT;function h(e){this[u]={},this[c]={},d(this,e||{})}this.create=function(e){return new h(e)},this.helpers=function(e){d(h.prototype,e||{})},h.prototype=d({},t||{}),Object.defineProperties(h.prototype,(R(R(R(R(R(R(R(R(R(R(n={},s,{value:q(),writable:!0,configurable:!1,enumerable:!1}),u,{value:{},writable:!0,configurable:!1,enumerable:!1}),c,{value:{},writable:!0,configurable:!1,enumerable:!1}),l,{value:!1,writable:!0,configurable:!1,enumerable:!1}),a,{value:!1,writable:!0,configurable:!1,enumerable:!1}),"getMacro",{value:function(){return this[c]},writable:!1,configurable:!1,enumerable:!1}),"getBuffer",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),"getComponent",{value:function(){var e=this;return f in e?function(){return e[f].apply(e,arguments)}:function(){console.log("%s function not defined",f)}},writable:!1,configurable:!1,enumerable:!1}),"getBlocks",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),"setExtend",{value:function(e){this[a]=e},writable:!1,configurable:!1,enumerable:!1}),R(R(R(R(R(R(R(R(R(R(n,"getExtend",{value:function(){return this[a]},writable:!1,configurable:!1,enumerable:!1}),"setLayout",{value:function(e){this[l]=e},writable:!1,configurable:!1,enumerable:!1}),"getLayout",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),"clone",{value:function(e){var t=[l,a,s];return!0===e&&t.push(u),j(this,t)},writable:!1,configurable:!1,enumerable:!1}),"extend",{value:function(e){this.setExtend(!0),this.setLayout(e)},writable:!1,configurable:!1,enumerable:!1}),"echo",{value:function(e){var t=this.getBuffer();[].slice.call(arguments).forEach(t)},writable:!1,configurable:!1,enumerable:!1}),"fn",{value:function(e){var t=this.getBuffer(),n=this;return function(){return t.backup(),r(e)&&e.apply(n,arguments),t.restore()}},writable:!1,configurable:!1,enumerable:!1}),"get",{value:function(e,t){var n=g(this,e,!0),r=n.shift(),i=n.pop();return O(r,i)?r[i]:t},writable:!0,configurable:!0,enumerable:!1}),"set",{value:function(e,t){var n=g(this,e,!1),r=n.shift(),i=n.pop();return this.getExtend()&&O(r,i)?r[i]:r[i]=t},writable:!1,configurable:!1,enumerable:!1}),"macro",{value:function(e,t){var n=this.getMacro(),r=this.fn(t),i=this;n[e]=function(){return i.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),R(R(R(R(R(R(R(R(R(n,"call",{value:function(e){var t=this.getMacro()[e],n=[].slice.call(arguments,1);if(r(t))return t.apply(t,n)},writable:!1,configurable:!1,enumerable:!1}),"block",{value:function(e,t){var n=this,r=this.getBlocks();if(r[e]=r[e]||[],r[e].push(this.fn(t)),!this.getExtend()){var i=Object.assign([],r[e]),o=function(){return i.shift()},u=function(){var e=o();return e?function(){n.echo(e(u()))}:w};this.echo(o()(u()))}},writable:!1,configurable:!1,enumerable:!1}),"hasBlock",{value:function(e){return this.getBlocks().hasOwnProperty(e)},writable:!1,configurable:!1,enumerable:!1}),"include",{value:function(e,t,n){var r=!1===n?{}:this.clone(!0),i=d(r,t||{}),o=this.render(e,i);this.echo(o)},writable:!1,configurable:!1,enumerable:!1}),"use",{value:function(e,t){var n=this.require(e);this.echo(E(n,(function(e){var n=this.getMacro();y(e,(function(e,r){n[[t,r].join(".")]=e}))}),this))},writable:!1,configurable:!1,enumerable:!1}),"async",{value:function(e,t){this.echo(E(e,(function(e){return this.fn(t)(e)}),this))},writable:!1,configurable:!1,enumerable:!1}),"each",{value:function(e,t){i(e)&&(e=this.get(e,[])),y(e,t)},writable:!1,configurable:!1,enumerable:!1}),"element",{value:function(e,t,n){return H(e,t,n)},writable:!1,configurable:!1,enumerable:!1}),"el",{value:function(e,t,n){r(n)&&(n=this.fn(n)()),this.echo(E(n,(function(n){return this.element(e,t,n)}),this))},writable:!1,configurable:!1,enumerable:!1})))},this.configure(e)}Object.setPrototypeOf(W.prototype,Error.prototype),Object.setPrototypeOf(W.prototype,L.prototype),Object.setPrototypeOf(J.prototype,L.prototype);var K={};var X=new function e(t){if(!1===v(this,e))return new e(t);var n={},i={};k(i,t||{});var o=new D(i),u=new B(i),c=new P,a=new T(i,c,u),l=function(e,t){var n=i.globalHelpers,o=[t,t.getComponent(),t.getBuffer(),b].concat(n.filter((function(e){return r(t[e])})).map((function(e){return t[e].bind(t)})));return a.get(e).then((function(e){return e.apply(t,o)}))},s=function(e,t){var n=m(e,i.extension),r=o.create(t);return l(n,r).then((function(e){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),n=r.clone();return s(t,n)}return e}))};return this.configure=function(e){return k(i,e=e||{}),o.configure(i,n),u.configure(i),c.configure(i),a.configure(i),i},this.render=function(e,t){return s(e,t)},this.helpers=function(e){o.helpers(d(n,e))},this.preload=function(e){return c.load(e||{})},this.create=function(t){return new e(t)},this.compile=function(e,t){return u.compile(e,t)},this.context=function(e){return o.create(e)},this.helpers({require:function(e){var t=m(e,i.extension),n=o.create({});return l(t,n).then((function(){return n.getMacro()}))},render:s}),this}({resolver:function(e,t){return new Promise((function(n,r){K.readFile(function(e,t){return(t=[e,t].join("/")).replace(/\/\//g,"/")}(e,t),(function(e,t){e?r(new L(e)):n(t.toString())}))}))}}),Y=X.render,z=X.context,G=X.compile,I=X.helpers,Q=X.preload,V=X.configure,Z=X.create,ee=function(e){return function(n,u,c){r(u)&&(c=u,u={});var a=d({},(u=u||{}).settings),l=t(i,x.path,a.views),s=t(o,x.cache,a["view cache"]),f=d({},a["view options"]),h=K.relative(l,n);return f.path=l,f.cache=s,e.configure(f),e.render(h,u).then((function(e){c(null,e)})).catch((function(e){c(e)}))}}(X);e.__express=ee,e.compile=G,e.configure=V,e.context=z,e.create=Z,e.helpers=I,e.preload=Q,e.render=Y}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ejs={})}(this,(function(e){"use strict";var t=function(){var e=[].slice.call(arguments),t=e.shift();return e.filter(t).pop()},n=function(e){return Array.isArray(e)},r=function(e){return"function"==typeof e},o=function(e){return"string"==typeof e},i=function(e){return"boolean"==typeof e},c=function(e){return void 0===e},u="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},s={"&":"&","<":"<",">":">",'"':""","'":"'"},l=function(e){return new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g")},f=l(s),h=l(a),p=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(f,(function(e){return s[e]}))},b=function(e,t){var n=e;return null==n?"":!0===Boolean(t)?p(n):n},g=function(e,t){return Boolean(e instanceof t)},v=function(e,t,n){for(var o=e,i=String(t).split("."),c=i.pop(),u=0;u<i.length;u++){var a=i[u];if(r(o.toJSON)&&(o=o.toJSON()),n&&!1===o.hasOwnProperty(a)){o={};break}o=o[a]=o[a]||{}}return r(o.toJSON)&&(o=o.toJSON()),[o,c]},m=function(e,t){var n=e.split(".").pop();return n!==t&&(e=[e,t].join(".")),e},d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.filter((function(e){return e})).reduce((function(e,t){return Object.assign(e,t)}),e)},w=function(){},y=function(e,t){var n;for(n in e)O(e,n)&&t(e[n],n,e)},j=function(e,t){return function(e,t){var n=e instanceof Array,r=n?[]:{};return y(e,(function(e,o,i){var u=t(e,o,i);!1===c(u)&&(n?r.push(u):r[o]=u)})),r}(e,(function(e,n){if(-1===t.indexOf(n))return e}))},E=function(e,t,n){return Promise.resolve(e).then(t.bind(n))},O=function(e,t){return e&&e.hasOwnProperty(t)},x={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(e,t){return Promise.resolve(["resolver is not defined",e,t].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},k=function(e,c){d(e,{path:t(o,x.path,e.path,c.path),export:t(o,x.export,e.export,c.export),resolver:t(r,x.resolver,e.resolver,c.resolver),extension:t(o,x.extension,e.extension,c.extension),withObject:t(i,x.withObject,e.withObject,c.withObject),rmWhitespace:t(i,x.rmWhitespace,e.rmWhitespace,c.rmWhitespace),cache:t(i,x.cache,e.cache,c.cache),token:d({},x.token,e.token,c.token),vars:d({},x.vars,e.vars,c.vars),globalHelpers:t(n,x.globalHelpers,e.globalHelpers,c.globalHelpers)})},F="undefined"!=typeof globalThis?globalThis:window||self;function S(e){if(!1===g(this,S))return new S;var t={enabled:!0,list:{}};this.configure=function(e){t.enabled=e.cache,!1===u&&this.load(F[e.export])},this.clear=function(){t.list={}},this.load=function(e){return t.enabled&&d(t.list,e||{}),this},this.get=function(e){if(t.enabled)return t.list[e]},this.set=function(e,n){return t.enabled&&(t.list[e]=n),this},this.resolve=function(e){return Promise.resolve(this.get(e))},this.remove=function(e){delete t.list[e]},this.exist=function(e){return O(t.list,e)}}var P=[{symbol:"-",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(e){return"')\n/**".concat(e,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(e){return"')\n".concat(e.trim(),"\n").concat(this.BUFFER,"('")}}];function B(e){if(!1===g(this,B))return new B(e);var t={};this.configure=function(e){t.withObject=e.withObject,t.rmWhitespace=e.rmWhitespace,t.token=e.token,t.vars=e.vars,t.globalHelpers=e.globalHelpers,t.matches=[],t.formats=[],t.slurp={match:"[ \\t]*",start:[t.token.start,"_"],end:["_",t.token.end]},P.forEach((function(e){t.matches.push(t.token.start.concat(e.symbol).concat(t.token.regex).concat(t.token.end)),t.formats.push(e.format.bind(t.vars))})),t.regex=new RegExp(t.matches.join("|").concat("|$"),"g"),t.slurpStart=new RegExp([t.slurp.match,t.slurp.start.join("")].join(""),"gm"),t.slurpEnd=new RegExp([t.slurp.end.join(""),t.slurp.match].join(""),"gm")},this.compile=function(e,n){var r=t.vars,o=r.SCOPE,i=r.SAFE,c=r.BUFFER,u=r.COMPONENT,s=t.globalHelpers;e=String(e),t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),e=e.replace(t.slurpStart,t.token.start).replace(t.slurpEnd,t.token.end);var l,f,p,b="".concat(c,"('");l=t.regex,f=function(n,r,o){b+=(""+e.slice(r,o)).replace(h,(function(e){return"\\"+a[e]})),n.forEach((function(e,n){e&&(b+=t.formats[n](e))}))},p=0,e.replace(l,(function(){var e=[].slice.call(arguments,0,-1),t=e.pop(),n=e.shift();return f(e,p,t),p=t+n.length,n})),b="try{".concat(b+="');","}catch(e){return ").concat(c,".error(e)}"),t.withObject&&(b="with(".concat(o,"){").concat(b,"}")),b="".concat(c,".start();").concat(b,"return ").concat(c,".end();"),b+="\n//# sourceURL=".concat(n);var g=null,v=[o,u,c,i].concat(s);try{(g=Function.apply(null,v.concat(b))).source="(function(".concat(v.join(","),"){\n").concat(b,"\n});")}catch(e){throw e.filename=n,e.source=b,e}return g},this.configure(e)}function T(e,t,n){if(!1===g(this,T))return new T(e,t,n);if(!1===g(t,S))throw new TypeError("cache is not instance of Cache");if(!1===g(n,B))throw new TypeError("compiler is not instance of Compiler");var o={},i=function(e){return o.resolver(o.path,e)};this.configure=function(e){o.path=e.path,o.cache=e.cache,r(e.resolver)&&(o.resolver=e.resolver)},this.get=function(e){return t.exist(e)?t.resolve(e):i(e).then((function(o){return function(e,n){return t.set(e,n),n}(e,function(e,t){return r(e)?e:n.compile(e,t)}(o,e))}))},this.configure(e)}function R(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],C=" ",$='"',A="/",M="<",U=">",H=function(e,t,n){var r=[],o=-1===N.indexOf(e),i=function(e,t){var n=[];return y(e,(function(e,r,o){var i=t(e,r,o);!1===c(i)&&n.push(i)})),n}(t,(function(e,t){if(null!=e)return[p(t),[$,p(e),$].join("")].join("=")})).join(C);return r.push([M,e,C,i,U].join("")),n&&r.push(n instanceof Array?n.join(""):n),o&&r.push([M,A,e,U].join("")),r.join("")};function L(e){this.name="TemplateError",this.message=e,Error.call(this)}function W(e){L.call(this),this.name="TemplateNotFound",this.message=e}function J(e){L.call(this),this.name="TemplateSyntaxError",this.message=e}function _(e){return Promise.all(e||[]).then((function(e){return e.join("")})).catch((function(e){return e}))}function q(){var e=[],t=[];function n(e){t.push(e)}return n.start=function(){t=[]},n.backup=function(){e.push(t.concat()),t=[]},n.restore=function(){var n=t.concat();return t=e.pop(),_(n)},n.error=function(e){return t=e,Promise.reject(new J(t.message));var t},n.end=function(){return _(t)},n}function D(e){if(!1===g(this,D))return new D(e);this.configure=function(e,t){var n,i=e.vars,c=i.BLOCKS,u=i.MACRO,a=i.EXTEND,s=i.LAYOUT,l=i.BUFFER,f=i.COMPONENT;function h(e){this[c]={},this[u]={},d(this,e||{})}this.create=function(e){return new h(e)},this.helpers=function(e){d(h.prototype,e||{})},h.prototype=d({},t||{}),Object.defineProperties(h.prototype,(R(R(R(R(R(R(R(R(R(R(n={},l,{value:q(),writable:!0,configurable:!1,enumerable:!1}),c,{value:{},writable:!0,configurable:!1,enumerable:!1}),u,{value:{},writable:!0,configurable:!1,enumerable:!1}),s,{value:!1,writable:!0,configurable:!1,enumerable:!1}),a,{value:!1,writable:!0,configurable:!1,enumerable:!1}),"getMacro",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),"getBuffer",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),"getComponent",{value:function(){var e=this;return f in e?function(){return e[f].apply(e,arguments)}:function(){console.log("%s function not defined",f)}},writable:!1,configurable:!1,enumerable:!1}),"getBlocks",{value:function(){return this[c]},writable:!1,configurable:!1,enumerable:!1}),"setExtend",{value:function(e){this[a]=e},writable:!1,configurable:!1,enumerable:!1}),R(R(R(R(R(R(R(R(R(R(n,"getExtend",{value:function(){return this[a]},writable:!1,configurable:!1,enumerable:!1}),"setLayout",{value:function(e){this[s]=e},writable:!1,configurable:!1,enumerable:!1}),"getLayout",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),"clone",{value:function(e){var t=[s,a,l];return!0===e&&t.push(c),j(this,t)},writable:!1,configurable:!1,enumerable:!1}),"extend",{value:function(e){this.setExtend(!0),this.setLayout(e)},writable:!1,configurable:!1,enumerable:!1}),"echo",{value:function(e){var t=this.getBuffer();[].slice.call(arguments).forEach(t)},writable:!1,configurable:!1,enumerable:!1}),"fn",{value:function(e){var t=this.getBuffer(),n=this;return function(){return t.backup(),r(e)&&e.apply(n,arguments),t.restore()}},writable:!1,configurable:!1,enumerable:!1}),"get",{value:function(e,t){var n=v(this,e,!0),r=n.shift(),o=n.pop();return O(r,o)?r[o]:t},writable:!0,configurable:!0,enumerable:!1}),"set",{value:function(e,t){var n=v(this,e,!1),r=n.shift(),o=n.pop();return this.getExtend()&&O(r,o)?r[o]:r[o]=t},writable:!1,configurable:!1,enumerable:!1}),"macro",{value:function(e,t){var n=this.getMacro(),r=this.fn(t),o=this;n[e]=function(){return o.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),R(R(R(R(R(R(R(R(R(n,"call",{value:function(e){var t=this.getMacro()[e],n=[].slice.call(arguments,1);if(r(t))return t.apply(t,n)},writable:!1,configurable:!1,enumerable:!1}),"block",{value:function(e,t){var n=this,r=this.getBlocks();if(r[e]=r[e]||[],r[e].push(this.fn(t)),!this.getExtend()){var o=Object.assign([],r[e]),i=function(){return o.shift()},c=function(){var e=i();return e?function(){n.echo(e(c()))}:w};this.echo(i()(c()))}},writable:!1,configurable:!1,enumerable:!1}),"hasBlock",{value:function(e){return this.getBlocks().hasOwnProperty(e)},writable:!1,configurable:!1,enumerable:!1}),"include",{value:function(e,t,n){var r=!1===n?{}:this.clone(!0),o=d(r,t||{}),i=this.render(e,o);this.echo(i)},writable:!1,configurable:!1,enumerable:!1}),"use",{value:function(e,t){var n=this.require(e);this.echo(E(n,(function(e){var n=this.getMacro();y(e,(function(e,r){n[[t,r].join(".")]=e}))}),this))},writable:!1,configurable:!1,enumerable:!1}),"async",{value:function(e,t){this.echo(E(e,(function(e){return this.fn(t)(e)}),this))},writable:!1,configurable:!1,enumerable:!1}),"each",{value:function(e,t){o(e)&&(e=this.get(e,[])),y(e,t)},writable:!1,configurable:!1,enumerable:!1}),"element",{value:function(e,t,n){return H(e,t,n)},writable:!1,configurable:!1,enumerable:!1}),"el",{value:function(e,t,n){r(n)&&(n=this.fn(n)()),this.echo(E(n,(function(n){return this.element(e,t,n)}),this))},writable:!1,configurable:!1,enumerable:!1})))},this.configure(e)}Object.setPrototypeOf(L.prototype,Error.prototype),Object.assign(L.prototype,{code:1}),L.prototype.getCode=function(){return this.code},L.prototype.getMessage=function(){return this.message},L.prototype.toString=function(){return this.getMessage()},Object.setPrototypeOf(W.prototype,L.prototype),Object.assign(W.prototype,{code:404}),Object.setPrototypeOf(J.prototype,L.prototype),Object.assign(J.prototype,{code:500});var K={};var X=new function e(t){if(!1===g(this,e))return new e(t);var n={},o={};k(o,t||{});var i=new D(o),c=new B(o),u=new S,a=new T(o,u,c),s=function(e,t){var n=o.globalHelpers,i=[t,t.getComponent(),t.getBuffer(),b].concat(n.filter((function(e){return r(t[e])})).map((function(e){return t[e].bind(t)})));return a.get(e).then((function(e){return e.apply(t,i)}))},l=function(e,t){var n=m(e,o.extension),r=i.create(t);return s(n,r).then((function(e){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),n=r.clone();return l(t,n)}return e}))};return this.configure=function(e){return k(o,e=e||{}),i.configure(o,n),c.configure(o),u.configure(o),a.configure(o),o},this.render=function(e,t){return l(e,t)},this.helpers=function(e){i.helpers(d(n,e))},this.preload=function(e){return u.load(e||{})},this.create=function(t){return new e(t)},this.compile=function(e,t){return c.compile(e,t)},this.context=function(e){return i.create(e)},this.helpers({require:function(e){var t=m(e,o.extension),n=i.create({});return s(t,n).then((function(){return n.getMacro()}))},render:l}),this}({resolver:function(e,t){return new Promise((function(n,r){K.readFile(function(e,t){return(t=[e,t].join("/")).replace(/\/\//g,"/")}(e,t),(function(e,t){e?r(new L(e)):n(t.toString())}))}))}}),Y=X.render,z=X.context,G=X.compile,I=X.helpers,Q=X.preload,V=X.configure,Z=X.create,ee=function(e){return function(n,c,u){r(c)&&(u=c,c={});var a=d({},(c=c||{}).settings),s=t(o,x.path,a.views),l=t(i,x.cache,a["view cache"]),f=d({},a["view options"]),h=K.relative(s,n);return f.path=s,f.cache=l,e.configure(f),e.render(h,c).then((function(e){u(null,e)})).catch((function(e){u(e)}))}}(X);e.TemplateError=L,e.TemplateNotFound=W,e.TemplateSyntaxError=J,e.__express=ee,e.compile=G,e.configure=V,e.context=z,e.create=Z,e.helpers=I,e.preload=Q,e.render=Y}));
|
package/dist/umd/worker.js
CHANGED
|
@@ -412,7 +412,7 @@
|
|
|
412
412
|
};
|
|
413
413
|
var safeValue = function safeValue(value, escape) {
|
|
414
414
|
var check = value;
|
|
415
|
-
return check == null ? '' : escape === true ? entities(check) : check;
|
|
415
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
416
416
|
};
|
|
417
417
|
var instanceOf = function instanceOf(object, instance) {
|
|
418
418
|
return Boolean(object instanceof instance);
|
|
@@ -754,31 +754,88 @@
|
|
|
754
754
|
return result.join('');
|
|
755
755
|
};
|
|
756
756
|
|
|
757
|
+
/**
|
|
758
|
+
* @extends Error
|
|
759
|
+
* @property code
|
|
760
|
+
* @param {string} message
|
|
761
|
+
* @constructor
|
|
762
|
+
*/
|
|
757
763
|
function TemplateError(message) {
|
|
758
|
-
this.code = 1;
|
|
759
764
|
this.name = 'TemplateError';
|
|
760
765
|
this.message = message;
|
|
761
766
|
Error.call(this);
|
|
762
767
|
}
|
|
763
|
-
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
*
|
|
771
|
+
*/
|
|
772
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
773
|
+
Object.assign(TemplateError.prototype, {
|
|
774
|
+
code: 1
|
|
775
|
+
});
|
|
776
|
+
/**
|
|
777
|
+
*
|
|
778
|
+
* @return {number}
|
|
779
|
+
*/
|
|
780
|
+
TemplateError.prototype.getCode = function () {
|
|
781
|
+
return this.code;
|
|
782
|
+
};
|
|
783
|
+
/**
|
|
784
|
+
*
|
|
785
|
+
* @return {string}
|
|
786
|
+
*/
|
|
787
|
+
TemplateError.prototype.getMessage = function () {
|
|
788
|
+
return this.message;
|
|
789
|
+
};
|
|
790
|
+
/**
|
|
791
|
+
* @return {string}
|
|
792
|
+
*/
|
|
793
|
+
TemplateError.prototype.toString = function () {
|
|
794
|
+
return this.getMessage();
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* @extends TemplateError
|
|
799
|
+
* @param {string} message
|
|
800
|
+
* @constructor
|
|
801
|
+
*/
|
|
764
802
|
function TemplateNotFound(message) {
|
|
765
803
|
TemplateError.call(this);
|
|
766
|
-
this.code = 404;
|
|
767
804
|
this.name = 'TemplateNotFound';
|
|
768
805
|
this.message = message;
|
|
769
806
|
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
*
|
|
810
|
+
*/
|
|
770
811
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
812
|
+
Object.assign(TemplateNotFound.prototype, {
|
|
813
|
+
code: 404
|
|
814
|
+
});
|
|
815
|
+
/**
|
|
816
|
+
* @extends TemplateError
|
|
817
|
+
* @param {string} message
|
|
818
|
+
* @constructor
|
|
819
|
+
*/
|
|
771
820
|
function TemplateSyntaxError(message) {
|
|
772
821
|
TemplateError.call(this);
|
|
773
|
-
this.code = 500;
|
|
774
822
|
this.name = 'TemplateSyntaxError';
|
|
775
823
|
this.message = message;
|
|
776
824
|
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
*
|
|
828
|
+
*/
|
|
777
829
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
830
|
+
Object.assign(TemplateSyntaxError.prototype, {
|
|
831
|
+
code: 500
|
|
832
|
+
});
|
|
778
833
|
|
|
779
834
|
function resolve(list) {
|
|
780
835
|
return Promise.all(list || []).then(function (list) {
|
|
781
836
|
return list.join('');
|
|
837
|
+
})["catch"](function (e) {
|
|
838
|
+
return e;
|
|
782
839
|
});
|
|
783
840
|
}
|
|
784
841
|
function reject(error) {
|
|
@@ -1217,6 +1274,7 @@
|
|
|
1217
1274
|
/**
|
|
1218
1275
|
* @typedef {Object<string,any>} HonoContext
|
|
1219
1276
|
* @property {function(*):Promise<Response>} html
|
|
1277
|
+
* @property {function():Promise<Response>} notFound
|
|
1220
1278
|
* @property {function(name:string,data:{}):Promise<string>} render
|
|
1221
1279
|
* @property {function(name:string,data:{}):Promise<string>} ejs
|
|
1222
1280
|
* @property {ContextScope} data
|
|
@@ -1232,6 +1290,7 @@
|
|
|
1232
1290
|
secure = _ref$secure === void 0 ? true : _ref$secure,
|
|
1233
1291
|
_ref$version = _ref.version,
|
|
1234
1292
|
version = _ref$version === void 0 ? '1.0' : _ref$version;
|
|
1293
|
+
_ref.errorHandler;
|
|
1235
1294
|
return /*#__PURE__*/function () {
|
|
1236
1295
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(c, next) {
|
|
1237
1296
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -1267,6 +1326,9 @@
|
|
|
1267
1326
|
configure = ejs.configure,
|
|
1268
1327
|
create = ejs.create;
|
|
1269
1328
|
|
|
1329
|
+
exports.TemplateError = TemplateError;
|
|
1330
|
+
exports.TemplateNotFound = TemplateNotFound;
|
|
1331
|
+
exports.TemplateSyntaxError = TemplateSyntaxError;
|
|
1270
1332
|
exports.compile = compile;
|
|
1271
1333
|
exports.configure = configure;
|
|
1272
1334
|
exports.context = context;
|