@meonode/ui 1.4.4-beta.2 → 1.4.4-beta.4
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/core.node.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("./helper/react-is.helper.cjs"),
|
|
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("react"),t=require("../helper/react-is.helper.cjs"),r=require("../helper/common.helper.cjs"),o=require("../constant/common.const.cjs"),n=require("../core.node.cjs");const s=Symbol.for("@meonode/ui/NodeUtil/functionSignatureCache");class i{constructor(){}static readBooleanFlag(e,t){if("function"!=typeof e)return!1;try{return!0===e[t]}catch{return!1}}static isServer="undefined"==typeof window;static get _functionSignatureCache(){return r.getGlobalState(s,()=>new WeakMap)}static CRITICAL_PROPS=new Set(["css","className","disableEmotion","props"]);static _propFuncCache=new WeakMap;static isClientReference(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return!1;try{return e.$$typeof===Symbol.for("react.client.reference")}catch{return!1}}static acceptsServerCss(e){return i.readBooleanFlag(e,"__meonodeAcceptsServerCss")}static providesServerTheme(e){return i.readBooleanFlag(e,"__meonodeProvidesServerTheme")}static isNodeInstance=e=>e instanceof n.BaseNode;static isStyleProp=i.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=Math.imul(r,33)^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(i.isServer)return;const o=r.getElementTypeName(e),n=Object.keys(t);n.length>1&&n.sort();const s=[`${o}:`];if("function"==typeof e){let t=i._functionSignatureCache.get(e);t||(t=i.hashString(e.toString()),i._functionSignatureCache.set(e,t)),s.push(t)}for(const e of n){const r=t[e];let o;const n=typeof r;if("string"===n||"number"===n||"boolean"===n)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"===n){let t=i._propFuncCache.get(r);t||(t=i.hashString(r.toString()),i._propFuncCache.set(r,t)),o=`${e}:${t};`}else{o=`${e}:{${Object.keys(r).sort().join(",")}};`}s.push(o)}return i.hashString(s.join(","))}static extractCriticalProps(e,t){const r={_keyCount:t.length};let o=0;for(const n of t){if(o>=50)break;if(i.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&&i.isStyleProp(n)&&(r[n]=e[n],o++):(r[n]=e[n],o++):(r[n]=e[n],o++)}return r}static processProps(e={},t){const{ref:o,key:n,children:s,css:c,props:a={},disableEmotion:d,...l}=e;if(0===Object.keys(l).length&&!c)return r.omitUndefined({ref:o,key:n,disableEmotion:d,nativeProps:r.omitUndefined(a),children:i._processChildren(s,d)});const
|
|
1
|
+
"use strict";var e=require("react"),t=require("../helper/react-is.helper.cjs"),r=require("../helper/common.helper.cjs"),o=require("../constant/common.const.cjs"),n=require("../core.node.cjs");const s=Symbol.for("@meonode/ui/NodeUtil/functionSignatureCache");class i{constructor(){}static readBooleanFlag(e,t){if("function"!=typeof e)return!1;try{return!0===e[t]}catch{return!1}}static isServer="undefined"==typeof window;static get _functionSignatureCache(){return r.getGlobalState(s,()=>new WeakMap)}static CRITICAL_PROPS=new Set(["css","className","disableEmotion","props"]);static _propFuncCache=new WeakMap;static isClientReference(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return!1;try{return e.$$typeof===Symbol.for("react.client.reference")}catch{return!1}}static acceptsServerCss(e){return i.readBooleanFlag(e,"__meonodeAcceptsServerCss")}static providesServerTheme(e){return i.readBooleanFlag(e,"__meonodeProvidesServerTheme")}static isNodeInstance=e=>e instanceof n.BaseNode;static isStyleProp=i.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=Math.imul(r,33)^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(i.isServer)return;const o=r.getElementTypeName(e),n=Object.keys(t);n.length>1&&n.sort();const s=[`${o}:`];if("function"==typeof e){let t=i._functionSignatureCache.get(e);t||(t=i.hashString(e.toString()),i._functionSignatureCache.set(e,t)),s.push(t)}for(const e of n){const r=t[e];let o;const n=typeof r;if("string"===n||"number"===n||"boolean"===n)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"===n){let t=i._propFuncCache.get(r);t||(t=i.hashString(r.toString()),i._propFuncCache.set(r,t)),o=`${e}:${t};`}else{o=`${e}:{${Object.keys(r).sort().join(",")}};`}s.push(o)}return i.hashString(s.join(","))}static extractCriticalProps(e,t){const r={_keyCount:t.length};let o=0;for(const n of t){if(o>=50)break;if(i.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&&i.isStyleProp(n)&&(r[n]=e[n],o++):(r[n]=e[n],o++):(r[n]=e[n],o++)}return r}static processProps(e={},t){const{ref:o,key:n,children:s,css:c,props:a={},disableEmotion:d,...l}=e;if(0===Object.keys(l).length&&!c)return r.omitUndefined({ref:o,key:n,disableEmotion:d,nativeProps:r.omitUndefined(a),children:i._processChildren(s,d)});const f={},p={},u=Object.keys(l);for(let e=0;e<u.length;e++){const t=u[e],r=l[t],o=typeof r;"string"===o||"number"===o||"boolean"===o?f[t]=r:p[t]=r}const y=r.getCSSProps(f),m=r.getCSSProps(p),h=r.getDOMProps(l),b={...y,...m,...c},g=i._processChildren(s,d,t);return r.omitUndefined({ref:o,key:n,css:b,...h,disableEmotion:d,nativeProps:r.omitUndefined(a),children:g})}static _processChildren(e,t,r){if(e)return"function"==typeof e?e:Array.isArray(e)?1===e.length?i.processRawNode(e[0],t,`${r}_0`):e.map((e,o)=>i.processRawNode(e,t,`${r}_${o}`)):i.processRawNode(e,t,r)}static shouldCacheElement(e){return!i.isServer&&!!e.stableKey&&!!e.dependencies}static shouldNodeUpdate(e,t,r){if(i.isServer)return!0;if(r)return!1;if(void 0===t)return!0;if(void 0===e)return!0;if(t.length!==e.length)return!0;for(let r=0;r<t.length;r++)if(!Object.is(t[r],e[r]))return!0;return!1}static processRawNode(r,o,s){if(null==r||"string"==typeof r||"number"==typeof r||"boolean"==typeof r)return r;if(i.isNodeInstance(r)){if(s||o&&!r.rawProps.disableEmotion){const e=new n.BaseNode(r.element,r.rawProps,r.dependencies);return e.stableKey=`${s}:${e.stableKey}`,o&&!e.rawProps.disableEmotion&&(e.rawProps.disableEmotion=!0),e}return r}if(i.isFunctionChild(r))return new n.BaseNode(i.functionRenderer,{props:{render:r,disableEmotion:o}},void 0);if(e.isValidElement(r)){const e=r.type;if(e&&"object"==typeof e){const t=e.$$typeof;if(t===Symbol.for("react.client.reference")||t===Symbol.for("react.lazy")||t===Symbol.for("react.memo")||t===Symbol.for("react.forward_ref"))return r}if("string"==typeof r.type){const{style:e,...t}=r.props,s={...t,...e||{}};return new n.BaseNode(r.type,{...s,...null!==r.key&&void 0!==r.key?{key:r.key}:{},disableEmotion:o},void 0)}return new n.BaseNode(r.type,{...r.props,...null!==r.key&&void 0!==r.key?{key:r.key}:{},disableEmotion:o},void 0)}return t.isReactClassComponent(r)||t.isMemo(r)||t.isForwardRef(r)?new n.BaseNode(r,{disableEmotion:o},void 0):r instanceof e.Component?i.processRawNode(r.render(),o,s):r}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 o.__DEBUG__&&console.error("MeoNode: Error checking if a node is a function child.",e),!0}}static functionRenderer({render:t,disableEmotion:s}){let c;try{c=t()}catch(e){o.__DEBUG__&&console.error("MeoNode: Error executing function-as-a-child.",e),c=null}if(null==c||"string"==typeof c||"number"==typeof c||"boolean"==typeof c)return c;if(i.isNodeInstance(c))return s&&!c.rawProps.disableEmotion?new n.BaseNode(c.element,{...c.rawProps,disableEmotion:!0}).render():c.render();if(Array.isArray(c)){const e=(e,t)=>{try{return`${r.getElementTypeName(e)}-${t}`}catch(e){return o.__DEBUG__&&console.error("MeoNode: Could not determine element type name for key in function-as-a-child.",e),`item-${t}`}};return c.map((t,r)=>i.renderProcessedNode({processedElement:i.processRawNode(t,s),passedKey:e(t,r),disableEmotion:s}))}if(c instanceof e.Component)return i.renderProcessedNode({processedElement:i.processRawNode(c.render(),s),disableEmotion:s});const a=i.processRawNode(c,s);return a?i.renderProcessedNode({processedElement:a,disableEmotion:s}):c}static renderProcessedNode({processedElement:r,passedKey:o,disableEmotion:s}){const c={};if(void 0!==o&&(c.key=o),i.isNodeInstance(r)){const e=r.rawProps?.key;return r.rawProps.disableEmotion=s,e===o?r.render():new n.BaseNode(r.element,{...r.rawProps,...c}).render()}return t.isReactClassComponent(r)?new n.BaseNode(r,{...c,disableEmotion:s}).render():r instanceof e.Component?r.render():"function"==typeof r?e.createElement(r,{key:o}):r}}exports.NodeUtil=i;
|
|
@@ -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,CAAC,EAAE,MAAM,CAAA;IAGzB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAEtC,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,WAAkB,YAAY,oDAE7B;IAGD,OAAO,CAAC,MAAM,KAAK,kBAAkB,GAEpC;IAED,OAAO,CAAC,MAAM,KAAK,kBAAkB,QAEpC;IAGD,OAAO,CAAC,MAAM,KAAK,iBAAiB,GAEnC;IAED,OAAO,CAAC,MAAM,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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()}
|
|
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};
|
|
@@ -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,EAEf,MAAM,yBAAyB,CAAA;AAQhC;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,OAAO;IAEP,OAAO,CAAC,MAAM,CAAC,eAAe;IA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BAAgB,CAAC,CAAC,SAAS,eAAe,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS;IA6D7I;;;;;;;;;;;;OAYG;WACW,mBAAmB,CAAC,EAChC,gBAAgB,EAChB,SAAS,EACT,cAAc,GACf,EAAE;QACD,gBAAgB,EAAE,WAAW,CAAA;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,cAAc,CAAC,EAAE,OAAO,CAAA;KACzB;CA+BF"}
|
|
@@ -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
|
|
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 f}from"../constant/common.const.js";import{BaseNode as p}from"../core.node.js";const u=Symbol.for("@meonode/ui/NodeUtil/functionSignatureCache");class y{constructor(){}static readBooleanFlag(e,t){if("function"!=typeof e)return!1;try{return!0===e[t]}catch{return!1}}static isServer="undefined"==typeof window;static get _functionSignatureCache(){return i(u,()=>new WeakMap)}static CRITICAL_PROPS=new Set(["css","className","disableEmotion","props"]);static _propFuncCache=new WeakMap;static isClientReference(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return!1;try{return e.$$typeof===Symbol.for("react.client.reference")}catch{return!1}}static acceptsServerCss(e){return y.readBooleanFlag(e,"__meonodeAcceptsServerCss")}static providesServerTheme(e){return y.readBooleanFlag(e,"__meonodeProvidesServerTheme")}static isNodeInstance=e=>e instanceof p;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=Math.imul(r,33)^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){let t=y._propFuncCache.get(r);t||(t=y.hashString(r.toString()),y._propFuncCache.set(r,t)),o=`${e}:${t};`}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){const{ref:r,key:o,children:n,css:s,props:i={},disableEmotion:c,...f}=e;if(0===Object.keys(f).length&&!s)return a({ref:r,key:o,disableEmotion:c,nativeProps:a(i),children:y._processChildren(n,c)});const p={},u={},h=Object.keys(f);for(let e=0;e<h.length;e++){const t=h[e],r=f[t],o=typeof r;"string"===o||"number"===o||"boolean"===o?p[t]=r:u[t]=r}const m=l(p),b=l(u),g=d(f),C={...m,...b,...s},S=y._processChildren(n,c,t);return a({ref:r,key:o,css:C,...g,disableEmotion:c,nativeProps:a(i),children:S})}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){if(y.isServer)return!0;if(r)return!1;if(void 0===t)return!0;if(void 0===e)return!0;if(t.length!==e.length)return!0;for(let r=0;r<t.length;r++)if(!Object.is(t[r],e[r]))return!0;return!1}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 e=r.type;if(e&&"object"==typeof e){const t=e.$$typeof;if(t===Symbol.for("react.client.reference")||t===Symbol.for("react.lazy")||t===Symbol.for("react.memo")||t===Symbol.for("react.forward_ref"))return 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?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 f&&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){f&&console.error("MeoNode: Error executing function-as-a-child.",e),o=null}if(null==o||"string"==typeof o||"number"==typeof o||"boolean"==typeof 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 f&&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});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}}export{y 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.4.4-beta.
|
|
4
|
+
"version": "1.4.4-beta.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@emotion/styled": "^11.14.1",
|
|
57
57
|
"@eslint/js": "^10.0.1",
|
|
58
58
|
"@mui/material": "^9.0.0",
|
|
59
|
+
"@playwright/test": "^1.59.1",
|
|
59
60
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
60
61
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
61
62
|
"@rollup/plugin-terser": "^1.0.0",
|