qumra-engine 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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,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,g=d.global)Object.hasOwnProperty.call(g,m)&&p.addGlobal(m,g[m]);i();case 16: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
|
+
"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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.cjs.js","sources":["../lib/utils/CookieParser.js","../lib/index.js"],"sourcesContent":["const CookieParser = (setCookieHeader) => {\n const cookies = {};\n\n // تقسيم الكوكيز بناءً على الفواصل، مع التعامل مع الفواصل داخل القيم\n const cookiePairs = setCookieHeader.split(/,(?![^\\(\\)]+\\))/);\n\n cookiePairs.forEach(cookieStr => {\n const parts = cookieStr.split(';');\n const [nameValue] = parts;\n const [name, value] = nameValue.split('=');\n\n if (name && value) {\n // إزالة المسافات البيضاء\n const trimmedName = name.trim();\n const trimmedValue = value.trim();\n \n // تهيئة الكائن للكوكي إذا لم يكن موجوداً\n if (!cookies[trimmedName]) {\n cookies[trimmedName] = {\n value: trimmedValue,\n attributes: {}\n };\n }\n\n // إضافة العلامات الأخرى\n for (let i = 1; i < parts.length; i++) {\n const [attributeName, attributeValue] = parts[i].split('=');\n if (attributeName) {\n cookies[trimmedName].attributes[attributeName.trim()] = attributeValue ? attributeValue.trim() : true;\n }\n }\n }\n });\n\n return cookies;\n}\nmodule.exports = CookieParser","const nunjucks = require(\"nunjucks\");\nconst path = require(\"path\");\nconst Fingerprint = require(\"express-fingerprint\");\nconst CookieParser = require(\"./utils/CookieParser\");\nconst fs = require(\"fs\")\nfunction extractLanguageAndPath(path) {\n // Regular expression to match the /[lang]/[path] pattern\n const langPattern = /^\\/([a-z]{2})\\/(.*)$/;\n const rootPattern = /^\\/([a-z]{2})$/;\n\n let result = {\n language: 'ar', // Default language is Arabic\n path: null\n };\n\n // Check if the path matches the /[lang]/[path] pattern\n let match = path.match(langPattern);\n if (match) {\n result.language = match[1]; // Extract language\n result.path = `/${match[2]}`; // Extract path\n } else {\n // Check if the path matches the /[lang] pattern\n match = path.match(rootPattern);\n if (match) {\n result.language = match[1]; // Extract language\n result.path = '/'; // Root path\n } else {\n // If the path does not match any pattern, consider the entire path as path and language as default\n result.path = path;\n }\n }\n\n return result;\n}\nfunction createNunjucksMiddleware(app, options = {}) {\n const viewsDirectory = options.viewsDirectory;\n const localesDirectory = path.join(viewsDirectory , \"../\", 'locales'); // الرجوع خطوة واحدة إلى مستوى أعلى ثم الوصول إلى مجلد locales\n\n // إعداد Nunjucks\n const env = nunjucks.configure(viewsDirectory, {\n autoescape: true,\n express: app,\n watch: options.watch || false,\n noCache: options.noCache || false,\n });\n\n const defaultFilters = {\n upperCase: (str) => str.toUpperCase(),\n reverse: (str) => str.split(\"\").reverse().join(\"\"),\n capitalize: (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(),\n formatCurrency: (amount, symbol = \"$\") => symbol + parseFloat(amount).toFixed(2),\n money: () => \"ToDo\",\n date: (date, format = \"YYYY-MM-DD\") => new Date(date).toISOString().split(\"T\")[0],\n applyDiscount: (price, discountPercent) => price - price * (discountPercent / 100),\n addVAT: (price, vatPercent = 15) => price + price * (vatPercent / 100),\n pluralize: (quantity, singular, plural) => quantity === 1 ? singular : plural,\n truncate: (str, length = 100) => str.length > length ? str.slice(0, length) + \"...\" : str,\n trimSpaces: (str) => str.trim(),\n isEmpty: (str) => !str || str.trim().length === 0,\n slugify: (str) => str.toLowerCase().replace(/\\s+/g, \"-\").replace(/[^\\w-]+/g, \"\"),\n formatNumber: (num) => num.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\"),\n assets: (path) => env.getGlobal(\"assets\"),\n cdn: (path) => env.getGlobal(\"cdn\"),\n };\n\n // إضافة الفلترات المدمجة إلى بيئة Nunjucks\n for (const filterName in defaultFilters) {\n env.addFilter(filterName, defaultFilters[filterName]);\n }\n\n const locales = {};\n fs.readdirSync(localesDirectory).forEach(file => {\n if (file.endsWith('.json')) {\n const localeName = path.basename(file, '.json');\n locales[localeName] = require(path.join(localesDirectory, file));\n }\n });\n\n\n\n const globalVars = {};\n\n app.use(async (req, res, next) => {\n const { originalUrl } = req;\n const newPath = extractLanguageAndPath(originalUrl);\n globalVars['lang'] = newPath.language;\n next();\n })\n\n env.addGlobal(\"set\", function (key, value) {\n globalVars[key] = value;\n });\n\n env.addGlobal(\"get\", function (key, defaultValue = null) {\n return globalVars[key] || defaultValue;\n });\n\n function getNestedValue(obj, key) {\n return key.split('.').reduce((acc, part) => acc && acc[part], obj);\n }\n\n env.addGlobal(\"t\", function (key, defaultValue = '') {\n console.log(\"🚀 ~ globalVars:\", globalVars)\n const lang = globalVars['lang'] || 'ar';\n const locale = locales[lang];\n return locale ? getNestedValue(locale, key) || defaultValue : defaultValue;\n });\n\n app.use(\n Fingerprint({\n parameters: [\n Fingerprint.useragent,\n Fingerprint.acceptHeaders,\n Fingerprint.geoip,\n function (next) {\n next(null, { param1: \"value1\" });\n },\n function (next) {\n next(null, { param2: \"value2\" });\n },\n ],\n })\n );\n\n app.use(async (req, res, next) => {\n const { originalUrl, protocol } = req;\n const fullUrl = `${protocol}://${req.get(\"host\")}${originalUrl}`;\n const url = `https://api.qumra.cloud/templateEngine/v1/render?path=${encodeURIComponent(fullUrl)}`;\n const headers = {\n \"Content-Type\": \"application/json\",\n secretKey: options.secretKey,\n fingerprint: req.fingerprint.hash,\n \"User-Agent\": req.get(\"User-Agent\") || \"\",\n Referer: req.get(\"Referer\") || \"\",\n };\n const config = { headers };\n\n const response = await fetch(url, config);\n const resHeaders = response.headers.getSetCookie();\n if (resHeaders) {\n resHeaders.forEach((header) => {\n const parsedCookies = CookieParser(header);\n Object.keys(parsedCookies).forEach((name) => {\n const { value, attributes } = parsedCookies[name];\n res.cookie(name, value, attributes);\n });\n });\n }\n\n const data = await response.json();\n console.log(\"🚀 ~ app.use ~ data:\", data)\n const { global } = data;\n for (const key in global) {\n if (Object.hasOwnProperty.call(global, key)) {\n env.addGlobal(key, global[key]);\n }\n }\n\n next();\n });\n\n return async (req, res, next) => {\n res.render(\"index.njk\", {\n title: \"Welcome\",\n message: \"Hello from Nunjucks with custom middleware!\",\n cdn: \"https://your-cdn-url.com/\",\n fingerprint: req.fingerprint,\n });\n };\n}\n\nmodule.exports = createNunjucksMiddleware;"],"names":["CookieParser_1","setCookieHeader","cookies","split","forEach","cookieStr","parts","_parts","_slicedToArray","_nameValue$split2","name","value","trimmedName","trim","trimmedValue","attributes","i","length","_parts$i$split2","attributeName","attributeValue","nunjucks","require$$0","path","require$$1","Fingerprint","require$$2","CookieParser","require$$3","fs","require$$4","extractLanguageAndPath","result","language","match","concat","app","options","arguments","undefined","viewsDirectory","localesDirectory","join","env","configure","autoescape","express","watch","noCache","defaultFilters","upperCase","str","toUpperCase","reverse","capitalize","charAt","slice","toLowerCase","formatCurrency","amount","parseFloat","toFixed","money","date","Date","toISOString","applyDiscount","price","discountPercent","addVAT","pluralize","quantity","singular","plural","truncate","trimSpaces","isEmpty","slugify","replace","formatNumber","num","toString","assets","getGlobal","cdn","filterName","addFilter","locales","readdirSync","file","endsWith","localeName","basename","require","globalVars","use","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","req","res","next","originalUrl","newPath","wrap","_context","prev","stop","_x","_x2","_x3","apply","this","addGlobal","key","defaultValue","console","log","lang","locale","obj","reduce","acc","part","getNestedValue","parameters","useragent","acceptHeaders","geoip","param1","param2","_ref2","_callee2","protocol","fullUrl","url","headers","config","response","resHeaders","data","global","_context2","get","encodeURIComponent","secretKey","fingerprint","hash","Referer","fetch","sent","getSetCookie","header","parsedCookies","Object","keys","_parsedCookies$name","cookie","json","hasOwnProperty","call","_x4","_x5","_x6","_ref3","_callee3","_context3","render","title","message","_x7","_x8","_x9"],"mappings":"w9PAAA,IAoCAA,EApCqB,SAACC,GAClB,IAAMC,EAAU,CAAA,EAiChB,OA9BoBD,EAAgBE,MAAM,mBAE9BC,SAAQ,SAAAC,GAChB,IAAM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AoJ,EAA8BH,EAAcjJ,GAApCC,EAAKmJ,EAALnJ,MAAOI,EAAU+I,EAAV/I,WACfuF,EAAIyD,OAAOrJ,EAAMC,EAAOI,EAClC,GACA,IACKiI,EAAAzC,KAAA,GAEkBqC,EAASoB,OAAM,KAAA,GAGlC,IAAW5C,KAHL0B,EAAIE,EAAAQ,KACVlC,QAAQC,IAAI,uBAAwBuB,GAC5BC,EAAWD,EAAXC,OAEFa,OAAOK,eAAeC,KAAKnB,EAAQ3B,IACrCzE,EAAIwE,UAAUC,EAAK2B,EAAO3B,IAI9Bb,IAAO,KAAA,GAAA,IAAA,MAAA,OAAAyC,EAAAnC,OAAA,GAAAyB,EACR,KAAA,OAAA,SAAA6B,EAAAC,EAAAC,GAAA,OAAAhC,EAAApB,MAAAC,KAAA5E,UAAA,CAAC,CAnCK,IAqCP,WAAA,IAAAgI,EAAArE,EAAAC,IAAAC,MAAO,SAAAoE,EAAOlE,EAAKC,EAAKC,GAAI,OAAAL,IAAAQ,MAAA,SAAA8D,GAAA,cAAAA,EAAA5D,KAAA4D,EAAAjE,MAAA,KAAA,EAC1BD,EAAImE,OAAO,YAAa,CACtBC,MAAO,UACPC,QAAS,8CACTvF,IAAK,4BACLgE,YAAa/C,EAAI+C,cAChB,KAAA,EAAA,IAAA,MAAA,OAAAoB,EAAA3D,OAAA,GAAA0D,EACJ,KAAA,OAAA,SAAAK,EAAAC,EAAAC,GAAA,OAAAR,EAAArD,MAAAC,KAAA5E,UAAA,CAAA,CAPD,EAQF"}
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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,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,g=d.global)Object.hasOwnProperty.call(g,m)&&p.addGlobal(m,g[m]);i();case 16: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);
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.esm.js","sources":["../lib/utils/CookieParser.js","../lib/index.js"],"sourcesContent":["const CookieParser = (setCookieHeader) => {\n const cookies = {};\n\n // تقسيم الكوكيز بناءً على الفواصل، مع التعامل مع الفواصل داخل القيم\n const cookiePairs = setCookieHeader.split(/,(?![^\\(\\)]+\\))/);\n\n cookiePairs.forEach(cookieStr => {\n const parts = cookieStr.split(';');\n const [nameValue] = parts;\n const [name, value] = nameValue.split('=');\n\n if (name && value) {\n // إزالة المسافات البيضاء\n const trimmedName = name.trim();\n const trimmedValue = value.trim();\n \n // تهيئة الكائن للكوكي إذا لم يكن موجوداً\n if (!cookies[trimmedName]) {\n cookies[trimmedName] = {\n value: trimmedValue,\n attributes: {}\n };\n }\n\n // إضافة العلامات الأخرى\n for (let i = 1; i < parts.length; i++) {\n const [attributeName, attributeValue] = parts[i].split('=');\n if (attributeName) {\n cookies[trimmedName].attributes[attributeName.trim()] = attributeValue ? attributeValue.trim() : true;\n }\n }\n }\n });\n\n return cookies;\n}\nmodule.exports = CookieParser","const nunjucks = require(\"nunjucks\");\nconst path = require(\"path\");\nconst Fingerprint = require(\"express-fingerprint\");\nconst CookieParser = require(\"./utils/CookieParser\");\nconst fs = require(\"fs\")\nfunction extractLanguageAndPath(path) {\n // Regular expression to match the /[lang]/[path] pattern\n const langPattern = /^\\/([a-z]{2})\\/(.*)$/;\n const rootPattern = /^\\/([a-z]{2})$/;\n\n let result = {\n language: 'ar', // Default language is Arabic\n path: null\n };\n\n // Check if the path matches the /[lang]/[path] pattern\n let match = path.match(langPattern);\n if (match) {\n result.language = match[1]; // Extract language\n result.path = `/${match[2]}`; // Extract path\n } else {\n // Check if the path matches the /[lang] pattern\n match = path.match(rootPattern);\n if (match) {\n result.language = match[1]; // Extract language\n result.path = '/'; // Root path\n } else {\n // If the path does not match any pattern, consider the entire path as path and language as default\n result.path = path;\n }\n }\n\n return result;\n}\nfunction createNunjucksMiddleware(app, options = {}) {\n const viewsDirectory = options.viewsDirectory;\n const localesDirectory = path.join(viewsDirectory , \"../\", 'locales'); // الرجوع خطوة واحدة إلى مستوى أعلى ثم الوصول إلى مجلد locales\n\n // إعداد Nunjucks\n const env = nunjucks.configure(viewsDirectory, {\n autoescape: true,\n express: app,\n watch: options.watch || false,\n noCache: options.noCache || false,\n });\n\n const defaultFilters = {\n upperCase: (str) => str.toUpperCase(),\n reverse: (str) => str.split(\"\").reverse().join(\"\"),\n capitalize: (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(),\n formatCurrency: (amount, symbol = \"$\") => symbol + parseFloat(amount).toFixed(2),\n money: () => \"ToDo\",\n date: (date, format = \"YYYY-MM-DD\") => new Date(date).toISOString().split(\"T\")[0],\n applyDiscount: (price, discountPercent) => price - price * (discountPercent / 100),\n addVAT: (price, vatPercent = 15) => price + price * (vatPercent / 100),\n pluralize: (quantity, singular, plural) => quantity === 1 ? singular : plural,\n truncate: (str, length = 100) => str.length > length ? str.slice(0, length) + \"...\" : str,\n trimSpaces: (str) => str.trim(),\n isEmpty: (str) => !str || str.trim().length === 0,\n slugify: (str) => str.toLowerCase().replace(/\\s+/g, \"-\").replace(/[^\\w-]+/g, \"\"),\n formatNumber: (num) => num.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\"),\n assets: (path) => env.getGlobal(\"assets\"),\n cdn: (path) => env.getGlobal(\"cdn\"),\n };\n\n // إضافة الفلترات المدمجة إلى بيئة Nunjucks\n for (const filterName in defaultFilters) {\n env.addFilter(filterName, defaultFilters[filterName]);\n }\n\n const locales = {};\n fs.readdirSync(localesDirectory).forEach(file => {\n if (file.endsWith('.json')) {\n const localeName = path.basename(file, '.json');\n locales[localeName] = require(path.join(localesDirectory, file));\n }\n });\n\n\n\n const globalVars = {};\n\n app.use(async (req, res, next) => {\n const { originalUrl } = req;\n const newPath = extractLanguageAndPath(originalUrl);\n globalVars['lang'] = newPath.language;\n next();\n })\n\n env.addGlobal(\"set\", function (key, value) {\n globalVars[key] = value;\n });\n\n env.addGlobal(\"get\", function (key, defaultValue = null) {\n return globalVars[key] || defaultValue;\n });\n\n function getNestedValue(obj, key) {\n return key.split('.').reduce((acc, part) => acc && acc[part], obj);\n }\n\n env.addGlobal(\"t\", function (key, defaultValue = '') {\n console.log(\"🚀 ~ globalVars:\", globalVars)\n const lang = globalVars['lang'] || 'ar';\n const locale = locales[lang];\n return locale ? getNestedValue(locale, key) || defaultValue : defaultValue;\n });\n\n app.use(\n Fingerprint({\n parameters: [\n Fingerprint.useragent,\n Fingerprint.acceptHeaders,\n Fingerprint.geoip,\n function (next) {\n next(null, { param1: \"value1\" });\n },\n function (next) {\n next(null, { param2: \"value2\" });\n },\n ],\n })\n );\n\n app.use(async (req, res, next) => {\n const { originalUrl, protocol } = req;\n const fullUrl = `${protocol}://${req.get(\"host\")}${originalUrl}`;\n const url = `https://api.qumra.cloud/templateEngine/v1/render?path=${encodeURIComponent(fullUrl)}`;\n const headers = {\n \"Content-Type\": \"application/json\",\n secretKey: options.secretKey,\n fingerprint: req.fingerprint.hash,\n \"User-Agent\": req.get(\"User-Agent\") || \"\",\n Referer: req.get(\"Referer\") || \"\",\n };\n const config = { headers };\n\n const response = await fetch(url, config);\n const resHeaders = response.headers.getSetCookie();\n if (resHeaders) {\n resHeaders.forEach((header) => {\n const parsedCookies = CookieParser(header);\n Object.keys(parsedCookies).forEach((name) => {\n const { value, attributes } = parsedCookies[name];\n res.cookie(name, value, attributes);\n });\n });\n }\n\n const data = await response.json();\n console.log(\"🚀 ~ app.use ~ data:\", data)\n const { global } = data;\n for (const key in global) {\n if (Object.hasOwnProperty.call(global, key)) {\n env.addGlobal(key, global[key]);\n }\n }\n\n next();\n });\n\n return async (req, res, next) => {\n res.render(\"index.njk\", {\n title: \"Welcome\",\n message: \"Hello from Nunjucks with custom middleware!\",\n cdn: \"https://your-cdn-url.com/\",\n fingerprint: req.fingerprint,\n });\n };\n}\n\nmodule.exports = createNunjucksMiddleware;"],"names":["nunjucks","require$$0","path","require$$1","Fingerprint","require$$2","CookieParser","setCookieHeader","cookies","split","forEach","cookieStr","parts","_parts","_slicedToArray","_nameValue$split2","name","value","trimmedName","trim","trimmedValue","attributes","i","length","_parts$i$split2","attributeName","attributeValue","fs","require$$4","extractLanguageAndPath","result","language","match","concat","app","options","arguments","undefined","viewsDirectory","localesDirectory","join","env","configure","autoescape","express","watch","noCache","defaultFilters","upperCase","str","toUpperCase","reverse","capitalize","charAt","slice","toLowerCase","formatCurrency","amount","parseFloat","toFixed","money","date","Date","toISOString","applyDiscount","price","discountPercent","addVAT","pluralize","quantity","singular","plural","truncate","trimSpaces","isEmpty","slugify","replace","formatNumber","num","toString","assets","getGlobal","cdn","filterName","addFilter","locales","readdirSync","file","endsWith","localeName","basename","require","globalVars","use","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","req","res","next","originalUrl","newPath","wrap","_context","prev","stop","_x","_x2","_x3","apply","this","addGlobal","key","defaultValue","console","log","lang","locale","obj","reduce","acc","part","getNestedValue","parameters","useragent","acceptHeaders","geoip","param1","param2","_ref2","_callee2","protocol","fullUrl","url","headers","config","response","resHeaders","data","global","_context2","get","encodeURIComponent","secretKey","fingerprint","hash","Referer","fetch","sent","getSetCookie","header","parsedCookies","Object","keys","_parsedCookies$name","cookie","json","hasOwnProperty","call","_x4","_x5","_x6","_ref3","_callee3","_context3","render","title","message","_x7","_x8","_x9"],"mappings":"u2PAAA,ICAMA,EAAWC,EACXC,EAAOC,EACPC,EAAcC,EACdC,EDHe,SAACC,GAClB,IAAMC,EAAU,CAAA,EAiChB,OA9BoBD,EAAgBE,MAAM,mBAE9BC,SAAQ,SAAAC,GAChB,IAAMC,EAAQD,EAAUF,MAAM,KAC9BI,EAAAC,EAAoBF,EAAK,GACiBG,EAAAD,EAD1BD,EAAA,GACgBJ,MAAM,KAAI,GAAnCO,EAAID,EAAA,GAAEE,EAAKF,EAAA,GAElB,GAAIC,GAAQC,EAAO,CAEf,IAAMC,EAAcF,EAAKG,OACnBC,EAAeH,EAAME,OAGtBX,EAAQU,KACTV,EAAQU,GAAe,CACnBD,MAAOG,EACPC,WAAY,CAAE,IAKtB,IAAK,IAAIC,EAAI,EAAGA,EAAIV,EAAMW,OAAQD,IAAK,CACnC,IAA2DE,EAAAV,EAAnBF,EAAMU,GAAGb,MAAM,KAAI,GAApDgB,EAAaD,EAAA,GAAEE,EAAcF,EAAA,GAChCC,IACAjB,EAAQU,GAAaG,WAAWI,EAAcN,S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,MAAO,SAAAoE,EAAOlE,EAAKC,EAAKC,GAAI,OAAAL,IAAAQ,MAAA,SAAA8D,GAAA,cAAAA,EAAA5D,KAAA4D,EAAAjE,MAAA,KAAA,EAC1BD,EAAImE,OAAO,YAAa,CACtBC,MAAO,UACPC,QAAS,8CACTvF,IAAK,4BACLgE,YAAa/C,EAAI+C,cAChB,KAAA,EAAA,IAAA,MAAA,OAAAoB,EAAA3D,OAAA,GAAA0D,EACJ,KAAA,OAAA,SAAAK,EAAAC,EAAAC,GAAA,OAAAR,EAAArD,MAAAC,KAAA5E,UAAA,CAAA,CAPD,EAQF"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qumra-engine",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "dist/bundle.js",
|
|
3
|
+
"version": "1.0.12",
|
|
4
|
+
"main": "dist/bundle.cjs.js",
|
|
5
|
+
"module": "dist/bundle.esm.js",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "rollup -c --bundleConfigAsCjs"
|
|
7
9
|
},
|
|
8
10
|
"keywords": [],
|
|
9
11
|
"author": "",
|
|
@@ -11,13 +13,19 @@
|
|
|
11
13
|
"description": "",
|
|
12
14
|
"dependencies": {
|
|
13
15
|
"express-fingerprint": "^1.2.2",
|
|
14
|
-
"nunjucks": "^3.2.4"
|
|
16
|
+
"nunjucks": "^3.2.4",
|
|
17
|
+
"qumra-cli": "^1.1.8"
|
|
15
18
|
},
|
|
16
19
|
"devDependencies": {
|
|
17
20
|
"@babel/core": "^7.25.2",
|
|
18
21
|
"@babel/preset-env": "^7.25.4",
|
|
22
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
23
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
24
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
19
25
|
"babel-loader": "^9.1.3",
|
|
20
26
|
"copy-webpack-plugin": "^12.0.2",
|
|
27
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
28
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
21
29
|
"webpack": "^5.94.0",
|
|
22
30
|
"webpack-cli": "^5.1.4",
|
|
23
31
|
"webpack-node-externals": "^3.0.0"
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import babel from 'rollup-plugin-babel';
|
|
4
|
+
import { terser } from 'rollup-plugin-terser';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
const input = './lib/index.js';
|
|
8
|
+
|
|
9
|
+
export default [
|
|
10
|
+
{
|
|
11
|
+
// Configuration for CommonJS
|
|
12
|
+
input,
|
|
13
|
+
output: {
|
|
14
|
+
file: path.resolve(__dirname, 'dist/bundle.cjs.js'),
|
|
15
|
+
format: 'cjs',
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
},
|
|
18
|
+
external: id => /node_modules/.test(id), // استبعاد المكتبات الخارجية
|
|
19
|
+
plugins: [
|
|
20
|
+
resolve(),
|
|
21
|
+
commonjs(),
|
|
22
|
+
babel({
|
|
23
|
+
exclude: 'node_modules/**',
|
|
24
|
+
presets: ['@babel/preset-env'],
|
|
25
|
+
}),
|
|
26
|
+
terser(), // ضغط الكود للإنتاج
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
// Configuration for ESM
|
|
31
|
+
input,
|
|
32
|
+
output: {
|
|
33
|
+
file: path.resolve(__dirname, 'dist/bundle.esm.js'),
|
|
34
|
+
format: 'esm',
|
|
35
|
+
sourcemap: true,
|
|
36
|
+
},
|
|
37
|
+
external: id => /node_modules/.test(id), // استبعاد المكتبات الخارجية
|
|
38
|
+
plugins: [
|
|
39
|
+
resolve(),
|
|
40
|
+
commonjs(),
|
|
41
|
+
babel({
|
|
42
|
+
exclude: 'node_modules/**',
|
|
43
|
+
presets: ['@babel/preset-env'],
|
|
44
|
+
}),
|
|
45
|
+
terser(), // ضغط الكود للإنتاج
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|