qumra-engine 1.0.12 → 1.0.14

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
- "use strict";var t=require("nunjucks"),r=require("path"),e=require("express-fingerprint"),n=require("fs");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=o(t),i=o(r),u=o(e),c=o(n);function l(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}function f(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 s(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function i(t){f(a,n,o,i,u,"next",t)}function u(t){f(a,n,o,i,u,"throw",t)}i(void 0)}))}}function h(){h=function(){return r};var t,r={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function f(t,r,e,n){var a=r&&r.prototype instanceof m?r:m,i=Object.create(a.prototype),u=new A(n||[]);return o(i,"_invoke",{value:S(t,e,u)}),i}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=f;var p="suspendedStart",v="suspendedYield",d="executing",y="completed",g={};function m(){}function w(){}function b(){}var x={};l(x,i,(function(){return this}));var j=Object.getPrototypeOf,E=j&&j(j(P([])));E&&E!==e&&n.call(E,i)&&(x=E);var L=b.prototype=m.prototype=Object.create(x);function O(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function k(t,r){function e(o,a,i,u){var c=s(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,i,u)}),(function(t){e("throw",t,i,u)})):r.resolve(f).then((function(t){l.value=t,i(l)}),(function(t){return e("throw",t,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new r((function(r,o){e(t,n,r,o)}))}return a=a?a.then(o,o):o()}})}function S(r,e,n){var o=p;return function(a,i){if(o===d)throw Error("Generator is already running");if(o===y){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=_(u,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var l=s(r,e,n);if("normal"===l.type){if(o=n.done?y:v,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=y,n.method="throw",n.arg=l.arg)}}}function _(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,_(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=s(o,r.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,g;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,g):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function G(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 A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(G,this),this.reset(!0)}function P(r){if(r||""===r){var e=r[i];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(n.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(typeof r+" is not iterable")}return w.prototype=b,o(L,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=l(b,c,"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,b):(t.__proto__=b,l(t,c,"GeneratorFunction")),t.prototype=Object.create(L),t},r.awrap=function(t){return{__await:t}},O(k.prototype),l(k.prototype,u,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,a){void 0===a&&(a=Promise);var i=new k(f(t,e,n,o),a);return r.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},O(L),l(L,c,"Generator"),l(L,i,(function(){return this})),l(L,"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=P,A.prototype={constructor:A,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)&&n.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 o(n,o){return u.type="throw",u.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,g):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),g},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),g}},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:P(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),g}},r}function p(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 l(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?l(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 v(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d=function(t){var r={};return t.split(/,(?![^\(\)]+\))/).forEach((function(t){var e=t.split(";"),n=p(e,1),o=p(n[0].split("="),2),a=o[0],i=o[1];if(a&&i){var u=a.trim(),c=i.trim();r[u]||(r[u]={value:c,attributes:{}});for(var l=1;l<e.length;l++){var f=p(e[l].split("="),2),s=f[0],h=f[1];s&&(r[u].attributes[s.trim()]=!h||h.trim())}}})),r},y=a.default,g=i.default,m=u.default,w=d,b=c.default;function x(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}var j=v((function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=r.viewsDirectory,n=g.join(e,"../","locales"),o=y.configure(e,{autoescape:!0,express:t,watch:r.watch||!1,noCache:r.noCache||!1}),a={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 o.getGlobal("assets")},cdn:function(t){return o.getGlobal("cdn")}};for(var i in a)o.addFilter(i,a[i]);var u={};b.readdirSync(n).forEach((function(t){if(t.endsWith(".json")){var r=g.basename(t,".json");u[r]=function(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}(g.join(n,t))}}));var c={};return t.use(function(){var t=s(h().mark((function t(r,e,n){var o,a;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=r.originalUrl,a=x(o),c.lang=a.language,n();case 4:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),o.addGlobal("set",(function(t,r){c[t]=r})),o.addGlobal("get",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return c[t]||r})),o.addGlobal("t",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("🚀 ~ globalVars:",c);var e=c.lang||"ar",n=u[e];return n&&function(t,r){return r.split(".").reduce((function(t,r){return t&&t[r]}),t)}(n,t)||r})),t.use(m({parameters:[m.useragent,m.acceptHeaders,m.geoip,function(t){t(null,{param1:"value1"})},function(t){t(null,{param2:"value2"})}]})),t.use(function(){var t=s(h().mark((function t(e,n,a){var i,u,c,l,f,s,p,v,d,y,g;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.originalUrl,u=e.protocol,c="".concat(u,"://").concat(e.get("host")).concat(i),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")||""},s={headers:f},t.next=7,fetch(l,s);case 7:return p=t.sent,(v=p.headers.getSetCookie())&&v.forEach((function(t){var r=w(t);Object.keys(r).forEach((function(t){var e=r[t],o=e.value,a=e.attributes;n.cookie(t,o,a)}))})),t.next=12,p.json();case 12:for(g in d=t.sent,console.log("🚀 ~ app.use ~ data:",d),y=d.global)Object.hasOwnProperty.call(y,g)&&o.addGlobal(g,y[g]);a();case 17:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),function(){var t=s(h().mark((function t(r,e,n){return h().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)}}()}));module.exports=j;
2
- //# sourceMappingURL=bundle.cjs.js.map
1
+ /*! For license information please see bundle.cjs.js.LICENSE.txt */
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,a=e.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",s=c.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,a=Object.create(o.prototype),c=new A(n||[]);return i(a,"_invoke",{value:_(t,e,c)}),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",d="executing",g="completed",m={};function w(){}function b(){}function x(){}var E={};f(E,u,(function(){return this}));var L=Object.getPrototypeOf,j=L&&L(L(T([])));j&&j!==e&&a.call(j,u)&&(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,i,c,u){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,c,u)}),(function(t){e("throw",t,c,u)})):r.resolve(f).then((function(t){s.value=t,c(s)}),(function(t){return e("throw",t,c,u)}))}u(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===d)throw Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=G(c,n);if(u){if(u===m)continue;return u}}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 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 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 N(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[u];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 b.prototype=x,i(O,"constructor",{value:x,configurable:!0}),i(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,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()}))},S(O),f(O,s,"Generator"),f(O,u,(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,A.prototype={constructor:A,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(N),!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 c.type="throw",c.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],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){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),N(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;N(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 c=t[a](i),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).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 c(t){a(i,n,o,c,u,"next",t)}function u(t){a(i,n,o,c,u,"throw",t)}c(void 0)}))}}var c=e(271),u=e(928),l=e(757),s=e(168),f=e(896);t.exports=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.viewsDirectory,a=u.join(n,"../","locales"),h=c.configure(n,{autoescape:!0,express:t,watch:r.watch||!1,noCache:r.noCache||!1}),p={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 h.getGlobal("assets")},cdn:function(t){return h.getGlobal("cdn")}};for(var v in p)h.addFilter(v,p[v]);var y={};try{f.readdirSync(a).forEach((function(t){if(t.endsWith(".json")){var r=u.basename(t,".json");y[r]=e(920)(u.join(a,t))}}))}catch(t){console.error("Error reading locales directory:",t)}var d={};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,d.lang=a.language,n();case 5:case"end":return t.stop()}var e,o,i}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),h.addGlobal("set",(function(t,r){d[t]=r})),h.addGlobal("get",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return d[t]||r})),h.addGlobal("t",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("🚀 ~ globalVars:",d);var e=d.lang||"ar",n=y[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=i(o().mark((function t(e,n,a){var i,c,u,l,f,p,v,y,d,g,m,w;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.originalUrl,c=e.protocol,u="".concat(c,"://").concat(e.get("host")).concat(i),l="https://api.qumra.cloud/templateEngine/v1/render?path=".concat(encodeURIComponent(u)),f={"Content-Type":"application/json",secretKey:r.secretKey,fingerprint:e.fingerprint.hash,"User-Agent":e.get("User-Agent")||"",Referer:e.get("Referer")||""},p={headers:f},t.prev=5,t.next=8,fetch(l,p);case 8:v=t.sent,t.next=15;break;case 11:return t.prev=11,t.t0=t.catch(5),console.error("Error fetching data:",t.t0),t.abrupt("return",a(t.t0));case 15:return(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,a=e.attributes;n.cookie(t,o,a)}))})),t.next=19,v.json();case 19:for(w in d=t.sent,g=d.global,m=d.context,g)Object.hasOwnProperty.call(g,w)&&h.addGlobal(w,g[w]);e.locales={global:g,context:m},a();case 24:case"end":return t.stop()}}),t,null,[[5,11]])})));return function(r,e,n){return t.apply(this,arguments)}}()),function(){var t=i(o().mark((function t(r,e,n){var a,i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(a=r.locales).global,i=a.context,e.render(i.page.fileName,{context:i,title:"Welcome",message:"Hello from Nunjucks with custom middleware!",cdn:"https://your-cdn-url.com/",fingerprint:r.fingerprint});case 2: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,a,i,c=[],u=!0,l=!1;try{if(a=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=a.call(e)).done)&&(c.push(n.value),c.length!==r);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(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],c=a[1];if(i&&c){var u=i.trim(),l=c.trim();e[u]||(e[u]={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[u].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 a=r[n]={exports:{}};return t[n](a,a.exports,e),a.exports}e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);var n=e(99);module.exports=n})();
@@ -0,0 +1 @@
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -1,2 +1,2 @@
1
- import t from"nunjucks";import r from"path";import e from"express-fingerprint";import n from"fs";function o(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}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)}))}}function u(){u=function(){return r};var t,r={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",l=a.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 s(t,r,e,n){var a=r&&r.prototype instanceof m?r:m,i=Object.create(a.prototype),u=new A(n||[]);return o(i,"_invoke",{value:S(t,e,u)}),i}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=s;var p="suspendedStart",v="suspendedYield",y="executing",d="completed",g={};function m(){}function w(){}function b(){}var x={};f(x,i,(function(){return this}));var j=Object.getPrototypeOf,E=j&&j(j(P([])));E&&E!==e&&n.call(E,i)&&(x=E);var L=b.prototype=m.prototype=Object.create(x);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,i,u){var c=h(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,i,u)}),(function(t){e("throw",t,i,u)})):r.resolve(f).then((function(t){l.value=t,i(l)}),(function(t){return e("throw",t,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new r((function(r,o){e(t,n,r,o)}))}return a=a?a.then(o,o):o()}})}function S(r,e,n){var o=p;return function(a,i){if(o===y)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=_(u,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=h(r,e,n);if("normal"===l.type){if(o=n.done?d:v,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=d,n.method="throw",n.arg=l.arg)}}}function _(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,_(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=h(o,r.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,g;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,g):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function G(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 A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(G,this),this.reset(!0)}function P(r){if(r||""===r){var e=r[i];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(n.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(typeof r+" is not iterable")}return w.prototype=b,o(L,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=f(b,l,"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,b):(t.__proto__=b,f(t,l,"GeneratorFunction")),t.prototype=Object.create(L),t},r.awrap=function(t){return{__await:t}},O(k.prototype),f(k.prototype,c,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,a){void 0===a&&(a=Promise);var i=new k(s(t,e,n,o),a);return r.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},O(L),f(L,l,"Generator"),f(L,i,(function(){return this})),f(L,"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=P,A.prototype={constructor:A,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)&&n.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 o(n,o){return u.type="throw",u.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,g):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),g},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),g}},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:P(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),g}},r}function c(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 o(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(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 l(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var f=t,s=r,h=e,p=function(t){var r={};return t.split(/,(?![^\(\)]+\))/).forEach((function(t){var e=t.split(";"),n=c(e,1),o=c(n[0].split("="),2),a=o[0],i=o[1];if(a&&i){var u=a.trim(),l=i.trim();r[u]||(r[u]={value:l,attributes:{}});for(var f=1;f<e.length;f++){var s=c(e[f].split("="),2),h=s[0],p=s[1];h&&(r[u].attributes[h.trim()]=!p||p.trim())}}})),r},v=n;function y(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}var d=l((function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=r.viewsDirectory,n=s.join(e,"../","locales"),o=f.configure(e,{autoescape:!0,express:t,watch:r.watch||!1,noCache:r.noCache||!1}),a={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 o.getGlobal("assets")},cdn:function(t){return o.getGlobal("cdn")}};for(var c in a)o.addFilter(c,a[c]);var l={};v.readdirSync(n).forEach((function(t){if(t.endsWith(".json")){var r=s.basename(t,".json");l[r]=function(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}(s.join(n,t))}}));var d={};return t.use(function(){var t=i(u().mark((function t(r,e,n){var o,a;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=r.originalUrl,a=y(o),d.lang=a.language,n();case 4:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),o.addGlobal("set",(function(t,r){d[t]=r})),o.addGlobal("get",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return d[t]||r})),o.addGlobal("t",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("🚀 ~ globalVars:",d);var e=d.lang||"ar",n=l[e];return n&&function(t,r){return r.split(".").reduce((function(t,r){return t&&t[r]}),t)}(n,t)||r})),t.use(h({parameters:[h.useragent,h.acceptHeaders,h.geoip,function(t){t(null,{param1:"value1"})},function(t){t(null,{param2:"value2"})}]})),t.use(function(){var t=i(u().mark((function t(e,n,a){var i,c,l,f,s,h,v,y,d,g,m;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.originalUrl,c=e.protocol,l="".concat(c,"://").concat(e.get("host")).concat(i),f="https://api.qumra.cloud/templateEngine/v1/render?path=".concat(encodeURIComponent(l)),s={"Content-Type":"application/json",secretKey:r.secretKey,fingerprint:e.fingerprint.hash,"User-Agent":e.get("User-Agent")||"",Referer:e.get("Referer")||""},h={headers:s},t.next=7,fetch(f,h);case 7:return v=t.sent,(y=v.headers.getSetCookie())&&y.forEach((function(t){var r=p(t);Object.keys(r).forEach((function(t){var e=r[t],o=e.value,a=e.attributes;n.cookie(t,o,a)}))})),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)&&o.addGlobal(m,g[m]);a();case 17:case"end":return t.stop()}}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),function(){var t=i(u().mark((function t(r,e,n){return u().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)}}()}));export{d as default};
2
- //# sourceMappingURL=bundle.esm.js.map
1
+ /*! For license information please see bundle.esm.js.LICENSE.txt */
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,a=e.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",s=c.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,a=Object.create(o.prototype),c=new A(n||[]);return i(a,"_invoke",{value:_(t,e,c)}),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",d="executing",g="completed",m={};function w(){}function b(){}function x(){}var E={};f(E,u,(function(){return this}));var L=Object.getPrototypeOf,j=L&&L(L(T([])));j&&j!==e&&a.call(j,u)&&(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,i,c,u){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,c,u)}),(function(t){e("throw",t,c,u)})):r.resolve(f).then((function(t){s.value=t,c(s)}),(function(t){return e("throw",t,c,u)}))}u(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===d)throw Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=G(c,n);if(u){if(u===m)continue;return u}}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 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 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 N(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[u];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 b.prototype=x,i(O,"constructor",{value:x,configurable:!0}),i(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,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()}))},S(O),f(O,s,"Generator"),f(O,u,(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,A.prototype={constructor:A,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(N),!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 c.type="throw",c.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],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){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),N(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;N(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 c=t[a](i),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).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 c(t){a(i,n,o,c,u,"next",t)}function u(t){a(i,n,o,c,u,"throw",t)}c(void 0)}))}}var c=e(271),u=e(928),l=e(757),s=e(168),f=e(896);t.exports=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.viewsDirectory,a=u.join(n,"../","locales"),h=c.configure(n,{autoescape:!0,express:t,watch:r.watch||!1,noCache:r.noCache||!1}),p={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 h.getGlobal("assets")},cdn:function(t){return h.getGlobal("cdn")}};for(var v in p)h.addFilter(v,p[v]);var y={};try{f.readdirSync(a).forEach((function(t){if(t.endsWith(".json")){var r=u.basename(t,".json");y[r]=e(920)(u.join(a,t))}}))}catch(t){console.error("Error reading locales directory:",t)}var d={};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,d.lang=a.language,n();case 5:case"end":return t.stop()}var e,o,i}),t)})));return function(r,e,n){return t.apply(this,arguments)}}()),h.addGlobal("set",(function(t,r){d[t]=r})),h.addGlobal("get",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return d[t]||r})),h.addGlobal("t",(function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("🚀 ~ globalVars:",d);var e=d.lang||"ar",n=y[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=i(o().mark((function t(e,n,a){var i,c,u,l,f,p,v,y,d,g,m,w;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.originalUrl,c=e.protocol,u="".concat(c,"://").concat(e.get("host")).concat(i),l="https://api.qumra.cloud/templateEngine/v1/render?path=".concat(encodeURIComponent(u)),f={"Content-Type":"application/json",secretKey:r.secretKey,fingerprint:e.fingerprint.hash,"User-Agent":e.get("User-Agent")||"",Referer:e.get("Referer")||""},p={headers:f},t.prev=5,t.next=8,fetch(l,p);case 8:v=t.sent,t.next=15;break;case 11:return t.prev=11,t.t0=t.catch(5),console.error("Error fetching data:",t.t0),t.abrupt("return",a(t.t0));case 15:return(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,a=e.attributes;n.cookie(t,o,a)}))})),t.next=19,v.json();case 19:for(w in d=t.sent,g=d.global,m=d.context,g)Object.hasOwnProperty.call(g,w)&&h.addGlobal(w,g[w]);e.locales={global:g,context:m},a();case 24:case"end":return t.stop()}}),t,null,[[5,11]])})));return function(r,e,n){return t.apply(this,arguments)}}()),function(){var t=i(o().mark((function t(r,e,n){var a,i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(a=r.locales).global,i=a.context,e.render(i.page.fileName,{context:i,title:"Welcome",message:"Hello from Nunjucks with custom middleware!",cdn:"https://your-cdn-url.com/",fingerprint:r.fingerprint});case 2: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,a,i,c=[],u=!0,l=!1;try{if(a=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=a.call(e)).done)&&(c.push(n.value),c.length!==r);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(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],c=a[1];if(i&&c){var u=i.trim(),l=c.trim();e[u]||(e[u]={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[u].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 a=e[t]={exports:{}};return r[t](a,a.exports,n),a.exports}n.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),n(99);
@@ -0,0 +1 @@
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qumra-engine",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "main": "dist/bundle.cjs.js",
5
5
  "module": "dist/bundle.esm.js",
6
6
  "scripts": {
@@ -12,6 +12,7 @@
12
12
  "license": "ISC",
13
13
  "description": "",
14
14
  "dependencies": {
15
+ "@rollup/plugin-babel": "^6.0.4",
15
16
  "express-fingerprint": "^1.2.2",
16
17
  "nunjucks": "^3.2.4",
17
18
  "qumra-cli": "^1.1.8"
package/rollup.config.js CHANGED
@@ -1,48 +1,42 @@
1
- import resolve from '@rollup/plugin-node-resolve';
1
+ import path from 'path';
2
+ import { nodeResolve } from '@rollup/plugin-node-resolve';
2
3
  import commonjs from '@rollup/plugin-commonjs';
3
- import babel from 'rollup-plugin-babel';
4
+ import babel from '@rollup/plugin-babel';
4
5
  import { terser } from 'rollup-plugin-terser';
5
- import path from 'path';
6
-
7
- const input = './lib/index.js';
6
+ import json from '@rollup/plugin-json'
7
+ const isDev = process.env.NODE_ENV === 'development';
8
8
 
9
9
  export default [
10
10
  {
11
11
  // Configuration for CommonJS
12
- input,
12
+ input: './lib/index.js',
13
13
  output: {
14
14
  file: path.resolve(__dirname, 'dist/bundle.cjs.js'),
15
15
  format: 'cjs',
16
- sourcemap: true,
16
+ sourcemap: !isDev,
17
17
  },
18
- external: id => /node_modules/.test(id), // استبعاد المكتبات الخارجية
19
18
  plugins: [
20
- resolve(),
19
+ json(),
20
+ nodeResolve(),
21
21
  commonjs(),
22
- babel({
23
- exclude: 'node_modules/**',
24
- presets: ['@babel/preset-env'],
25
- }),
26
- terser(), // ضغط الكود للإنتاج
22
+ babel({ babelHelpers: 'bundled', exclude: 'node_modules/**' }),
23
+ !isDev && terser(),
27
24
  ],
28
25
  },
29
26
  {
30
27
  // Configuration for ESM
31
- input,
28
+ input: './lib/index.js',
32
29
  output: {
33
30
  file: path.resolve(__dirname, 'dist/bundle.esm.js'),
34
31
  format: 'esm',
35
- sourcemap: true,
32
+ sourcemap: !isDev,
36
33
  },
37
- external: id => /node_modules/.test(id), // استبعاد المكتبات الخارجية
38
34
  plugins: [
39
- resolve(),
35
+ json(),
36
+ nodeResolve(),
40
37
  commonjs(),
41
- babel({
42
- exclude: 'node_modules/**',
43
- presets: ['@babel/preset-env'],
44
- }),
45
- terser(), // ضغط الكود للإنتاج
38
+ babel({ babelHelpers: 'bundled', exclude: 'node_modules/**' }),
39
+ !isDev && terser(),
46
40
  ],
47
41
  },
48
42
  ];