@meonode/ui 1.4.4-beta.1 → 1.4.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/styled-renderer.client.cjs +1 -1
- package/dist/cjs/components/theme-provider.client.cjs +1 -1
- package/dist/cjs/core.node.cjs +1 -1
- package/dist/cjs/util/server-theme.util.cjs +1 -1
- package/dist/esm/components/styled-renderer.client.js +1 -1
- package/dist/esm/components/theme-provider.client.d.ts.map +1 -1
- package/dist/esm/components/theme-provider.client.js +1 -1
- package/dist/esm/core.node.d.ts.map +1 -1
- package/dist/esm/core.node.js +1 -1
- package/dist/esm/util/server-theme.util.d.ts +6 -0
- package/dist/esm/util/server-theme.util.d.ts.map +1 -1
- package/dist/esm/util/server-theme.util.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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;
|
package/dist/cjs/core.node.cjs
CHANGED
|
@@ -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
|
|
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},...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 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../helper/common.helper.cjs");const t=Symbol.for("@meonode/ui/serverActiveTheme"),
|
|
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
|
|
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,
|
|
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
|
|
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,CAA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CAKJ;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,sBAAsB,EAAE,CAAC,SAAS,eAAe,EAAE,iBAAiB,SAAS,MAAM,GAAG,MAAM,EAClI,OAAO,EAAE,CAAC,EACV,YAAY,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,GACvE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GACxC,CAAC,CAAC,eAAe,GAAG,SAAS,EAAE,UAAU,SAAS,MAAM,GAAG,MAAM,EAC/D,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,WAAW,CAAC,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,EACzE,IAAI,CAAC,EAAE,cAAc,KAClB,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,GACtC,CAAC,CAAC,eAAe,GAAG,SAAS,EAAE,UAAU,SAAS,MAAM,GAAG,MAAM,EAC/D,QAAQ,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"}
|
package/dist/esm/core.node.js
CHANGED
|
@@ -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
|
|
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},...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};
|
|
@@ -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
|
|
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.
|
|
4
|
+
"version": "1.4.4-beta.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|