@meonode/ui 1.0.0 → 1.0.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.1] - 2025-11-30
6
+
7
+ ### Fix
8
+
9
+ - **core**: fix style prop extraction for React Components ([`19618b4`](https://github.com/l7aromeo/meonode-ui/commit/19618b4))
10
+ - Modified `processRawNode` to prevent `style` props from being extracted and flattened into HTML attributes when the node is a React Component.
11
+ - This ensures components receive their `style` prop intact as an object, preventing invalid attribute errors.
12
+
5
13
  ## [1.0.0] - 2025-11-28
6
14
 
7
15
  ### Perf
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("../helper/react-is.helper.js"),o=require("../helper/common.helper.js"),r=require("../constant/common.const.js"),n=require("../core.node.js"),s=require("react-dom/client");const i=Symbol.for("@meonode/ui/NodeUtil/functionSignatureCache"),a=Symbol.for("@meonode/ui/NodeUtil/portalInfrastructure");class c{constructor(){}static isServer="undefined"==typeof window;static get _functionSignatureCache(){return o.getGlobalState(i,()=>new WeakMap)}static CRITICAL_PROPS=new Set(["css","className","disableEmotion","props"]);static get portalInfrastructure(){return o.getGlobalState(a,()=>new WeakMap)}static isNodeInstance=e=>"object"==typeof e&&null!==e&&"element"in e&&"function"==typeof e.render&&"function"==typeof e.toPortal&&"isBaseNode"in e;static isStyleProp=c.isServer||"undefined"==typeof document?()=>!1:e=>e in document.body.style;static hashString(e){let t=2166136261,o=5381;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);t^=n,t=Math.imul(t,16777619),o=33*o^n}return`${(t>>>0).toString(36)}_${(o>>>0).toString(36)}`}static hashCSS(e){const t=Object.keys(e);let o=t.length;for(let r=0;r<Math.min(t.length,10);r++){const n=t[r],s=e[n];o=(o<<5)-o+n.charCodeAt(0),o&=o,"string"==typeof s&&(o=(o<<5)-o+s.length)}return o.toString(36)}static createPropSignature(e,t){if(c.isServer)return;const r=o.getElementTypeName(e),n=Object.keys(t);n.length>1&&n.sort();const s=[`${r}:`];if("function"==typeof e){let t=c._functionSignatureCache.get(e);t||(t=c.hashString(e.toString()),c._functionSignatureCache.set(e,t)),s.push(t)}for(const e of n){const o=t[e];let r;const n=typeof o;if("string"===n||"number"===n||"boolean"===n)r=`${e}:${o};`;else if(null===o)r=`${e}:null;`;else if(void 0===o)r=`${e}:undefined;`;else if("css"===e&&"object"==typeof o)r=`css:${this.hashCSS(o)};`;else if(Array.isArray(o)){const t=o.filter(e=>{const t=typeof e;return"string"===t||"number"===t||"boolean"===t||null===e});r=t.length===o.length?`${e}:[${t.join(",")}];`:`${e}:[${o.length}];`}else if(o&&o.isBaseNode)r=`${e}:${o.stableKey};`;else if("function"===n)r=`${e}:${c.hashString(o.toString())};`;else{r=`${e}:{${Object.keys(o).sort().join(",")}};`}s.push(r)}return c.hashString(s.join(","))}static extractCriticalProps(e,t){const o={_keyCount:t.length};let r=0;for(const n of t){if(r>=50)break;if(c.CRITICAL_PROPS.has(n)){o[n]=e[n],r++;continue}const s=n.charCodeAt(0);111!==s||110!==n.charCodeAt(1)?!(97===s&&114===n.charCodeAt(1)&&105===n.charCodeAt(2)&&97===n.charCodeAt(3)||100===s&&97===n.charCodeAt(1)&&116===n.charCodeAt(2)&&97===n.charCodeAt(3))?t.length<=100&&c.isStyleProp(n)&&(o[n]=e[n],r++):(o[n]=e[n],r++):(o[n]=e[n],r++)}return o}static processProps(e,t={},r){const{ref:n,key:s,children:i,css:a,props:d={},disableEmotion:l,...u}=t;if(0===Object.keys(u).length&&!a)return o.omitUndefined({ref:n,key:s,disableEmotion:l,nativeProps:o.omitUndefined(d),children:c._processChildren(i,l)});const p={},f={},m=Object.keys(u);for(let e=0;e<m.length;e++){const t=m[e],o=u[t],r=typeof o;"string"===r||"number"===r||"boolean"===r?p[t]=o:f[t]=o}const{cssProps:h}={cssProps:o.getCSSProps(p)},y=o.getCSSProps(f),g=o.getDOMProps(u),b={...h,...y,...a},C=c._processChildren(i,l,r);return o.omitUndefined({ref:n,key:s,css:b,...g,disableEmotion:l,nativeProps:o.omitUndefined(d),children:C})}static _processChildren(e,t,o){if(e)return"function"==typeof e?e:Array.isArray(e)?1===e.length?c.processRawNode(e[0],t,`${o}_0`):e.map((e,r)=>c.processRawNode(e,t,`${o}_${r}`)):c.processRawNode(e,t,o)}static shouldCacheElement(e){return!c.isServer&&!!e.stableKey&&!!e.dependencies}static shouldNodeUpdate(e,t,o){return!!c.isServer||!o&&(void 0===t||(void 0===e||(t.length!==e.length||!!t.some((t,o)=>!Object.is(t,e[o])))))}static processRawNode(o,r,s){if(null==o||"string"==typeof o||"number"==typeof o||"boolean"==typeof o)return o;if(c.isNodeInstance(o)){if(s||r&&!o.rawProps.disableEmotion){const e=new n.BaseNode(o.element,o.rawProps,o.dependencies);return e.stableKey=`${s}:${e.stableKey}`,r&&!e.rawProps.disableEmotion&&(e.rawProps.disableEmotion=!0),e}return o}if(c.isFunctionChild(o))return new n.BaseNode(c.functionRenderer,{props:{render:o,disableEmotion:r}},void 0);if(e.isValidElement(o)){const{style:e,...t}=o.props,s={...t,...e||{}};return new n.BaseNode(o.type,{...s,...null!==o.key&&void 0!==o.key?{key:o.key}:{},disableEmotion:r},void 0)}return t.isReactClassComponent(o)||t.isMemo(o)||t.isForwardRef(o)?new n.BaseNode(o,{disableEmotion:r},void 0):o instanceof e.Component?c.processRawNode(o.render(),r,s):o}static isFunctionChild(e){if("function"!=typeof e||t.isReactClassComponent(e)||t.isMemo(e)||t.isForwardRef(e))return!1;try{return!(e.prototype&&"function"==typeof e.prototype.render)}catch(e){return r.__DEBUG__&&console.error("MeoNode: Error checking if a node is a function child.",e),!0}}static functionRenderer({render:t,disableEmotion:s}){let i;try{i=t()}catch(e){r.__DEBUG__&&console.error("MeoNode: Error executing function-as-a-child.",e),i=null}if(null==i)return i;if(c.isNodeInstance(i))return s&&!i.rawProps.disableEmotion?new n.BaseNode(i.element,{...i.rawProps,disableEmotion:!0}).render():i.render();if(Array.isArray(i)){const e=(e,t)=>{try{return`${o.getElementTypeName(e)}-${t}`}catch(e){return r.__DEBUG__&&console.error("MeoNode: Could not determine element type name for key in function-as-a-child.",e),`item-${t}`}};return i.map((t,o)=>c.renderProcessedNode({processedElement:c.processRawNode(t,s),passedKey:e(t,o),disableEmotion:s}))}if(i instanceof e.Component)return c.renderProcessedNode({processedElement:c.processRawNode(i.render(),s),disableEmotion:s});if("string"==typeof i||"number"==typeof i||"boolean"==typeof i)return i;const a=c.processRawNode(i,s);return a?c.renderProcessedNode({processedElement:a,disableEmotion:s}):i}static renderProcessedNode({processedElement:o,passedKey:r,disableEmotion:s}){const i={};if(void 0!==r&&(i.key=r),c.isNodeInstance(o)){const e=o.rawProps?.key;return o.rawProps.disableEmotion=s,e===r?o.render():new n.BaseNode(o.element,{...o.rawProps,...i}).render()}return t.isReactClassComponent(o)?new n.BaseNode(o,{...i,disableEmotion:s}).render():o instanceof e.Component?o.render():"function"==typeof o?e.createElement(o,{key:r}):o}static ensurePortalInfrastructure(e){if(c.isServer)return!1;let t=c.portalInfrastructure.get(e);if(t?.domElement?.isConnected&&t?.reactRoot)return!0;if(t&&(!t.domElement?.isConnected||!t.reactRoot)){try{t.reactRoot?.unmount?.()}catch(e){r.__DEBUG__&&console.error("MeoNode: Error unmounting stale portal root.",e)}c.cleanupPortalInfra(t),c.portalInfrastructure.delete(e),t=void 0}const o=document.createElement("div");document.body.appendChild(o);const i=s.createRoot(o),a={render:i.render.bind(i),unmount:i.unmount.bind(i),update:()=>{}};return t={domElement:o,reactRoot:a,instanceId:e.instanceId},c.portalInfrastructure.set(e,t),n.BaseNode.portalCleanupRegistry.register(e,{domElement:o,reactRoot:a},e),!0}static cleanupPortalInfra(e){try{e.reactRoot?.unmount&&e.reactRoot.unmount()}catch(e){r.__DEBUG__&&console.error("Portal cleanup error:",e)}try{e.domElement?.isConnected&&e.domElement.remove()}catch(e){r.__DEBUG__&&console.error("DOM removal error:",e)}}}exports.NodeUtil=c;
1
+ "use strict";var e=require("react"),t=require("../helper/react-is.helper.js"),o=require("../helper/common.helper.js"),r=require("../constant/common.const.js"),n=require("../core.node.js"),s=require("react-dom/client");const i=Symbol.for("@meonode/ui/NodeUtil/functionSignatureCache"),a=Symbol.for("@meonode/ui/NodeUtil/portalInfrastructure");class c{constructor(){}static isServer="undefined"==typeof window;static get _functionSignatureCache(){return o.getGlobalState(i,()=>new WeakMap)}static CRITICAL_PROPS=new Set(["css","className","disableEmotion","props"]);static get portalInfrastructure(){return o.getGlobalState(a,()=>new WeakMap)}static isNodeInstance=e=>"object"==typeof e&&null!==e&&"element"in e&&"function"==typeof e.render&&"function"==typeof e.toPortal&&"isBaseNode"in e;static isStyleProp=c.isServer||"undefined"==typeof document?()=>!1:e=>e in document.body.style;static hashString(e){let t=2166136261,o=5381;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);t^=n,t=Math.imul(t,16777619),o=33*o^n}return`${(t>>>0).toString(36)}_${(o>>>0).toString(36)}`}static hashCSS(e){const t=Object.keys(e);let o=t.length;for(let r=0;r<Math.min(t.length,10);r++){const n=t[r],s=e[n];o=(o<<5)-o+n.charCodeAt(0),o&=o,"string"==typeof s&&(o=(o<<5)-o+s.length)}return o.toString(36)}static createPropSignature(e,t){if(c.isServer)return;const r=o.getElementTypeName(e),n=Object.keys(t);n.length>1&&n.sort();const s=[`${r}:`];if("function"==typeof e){let t=c._functionSignatureCache.get(e);t||(t=c.hashString(e.toString()),c._functionSignatureCache.set(e,t)),s.push(t)}for(const e of n){const o=t[e];let r;const n=typeof o;if("string"===n||"number"===n||"boolean"===n)r=`${e}:${o};`;else if(null===o)r=`${e}:null;`;else if(void 0===o)r=`${e}:undefined;`;else if("css"===e&&"object"==typeof o)r=`css:${this.hashCSS(o)};`;else if(Array.isArray(o)){const t=o.filter(e=>{const t=typeof e;return"string"===t||"number"===t||"boolean"===t||null===e});r=t.length===o.length?`${e}:[${t.join(",")}];`:`${e}:[${o.length}];`}else if(o&&o.isBaseNode)r=`${e}:${o.stableKey};`;else if("function"===n)r=`${e}:${c.hashString(o.toString())};`;else{r=`${e}:{${Object.keys(o).sort().join(",")}};`}s.push(r)}return c.hashString(s.join(","))}static extractCriticalProps(e,t){const o={_keyCount:t.length};let r=0;for(const n of t){if(r>=50)break;if(c.CRITICAL_PROPS.has(n)){o[n]=e[n],r++;continue}const s=n.charCodeAt(0);111!==s||110!==n.charCodeAt(1)?!(97===s&&114===n.charCodeAt(1)&&105===n.charCodeAt(2)&&97===n.charCodeAt(3)||100===s&&97===n.charCodeAt(1)&&116===n.charCodeAt(2)&&97===n.charCodeAt(3))?t.length<=100&&c.isStyleProp(n)&&(o[n]=e[n],r++):(o[n]=e[n],r++):(o[n]=e[n],r++)}return o}static processProps(e,t={},r){const{ref:n,key:s,children:i,css:a,props:d={},disableEmotion:l,...u}=t;if(0===Object.keys(u).length&&!a)return o.omitUndefined({ref:n,key:s,disableEmotion:l,nativeProps:o.omitUndefined(d),children:c._processChildren(i,l)});const p={},f={},m=Object.keys(u);for(let e=0;e<m.length;e++){const t=m[e],o=u[t],r=typeof o;"string"===r||"number"===r||"boolean"===r?p[t]=o:f[t]=o}const{cssProps:y}={cssProps:o.getCSSProps(p)},h=o.getCSSProps(f),g=o.getDOMProps(u),b={...y,...h,...a},C=c._processChildren(i,l,r);return o.omitUndefined({ref:n,key:s,css:b,...g,disableEmotion:l,nativeProps:o.omitUndefined(d),children:C})}static _processChildren(e,t,o){if(e)return"function"==typeof e?e:Array.isArray(e)?1===e.length?c.processRawNode(e[0],t,`${o}_0`):e.map((e,r)=>c.processRawNode(e,t,`${o}_${r}`)):c.processRawNode(e,t,o)}static shouldCacheElement(e){return!c.isServer&&!!e.stableKey&&!!e.dependencies}static shouldNodeUpdate(e,t,o){return!!c.isServer||!o&&(void 0===t||(void 0===e||(t.length!==e.length||!!t.some((t,o)=>!Object.is(t,e[o])))))}static processRawNode(o,r,s){if(null==o||"string"==typeof o||"number"==typeof o||"boolean"==typeof o)return o;if(c.isNodeInstance(o)){if(s||r&&!o.rawProps.disableEmotion){const e=new n.BaseNode(o.element,o.rawProps,o.dependencies);return e.stableKey=`${s}:${e.stableKey}`,r&&!e.rawProps.disableEmotion&&(e.rawProps.disableEmotion=!0),e}return o}if(c.isFunctionChild(o))return new n.BaseNode(c.functionRenderer,{props:{render:o,disableEmotion:r}},void 0);if(e.isValidElement(o)){if("string"==typeof o.type){const{style:e,...t}=o.props,s={...t,...e||{}};return new n.BaseNode(o.type,{...s,...null!==o.key&&void 0!==o.key?{key:o.key}:{},disableEmotion:r},void 0)}return new n.BaseNode(o.type,{...o.props,...null!==o.key&&void 0!==o.key?{key:o.key}:{},disableEmotion:r},void 0)}return t.isReactClassComponent(o)||t.isMemo(o)||t.isForwardRef(o)?new n.BaseNode(o,{disableEmotion:r},void 0):o instanceof e.Component?c.processRawNode(o.render(),r,s):o}static isFunctionChild(e){if("function"!=typeof e||t.isReactClassComponent(e)||t.isMemo(e)||t.isForwardRef(e))return!1;try{return!(e.prototype&&"function"==typeof e.prototype.render)}catch(e){return r.__DEBUG__&&console.error("MeoNode: Error checking if a node is a function child.",e),!0}}static functionRenderer({render:t,disableEmotion:s}){let i;try{i=t()}catch(e){r.__DEBUG__&&console.error("MeoNode: Error executing function-as-a-child.",e),i=null}if(null==i)return i;if(c.isNodeInstance(i))return s&&!i.rawProps.disableEmotion?new n.BaseNode(i.element,{...i.rawProps,disableEmotion:!0}).render():i.render();if(Array.isArray(i)){const e=(e,t)=>{try{return`${o.getElementTypeName(e)}-${t}`}catch(e){return r.__DEBUG__&&console.error("MeoNode: Could not determine element type name for key in function-as-a-child.",e),`item-${t}`}};return i.map((t,o)=>c.renderProcessedNode({processedElement:c.processRawNode(t,s),passedKey:e(t,o),disableEmotion:s}))}if(i instanceof e.Component)return c.renderProcessedNode({processedElement:c.processRawNode(i.render(),s),disableEmotion:s});if("string"==typeof i||"number"==typeof i||"boolean"==typeof i)return i;const a=c.processRawNode(i,s);return a?c.renderProcessedNode({processedElement:a,disableEmotion:s}):i}static renderProcessedNode({processedElement:o,passedKey:r,disableEmotion:s}){const i={};if(void 0!==r&&(i.key=r),c.isNodeInstance(o)){const e=o.rawProps?.key;return o.rawProps.disableEmotion=s,e===r?o.render():new n.BaseNode(o.element,{...o.rawProps,...i}).render()}return t.isReactClassComponent(o)?new n.BaseNode(o,{...i,disableEmotion:s}).render():o instanceof e.Component?o.render():"function"==typeof o?e.createElement(o,{key:r}):o}static ensurePortalInfrastructure(e){if(c.isServer)return!1;let t=c.portalInfrastructure.get(e);if(t?.domElement?.isConnected&&t?.reactRoot)return!0;if(t&&(!t.domElement?.isConnected||!t.reactRoot)){try{t.reactRoot?.unmount?.()}catch(e){r.__DEBUG__&&console.error("MeoNode: Error unmounting stale portal root.",e)}c.cleanupPortalInfra(t),c.portalInfrastructure.delete(e),t=void 0}const o=document.createElement("div");document.body.appendChild(o);const i=s.createRoot(o),a={render:i.render.bind(i),unmount:i.unmount.bind(i),update:()=>{}};return t={domElement:o,reactRoot:a,instanceId:e.instanceId},c.portalInfrastructure.set(e,t),n.BaseNode.portalCleanupRegistry.register(e,{domElement:o,reactRoot:a},e),!0}static cleanupPortalInfra(e){try{e.reactRoot?.unmount&&e.reactRoot.unmount()}catch(e){r.__DEBUG__&&console.error("Portal cleanup error:",e)}try{e.domElement?.isConnected&&e.domElement.remove()}catch(e){r.__DEBUG__&&console.error("DOM removal error:",e)}}}exports.NodeUtil=c;
@@ -1 +1 @@
1
- {"version":3,"file":"node.util.d.ts","sourceRoot":"","sources":["../../../src/util/node.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,KAAK,SAAS,EAAiC,MAAM,OAAO,CAAA;AACnH,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACd,cAAc,EAEd,UAAU,EACX,MAAM,yBAAyB,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AAI,CAAA;KAAE,QAgBtF;CACF"}
@@ -1 +1 @@
1
- import e,{isValidElement as t,createElement as r}from"react";import{isReactClassComponent as o,isMemo as n,isForwardRef as s}from"../helper/react-is.helper.js";import{getGlobalState as i,getElementTypeName as c,omitUndefined as a,getCSSProps as l,getDOMProps as d}from"../helper/common.helper.js";import{__DEBUG__ as u}from"../constant/common.const.js";import{BaseNode as p}from"../core.node.js";import{createRoot as f}from"react-dom/client";const m=Symbol.for("@meonode/ui/NodeUtil/functionSignatureCache"),h=Symbol.for("@meonode/ui/NodeUtil/portalInfrastructure");class y{constructor(){}static isServer="undefined"==typeof window;static get _functionSignatureCache(){return i(m,()=>new WeakMap)}static CRITICAL_PROPS=new Set(["css","className","disableEmotion","props"]);static get portalInfrastructure(){return i(h,()=>new WeakMap)}static isNodeInstance=e=>"object"==typeof e&&null!==e&&"element"in e&&"function"==typeof e.render&&"function"==typeof e.toPortal&&"isBaseNode"in e;static isStyleProp=y.isServer||"undefined"==typeof document?()=>!1:e=>e in document.body.style;static hashString(e){let t=2166136261,r=5381;for(let o=0;o<e.length;o++){const n=e.charCodeAt(o);t^=n,t=Math.imul(t,16777619),r=33*r^n}return`${(t>>>0).toString(36)}_${(r>>>0).toString(36)}`}static hashCSS(e){const t=Object.keys(e);let r=t.length;for(let o=0;o<Math.min(t.length,10);o++){const n=t[o],s=e[n];r=(r<<5)-r+n.charCodeAt(0),r&=r,"string"==typeof s&&(r=(r<<5)-r+s.length)}return r.toString(36)}static createPropSignature(e,t){if(y.isServer)return;const r=c(e),o=Object.keys(t);o.length>1&&o.sort();const n=[`${r}:`];if("function"==typeof e){let t=y._functionSignatureCache.get(e);t||(t=y.hashString(e.toString()),y._functionSignatureCache.set(e,t)),n.push(t)}for(const e of o){const r=t[e];let o;const s=typeof r;if("string"===s||"number"===s||"boolean"===s)o=`${e}:${r};`;else if(null===r)o=`${e}:null;`;else if(void 0===r)o=`${e}:undefined;`;else if("css"===e&&"object"==typeof r)o=`css:${this.hashCSS(r)};`;else if(Array.isArray(r)){const t=r.filter(e=>{const t=typeof e;return"string"===t||"number"===t||"boolean"===t||null===e});o=t.length===r.length?`${e}:[${t.join(",")}];`:`${e}:[${r.length}];`}else if(r&&r.isBaseNode)o=`${e}:${r.stableKey};`;else if("function"===s)o=`${e}:${y.hashString(r.toString())};`;else{o=`${e}:{${Object.keys(r).sort().join(",")}};`}n.push(o)}return y.hashString(n.join(","))}static extractCriticalProps(e,t){const r={_keyCount:t.length};let o=0;for(const n of t){if(o>=50)break;if(y.CRITICAL_PROPS.has(n)){r[n]=e[n],o++;continue}const s=n.charCodeAt(0);111!==s||110!==n.charCodeAt(1)?!(97===s&&114===n.charCodeAt(1)&&105===n.charCodeAt(2)&&97===n.charCodeAt(3)||100===s&&97===n.charCodeAt(1)&&116===n.charCodeAt(2)&&97===n.charCodeAt(3))?t.length<=100&&y.isStyleProp(n)&&(r[n]=e[n],o++):(r[n]=e[n],o++):(r[n]=e[n],o++)}return r}static processProps(e,t={},r){const{ref:o,key:n,children:s,css:i,props:c={},disableEmotion:u,...p}=t;if(0===Object.keys(p).length&&!i)return a({ref:o,key:n,disableEmotion:u,nativeProps:a(c),children:y._processChildren(s,u)});const f={},m={},h=Object.keys(p);for(let e=0;e<h.length;e++){const t=h[e],r=p[t],o=typeof r;"string"===o||"number"===o||"boolean"===o?f[t]=r:m[t]=r}const{cssProps:b}={cssProps:l(f)},g=l(m),C=d(p),E={...b,...g,...i},P=y._processChildren(s,u,r);return a({ref:o,key:n,css:E,...C,disableEmotion:u,nativeProps:a(c),children:P})}static _processChildren(e,t,r){if(e)return"function"==typeof e?e:Array.isArray(e)?1===e.length?y.processRawNode(e[0],t,`${r}_0`):e.map((e,o)=>y.processRawNode(e,t,`${r}_${o}`)):y.processRawNode(e,t,r)}static shouldCacheElement(e){return!y.isServer&&!!e.stableKey&&!!e.dependencies}static shouldNodeUpdate(e,t,r){return!!y.isServer||!r&&(void 0===t||(void 0===e||(t.length!==e.length||!!t.some((t,r)=>!Object.is(t,e[r])))))}static processRawNode(r,i,c){if(null==r||"string"==typeof r||"number"==typeof r||"boolean"==typeof r)return r;if(y.isNodeInstance(r)){if(c||i&&!r.rawProps.disableEmotion){const e=new p(r.element,r.rawProps,r.dependencies);return e.stableKey=`${c}:${e.stableKey}`,i&&!e.rawProps.disableEmotion&&(e.rawProps.disableEmotion=!0),e}return r}if(y.isFunctionChild(r))return new p(y.functionRenderer,{props:{render:r,disableEmotion:i}},void 0);if(t(r)){const{style:e,...t}=r.props,o={...t,...e||{}};return new p(r.type,{...o,...null!==r.key&&void 0!==r.key?{key:r.key}:{},disableEmotion:i},void 0)}return o(r)||n(r)||s(r)?new p(r,{disableEmotion:i},void 0):r instanceof e.Component?y.processRawNode(r.render(),i,c):r}static isFunctionChild(e){if("function"!=typeof e||o(e)||n(e)||s(e))return!1;try{return!(e.prototype&&"function"==typeof e.prototype.render)}catch(e){return u&&console.error("MeoNode: Error checking if a node is a function child.",e),!0}}static functionRenderer({render:t,disableEmotion:r}){let o;try{o=t()}catch(e){u&&console.error("MeoNode: Error executing function-as-a-child.",e),o=null}if(null==o)return o;if(y.isNodeInstance(o))return r&&!o.rawProps.disableEmotion?new p(o.element,{...o.rawProps,disableEmotion:!0}).render():o.render();if(Array.isArray(o)){const e=(e,t)=>{try{return`${c(e)}-${t}`}catch(e){return u&&console.error("MeoNode: Could not determine element type name for key in function-as-a-child.",e),`item-${t}`}};return o.map((t,o)=>y.renderProcessedNode({processedElement:y.processRawNode(t,r),passedKey:e(t,o),disableEmotion:r}))}if(o instanceof e.Component)return y.renderProcessedNode({processedElement:y.processRawNode(o.render(),r),disableEmotion:r});if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)return o;const n=y.processRawNode(o,r);return n?y.renderProcessedNode({processedElement:n,disableEmotion:r}):o}static renderProcessedNode({processedElement:t,passedKey:n,disableEmotion:s}){const i={};if(void 0!==n&&(i.key=n),y.isNodeInstance(t)){const e=t.rawProps?.key;return t.rawProps.disableEmotion=s,e===n?t.render():new p(t.element,{...t.rawProps,...i}).render()}return o(t)?new p(t,{...i,disableEmotion:s}).render():t instanceof e.Component?t.render():"function"==typeof t?r(t,{key:n}):t}static ensurePortalInfrastructure(e){if(y.isServer)return!1;let t=y.portalInfrastructure.get(e);if(t?.domElement?.isConnected&&t?.reactRoot)return!0;if(t&&(!t.domElement?.isConnected||!t.reactRoot)){try{t.reactRoot?.unmount?.()}catch(e){u&&console.error("MeoNode: Error unmounting stale portal root.",e)}y.cleanupPortalInfra(t),y.portalInfrastructure.delete(e),t=void 0}const r=document.createElement("div");document.body.appendChild(r);const o=f(r),n={render:o.render.bind(o),unmount:o.unmount.bind(o),update:()=>{}};return t={domElement:r,reactRoot:n,instanceId:e.instanceId},y.portalInfrastructure.set(e,t),p.portalCleanupRegistry.register(e,{domElement:r,reactRoot:n},e),!0}static cleanupPortalInfra(e){try{e.reactRoot?.unmount&&e.reactRoot.unmount()}catch(e){u&&console.error("Portal cleanup error:",e)}try{e.domElement?.isConnected&&e.domElement.remove()}catch(e){u&&console.error("DOM removal error:",e)}}}export{y as NodeUtil};
1
+ import e,{isValidElement as t,createElement as r}from"react";import{isReactClassComponent as o,isMemo as n,isForwardRef as s}from"../helper/react-is.helper.js";import{getGlobalState as i,getElementTypeName as c,omitUndefined as a,getCSSProps as l,getDOMProps as d}from"../helper/common.helper.js";import{__DEBUG__ as u}from"../constant/common.const.js";import{BaseNode as p}from"../core.node.js";import{createRoot as f}from"react-dom/client";const m=Symbol.for("@meonode/ui/NodeUtil/functionSignatureCache"),y=Symbol.for("@meonode/ui/NodeUtil/portalInfrastructure");class h{constructor(){}static isServer="undefined"==typeof window;static get _functionSignatureCache(){return i(m,()=>new WeakMap)}static CRITICAL_PROPS=new Set(["css","className","disableEmotion","props"]);static get portalInfrastructure(){return i(y,()=>new WeakMap)}static isNodeInstance=e=>"object"==typeof e&&null!==e&&"element"in e&&"function"==typeof e.render&&"function"==typeof e.toPortal&&"isBaseNode"in e;static isStyleProp=h.isServer||"undefined"==typeof document?()=>!1:e=>e in document.body.style;static hashString(e){let t=2166136261,r=5381;for(let o=0;o<e.length;o++){const n=e.charCodeAt(o);t^=n,t=Math.imul(t,16777619),r=33*r^n}return`${(t>>>0).toString(36)}_${(r>>>0).toString(36)}`}static hashCSS(e){const t=Object.keys(e);let r=t.length;for(let o=0;o<Math.min(t.length,10);o++){const n=t[o],s=e[n];r=(r<<5)-r+n.charCodeAt(0),r&=r,"string"==typeof s&&(r=(r<<5)-r+s.length)}return r.toString(36)}static createPropSignature(e,t){if(h.isServer)return;const r=c(e),o=Object.keys(t);o.length>1&&o.sort();const n=[`${r}:`];if("function"==typeof e){let t=h._functionSignatureCache.get(e);t||(t=h.hashString(e.toString()),h._functionSignatureCache.set(e,t)),n.push(t)}for(const e of o){const r=t[e];let o;const s=typeof r;if("string"===s||"number"===s||"boolean"===s)o=`${e}:${r};`;else if(null===r)o=`${e}:null;`;else if(void 0===r)o=`${e}:undefined;`;else if("css"===e&&"object"==typeof r)o=`css:${this.hashCSS(r)};`;else if(Array.isArray(r)){const t=r.filter(e=>{const t=typeof e;return"string"===t||"number"===t||"boolean"===t||null===e});o=t.length===r.length?`${e}:[${t.join(",")}];`:`${e}:[${r.length}];`}else if(r&&r.isBaseNode)o=`${e}:${r.stableKey};`;else if("function"===s)o=`${e}:${h.hashString(r.toString())};`;else{o=`${e}:{${Object.keys(r).sort().join(",")}};`}n.push(o)}return h.hashString(n.join(","))}static extractCriticalProps(e,t){const r={_keyCount:t.length};let o=0;for(const n of t){if(o>=50)break;if(h.CRITICAL_PROPS.has(n)){r[n]=e[n],o++;continue}const s=n.charCodeAt(0);111!==s||110!==n.charCodeAt(1)?!(97===s&&114===n.charCodeAt(1)&&105===n.charCodeAt(2)&&97===n.charCodeAt(3)||100===s&&97===n.charCodeAt(1)&&116===n.charCodeAt(2)&&97===n.charCodeAt(3))?t.length<=100&&h.isStyleProp(n)&&(r[n]=e[n],o++):(r[n]=e[n],o++):(r[n]=e[n],o++)}return r}static processProps(e,t={},r){const{ref:o,key:n,children:s,css:i,props:c={},disableEmotion:u,...p}=t;if(0===Object.keys(p).length&&!i)return a({ref:o,key:n,disableEmotion:u,nativeProps:a(c),children:h._processChildren(s,u)});const f={},m={},y=Object.keys(p);for(let e=0;e<y.length;e++){const t=y[e],r=p[t],o=typeof r;"string"===o||"number"===o||"boolean"===o?f[t]=r:m[t]=r}const{cssProps:b}={cssProps:l(f)},g=l(m),C=d(p),E={...b,...g,...i},P=h._processChildren(s,u,r);return a({ref:o,key:n,css:E,...C,disableEmotion:u,nativeProps:a(c),children:P})}static _processChildren(e,t,r){if(e)return"function"==typeof e?e:Array.isArray(e)?1===e.length?h.processRawNode(e[0],t,`${r}_0`):e.map((e,o)=>h.processRawNode(e,t,`${r}_${o}`)):h.processRawNode(e,t,r)}static shouldCacheElement(e){return!h.isServer&&!!e.stableKey&&!!e.dependencies}static shouldNodeUpdate(e,t,r){return!!h.isServer||!r&&(void 0===t||(void 0===e||(t.length!==e.length||!!t.some((t,r)=>!Object.is(t,e[r])))))}static processRawNode(r,i,c){if(null==r||"string"==typeof r||"number"==typeof r||"boolean"==typeof r)return r;if(h.isNodeInstance(r)){if(c||i&&!r.rawProps.disableEmotion){const e=new p(r.element,r.rawProps,r.dependencies);return e.stableKey=`${c}:${e.stableKey}`,i&&!e.rawProps.disableEmotion&&(e.rawProps.disableEmotion=!0),e}return r}if(h.isFunctionChild(r))return new p(h.functionRenderer,{props:{render:r,disableEmotion:i}},void 0);if(t(r)){if("string"==typeof r.type){const{style:e,...t}=r.props,o={...t,...e||{}};return new p(r.type,{...o,...null!==r.key&&void 0!==r.key?{key:r.key}:{},disableEmotion:i},void 0)}return new p(r.type,{...r.props,...null!==r.key&&void 0!==r.key?{key:r.key}:{},disableEmotion:i},void 0)}return o(r)||n(r)||s(r)?new p(r,{disableEmotion:i},void 0):r instanceof e.Component?h.processRawNode(r.render(),i,c):r}static isFunctionChild(e){if("function"!=typeof e||o(e)||n(e)||s(e))return!1;try{return!(e.prototype&&"function"==typeof e.prototype.render)}catch(e){return u&&console.error("MeoNode: Error checking if a node is a function child.",e),!0}}static functionRenderer({render:t,disableEmotion:r}){let o;try{o=t()}catch(e){u&&console.error("MeoNode: Error executing function-as-a-child.",e),o=null}if(null==o)return o;if(h.isNodeInstance(o))return r&&!o.rawProps.disableEmotion?new p(o.element,{...o.rawProps,disableEmotion:!0}).render():o.render();if(Array.isArray(o)){const e=(e,t)=>{try{return`${c(e)}-${t}`}catch(e){return u&&console.error("MeoNode: Could not determine element type name for key in function-as-a-child.",e),`item-${t}`}};return o.map((t,o)=>h.renderProcessedNode({processedElement:h.processRawNode(t,r),passedKey:e(t,o),disableEmotion:r}))}if(o instanceof e.Component)return h.renderProcessedNode({processedElement:h.processRawNode(o.render(),r),disableEmotion:r});if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)return o;const n=h.processRawNode(o,r);return n?h.renderProcessedNode({processedElement:n,disableEmotion:r}):o}static renderProcessedNode({processedElement:t,passedKey:n,disableEmotion:s}){const i={};if(void 0!==n&&(i.key=n),h.isNodeInstance(t)){const e=t.rawProps?.key;return t.rawProps.disableEmotion=s,e===n?t.render():new p(t.element,{...t.rawProps,...i}).render()}return o(t)?new p(t,{...i,disableEmotion:s}).render():t instanceof e.Component?t.render():"function"==typeof t?r(t,{key:n}):t}static ensurePortalInfrastructure(e){if(h.isServer)return!1;let t=h.portalInfrastructure.get(e);if(t?.domElement?.isConnected&&t?.reactRoot)return!0;if(t&&(!t.domElement?.isConnected||!t.reactRoot)){try{t.reactRoot?.unmount?.()}catch(e){u&&console.error("MeoNode: Error unmounting stale portal root.",e)}h.cleanupPortalInfra(t),h.portalInfrastructure.delete(e),t=void 0}const r=document.createElement("div");document.body.appendChild(r);const o=f(r),n={render:o.render.bind(o),unmount:o.unmount.bind(o),update:()=>{}};return t={domElement:r,reactRoot:n,instanceId:e.instanceId},h.portalInfrastructure.set(e,t),p.portalCleanupRegistry.register(e,{domElement:r,reactRoot:n},e),!0}static cleanupPortalInfra(e){try{e.reactRoot?.unmount&&e.reactRoot.unmount()}catch(e){u&&console.error("Portal cleanup error:",e)}try{e.domElement?.isConnected&&e.domElement.remove()}catch(e){u&&console.error("DOM removal error:",e)}}}export{h as NodeUtil};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meonode/ui",
3
3
  "description": "A structured approach to component composition, direct CSS-first prop styling, built-in theming, smart prop handling (including raw property pass-through), and dynamic children.",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "types": "./dist/main.d.ts",