@meonode/ui 0.2.20 → 0.3.0

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/core.node.js CHANGED
@@ -1,10 +1,9 @@
1
- "use strict";var _excluded=["ref","key","children","nodetheme","theme","props"],_excluded2=["style"],_excluded3=["style","css"],_excluded4=["style"],_excluded5=["children","key","nativeProps"];function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import React,{createElement,Fragment,isValidElement}from"react";import{createStableHash,isNodeInstance,resolveDefaultStyle}from"./helper/node.helper.js";import{isForwardRef,isFragment,isMemo,isReactClassComponent,isValidElementType}from"./helper/react-is.helper.js";import{createRoot}from"react-dom/client";import{getComponentType,getCSSProps,getDOMProps,getElementTypeName,hasNoStyleTag,omit,omitUndefined}from"./helper/common.helper.js";import StyledRenderer from"./components/styled-renderer.client.js";import{resolveObjWithTheme}from"./helper/theme.helper.js";/**
2
- * Represents a node in a React component tree with theme and styling capabilities.
1
+ "use strict";var _excluded=["ref","key","children","css","props"],_excluded2=["style"],_excluded3=["style"],_excluded4=["children","key","nativeProps"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import React,{createElement,Fragment,isValidElement}from"react";import{isNodeInstance}from"./helper/node.helper.js";import{isForwardRef,isFragment,isMemo,isReactClassComponent,isValidElementType}from"./helper/react-is.helper.js";import{createRoot}from"react-dom/client";import{getComponentType,getCSSProps,getDOMProps,getElementTypeName,hasNoStyleTag,omitUndefined}from"./helper/common.helper.js";import StyledRenderer from"./components/styled-renderer.client.js";/**
2
+ * Represents a node in a React component tree.
3
3
  * This class wraps React elements and handles:
4
4
  * - Props processing and normalization
5
- * - Theme inheritance and resolution
6
5
  * - Child node processing and management
7
- * - Style processing with theme variables
6
+ * - Style processing
8
7
  * @template E The type of React element or component this node represents
9
8
  */export class BaseNode{/**
10
9
  * Constructs a new BaseNode instance.
@@ -14,205 +13,155 @@
14
13
  * accessed via the `props` getter, allowing for lazy evaluation.
15
14
  * @param element The React element or component type this node will represent.
16
15
  * @param rawProps The initial, unprocessed props for the element.
17
- */constructor(a){var b=this,c=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};/** The underlying React element or component type that this node represents *//** Original props passed during construction, preserved for cloning/recreation *//** Flag to identify BaseNode instances *//** DOM element used for portal rendering *//** React root instance for portal rendering *//**
18
- * Generates a stable key for a node, especially for elements within an array.
19
- *
20
- * If an `existingKey` is provided, it is returned. Otherwise, a key is generated
21
- * based on the element's type name and its index within a list of siblings.
22
- * This helps prevent re-rendering issues in React when dealing with dynamic lists.
23
- * @param options The options for key generation.
24
- * @param options.nodeIndex The index of the node in an array of children.
25
- * @param options.element The element for which to generate a key.
26
- * @param options.existingKey An existing key, if one was already provided.
27
- * @param options.children The children of the node, used to add complexity to the key.
28
- * @returns A React key, or `undefined` if no key could be generated.
29
- * @private
30
- *//**
16
+ */constructor(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};/** The underlying React element or component type that this node represents *//** Original props passed during construction, preserved for cloning/recreation *//** Flag to identify BaseNode instances *//** DOM element used for portal rendering *//** React root instance for portal rendering *//**
31
17
  * Normalizes a processed child node into a final, renderable `ReactNode`.
32
18
  *
33
19
  * This method is called during the `render` phase. It takes a child that has already
34
20
  * been processed by `_processChildren` and prepares it for `React.createElement`.
35
21
  *
36
- * - For `BaseNode` instances, it calls their `render()` method, ensuring the theme is consistent.
22
+ * - For `BaseNode` instances, it calls their `render()` method.
37
23
  * - It validates that other children are valid React element types.
38
24
  * - Primitives and other valid nodes are returned as-is.
39
25
  * @param child The processed child node to normalize.
40
26
  * @returns A renderable `ReactNode`.
41
27
  * @throws {Error} If the child is not a valid React element type.
42
28
  * @private
43
- */_defineProperty(this,"rawProps",{}),_defineProperty(this,"isBaseNode",!0),_defineProperty(this,"_portalDOMElement",null),_defineProperty(this,"_portalReactRoot",null),_defineProperty(this,"_generateKey",function(a){var b=a.nodeIndex,c=a.element,d=a.existingKey,e=a.children;if(d)return d;var f,g=getElementTypeName(c);return f=Array.isArray(e)&&0<e.length?void 0===b?"".concat(g,"-").concat(e.length):"".concat(g,"-").concat(b,"-").concat(e.length):void 0===b?g:"".concat(g,"-").concat(b),f}),_defineProperty(this,"_normalizeChild",function(a){var c,d;// Handle null/undefined quickly
29
+ */_defineProperty(this,"rawProps",{}),_defineProperty(this,"isBaseNode",!0),_defineProperty(this,"_portalDOMElement",null),_defineProperty(this,"_portalReactRoot",null),_defineProperty(this,"_normalizeChild",function(a){// Handle null/undefined quickly
44
30
  if(null===a||a===void 0)return a;// Primitives should be returned as-is (text nodes, numbers, booleans)
45
- var e=_typeof(a);if("string"===e||"number"===e||"boolean"===e)return a;var f=(null===(c=b.rawProps)||void 0===c?void 0:c.nodetheme)||(null===(d=b.rawProps)||void 0===d?void 0:d.theme)||b.props.nodetheme||b.props.theme;// For BaseNode instances, apply current theme if child has no theme
46
- if(a instanceof BaseNode||isNodeInstance(a)){var g;return null!==(g=a.rawProps)&&void 0!==g&&g.nodetheme||void 0===f?a.render():new BaseNode(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{nodetheme:f})).render()}// Handle React.Component instances
31
+ var b=_typeof(a);if("string"===b||"number"===b||"boolean"===b)return a;// For BaseNode instances, apply current theme if child has no theme
32
+ if(a instanceof BaseNode||isNodeInstance(a))return a.render();// Handle React.Component instances
47
33
  if("function"==typeof a.render)// React.Component instance
48
34
  return a.render();// Validate element type before returning
49
- if(!isValidElementType(a)){var h=getComponentType(a);throw new Error("Invalid element type: ".concat(h," provided!"))}// Return valid React elements as-is
50
- return a}),this.element=a,this.rawProps=c}/**
35
+ if(!isValidElementType(a)){var c=getComponentType(a);throw new Error("Invalid element type: ".concat(c," provided!"))}// Return valid React elements as-is
36
+ return a}),this.element=a,this.rawProps=b}/**
51
37
  * Lazily processes and retrieves the final, normalized props for the node.
52
38
  *
53
39
  * The first time this getter is accessed, it triggers `_processProps` to resolve
54
- * themes, styles, and children. Subsequent accesses return the cached result
40
+ * styles, and children. Subsequent accesses return the cached result
55
41
  * until the node is cloned or recreated.
56
42
  * @returns The fully processed and normalized `FinalNodeProps`.
57
43
  */get props(){return this._props||(this._props=this._processProps()),this._props}/**
58
- * Performs the core logic of processing raw props into their final, normalized form.
59
- *
60
- * This method is called by the `props` getter on its first access. It handles:
61
- * 1. **Theme Resolution**: Selects the active theme from `theme` or `nodetheme` props.
62
- * 2. **Prop Resolution**: Resolves theme-aware values (functions) in `rawProps` and `nativeProps.style`.
63
- * 3. **Style Extraction**: Separates style-related props (`css`, `style`) from other DOM/component props.
64
- * 4. **Default Style Merging**: Combines default styles with resolved style props.
65
- * 5. **Child Processing**: Normalizes the `children` prop, propagating the theme.
66
- * @returns The processed `FinalNodeProps` object.
44
+ * Processes raw props into a final, normalized form.
45
+ * This includes:
46
+ * - Extracting and separating style-related props
47
+ * - Merging CSS-in-JS styles with other style props
48
+ * - Processing and normalizing children
49
+ * - Combining all parts into a single props object
67
50
  * @private
51
+ * @returns The processed `FinalNodeProps` ready for rendering.
68
52
  */_processProps(){// Destructure raw props into relevant parts
69
- var a=this.rawProps,b=a.ref,c=a.key,d=a.children,e=a.nodetheme,f=a.theme,g=a.props,h=void 0===g?{}:g,i=_objectWithoutProperties(a,_excluded),j=f||e,k=h,l=k.style,m=_objectWithoutProperties(k,_excluded2),n=resolveObjWithTheme(i,j),o=resolveObjWithTheme(l,j),p=n.style,q=n.css,r=_objectWithoutProperties(n,_excluded3),s=getCSSProps(r),t=getDOMProps(r),u=resolveDefaultStyle(_objectSpread(_objectSpread({},s),p)),v=this._processChildren(d,j),w=omitUndefined(_objectSpread(_objectSpread({ref:b,key:c,nodetheme:j,theme:f,css:_objectSpread(_objectSpread({},u),q),style:o},t),{},{nativeProps:m,children:v}));// Process children while maintaining theme inheritance
53
+ var a=this.rawProps,b=a.ref,c=a.key,d=a.children,e=a.css,f=a.props,g=void 0===f?{}:f,h=_objectWithoutProperties(a,_excluded),i=g,j=i.style,k=_objectWithoutProperties(i,_excluded2),l=getCSSProps(h),m=getDOMProps(h),n=this._processChildren(d);// Process children
70
54
  // Combine processed props into final normalized form
71
- // Special handling for standard HTML tags vs custom components
72
- return"string"==typeof this.element&&(hasNoStyleTag(this.element)?w=omit(w,"css","style","theme","nodetheme"):w=omit(w,"theme","nodetheme")),w}/**
73
- * Deeply clones processed children before returning them from cache so that each parent receives
74
- * independent `BaseNode` instances (prevents sharing cycles and mutation bugs).
75
- *
76
- * - If the input is an array, each child is cloned recursively.
77
- * - If the input is a `BaseNode`, a new instance is created with the same element and copied rawProps.
78
- * - For other objects/primitives, the value is returned as-is (they are immutable or safe to reuse).
55
+ return omitUndefined(_objectSpread(_objectSpread({ref:b,key:c,css:_objectSpread(_objectSpread({},l),e),style:j},m),{},{nativeProps:k,children:n}))}/**
56
+ * Recursively processes raw children, converting them into `BaseNode` instances as needed.
79
57
  *
80
- * This ensures that cached children are never shared between different parents in the React tree.
81
- * @param processed The processed child or array of children to clone.
82
- * @returns A deep clone of the processed children, safe for use in multiple parents.
83
- * @private
84
- */static _cloneProcessedChildren(a){var b=function cloneOne(a){return a instanceof BaseNode?new BaseNode(a.element,_objectSpread({},a.rawProps)):a;// NodeInstance returns its own instances when render() is called - we avoid calling render here.
85
- // For other objects/primitives, return as-is (they are immutable or safe to reuse).
86
- };return Array.isArray(a)?a.map(function(a){return b(a)}):b(a)}/**
87
- * Retrieves cached processed children for a given set of `children` and an optional `theme`.
88
- *
89
- * - Skips caching entirely when executed on the server (returns `null`).
90
- * - Uses a **WeakMap** for identity-based caching when `children` is an object or array,
91
- * ensuring garbage collection safety.
92
- * - Falls back to a **Map** keyed by a stable hash of `children` and `theme`
93
- * for value-based caching.
94
- * - Only returns cached entries that are **not server-side**.
95
- * @param children The child node(s) to resolve cached results for.
96
- * @param theme The theme context that may influence child processing.
97
- * @returns A cloned version of the cached processed children if available, otherwise `null`.
98
- * @private
99
- */_getCachedChildren(a,b){if(BaseNode._isServer)return null;// No server caching
100
- // Compute hash once
101
- var c=createStableHash(a,b);// If children is an object (array or object), try identity-keyed WeakMap first
102
- if(a&&"object"===_typeof(a)){var d=BaseNode._processedChildrenWeakCache.get(a);if(d&&d.hash===c&&!d.isServerSide)return BaseNode._cloneProcessedChildren(d.children)}// Fallback to string-hash Map cache
103
- var e=BaseNode._processedChildrenMapCache.get(c);return e&&!e.isServerSide?BaseNode._cloneProcessedChildren(e.children):null}/**
104
- * Caches processed children for a given set of children and theme.
105
- * This method stores the processed NodeElement(s) in a Map keyed by a stable hash.
106
- * The cache is bounded to avoid unbounded memory growth.
107
- * No caching is performed on the server to avoid RSC issues.
108
- * @param children The original children to cache.
109
- * @param theme The theme associated with the children.
110
- * @param processed The processed NodeElement(s) to cache.
111
- * @private
112
- */_setCachedChildren(a,b,c){if(!BaseNode._isServer){var d=createStableHash(a,b);if(a&&"object"===_typeof(a))return void BaseNode._processedChildrenWeakCache.set(a,{hash:d,children:c,isServerSide:!1});// Manage bounded Map cache (FIFO eviction)
113
- if(BaseNode._processedChildrenMapCache.has(d))return void BaseNode._processedChildrenMapCache.set(d,{children:c,isServerSide:!1});if(BaseNode._processedChildrenMapCache.size>=BaseNode._MAX_PROCESSED_CHILDREN_CACHE){var e=BaseNode._processedChildrenMapCache.keys().next().value;void 0!==e&&BaseNode._processedChildrenMapCache["delete"](e)}BaseNode._processedChildrenMapCache.set(d,{children:c,isServerSide:!1})}}/**
114
- * Recursively processes raw children, converting them into `BaseNode` instances as needed
115
- * and propagating the provided theme.
116
- *
117
- * This method ensures consistent theme handling for all children and optimizes performance
118
- * using caching strategies: a Map for client-side and no caching for server-side.
58
+ * This method ensures consistent handling for all children.
119
59
  *
120
60
  * - If `children` is an array, each child is processed individually.
121
61
  * - If `children` is a single node, it is processed directly.
122
- * - The processed result is cached on the client to avoid redundant work.
123
62
  * @param children The raw child or array of children to process.
124
- * @param theme The theme to propagate to the children.
125
63
  * @returns The processed children, ready for normalization and rendering.
126
64
  * @private
127
- */_processChildren(a,b){var c=this;if(a){// Use RSC-safe caching strategy
128
- var d=this._getCachedChildren(a,b);if(d)return d;var e;return e="function"==typeof a?a:Array.isArray(a)?a.map(function(a,d){return c._processRawNode(a,b,d)}):this._processRawNode(a,b),BaseNode._isServer||this._setCachedChildren(a,b,e),e}}/**
129
- * Renders a processed `NodeElement` into a `ReactNode`, applying a theme and key if necessary.
65
+ */_processChildren(a){if(a){var b;return b="function"==typeof a?a:Array.isArray(a)?a.map(function(a,b){return BaseNode._processRawNode(a,b)}):BaseNode._processRawNode(a),b}}/**
66
+ * Renders a processed `NodeElement` into a `ReactNode`, applying a key if necessary.
130
67
  *
131
68
  * This static method centralizes the logic for converting various types of processed elements
132
69
  * into renderable React nodes. It handles:
133
- * - `BaseNode` instances: Re-wraps them to apply a new key or theme.
70
+ * - `BaseNode` instances: Re-wraps them to apply a new key.
134
71
  * - React class components: Wraps them in a new `BaseNode`.
135
72
  * - `NodeInstance` objects: Invokes their `render()` method.
136
73
  * - React component instances: Invokes their `render()` method.
137
74
  * - Functional components: Creates a React element from them.
138
75
  * - Other valid `ReactNode` types (strings, numbers, etc.): Returns them as-is.
139
76
  * @param processedElement The node element to render.
140
- * @param passedTheme The theme to propagate.
141
77
  * @param passedKey The React key to assign.
142
78
  * @returns A renderable `ReactNode`.
143
79
  * @private
144
80
  * @static
145
- */static _renderProcessedNode(a,b,c){var d={};// 1. BaseNode instance: re-wrap to apply key/theme if needed
146
- if(void 0!==c&&(d.key=c),a instanceof BaseNode){var e,f,g,h,i,j=(null===(e=a.rawProps)||void 0===e?void 0:e.theme)||(null===(f=a.rawProps)||void 0===f?void 0:f.nodetheme)||b,k=null===(g=a.rawProps)||void 0===g?void 0:g.key;return k===c&&j===((null===(h=a.rawProps)||void 0===h?void 0:h.nodetheme)||(null===(i=a.rawProps)||void 0===i?void 0:i.theme))?a.render():new BaseNode(a.element,_objectSpread(_objectSpread(_objectSpread({},a.rawProps),d),{},{nodetheme:j})).render()}// 2. React class component type: wrap in BaseNode
147
- return isReactClassComponent(a)?new BaseNode(a,d).render():isNodeInstance(a)?a.render():a instanceof React.Component?a.render():"function"==typeof a?createElement(a,{key:c}):a;// 3. NodeInstance object: call its render
81
+ */static _renderProcessedNode(a,b){var c={};// 1. BaseNode instance: re-wrap to apply key/theme if needed
82
+ if(void 0!==b&&(c.key=b),a instanceof BaseNode||isNodeInstance(a)){var d,e=null===(d=a.rawProps)||void 0===d?void 0:d.key;return e===b?a.render():new BaseNode(a.element,_objectSpread(_objectSpread({},a.rawProps),c)).render()}// 2. React class component type: wrap in BaseNode
83
+ return isReactClassComponent(a)?new BaseNode(a,c).render():isNodeInstance(a)?a.render():a instanceof React.Component?a.render():"function"==typeof a?createElement(a,{key:b}):a;// 3. NodeInstance object: call its render
148
84
  // 4. React.Component instance: call its render
149
85
  // 5. Functional component: create element with key
150
86
  // 6. Other valid ReactNode types
151
87
  }/**
152
- * Determines if a raw node is a function that should be treated as a render prop.
153
- * @param rawNode
88
+ * Renders this node into a `ReactNode`, handling function node element.
89
+ * @param node The node to render.
154
90
  * @private
155
- */_isFunctionChild(a){// Basic function check
156
- return!("function"!=typeof a)&&!isReactClassComponent(a)&&!isMemo(a)&&!isForwardRef(a)&&!("displayName"in a&&a.displayName&&/^[A-Z]/.test(a.displayName))&&!(a.name&&/^[A-Z]/.test(a.name))&&!(a.prototype&&"function"==typeof a.prototype.render);// Exclude React component types
157
- // Check if it's a component function vs render function
158
- // Component functions typically have displayName, name starting with capital, or prototype
159
- // If function has prototype properties (likely a constructor), it's probably a component
160
- }/**
161
- * Renders the output of a function-as-a-child, ensuring theme propagation.
91
+ * @static
92
+ * @example
93
+ * ```typescript
94
+ * const myNode = Node('div', { children: [ () => 'Hello' ] });
95
+ * ```
96
+ */static _isFunctionChild(a){// Basic function check
97
+ if("function"!=typeof a)return!1;// Exclude React component types
98
+ if(isReactClassComponent(a))return!1;if(isMemo(a))return!1;if(isForwardRef(a))return!1;try{// Try to check if it's a React component instance using prototype
99
+ return!(a.prototype&&"function"==typeof a.prototype.render)}catch(a){// If accessing prototype fails (due to cross-realm), assume it's a function child
100
+ return!0}}/**
101
+ * Renders the output of a function-as-a-child.
162
102
  *
163
103
  * This method is designed to handle "render prop" style children (`() => ReactNode`).
164
- * It invokes the function, processes its result, and ensures the parent's theme is
165
- * correctly passed down to any `BaseNode` instances returned by the function.
104
+ * It invokes the function and processes its result.
166
105
  * @param props The properties for the function renderer.
167
106
  * @param props.render The function to execute to get the child content.
168
- * @param props.passedTheme The theme to propagate to the rendered child.
169
- * @param props.processRawNode A reference to the `_processRawNode` method for recursive processing.
170
107
  * @returns The rendered `ReactNode`.
171
108
  * @private
172
- */_functionRenderer(a){var b,c=a.render,d=a.passedTheme,e=a.processRawNode;// Invoke the render function to get the child node.
109
+ */static _functionRenderer(a){var b,c=a.render;// Invoke the render function to get the child node.
173
110
  try{b=c()}catch(a){b=null}// Handle null/undefined
174
111
  if(null===b||b===void 0)return b;// Handle arrays of elements (common in render props)
175
- if(Array.isArray(b))return b.map(function(a,b){var c=e(a,d,b);return BaseNode._renderProcessedNode(c,d,"".concat(getElementTypeName(a),"-").concat(b))});// Handle React.Component instance
176
- if(b instanceof React.Component){var f=b.render(),g=e(f,d);return BaseNode._renderProcessedNode(g,d)}// Handle BaseNode instance or NodeInstance
177
- if(b instanceof BaseNode||isNodeInstance(b)){var h,i=b;// If nodetheme is missing and passedTheme exists, inject it
178
- return void 0===(null===(h=i.rawProps)||void 0===h?void 0:h.nodetheme)&&void 0!==d?new BaseNode(i.element,_objectSpread(_objectSpread({},i.rawProps),{},{nodetheme:d})).render():i.render()}// Handle primitives and valid React nodes (JSX, string, number, boolean)
179
- if("string"==typeof b||"number"==typeof b||"boolean"==typeof b||b&&"object"===_typeof(b)&&"$$typeof"in b// React JSX element
180
- )return b;// Process any other result types
181
- var j=e?e(b,d):b;return j?BaseNode._renderProcessedNode(j,d):b}/**
112
+ if(Array.isArray(b))return b.map(function(a,b){var c=BaseNode._processRawNode(a,b);return BaseNode._renderProcessedNode(c,"".concat(getElementTypeName(a),"-").concat(b))});// Handle React.Component instance
113
+ if(b instanceof React.Component){var d=b.render(),e=BaseNode._processRawNode(d);return BaseNode._renderProcessedNode(e)}// Handle BaseNode instance or NodeInstance
114
+ if(b instanceof BaseNode||isNodeInstance(b))return b.render();// Handle primitives and valid React nodes (string, number, boolean)
115
+ if("string"==typeof b||"number"==typeof b||"boolean"==typeof b)return b;// Process any other result types
116
+ var f=BaseNode._processRawNode(b);return f?BaseNode._renderProcessedNode(f):b}/**
117
+ * Generates a stable key for a node, especially for elements within an array.
118
+ *
119
+ * If an `existingKey` is provided, it is returned. Otherwise, a key is generated
120
+ * based on the element's type name and its index within a list of siblings.
121
+ * This helps prevent re-rendering issues in React when dealing with dynamic lists.
122
+ * @param options The options for key generation.
123
+ * @param options.nodeIndex The index of the node in an array of children.
124
+ * @param options.element The element for which to generate a key.
125
+ * @param options.existingKey An existing key, if one was already provided.
126
+ * @param options.children The children of the node, used to add complexity to the key.
127
+ * @returns A React key, or `undefined` if no key could be generated.
128
+ * @private
129
+ * @static
130
+ *//**
182
131
  * Processes a single raw node, recursively converting it into a `BaseNode` or other renderable type.
183
132
  *
184
133
  * This is a central method for normalizing children. It handles various types of input:
185
- * - **`BaseNode` instances**: Re-creates them to ensure the correct theme and key are applied.
134
+ * - **`BaseNode` instances**: Re-creates them to ensure the correct key is applied.
186
135
  * - **Primitives**: Returns strings, numbers, booleans, null, and undefined as-is.
187
136
  * - **Functions (Render Props)**: Wraps them in a `BaseNode` that uses `_functionRenderer` to delay execution.
188
- * - **Valid React Elements**: Converts them into `BaseNode` instances, extracting props and propagating the theme.
189
- * - **React Component Types**: Wraps them in a `BaseNode` with the parent theme.
137
+ * - **Valid React Elements**: Converts them into `BaseNode` instances, extracting props.
138
+ * - **React Component Types**: Wraps them in a `BaseNode`.
190
139
  * - **React Component Instances**: Renders them and processes the output recursively.
191
140
  *
192
141
  * It also generates a stable key for elements within an array if one is not provided.
193
- * @param rawNode The raw child node to process.
194
- * @param parentTheme The theme inherited from the parent.
142
+ * @param node The raw child node to process.
195
143
  * @param nodeIndex The index of the child if it is in an array, used for key generation.
196
144
  * @returns A processed `NodeElement` (typically a `BaseNode` instance or a primitive).
197
145
  * @private
198
- */_processRawNode(a,b,c// Index for generating stable keys for array children
199
- ){var d=getComponentType(a);// Determine the type of the raw node
146
+ * @static
147
+ */static _processRawNode(a,b// Index for generating stable keys for array children
148
+ ){var c=getComponentType(a);// Determine the type of the raw node
200
149
  // Case 1: Child is already a BaseNode instance
201
- if(a instanceof BaseNode){var e=a,f=e.rawProps||{},g=f.theme||f.nodetheme||b;// Get initial raw props of the child
202
- // Prefer child's own theme
150
+ if(a instanceof BaseNode||isNodeInstance(a)){var d=a.rawProps||{};// Get initial raw props of the child
203
151
  // Check if we can reuse the existing node
204
- if(f.nodetheme===g&&f.key!==void 0)return e;var h=this._generateKey({nodeIndex:c,element:e.element,existingKey:f.key,children:f.children});// Generate key if needed
205
- return new BaseNode(e.element,_objectSpread(_objectSpread({},f),{},{nodetheme:g,// Use the determined theme for the new node
206
- key:h}));// Create a new BaseNode with merged props and theme
152
+ if(d.key!==void 0)return a;var e=BaseNode._generateKey({nodeIndex:b,element:a.element,existingKey:d.key,children:d.children});// Generate key if needed
153
+ return new BaseNode(a.element,_objectSpread(_objectSpread({},d),{},{key:e}));// Create a new BaseNode with merged props and theme
207
154
  }// Case 2: Child is a primitive (string, number, boolean, null, undefined)
208
- if("string"===d||"number"===d||"boolean"===d||null===a||void 0===a)return a;// Case 3: Child is a function that needs to be called during render (FunctionRenderer).
209
- if(this._isFunctionChild(a)){var i=this._generateKey({nodeIndex:c,element:this._functionRenderer});return new BaseNode(this._functionRenderer,{processRawNode:this._processRawNode.bind(this),render:a,passedTheme:b,key:i})}// Case 4: Child is a React Element (JSX element like <div> or <MyComponent>)
210
- if(isValidElement(a)){var j=a.props,k=j.style,l=_objectWithoutProperties(j,_excluded4),m=_objectSpread(_objectSpread({},l),k||{}),n=m.theme||m.nodetheme||b,o=this._generateKey({nodeIndex:c,element:a.type,existingKey:a.key,children:m.children});return new BaseNode(a.type,_objectSpread(_objectSpread({},m),{},{nodetheme:n,key:o}))}// Case 5: Child is an ElementType (string tag, class component, Memo/ForwardRef)
211
- if(isReactClassComponent(a)||"object"===d&&(isMemo(a)||isForwardRef(a))){var p,q=this._generateKey({nodeIndex:c,element:a,children:"object"===_typeof(a)&&"props"in a?null===(p=a.props)||void 0===p?void 0:p.children:void 0});// ElementTypes don't have an intrinsic key from the rawNode itself.
212
- return new BaseNode(a,{nodetheme:b,// Apply parent theme
213
- key:q})}// Case 6: Handle instances of React.Component
214
- if(a instanceof React.Component){var r=a.render();// Recursively process the rendered element with a parent theme and index if available
215
- return this._processRawNode(r,b,c)}// Case 7: Fallback for other ReactNode types (e.g., Fragments, Portals if not caught by isValidElement)
155
+ if("string"===c||"number"===c||"boolean"===c||null===a||void 0===a)return a;// Case 3: Child is a function that needs to be called during render (FunctionRenderer).
156
+ if(BaseNode._isFunctionChild(a)){// The key is for the BaseNode that wraps the _functionRenderer component.
157
+ // Functions themselves don't have a .key prop that we can access here.
158
+ var f=BaseNode._generateKey({nodeIndex:b,element:BaseNode._functionRenderer});// Generate key for function renderer
159
+ return new BaseNode(BaseNode._functionRenderer,{render:a,key:f})}// Case 4: Child is a React Element (JSX element like <div> or <MyComponent>)
160
+ if(isValidElement(a)){var g=a.props,h=g.style,i=_objectWithoutProperties(g,_excluded3),j=_objectSpread(_objectSpread({},i),h||{}),k=BaseNode._generateKey({nodeIndex:b,element:a.type,existingKey:a.key,children:j.children});return new BaseNode(a.type,_objectSpread(_objectSpread({},j),{},{key:k}))}// Case 5: Child is an ElementType (string tag, class component, Memo/ForwardRef)
161
+ if(isReactClassComponent(a)||"object"===c&&(isMemo(a)||isForwardRef(a))){var l,m=BaseNode._generateKey({nodeIndex:b,element:a,children:"object"===_typeof(a)&&"props"in a?null===(l=a.props)||void 0===l?void 0:l.children:void 0});// ElementTypes don't have an intrinsic key from the node itself.
162
+ return new BaseNode(a,{key:m})}// Case 6: Handle instances of React.Component
163
+ if(a instanceof React.Component){var n=a.render();// Recursively process the rendered element with a parent theme and index if available
164
+ return BaseNode._processRawNode(n,b)}// Case 7: Fallback for other ReactNode types (e.g., Fragments, Portals if not caught by isValidElement)
216
165
  // These are returned as-is. If they are elements within an array, React expects them to have keys.
217
166
  // This logic primarily adds keys to BaseNode instances we create, other ReactNodes are returned as-is.
218
167
  return a}/**
@@ -230,7 +179,7 @@ return a}/**
230
179
  * @returns The rendered `ReactElement`.
231
180
  * @throws {Error} If the node's `element` is not a valid React element type.
232
181
  */render(){var a=this;if(!isValidElementType(this.element)){var b=getComponentType(this.element);throw new Error("Invalid element type: ".concat(b," provided!"))}// Extract children and key
233
- var c=this.props,d=c.children,e=c.key,f=c.nativeProps,g=_objectWithoutProperties(c,_excluded5),h=void 0;if(d!==void 0&&null!==d){if(!this._normalizedChildren||this._childrenHash!==createStableHash(d,this.props.nodetheme||this.props.theme))if(!Array.isArray(d))this._normalizedChildren=this._normalizeChild(d);else if(0<d.length){var i=d.map(function(b){return a._normalizeChild(b)});this._normalizedChildren=i.every(function(a){return null===a||void 0===a})?void 0:i}else this._normalizedChildren=void 0;h=this._normalizedChildren}// If the element is a Fragment, use React.createElement directly
182
+ var c=this.props,d=c.children,e=c.key,f=c.nativeProps,g=_objectWithoutProperties(c,_excluded4),h=void 0;if(d!==void 0&&null!==d){if(!this._normalizedChildren)if(!Array.isArray(d))this._normalizedChildren=this._normalizeChild(d);else if(0<d.length){var i=d.map(function(b){return a._normalizeChild(b)});this._normalizedChildren=i.every(function(a){return null===a||void 0===a})?void 0:i}else this._normalizedChildren=void 0;h=this._normalizedChildren}// If the element is a Fragment, use React.createElement directly
234
183
  if(this.element===Fragment||isFragment(this.element))return createElement(this.element,{key:e},h);// If the element has a `css` prop and has style tag, render using the `StyledRenderer` component
235
184
  // This enables emotion-based style handling for the element
236
185
  if(this.element&&!hasNoStyleTag(this.element)&&g.css){// Set displayName for easier debugging in React DevTools
@@ -285,7 +234,7 @@ return this._portalReactRoot}}}/**
285
234
  * @param props The props for the node (optional).
286
235
  * @param additionalProps Additional props to merge into the node (optional).
287
236
  * @returns A new `BaseNode` instance as a `NodeInstance<E>`.
288
- */_defineProperty(BaseNode,"_isServer","undefined"==typeof window),_defineProperty(BaseNode,"_processedChildrenWeakCache",new WeakMap),_defineProperty(BaseNode,"_processedChildrenMapCache",new Map),_defineProperty(BaseNode,"_MAX_PROCESSED_CHILDREN_CACHE",1e3);export function Node(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},d=_objectSpread(_objectSpread({},b),c);return d.theme&&!d.nodetheme&&(d.nodetheme=d.theme),new BaseNode(a,d)}/**
237
+ */_defineProperty(BaseNode,"_isServer","undefined"==typeof window),_defineProperty(BaseNode,"_generateKey",function(a){var b=a.nodeIndex,c=a.element,d=a.existingKey,e=a.children;if(d)return d;var f,g=getElementTypeName(c);return f=Array.isArray(e)&&0<e.length?void 0===b?"".concat(g,"-").concat(e.length):"".concat(g,"-").concat(b,"-").concat(e.length):void 0===b?g:"".concat(g,"-").concat(b),f});export function Node(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=_objectSpread(_objectSpread({},b),c);return new BaseNode(a,d)}/**
289
238
  * Creates a curried node factory for a given React element or component type.
290
239
  *
291
240
  * Returns a function that, when called with props, produces a `NodeInstance<E>`.
@@ -1,5 +1,5 @@
1
1
  import type { CSSProperties } from 'react';
2
- import type { Children, NodeInstance, Theme } from '../node.type.js';
2
+ import type { NodeInstance } from '../node.type.js';
3
3
  /**
4
4
  * Type guard to check if an object is a NodeInstance.
5
5
  *
@@ -893,14 +893,4 @@ export declare const resolveDefaultStyle: (style: CSSProperties) => {
893
893
  minHeight: import("csstype").Property.MinHeight<string | number>;
894
894
  minWidth: import("csstype").Property.MinWidth<string | number>;
895
895
  };
896
- /**
897
- * Public: createStableHash
898
- * Produces a deterministic string signature for children + theme.
899
- * Keep traversal limited so it is cheap in large trees.
900
- *
901
- * If you prefer a shorter hashed output, wrap the returned string in a lightweight
902
- * hash function (fnv1a, xxhash, etc.). Returning the full signature is useful
903
- * for debugging and deterministic comparisons.
904
- */
905
- export declare function createStableHash(children: Children, theme?: Theme): string;
906
896
  //# sourceMappingURL=node.hel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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiE/B,CAAA"}
@@ -1,4 +1,4 @@
1
- "use strict";var _excluded=["flex"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}import{getElementTypeName}from"./common.helper.js";import{ObjHelper}from"./obj.helper.js";/**
1
+ "use strict";var _excluded=["flex"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}/**
2
2
  * Type guard to check if an object is a NodeInstance.
3
3
  *
4
4
  * A NodeInstance is expected to be a non-null object with:
@@ -109,24 +109,4 @@ if(!f){var k="column"===d.flexDirection||"column-reverse"===d.flexDirection,l="r
109
109
  return _objectSpread({flex:c,// Preserve original flex shorthand
110
110
  flexShrink:j,// Apply computed or explicit flexShrink
111
111
  minHeight:0,// Fix flex item scrolling issues
112
- minWidth:0},d)};/**
113
- * Create a stable signature for a React node (children) with bounded traversal.
114
- * This focuses on the structural identity important for rendering decisions:
115
- * - element type (string or component name)
116
- * - key (if present)
117
- * - basic children shape (recursing within limits)
118
- */function nodeSignature(a){var b=Math.min,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:5,d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:6,e=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new WeakSet;if(null===a)return"null";if(void 0===a)return"undefined";var f=_typeof(a);if("string"===f)return"s:".concat(a);if("number"===f)return"n:".concat(a+"");if("boolean"===f)return"b:".concat(a+"");if("function"===f)return"\u0192:(".concat(a+"",")");if("symbol"===f)return"sym:".concat(a+"");// Circular reference check for all objects
119
- if("object"===f){if(e.has(a))return"[Circular]";e.add(a)}// Arrays
120
- if(Array.isArray(a)){if(0>=c)return"ary[...]";for(var g=[],h=b(a.length,d),j=0;j<h;j++)g.push(nodeSignature(a[j],c-1,d,e));return a.length>d&&g.push("...len:".concat(a.length)),"ary[".concat(g.join(","),"]")}// React element-ish: require a 'type' property
121
- if("object"===f&&a&&"type"in a){// Type can be string (div) or function/class. Use helper to get name.
122
- var l,m=a.type;try{l=getElementTypeName(m)}catch(a){try{l=m+""}catch(a){l="unknown"}}var n,o="object"===f&&"key"in a&&null!=a.key?"#".concat(a.key+""):"",p="props"in a&&"object"===_typeof(a.props)&&a.props||{};try{n=nodeSignature(p.children,c-1,d,e)}catch(a){n="<err>"}var q=p.id?"@id:".concat(p.id+""):"",r=p.className?"@class:".concat(p.className+""):"";return"el:".concat(l).concat(o).concat(q).concat(r,"{").concat(n,"}")}// Plain object: handles any other object
123
- if("object"===f&&a){if(0>=c)return"obj[...]";for(var s,t=Object.keys(a).sort(),u=[],v=b(t.length,d),w=0;w<v;w++){s=t[w];try{u.push("".concat(s,":").concat(nodeSignature(a[s],c-1,d,e)))}catch(a){u.push("".concat(s,":<err>"))}}return t.length>d&&u.push("...keys:".concat(t.length)),"obj{".concat(u.join(","),"}")}// Fallback
124
- try{return"o:".concat(a+"")}catch(a){return"o:<unserializable>"}}/**
125
- * Public: createStableHash
126
- * Produces a deterministic string signature for children + theme.
127
- * Keep traversal limited so it is cheap in large trees.
128
- *
129
- * If you prefer a shorter hashed output, wrap the returned string in a lightweight
130
- * hash function (fnv1a, xxhash, etc.). Returning the full signature is useful
131
- * for debugging and deterministic comparisons.
132
- */export function createStableHash(a,b){var c=b?ObjHelper.stringify(b,6):"theme:undefined",d=nodeSignature(a,6,8);return"".concat(c,"|").concat(d)}
112
+ minWidth:0},d)};
@@ -1,64 +1,4 @@
1
- import type { Theme } from '../node.type.js';
2
- /**
3
- * Cache manager for theme resolution operations.
4
- * Provides singleton-based caching with different strategies for server vs client environments.
5
- */
6
- declare class ThemeResolverCache {
7
- private static _instance;
8
- private readonly _resolutionCache;
9
- private readonly _pathLookupCache;
10
- private readonly _themeRegex;
11
- // Track cache statistics for performance monitoring
12
- private _stats;
13
- private constructor();
14
- /**
15
- * Get the singleton instance of the cache manager
16
- */
17
- static getInstance(): ThemeResolverCache;
18
- /**
19
- * Generate a stable cache key from object and theme
20
- */
21
- private _generateCacheKey;
22
- /**
23
- * Check if resolution result exists in cache
24
- */
25
- getResolution(obj: Record<string, any>, theme: Theme): any | null;
26
- /**
27
- * Store resolution result in cache
28
- */
29
- setResolution(obj: Record<string, any>, theme: Theme, result: any): void;
30
- /**
31
- * Get cached theme path lookup
32
- */
33
- getPathLookup(theme: Theme, path: string): any | null;
34
- /**
35
- * Cache theme path lookup result
36
- */
37
- setPathLookup(theme: Theme, path: string, value: any): void;
38
- /**
39
- * Get the shared regex instance (reused for performance)
40
- */
41
- getThemeRegex(): RegExp;
42
- /**
43
- * Clear all caches (useful for testing or memory management)
44
- */
45
- clearCaches(): void;
46
- /**
47
- * Get cache statistics for performance monitoring
48
- */
49
- getStats(): {
50
- hits: number;
51
- misses: number;
52
- pathHits: number;
53
- pathMisses: number;
54
- };
55
- /**
56
- * Check if we should use caching (server-side only for RSC optimization)
57
- */
58
- shouldCache(): boolean;
59
- }
60
- // Module-level cache instance
61
- declare const themeCache: ThemeResolverCache;
1
+ import type { ThemeSystem } from '../node.type.js';
62
2
  /**
63
3
  * Resolves theme variable references in an object's values recursively.
64
4
  * This function performs a "smart merge" to maintain object reference identity
@@ -71,9 +11,5 @@ declare const themeCache: ThemeResolverCache;
71
11
  * @returns A new object (or array) with all theme variables resolved to their corresponding values,
72
12
  * or the original object (or array) if no changes were necessary.
73
13
  */
74
- export declare const resolveObjWithTheme: (obj?: Record<string, any>, theme?: Partial<{
75
- [key: string]: any;
76
- }> | undefined) => any;
77
- // Export cache instance for testing and monitoring
78
- export { themeCache as ThemeResolverCache };
14
+ export declare const resolveObjWithTheme: (obj?: Record<string, any>, theme?: ThemeSystem | undefined) => any;
79
15
  //# sourceMappingURL=theme.helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.helper.d.ts","sourceRoot":"","sources":["../../src/helper/theme.helper.ts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mDAAmD;AACnD,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,CAAA"}
1
+ {"version":3,"file":"theme.helper.d.ts","sourceRoot":"","sources":["../../src/helper/theme.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AA8GpD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,qEAwI/B,CAAA"}
@@ -1,4 +1,4 @@
1
- function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import{getValueByPath}from"./common.helper.js";import{ObjHelper}from"./obj.helper.js";/**
1
+ function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import{getValueByPath}from"./common.helper.js";import{ObjHelper}from"./obj.helper.js";/**
2
2
  * Cache manager for theme resolution operations.
3
3
  * Provides singleton-based caching with different strategies for server vs client environments.
4
4
  */class ThemeResolverCache{constructor(){// Track cache statistics for performance monitoring
@@ -19,10 +19,6 @@ return"".concat(ObjHelper.stringify(a),"_").concat(ObjHelper.stringify(b))}/**
19
19
  */setPathLookup(a,b,c){var d="".concat(ObjHelper.stringify(a),"_").concat(b);this._pathLookupCache.set(d,c)}/**
20
20
  * Get the shared regex instance (reused for performance)
21
21
  */getThemeRegex(){return this._themeRegex.lastIndex=0,this._themeRegex}/**
22
- * Clear all caches (useful for testing or memory management)
23
- */clearCaches(){this._resolutionCache.clear(),this._pathLookupCache.clear(),this._stats={hits:0,misses:0,pathHits:0,pathMisses:0}}/**
24
- * Get cache statistics for performance monitoring
25
- */getStats(){return _objectSpread({},this._stats)}/**
26
22
  * Check if we should use caching (server-side only for RSC optimization)
27
23
  */shouldCache(){return"undefined"==typeof window}}// Module-level cache instance
28
24
  _defineProperty(ThemeResolverCache,"_instance",null);var themeCache=ThemeResolverCache.getInstance();/**
@@ -55,5 +51,4 @@ g=g.replace(i,function(a,c){// Check path lookup cache first
55
51
  var d=themeCache.getPathLookup(b,c);return null===d&&(d=getValueByPath(b,c),themeCache.setPathLookup(b,c,d)),void 0!==d&&null!==d?(h=!0,"object"===_typeof(d)&&!Array.isArray(d)&&"default"in d?d["default"]:d):a}),f=h&&g!==e?g:e}else"object"===_typeof(e)&&null!==e&&(// Recursively process nested objects or arrays
56
52
  f=d(e,c));f===e?l&&(k[n]=e):(!l&&(k=_objectSpread({},a),l=!0),k[n]=f)};for(var n in a)m();return k},e=d(a,new Set);// Perform the resolution
57
53
  // Cache the result (only on server-side)
58
- return themeCache.shouldCache()&&themeCache.setResolution(a,b,e),e};// Export cache instance for testing and monitoring
59
- export{themeCache as ThemeResolverCache};
54
+ return themeCache.shouldCache()&&themeCache.setResolution(a,b,e),e};
@@ -1,32 +1,29 @@
1
- import type { Children, ComponentNode, HasCSSCompatibleStyleProp, Theme } from '../node.type.js';
1
+ import type { Children, ComponentNode, HasCSSCompatibleStyleProp } from '../node.type.js';
2
2
  import { type CSSProperties, type ReactElement } from 'react';
3
3
  /**
4
4
  * Props definition for components wrapped using the `Component` higher-order function.
5
5
  *
6
6
  * This type adapts based on whether the underlying component defines its own props:
7
7
  *
8
- * - If `TProps` is `undefined`, only `children` and `theme` can be passed.
8
+ * - If `TProps` is `undefined`, only `children` can be passed.
9
9
  * - If `TProps` is defined, the component will accept:
10
10
  * - The full prop shape `TProps`
11
11
  * - Optional `props` to override part of `TProps` (excluding `children`)
12
12
  * - Optional `children`
13
- * - Optional `theme`
14
13
  *
15
14
  * If the component supports inline styles (determined via `HasCSSCompatibleStyleProp`), the props also allow `CSSProperties`.
16
15
  */
17
16
  export type ComponentNodeProps<TProps> = TProps extends undefined ? Partial<{
18
17
  children: Children;
19
- theme: Theme;
20
18
  }> : TProps & (HasCSSCompatibleStyleProp<TProps> extends true ? CSSProperties : object) & Partial<{
21
19
  props: Partial<Omit<TProps, 'children'>>;
22
20
  children: Children;
23
- theme: Theme;
24
21
  }>;
25
22
  /**
26
23
  * Creates a component from a function that uses no custom props.
27
24
  * @template TProps Must be `undefined`
28
- * @param component A function that returns a MeoNode `ComponentNode` and only uses basic props like `children` and `theme`.
29
- * @returns A React-compatible component that can accept `children` and `theme`.
25
+ * @param component A function that returns a MeoNode `ComponentNode` and only uses basic props like `children`.
26
+ * @returns A React-compatible component that can accept `children`.
30
27
  * @example
31
28
  * ```ts
32
29
  * const Title = Component((props) => {
@@ -41,7 +38,7 @@ export declare function Component<TProps extends undefined>(component: (props: C
41
38
  * Creates a component from a function that uses a defined props interface.
42
39
  * @template TProps Props interface expected by the component.
43
40
  * @param component A function that returns a MeoNode `ComponentNode` using props of type `TProps`.
44
- * @returns A React-compatible component that supports full prop shape and `theme`/`children`/`props` overrides.
41
+ * @returns A React-compatible component that supports full prop shape and `children`/`props` overrides.
45
42
  * @example
46
43
  * ```ts
47
44
  * interface ButtonProps {
@@ -1 +1 @@
1
- {"version":3,"file":"component.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/component.hoc.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClG,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AAG7E;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,kBAAkB,CAAC,MAAM,IAAI,MAAM,SAAS,SAAS,GAC7D,OAAO,CA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