@kosatyi/ejs 0.0.110 → 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 +295 -200
- package/dist/cjs/bundler.js +9 -1
- package/dist/cjs/element.js +1 -1
- package/dist/cjs/index.js +361 -277
- package/dist/cjs/worker.js +302 -224
- package/dist/esm/browser.js +77 -62
- package/dist/esm/bundler.js +9 -1
- package/dist/esm/index.js +195 -191
- package/dist/esm/worker.js +81 -83
- package/dist/umd/browser.js +832 -737
- 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 +851 -767
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +302 -224
- package/dist/umd/worker.min.js +1 -1
- package/package.json +4 -4
- package/types/context.d.ts +19 -4
- package/types/ejs.d.ts +1 -1
- package/types/error.d.ts +5 -2
- package/types/worker.d.ts +0 -6
- package/dist/kosatyi-ejs-0.0.109.tgz +0 -0
- package/dist/umd/browser.js.map +0 -7
- package/dist/umd/browser.min.js.map +0 -7
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";const e="ejsPrecompiled",s=!0,i="views",o="ejs",r=!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,o,t.extension,v.extension),strict:p(d,n,t.strict,v.strict),rmWhitespace:p(d,r,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,o=String(e).split("."),r=o.pop();for(let t=0;t<o.length;t++){const e=o[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,r]},P=(t,e)=>{let s;for(s in t)C(t,s)&&e(t[s],s,t)},k=(t,e)=>{const s={...t};for(const t of e)delete s[t];return s},C=(t,e)=>t&&Object.hasOwn(t,e),S=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 extends Error{constructor(t,e){super(e),this.code=t,e instanceof Error&&(this.stack=e.stack,this.message=e.message)}}const B=(t,e)=>{throw new T(t,e)};class N{#t;#e;#s;#i;static exports=["configure","get"];constructor(t,e,s){S(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)}#o(t){const e=this.#s.get(t);if(e instanceof Promise)return e;const s=Promise.resolve(this.#e(this.#t,t,B));return this.#s.set(t,s),s}#r(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.#o(t).then((e=>this.#r(e,t)))}}const L=[["-",(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 A{#n={};static exports=["configure","compile"];constructor(t){S(this,this.constructor.exports),this.configure(t)}configure(t){this.#n.strict=t.strict,this.#n.rmWhitespace=t.rmWhitespace,this.#n.token=t.token,this.#n.vars=t.vars,this.#n.globals=t.globals,this.#n.legacy=t.legacy??!0,this.#n.slurp={match:"[s\t\n]*",start:[this.#n.token.start,"_"],end:["_",this.#n.token.end]},this.#n.matches=[],this.#n.formats=[];for(const[t,e]of L)this.#n.matches.push(this.#n.token.start.concat(t).concat(this.#n.token.regex).concat(this.#n.token.end)),this.#n.formats.push(e);this.#n.regex=new RegExp(this.#n.matches.join("|").concat("|$"),"g"),this.#n.slurpStart=new RegExp([this.#n.slurp.match,this.#n.slurp.start.join("")].join(""),"gm"),this.#n.slurpEnd=new RegExp([this.#n.slurp.end.join(""),this.#n.slurp.match].join(""),"gm"),this.#n.globals.length&&(this.#n.legacy?this.#n.globalVariables=`const ${this.#n.globals.map((t=>`${t}=${this.#n.vars.SCOPE}.${t}`)).join(",")};`:this.#n.globalVariables=`const {${this.#n.globals.join(",")}} = ${this.#n.vars.SCOPE};`)}compile(t,e){const s=this.#n.globalVariables,{SCOPE:i,SAFE:o,BUFFER:r,COMPONENT:n,ELEMENT:c}=this.#n.vars;this.#n.rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(this.#n.slurpStart,this.#n.token.start).replace(this.#n.slurpEnd,this.#n.token.end);let h=`${r}('`;((t,e,s)=>{let i=0;e.replace(t,(function(){const t=[].slice.call(arguments,0,-1),e=t.pop(),o=t.shift();return s(t,i,e),i=e+o.length,o}))})(this.#n.regex,t,((e,s,i)=>{h+=(""+t.slice(s,i)).replace(E,(t=>"\\"+b[t])),e.forEach(((t,e)=>{t&&(h+=this.#n.formats[e](t.trim(),r,o))}))})),h+="');",h=`try{${h}}catch(e){return ${r}.error(e)}`,!1===this.#n.strict&&(h=`with(${i}){${h}}`),h=`${r}.start();${h}return ${r}.end();`,h+=`\n//# sourceURL=${e}`,s&&(h=`${s}\n${h}`);try{const t=[i,n,c,r,o],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 M{static exports=["load","set","get","exist","clear","remove","resolve"];#s=!0;#c;#h={};constructor(t){S(this,this.constructor.exports),this.configure(t)}get(t){if(this.#s)return this.#h[t]}set(t,e){this.#s&&(this.#h[t]=e)}exist(t){if(this.#s)return this.#h.hasOwnProperty(t)}clear(){Object.keys(this.#h).forEach(this.remove)}remove(t){delete this.#h[t]}resolve(t){return Promise.resolve(this.get(t))}load(t){this.#s&&Object.assign(this.#h,t||{})}configure(t){this.#s=t.cache,this.#c=t.precompiled,"object"==typeof window&&this.load(window[this.#c])}}const F=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],R=" ",q='"',U="/",W="<",V=">",J=t=>{let[e,s]=t;if(null!=s)return[$(e),[q,$(s),q].join("")].join("=")},_=t=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>B(500,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(),_(s)},s.error=t=>(t=>Promise.reject(B(500,t)))(t),s.end=()=>_(e),s},D=Symbol("EjsContext.parentTemplate"),K=(t,e)=>{const{BLOCKS:s,MACRO:i,EXTEND:o,LAYOUT:r,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.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,r,{value:!1,writable:!0}),Object.defineProperty(p.prototype,o,{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]}},useEscapeValue:{get:()=>O},useComponent:{get(){return g(this[a])?this[a].bind(this):function(){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[o]=t,this}},getExtend:{value(){return this[o]}},setLayout:{value(t){return this[r]=t,this}},getLayout:{value(){return this[r]}},clone:{value(t){const e=[r,o,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){const e=this;return function(){if(g(t))return e.useBuffer.backup(),e.useBuffer(t.apply(e,arguments)),e.useBuffer.restore()}}},macro:{value(t,e){const s=this.getMacro(),i=this.fn(e),o=this;s[t]=function(){return o.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=this,o=Object.assign([],s[t]),r=function(){return o.shift()},n=function(){const t=r();return t?function(){i.echo(t(n()))}:function(){}};this.echo(r()(n()))}},hasBlock:{value(t){return this.getBlocks().hasOwnProperty(t)}},include:{value(t,e,s){const i=!1===s?{}:this.clone(!0),o=Object.assign(i,e||{}),r=this.render(t,o);this.echo(r)}},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}))})))}},get:{value(t,e){const s=w(this,t,!0),i=s.shift(),o=s.pop();return C(i,o)?i[o]:e}},set:{value(t,e){const s=w(this,t,!1),i=s.shift(),o=s.pop();return this.getParentTemplate()&&C(i,o)?i[o]:i[o]=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=[],o=-1===F.indexOf(t),r=Object.entries(e??{}).map(J).filter((t=>t)).join(R);return i.push([W,t,R,r,V].join("")),s&&o&&i.push(Array.isArray(s)?s.join(""):s),o&&i.push([W,U,t,V].join("")),i.join("")})(t,e,s))))},writable:!0},ui:{value(){},writable:!0}}),Object.entries(e).forEach((t=>{let[e,s]=t;g(s)&&u.includes(e)&&(s=s.bind(p.prototype)),p.prototype[e]=s})),p};class X{#a;static exports=["create","globals","helpers"];constructor(t,e){S(this,this.constructor.exports),this.configure(t,e)}create(t){return new this.#a(t)}helpers(t){Object.assign(this.#a.prototype,t)}configure(t,e){this.#a=K(t,e)}}const{render:Y,configure:Z,create:I,helpers:G,createContext:H,compile:Q,preload:tt}=new class{#s;#a;#i;#l;#n={};#u={};static exports=["configure","create","createContext","render","require","preload","compile","helpers"];constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S(this,this.constructor.exports),this.#u={},this.#n=v({},t),this.#a=new X(this.#n,this.#u),this.#i=new A(this.#n),this.#s=new M(this.#n),this.#l=new N(this.#n,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.#n,t),this.#a.configure(this.#n,this.#u),this.#i.configure(this.#n),this.#s.configure(this.#n),this.#l.configure(this.#n)),this.#n}createContext(t){return this.#a.create(t)}preload(t){return this.#s.load(t||{})}compile(t,e){return this.#i.compile(t,e)}helpers(t){this.#a.helpers(Object.assign(this.#u,t))}async render(t,e){const s=this.createContext(e);return this.#p(this.#t(t),s).then(this.#f(t,s))}async require(t){const e=this.createContext({});return this.#p(this.#t(t),e).then((()=>e.getMacro()))}#t(t){return t.split(".").pop()!==this.#n.extension&&(t=[t,this.#n.extension].join(".")),t}#p(t,e){return this.#l.get(t).then((t=>t.apply(e,[e,e.useComponent,e.useElement,e.useBuffer,e.useEscapeValue])))}#g(t,e,s){const i=this.createContext(e);return s&&i.setParentTemplate(s),this.#p(this.#t(t),i).then(this.#f(t,i))}#f(t,e){return s=>e.getExtend()?(e.setExtend(!1),this.#g(e.getLayout(),e,t)):s}}({resolver:(t,e,s)=>fetch(((t,e)=>(e=[t,e].join("/")).replace(/\/\//g,"/"))(t,e)).then((t=>t.ok?t.text():s(404,`template ${e} not found`)),(t=>s(500,t)))});t.compile=Q,t.configure=Z,t.create=I,t.createContext=H,t.helpers=G,t.preload=tt,t.render=Y}));
|
|
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=>Promise.all(t||[]).then((t=>t.join(""))).catch((t=>q(0,t))),ht=()=>{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(),at(s)},s.error=t=>(t=>Promise.reject(q(0,t)))(t),s.end=()=>at(e),s},lt=Symbol("EjsContext.parentTemplate"),ut=(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[lt]=null,this[n]={},this[r]={},Object.assign(this,A(t,[h,c,a,l,u]))}}return Object.defineProperties(p.prototype,{[c]:{value:ht()},[n]:{value:{},writable:!0},[r]:{value:{},writable:!0},[o]:{value:!1,writable:!0},[i]:{value:!1,writable:!0},[lt]:{value:null,writable:!0},setParentTemplate:{value(t){return this[lt]=t,this}},getParentTemplate:{value(){return this[lt]}},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=>((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("")})(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 pt=new WeakMap;class ft{constructor(t,e){r(this,pt,void 0),F(this,this.constructor.exports),this.configure(t,e)}create(t){return new(n(pt,this))(t)}helpers(t){Object.assign(n(pt,this).prototype,t)}configure(t,e){i(pt,this,ut(t,e))}}c(ft,"exports",["create","globals","helpers"]);var gt=new WeakMap,vt=new WeakMap,bt=new WeakMap,dt=new WeakMap,mt=new WeakMap,wt=new WeakMap,yt=new WeakSet;class jt{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,yt),r(this,gt,void 0),r(this,vt,void 0),r(this,bt,void 0),r(this,dt,void 0),r(this,mt,{}),r(this,wt,{}),F(this,this.constructor.exports),i(wt,this,{}),i(mt,this,k({},t)),i(vt,this,new ft(n(mt,this),n(wt,this))),i(bt,this,new I(n(mt,this))),i(gt,this,new tt(n(mt,this))),i(dt,this,new z(n(mt,this),n(gt,this),n(bt,this))),this.helpers({render:this.render,require:this.require})}create(t){return new this.constructor(t)}configure(t){return t&&(k(n(mt,this),t),n(vt,this).configure(n(mt,this),n(wt,this)),n(bt,this).configure(n(mt,this)),n(gt,this).configure(n(mt,this)),n(dt,this).configure(n(mt,this))),n(mt,this)}createContext(t){return n(vt,this).create(t)}preload(t){return n(gt,this).load(t||{})}compile(t,e){return n(bt,this).compile(t,e)}helpers(t){n(vt,this).helpers(Object.assign(n(wt,this),t))}async render(t,s){const n=this.createContext(s);return e(yt,this,Et).call(this,e(yt,this,Ot).call(this,t),n).then(e(yt,this,kt).call(this,t,n))}async require(t){const s=this.createContext({});return e(yt,this,Et).call(this,e(yt,this,Ot).call(this,t),s).then((()=>s.getMacro()))}}function Ot(t){return t.split(".").pop()!==n(mt,this).extension&&(t=[t,n(mt,this).extension].join(".")),t}function Et(t,e){return n(dt,this).get(t).then((t=>t.apply(e,[e,e.useComponent(),e.useElement(),e.useBuffer(),e.useEscapeValue()])))}function xt(t,s,n){const r=this.createContext(s);return n&&r.setParentTemplate(n),e(yt,this,Et).call(this,e(yt,this,Ot).call(this,t),r).then(e(yt,this,kt).call(this,t,r))}function kt(t,s){return n=>s.getExtend()?(s.setExtend(!1),e(yt,this,xt).call(this,s.getLayout(),s,t)):n}c(jt,"exports",["configure","create","createContext","render","require","preload","compile","helpers"]);const{render:Pt,configure:Mt,create:St,helpers:Ct,createContext:Wt,compile:Tt,preload:$t}=new jt({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=Tt,t.configure=Mt,t.create=St,t.createContext=Wt,t.helpers=Ct,t.preload=$t,t.render=Pt}));
|
package/dist/umd/element.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
const element = (tag, attrs, content) => {
|
|
49
49
|
const result = [];
|
|
50
50
|
const hasClosedTag = selfClosed.indexOf(tag) === -1;
|
|
51
|
-
const attributes = Object.entries(attrs
|
|
51
|
+
const attributes = Object.entries(attrs !== null && attrs !== void 0 ? attrs : {}).map(eachAttribute).filter(e => e).join(space);
|
|
52
52
|
result.push([lt, tag, space, attributes, gt].join(''));
|
|
53
53
|
if (content && hasClosedTag) {
|
|
54
54
|
result.push(Array.isArray(content) ? content.join('') : content);
|
package/dist/umd/element.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ejsElement={})}(this,(function(e){"use strict";const n={"&":"&","<":"<",">":">",'"':""","'":"'"},t=e=>new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g"),o=t(n);t({"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"});const i=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(o,(e=>n[e]))},r=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],u=" ",
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ejsElement={})}(this,(function(e){"use strict";const n={"&":"&","<":"<",">":">",'"':""","'":"'"},t=e=>new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g"),o=t(n);t({"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"});const i=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(o,(e=>n[e]))},r=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],u=" ",l='"',s="/",a="<",c=">",f=e=>{let[n,t]=e;if(null!=t)return[i(n),[l,i(t),l].join("")].join("=")};e.element=(e,n,t)=>{const o=[],i=-1===r.indexOf(e),l=Object.entries(null!=n?n:{}).map(f).filter((e=>e)).join(u);return o.push([a,e,u,l,c].join("")),t&&i&&o.push(Array.isArray(t)?t.join(""):t),i&&o.push([a,s,e,c].join("")),o.join("")},e.escapeValue=(e,n)=>{const t=e;return null==t?"":!0===Boolean(n)?i(t):t}}));
|