@kosatyi/ejs 0.0.114 → 0.0.115
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 +2 -1
- package/dist/esm/browser.js +2 -1
- package/dist/umd/browser.js +2 -1
- package/dist/umd/browser.min.js +1 -1
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -876,7 +876,8 @@ function _outputContent(name, data) {
|
|
|
876
876
|
_defineProperty(EjsInstance, "exports", ['configure', 'create', 'createContext', 'render', 'require', 'preload', 'compile', 'helpers']);
|
|
877
877
|
|
|
878
878
|
const resolver = async (path, template, error) => {
|
|
879
|
-
|
|
879
|
+
const url = new URL(joinPath(path, template), location.origin);
|
|
880
|
+
return fetch(url).then(response => {
|
|
880
881
|
if (response.ok) return response.text();
|
|
881
882
|
return error(1, "template ".concat(template, " not found"));
|
|
882
883
|
}, reason => error(0, reason));
|
package/dist/esm/browser.js
CHANGED
|
@@ -958,7 +958,8 @@ class EjsInstance {
|
|
|
958
958
|
}
|
|
959
959
|
|
|
960
960
|
const resolver = async (path, template, error) => {
|
|
961
|
-
|
|
961
|
+
const url = new URL(joinPath(path, template), location.origin);
|
|
962
|
+
return fetch(url).then(
|
|
962
963
|
(response) => {
|
|
963
964
|
if (response.ok) return response.text()
|
|
964
965
|
return error(1, `template ${template} not found`)
|
package/dist/umd/browser.js
CHANGED
|
@@ -880,7 +880,8 @@
|
|
|
880
880
|
_defineProperty(EjsInstance, "exports", ['configure', 'create', 'createContext', 'render', 'require', 'preload', 'compile', 'helpers']);
|
|
881
881
|
|
|
882
882
|
const resolver = async (path, template, error) => {
|
|
883
|
-
|
|
883
|
+
const url = new URL(joinPath(path, template), location.origin);
|
|
884
|
+
return fetch(url).then(response => {
|
|
884
885
|
if (response.ok) return response.text();
|
|
885
886
|
return error(1, "template ".concat(template, " not found"));
|
|
886
887
|
}, reason => error(0, reason));
|
package/dist/umd/browser.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";function e(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 s(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function n(t,s){return t.get(e(t,s))}function r(t,e,n){s(t,e),e.set(t,n)}function i(t,s,n){return t.set(e(t,s),n),n}function o(t,e){s(t,e),e.add(t)}function c(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 a(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 h="ejsPrecompiled",l=!0,u="views",p="ejs",f=!0,g=!0,v=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),b=[],d={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},m={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},w=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,y=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},j=t=>Array.isArray(t),O=t=>"function"==typeof t,E=t=>"string"==typeof t,x=t=>"boolean"==typeof t,k=(t,e)=>{return Object.assign(t,{path:y(E,u,t.path,e.path),precompiled:y(E,h,t.export,e.export),resolver:y(O,v,t.resolver,e.resolver),extension:y(E,p,t.extension,e.extension),strict:y(x,g,t.strict,e.strict),rmWhitespace:y(x,f,t.rmWhitespace,e.rmWhitespace),cache:y(x,l,t.cache,e.cache),globals:y(j,b,t.globals,(s=e.globals,!!j(s)&&s.filter((t=>{const e=w.test(t);return!1===e&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),e})))),token:Object.assign({},m,t.token,e.token),vars:Object.assign({},d,t.vars,e.vars)});var s},P={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},M={"&":"&","<":"<",">":">",'"':""","'":"'"},S=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),C=S(M),W=S(P),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(C,(t=>M[t]))},$=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?T(s):s},N=(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(O(n.toJSON)&&(n=n.toJSON()),s&&!1===n.hasOwnProperty(e)){n={};break}n=n[e]=n[e]||{}}return O(n.toJSON)&&(n=n.toJSON()),[n,i]},B=(t,e)=>{let s;for(s in t)L(t,s)&&e(t[s],s,t)},A=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?a(Object(s),!0).forEach((function(e){c(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):a(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},L=(t,e)=>t&&Object.hasOwn(t,e),F=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))}};class R extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const q=(t,e)=>{throw new R(t,e)};var D=new WeakMap,U=new WeakMap,V=new WeakMap,J=new WeakMap,_=new WeakSet;class z{constructor(t,e,s){o(this,_),r(this,D,void 0),r(this,U,void 0),r(this,V,void 0),r(this,J,void 0),F(this,this.constructor.exports),i(V,this,e),i(J,this,s),this.configure(null!=t?t:{})}configure(t){i(D,this,t.path),O(t.resolver)&&i(U,this,t.resolver)}get(t){return e(_,this,K).call(this,t).then((s=>e(_,this,X).call(this,s,t)))}}function K(t){const e=n(V,this).get(t);if(e instanceof Promise)return e;const s=Promise.resolve(n(U,this).call(this,n(D,this),t,q));return n(V,this).set(t,s),s}function X(t,e){const s=n(V,this).get(e);return"function"==typeof s?s:("string"==typeof t&&(t=n(J,this).compile(t,e)),"function"==typeof t?(n(V,this).set(e,t),t):void 0)}c(z,"exports",["configure","get"]);const Y=[["-",(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 Z=new WeakMap;class I{constructor(t){r(this,Z,{}),F(this,this.constructor.exports),this.configure(t)}configure(t){var e;n(Z,this).strict=t.strict,n(Z,this).rmWhitespace=t.rmWhitespace,n(Z,this).token=t.token,n(Z,this).vars=t.vars,n(Z,this).globals=t.globals,n(Z,this).legacy=null===(e=t.legacy)||void 0===e||e,n(Z,this).slurp={match:"[s\t\n]*",start:[n(Z,this).token.start,"_"],end:["_",n(Z,this).token.end]},n(Z,this).matches=[],n(Z,this).formats=[];for(const[t,e]of Y)n(Z,this).matches.push(n(Z,this).token.start.concat(t).concat(n(Z,this).token.regex).concat(n(Z,this).token.end)),n(Z,this).formats.push(e);n(Z,this).regex=new RegExp(n(Z,this).matches.join("|").concat("|$"),"g"),n(Z,this).slurpStart=new RegExp([n(Z,this).slurp.match,n(Z,this).slurp.start.join("")].join(""),"gm"),n(Z,this).slurpEnd=new RegExp([n(Z,this).slurp.end.join(""),n(Z,this).slurp.match].join(""),"gm"),n(Z,this).globals.length&&(n(Z,this).legacy?n(Z,this).globalVariables="const ".concat(n(Z,this).globals.map((t=>"".concat(t,"=").concat(n(Z,this).vars.SCOPE,".").concat(t))).join(","),";"):n(Z,this).globalVariables="const {".concat(n(Z,this).globals.join(","),"} = ").concat(n(Z,this).vars.SCOPE,";"))}compile(t,e){const s=n(Z,this).globalVariables,{SCOPE:r,SAFE:i,BUFFER:o,COMPONENT:c,ELEMENT:a}=n(Z,this).vars;n(Z,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(n(Z,this).slurpStart,n(Z,this).token.start).replace(n(Z,this).slurpEnd,n(Z,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}))})(n(Z,this).regex,t,((e,s,r)=>{h+=(""+t.slice(s,r)).replace(W,(t=>"\\"+P[t])),e.forEach(((t,e)=>{t&&(h+=n(Z,this).formats[e](t.trim(),o,i))}))})),h+="');",h="try{".concat(h,"}catch(e){return ").concat(o,".error(e)}"),!1===n(Z,this).strict&&(h="with(".concat(r,"){").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=[r,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,q(0,t)}}}c(I,"exports",["configure","compile"]);var G=new WeakMap,H=new WeakMap,Q=new WeakMap;class tt{constructor(t){r(this,G,!0),r(this,H,void 0),r(this,Q,{}),F(this,this.constructor.exports),this.configure(t)}get(t){if(n(G,this))return n(Q,this)[t]}set(t,e){n(G,this)&&(n(Q,this)[t]=e)}exist(t){if(n(G,this))return n(Q,this).hasOwnProperty(t)}clear(){Object.keys(n(Q,this)).forEach(this.remove)}remove(t){delete n(Q,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){n(G,this)&&Object.assign(n(Q,this),t||{})}configure(t){i(G,this,t.cache),i(H,this,t.precompiled),"object"==typeof window&&this.load(window[n(H,this)])}}c(tt,"exports",["load","set","get","exist","clear","remove","resolve"]);const et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],st=" ",nt='"',rt="/",it="<",ot=">",ct=t=>{let[e,s]=t;if(null!=s)return[T(e),[nt,T(s),nt].join("")].join("=")},at=(t,e,s)=>{const n=[],r=-1===et.indexOf(t),i=Object.entries(null!=e?e:{}).map(ct).filter((t=>t)).join(st);return n.push([it,t,st,i,ot].join("")),s&&r&&n.push(Array.isArray(s)?s.join(""):s),r&&n.push([it,rt,t,ot].join("")),n.join("")},ht=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>q(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(q(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,A(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:()=>$},useComponent:{value(){return O(this[l])?this[l].bind(this):function(){q(2,"".concat(l," must be a function"))}}},useElement:{value(){return O(this[u])?this[u].bind(this):()=>{q(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),A(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(O(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(O(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();B(t,((t,n)=>{s[[e,n].join(".")]=t}))})))}},get:{value(t,e){const s=N(this,t,!0),n=s.shift(),r=s.pop();return L(n,r)?n[r]:e}},set:{value(t,e){const s=N(this,t,!1),n=s.shift(),r=s.pop();return this.getParentTemplate()&&L(n,r)?n[r]:n[r]=e}},each:{value(t,e){E(t)&&(t=this.get(t,[])),B(t,e)},writable:!0},el:{value(t,e,s){s=O(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>at(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;O(n)&&s.includes(e)&&(n=n.bind(p.prototype)),p.prototype[e]=n})),p};var ft=new WeakMap;class gt{constructor(t,e){r(this,ft,void 0),F(this,this.constructor.exports),this.configure(t,e)}create(t){return new(n(ft,this))(t)}helpers(t){Object.assign(n(ft,this).prototype,t)}configure(t,e){i(ft,this,pt(t,e))}}c(gt,"exports",["create","globals","helpers"]);var vt=new WeakMap,bt=new WeakMap,dt=new WeakMap,mt=new WeakMap,wt=new WeakMap,yt=new WeakMap,jt=new WeakSet;class Ot{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,jt),r(this,vt,void 0),r(this,bt,void 0),r(this,dt,void 0),r(this,mt,void 0),r(this,wt,{}),r(this,yt,{}),F(this,this.constructor.exports),i(yt,this,{}),i(wt,this,k({},t)),i(bt,this,new gt(n(wt,this),n(yt,this))),i(dt,this,new I(n(wt,this))),i(vt,this,new tt(n(wt,this))),i(mt,this,new z(n(wt,this),n(vt,this),n(dt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(k(n(wt,this),t),n(bt,this).configure(n(wt,this),n(yt,this)),n(dt,this).configure(n(wt,this)),n(vt,this).configure(n(wt,this)),n(mt,this).configure(n(wt,this))),n(wt,this)}createContext(t){return n(bt,this).create(t)}preload(t){return n(vt,this).load(t||{})}compile(t,e){return n(dt,this).compile(t,e)}helpers(t){n(bt,this).helpers(Object.assign(n(yt,this),t))}async render(t,s){const n=this.createContext(s);return e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),n).then(e(jt,this,Pt).call(this,t,n))}async require(t){const s=this.createContext({});return e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),s).then((()=>s.getMacro()))}}function Et(t){return t.split(".").pop()!==n(wt,this).extension&&(t=[t,n(wt,this).extension].join(".")),t}function xt(t,e){return n(mt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function kt(t,s,n){const r=this.createContext(s);return n&&r.setParentTemplate(n),e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),r).then(e(jt,this,Pt).call(this,t,r))}function Pt(t,s){return n=>s.getExtend()?(s.setExtend(!1),e(jt,this,kt).call(this,s.getLayout(),s,t)):n}c(Ot,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const{render:Mt,configure:St,create:Ct,helpers:Wt,createContext:Tt,compile:$t,preload:Nt}=new Ot({resolver:async(t,e,s)=>fetch(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,e)).then((t=>t.ok?t.text():s(1,"template ".concat(e," not found"))),(t=>s(0,t)))});t.compile=$t,t.configure=St,t.create=Ct,t.createContext=Tt,t.element=at,t.escapeValue=$,t.helpers=Wt,t.preload=Nt,t.render=Mt}));
|
|
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";function e(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 s(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function n(t,s){return t.get(e(t,s))}function r(t,e,n){s(t,e),e.set(t,n)}function i(t,s,n){return t.set(e(t,s),n),n}function o(t,e){s(t,e),e.add(t)}function c(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 a(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 h="ejsPrecompiled",l=!0,u="views",p="ejs",f=!0,g=!0,v=(t,e)=>Promise.resolve(["resolver is not defined",t,e].join(" ")),b=[],d={SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},m={start:"<%",end:"%>",regex:"([\\s\\S]+?)"},w=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,y=function(){const t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},j=t=>Array.isArray(t),O=t=>"function"==typeof t,E=t=>"string"==typeof t,x=t=>"boolean"==typeof t,k=(t,e)=>{return Object.assign(t,{path:y(E,u,t.path,e.path),precompiled:y(E,h,t.export,e.export),resolver:y(O,v,t.resolver,e.resolver),extension:y(E,p,t.extension,e.extension),strict:y(x,g,t.strict,e.strict),rmWhitespace:y(x,f,t.rmWhitespace,e.rmWhitespace),cache:y(x,l,t.cache,e.cache),globals:y(j,b,t.globals,(s=e.globals,!!j(s)&&s.filter((t=>{const e=w.test(t);return!1===e&&console.log("ejsConfig.globals: expected '".concat(t,"' to be valid variable name --\x3e skipped")),e})))),token:Object.assign({},m,t.token,e.token),vars:Object.assign({},d,t.vars,e.vars)});var s},P={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},M={"&":"&","<":"<",">":">",'"':""","'":"'"},S=t=>new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g"),C=S(M),W=S(P),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(C,(t=>M[t]))},$=(t,e)=>{const s=t;return null==s?"":!0===Boolean(e)?T(s):s},N=(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(O(n.toJSON)&&(n=n.toJSON()),s&&!1===n.hasOwnProperty(e)){n={};break}n=n[e]=n[e]||{}}return O(n.toJSON)&&(n=n.toJSON()),[n,i]},B=(t,e)=>{let s;for(s in t)L(t,s)&&e(t[s],s,t)},A=(t,e)=>{const s=function(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?a(Object(s),!0).forEach((function(e){c(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):a(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},L=(t,e)=>t&&Object.hasOwn(t,e),R=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))}};class F extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const q=(t,e)=>{throw new F(t,e)};var U=new WeakMap,D=new WeakMap,V=new WeakMap,J=new WeakMap,_=new WeakSet;class z{constructor(t,e,s){o(this,_),r(this,U,void 0),r(this,D,void 0),r(this,V,void 0),r(this,J,void 0),R(this,this.constructor.exports),i(V,this,e),i(J,this,s),this.configure(null!=t?t:{})}configure(t){i(U,this,t.path),O(t.resolver)&&i(D,this,t.resolver)}get(t){return e(_,this,K).call(this,t).then((s=>e(_,this,X).call(this,s,t)))}}function K(t){const e=n(V,this).get(t);if(e instanceof Promise)return e;const s=Promise.resolve(n(D,this).call(this,n(U,this),t,q));return n(V,this).set(t,s),s}function X(t,e){const s=n(V,this).get(e);return"function"==typeof s?s:("string"==typeof t&&(t=n(J,this).compile(t,e)),"function"==typeof t?(n(V,this).set(e,t),t):void 0)}c(z,"exports",["configure","get"]);const Y=[["-",(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 Z=new WeakMap;class I{constructor(t){r(this,Z,{}),R(this,this.constructor.exports),this.configure(t)}configure(t){var e;n(Z,this).strict=t.strict,n(Z,this).rmWhitespace=t.rmWhitespace,n(Z,this).token=t.token,n(Z,this).vars=t.vars,n(Z,this).globals=t.globals,n(Z,this).legacy=null===(e=t.legacy)||void 0===e||e,n(Z,this).slurp={match:"[s\t\n]*",start:[n(Z,this).token.start,"_"],end:["_",n(Z,this).token.end]},n(Z,this).matches=[],n(Z,this).formats=[];for(const[t,e]of Y)n(Z,this).matches.push(n(Z,this).token.start.concat(t).concat(n(Z,this).token.regex).concat(n(Z,this).token.end)),n(Z,this).formats.push(e);n(Z,this).regex=new RegExp(n(Z,this).matches.join("|").concat("|$"),"g"),n(Z,this).slurpStart=new RegExp([n(Z,this).slurp.match,n(Z,this).slurp.start.join("")].join(""),"gm"),n(Z,this).slurpEnd=new RegExp([n(Z,this).slurp.end.join(""),n(Z,this).slurp.match].join(""),"gm"),n(Z,this).globals.length&&(n(Z,this).legacy?n(Z,this).globalVariables="const ".concat(n(Z,this).globals.map((t=>"".concat(t,"=").concat(n(Z,this).vars.SCOPE,".").concat(t))).join(","),";"):n(Z,this).globalVariables="const {".concat(n(Z,this).globals.join(","),"} = ").concat(n(Z,this).vars.SCOPE,";"))}compile(t,e){const s=n(Z,this).globalVariables,{SCOPE:r,SAFE:i,BUFFER:o,COMPONENT:c,ELEMENT:a}=n(Z,this).vars;n(Z,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(n(Z,this).slurpStart,n(Z,this).token.start).replace(n(Z,this).slurpEnd,n(Z,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}))})(n(Z,this).regex,t,((e,s,r)=>{h+=(""+t.slice(s,r)).replace(W,(t=>"\\"+P[t])),e.forEach(((t,e)=>{t&&(h+=n(Z,this).formats[e](t.trim(),o,i))}))})),h+="');",h="try{".concat(h,"}catch(e){return ").concat(o,".error(e)}"),!1===n(Z,this).strict&&(h="with(".concat(r,"){").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=[r,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,q(0,t)}}}c(I,"exports",["configure","compile"]);var G=new WeakMap,H=new WeakMap,Q=new WeakMap;class tt{constructor(t){r(this,G,!0),r(this,H,void 0),r(this,Q,{}),R(this,this.constructor.exports),this.configure(t)}get(t){if(n(G,this))return n(Q,this)[t]}set(t,e){n(G,this)&&(n(Q,this)[t]=e)}exist(t){if(n(G,this))return n(Q,this).hasOwnProperty(t)}clear(){Object.keys(n(Q,this)).forEach(this.remove)}remove(t){delete n(Q,this)[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){n(G,this)&&Object.assign(n(Q,this),t||{})}configure(t){i(G,this,t.cache),i(H,this,t.precompiled),"object"==typeof window&&this.load(window[n(H,this)])}}c(tt,"exports",["load","set","get","exist","clear","remove","resolve"]);const et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],st=" ",nt='"',rt="/",it="<",ot=">",ct=t=>{let[e,s]=t;if(null!=s)return[T(e),[nt,T(s),nt].join("")].join("=")},at=(t,e,s)=>{const n=[],r=-1===et.indexOf(t),i=Object.entries(null!=e?e:{}).map(ct).filter((t=>t)).join(st);return n.push([it,t,st,i,ot].join("")),s&&r&&n.push(Array.isArray(s)?s.join(""):s),r&&n.push([it,rt,t,ot].join("")),n.join("")},ht=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>q(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(q(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,A(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:()=>$},useComponent:{value(){return O(this[l])?this[l].bind(this):function(){q(2,"".concat(l," must be a function"))}}},useElement:{value(){return O(this[u])?this[u].bind(this):()=>{q(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),A(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(O(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(O(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();B(t,((t,n)=>{s[[e,n].join(".")]=t}))})))}},get:{value(t,e){const s=N(this,t,!0),n=s.shift(),r=s.pop();return L(n,r)?n[r]:e}},set:{value(t,e){const s=N(this,t,!1),n=s.shift(),r=s.pop();return this.getParentTemplate()&&L(n,r)?n[r]:n[r]=e}},each:{value(t,e){E(t)&&(t=this.get(t,[])),B(t,e)},writable:!0},el:{value(t,e,s){s=O(s)?this.fn(s)():s,this.echo(Promise.resolve(s).then((s=>at(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;O(n)&&s.includes(e)&&(n=n.bind(p.prototype)),p.prototype[e]=n})),p};var ft=new WeakMap;class gt{constructor(t,e){r(this,ft,void 0),R(this,this.constructor.exports),this.configure(t,e)}create(t){return new(n(ft,this))(t)}helpers(t){Object.assign(n(ft,this).prototype,t)}configure(t,e){i(ft,this,pt(t,e))}}c(gt,"exports",["create","globals","helpers"]);var vt=new WeakMap,bt=new WeakMap,dt=new WeakMap,mt=new WeakMap,wt=new WeakMap,yt=new WeakMap,jt=new WeakSet;class Ot{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,jt),r(this,vt,void 0),r(this,bt,void 0),r(this,dt,void 0),r(this,mt,void 0),r(this,wt,{}),r(this,yt,{}),R(this,this.constructor.exports),i(yt,this,{}),i(wt,this,k({},t)),i(bt,this,new gt(n(wt,this),n(yt,this))),i(dt,this,new I(n(wt,this))),i(vt,this,new tt(n(wt,this))),i(mt,this,new z(n(wt,this),n(vt,this),n(dt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(k(n(wt,this),t),n(bt,this).configure(n(wt,this),n(yt,this)),n(dt,this).configure(n(wt,this)),n(vt,this).configure(n(wt,this)),n(mt,this).configure(n(wt,this))),n(wt,this)}createContext(t){return n(bt,this).create(t)}preload(t){return n(vt,this).load(t||{})}compile(t,e){return n(dt,this).compile(t,e)}helpers(t){n(bt,this).helpers(Object.assign(n(yt,this),t))}async render(t,s){const n=this.createContext(s);return e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),n).then(e(jt,this,Pt).call(this,t,n))}async require(t){const s=this.createContext({});return e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),s).then((()=>s.getMacro()))}}function Et(t){return t.split(".").pop()!==n(wt,this).extension&&(t=[t,n(wt,this).extension].join(".")),t}function xt(t,e){return n(mt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function kt(t,s,n){const r=this.createContext(s);return n&&r.setParentTemplate(n),e(jt,this,xt).call(this,e(jt,this,Et).call(this,t),r).then(e(jt,this,Pt).call(this,t,r))}function Pt(t,s){return n=>s.getExtend()?(s.setExtend(!1),e(jt,this,kt).call(this,s.getLayout(),s,t)):n}c(Ot,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const{render:Mt,configure:St,create:Ct,helpers:Wt,createContext:Tt,compile:$t,preload:Nt}=new Ot({resolver:async(t,e,s)=>{const n=new URL(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,e),location.origin);return fetch(n).then((t=>t.ok?t.text():s(1,"template ".concat(e," not found"))),(t=>s(0,t)))}});t.compile=$t,t.configure=St,t.create=Ct,t.createContext=Tt,t.element=at,t.escapeValue=$,t.helpers=Wt,t.preload=Nt,t.render=Mt}));
|
package/package.json
CHANGED