@ynck/rendux 0.92.0 → 0.92.1
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/README.md +1 -1
- package/dist/plugin/i18n.cjs.min.js +1 -1
- package/dist/plugin/i18n.min.js +1 -1
- package/dist/plugin/x-logger.cjs.min.js +1 -1
- package/dist/plugin/x-logger.min.js +1 -1
- package/dist/plugin/x-tooltip.cjs.min.js +1 -1
- package/dist/plugin/x-tooltip.min.js +1 -1
- package/dist/rendux.cjs.min.js +1 -1
- package/dist/rendux.min.js +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! plugin/i18n v0.92.
|
|
1
|
+
/*! plugin/i18n v0.92.1 | Copyright (c) JULY 2025 Yannick J.A. CHARLERY | This software is licensed for non-commercial use only. Commercial licensing available upon request. For license details: https://github.com/ynck-chrl/rendux */
|
|
2
2
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={en:{message:"Welcome to rendux!",button:"Click me",title:"Hello World"},fr:{message:"Bienvenue dans rendux!",button:"Cliquez-moi",title:"Bonjour le Monde"}};const t=function(t={}){const n=t.translations||e;let o=t.defaultLanguage||"en";return{name:"i18n",target:"render",execute:function(e,...t){const r=e.split(".");let s=n[o];for(const t of r){if(!s||"object"!=typeof s||!(t in s))return`[${e}]`;s=s[t]}if("string"==typeof s&&t.length>0){return s.replace(/\{(\d+)\}/g,(e,n)=>{const o=parseInt(n,10);return void 0!==t[o]?t[o]:e})}return s||`[${e}]`},setLanguage:e=>!!n[e]&&(o=e,!0),getLanguage:()=>o,addTranslations(e,t){n[e]||(n[e]={}),Object.assign(n[e],t)}}};exports.i18nPlugin=t;
|
package/dist/plugin/i18n.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! plugin/i18n v0.92.
|
|
1
|
+
/*! plugin/i18n v0.92.1 | Copyright (c) JULY 2025 Yannick J.A. CHARLERY | This software is licensed for non-commercial use only. Commercial licensing available upon request. For license details: https://github.com/ynck-chrl/rendux */
|
|
2
2
|
const e={en:{message:"Welcome to rendux!",button:"Click me",title:"Hello World"},fr:{message:"Bienvenue dans rendux!",button:"Cliquez-moi",title:"Bonjour le Monde"}};const t=function(t={}){const n=t.translations||e;let o=t.defaultLanguage||"en";return{name:"i18n",target:"render",execute:function(e,...t){const r=e.split(".");let s=n[o];for(const t of r){if(!s||"object"!=typeof s||!(t in s))return`[${e}]`;s=s[t]}if("string"==typeof s&&t.length>0){return s.replace(/\{(\d+)\}/g,(e,n)=>{const o=parseInt(n,10);return void 0!==t[o]?t[o]:e})}return s||`[${e}]`},setLanguage:e=>!!n[e]&&(o=e,!0),getLanguage:()=>o,addTranslations(e,t){n[e]||(n[e]={}),Object.assign(n[e],t)}}};export{t as i18nPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! plugin/x-logger v0.92.
|
|
1
|
+
/*! plugin/x-logger v0.92.1 | Copyright (c) JULY 2025 Yannick J.A. CHARLERY | This software is licensed for non-commercial use only. Commercial licensing available upon request. For license details: https://github.com/ynck-chrl/rendux */
|
|
2
2
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={name:"logger",target:"render",execute:function(e,...r){switch(e){case"logMessage":return`[Message: ${r.join(", ")}]`;case"logError":return`[Error: ${r.join(", ")}]`;case"logWarning":return`[Warning: ${r.join(", ")}]`;case"logInfo":return`[Info: ${r.join(", ")}]`;case"logDebug":return`[Debug: ${r.join(", ")}]`;case"logTable":return r.length>0&&(Array.isArray(r[0])||"object"==typeof r[0])?`[Table: ${Array.isArray(r[0])?r[0].length+" items":"object"}]`:`[Table: ${r.join(", ")}]`;default:return`[${e}: ${r.join(", ")}]`}}},r=e;exports.logger=e,exports.loggerPlugin=r;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! plugin/x-logger v0.92.
|
|
1
|
+
/*! plugin/x-logger v0.92.1 | Copyright (c) JULY 2025 Yannick J.A. CHARLERY | This software is licensed for non-commercial use only. Commercial licensing available upon request. For license details: https://github.com/ynck-chrl/rendux */
|
|
2
2
|
const e={name:"logger",target:"render",execute:function(e,...r){switch(e){case"logMessage":return`[Message: ${r.join(", ")}]`;case"logError":return`[Error: ${r.join(", ")}]`;case"logWarning":return`[Warning: ${r.join(", ")}]`;case"logInfo":return`[Info: ${r.join(", ")}]`;case"logDebug":return`[Debug: ${r.join(", ")}]`;case"logTable":return r.length>0&&(Array.isArray(r[0])||"object"==typeof r[0])?`[Table: ${Array.isArray(r[0])?r[0].length+" items":"object"}]`:`[Table: ${r.join(", ")}]`;default:return`[${e}: ${r.join(", ")}]`}}},r=e;export{e as logger,r as loggerPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! plugin/x-tooltip v0.92.
|
|
1
|
+
/*! plugin/x-tooltip v0.92.1 | Copyright (c) JULY 2025 Yannick J.A. CHARLERY | This software is licensed for non-commercial use only. Commercial licensing available upon request. For license details: https://github.com/ynck-chrl/rendux */
|
|
2
2
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={name:"x-tooltip",target:"attribute",execute:function(e,t,o){e._xTooltipElement&&e._xTooltipElement.remove();const n=document.createElement("div");n.textContent=t,n.style.cssText="\n position: absolute;\n background: #333;\n color: white;\n padding: 8px 12px;\n border-radius: 4px;\n font-size: 12px;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.2s;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n ",document.body.appendChild(n),e._xTooltipElement=n;const i=function(t){const o=e.getBoundingClientRect(),i=window.pageXOffset||document.documentElement.scrollLeft,s=window.pageYOffset||document.documentElement.scrollTop,l=i+o.left+(o.width-n.offsetWidth)/2,p=s+o.top-n.offsetHeight-8;n.style.left=`${l}px`,n.style.top=`${p}px`,n.style.opacity="1"},s=function(){n.style.opacity="0"};if(e._xTooltipListeners&&(e.removeEventListener("mouseenter",e._xTooltipListeners.show),e.removeEventListener("mouseleave",e._xTooltipListeners.hide)),e.addEventListener("mouseenter",i),e.addEventListener("mouseleave",s),e._xTooltipListeners={show:i,hide:s},!e._xTooltipCleanup){e._xTooltipCleanup=!0;const t=new MutationObserver(o=>{o.forEach(o=>{o.removedNodes.forEach(o=>{(o===e||o.contains&&o.contains(e))&&(e._xTooltipElement&&e._xTooltipElement.remove(),t.disconnect())})})});t.observe(document.body,{childList:!0,subtree:!0})}}};exports.xTooltip=e;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! plugin/x-tooltip v0.92.
|
|
1
|
+
/*! plugin/x-tooltip v0.92.1 | Copyright (c) JULY 2025 Yannick J.A. CHARLERY | This software is licensed for non-commercial use only. Commercial licensing available upon request. For license details: https://github.com/ynck-chrl/rendux */
|
|
2
2
|
const e={name:"x-tooltip",target:"attribute",execute:function(e,t,o){e._xTooltipElement&&e._xTooltipElement.remove();const n=document.createElement("div");n.textContent=t,n.style.cssText="\n position: absolute;\n background: #333;\n color: white;\n padding: 8px 12px;\n border-radius: 4px;\n font-size: 12px;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.2s;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n ",document.body.appendChild(n),e._xTooltipElement=n;const i=function(t){const o=e.getBoundingClientRect(),i=window.pageXOffset||document.documentElement.scrollLeft,s=window.pageYOffset||document.documentElement.scrollTop,l=i+o.left+(o.width-n.offsetWidth)/2,p=s+o.top-n.offsetHeight-8;n.style.left=`${l}px`,n.style.top=`${p}px`,n.style.opacity="1"},s=function(){n.style.opacity="0"};if(e._xTooltipListeners&&(e.removeEventListener("mouseenter",e._xTooltipListeners.show),e.removeEventListener("mouseleave",e._xTooltipListeners.hide)),e.addEventListener("mouseenter",i),e.addEventListener("mouseleave",s),e._xTooltipListeners={show:i,hide:s},!e._xTooltipCleanup){e._xTooltipCleanup=!0;const t=new MutationObserver(o=>{o.forEach(o=>{o.removedNodes.forEach(o=>{(o===e||o.contains&&o.contains(e))&&(e._xTooltipElement&&e._xTooltipElement.remove(),t.disconnect())})})});t.observe(document.body,{childList:!0,subtree:!0})}}};export{e as xTooltip};
|
package/dist/rendux.cjs.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! rendux v0.92.
|
|
1
|
+
/*! rendux v0.92.1 | Copyright (c) JULY 2025 Yannick J.A. CHARLERY | This software is licensed for non-commercial use only. Commercial licensing available upon request. For license details: https://github.com/ynck-chrl/rendux */
|
|
2
2
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={Math:Math,Date:Date,Number:Number,String:String,Boolean:Boolean,JSON:JSON,parseInt:parseInt,parseFloat:parseFloat,isFinite:isFinite,Array:Array};function t(t,r={}){const n=function(e){const t=[];let r=0;for(;r<e.length;){let n=e[r];if(/\s/.test(n)){r++;continue}if('"'===n||"'"===n){const o=n;let s="";for(r++;r<e.length&&e[r]!==o;)"\\"===e[r]?(r++,r<e.length&&(s+=e[r++])):s+=e[r++];r++,t.push({type:"string",value:s});continue}if(/[0-9]/.test(n)||"."===n&&/[0-9]/.test(e[r+1])){let n=r;for(;r<e.length&&/[0-9]/.test(e[r]);)r++;if("."===e[r])for(r++;r<e.length&&/[0-9]/.test(e[r]);)r++;const o=parseFloat(e.slice(n,r));t.push({type:"number",value:o});continue}if(/[a-zA-Z_$]/.test(n)){let n=r;for(r++;r<e.length&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;const o=e.slice(n,r);"true"===o||"false"===o?t.push({type:"boolean",value:"true"===o}):"null"===o?t.push({type:"null",value:null}):t.push({type:"identifier",value:o});continue}const o=e.substr(r,2),s=e.substr(r,3);if(["===","!=="].includes(s))t.push({type:"operator",value:s}),r+=3;else if(["==","!=",">=","<=","&&","||"].includes(o))t.push({type:"operator",value:o}),r+=2;else{if(!["+","-","*","/","%",">","<","!","?",":","(",")","[","]",".",","].includes(n))throw new Error(`Invalid character '${n}' in expression`);t.push({type:"operator",value:n}),r++}}return t.push({type:"EOF"}),t}(t);let o=0;function s(){return n[o]||{type:"EOF"}}function a(){return n[o++]||{type:"EOF"}}function i(e,t){const r=s();if(r.type!==e||void 0!==t&&r.value!==t)throw new Error(`Expected ${t||e} but got ${r.value}`);return a(),r}function l(e){const t=s();return"operator"===t.type&&t.value===e}const c=u();if("EOF"!==s().type)throw new Error(`Unexpected token: ${s().value}`);return c;function u(){let e=function(){let e=f();for(;l("||");){a();const t=f();e=e||t}return e}();if(l("?")){a();const t=u();i("operator",":");const r=u();e=e?t:r}return e}function f(){let e=p();for(;l("&&");){a();const t=p();e=e&&t}return e}function p(){let e=d();for(;["==","!=","===","!=="].includes(s().value);){const t=a().value,r=d();switch(t){case"==":e=e==r;break;case"!=":e=e!=r;break;case"===":e=e===r;break;case"!==":e=e!==r}}return e}function d(){let e=h();for(;[">","<",">=","<="].includes(s().value);){const t=a().value,r=h();switch(t){case">":e=e>r;break;case"<":e=e<r;break;case">=":e=e>=r;break;case"<=":e=e<=r}}return e}function h(){let e=x();for(;["+","-"].includes(s().value);){const t=a().value,r=x();e="+"===t?e+r:e-r}return e}function x(){let e=g();for(;["*","/","%"].includes(s().value);){const t=a().value,r=g();switch(t){case"*":e*=r;break;case"/":e/=r;break;case"%":e%=r}}return e}function g(){if(["!","+","-"].includes(s().value)){const e=a().value,t=g();switch(e){case"!":return!t;case"+":return+t;case"-":return-t}}return function(){const t=s();if("number"===t.type||"string"===t.type||"boolean"===t.type||"null"===t.type)return a(),t.value;if("identifier"===t.type){a();let n=function(t){if(t in r)return r[t];if(t in e)return e[t];if(null!=r.this&&t in r.this)return r.this[t];throw new Error(`Unknown identifier: ${t}`)}(t.value);for(;;)if(l(".")){a();const e=i("identifier").value;n=null==n?void 0:n[e]}else if(l("[")){a();const e=u();i("operator","]"),n=null==n?void 0:n[e]}else{if(!l("("))break;{a();const e=[];if(!l(")"))do{e.push(u())}while(l(",")&&a());if(i("operator",")"),"function"!=typeof n)throw new Error(`'${t.value}' is not a function`);n=n.apply(r.this,e)}}return n}if(l("(")){a();const e=u();return i("operator",")"),e}throw new Error(`Unexpected token: ${t.value}`)}()}}const r=new Map;function n(e){if(!e||!e.name)throw new Error("Invalid plugin");r.set(e.name,e)}function o(e,t={}){const n=e.match(/^([a-zA-Z_$][\w$]*)\s*\(\s*(.*)\s*\)$/);if(!n)return null;const o=n[1],s=r.get(o);if(!s)return null;const a=n[2].trim();if(""===a)return{plugin:s,args:[]};return{plugin:s,args:a.split(/\s*,\s*/).map(e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(/^-?\d+(?:\.\d+)?$/.test(e))return parseFloat(e);if(e in t)return t[e];throw new Error(`Unknown identifier: ${e}`)})}}async function s(e=document,t={}){const n=Array.from(e.querySelectorAll("*")).filter(e=>Array.from(e.attributes).some(e=>e.name.startsWith("render.")));for(const e of n)for(const n of Array.from(e.attributes)){if(!n.name.startsWith("render."))continue;const s=n.name,a=n.value.trim();let i,l,c;if("render.plugin"===s){let e;try{e=o(a,t)}catch(e){console.error(e);continue}if(!e)continue;i=e.plugin,l=e.args}else{const e=s.slice(7);if(i=r.get(e),!i)continue;if(a.startsWith(e+"(")){let e;try{e=o(a,t)}catch(e){console.error(e);continue}if(!e)continue;i=e.plugin,l=e.args}else l=[a]}"function"==typeof i.onBeforeExecute&&i.onBeforeExecute(e,a,t);try{c=i.execute(...l)}catch(e){continue}e.textContent=null==c?"":String(c),"function"==typeof i.onAfterExecute&&i.onAfterExecute(e,a,t)}for(const n of r.values())"function"==typeof n.onAfterRender&&await n.onAfterRender(e,t)}function rendux(e=this.shadowRoot||this){const n=this;for(const t of r.values())"function"==typeof t.onBeforeRender&&t.onBeforeRender(e,n);const o=document,a=n.getAttribute("logs"),i=Boolean(a),l=a?new Set(a.split(",").map(e=>e.trim().toLowerCase())):new Set,c=e=>l.has("all")||l.has(e.toLowerCase())||l.has(("x-"+e).toLowerCase()),u=i&&l.has("plugins"),f=(...e)=>console.warn(...e);n._xRenderCache||(n._xRenderCache=new Map),n._xRenderOriginalText||(n._xRenderOriginalText=new WeakMap),n._xIfData||(n._xIfData=new WeakMap),n._cloneContext||(n._cloneContext=new WeakMap),n._xClassCache||(n._xClassCache=new Map),n._xForCache||(n._xForCache=new WeakMap),n.__mirrorContainer||(n.__mirrorContainer=o.createDocumentFragment());const p={};function d(e){let t=e;for(;t;){const e=n._cloneContext.get(t);if(e)return n.getAttribute("logs")&&n.getAttribute("logs").includes("plugins")&&console.log("Found context for element:",t,e),e;t=t.parentNode}return n.getAttribute("logs")&&n.getAttribute("logs").includes("plugins")&&console.log("Using default component context:",n),n}function h(e,r){if(!e)return!0;const n=d(r);try{return t(e,{this:n,...p})}catch(t){return void f(`[evaluate] "${e}" failed in`,n,t)}}Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach(e=>{"function"==typeof n[e]&&"constructor"!==e&&(p[e]=n[e].bind(n))}),p.plugins=r;const x=i&&c("for");x&&console.groupCollapsed("x-for");Array.from(e.querySelectorAll("template[x-for]")).concat(Array.from(n.__mirrorContainer.querySelectorAll("template[x-for]"))).forEach(e=>{let t,r,s;e._xForMeta||(e._xForMeta={parent:e.parentNode,next:e.nextSibling},n.__mirrorContainer.appendChild(e));try{({loopVar:t,indexVar:r,arrayPath:s}=function(e){const t=e.match(/^\s*(?:\(\s*([^,\s]+)\s*,\s*([^,\s]+)\s*\)|([^,\s()]+))\s+(?:in|of)\s+(.+)$/);if(!t)throw new Error("Invalid x-for: "+e);return{loopVar:t[1]||t[3],indexVar:t[2]||null,arrayPath:t[4].trim()}}(e.getAttribute("x-for")))}catch(e){return void f("[x-for]",e.message)}const a=function(e,t){const r=d(t),n=e.match(/([^[.\]]+)|\[(\d+)\]/g);if(n)return n.reduce((e,t)=>{if(null!=e){if(t.startsWith("[")){const r=parseInt(t.slice(1,-1),10);return Array.isArray(e)?e[r]:void 0}return e[t]}},r)}(s,e);if(!Array.isArray(a))return void f(`[x-for] expected array at ${s}`,a);x&&console.log(`iterating ${s} → length ${a.length}`);const i=function(e){return JSON.stringify(e)}(a),l=n._xForCache.get(e);l&&l.arrayRef===a&&l.length===a.length&&l.signature===i?x&&console.log(" → skipped (no change)"):(n._xForCache.set(e,{arrayRef:a,length:a.length,signature:i}),e._forClones&&e._forClones.forEach(e=>e.remove()),e._forClones=[],a.forEach((s,a)=>{x&&console.groupCollapsed(` index ${a}`);const i=o.createDocumentFragment();i.appendChild(e.content.cloneNode(!0));const l=(c=t,u=s,f=r,p=a,new Proxy(n,{has:(e,t)=>t===c||f&&t===f||t in e,get:(e,t)=>t===c?u:f&&t===f?p:e[t]}));var c,u,f,p,d,h;d=i,h=l,n._cloneContext.set(d,h),d.querySelectorAll("*").forEach(e=>n._cloneContext.set(e,h));const g=n._xRenderCache,y=n._xRenderOriginalText;for(n._xRenderCache=new Map,n._xRenderOriginalText=new WeakMap,rendux.call(n,i),n._xRenderCache=g,n._xRenderOriginalText=y;i.firstChild;){const t=i.firstChild;e._xForMeta.parent.insertBefore(t,e._xForMeta.next),e._forClones.push(t)}x&&console.groupEnd()}))}),x&&console.groupEnd();const g=i&&c("if");Array.from(e.querySelectorAll("[x-if]")).concat(Array.from(n.__mirrorContainer.querySelectorAll("[x-if]"))).forEach(e=>{const t=e.getAttribute("x-if")?.trim(),r=!t||h(t,e);g&&console.groupCollapsed("x-if",e,t,"→",r);let s=n._xIfData.get(e);s||(s={placeholder:o.createComment("x-if placeholder"),isHidden:!1},n._xIfData.set(e,s)),r||s.isHidden?r&&s.isHidden&&(s.placeholder.parentNode.replaceChild(e,s.placeholder),s.isHidden=!1):(e.parentNode.replaceChild(s.placeholder,e),n.__mirrorContainer.appendChild(e),s.isHidden=!0),g&&console.groupEnd()}),0===n._xRenderCache.size&&Array.from(e.querySelectorAll("[render]")).forEach(e=>{const t=e.getAttribute("render")?.trim();t&&(n._xRenderCache.set(e,t),n._xRenderOriginalText.set(e,e.textContent))}),Array.from(e.querySelectorAll("[x-class]")).forEach(e=>{const t=e.getAttribute("x-class");null==t||n._xClassCache.has(e)||n._xClassCache.set(e,t)});const y=i&&c("attr");Array.from(e.querySelectorAll("*")).forEach(e=>{Array.from(e.attributes).forEach(t=>{if(t.name.startsWith("x-")&&!["x-for","x-key","x-class","x-if","x-hidden"].includes(t.name)){const o=t.name,s=r.get(o);if(s&&"attribute"===s.target){const r=h(t.value.trim(),e);try{u&&console.log("[plugin]",`Executing ${o} with:`,{element:e,value:r,component:n}),s.execute(e,r,n)}catch(e){u&&console.error("[plugin]",`Error executing ${o}:`,e)}}else{const r=t.name.slice(2),n=h(t.value.trim(),e);y&&console.groupCollapsed("x-attr",e,r,"=",n),n?e.setAttribute(r,String(n)):e.removeAttribute(r),y&&console.groupEnd()}}})});const m=i&&c("class");m&&console.groupCollapsed("x-class");for(const[e,t]of n._xClassCache){m&&console.log("element →",e);const r=t.trim();if(r.includes("(")){const t=/\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)/g;n._xClassDynamicValues||(n._xClassDynamicValues=new Map);(n._xClassDynamicValues.get(e)||[]).forEach(t=>e.classList.remove(t));const o=new Set;let s;for(;s=t.exec(r);){const t=s[1].trim(),r=s[2].trim();let n;n=/^[\w\-\s]+$/.test(t)?t:h(t,e);const a=Boolean(h(r,e));let i=[];"string"==typeof n?i=n.split(/\s+/).filter(Boolean):Array.isArray(n)?i=n:n&&"object"==typeof n&&(i=Object.keys(n).filter(e=>n[e])),a&&i.forEach(t=>e.classList.add(t)),i.forEach(e=>o.add(e)),m&&console.log(` ${t} → [${i.join(" ")}] (= ${a})`)}n._xClassDynamicValues.set(e,Array.from(o))}else{n._xClassDynamicValues||(n._xClassDynamicValues=new Map);let t;(n._xClassDynamicValues.get(e)||[]).forEach(t=>e.classList.remove(t));let o=!0;if(!r.includes(",")&&/[?:]/.test(r))t=h(r,e);else{const n=r.indexOf(","),s=n>=0?r.slice(0,n).trim():r,a=n>=0?r.slice(n+1).trim():"true";o=Boolean(h(a,e)),t=s}const s=[];"string"==typeof t?s.push(...t.split(/\s+/).filter(Boolean)):Array.isArray(t)?s.push(...t):t&&"object"==typeof t&&s.push(...Object.keys(t).filter(e=>t[e])),s.forEach(t=>{o?e.classList.add(t):e.classList.remove(t)}),m&&console.log(` x-class ${r} →`,s,`ok=${o}`),n._xClassDynamicValues.set(e,s)}}m&&console.groupEnd();const _=i&&c("render");_&&console.groupCollapsed("render");for(const[e,t]of n._xRenderCache){const r=n._xIfData.get(e);if(r&&r.isHidden)continue;_&&console.log("element →",e,"expr=",t);const o=t.indexOf(","),s=o<0?t:t.slice(0,o).trim(),a=h(o<0?"true":t.slice(o+1).trim(),e);let i;if(a){let t=h(s,e);if(void 0===t)i=n._xRenderOriginalText.get(e)||"";else if(null!=t&&"object"==typeof t)try{i=JSON.stringify(t,null,2)}catch{i=String(t)}else i=null==t||"boolean"==typeof t?"":String(t)}else i=n._xRenderOriginalText.get(e)||"";e.textContent!==i&&(e.textContent=i),_&&console.log(` → "${i}" (cond=${a})`)}_&&console.groupEnd(),Array.from(e.querySelectorAll("*")).forEach(e=>{const t=n._xIfData.get(e);t&&t.isHidden||[["render","render"]].forEach(([t,r])=>{e.hasAttribute(t)&&!c(r)&&e.removeAttribute(t)})}),function e(r){Array.from(r.querySelectorAll("*")).forEach(e=>{Array.from(e.attributes).forEach(r=>{if(r.name.startsWith("@")){const o=r.name.slice(1),s=r.value.trim();e._xEventListeners&&e._xEventListeners[o]&&e.removeEventListener(o,e._xEventListeners[o]),e._xEventListeners||(e._xEventListeners={});const a=d(e),i=new Proxy(a,{get:(e,t)=>t in e?e[t]:n[t]}),l=function(e){try{return t(s,{this:i,event:e,...p})}catch(e){f(`[rendux @${o}] Error evaluating: ${s}`,e)}};e.addEventListener(o,l),e._xEventListeners[o]=l}})}),Array.from(r.querySelectorAll("slot")).forEach(t=>{(t.assignedElements?t.assignedElements({flatten:!0}):[]).forEach(t=>{e(t)})})}(e),s(e,n)}rendux.use=function(e){return n(e),rendux},"undefined"!=typeof module&&module.exports&&(module.exports={rendux:rendux,use:n,process:s,plugins:r,parsePluginCall:o}),exports.parsePluginCall=o,exports.plugins=r,exports.process=s,exports.rendux=rendux,exports.use=n;
|
package/dist/rendux.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! rendux v0.92.
|
|
1
|
+
/*! rendux v0.92.1 | Copyright (c) JULY 2025 Yannick J.A. CHARLERY | This software is licensed for non-commercial use only. Commercial licensing available upon request. For license details: https://github.com/ynck-chrl/rendux */
|
|
2
2
|
const e={Math:Math,Date:Date,Number:Number,String:String,Boolean:Boolean,JSON:JSON,parseInt:parseInt,parseFloat:parseFloat,isFinite:isFinite,Array:Array};function t(t,r={}){const n=function(e){const t=[];let r=0;for(;r<e.length;){let n=e[r];if(/\s/.test(n)){r++;continue}if('"'===n||"'"===n){const o=n;let s="";for(r++;r<e.length&&e[r]!==o;)"\\"===e[r]?(r++,r<e.length&&(s+=e[r++])):s+=e[r++];r++,t.push({type:"string",value:s});continue}if(/[0-9]/.test(n)||"."===n&&/[0-9]/.test(e[r+1])){let n=r;for(;r<e.length&&/[0-9]/.test(e[r]);)r++;if("."===e[r])for(r++;r<e.length&&/[0-9]/.test(e[r]);)r++;const o=parseFloat(e.slice(n,r));t.push({type:"number",value:o});continue}if(/[a-zA-Z_$]/.test(n)){let n=r;for(r++;r<e.length&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;const o=e.slice(n,r);"true"===o||"false"===o?t.push({type:"boolean",value:"true"===o}):"null"===o?t.push({type:"null",value:null}):t.push({type:"identifier",value:o});continue}const o=e.substr(r,2),s=e.substr(r,3);if(["===","!=="].includes(s))t.push({type:"operator",value:s}),r+=3;else if(["==","!=",">=","<=","&&","||"].includes(o))t.push({type:"operator",value:o}),r+=2;else{if(!["+","-","*","/","%",">","<","!","?",":","(",")","[","]",".",","].includes(n))throw new Error(`Invalid character '${n}' in expression`);t.push({type:"operator",value:n}),r++}}return t.push({type:"EOF"}),t}(t);let o=0;function s(){return n[o]||{type:"EOF"}}function a(){return n[o++]||{type:"EOF"}}function i(e,t){const r=s();if(r.type!==e||void 0!==t&&r.value!==t)throw new Error(`Expected ${t||e} but got ${r.value}`);return a(),r}function l(e){const t=s();return"operator"===t.type&&t.value===e}const c=u();if("EOF"!==s().type)throw new Error(`Unexpected token: ${s().value}`);return c;function u(){let e=function(){let e=f();for(;l("||");){a();const t=f();e=e||t}return e}();if(l("?")){a();const t=u();i("operator",":");const r=u();e=e?t:r}return e}function f(){let e=p();for(;l("&&");){a();const t=p();e=e&&t}return e}function p(){let e=d();for(;["==","!=","===","!=="].includes(s().value);){const t=a().value,r=d();switch(t){case"==":e=e==r;break;case"!=":e=e!=r;break;case"===":e=e===r;break;case"!==":e=e!==r}}return e}function d(){let e=h();for(;[">","<",">=","<="].includes(s().value);){const t=a().value,r=h();switch(t){case">":e=e>r;break;case"<":e=e<r;break;case">=":e=e>=r;break;case"<=":e=e<=r}}return e}function h(){let e=x();for(;["+","-"].includes(s().value);){const t=a().value,r=x();e="+"===t?e+r:e-r}return e}function x(){let e=g();for(;["*","/","%"].includes(s().value);){const t=a().value,r=g();switch(t){case"*":e*=r;break;case"/":e/=r;break;case"%":e%=r}}return e}function g(){if(["!","+","-"].includes(s().value)){const e=a().value,t=g();switch(e){case"!":return!t;case"+":return+t;case"-":return-t}}return function(){const t=s();if("number"===t.type||"string"===t.type||"boolean"===t.type||"null"===t.type)return a(),t.value;if("identifier"===t.type){a();let n=function(t){if(t in r)return r[t];if(t in e)return e[t];if(null!=r.this&&t in r.this)return r.this[t];throw new Error(`Unknown identifier: ${t}`)}(t.value);for(;;)if(l(".")){a();const e=i("identifier").value;n=null==n?void 0:n[e]}else if(l("[")){a();const e=u();i("operator","]"),n=null==n?void 0:n[e]}else{if(!l("("))break;{a();const e=[];if(!l(")"))do{e.push(u())}while(l(",")&&a());if(i("operator",")"),"function"!=typeof n)throw new Error(`'${t.value}' is not a function`);n=n.apply(r.this,e)}}return n}if(l("(")){a();const e=u();return i("operator",")"),e}throw new Error(`Unexpected token: ${t.value}`)}()}}const r=new Map;function n(e){if(!e||!e.name)throw new Error("Invalid plugin");r.set(e.name,e)}function o(e,t={}){const n=e.match(/^([a-zA-Z_$][\w$]*)\s*\(\s*(.*)\s*\)$/);if(!n)return null;const o=n[1],s=r.get(o);if(!s)return null;const a=n[2].trim();if(""===a)return{plugin:s,args:[]};return{plugin:s,args:a.split(/\s*,\s*/).map(e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(/^-?\d+(?:\.\d+)?$/.test(e))return parseFloat(e);if(e in t)return t[e];throw new Error(`Unknown identifier: ${e}`)})}}async function s(e=document,t={}){const n=Array.from(e.querySelectorAll("*")).filter(e=>Array.from(e.attributes).some(e=>e.name.startsWith("render.")));for(const e of n)for(const n of Array.from(e.attributes)){if(!n.name.startsWith("render."))continue;const s=n.name,a=n.value.trim();let i,l,c;if("render.plugin"===s){let e;try{e=o(a,t)}catch(e){console.error(e);continue}if(!e)continue;i=e.plugin,l=e.args}else{const e=s.slice(7);if(i=r.get(e),!i)continue;if(a.startsWith(e+"(")){let e;try{e=o(a,t)}catch(e){console.error(e);continue}if(!e)continue;i=e.plugin,l=e.args}else l=[a]}"function"==typeof i.onBeforeExecute&&i.onBeforeExecute(e,a,t);try{c=i.execute(...l)}catch(e){continue}e.textContent=null==c?"":String(c),"function"==typeof i.onAfterExecute&&i.onAfterExecute(e,a,t)}for(const n of r.values())"function"==typeof n.onAfterRender&&await n.onAfterRender(e,t)}function rendux(e=this.shadowRoot||this){const n=this;for(const t of r.values())"function"==typeof t.onBeforeRender&&t.onBeforeRender(e,n);const o=document,a=n.getAttribute("logs"),i=Boolean(a),l=a?new Set(a.split(",").map(e=>e.trim().toLowerCase())):new Set,c=e=>l.has("all")||l.has(e.toLowerCase())||l.has(("x-"+e).toLowerCase()),u=i&&l.has("plugins"),f=(...e)=>console.warn(...e);n._xRenderCache||(n._xRenderCache=new Map),n._xRenderOriginalText||(n._xRenderOriginalText=new WeakMap),n._xIfData||(n._xIfData=new WeakMap),n._cloneContext||(n._cloneContext=new WeakMap),n._xClassCache||(n._xClassCache=new Map),n._xForCache||(n._xForCache=new WeakMap),n.__mirrorContainer||(n.__mirrorContainer=o.createDocumentFragment());const p={};function d(e){let t=e;for(;t;){const e=n._cloneContext.get(t);if(e)return n.getAttribute("logs")&&n.getAttribute("logs").includes("plugins")&&console.log("Found context for element:",t,e),e;t=t.parentNode}return n.getAttribute("logs")&&n.getAttribute("logs").includes("plugins")&&console.log("Using default component context:",n),n}function h(e,r){if(!e)return!0;const n=d(r);try{return t(e,{this:n,...p})}catch(t){return void f(`[evaluate] "${e}" failed in`,n,t)}}Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach(e=>{"function"==typeof n[e]&&"constructor"!==e&&(p[e]=n[e].bind(n))}),p.plugins=r;const x=i&&c("for");x&&console.groupCollapsed("x-for");Array.from(e.querySelectorAll("template[x-for]")).concat(Array.from(n.__mirrorContainer.querySelectorAll("template[x-for]"))).forEach(e=>{let t,r,s;e._xForMeta||(e._xForMeta={parent:e.parentNode,next:e.nextSibling},n.__mirrorContainer.appendChild(e));try{({loopVar:t,indexVar:r,arrayPath:s}=function(e){const t=e.match(/^\s*(?:\(\s*([^,\s]+)\s*,\s*([^,\s]+)\s*\)|([^,\s()]+))\s+(?:in|of)\s+(.+)$/);if(!t)throw new Error("Invalid x-for: "+e);return{loopVar:t[1]||t[3],indexVar:t[2]||null,arrayPath:t[4].trim()}}(e.getAttribute("x-for")))}catch(e){return void f("[x-for]",e.message)}const a=function(e,t){const r=d(t),n=e.match(/([^[.\]]+)|\[(\d+)\]/g);if(n)return n.reduce((e,t)=>{if(null!=e){if(t.startsWith("[")){const r=parseInt(t.slice(1,-1),10);return Array.isArray(e)?e[r]:void 0}return e[t]}},r)}(s,e);if(!Array.isArray(a))return void f(`[x-for] expected array at ${s}`,a);x&&console.log(`iterating ${s} → length ${a.length}`);const i=function(e){return JSON.stringify(e)}(a),l=n._xForCache.get(e);l&&l.arrayRef===a&&l.length===a.length&&l.signature===i?x&&console.log(" → skipped (no change)"):(n._xForCache.set(e,{arrayRef:a,length:a.length,signature:i}),e._forClones&&e._forClones.forEach(e=>e.remove()),e._forClones=[],a.forEach((s,a)=>{x&&console.groupCollapsed(` index ${a}`);const i=o.createDocumentFragment();i.appendChild(e.content.cloneNode(!0));const l=(c=t,u=s,f=r,p=a,new Proxy(n,{has:(e,t)=>t===c||f&&t===f||t in e,get:(e,t)=>t===c?u:f&&t===f?p:e[t]}));var c,u,f,p,d,h;d=i,h=l,n._cloneContext.set(d,h),d.querySelectorAll("*").forEach(e=>n._cloneContext.set(e,h));const g=n._xRenderCache,y=n._xRenderOriginalText;for(n._xRenderCache=new Map,n._xRenderOriginalText=new WeakMap,rendux.call(n,i),n._xRenderCache=g,n._xRenderOriginalText=y;i.firstChild;){const t=i.firstChild;e._xForMeta.parent.insertBefore(t,e._xForMeta.next),e._forClones.push(t)}x&&console.groupEnd()}))}),x&&console.groupEnd();const g=i&&c("if");Array.from(e.querySelectorAll("[x-if]")).concat(Array.from(n.__mirrorContainer.querySelectorAll("[x-if]"))).forEach(e=>{const t=e.getAttribute("x-if")?.trim(),r=!t||h(t,e);g&&console.groupCollapsed("x-if",e,t,"→",r);let s=n._xIfData.get(e);s||(s={placeholder:o.createComment("x-if placeholder"),isHidden:!1},n._xIfData.set(e,s)),r||s.isHidden?r&&s.isHidden&&(s.placeholder.parentNode.replaceChild(e,s.placeholder),s.isHidden=!1):(e.parentNode.replaceChild(s.placeholder,e),n.__mirrorContainer.appendChild(e),s.isHidden=!0),g&&console.groupEnd()}),0===n._xRenderCache.size&&Array.from(e.querySelectorAll("[render]")).forEach(e=>{const t=e.getAttribute("render")?.trim();t&&(n._xRenderCache.set(e,t),n._xRenderOriginalText.set(e,e.textContent))}),Array.from(e.querySelectorAll("[x-class]")).forEach(e=>{const t=e.getAttribute("x-class");null==t||n._xClassCache.has(e)||n._xClassCache.set(e,t)});const y=i&&c("attr");Array.from(e.querySelectorAll("*")).forEach(e=>{Array.from(e.attributes).forEach(t=>{if(t.name.startsWith("x-")&&!["x-for","x-key","x-class","x-if","x-hidden"].includes(t.name)){const o=t.name,s=r.get(o);if(s&&"attribute"===s.target){const r=h(t.value.trim(),e);try{u&&console.log("[plugin]",`Executing ${o} with:`,{element:e,value:r,component:n}),s.execute(e,r,n)}catch(e){u&&console.error("[plugin]",`Error executing ${o}:`,e)}}else{const r=t.name.slice(2),n=h(t.value.trim(),e);y&&console.groupCollapsed("x-attr",e,r,"=",n),n?e.setAttribute(r,String(n)):e.removeAttribute(r),y&&console.groupEnd()}}})});const m=i&&c("class");m&&console.groupCollapsed("x-class");for(const[e,t]of n._xClassCache){m&&console.log("element →",e);const r=t.trim();if(r.includes("(")){const t=/\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)/g;n._xClassDynamicValues||(n._xClassDynamicValues=new Map);(n._xClassDynamicValues.get(e)||[]).forEach(t=>e.classList.remove(t));const o=new Set;let s;for(;s=t.exec(r);){const t=s[1].trim(),r=s[2].trim();let n;n=/^[\w\-\s]+$/.test(t)?t:h(t,e);const a=Boolean(h(r,e));let i=[];"string"==typeof n?i=n.split(/\s+/).filter(Boolean):Array.isArray(n)?i=n:n&&"object"==typeof n&&(i=Object.keys(n).filter(e=>n[e])),a&&i.forEach(t=>e.classList.add(t)),i.forEach(e=>o.add(e)),m&&console.log(` ${t} → [${i.join(" ")}] (= ${a})`)}n._xClassDynamicValues.set(e,Array.from(o))}else{n._xClassDynamicValues||(n._xClassDynamicValues=new Map);let t;(n._xClassDynamicValues.get(e)||[]).forEach(t=>e.classList.remove(t));let o=!0;if(!r.includes(",")&&/[?:]/.test(r))t=h(r,e);else{const n=r.indexOf(","),s=n>=0?r.slice(0,n).trim():r,a=n>=0?r.slice(n+1).trim():"true";o=Boolean(h(a,e)),t=s}const s=[];"string"==typeof t?s.push(...t.split(/\s+/).filter(Boolean)):Array.isArray(t)?s.push(...t):t&&"object"==typeof t&&s.push(...Object.keys(t).filter(e=>t[e])),s.forEach(t=>{o?e.classList.add(t):e.classList.remove(t)}),m&&console.log(` x-class ${r} →`,s,`ok=${o}`),n._xClassDynamicValues.set(e,s)}}m&&console.groupEnd();const _=i&&c("render");_&&console.groupCollapsed("render");for(const[e,t]of n._xRenderCache){const r=n._xIfData.get(e);if(r&&r.isHidden)continue;_&&console.log("element →",e,"expr=",t);const o=t.indexOf(","),s=o<0?t:t.slice(0,o).trim(),a=h(o<0?"true":t.slice(o+1).trim(),e);let i;if(a){let t=h(s,e);if(void 0===t)i=n._xRenderOriginalText.get(e)||"";else if(null!=t&&"object"==typeof t)try{i=JSON.stringify(t,null,2)}catch{i=String(t)}else i=null==t||"boolean"==typeof t?"":String(t)}else i=n._xRenderOriginalText.get(e)||"";e.textContent!==i&&(e.textContent=i),_&&console.log(` → "${i}" (cond=${a})`)}_&&console.groupEnd(),Array.from(e.querySelectorAll("*")).forEach(e=>{const t=n._xIfData.get(e);t&&t.isHidden||[["render","render"]].forEach(([t,r])=>{e.hasAttribute(t)&&!c(r)&&e.removeAttribute(t)})}),function e(r){Array.from(r.querySelectorAll("*")).forEach(e=>{Array.from(e.attributes).forEach(r=>{if(r.name.startsWith("@")){const o=r.name.slice(1),s=r.value.trim();e._xEventListeners&&e._xEventListeners[o]&&e.removeEventListener(o,e._xEventListeners[o]),e._xEventListeners||(e._xEventListeners={});const a=d(e),i=new Proxy(a,{get:(e,t)=>t in e?e[t]:n[t]}),l=function(e){try{return t(s,{this:i,event:e,...p})}catch(e){f(`[rendux @${o}] Error evaluating: ${s}`,e)}};e.addEventListener(o,l),e._xEventListeners[o]=l}})}),Array.from(r.querySelectorAll("slot")).forEach(t=>{(t.assignedElements?t.assignedElements({flatten:!0}):[]).forEach(t=>{e(t)})})}(e),s(e,n)}rendux.use=function(e){return n(e),rendux},"undefined"!=typeof module&&module.exports&&(module.exports={rendux:rendux,use:n,process:s,plugins:r,parsePluginCall:o});export{o as parsePluginCall,r as plugins,s as process,rendux,n as use};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ynck/rendux",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/rendux.cjs.min.js",
|
|
6
6
|
"module": "./dist/rendux.min.js",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"require": "./dist/plugin/i18n.cjs.min.js"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"description": "A lightweight dependency-free templating and rendering library for HTML and Web Components",
|
|
22
21
|
"author": "Yannick J.A. CHARLERY",
|
|
23
22
|
"repository": {
|
|
24
23
|
"type": "git",
|