@meonode/ui 1.4.4-beta.1 → 1.4.4-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@emotion/react"),r=require("./theme-provider.client.cjs"),s=require("../util/theme.util.cjs");function i({element:i,children:o,...c}){const l=e.useContext(r.ThemeContext),n=l?.theme,{css:u,...m}=c;let h=u,a=m;n&&(h=s.ThemeUtil.resolveObjWithTheme(u,n,{processFunctions:!0}),a=s.ThemeUtil.resolveObjWithTheme(m,n,{processFunctions:!1}));const d=s.ThemeUtil.resolveDefaultStyle(h);return t.jsx(i,{...a,css:d},o)}i.displayName="Styled",i.__meonodeAcceptsServerCss=!0,exports.default=i;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@emotion/react"),r=require("./theme-provider.client.cjs"),s=require("../util/theme.util.cjs");function i({element:i,children:o,...c}){const l=e.useContext(r.ThemeContext),n=l?.theme,{css:u,...m}=c;let h=u,a=m;n&&(h=s.ThemeUtil.resolveObjWithTheme(u,n,{processFunctions:!0,themeStringsMode:"vars"}),a=s.ThemeUtil.resolveObjWithTheme(m,n,{processFunctions:!1,themeStringsMode:"vars"}));const d=s.ThemeUtil.resolveDefaultStyle(h);return t.jsx(i,{...a,css:d},o)}i.displayName="Styled",i.__meonodeAcceptsServerCss=!0,exports.default=i;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../core.node.cjs");const r=e.createContext(null);function o({children:o,theme:n}){const[c,s]=e.useState(n);if(!n)throw new Error("`theme` prop must be defined");const d={theme:c,setTheme:e=>{"function"==typeof e&&(e=e(c)),document.cookie=`theme=${e.mode}; path=/;`,s(e)}};return t.Node(r.Provider,{value:d,children:o}).render()}o.__meonodeAcceptsServerCss=!0,o.__meonodeProvidesServerTheme=!0,exports.ThemeContext=r,exports.default=o;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../core.node.cjs"),r=require("../util/server-theme.util.cjs");const o=e.createContext(null);function n({children:n,theme:s}){const[c,d]=e.useState(s);if(!s)throw new Error("`theme` prop must be defined");const u={theme:c,setTheme:e=>{"function"==typeof e&&(e=e(c)),document.cookie=`theme=${e.mode}; path=/;`,d(e)}};return e.useInsertionEffect(()=>{const e=r.buildThemeVariablesCss(c);if(!e)return;const t=document.createElement("style");return t.setAttribute("data-meonode-theme-vars",""),t.textContent=e,document.head.appendChild(t),()=>{t.remove()}},[c]),t.Node(o.Provider,{value:u,children:n}).render()}n.__meonodeAcceptsServerCss=!0,n.__meonodeProvidesServerTheme=!0,exports.ThemeContext=o,exports.default=n;
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("./helper/react-is.helper.cjs"),n=require("./helper/common.helper.cjs"),r=require("./components/styled-renderer.client.cjs"),s=require("./constant/common.const.cjs"),o=require("./util/mount-tracker.util.cjs"),i=require("./components/meonode-unmounter.client.cjs"),l=require("./util/navigation-cache-manager.util.cjs"),a=require("./util/node.util.cjs"),c=require("./util/server-emotion.util.cjs"),d=require("./util/server-theme.util.cjs"),h=require("./util/theme.util.cjs");const u=Symbol.for("@meonode/ui/BaseNode/elementCache"),m=Symbol.for("@meonode/ui/BaseNode/navigationStarted"),p=Symbol.for("@meonode/ui/BaseNode/renderContextPool"),g=Symbol.for("@meonode/ui/BaseNode/cacheCleanupRegistry");class f{static _idCounter=0;instanceId="m"+ ++f._idCounter;element;rawProps={};isBaseNode=!0;_props;_deps;stableKey;lastPropsObj;lastSignature;static get elementCache(){return n.getGlobalState(u,()=>new Map)}static get _navigationStarted(){return n.getGlobalState(m,()=>({value:!1})).value}static set _navigationStarted(e){n.getGlobalState(m,()=>({value:!1})).value=e}static get renderContextPool(){return n.getGlobalState(p,()=>[])}static acquireRenderContext(){const e=f.renderContextPool;return e.length>0?e.pop():{workStack:new Array(512),renderedElements:new Map}}static releaseRenderContext(e){f.renderContextPool.length<50&&e.workStack.length<2048&&(e.workStack.length=0,e.renderedElements.clear(),f.renderContextPool.push(e))}constructor(e,r={},s){if(!t.isValidElementType(e)){const t=n.getComponentType(e);if(a.NodeUtil.isNodeInstance(e))throw new Error("Invalid element type: MeoNode UI instance provided!");throw new Error(`Invalid element type: ${t} provided!`)}if(this.element=e,this.rawProps=r,this._deps=s,a.NodeUtil.isServer&&a.NodeUtil.providesServerTheme(e)){const e=r.theme;if(e&&"object"==typeof e&&"system"in e){const t=e;d.setActiveServerTheme(t),d.registerServerThemeVariables(t)}}const{ref:o,children:i,...c}=r;this.stableKey=this._getStableKey(c),a.NodeUtil.isServer||f._navigationStarted||(l.NavigationCacheManagerUtil.getInstance().start(),f._navigationStarted=!0)}get props(){return this._props||(this._props=a.NodeUtil.processProps(this.rawProps,this.stableKey)),this._props}get dependencies(){return this._deps}_getStableKey({key:e,...t}){if(a.NodeUtil.isServer)return;if(this.lastPropsObj===t)return this.lastSignature;this.lastPropsObj=t;const r=Object.keys(t),o=r.length;if(o>100){const e=a.NodeUtil.extractCriticalProps(t,r);this.lastSignature=a.NodeUtil.createPropSignature(this.element,e),s.__DEBUG__&&o>200&&console.warn(`MeoNode: Large props (${o} keys) on "${n.getElementTypeName(this.element)}". Consider splitting.`)}else this.lastSignature=a.NodeUtil.createPropSignature(this.element,t);return null!=e?`${String(e)}:${this.lastSignature}`:this.lastSignature}static get cacheCleanupRegistry(){return n.getGlobalState(g,()=>new FinalizationRegistry(e=>{const{cacheKey:t,instanceId:n}=e,r=f.elementCache.get(t);r?.instanceId===n&&f.elementCache.delete(t),o.MountTrackerUtil.isMounted(t)&&o.MountTrackerUtil.untrackMount(t)}))}render(s=!1){const o=a.NodeUtil.shouldCacheElement(this)?f.elementCache.get(this.stableKey):void 0,l=a.NodeUtil.shouldNodeUpdate(o?.prevDeps,this._deps,s);if(!l&&o?.renderedElement)return o.accessCount+=1,o.renderedElement;const u=!l,m=f.acquireRenderContext();let{workStack:p}=m;const{renderedElements:g}=m;let y=0;try{const s=e=>{if(e>p.length){const t=Math.max(e,p.length<<1),n=new Array(t);for(let e=0;e<y;e++)n[e]=p[e];p=n}};for(p[y++]={node:this,isProcessed:!1,blocked:u,theme:void 0};y>0;){const o=p[y-1];if(!o){y--;continue}const{node:i,isProcessed:l,blocked:u,theme:m}=o,C=(e,t)=>{const n=e.theme;return n&&"object"==typeof n&&"system"in n?n:t??d.getActiveServerTheme()},v=e=>{if(!e)return!1;if("string"==typeof e)return e.includes("theme.");if("function"==typeof e)return!0;if("object"!=typeof e)return!1;if(Array.isArray(e)){for(const t of e)if(v(t))return!0;return!1}for(const t of Object.values(e))if(v(t))return!0;return!1};if(l){y--;const{children:s,key:o,css:l,nativeProps:u,disableEmotion:p,...N}=i.props,S=C(i.props,m);let b=[];if(s){const e=Array.isArray(s)?s:[s],t=e.length;b=new Array(t);for(let n=0;n<t;n++){const t=e[n];if(a.NodeUtil.isNodeInstance(t)){const e=g.get(t);if(!e)throw new Error(`[MeoNode] Missing rendered element for child node: ${t.stableKey}`);b[n]=e}else b[n]=t}}const U={...N,key:o,...u};let _;if(i.element===e.Fragment||t.isFragment(i.element))_=e.createElement(i.element,{key:o},...b);else{const t=!p&&(l||!n.hasNoStyleTag(i.element)),s=a.NodeUtil.isServer&&"string"!=typeof i.element,o=t&&s&&a.NodeUtil.isClientReference(i.element)&&v(l);if(t&&!s||o){const t=a.NodeUtil.isServer?d.replaceThemeTokensWithCssVars(l):l;_=e.createElement(r.default,{element:i.element,...U,css:t,suppressHydrationWarning:!0},...b)}else if(t&&s&&!a.NodeUtil.acceptsServerCss(i.element)){const t=h.ThemeUtil.resolveObjWithTheme(U,S,{processFunctions:!1}),n=h.ThemeUtil.resolveObjWithTheme(d.replaceThemeTokensWithCssVars(l),S,{processFunctions:!0,themeStringsMode:"vars"}),r=h.ThemeUtil.resolveDefaultStyle(n),s=c.compileServerEmotionClassName(r),o=[t.className,s].filter(Boolean).join(" ")||void 0,a=o?{...t,className:o}:t;_=e.createElement(i.element,a,...b)}else{const n=t&&(!s||a.NodeUtil.acceptsServerCss(i.element))?{...U,css:l}:U;_=e.createElement(i.element,n,...b)}}if(i!==this&&a.NodeUtil.shouldCacheElement(i)){const e=f.elementCache.get(i.stableKey);if(e)e.prevDeps=i._deps,e.renderedElement=_,e.accessCount+=1;else{const e={prevDeps:i._deps,renderedElement:_,nodeRef:new WeakRef(i),createdAt:Date.now(),accessCount:1,instanceId:i.instanceId};f.elementCache.set(i.stableKey,e),f.cacheCleanupRegistry.register(i,{cacheKey:i.stableKey,instanceId:i.instanceId},i)}}g.set(i,_)}else{o.isProcessed=!0;const e=i.props.children,t=C(i.props,m);if(e){const n=Array.isArray(e)?e:[e];let r=0;for(let e=0;e<n.length;e++)a.NodeUtil.isNodeInstance(n[e])&&r++;s(y+r);for(let e=n.length-1;e>=0;e--){const r=n[e];if(!a.NodeUtil.isNodeInstance(r))continue;const s=a.NodeUtil.shouldCacheElement(r)?f.elementCache.get(r.stableKey):void 0,o=a.NodeUtil.shouldNodeUpdate(s?.prevDeps,r._deps,u);if(!o&&s?.renderedElement){g.set(r,s.renderedElement);continue}const i=u||!o;p[y++]={node:r,isProcessed:!1,blocked:i,theme:t}}}}}let o=g.get(this);if(!a.NodeUtil.isServer&&this.stableKey&&(o=e.createElement(i.default,{node:this},o)),a.NodeUtil.shouldCacheElement(this)){const e=f.elementCache.get(this.stableKey);if(e)e.prevDeps=this._deps,e.renderedElement=o,e.accessCount+=1;else{const e={prevDeps:this._deps,renderedElement:o,nodeRef:new WeakRef(this),createdAt:Date.now(),accessCount:1,instanceId:this.instanceId};f.elementCache.set(this.stableKey,e),f.cacheCleanupRegistry.register(this,{cacheKey:this.stableKey,instanceId:this.instanceId},this)}}return o}finally{for(let e=0;e<y;e++)p[e]=null;f.releaseRenderContext({workStack:p,renderedElements:g})}}static clearCaches(){const e=Array.from(f.elementCache.keys());s.__DEBUG__&&console.log(`[MeoNode] clearCaches: Clearing ${e.length} entries`);for(const t of e){const e=f.elementCache.get(t);if(e){const n=e.nodeRef?.deref();if(n)try{f.cacheCleanupRegistry.unregister(n),n.lastSignature=void 0,n.lastPropsObj=void 0}catch{s.__DEBUG__&&console.warn(`[MeoNode] Could not unregister ${t} from FinalizationRegistry`)}}}f.elementCache.clear(),o.MountTrackerUtil.cleanup(),s.__DEBUG__&&console.log("[MeoNode] All caches cleared")}}function y(e,t={},n){return new f(e,t,n)}y.clearCaches=f.clearCaches,exports.BaseNode=f,exports.Node=y,exports.createChildrenFirstNode=function(e,t){const n=(n,r,s)=>y(e,{...t,...r,children:n},s);return n.element=e,n},exports.createNode=function(e,t){const n=(n,r)=>y(e,{...t,...n},r);return n.element=e,n};
1
+ "use strict";var e=require("react"),t=require("./helper/react-is.helper.cjs"),s=require("./helper/common.helper.cjs"),n=require("./components/styled-renderer.client.cjs"),r=require("./constant/common.const.cjs"),o=require("./util/mount-tracker.util.cjs"),i=require("./components/meonode-unmounter.client.cjs"),l=require("./util/navigation-cache-manager.util.cjs"),a=require("./util/node.util.cjs"),c=require("./util/server-emotion.util.cjs"),d=require("./util/server-theme.util.cjs"),h=require("./util/theme.util.cjs");const m=Symbol.for("@meonode/ui/BaseNode/elementCache"),u=Symbol.for("@meonode/ui/BaseNode/navigationStarted"),p=Symbol.for("@meonode/ui/BaseNode/renderContextPool"),g=Symbol.for("@meonode/ui/BaseNode/cacheCleanupRegistry");class f{static _idCounter=0;instanceId="m"+ ++f._idCounter;element;rawProps={};isBaseNode=!0;_props;_deps;stableKey;lastPropsObj;lastSignature;static get elementCache(){return s.getGlobalState(m,()=>new Map)}static get _navigationStarted(){return s.getGlobalState(u,()=>({value:!1})).value}static set _navigationStarted(e){s.getGlobalState(u,()=>({value:!1})).value=e}static get renderContextPool(){return s.getGlobalState(p,()=>[])}static acquireRenderContext(){const e=f.renderContextPool;return e.length>0?e.pop():{workStack:new Array(512),renderedElements:new Map}}static releaseRenderContext(e){f.renderContextPool.length<50&&e.workStack.length<2048&&(e.workStack.length=0,e.renderedElements.clear(),f.renderContextPool.push(e))}constructor(e,n={},r){if(!t.isValidElementType(e)){const t=s.getComponentType(e);if(a.NodeUtil.isNodeInstance(e))throw new Error("Invalid element type: MeoNode UI instance provided!");throw new Error(`Invalid element type: ${t} provided!`)}if(this.element=e,this.rawProps=n,this._deps=r,a.NodeUtil.isServer&&a.NodeUtil.providesServerTheme(e)){const e=n.theme;if(e&&"object"==typeof e&&"system"in e){const t=e;d.setActiveServerTheme(t),d.registerServerThemeVariables(t)}}const{ref:o,children:i,...c}=n;this.stableKey=this._getStableKey(c),a.NodeUtil.isServer||f._navigationStarted||(l.NavigationCacheManagerUtil.getInstance().start(),f._navigationStarted=!0)}get props(){return this._props||(this._props=a.NodeUtil.processProps(this.rawProps,this.stableKey)),this._props}get dependencies(){return this._deps}_getStableKey({key:e,...t}){if(a.NodeUtil.isServer)return;if(this.lastPropsObj===t)return this.lastSignature;this.lastPropsObj=t;const n=Object.keys(t),o=n.length;if(o>100){const e=a.NodeUtil.extractCriticalProps(t,n);this.lastSignature=a.NodeUtil.createPropSignature(this.element,e),r.__DEBUG__&&o>200&&console.warn(`MeoNode: Large props (${o} keys) on "${s.getElementTypeName(this.element)}". Consider splitting.`)}else this.lastSignature=a.NodeUtil.createPropSignature(this.element,t);return null!=e?`${String(e)}:${this.lastSignature}`:this.lastSignature}static get cacheCleanupRegistry(){return s.getGlobalState(g,()=>new FinalizationRegistry(e=>{const{cacheKey:t,instanceId:s}=e,n=f.elementCache.get(t);n?.instanceId===s&&f.elementCache.delete(t),o.MountTrackerUtil.isMounted(t)&&o.MountTrackerUtil.untrackMount(t)}))}render(r=!1){const o=a.NodeUtil.shouldCacheElement(this)?f.elementCache.get(this.stableKey):void 0,l=a.NodeUtil.shouldNodeUpdate(o?.prevDeps,this._deps,r);if(!l&&o?.renderedElement)return o.accessCount+=1,o.renderedElement;const m=!l,u=f.acquireRenderContext();let{workStack:p}=u;const{renderedElements:g}=u;let y=0;try{const r=e=>{if(e>p.length){const t=Math.max(e,p.length<<1),s=new Array(t);for(let e=0;e<y;e++)s[e]=p[e];p=s}};for(p[y++]={node:this,isProcessed:!1,blocked:m,theme:void 0};y>0;){const o=p[y-1];if(!o){y--;continue}const{node:i,isProcessed:l,blocked:m,theme:u}=o,C=(e,t)=>{const s=e.theme;return s&&"object"==typeof s&&"system"in s?s:t??d.getActiveServerTheme()};if(l){y--;const{children:r,key:o,css:l,nativeProps:m,disableEmotion:p,...v}=i.props,N=C(i.props,u);let S=[];if(r){const e=Array.isArray(r)?r:[r],t=e.length;S=new Array(t);for(let s=0;s<t;s++){const t=e[s];if(a.NodeUtil.isNodeInstance(t)){const e=g.get(t);if(!e)throw new Error(`[MeoNode] Missing rendered element for child node: ${t.stableKey}`);S[s]=e}else S[s]=t}}const b={...v,key:o,...m};let U;if(i.element===e.Fragment||t.isFragment(i.element))U=e.createElement(i.element,{key:o},...S);else{const t=!p&&(l||!s.hasNoStyleTag(i.element)),r=a.NodeUtil.isServer&&"string"!=typeof i.element,o=t&&r&&a.NodeUtil.isClientReference(i.element);if(t&&!r||o){const t=a.NodeUtil.isServer?d.replaceThemeTokensWithCssVars(l):l;U=e.createElement(n.default,{element:i.element,...b,css:t},...S)}else if(t&&r&&!a.NodeUtil.acceptsServerCss(i.element)){const t=h.ThemeUtil.resolveObjWithTheme(b,N,{processFunctions:!1}),s=h.ThemeUtil.resolveObjWithTheme(d.replaceThemeTokensWithCssVars(l),N,{processFunctions:!0,themeStringsMode:"vars"}),n=h.ThemeUtil.resolveDefaultStyle(s),r=c.compileServerEmotionClassName(n),o=[t.className,r].filter(Boolean).join(" ")||void 0,a=o?{...t,className:o}:t;U=e.createElement(i.element,a,...S)}else{const s=t&&(!r||a.NodeUtil.acceptsServerCss(i.element))?{...b,css:l}:b;U=e.createElement(i.element,s,...S)}}if(i!==this&&a.NodeUtil.shouldCacheElement(i)){const e=f.elementCache.get(i.stableKey);if(e)e.prevDeps=i._deps,e.renderedElement=U,e.accessCount+=1;else{const e={prevDeps:i._deps,renderedElement:U,nodeRef:new WeakRef(i),createdAt:Date.now(),accessCount:1,instanceId:i.instanceId};f.elementCache.set(i.stableKey,e),f.cacheCleanupRegistry.register(i,{cacheKey:i.stableKey,instanceId:i.instanceId},i)}}g.set(i,U)}else{o.isProcessed=!0;const e=i.props.children,t=C(i.props,u);if(e){const s=Array.isArray(e)?e:[e];let n=0;for(let e=0;e<s.length;e++)a.NodeUtil.isNodeInstance(s[e])&&n++;r(y+n);for(let e=s.length-1;e>=0;e--){const n=s[e];if(!a.NodeUtil.isNodeInstance(n))continue;const r=a.NodeUtil.shouldCacheElement(n)?f.elementCache.get(n.stableKey):void 0,o=a.NodeUtil.shouldNodeUpdate(r?.prevDeps,n._deps,m);if(!o&&r?.renderedElement){g.set(n,r.renderedElement);continue}const i=m||!o;p[y++]={node:n,isProcessed:!1,blocked:i,theme:t}}}}}let o=g.get(this);if(!a.NodeUtil.isServer&&this.stableKey&&(o=e.createElement(i.default,{node:this},o)),a.NodeUtil.shouldCacheElement(this)){const e=f.elementCache.get(this.stableKey);if(e)e.prevDeps=this._deps,e.renderedElement=o,e.accessCount+=1;else{const e={prevDeps:this._deps,renderedElement:o,nodeRef:new WeakRef(this),createdAt:Date.now(),accessCount:1,instanceId:this.instanceId};f.elementCache.set(this.stableKey,e),f.cacheCleanupRegistry.register(this,{cacheKey:this.stableKey,instanceId:this.instanceId},this)}}return o}finally{for(let e=0;e<y;e++)p[e]=null;f.releaseRenderContext({workStack:p,renderedElements:g})}}static clearCaches(){const e=Array.from(f.elementCache.keys());r.__DEBUG__&&console.log(`[MeoNode] clearCaches: Clearing ${e.length} entries`);for(const t of e){const e=f.elementCache.get(t);if(e){const s=e.nodeRef?.deref();if(s)try{f.cacheCleanupRegistry.unregister(s),s.lastSignature=void 0,s.lastPropsObj=void 0}catch{r.__DEBUG__&&console.warn(`[MeoNode] Could not unregister ${t} from FinalizationRegistry`)}}}f.elementCache.clear(),o.MountTrackerUtil.cleanup(),r.__DEBUG__&&console.log("[MeoNode] All caches cleared")}}function y(e,t={},s){return new f(e,t,s)}y.clearCaches=f.clearCaches,exports.BaseNode=f,exports.Node=y,exports.createChildrenFirstNode=function(e,t){const s=(s,n,r)=>y(e,{...t,...n,children:s},r);return s.element=e,s},exports.createNode=function(e,t){const s=(s,n)=>y(e,{...t,...s},n);return s.element=e,s};
@@ -1 +1 @@
1
- "use strict";var e=require("../helper/common.helper.cjs");const t=Symbol.for("@meonode/ui/serverActiveTheme"),r=Symbol.for("@meonode/ui/serverThemeVariables");function o(e){return`--meonode-theme-${e.replace(/[^\w.-]/g,"-").replace(/\./g,"-")}`}function n(){return e.getGlobalState(r,()=>({byName:new Map}))}exports.consumeServerThemeVariablesCss=function(){const e=n();if(0===e.byName.size)return;const t=Array.from(e.byName.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${e}:${t};`).join("");return e.byName.clear(),t?{id:"theme-vars",cssText:`:root{${t}}`}:void 0},exports.getActiveServerTheme=function(){return e.getGlobalState(t,()=>({})).activeTheme},exports.registerServerThemeVariables=function(e){if(!e?.system||"object"!=typeof e.system)return;const t=n(),r=[{path:"",value:e.system}];for(;r.length>0;){const e=r.pop();if(!e||!e.value||"object"!=typeof e.value)continue;const n=e.value;for(const[s,a]of Object.entries(n)){const n=e.path?`${e.path}.${s}`:s;if(null!=a)if("string"!=typeof a&&"number"!=typeof a&&"boolean"!=typeof a){if("object"==typeof a){const e=a.default;"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e||t.byName.set(o(n),String(e)),r.push({path:n,value:a})}}else t.byName.set(o(n),String(a))}}},exports.replaceThemeTokensWithCssVars=function(e){const t=e=>e.replace(/theme\.([a-zA-Z0-9_.-]+)/g,(e,t)=>`var(${o(t)})`),r=e=>{if("string"==typeof e)return t(e);if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>r(e));const o={};for(const[n,s]of Object.entries(e)){o[t(n)]=r(s)}return o};return r(e)},exports.setActiveServerTheme=function(r){e.getGlobalState(t,()=>({})).activeTheme=r};
1
+ "use strict";var e=require("../helper/common.helper.cjs");const t=Symbol.for("@meonode/ui/serverActiveTheme"),o=Symbol.for("@meonode/ui/serverThemeVariables");function r(e){return`--meonode-theme-${e.replace(/[^\w.-]/g,"-").replace(/\./g,"-")}`}function n(){return e.getGlobalState(o,()=>({byName:new Map}))}exports.buildThemeVariablesCss=function(e){if(!e?.system||"object"!=typeof e.system)return"";const t=[],o=[{path:"",value:e.system}];for(;o.length>0;){const e=o.pop();if(!e||!e.value||"object"!=typeof e.value)continue;const n=e.value;for(const[s,a]of Object.entries(n)){const n=e.path?`${e.path}.${s}`:s;if(null!=a)if("string"!=typeof a&&"number"!=typeof a&&"boolean"!=typeof a){if("object"==typeof a){const e=a.default;"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e||t.push([r(n),String(e)]),o.push({path:n,value:a})}}else t.push([r(n),String(a)])}}return 0===t.length?"":`:root{${t.sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${e}:${t};`).join("")}}`},exports.consumeServerThemeVariablesCss=function(){const e=n();if(0===e.byName.size)return;const t=Array.from(e.byName.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${e}:${t};`).join("");return e.byName.clear(),t?{id:"theme-vars",cssText:`:root{${t}}`}:void 0},exports.getActiveServerTheme=function(){return e.getGlobalState(t,()=>({})).activeTheme},exports.registerServerThemeVariables=function(e){if(!e?.system||"object"!=typeof e.system)return;const t=n(),o=[{path:"",value:e.system}];for(;o.length>0;){const e=o.pop();if(!e||!e.value||"object"!=typeof e.value)continue;const n=e.value;for(const[s,a]of Object.entries(n)){const n=e.path?`${e.path}.${s}`:s;if(null!=a)if("string"!=typeof a&&"number"!=typeof a&&"boolean"!=typeof a){if("object"==typeof a){const e=a.default;"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e||t.byName.set(r(n),String(e)),o.push({path:n,value:a})}}else t.byName.set(r(n),String(a))}}},exports.replaceThemeTokensWithCssVars=function(e){const t=e=>e.replace(/theme\.([a-zA-Z0-9_.-]+)/g,(e,t)=>`var(${r(t)})`),o=e=>{if("string"==typeof e)return t(e);if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>o(e));const r={};for(const[n,s]of Object.entries(e)){r[t(n)]=o(s)}return r};return o(e)},exports.setActiveServerTheme=function(o){e.getGlobalState(t,()=>({})).activeTheme=o};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{useContext as e}from"react";import{jsx as t}from"@emotion/react";import{ThemeContext as o}from"./theme-provider.client.js";import{ThemeUtil as r}from"../util/theme.util.js";function s({element:s,children:m,...i}){const c=e(o),l=c?.theme,{css:n,...p}=i;let h=n,u=p;l&&(h=r.resolveObjWithTheme(n,l,{processFunctions:!0}),u=r.resolveObjWithTheme(p,l,{processFunctions:!1}));const a=r.resolveDefaultStyle(h);return t(s,{...u,css:a},m)}s.displayName="Styled",s.__meonodeAcceptsServerCss=!0;export{s as default};
2
+ import{useContext as e}from"react";import{jsx as t}from"@emotion/react";import{ThemeContext as r}from"./theme-provider.client.js";import{ThemeUtil as o}from"../util/theme.util.js";function s({element:s,children:m,...i}){const n=e(r),c=n?.theme,{css:l,...h}=i;let p=l,a=h;c&&(p=o.resolveObjWithTheme(l,c,{processFunctions:!0,themeStringsMode:"vars"}),a=o.resolveObjWithTheme(h,c,{processFunctions:!1,themeStringsMode:"vars"}));const d=o.resolveDefaultStyle(p);return t(s,{...a,css:d},m)}s.displayName="Styled",s.__meonodeAcceptsServerCss=!0;export{s as default};
@@ -1 +1 @@
1
- {"version":3,"file":"theme-provider.client.d.ts","sourceRoot":"","sources":["../../../src/components/theme-provider.client.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAG9D,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,CAAA;CAC7D;AAED,eAAO,MAAM,YAAY,mDAAgD,CAAA;AAEzE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,SAAS,CAmB3G"}
1
+ {"version":3,"file":"theme-provider.client.d.ts","sourceRoot":"","sources":["../../../src/components/theme-provider.client.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAA;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAI9D,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,CAAA;CAC7D;AAED,eAAO,MAAM,YAAY,mDAAgD,CAAA;AAEzE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,SAAS,CAiC3G"}
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{createContext as e,useState as o}from"react";import{Node as r}from"../core.node.js";const t=e(null);function n({children:e,theme:n}){const[m,c]=o(n);if(!n)throw new Error("`theme` prop must be defined");const d={theme:m,setTheme:e=>{"function"==typeof e&&(e=e(m)),document.cookie=`theme=${e.mode}; path=/;`,c(e)}};return r(t.Provider,{value:d,children:e}).render()}n.__meonodeAcceptsServerCss=!0,n.__meonodeProvidesServerTheme=!0;export{t as ThemeContext,n as default};
2
+ import{createContext as e,useState as t,useInsertionEffect as r}from"react";import{Node as o}from"../core.node.js";import{buildThemeVariablesCss as n}from"../util/server-theme.util.js";const m=e(null);function d({children:e,theme:d}){const[c,s]=t(d);if(!d)throw new Error("`theme` prop must be defined");const i={theme:c,setTheme:e=>{"function"==typeof e&&(e=e(c)),document.cookie=`theme=${e.mode}; path=/;`,s(e)}};return r(()=>{const e=n(c);if(!e)return;const t=document.createElement("style");return t.setAttribute("data-meonode-theme-vars",""),t.textContent=e,document.head.appendChild(t),()=>{t.remove()}},[c]),o(m.Provider,{value:i,children:e}).render()}d.__meonodeAcceptsServerCss=!0,d.__meonodeProvidesServerTheme=!0;export{m as ThemeContext,d as default};
@@ -1 +1 @@
1
- {"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../../src/core.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,SAAS,EACT,OAAO,EAGR,MAAM,yBAAyB,CAAA;AAkBhC;;;;;;GAMG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe;IAC/D,OAAO,CAAC,MAAM,CAAC,UAAU,CAAI;IACtB,UAAU,EAAE,MAAM,CAA8B;IAEhD,OAAO,EAAE,CAAC,CAAA;IACV,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAK;IAC3C,SAAgB,UAAU,QAAO;IAEjC,OAAO,CAAC,MAAM,CAAC,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAgB;IAChC,SAAS,CAA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Q,CAAC,EAAE,QAAQ,EACnB,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,EAC1E,IAAI,CAAC,EAAE,cAAc,KAClB,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG;IACtB,OAAO,EAAE,CAAC,CAAA;CACX,CAQJ"}
@@ -1 +1 @@
1
- import{Fragment as e,createElement as t}from"react";import{isValidElementType as n,isFragment as s}from"./helper/react-is.helper.js";import{getGlobalState as r,getComponentType as o,hasNoStyleTag as i,getElementTypeName as a}from"./helper/common.helper.js";import l from"./components/styled-renderer.client.js";import{__DEBUG__ as c}from"./constant/common.const.js";import{MountTrackerUtil as d}from"./util/mount-tracker.util.js";import h from"./components/meonode-unmounter.client.js";import{NavigationCacheManagerUtil as m}from"./util/navigation-cache-manager.util.js";import{NodeUtil as p}from"./util/node.util.js";import{compileServerEmotionClassName as u}from"./util/server-emotion.util.js";import{setActiveServerTheme as f,registerServerThemeVariables as g,getActiveServerTheme as y,replaceThemeTokensWithCssVars as C}from"./util/server-theme.util.js";import{ThemeUtil as v}from"./util/theme.util.js";const S=Symbol.for("@meonode/ui/BaseNode/elementCache"),b=Symbol.for("@meonode/ui/BaseNode/navigationStarted"),w=Symbol.for("@meonode/ui/BaseNode/renderContextPool"),k=Symbol.for("@meonode/ui/BaseNode/cacheCleanupRegistry");class j{static _idCounter=0;instanceId="m"+ ++j._idCounter;element;rawProps={};isBaseNode=!0;_props;_deps;stableKey;lastPropsObj;lastSignature;static get elementCache(){return r(S,()=>new Map)}static get _navigationStarted(){return r(b,()=>({value:!1})).value}static set _navigationStarted(e){r(b,()=>({value:!1})).value=e}static get renderContextPool(){return r(w,()=>[])}static acquireRenderContext(){const e=j.renderContextPool;return e.length>0?e.pop():{workStack:new Array(512),renderedElements:new Map}}static releaseRenderContext(e){j.renderContextPool.length<50&&e.workStack.length<2048&&(e.workStack.length=0,e.renderedElements.clear(),j.renderContextPool.push(e))}constructor(e,t={},s){if(!n(e)){const t=o(e);if(p.isNodeInstance(e))throw new Error("Invalid element type: MeoNode UI instance provided!");throw new Error(`Invalid element type: ${t} provided!`)}if(this.element=e,this.rawProps=t,this._deps=s,p.isServer&&p.providesServerTheme(e)){const e=t.theme;if(e&&"object"==typeof e&&"system"in e){const t=e;f(t),g(t)}}const{ref:r,children:i,...a}=t;this.stableKey=this._getStableKey(a),p.isServer||j._navigationStarted||(m.getInstance().start(),j._navigationStarted=!0)}get props(){return this._props||(this._props=p.processProps(this.rawProps,this.stableKey)),this._props}get dependencies(){return this._deps}_getStableKey({key:e,...t}){if(p.isServer)return;if(this.lastPropsObj===t)return this.lastSignature;this.lastPropsObj=t;const n=Object.keys(t),s=n.length;if(s>100){const e=p.extractCriticalProps(t,n);this.lastSignature=p.createPropSignature(this.element,e),c&&s>200&&console.warn(`MeoNode: Large props (${s} keys) on "${a(this.element)}". Consider splitting.`)}else this.lastSignature=p.createPropSignature(this.element,t);return null!=e?`${String(e)}:${this.lastSignature}`:this.lastSignature}static get cacheCleanupRegistry(){return r(k,()=>new FinalizationRegistry(e=>{const{cacheKey:t,instanceId:n}=e,s=j.elementCache.get(t);s?.instanceId===n&&j.elementCache.delete(t),d.isMounted(t)&&d.untrackMount(t)}))}render(n=!1){const r=p.shouldCacheElement(this)?j.elementCache.get(this.stableKey):void 0,o=p.shouldNodeUpdate(r?.prevDeps,this._deps,n);if(!o&&r?.renderedElement)return r.accessCount+=1,r.renderedElement;const a=!o,c=j.acquireRenderContext();let{workStack:d}=c;const{renderedElements:m}=c;let f=0;try{const n=e=>{if(e>d.length){const t=Math.max(e,d.length<<1),n=new Array(t);for(let e=0;e<f;e++)n[e]=d[e];d=n}};for(d[f++]={node:this,isProcessed:!1,blocked:a,theme:void 0};f>0;){const r=d[f-1];if(!r){f--;continue}const{node:o,isProcessed:a,blocked:c,theme:h}=r,g=(e,t)=>{const n=e.theme;return n&&"object"==typeof n&&"system"in n?n:t??y()},S=e=>{if(!e)return!1;if("string"==typeof e)return e.includes("theme.");if("function"==typeof e)return!0;if("object"!=typeof e)return!1;if(Array.isArray(e)){for(const t of e)if(S(t))return!0;return!1}for(const t of Object.values(e))if(S(t))return!0;return!1};if(a){f--;const{children:n,key:r,css:a,nativeProps:c,disableEmotion:d,...y}=o.props,b=g(o.props,h);let w=[];if(n){const e=Array.isArray(n)?n:[n],t=e.length;w=new Array(t);for(let n=0;n<t;n++){const t=e[n];if(p.isNodeInstance(t)){const e=m.get(t);if(!e)throw new Error(`[MeoNode] Missing rendered element for child node: ${t.stableKey}`);w[n]=e}else w[n]=t}}const k={...y,key:r,...c};let P;if(o.element===e||s(o.element))P=t(o.element,{key:r},...w);else{const e=!d&&(a||!i(o.element)),n=p.isServer&&"string"!=typeof o.element,s=e&&n&&p.isClientReference(o.element)&&S(a);if(e&&!n||s){const e=p.isServer?C(a):a;P=t(l,{element:o.element,...k,css:e,suppressHydrationWarning:!0},...w)}else if(e&&n&&!p.acceptsServerCss(o.element)){const e=v.resolveObjWithTheme(k,b,{processFunctions:!1}),n=v.resolveObjWithTheme(C(a),b,{processFunctions:!0,themeStringsMode:"vars"}),s=v.resolveDefaultStyle(n),r=u(s),i=[e.className,r].filter(Boolean).join(" ")||void 0,l=i?{...e,className:i}:e;P=t(o.element,l,...w)}else{const s=e&&(!n||p.acceptsServerCss(o.element))?{...k,css:a}:k;P=t(o.element,s,...w)}}if(o!==this&&p.shouldCacheElement(o)){const e=j.elementCache.get(o.stableKey);if(e)e.prevDeps=o._deps,e.renderedElement=P,e.accessCount+=1;else{const e={prevDeps:o._deps,renderedElement:P,nodeRef:new WeakRef(o),createdAt:Date.now(),accessCount:1,instanceId:o.instanceId};j.elementCache.set(o.stableKey,e),j.cacheCleanupRegistry.register(o,{cacheKey:o.stableKey,instanceId:o.instanceId},o)}}m.set(o,P)}else{r.isProcessed=!0;const e=o.props.children,t=g(o.props,h);if(e){const s=Array.isArray(e)?e:[e];let r=0;for(let e=0;e<s.length;e++)p.isNodeInstance(s[e])&&r++;n(f+r);for(let e=s.length-1;e>=0;e--){const n=s[e];if(!p.isNodeInstance(n))continue;const r=p.shouldCacheElement(n)?j.elementCache.get(n.stableKey):void 0,o=p.shouldNodeUpdate(r?.prevDeps,n._deps,c);if(!o&&r?.renderedElement){m.set(n,r.renderedElement);continue}const i=c||!o;d[f++]={node:n,isProcessed:!1,blocked:i,theme:t}}}}}let r=m.get(this);if(!p.isServer&&this.stableKey&&(r=t(h,{node:this},r)),p.shouldCacheElement(this)){const e=j.elementCache.get(this.stableKey);if(e)e.prevDeps=this._deps,e.renderedElement=r,e.accessCount+=1;else{const e={prevDeps:this._deps,renderedElement:r,nodeRef:new WeakRef(this),createdAt:Date.now(),accessCount:1,instanceId:this.instanceId};j.elementCache.set(this.stableKey,e),j.cacheCleanupRegistry.register(this,{cacheKey:this.stableKey,instanceId:this.instanceId},this)}}return r}finally{for(let e=0;e<f;e++)d[e]=null;j.releaseRenderContext({workStack:d,renderedElements:m})}}static clearCaches(){const e=Array.from(j.elementCache.keys());c&&console.log(`[MeoNode] clearCaches: Clearing ${e.length} entries`);for(const t of e){const e=j.elementCache.get(t);if(e){const n=e.nodeRef?.deref();if(n)try{j.cacheCleanupRegistry.unregister(n),n.lastSignature=void 0,n.lastPropsObj=void 0}catch{c&&console.warn(`[MeoNode] Could not unregister ${t} from FinalizationRegistry`)}}}j.elementCache.clear(),d.cleanup(),c&&console.log("[MeoNode] All caches cleared")}}function P(e,t={},n){return new j(e,t,n)}function _(e,t){const n=(n,s)=>P(e,{...t,...n},s);return n.element=e,n}function E(e,t){const n=(n,s,r)=>P(e,{...t,...s,children:n},r);return n.element=e,n}P.clearCaches=j.clearCaches;export{j as BaseNode,P as Node,E as createChildrenFirstNode,_ as createNode};
1
+ import{Fragment as e,createElement as t}from"react";import{isValidElementType as n,isFragment as s}from"./helper/react-is.helper.js";import{getGlobalState as r,getComponentType as o,hasNoStyleTag as i,getElementTypeName as a}from"./helper/common.helper.js";import l from"./components/styled-renderer.client.js";import{__DEBUG__ as c}from"./constant/common.const.js";import{MountTrackerUtil as d}from"./util/mount-tracker.util.js";import h from"./components/meonode-unmounter.client.js";import{NavigationCacheManagerUtil as m}from"./util/navigation-cache-manager.util.js";import{NodeUtil as p}from"./util/node.util.js";import{compileServerEmotionClassName as u}from"./util/server-emotion.util.js";import{setActiveServerTheme as f,registerServerThemeVariables as g,getActiveServerTheme as y,replaceThemeTokensWithCssVars as C}from"./util/server-theme.util.js";import{ThemeUtil as v}from"./util/theme.util.js";const S=Symbol.for("@meonode/ui/BaseNode/elementCache"),b=Symbol.for("@meonode/ui/BaseNode/navigationStarted"),w=Symbol.for("@meonode/ui/BaseNode/renderContextPool"),k=Symbol.for("@meonode/ui/BaseNode/cacheCleanupRegistry");class j{static _idCounter=0;instanceId="m"+ ++j._idCounter;element;rawProps={};isBaseNode=!0;_props;_deps;stableKey;lastPropsObj;lastSignature;static get elementCache(){return r(S,()=>new Map)}static get _navigationStarted(){return r(b,()=>({value:!1})).value}static set _navigationStarted(e){r(b,()=>({value:!1})).value=e}static get renderContextPool(){return r(w,()=>[])}static acquireRenderContext(){const e=j.renderContextPool;return e.length>0?e.pop():{workStack:new Array(512),renderedElements:new Map}}static releaseRenderContext(e){j.renderContextPool.length<50&&e.workStack.length<2048&&(e.workStack.length=0,e.renderedElements.clear(),j.renderContextPool.push(e))}constructor(e,t={},s){if(!n(e)){const t=o(e);if(p.isNodeInstance(e))throw new Error("Invalid element type: MeoNode UI instance provided!");throw new Error(`Invalid element type: ${t} provided!`)}if(this.element=e,this.rawProps=t,this._deps=s,p.isServer&&p.providesServerTheme(e)){const e=t.theme;if(e&&"object"==typeof e&&"system"in e){const t=e;f(t),g(t)}}const{ref:r,children:i,...a}=t;this.stableKey=this._getStableKey(a),p.isServer||j._navigationStarted||(m.getInstance().start(),j._navigationStarted=!0)}get props(){return this._props||(this._props=p.processProps(this.rawProps,this.stableKey)),this._props}get dependencies(){return this._deps}_getStableKey({key:e,...t}){if(p.isServer)return;if(this.lastPropsObj===t)return this.lastSignature;this.lastPropsObj=t;const n=Object.keys(t),s=n.length;if(s>100){const e=p.extractCriticalProps(t,n);this.lastSignature=p.createPropSignature(this.element,e),c&&s>200&&console.warn(`MeoNode: Large props (${s} keys) on "${a(this.element)}". Consider splitting.`)}else this.lastSignature=p.createPropSignature(this.element,t);return null!=e?`${String(e)}:${this.lastSignature}`:this.lastSignature}static get cacheCleanupRegistry(){return r(k,()=>new FinalizationRegistry(e=>{const{cacheKey:t,instanceId:n}=e,s=j.elementCache.get(t);s?.instanceId===n&&j.elementCache.delete(t),d.isMounted(t)&&d.untrackMount(t)}))}render(n=!1){const r=p.shouldCacheElement(this)?j.elementCache.get(this.stableKey):void 0,o=p.shouldNodeUpdate(r?.prevDeps,this._deps,n);if(!o&&r?.renderedElement)return r.accessCount+=1,r.renderedElement;const a=!o,c=j.acquireRenderContext();let{workStack:d}=c;const{renderedElements:m}=c;let f=0;try{const n=e=>{if(e>d.length){const t=Math.max(e,d.length<<1),n=new Array(t);for(let e=0;e<f;e++)n[e]=d[e];d=n}};for(d[f++]={node:this,isProcessed:!1,blocked:a,theme:void 0};f>0;){const r=d[f-1];if(!r){f--;continue}const{node:o,isProcessed:a,blocked:c,theme:h}=r,g=(e,t)=>{const n=e.theme;return n&&"object"==typeof n&&"system"in n?n:t??y()};if(a){f--;const{children:n,key:r,css:a,nativeProps:c,disableEmotion:d,...y}=o.props,S=g(o.props,h);let b=[];if(n){const e=Array.isArray(n)?n:[n],t=e.length;b=new Array(t);for(let n=0;n<t;n++){const t=e[n];if(p.isNodeInstance(t)){const e=m.get(t);if(!e)throw new Error(`[MeoNode] Missing rendered element for child node: ${t.stableKey}`);b[n]=e}else b[n]=t}}const w={...y,key:r,...c};let k;if(o.element===e||s(o.element))k=t(o.element,{key:r},...b);else{const e=!d&&(a||!i(o.element)),n=p.isServer&&"string"!=typeof o.element,s=e&&n&&p.isClientReference(o.element);if(e&&!n||s){const e=p.isServer?C(a):a;k=t(l,{element:o.element,...w,css:e},...b)}else if(e&&n&&!p.acceptsServerCss(o.element)){const e=v.resolveObjWithTheme(w,S,{processFunctions:!1}),n=v.resolveObjWithTheme(C(a),S,{processFunctions:!0,themeStringsMode:"vars"}),s=v.resolveDefaultStyle(n),r=u(s),i=[e.className,r].filter(Boolean).join(" ")||void 0,l=i?{...e,className:i}:e;k=t(o.element,l,...b)}else{const s=e&&(!n||p.acceptsServerCss(o.element))?{...w,css:a}:w;k=t(o.element,s,...b)}}if(o!==this&&p.shouldCacheElement(o)){const e=j.elementCache.get(o.stableKey);if(e)e.prevDeps=o._deps,e.renderedElement=k,e.accessCount+=1;else{const e={prevDeps:o._deps,renderedElement:k,nodeRef:new WeakRef(o),createdAt:Date.now(),accessCount:1,instanceId:o.instanceId};j.elementCache.set(o.stableKey,e),j.cacheCleanupRegistry.register(o,{cacheKey:o.stableKey,instanceId:o.instanceId},o)}}m.set(o,k)}else{r.isProcessed=!0;const e=o.props.children,t=g(o.props,h);if(e){const s=Array.isArray(e)?e:[e];let r=0;for(let e=0;e<s.length;e++)p.isNodeInstance(s[e])&&r++;n(f+r);for(let e=s.length-1;e>=0;e--){const n=s[e];if(!p.isNodeInstance(n))continue;const r=p.shouldCacheElement(n)?j.elementCache.get(n.stableKey):void 0,o=p.shouldNodeUpdate(r?.prevDeps,n._deps,c);if(!o&&r?.renderedElement){m.set(n,r.renderedElement);continue}const i=c||!o;d[f++]={node:n,isProcessed:!1,blocked:i,theme:t}}}}}let r=m.get(this);if(!p.isServer&&this.stableKey&&(r=t(h,{node:this},r)),p.shouldCacheElement(this)){const e=j.elementCache.get(this.stableKey);if(e)e.prevDeps=this._deps,e.renderedElement=r,e.accessCount+=1;else{const e={prevDeps:this._deps,renderedElement:r,nodeRef:new WeakRef(this),createdAt:Date.now(),accessCount:1,instanceId:this.instanceId};j.elementCache.set(this.stableKey,e),j.cacheCleanupRegistry.register(this,{cacheKey:this.stableKey,instanceId:this.instanceId},this)}}return r}finally{for(let e=0;e<f;e++)d[e]=null;j.releaseRenderContext({workStack:d,renderedElements:m})}}static clearCaches(){const e=Array.from(j.elementCache.keys());c&&console.log(`[MeoNode] clearCaches: Clearing ${e.length} entries`);for(const t of e){const e=j.elementCache.get(t);if(e){const n=e.nodeRef?.deref();if(n)try{j.cacheCleanupRegistry.unregister(n),n.lastSignature=void 0,n.lastPropsObj=void 0}catch{c&&console.warn(`[MeoNode] Could not unregister ${t} from FinalizationRegistry`)}}}j.elementCache.clear(),d.cleanup(),c&&console.log("[MeoNode] All caches cleared")}}function P(e,t={},n){return new j(e,t,n)}function _(e,t){const n=(n,s)=>P(e,{...t,...n},s);return n.element=e,n}function E(e,t){const n=(n,s,r)=>P(e,{...t,...s,children:n},r);return n.element=e,n}P.clearCaches=j.clearCaches;export{j as BaseNode,P as Node,E as createChildrenFirstNode,_ as createNode};
@@ -6,5 +6,11 @@ export declare function consumeServerThemeVariablesCss(): {
6
6
  id: string;
7
7
  cssText: string;
8
8
  } | undefined;
9
+ /**
10
+ * Builds the `:root{--meonode-theme-*: …}` CSS text directly from a Theme without
11
+ * touching the server-only variable store. Safe to call on the client for pure
12
+ * SPA flows (Vite/CRA) where there is no SSR emission to pick up.
13
+ */
14
+ export declare function buildThemeVariablesCss(theme: Theme): string;
9
15
  export declare function replaceThemeTokensWithCssVars<T>(value: T): T;
10
16
  //# sourceMappingURL=server-theme.util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-theme.util.d.ts","sourceRoot":"","sources":["../../../src/util/server-theme.util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAapD,wBAAgB,oBAAoB,IAAI,KAAK,GAAG,SAAS,CAExD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAEvD;AAUD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CA6B/D;AAED,wBAAgB,8BAA8B,IAAI;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAU5F;AAED,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAiB5D"}
1
+ {"version":3,"file":"server-theme.util.d.ts","sourceRoot":"","sources":["../../../src/util/server-theme.util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAapD,wBAAgB,oBAAoB,IAAI,KAAK,GAAG,SAAS,CAExD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAEvD;AAUD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CA6B/D;AAED,wBAAgB,8BAA8B,IAAI;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAU5F;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAmC3D;AAED,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAiB5D"}
@@ -1 +1 @@
1
- import{getGlobalState as e}from"../helper/common.helper.js";const t=Symbol.for("@meonode/ui/serverActiveTheme"),o=Symbol.for("@meonode/ui/serverThemeVariables");function r(){return e(t,()=>({})).activeTheme}function n(o){e(t,()=>({})).activeTheme=o}function s(e){return`--meonode-theme-${e.replace(/[^\w.-]/g,"-").replace(/\./g,"-")}`}function a(){return e(o,()=>({byName:new Map}))}function f(e){if(!e?.system||"object"!=typeof e.system)return;const t=a(),o=[{path:"",value:e.system}];for(;o.length>0;){const e=o.pop();if(!e||!e.value||"object"!=typeof e.value)continue;const r=e.value;for(const[n,a]of Object.entries(r)){const r=e.path?`${e.path}.${n}`:n;if(null!=a)if("string"!=typeof a&&"number"!=typeof a&&"boolean"!=typeof a){if("object"==typeof a){const e=a.default;"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e||t.byName.set(s(r),String(e)),o.push({path:r,value:a})}}else t.byName.set(s(r),String(a))}}}function i(){const e=a();if(0===e.byName.size)return;const t=Array.from(e.byName.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${e}:${t};`).join("");return e.byName.clear(),t?{id:"theme-vars",cssText:`:root{${t}}`}:void 0}function c(e){const t=e=>e.replace(/theme\.([a-zA-Z0-9_.-]+)/g,(e,t)=>`var(${s(t)})`),o=e=>{if("string"==typeof e)return t(e);if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>o(e));const r={};for(const[n,s]of Object.entries(e)){r[t(n)]=o(s)}return r};return o(e)}export{i as consumeServerThemeVariablesCss,r as getActiveServerTheme,f as registerServerThemeVariables,c as replaceThemeTokensWithCssVars,n as setActiveServerTheme};
1
+ import{getGlobalState as e}from"../helper/common.helper.js";const t=Symbol.for("@meonode/ui/serverActiveTheme"),o=Symbol.for("@meonode/ui/serverThemeVariables");function n(){return e(t,()=>({})).activeTheme}function r(o){e(t,()=>({})).activeTheme=o}function s(e){return`--meonode-theme-${e.replace(/[^\w.-]/g,"-").replace(/\./g,"-")}`}function f(){return e(o,()=>({byName:new Map}))}function a(e){if(!e?.system||"object"!=typeof e.system)return;const t=f(),o=[{path:"",value:e.system}];for(;o.length>0;){const e=o.pop();if(!e||!e.value||"object"!=typeof e.value)continue;const n=e.value;for(const[r,f]of Object.entries(n)){const n=e.path?`${e.path}.${r}`:r;if(null!=f)if("string"!=typeof f&&"number"!=typeof f&&"boolean"!=typeof f){if("object"==typeof f){const e=f.default;"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e||t.byName.set(s(n),String(e)),o.push({path:n,value:f})}}else t.byName.set(s(n),String(f))}}}function i(){const e=f();if(0===e.byName.size)return;const t=Array.from(e.byName.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${e}:${t};`).join("");return e.byName.clear(),t?{id:"theme-vars",cssText:`:root{${t}}`}:void 0}function c(e){if(!e?.system||"object"!=typeof e.system)return"";const t=[],o=[{path:"",value:e.system}];for(;o.length>0;){const e=o.pop();if(!e||!e.value||"object"!=typeof e.value)continue;const n=e.value;for(const[r,f]of Object.entries(n)){const n=e.path?`${e.path}.${r}`:r;if(null!=f)if("string"!=typeof f&&"number"!=typeof f&&"boolean"!=typeof f){if("object"==typeof f){const e=f.default;"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e||t.push([s(n),String(e)]),o.push({path:n,value:f})}}else t.push([s(n),String(f)])}}if(0===t.length)return"";return`:root{${t.sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${e}:${t};`).join("")}}`}function p(e){const t=e=>e.replace(/theme\.([a-zA-Z0-9_.-]+)/g,(e,t)=>`var(${s(t)})`),o=e=>{if("string"==typeof e)return t(e);if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>o(e));const n={};for(const[r,s]of Object.entries(e)){n[t(r)]=o(s)}return n};return o(e)}export{c as buildThemeVariablesCss,i as consumeServerThemeVariablesCss,n as getActiveServerTheme,a as registerServerThemeVariables,p as replaceThemeTokensWithCssVars,r as setActiveServerTheme};
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.4.4-beta.1",
4
+ "version": "1.4.4-beta.3",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "types": "./dist/main.d.ts",