@kosatyi/ejs 0.0.109 → 0.0.111
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 +338 -279
- package/dist/cjs/bundler.js +14 -6
- package/dist/cjs/element.js +3 -3
- package/dist/cjs/index.js +406 -350
- package/dist/cjs/worker.js +341 -298
- package/dist/esm/browser.js +138 -159
- package/dist/esm/bundler.js +14 -6
- package/dist/esm/element.js +2 -2
- package/dist/esm/index.js +258 -280
- package/dist/esm/worker.js +139 -174
- package/dist/umd/browser.js +832 -773
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/element.js +4 -4
- package/dist/umd/element.min.js +1 -1
- package/dist/umd/index.js +853 -797
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +341 -298
- package/dist/umd/worker.min.js +1 -1
- package/package.json +4 -4
- package/types/browser.d.ts +0 -6
- package/types/context.d.ts +19 -10
- package/types/ejs.d.ts +2 -5
- package/types/element.d.ts +9 -1
- package/types/error.d.ts +11 -11
- package/types/index.d.ts +0 -2
- package/types/worker.d.ts +0 -12
- package/dist/kosatyi-ejs-0.0.107.tgz +0 -0
- package/dist/kosatyi-ejs-0.0.108.tgz +0 -0
- package/dist/umd/browser.js.map +0 -7
- package/dist/umd/browser.min.js.map +0 -7
package/dist/umd/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejsInstance={})}(this,(function(t){"use strict";const e="ejsPrecompiled",s=!0,i="views",r="ejs",o=!0,n=!0,c=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),h=[],a={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},l={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},u=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,p=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},f=t=>Array.isArray(t),g=t=>"function"==typeof t,m=t=>"string"==typeof t,d=t=>"boolean"==typeof t,v=(t,v)=>{return Object.assign(t,{path:p(m,i,t.path,v.path),precompiled:p(m,e,t.export,v.export),resolver:p(g,c,t.resolver,v.resolver),extension:p(m,r,t.extension,v.extension),strict:p(d,n,t.strict,v.strict),rmWhitespace:p(d,o,t.rmWhitespace,v.rmWhitespace),cache:p(d,s,t.cache,v.cache),globals:p(f,h,t.globals,(b=v.globals,!!f(b)&&b.filter((t=>{const e=u.test(t);return!1===e&&console.log(`ejsConfig.globals: expected '${t}' to be valid variable name --\x3e skipped`),e})))),token:Object.assign({},l,t.token,v.token),vars:Object.assign({},a,t.vars,v.vars)});var b},b={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},x={"&":"&","<":"<",">":">",'"':""","'":"'"},y=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),j=y(x),E=y(b),$=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(j,(t=>x[t]))},O=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?$(s):s},w=(t,e,s)=>{let i=t,r=String(e).split("."),o=r.pop();for(let t=0;t<r.length;t++){const e=r[t];if(g(i.toJSON)&&(i=i.toJSON()),s&&!1===i.hasOwnProperty(e)){i={};break}i=i[e]=i[e]||{}}return g(i.toJSON)&&(i=i.toJSON()),[i,o]},P=(t,e)=>{let s;for(s in t)S(t,s)&&e(t[s],s,t)},k=(t,e)=>{const s={...t};for(const t of e)delete s[t];return s},S=(t,e)=>t&&Object.hasOwn(t,e),C=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for(let s=0,i=e.length;s<i;s++){const i=e[s];i in t&&(t[i]=t[i].bind(t))}};class T{#t;#e;#s;#i;static exports=["configure","get","compile"];constructor(t,e,s){C(this,this.constructor.exports),this.#s=e,this.#i=s,this.configure(t??{})}configure(t){this.#t=t.path,g(t.resolver)&&(this.#e=t.resolver)}#r(t){const e=this.#s.get(t);if(e instanceof Promise)return e;const s=Promise.resolve(this.#e(this.#t,t));return this.#s.set(t,s),s}compile(t,e){const s=this.#s.get(e);return"function"==typeof s?s:("string"==typeof t&&(t=this.#i.compile(t,e)),"function"==typeof t?(this.#s.set(e,t),t):void 0)}get(t){return this.#r(t).then((e=>this.compile(e,t)))}}const N=[["-",(t,e,s)=>`')\n${e}(${s}(${t},1))\n${e}('`],["=",(t,e,s)=>`')\n${e}(${s}(${t}))\n${e}('`],["#",(t,e)=>`')\n/**${t}**/\n${e}('`],["",(t,e)=>`')\n${t}\n${e}('`]];class B{#o={};static exports=["compile"];constructor(t){C(this,this.constructor.exports),this.configure(t)}configure(t){this.#o.strict=t.strict,this.#o.rmWhitespace=t.rmWhitespace,this.#o.token=t.token,this.#o.vars=t.vars,this.#o.globals=t.globals,this.#o.legacy=t.legacy??!0,this.#o.slurp={match:"[s\t\n]*",start:[this.#o.token.start,"_"],end:["_",this.#o.token.end]},this.#o.matches=[],this.#o.formats=[];for(const[t,e]of N)this.#o.matches.push(this.#o.token.start.concat(t).concat(this.#o.token.regex).concat(this.#o.token.end)),this.#o.formats.push(e);this.#o.regex=new RegExp(this.#o.matches.join("|").concat("|$"),"g"),this.#o.slurpStart=new RegExp([this.#o.slurp.match,this.#o.slurp.start.join("")].join(""),"gm"),this.#o.slurpEnd=new RegExp([this.#o.slurp.end.join(""),this.#o.slurp.match].join(""),"gm"),this.#o.globals.length&&(this.#o.legacy?this.#o.globalVariables=`const ${this.#o.globals.map((t=>`${t}=${this.#o.vars.SCOPE}.${t}`)).join(",")};`:this.#o.globalVariables=`const {${this.#o.globals.join(",")}} = ${this.#o.vars.SCOPE};`)}compile(t,e){const s=this.#o.globalVariables,{SCOPE:i,SAFE:r,BUFFER:o,COMPONENT:n,ELEMENT:c}=this.#o.vars;this.#o.rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(this.#o.slurpStart,this.#o.token.start).replace(this.#o.slurpEnd,this.#o.token.end);let h=`${o}('`;((t,e,s)=>{let i=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),r=t.shift();return s(t,i,e),i=e+r.length,r}))})(this.#o.regex,t,((e,s,i)=>{h+=(""+t.slice(s,i)).replace(E,(t=>"\\"+b[t])),e.forEach(((t,e)=>{t&&(h+=this.#o.formats[e](t.trim(),o,r))}))})),h+="');",h=`try{${h}}catch(e){return ${o}.error(e,'${e}')}`,!1===this.#o.strict&&(h=`with(${i}){${h}}`),h=`${o}.start();${h}return ${o}.end();`,h+=`\n//# sourceURL=${e}`,s&&(h=`${s}\n${h}`);try{const t=[i,n,c,o,r],e=Function.apply(null,t.concat(h));return e.source=`(function(${t.join(",")}){\n${h}\n});`,e}catch(t){throw t.filename=e,t.source=h,t}}}class L{static exports=["load","set","get","exist","clear","remove","resolve"];#s=!0;#n;#c={};constructor(t){C(this,this.constructor.exports),this.configure(t)}get(t){if(this.#s)return this.#c[t]}set(t,e){this.#s&&(this.#c[t]=e)}exist(t){if(this.#s)return this.#c.hasOwnProperty(t)}clear(){Object.keys(this.#c).forEach(this.remove)}remove(t){delete this.#c[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){this.#s&&Object.assign(this.#c,t||{})}configure(t){this.#s=t.cache,this.#n=t.precompiled,"object"==typeof window&&this.load(window[this.#n])}}const A=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=" ",M='"',R="/",q="<",U=">",W=t=>{let[e,s]=t;if(null!=s)return[$(e),[M,$(s),M].join("")].join("=")};class _ extends Error{name="TemplateError";constructor(t){super(t),t instanceof Error&&(this.stack=t.stack,this.filename=t.filename,this.lineno=t.lineno)}}class V extends _{name="TemplateSyntaxError";code=500}const J=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>t)),z=()=>{let t=[],e=[];const s=t=>{e.push(t)};return s.start=()=>{e=[]},s.backup=()=>{t.push(e.concat()),e=[]},s.restore=()=>{const s=e.concat();return e=t.pop(),J(s)},s.error=(t,e)=>{return s=t,Promise.reject(new V(s));var s},s.end=()=>J(e),s},D=Symbol("EjsContext.parentTemplate"),K=(t,e)=>{const{BLOCKS:s,MACRO:i,EXTEND:r,LAYOUT:o,BUFFER:n,SAFE:c,SCOPE:h,COMPONENT:a,ELEMENT:l}=t.vars,u=t.globals||[];function p(t){this[D]=null,this[s]={},this[i]={},Object.assign(this,k(t,[h,n,c,a,l]))}return Object.entries(e).forEach((t=>{let[e,s]=t;g(s)&&u.includes(e)&&(s=s.bind(p.prototype)),p.prototype[e]=s})),Object.defineProperty(p.prototype,n,{value:z()}),Object.defineProperty(p.prototype,s,{value:{},writable:!0}),Object.defineProperty(p.prototype,i,{value:{},writable:!0}),Object.defineProperty(p.prototype,o,{value:!1,writable:!0}),Object.defineProperty(p.prototype,r,{value:!1,writable:!0}),Object.defineProperty(p.prototype,D,{value:null,writable:!0}),Object.defineProperties(p.prototype,{setParentTemplate:{value(t){return this[D]=t,this}},getParentTemplate:{value(){return this[D]}},useSafeValue:{get:()=>O},useComponent:{get(){return g(this[a])?this[a].bind(this):()=>{throw new Error(`${a} must be a function`)}}},useElement:{get(){return g(this[l])?this[l].bind(this):()=>{throw new Error(`${l} must be a function`)}}},useBuffer:{get(){return this[n]}},getMacro:{value(){return this[i]}},getBlocks:{value(){return this[s]}},setExtend:{value(t){return this[r]=t,this}},getExtend:{value(){return this[r]}},setLayout:{value(t){return this[o]=t,this}},getLayout:{value(){return this[o]}},clone:{value(t){const e=[o,r,n];return!0===t&&e.push(s),k(this,e)}},extend:{value(t){this.setExtend(!0),this.setLayout(t)}},echo:{value(){return[].slice.call(arguments).forEach(this.useBuffer)}},fn:{value(t){return()=>{if(g(t))return this.useBuffer.backup(),this.useBuffer(t.apply(this,arguments)),this.useBuffer.restore()}}},macro:{value(t,e){const s=this.getMacro(),i=this.fn(e),r=this;s[t]=function(){return r.echo(i.apply(void 0,arguments))}}},call:{value(t){const e=this.getMacro()[t],s=[].slice.call(arguments,1);if(g(e))return e.apply(e,s)}},block:{value(t,e){const s=this.getBlocks();if(s[t]=s[t]||[],s[t].push(this.fn(e)),this.getExtend())return;const i=Object.assign([],s[t]),r=()=>i.shift(),o=()=>{const t=r();return t?()=>{this.echo(t(o()))}:()=>{}};this.echo(r()(o()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const i=!1===s?{}:this.clone(!0),r=Object.assign(i,e||{}),o=this.render(t,r);this.echo(o)}},use:{value(t,e){this.echo(Promise.resolve(this.require(t)).then((t=>{const s=this.getMacro();P(t,((t,i)=>{s[[e,i].join(".")]=t}))})))}},async:{value(t,e){this.echo(Promise.resolve(t).then(e))}},get:{value(t,e){const s=w(this,t,!0),i=s.shift(),r=s.pop();return S(i,r)?i[r]:e}},set:{value(t,e){const s=w(this,t,!1),i=s.shift(),r=s.pop();return this.getParentTemplate()&&S(i,r)?i[r]:i[r]=e}},each:{value(t,e){m(t)&&(t=this.get(t,[])),P(t,e)},writable:!0},el:{value(t,e,s){s=g(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>((t,e,s)=>{const i=[],r=-1===A.indexOf(t),o=Object.entries(e??{}).map(W).filter((t=>t)).join(F);return i.push([q,t,F,o,U].join("")),s&&r&&i.push(Array.isArray(s)?s.join(""):s),r&&i.push([q,R,t,U].join("")),i.join("")})(t,e,s))))},writable:!0},ui:{value(t){},writable:!0}}),p};class X{#h;static exports=["create","globals","helpers"];constructor(t,e){C(this,this.constructor.exports),this.configure(t,e)}create(t){return new this.#h(t)}helpers(t){Object.assign(this.#h.prototype,t)}configure(t,e){this.#h=K(t,e)}}var Y={};const{render:Z,createContext:I,compile:G,helpers:H,preload:Q,configure:tt,create:et}=new class{#s;#h;#i;#a;#o={};#l={};static exports=["configure","create","createContext","render","require","preload","compile","helpers"];constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};C(this,this.constructor.exports),this.#l={},this.#o=v({},t),this.#h=new X(this.#o,this.#l),this.#i=new B(this.#o),this.#s=new L(this.#o),this.#a=new T(this.#o,this.#s,this.#i),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(v(this.#o,t),this.#h.configure(this.#o,this.#l),this.#i.configure(this.#o),this.#s.configure(this.#o),this.#a.configure(this.#o)),this.#o}createContext(t){return this.#h.create(t)}preload(t){return this.#s.load(t||{})}compile(t,e){return this.#i.compile(t,e)}helpers(t){this.#h.helpers(Object.assign(this.#l,t))}async render(t,e){const s=this.createContext(e);return this.#u(this.#t(t),s).then(this.#p(t,s))}async require(t){const e=this.createContext({});return this.#u(this.#t(t),e).then((()=>e.getMacro()))}#t(t){return t.split(".").pop()!==this.#o.extension&&(t=[t,this.#o.extension].join(".")),t}#u(t,e){return this.#a.get(t).then((t=>t.apply(e,[e,e.useComponent,e.useElement,e.useBuffer,e.useSafeValue])))}#f(t,e,s){const i=this.createContext(e);return s&&i.setParentTemplate(s),this.#u(this.#t(t),i).then(this.#p(t,i))}#p(t,e){return s=>e.getExtend()?(e.setExtend(!1),this.#f(e.getLayout(),e,t)):s}}({resolver:(t,e)=>Y.readFile(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,e)).then((t=>t.toString())).then((t=>String(t)))}),st=((t,e)=>function(r,o,n){g(o)&&(n=o,o={}),o=o||{};const c=Object.assign({},o.settings),h=p(m,i,c.views),a=p(d,s,c["view cache"]),l=Object.assign({},c["view options"]),u=Y.relative(h,r);return l.path=h,l.cache=a,t(l),e(u,o).then((t=>{n(null,t)})).catch((t=>{n(t)}))})(tt,Z);t.TemplateError=_,t.TemplateNotFound=class extends _{name="TemplateNotFound";code=404},t.TemplateSyntaxError=V,t.__express=st,t.compile=G,t.configure=tt,t.create=et,t.createContext=I,t.helpers=H,t.preload=Q,t.render=Z}));
|
|
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).ejsInstance={})}(this,(function(t){"use strict";var e={};function s(t,e,s){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:s;throw new TypeError("Private element is not present on this object")}function n(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function r(t,e){return t.get(s(t,e))}function i(t,e,s){n(t,e),e.set(t,s)}function o(t,e,n){return t.set(s(t,e),n),n}function c(t,e){n(t,e),e.add(t)}function a(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var n=s.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function h(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,n)}return s}const l=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,u=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},p=t=>Array.isArray(t),f=t=>"function"==typeof t,g=t=>"string"==typeof t,v=t=>"boolean"==typeof t,b={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},d={"&":"&","<":"<",">":">",'"':""","'":"'"},m=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),w=m(d),j=m(b),y=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(w,(t=>d[t]))},O=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?y(s):s},E=(t,e,s)=>{let n=t,r=String(e).split("."),i=r.pop();for(let t=0;t<r.length;t++){const e=r[t];if(f(n.toJSON)&&(n=n.toJSON()),s&&!1===n.hasOwnProperty(e)){n={};break}n=n[e]=n[e]||{}}return f(n.toJSON)&&(n=n.toJSON()),[n,i]},x=(t,e)=>{let s;for(s in t)P(t,s)&&e(t[s],s,t)},k=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?h(Object(s),!0).forEach((function(e){a(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):h(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}({},t);for(const t of e)delete s[t];return s},P=(t,e)=>t&&Object.hasOwn(t,e),M=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];for(let s=0,n=e.length;s<n;s++){const n=e[s];n in t&&(t[n]=t[n].bind(t))}},S="ejsPrecompiled",C=!0,W="views",T="ejs",N=!0,$=!0,B=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),A=[],L={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},F={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},R=(t,e)=>{return Object.assign(t,{path:u(g,W,t.path,e.path),precompiled:u(g,S,t.export,e.export),resolver:u(f,B,t.resolver,e.resolver),extension:u(g,T,t.extension,e.extension),strict:u(v,$,t.strict,e.strict),rmWhitespace:u(v,N,t.rmWhitespace,e.rmWhitespace),cache:u(v,C,t.cache,e.cache),globals:u(p,A,t.globals,(s=e.globals,!!p(s)&&s.filter((t=>{const e=l.test(t);return!1===e&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),e})))),token:Object.assign({},F,t.token,e.token),vars:Object.assign({},L,t.vars,e.vars)});var s};class q extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const D=(t,e)=>{throw new q(t,e)};var U=new WeakMap,_=new WeakMap,V=new WeakMap,J=new WeakMap,z=new WeakSet;class K{constructor(t,e,s){c(this,z),i(this,U,void 0),i(this,_,void 0),i(this,V,void 0),i(this,J,void 0),M(this,this.constructor.exports),o(V,this,e),o(J,this,s),this.configure(null!=t?t:{})}configure(t){o(U,this,t.path),f(t.resolver)&&o(_,this,t.resolver)}get(t){return s(z,this,X).call(this,t).then((e=>s(z,this,Y).call(this,e,t)))}}function X(t){const e=r(V,this).get(t);if(e instanceof Promise)return e;const s=Promise.resolve(r(_,this).call(this,r(U,this),t,D));return r(V,this).set(t,s),s}function Y(t,e){const s=r(V,this).get(e);return"function"==typeof s?s:("string"==typeof t&&(t=r(J,this).compile(t,e)),"function"==typeof t?(r(V,this).set(e,t),t):void 0)}a(K,"exports",["configure","get"]);const Z=[["-",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,",1))\n").concat(e,"('")],["=",(t,e,s)=>"')\n".concat(e,"(").concat(s,"(").concat(t,"))\n").concat(e,"('")],["#",(t,e)=>"')\n/**".concat(t,"**/\n").concat(e,"('")],["",(t,e)=>"')\n".concat(t,"\n").concat(e,"('")]];var I=new WeakMap;class G{constructor(t){i(this,I,{}),M(this,this.constructor.exports),this.configure(t)}configure(t){var e;r(I,this).strict=t.strict,r(I,this).rmWhitespace=t.rmWhitespace,r(I,this).token=t.token,r(I,this).vars=t.vars,r(I,this).globals=t.globals,r(I,this).legacy=null===(e=t.legacy)||void 0===e||e,r(I,this).slurp={match:"[s\t\n]*",start:[r(I,this).token.start,"_"],end:["_",r(I,this).token.end]},r(I,this).matches=[],r(I,this).formats=[];for(const[t,e]of Z)r(I,this).matches.push(r(I,this).token.start.concat(t).concat(r(I,this).token.regex).concat(r(I,this).token.end)),r(I,this).formats.push(e);r(I,this).regex=new RegExp(r(I,this).matches.join("|").concat("|$"),"g"),r(I,this).slurpStart=new RegExp([r(I,this).slurp.match,r(I,this).slurp.start.join("")].join(""),"gm"),r(I,this).slurpEnd=new RegExp([r(I,this).slurp.end.join(""),r(I,this).slurp.match].join(""),"gm"),r(I,this).globals.length&&(r(I,this).legacy?r(I,this).globalVariables="const ".concat(r(I,this).globals.map((t=>"".concat(t,"=").concat(r(I,this).vars.SCOPE,".").concat(t))).join(","),";"):r(I,this).globalVariables="const {".concat(r(I,this).globals.join(","),"} = ").concat(r(I,this).vars.SCOPE,";"))}compile(t,e){const s=r(I,this).globalVariables,{SCOPE:n,SAFE:i,BUFFER:o,COMPONENT:c,ELEMENT:a}=r(I,this).vars;r(I,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(r(I,this).slurpStart,r(I,this).token.start).replace(r(I,this).slurpEnd,r(I,this).token.end);let h="".concat(o,"('");((t,e,s)=>{let n=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),r=t.shift();return s(t,n,e),n=e+r.length,r}))})(r(I,this).regex,t,((e,s,n)=>{h+=(""+t.slice(s,n)).replace(j,(t=>"\\"+b[t])),e.forEach(((t,e)=>{t&&(h+=r(I,this).formats[e](t.trim(),o,i))}))})),h+="');",h="try{".concat(h,"}catch(e){return ").concat(o,".error(e)}"),!1===r(I,this).strict&&(h="with(".concat(n,"){").concat(h,"}")),h="".concat(o,".start();").concat(h,"return ").concat(o,".end();"),h+="\n//# sourceURL=".concat(e),s&&(h="".concat(s,"\n").concat(h));try{const t=[n,c,a,o,i],e=Function.apply(null,t.concat(h));return e.source="(function(".concat(t.join(","),"){\n").concat(h,"\n});"),e}catch(t){t.filename=e,t.source=h,D(0,t)}}}a(G,"exports",["configure","compile"]);var H=new WeakMap,Q=new WeakMap,tt=new WeakMap;class et{constructor(t){i(this,H,!0),i(this,Q,void 0),i(this,tt,{}),M(this,this.constructor.exports),this.configure(t)}get(t){if(r(H,this))return r(tt,this)[t]}set(t,e){r(H,this)&&(r(tt,this)[t]=e)}exist(t){if(r(H,this))return r(tt,this).hasOwnProperty(t)}clear(){Object.keys(r(tt,this)).forEach(this.remove)}remove(t){delete r(tt,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){r(H,this)&&Object.assign(r(tt,this),t||{})}configure(t){o(H,this,t.cache),o(Q,this,t.precompiled),"object"==typeof window&&this.load(window[r(Q,this)])}}a(et,"exports",["load","set","get","exist","clear","remove","resolve"]);const st=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],nt=" ",rt='"',it="/",ot="<",ct=">",at=t=>{let[e,s]=t;if(null!=s)return[y(e),[rt,y(s),rt].join("")].join("=")},ht=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>D(0,t))),lt=()=>{let t=[],e=[];const s=t=>{e.push(t)};return s.start=()=>{e=[]},s.backup=()=>{t.push(e.concat()),e=[]},s.restore=()=>{const s=e.concat();return e=t.pop(),ht(s)},s.error=t=>(t=>Promise.reject(D(0,t)))(t),s.end=()=>ht(e),s},ut=Symbol("EjsContext.parentTemplate"),pt=(t,e)=>{const s=t.globals||[],{BLOCKS:n,MACRO:r,EXTEND:i,LAYOUT:o,BUFFER:c,SAFE:a,SCOPE:h,COMPONENT:l,ELEMENT:u}=t.vars;class p{constructor(t){this[ut]=null,this[n]={},this[r]={},Object.assign(this,k(t,[h,c,a,l,u]))}}return Object.defineProperties(p.prototype,{[c]:{value:lt()},[n]:{value:{},writable:!0},[r]:{value:{},writable:!0},[o]:{value:!1,writable:!0},[i]:{value:!1,writable:!0},[ut]:{value:null,writable:!0},setParentTemplate:{value(t){return this[ut]=t,this}},getParentTemplate:{value(){return this[ut]}},useEscapeValue:{value:()=>O},useComponent:{value(){return f(this[l])?this[l].bind(this):function(){D(2,"".concat(l," must be a function"))}}},useElement:{value(){return f(this[u])?this[u].bind(this):()=>{D(2,"".concat(u," must be a function"))}}},useBuffer:{value(){return this[c]}},getMacro:{value(){return this[r]}},getBlocks:{value(){return this[n]}},setExtend:{value(t){return this[i]=t,this}},getExtend:{value(){return this[i]}},setLayout:{value(t){return this[o]=t,this}},getLayout:{value(){return this[o]}},clone:{value(t){const e=[o,i,c];return!0===t&&e.push(n),k(this,e)}},extend:{value(t){this.setExtend(!0),this.setLayout(t)}},echo:{value(){return[].slice.call(arguments).forEach(this.useBuffer())}},fn:{value(t){const e=this.useBuffer(),s=this;return function(){if(f(t))return e.backup(),e(t.apply(s,arguments)),e.restore()}}},macro:{value(t,e){const s=this.getMacro(),n=this.fn(e),r=this;s[t]=function(){return r.echo(n.apply(void 0,arguments))}}},call:{value(t){const e=this.getMacro()[t],s=[].slice.call(arguments,1);if(f(e))return e.apply(e,s)}},block:{value(t,e){const s=this.getBlocks();if(s[t]=s[t]||[],s[t].push(this.fn(e)),this.getExtend())return;const n=this,r=Object.assign([],s[t]),i=function(){return r.shift()},o=function(){const t=i();return t?function(){n.echo(t(o()))}:function(){}};this.echo(i()(o()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const n=!1===s?{}:this.clone(!0),r=Object.assign(n,e||{}),i=this.render(t,r);this.echo(i)}},use:{value(t,e){this.echo(Promise.resolve(this.require(t)).then((t=>{const s=this.getMacro();x(t,((t,n)=>{s[[e,n].join(".")]=t}))})))}},get:{value(t,e){const s=E(this,t,!0),n=s.shift(),r=s.pop();return P(n,r)?n[r]:e}},set:{value(t,e){const s=E(this,t,!1),n=s.shift(),r=s.pop();return this.getParentTemplate()&&P(n,r)?n[r]:n[r]=e}},each:{value(t,e){g(t)&&(t=this.get(t,[])),x(t,e)},writable:!0},el:{value(t,e,s){s=f(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>((t,e,s)=>{const n=[],r=-1===st.indexOf(t),i=Object.entries(null!=e?e:{}).map(at).filter((t=>t)).join(nt);return n.push([ot,t,nt,i,ct].join("")),s&&r&&n.push(Array.isArray(s)?s.join(""):s),r&&n.push([ot,it,t,ct].join("")),n.join("")})(t,e,s))))},writable:!0},ui:{value(){},writable:!0},require:{value(){},writable:!0},render:{value(){},writable:!0}}),Object.entries(e).forEach((t=>{let[e,n]=t;f(n)&&s.includes(e)&&(n=n.bind(p.prototype)),p.prototype[e]=n})),p};var ft=new WeakMap;class gt{constructor(t,e){i(this,ft,void 0),M(this,this.constructor.exports),this.configure(t,e)}create(t){return new(r(ft,this))(t)}helpers(t){Object.assign(r(ft,this).prototype,t)}configure(t,e){o(ft,this,pt(t,e))}}a(gt,"exports",["create","globals","helpers"]);var vt=new WeakMap,bt=new WeakMap,dt=new WeakMap,mt=new WeakMap,wt=new WeakMap,jt=new WeakMap,yt=new WeakSet;class Ot{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,yt),i(this,vt,void 0),i(this,bt,void 0),i(this,dt,void 0),i(this,mt,void 0),i(this,wt,{}),i(this,jt,{}),M(this,this.constructor.exports),o(jt,this,{}),o(wt,this,R({},t)),o(bt,this,new gt(r(wt,this),r(jt,this))),o(dt,this,new G(r(wt,this))),o(vt,this,new et(r(wt,this))),o(mt,this,new K(r(wt,this),r(vt,this),r(dt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(R(r(wt,this),t),r(bt,this).configure(r(wt,this),r(jt,this)),r(dt,this).configure(r(wt,this)),r(vt,this).configure(r(wt,this)),r(mt,this).configure(r(wt,this))),r(wt,this)}createContext(t){return r(bt,this).create(t)}preload(t){return r(vt,this).load(t||{})}compile(t,e){return r(dt,this).compile(t,e)}helpers(t){r(bt,this).helpers(Object.assign(r(jt,this),t))}async render(t,e){const n=this.createContext(e);return s(yt,this,xt).call(this,s(yt,this,Et).call(this,t),n).then(s(yt,this,Pt).call(this,t,n))}async require(t){const e=this.createContext({});return s(yt,this,xt).call(this,s(yt,this,Et).call(this,t),e).then((()=>e.getMacro()))}}function Et(t){return t.split(".").pop()!==r(wt,this).extension&&(t=[t,r(wt,this).extension].join(".")),t}function xt(t,e){return r(mt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function kt(t,e,n){const r=this.createContext(e);return n&&r.setParentTemplate(n),s(yt,this,xt).call(this,s(yt,this,Et).call(this,t),r).then(s(yt,this,Pt).call(this,t,r))}function Pt(t,e){return n=>e.getExtend()?(e.setExtend(!1),s(yt,this,kt).call(this,e.getLayout(),e,t)):n}a(Ot,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const{render:Mt,helpers:St,configure:Ct,create:Wt,createContext:Tt,compile:Nt,preload:$t}=new Ot({resolver:async(t,s,n)=>e.readFile(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,s)).then((t=>t.toString())).catch((t=>"ENOENT"===t.code?n(1,"template ".concat(s," not found")):n(0,t)))});t.__express=function(t,s,n){f(s)&&(n=s,s={}),s=s||{};const r=Object.assign({},s.settings),i=u(g,W,r.views),o=u(v,C,r["view cache"]),c=Object.assign({},r["view options"]),a=e.relative(i,t);return c.path=i,c.cache=o,Ct(c),Mt(a,s).then((t=>{n(null,t)})).catch((t=>{n(t)}))},t.compile=Nt,t.configure=Ct,t.create=Wt,t.createContext=Tt,t.helpers=St,t.preload=$t,t.render=Mt}));
|