qumra-engine 1.0.22 → 1.0.23

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see bundle.cjs.js.LICENSE.txt */
2
- (()=>{var t={863:t=>{t.exports={upperCase:function(t){return t.toUpperCase()},reverse:function(t){return t.split("").reverse().join("")},capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()},formatCurrency:function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$")+parseFloat(t).toFixed(2)},money:function(){return"ToDo"},date:function(t){return new Date(t).toISOString().split("T")[0]},applyDiscount:function(t,r){return t-t*(r/100)},addVAT:function(t){return t+t*((arguments.length>1&&void 0!==arguments[1]?arguments[1]:15)/100)},pluralize:function(t,r,e){return 1===t?r:e},truncate:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return t.length>r?t.slice(0,r)+"...":t},trimSpaces:function(t){return t.trim()},isEmpty:function(t){return!t||0===t.trim().length},slugify:function(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]+/g,"")},formatNumber:function(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},assets:function(t){return env.getGlobal("assets")},cdn:function(t){return env.getGlobal("cdn")}}},99:(t,r,e)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){"use strict";o=function(){return r};var t,r={},e=Object.prototype,i=e.hasOwnProperty,a=Object.defineProperty||function(t,r,e){t[r]=e.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",s=u.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var o=r&&r.prototype instanceof b?r:b,i=Object.create(o.prototype),u=new N(n||[]);return a(i,"_invoke",{value:_(t,e,u)}),i}function p(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var v="suspendedStart",y="suspendedYield",g="executing",d="completed",m={};function b(){}function w(){}function x(){}var E={};f(E,c,(function(){return this}));var j=Object.getPrototypeOf,L=j&&j(j(T([])));L&&L!==e&&i.call(L,c)&&(E=L);var S=x.prototype=b.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function k(t,r){function e(o,a,u,c){var l=p(t[o],t,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==n(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,u,c)}),(function(t){e("throw",t,u,c)})):r.resolve(f).then((function(t){s.value=t,u(s)}),(function(t){return e("throw",t,u,c)}))}c(l.arg)}var o;a(this,"_invoke",{value:function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}})}function _(r,e,n){var o=v;return function(i,a){if(o===g)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=G(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=g;var l=p(r,e,n);if("normal"===l.type){if(o=n.done?d:y,l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=d,n.method="throw",n.arg=l.arg)}}}function G(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,G(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=p(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function A(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function C(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(n(r)+" is not iterable")}return w.prototype=x,a(S,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:w,configurable:!0}),w.displayName=f(x,s,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,f(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},r.awrap=function(t){return{__await:t}},O(k.prototype),f(k.prototype,l,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new k(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),f(S,s,"Generator"),f(S,c,(function(){return this})),f(S,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,N.prototype={constructor:N,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!r)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return u.type="throw",u.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),l=i.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),C(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;C(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:T(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function i(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function a(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function u(t){i(a,n,o,u,c,"next",t)}function c(t){i(a,n,o,u,c,"throw",t)}u(void 0)}))}}var u=e(271),c=e(928),l=e(757),s=e(168),f=e(896),h=e(863);t.exports=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=r.viewsDirectory,n=c.join(e,"../","locales"),i=u.configure(e,{autoescape:!0,express:t,watch:r.watch||!1,noCache:r.noCache||!1}),p={},v={};for(var y in h)i.addFilter(y,h[y]);try{f.readdirSync(n).forEach((function(t){if(t.endsWith(".json")){var r=c.basename(t,".json"),e=c.join(n,t),o=f.readFileSync(e,"utf-8");p[r]=JSON.parse(o)}}))}catch(t){console.error("Error reading locales directory:",t)}return t.use(function(){var t=a(o().mark((function t(r,e,n){var i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.locales={},o=void 0,a=void 0,o={language:"ar",path:null},(a=(e=r.originalUrl).match(/^\/([a-z]{2})\/(.*)$/))?(o.language=a[1],o.path="/".concat(a[2])):(a=e.match(/^\/([a-z]{2})$/))?(o.language=a[1],o.path="/"):o.path=e,i=o,v.lang=i.language,r.locales.lang=i.language,n();case 6:case"end":return t.stop()}var e,o,a}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),i.addGlobal("set",(function(t,r){v[t]=r})),i.addGlobal("get",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v[t]||r})),i.addGlobal("t",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("🚀 ~ globalVars:",v);var e=v.lang||"ar",n=p[e];return n&&function(t,r){return r.split(".").reduce((function(t,r){return t&&t[r]}),t)}(n,t)||r})),t.use(l({parameters:[l.useragent,l.acceptHeaders,l.geoip,function(t){t(null,{param1:"value1"})},function(t){t(null,{param2:"value2"})}]})),function(){var t=a(o().mark((function t(e,n,a){var u,l,f,h,p,v,y,g,d,m,b,w,x,E;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l=e.originalUrl,f=e.protocol,h="".concat(f,"://").concat(e.get("host")).concat(l),console.log("🚀 ~ return ~ fullUrl:",h),h){t.next=5;break}return t.abrupt("return",a(new Error("The 'originalUrl' is undefined or invalid")));case 5:if(p=c.extname(h),![".jpg",".jpeg",".png",".gif",".svg",".js",".css",".woff",".woff2",".ttf"].includes(p)){t.next=9;break}return t.abrupt("return",a());case 9:return v="https://api.qumra.cloud/templateEngine/v1/render?path=".concat(encodeURIComponent(h)),console.log("🚀 ~ app.use ~ url:",v),y={"Content-Type":"application/json",secretKey:r.secretKey,fingerprint:e.fingerprint.hash,"User-Agent":e.get("User-Agent")||"",Referer:e.get("Referer")||""},g={headers:y},t.prev=13,t.next=16,fetch(v,g);case 16:d=t.sent,t.next=23;break;case 19:return t.prev=19,t.t0=t.catch(13),console.error("Error fetching data:",t.t0),t.abrupt("return",a(t.t0));case 23:return(m=d.headers.getSetCookie())&&m.forEach((function(t){var r=s(t);Object.keys(r).forEach((function(t){var e=r[t],o=e.value,i=e.attributes;n.cookie(t,o,i)}))})),t.next=27,d.json();case 27:for(E in b=t.sent,w=b.global,x=b.context,w)Object.hasOwnProperty.call(w,E)&&i.addGlobal(E,w[E]);n.render(null===(u=x.page)||void 0===u?void 0:u.fileName,{context:x,title:"Welcome",message:"Hello from Nunjucks with custom middleware!",cdn:"https://your-cdn-url.com/",fingerprint:e.fingerprint});case 31:case"end":return t.stop()}}),t,null,[[13,19]])})));return function(r,e,n){return t.apply(this,arguments)}}()}},168:t=>{function r(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;c=!1}else for(;!(c=(n=i.call(e)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,r)||function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}t.exports=function(t){var e={};return t.split(/,(?![^\(\)]+\))/).forEach((function(t){var n=t.split(";"),o=r(n,1),i=r(o[0].split("="),2),a=i[0],u=i[1];if(a&&u){var c=a.trim(),l=u.trim();e[c]||(e[c]={value:l,attributes:{}});for(var s=1;s<n.length;s++){var f=r(n[s].split("="),2),h=f[0],p=f[1];h&&(e[c].attributes[h.trim()]=!p||p.trim())}}})),e}},757:t=>{"use strict";t.exports=require("express-fingerprint")},271:t=>{"use strict";t.exports=require("nunjucks")},896:t=>{"use strict";t.exports=require("fs")},928:t=>{"use strict";t.exports=require("path")}},r={},e=function e(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return t[n](i,i.exports,e),i.exports}(99);module.exports=e})();
2
+ (()=>{var t={920:t=>{function r(t){var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}r.keys=()=>[],r.resolve=r,r.id=920,t.exports=r},99:(t,r,e)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){"use strict";o=function(){return r};var t,r={},e=Object.prototype,i=e.hasOwnProperty,a=Object.defineProperty||function(t,r,e){t[r]=e.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",s=u.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var o=r&&r.prototype instanceof w?r:w,i=Object.create(o.prototype),u=new N(n||[]);return a(i,"_invoke",{value:_(t,e,u)}),i}function p(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var v="suspendedStart",y="suspendedYield",d="executing",g="completed",m={};function w(){}function b(){}function x(){}var E={};f(E,c,(function(){return this}));var L=Object.getPrototypeOf,j=L&&L(L(T([])));j&&j!==e&&i.call(j,c)&&(E=j);var O=x.prototype=w.prototype=Object.create(E);function S(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function k(t,r){function e(o,a,u,c){var l=p(t[o],t,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==n(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,u,c)}),(function(t){e("throw",t,u,c)})):r.resolve(f).then((function(t){s.value=t,u(s)}),(function(t){return e("throw",t,u,c)}))}c(l.arg)}var o;a(this,"_invoke",{value:function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}})}function _(r,e,n){var o=v;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=G(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var l=p(r,e,n);if("normal"===l.type){if(o=n.done?g:y,l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=g,n.method="throw",n.arg=l.arg)}}}function G(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,G(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=p(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function C(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function A(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(n(r)+" is not iterable")}return b.prototype=x,a(O,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=f(x,s,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,f(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},r.awrap=function(t){return{__await:t}},S(k.prototype),f(k.prototype,l,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new k(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),f(O,s,"Generator"),f(O,c,(function(){return this})),f(O,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,N.prototype={constructor:N,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!r)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return u.type="throw",u.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),l=i.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),A(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;A(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:T(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function i(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function a(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function u(t){i(a,n,o,u,c,"next",t)}function c(t){i(a,n,o,u,c,"throw",t)}u(void 0)}))}}var u=e(271),c=e(928),l=e(757),s=e(168),f=e(896);function h(t){var r={language:"ar",path:null},e=t.match(/^\/([a-z]{2})\/(.*)$/);return e?(r.language=e[1],r.path="/".concat(e[2])):(e=t.match(/^\/([a-z]{2})$/))?(r.language=e[1],r.path="/"):r.path=t,r}t.exports=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.viewsDirectory,i=c.join(n,"../","locales"),p=u.configure(n,{autoescape:!0,express:t,watch:r.watch||!1,noCache:r.noCache||!1}),v={upperCase:function(t){return t.toUpperCase()},reverse:function(t){return t.split("").reverse().join("")},capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()},formatCurrency:function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$")+parseFloat(t).toFixed(2)},money:function(){return"ToDo"},date:function(t){return new Date(t).toISOString().split("T")[0]},applyDiscount:function(t,r){return t-t*(r/100)},addVAT:function(t){return t+t*((arguments.length>1&&void 0!==arguments[1]?arguments[1]:15)/100)},pluralize:function(t,r,e){return 1===t?r:e},truncate:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return t.length>r?t.slice(0,r)+"...":t},trimSpaces:function(t){return t.trim()},isEmpty:function(t){return!t||0===t.trim().length},slugify:function(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]+/g,"")},formatNumber:function(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},assets:function(t){return p.getGlobal("assets")},cdn:function(t){return p.getGlobal("cdn")}};for(var y in v)p.addFilter(y,v[y]);var d={};f.readdirSync(i).forEach((function(t){if(t.endsWith(".json")){var r=c.basename(t,".json");d[r]=e(920)(c.join(i,t))}}));var g={};return t.use(function(){var t=a(o().mark((function t(r,e,n){var i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=r.originalUrl,a=h(i),g.lang=a.language,n();case 4:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),p.addGlobal("set",(function(t,r){g[t]=r})),p.addGlobal("get",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return g[t]||r})),p.addGlobal("t",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("🚀 ~ globalVars:",g);var e=g.lang||"ar",n=d[e];return n&&function(t,r){return r.split(".").reduce((function(t,r){return t&&t[r]}),t)}(n,t)||r})),t.use(l({parameters:[l.useragent,l.acceptHeaders,l.geoip,function(t){t(null,{param1:"value1"})},function(t){t(null,{param2:"value2"})}]})),t.use(function(){var t=a(o().mark((function t(e,n,i){var a,u,c,l,f,h,v,y,d,g,m;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.originalUrl,u=e.protocol,c="".concat(u,"://").concat(e.get("host")).concat(a),l="https://api.qumra.cloud/templateEngine/v1/render?path=".concat(encodeURIComponent(c)),f={"Content-Type":"application/json",secretKey:r.secretKey,fingerprint:e.fingerprint.hash,"User-Agent":e.get("User-Agent")||"",Referer:e.get("Referer")||""},h={headers:f},t.next=7,fetch(l,h);case 7:return v=t.sent,(y=v.headers.getSetCookie())&&y.forEach((function(t){var r=s(t);Object.keys(r).forEach((function(t){var e=r[t],o=e.value,i=e.attributes;n.cookie(t,o,i)}))})),t.next=12,v.json();case 12:for(m in d=t.sent,console.log("🚀 ~ app.use ~ data:",d),g=d.global)Object.hasOwnProperty.call(g,m)&&p.addGlobal(m,g[m]);i();case 17:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),function(){var t=a(o().mark((function t(r,e,n){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.render("index.njk",{title:"Welcome",message:"Hello from Nunjucks with custom middleware!",cdn:"https://your-cdn-url.com/",fingerprint:r.fingerprint});case 1:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()}},168:t=>{function r(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;c=!1}else for(;!(c=(n=i.call(e)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,r)||function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}t.exports=function(t){var e={};return t.split(/,(?![^\(\)]+\))/).forEach((function(t){var n=t.split(";"),o=r(n,1),i=r(o[0].split("="),2),a=i[0],u=i[1];if(a&&u){var c=a.trim(),l=u.trim();e[c]||(e[c]={value:l,attributes:{}});for(var s=1;s<n.length;s++){var f=r(n[s].split("="),2),h=f[0],p=f[1];h&&(e[c].attributes[h.trim()]=!p||p.trim())}}})),e}},757:t=>{"use strict";t.exports=require("express-fingerprint")},271:t=>{"use strict";t.exports=require("nunjucks")},896:t=>{"use strict";t.exports=require("fs")},928:t=>{"use strict";t.exports=require("path")}},r={};function e(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return t[n](i,i.exports,e),i.exports}e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);var n=e(99);module.exports=n})();
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see bundle.esm.js.LICENSE.txt */
2
- import{createRequire as t}from"node:module";var r={863:t=>{t.exports={upperCase:function(t){return t.toUpperCase()},reverse:function(t){return t.split("").reverse().join("")},capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()},formatCurrency:function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$")+parseFloat(t).toFixed(2)},money:function(){return"ToDo"},date:function(t){return new Date(t).toISOString().split("T")[0]},applyDiscount:function(t,r){return t-t*(r/100)},addVAT:function(t){return t+t*((arguments.length>1&&void 0!==arguments[1]?arguments[1]:15)/100)},pluralize:function(t,r,e){return 1===t?r:e},truncate:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return t.length>r?t.slice(0,r)+"...":t},trimSpaces:function(t){return t.trim()},isEmpty:function(t){return!t||0===t.trim().length},slugify:function(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]+/g,"")},formatNumber:function(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},assets:function(t){return env.getGlobal("assets")},cdn:function(t){return env.getGlobal("cdn")}}},99:(t,r,e)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){o=function(){return r};var t,r={},e=Object.prototype,a=e.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",s=u.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var o=r&&r.prototype instanceof b?r:b,a=Object.create(o.prototype),u=new N(n||[]);return i(a,"_invoke",{value:_(t,e,u)}),a}function p(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var v="suspendedStart",y="suspendedYield",g="executing",d="completed",m={};function b(){}function w(){}function x(){}var E={};f(E,c,(function(){return this}));var j=Object.getPrototypeOf,L=j&&j(j(T([])));L&&L!==e&&a.call(L,c)&&(E=L);var S=x.prototype=b.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function k(t,r){function e(o,i,u,c){var l=p(t[o],t,i);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==n(f)&&a.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,u,c)}),(function(t){e("throw",t,u,c)})):r.resolve(f).then((function(t){s.value=t,u(s)}),(function(t){return e("throw",t,u,c)}))}c(l.arg)}var o;i(this,"_invoke",{value:function(t,n){function a(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(a,a):a()}})}function _(r,e,n){var o=v;return function(a,i){if(o===g)throw Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=G(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=g;var l=p(r,e,n);if("normal"===l.type){if(o=n.done?d:y,l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=d,n.method="throw",n.arg=l.arg)}}}function G(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,G(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=p(o,r.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,m;var i=a.arg;return i?i.done?(e[r.resultName]=i.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function A(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function C(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,i=function e(){for(;++o<r.length;)if(a.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(n(r)+" is not iterable")}return w.prototype=x,i(S,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:w,configurable:!0}),w.displayName=f(x,s,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,f(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},r.awrap=function(t){return{__await:t}},O(k.prototype),f(k.prototype,l,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,a){void 0===a&&(a=Promise);var i=new k(h(t,e,n,o),a);return r.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},O(S),f(S,s,"Generator"),f(S,c,(function(){return this})),f(S,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,N.prototype={constructor:N,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!r)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return u.type="throw",u.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=r,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(i)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),C(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;C(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:T(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function a(t,r,e,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var i=t.apply(r,e);function u(t){a(i,n,o,u,c,"next",t)}function c(t){a(i,n,o,u,c,"throw",t)}u(void 0)}))}}var u=e(271),c=e(928),l=e(757),s=e(168),f=e(896),h=e(863);t.exports=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=r.viewsDirectory,n=c.join(e,"../","locales"),a=u.configure(e,{autoescape:!0,express:t,watch:r.watch||!1,noCache:r.noCache||!1}),p={},v={};for(var y in h)a.addFilter(y,h[y]);try{f.readdirSync(n).forEach((function(t){if(t.endsWith(".json")){var r=c.basename(t,".json"),e=c.join(n,t),o=f.readFileSync(e,"utf-8");p[r]=JSON.parse(o)}}))}catch(t){console.error("Error reading locales directory:",t)}return t.use(function(){var t=i(o().mark((function t(r,e,n){var a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.locales={},o=void 0,i=void 0,o={language:"ar",path:null},(i=(e=r.originalUrl).match(/^\/([a-z]{2})\/(.*)$/))?(o.language=i[1],o.path="/".concat(i[2])):(i=e.match(/^\/([a-z]{2})$/))?(o.language=i[1],o.path="/"):o.path=e,a=o,v.lang=a.language,r.locales.lang=a.language,n();case 6:case"end":return t.stop()}var e,o,i}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),a.addGlobal("set",(function(t,r){v[t]=r})),a.addGlobal("get",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v[t]||r})),a.addGlobal("t",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("🚀 ~ globalVars:",v);var e=v.lang||"ar",n=p[e];return n&&function(t,r){return r.split(".").reduce((function(t,r){return t&&t[r]}),t)}(n,t)||r})),t.use(l({parameters:[l.useragent,l.acceptHeaders,l.geoip,function(t){t(null,{param1:"value1"})},function(t){t(null,{param2:"value2"})}]})),function(){var t=i(o().mark((function t(e,n,i){var u,l,f,h,p,v,y,g,d,m,b,w,x,E;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l=e.originalUrl,f=e.protocol,h="".concat(f,"://").concat(e.get("host")).concat(l),console.log("🚀 ~ return ~ fullUrl:",h),h){t.next=5;break}return t.abrupt("return",i(new Error("The 'originalUrl' is undefined or invalid")));case 5:if(p=c.extname(h),![".jpg",".jpeg",".png",".gif",".svg",".js",".css",".woff",".woff2",".ttf"].includes(p)){t.next=9;break}return t.abrupt("return",i());case 9:return v="https://api.qumra.cloud/templateEngine/v1/render?path=".concat(encodeURIComponent(h)),console.log("🚀 ~ app.use ~ url:",v),y={"Content-Type":"application/json",secretKey:r.secretKey,fingerprint:e.fingerprint.hash,"User-Agent":e.get("User-Agent")||"",Referer:e.get("Referer")||""},g={headers:y},t.prev=13,t.next=16,fetch(v,g);case 16:d=t.sent,t.next=23;break;case 19:return t.prev=19,t.t0=t.catch(13),console.error("Error fetching data:",t.t0),t.abrupt("return",i(t.t0));case 23:return(m=d.headers.getSetCookie())&&m.forEach((function(t){var r=s(t);Object.keys(r).forEach((function(t){var e=r[t],o=e.value,a=e.attributes;n.cookie(t,o,a)}))})),t.next=27,d.json();case 27:for(E in b=t.sent,w=b.global,x=b.context,w)Object.hasOwnProperty.call(w,E)&&a.addGlobal(E,w[E]);n.render(null===(u=x.page)||void 0===u?void 0:u.fileName,{context:x,title:"Welcome",message:"Hello from Nunjucks with custom middleware!",cdn:"https://your-cdn-url.com/",fingerprint:e.fingerprint});case 31:case"end":return t.stop()}}),t,null,[[13,19]])})));return function(r,e,n){return t.apply(this,arguments)}}()}},168:t=>{function r(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,a,i,u=[],c=!0,l=!1;try{if(a=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;c=!1}else for(;!(c=(n=a.call(e)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(t,r)||function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}t.exports=function(t){var e={};return t.split(/,(?![^\(\)]+\))/).forEach((function(t){var n=t.split(";"),o=r(n,1),a=r(o[0].split("="),2),i=a[0],u=a[1];if(i&&u){var c=i.trim(),l=u.trim();e[c]||(e[c]={value:l,attributes:{}});for(var s=1;s<n.length;s++){var f=r(n[s].split("="),2),h=f[0],p=f[1];h&&(e[c].attributes[h.trim()]=!p||p.trim())}}})),e}},757:t=>{t.exports=require("express-fingerprint")},271:t=>{t.exports=require("nunjucks")},896:r=>{r.exports=t(import.meta.url)("fs")},928:r=>{r.exports=t(import.meta.url)("path")}},e={};!function t(n){var o=e[n];if(void 0!==o)return o.exports;var a=e[n]={exports:{}};return r[n](a,a.exports,t),a.exports}(99);
2
+ import{createRequire as t}from"node:module";var r={920:t=>{function r(t){var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}r.keys=()=>[],r.resolve=r,r.id=920,t.exports=r},99:(t,r,e)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){o=function(){return r};var t,r={},e=Object.prototype,i=e.hasOwnProperty,a=Object.defineProperty||function(t,r,e){t[r]=e.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",s=u.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var o=r&&r.prototype instanceof w?r:w,i=Object.create(o.prototype),u=new N(n||[]);return a(i,"_invoke",{value:_(t,e,u)}),i}function p(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var v="suspendedStart",y="suspendedYield",d="executing",g="completed",m={};function w(){}function b(){}function x(){}var E={};f(E,c,(function(){return this}));var L=Object.getPrototypeOf,j=L&&L(L(T([])));j&&j!==e&&i.call(j,c)&&(E=j);var O=x.prototype=w.prototype=Object.create(E);function S(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function k(t,r){function e(o,a,u,c){var l=p(t[o],t,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==n(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,u,c)}),(function(t){e("throw",t,u,c)})):r.resolve(f).then((function(t){s.value=t,u(s)}),(function(t){return e("throw",t,u,c)}))}c(l.arg)}var o;a(this,"_invoke",{value:function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}})}function _(r,e,n){var o=v;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=G(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var l=p(r,e,n);if("normal"===l.type){if(o=n.done?g:y,l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=g,n.method="throw",n.arg=l.arg)}}}function G(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,G(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=p(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function C(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function A(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(n(r)+" is not iterable")}return b.prototype=x,a(O,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=f(x,s,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,f(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},r.awrap=function(t){return{__await:t}},S(k.prototype),f(k.prototype,l,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new k(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),f(O,s,"Generator"),f(O,c,(function(){return this})),f(O,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,N.prototype={constructor:N,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!r)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return u.type="throw",u.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),l=i.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),A(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;A(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:T(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function i(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function a(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function u(t){i(a,n,o,u,c,"next",t)}function c(t){i(a,n,o,u,c,"throw",t)}u(void 0)}))}}var u=e(271),c=e(928),l=e(757),s=e(168),f=e(896);function h(t){var r={language:"ar",path:null},e=t.match(/^\/([a-z]{2})\/(.*)$/);return e?(r.language=e[1],r.path="/".concat(e[2])):(e=t.match(/^\/([a-z]{2})$/))?(r.language=e[1],r.path="/"):r.path=t,r}t.exports=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.viewsDirectory,i=c.join(n,"../","locales"),p=u.configure(n,{autoescape:!0,express:t,watch:r.watch||!1,noCache:r.noCache||!1}),v={upperCase:function(t){return t.toUpperCase()},reverse:function(t){return t.split("").reverse().join("")},capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()},formatCurrency:function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$")+parseFloat(t).toFixed(2)},money:function(){return"ToDo"},date:function(t){return new Date(t).toISOString().split("T")[0]},applyDiscount:function(t,r){return t-t*(r/100)},addVAT:function(t){return t+t*((arguments.length>1&&void 0!==arguments[1]?arguments[1]:15)/100)},pluralize:function(t,r,e){return 1===t?r:e},truncate:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return t.length>r?t.slice(0,r)+"...":t},trimSpaces:function(t){return t.trim()},isEmpty:function(t){return!t||0===t.trim().length},slugify:function(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]+/g,"")},formatNumber:function(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},assets:function(t){return p.getGlobal("assets")},cdn:function(t){return p.getGlobal("cdn")}};for(var y in v)p.addFilter(y,v[y]);var d={};f.readdirSync(i).forEach((function(t){if(t.endsWith(".json")){var r=c.basename(t,".json");d[r]=e(920)(c.join(i,t))}}));var g={};return t.use(function(){var t=a(o().mark((function t(r,e,n){var i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=r.originalUrl,a=h(i),g.lang=a.language,n();case 4:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),p.addGlobal("set",(function(t,r){g[t]=r})),p.addGlobal("get",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return g[t]||r})),p.addGlobal("t",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("🚀 ~ globalVars:",g);var e=g.lang||"ar",n=d[e];return n&&function(t,r){return r.split(".").reduce((function(t,r){return t&&t[r]}),t)}(n,t)||r})),t.use(l({parameters:[l.useragent,l.acceptHeaders,l.geoip,function(t){t(null,{param1:"value1"})},function(t){t(null,{param2:"value2"})}]})),t.use(function(){var t=a(o().mark((function t(e,n,i){var a,u,c,l,f,h,v,y,d,g,m;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.originalUrl,u=e.protocol,c="".concat(u,"://").concat(e.get("host")).concat(a),l="https://api.qumra.cloud/templateEngine/v1/render?path=".concat(encodeURIComponent(c)),f={"Content-Type":"application/json",secretKey:r.secretKey,fingerprint:e.fingerprint.hash,"User-Agent":e.get("User-Agent")||"",Referer:e.get("Referer")||""},h={headers:f},t.next=7,fetch(l,h);case 7:return v=t.sent,(y=v.headers.getSetCookie())&&y.forEach((function(t){var r=s(t);Object.keys(r).forEach((function(t){var e=r[t],o=e.value,i=e.attributes;n.cookie(t,o,i)}))})),t.next=12,v.json();case 12:for(m in d=t.sent,console.log("🚀 ~ app.use ~ data:",d),g=d.global)Object.hasOwnProperty.call(g,m)&&p.addGlobal(m,g[m]);i();case 17:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),function(){var t=a(o().mark((function t(r,e,n){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.render("index.njk",{title:"Welcome",message:"Hello from Nunjucks with custom middleware!",cdn:"https://your-cdn-url.com/",fingerprint:r.fingerprint});case 1:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()}},168:t=>{function r(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;c=!1}else for(;!(c=(n=i.call(e)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,r)||function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}t.exports=function(t){var e={};return t.split(/,(?![^\(\)]+\))/).forEach((function(t){var n=t.split(";"),o=r(n,1),i=r(o[0].split("="),2),a=i[0],u=i[1];if(a&&u){var c=a.trim(),l=u.trim();e[c]||(e[c]={value:l,attributes:{}});for(var s=1;s<n.length;s++){var f=r(n[s].split("="),2),h=f[0],p=f[1];h&&(e[c].attributes[h.trim()]=!p||p.trim())}}})),e}},757:t=>{t.exports=require("express-fingerprint")},271:t=>{t.exports=require("nunjucks")},896:r=>{r.exports=t(import.meta.url)("fs")},928:r=>{r.exports=t(import.meta.url)("path")}},e={};function n(t){var o=e[t];if(void 0!==o)return o.exports;var i=e[t]={exports:{}};return r[t](i,i.exports,n),i.exports}n.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),n(99);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qumra-engine",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "main": "dist/bundle.cjs.js",
5
5
  "module": "dist/bundle.esm.js",
6
6
  "scripts": {
package/app/index.js DELETED
@@ -1,16 +0,0 @@
1
- const express = require('express');
2
- const path = require('path');
3
- const createNunjucksMiddleware = require('../lib');
4
-
5
- const app = express();
6
-
7
- app.use("*",createNunjucksMiddleware(app, {
8
- viewsDirectory: path.join(__dirname, "src" , 'views'),
9
- secretKey: "5cd7670387f5eed1ea597d46dbb45d791516a02b7df3c8e9f81f59a9266ad7ca",
10
- watch: true,
11
- }));
12
-
13
- // تشغيل الخادم
14
- app.listen(3000, () => {
15
- console.log('Server is running on http://localhost:3000');
16
- });
@@ -1,25 +0,0 @@
1
- {
2
- "blocks": {
3
- "header": {
4
- "cart": "السلة"
5
- },
6
- "appBanner": {
7
- "download_now": "حمله الان"
8
- }
9
- },
10
- "pages": {
11
- "cart": {
12
- "cart_options": "خيارات السلة"
13
- },
14
- "order": {
15
- "can_edit_or_delete_your_review_within": "يمكنك تعديل أو حذف تقييمك خلال",
16
- "edit_period_ended": "تم انتهاء المدة المحددة لتعديل التقييم",
17
- "delete_period_ended": "تم انتهاء المدة المحددة لحذف التقييم",
18
- "days_since_added": "أيام من إضافته"
19
- }
20
- },
21
- "common": {
22
- "bank_offer_sub_title_multiple": "ادفع قيمة مشترياتك عبر أحد البطاقات البنكة التالية واحصل على الخصم المحدد",
23
- "bank_offer_sub_title_single": "ادفع قيمة مشترياتك عبر أحد بطاقات بنك :bank_name واحصل على خصم بنسبة "
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "blocks": {
3
- "header": {
4
- "cart": "Cart"
5
- },
6
- "appBanner": {
7
- "download_now": "download now"
8
- }
9
- },
10
- "pages": {
11
- "cart": {
12
- "cart_options": "Cart Options"
13
- },
14
- "order": {
15
- "can_edit_or_delete_your_review_within": "You can edit or delete your review within",
16
- "edit_period_ended": "The period to edit the review has ended",
17
- "delete_period_ended": "The period to delete the review has ended",
18
- "days_since_added": "days since it was added"
19
- }
20
- },
21
- "common": {
22
- "bank_offer_sub_title_multiple": "Pay for your purchases via one of the following bank cards and get the specified discount",
23
- "bank_offer_sub_title_single": "Pay for your purchases via :bank_name bank card and get discount"
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "blocks": {
3
- "header": {
4
- "cart": "Panier9999999"
5
- },
6
- "appBanner": {
7
- "download_now": "télécharger maintenant"
8
- }
9
- },
10
- "pages": {
11
- "cart": {
12
- "cart_options": "Options du panier"
13
- },
14
- "order": {
15
- "can_edit_or_delete_your_review_within": "Vous pouvez modifier ou supprimer votre avis dans",
16
- "edit_period_ended": "La période pour modifier l'avis est terminée",
17
- "delete_period_ended": "La période pour supprimer l'avis est terminée",
18
- "days_since_added": "jours depuis son ajout"
19
- }
20
- },
21
- "common": {
22
- "bank_offer_sub_title_multiple": "Payez vos achats avec l'une des cartes bancaires suivantes et obtenez la réduction spécifiée",
23
- "bank_offer_sub_title_single": "Payez vos achats avec la carte bancaire :bank_name et obtenez une réduction"
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "blocks": {
3
- "header": {
4
- "cart": "Panier"
5
- },
6
- "appBanner": {
7
- "download_now": "télécharger maintenant"
8
- }
9
- },
10
- "pages": {
11
- "cart": {
12
- "cart_options": "Options du panier"
13
- },
14
- "order": {
15
- "can_edit_or_delete_your_review_within": "Vous pouvez modifier ou supprimer votre avis dans",
16
- "edit_period_ended": "La période pour modifier l'avis est terminée",
17
- "delete_period_ended": "La période pour supprimer l'avis est terminée",
18
- "days_since_added": "jours depuis son ajout"
19
- }
20
- },
21
- "common": {
22
- "bank_offer_sub_title_multiple": "Payez vos achats avec l'une des cartes bancaires suivantes et obtenez la réduction spécifiée",
23
- "bank_offer_sub_title_single": "Payez vos achats avec la carte bancaire :bank_name et obtenez une réduction"
24
- }
25
- }
@@ -1,18 +0,0 @@
1
- {% macro field(name, value = '', type = 'text') %}
2
- <div class="field">
3
- <p>
4
- {{"123456789" | reverse}}
5
- </p>
6
- <input type="{{ type }}" name="{{ name }}"
7
- value="{{ value | escape }}"/>
8
- </div>
9
- {% endmacro %}
10
-
11
- {% macro label(text) %}
12
- <div>
13
- <p>
14
- {{"123456789" | assets}}
15
- </p>
16
- <label>{{ text }}</label>
17
- </div>
18
- {% endmacro %}
@@ -1,24 +0,0 @@
1
- {% import "forms.njk" as forms %}
2
-
3
- <html lang="en">
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Document</title>
8
- </head>
9
- <body>
10
-
11
- {{ set('theme_color', '#ffaaa0000') }}
12
- {{ set('font_size', '16px') }}
13
-
14
- {{ forms.label('Username') }}
15
-
16
- {{fingerprint.hash}}
17
- {{"123456789" | reverse}}
18
- <div>{{t("blocks.header.cart", "no")}}</div>
19
- asd
20
- <div>
21
- Default Background Color: {{ get('theme_color', '#ffffff') }}
22
- </div>
23
- </body>
24
- </html>