@meonode/ui 0.4.11 → 0.4.13

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.
Files changed (158) hide show
  1. package/CHANGELOG.md +32 -2
  2. package/dist/cjs/client.js +1 -0
  3. package/dist/cjs/components/html.node.js +1 -0
  4. package/dist/cjs/components/meonode-unmounter.client.js +2 -0
  5. package/dist/cjs/components/react.node.js +1 -0
  6. package/dist/cjs/components/registry.client.js +2 -0
  7. package/dist/cjs/components/styled-renderer.client.js +2 -0
  8. package/dist/cjs/components/theme-provider.client.js +2 -0
  9. package/dist/cjs/components/theme-provider.js +1 -0
  10. package/dist/cjs/constant/common.const.js +1 -0
  11. package/dist/{constant → cjs/constant}/css-properties.const.js +1 -1
  12. package/dist/cjs/core.node.js +1 -0
  13. package/dist/cjs/helper/common.helper.js +1 -0
  14. package/dist/cjs/helper/obj.helper.js +1 -0
  15. package/dist/cjs/helper/react-is.helper.js +1 -0
  16. package/dist/cjs/hoc/component.hoc.js +1 -0
  17. package/dist/cjs/hoc/portal.hoc.js +1 -0
  18. package/dist/cjs/hook/usePortal.js +2 -0
  19. package/dist/cjs/hook/useTheme.js +2 -0
  20. package/dist/cjs/main.js +1 -0
  21. package/dist/cjs/nextjs-registry/index.js +1 -0
  22. package/dist/cjs/util/mount-tracker.util.js +1 -0
  23. package/dist/cjs/util/navigation-cache-manager.util.js +1 -0
  24. package/dist/cjs/util/node.util.js +1 -0
  25. package/dist/cjs/util/theme.util.js +1 -0
  26. package/dist/esm/client.d.ts.map +1 -0
  27. package/dist/esm/client.js +1 -0
  28. package/dist/esm/components/html.node.d.ts.map +1 -0
  29. package/dist/esm/components/html.node.js +1 -0
  30. package/dist/{components → esm/components}/meonode-unmounter.client.d.ts +1 -1
  31. package/dist/esm/components/meonode-unmounter.client.d.ts.map +1 -0
  32. package/dist/esm/components/meonode-unmounter.client.js +2 -0
  33. package/dist/esm/components/react.node.d.ts.map +1 -0
  34. package/dist/esm/components/react.node.js +1 -0
  35. package/dist/esm/components/registry.client.d.ts.map +1 -0
  36. package/dist/esm/components/registry.client.js +2 -0
  37. package/dist/esm/components/styled-renderer.client.d.ts.map +1 -0
  38. package/dist/esm/components/styled-renderer.client.js +2 -0
  39. package/dist/esm/components/theme-provider.client.d.ts.map +1 -0
  40. package/dist/esm/components/theme-provider.client.js +2 -0
  41. package/dist/esm/components/theme-provider.d.ts.map +1 -0
  42. package/dist/esm/components/theme-provider.js +1 -0
  43. package/dist/esm/constant/common.const.d.ts.map +1 -0
  44. package/dist/esm/constant/common.const.js +1 -0
  45. package/dist/esm/constant/css-properties.const.d.ts.map +1 -0
  46. package/dist/esm/constant/css-properties.const.js +1 -0
  47. package/dist/esm/core.node.d.ts.map +1 -0
  48. package/dist/esm/core.node.js +1 -0
  49. package/dist/esm/helper/common.helper.d.ts.map +1 -0
  50. package/dist/esm/helper/common.helper.js +1 -0
  51. package/dist/esm/helper/obj.helper.d.ts.map +1 -0
  52. package/dist/esm/helper/obj.helper.js +1 -0
  53. package/dist/esm/helper/react-is.helper.d.ts.map +1 -0
  54. package/dist/esm/helper/react-is.helper.js +1 -0
  55. package/dist/esm/hoc/component.hoc.d.ts.map +1 -0
  56. package/dist/esm/hoc/component.hoc.js +1 -0
  57. package/dist/esm/hoc/index.d.ts.map +1 -0
  58. package/dist/esm/hoc/portal.hoc.d.ts.map +1 -0
  59. package/dist/esm/hoc/portal.hoc.js +1 -0
  60. package/dist/esm/hook/index.d.ts.map +1 -0
  61. package/dist/esm/hook/usePortal.d.ts.map +1 -0
  62. package/dist/esm/hook/usePortal.js +2 -0
  63. package/dist/esm/hook/useTheme.d.ts.map +1 -0
  64. package/dist/esm/hook/useTheme.js +2 -0
  65. package/dist/esm/main.d.ts.map +1 -0
  66. package/dist/esm/main.js +1 -0
  67. package/dist/esm/nextjs-registry/index.d.ts.map +1 -0
  68. package/dist/esm/nextjs-registry/index.js +1 -0
  69. package/dist/esm/types/node.type.d.ts.map +1 -0
  70. package/dist/esm/util/mount-tracker.util.d.ts.map +1 -0
  71. package/dist/esm/util/mount-tracker.util.js +1 -0
  72. package/dist/esm/util/navigation-cache-manager.util.d.ts.map +1 -0
  73. package/dist/esm/util/navigation-cache-manager.util.js +1 -0
  74. package/dist/esm/util/node.util.d.ts.map +1 -0
  75. package/dist/esm/util/node.util.js +1 -0
  76. package/dist/esm/util/theme.util.d.ts.map +1 -0
  77. package/dist/esm/util/theme.util.js +1 -0
  78. package/package.json +21 -19
  79. package/dist/client.d.ts.map +0 -1
  80. package/dist/client.js +0 -6
  81. package/dist/components/html.node.d.ts.map +0 -1
  82. package/dist/components/html.node.js +0 -632
  83. package/dist/components/meonode-unmounter.client.d.ts.map +0 -1
  84. package/dist/components/meonode-unmounter.client.js +0 -17
  85. package/dist/components/react.node.d.ts.map +0 -1
  86. package/dist/components/react.node.js +0 -43
  87. package/dist/components/registry.client.d.ts.map +0 -1
  88. package/dist/components/registry.client.js +0 -14
  89. package/dist/components/styled-renderer.client.d.ts.map +0 -1
  90. package/dist/components/styled-renderer.client.js +0 -10
  91. package/dist/components/theme-provider.client.d.ts.map +0 -1
  92. package/dist/components/theme-provider.client.js +0 -8
  93. package/dist/components/theme-provider.d.ts.map +0 -1
  94. package/dist/components/theme-provider.js +0 -3
  95. package/dist/constant/common.const.d.ts.map +0 -1
  96. package/dist/constant/common.const.js +0 -1
  97. package/dist/constant/css-properties.const.d.ts.map +0 -1
  98. package/dist/core.node.d.ts.map +0 -1
  99. package/dist/core.node.js +0 -139
  100. package/dist/helper/common.helper.d.ts.map +0 -1
  101. package/dist/helper/common.helper.js +0 -73
  102. package/dist/helper/obj.helper.d.ts.map +0 -1
  103. package/dist/helper/obj.helper.js +0 -23
  104. package/dist/helper/react-is.helper.d.ts.map +0 -1
  105. package/dist/helper/react-is.helper.js +0 -94
  106. package/dist/hoc/component.hoc.d.ts.map +0 -1
  107. package/dist/hoc/component.hoc.js +0 -50
  108. package/dist/hoc/index.d.ts.map +0 -1
  109. package/dist/hoc/index.js +0 -1
  110. package/dist/hoc/portal.hoc.d.ts.map +0 -1
  111. package/dist/hoc/portal.hoc.js +0 -73
  112. package/dist/hook/index.d.ts.map +0 -1
  113. package/dist/hook/index.js +0 -1
  114. package/dist/hook/usePortal.d.ts.map +0 -1
  115. package/dist/hook/usePortal.js +0 -4
  116. package/dist/hook/useTheme.d.ts.map +0 -1
  117. package/dist/hook/useTheme.js +0 -8
  118. package/dist/main.d.ts.map +0 -1
  119. package/dist/main.js +0 -7
  120. package/dist/nextjs-registry/index.d.ts.map +0 -1
  121. package/dist/nextjs-registry/index.js +0 -1
  122. package/dist/types/env.d.js +0 -1
  123. package/dist/types/node.type.d.ts.map +0 -1
  124. package/dist/types/node.type.js +0 -1
  125. package/dist/util/mount-tracker.util.d.ts.map +0 -1
  126. package/dist/util/mount-tracker.util.js +0 -15
  127. package/dist/util/navigation-cache-manager.util.d.ts.map +0 -1
  128. package/dist/util/navigation-cache-manager.util.js +0 -19
  129. package/dist/util/node.util.d.ts.map +0 -1
  130. package/dist/util/node.util.js +0 -241
  131. package/dist/util/theme.util.d.ts.map +0 -1
  132. package/dist/util/theme.util.js +0 -112
  133. /package/dist/{client.d.ts → esm/client.d.ts} +0 -0
  134. /package/dist/{components → esm/components}/html.node.d.ts +0 -0
  135. /package/dist/{components → esm/components}/react.node.d.ts +0 -0
  136. /package/dist/{components → esm/components}/registry.client.d.ts +0 -0
  137. /package/dist/{components → esm/components}/styled-renderer.client.d.ts +0 -0
  138. /package/dist/{components → esm/components}/theme-provider.client.d.ts +0 -0
  139. /package/dist/{components → esm/components}/theme-provider.d.ts +0 -0
  140. /package/dist/{constant → esm/constant}/common.const.d.ts +0 -0
  141. /package/dist/{constant → esm/constant}/css-properties.const.d.ts +0 -0
  142. /package/dist/{core.node.d.ts → esm/core.node.d.ts} +0 -0
  143. /package/dist/{helper → esm/helper}/common.helper.d.ts +0 -0
  144. /package/dist/{helper → esm/helper}/obj.helper.d.ts +0 -0
  145. /package/dist/{helper → esm/helper}/react-is.helper.d.ts +0 -0
  146. /package/dist/{hoc → esm/hoc}/component.hoc.d.ts +0 -0
  147. /package/dist/{hoc → esm/hoc}/index.d.ts +0 -0
  148. /package/dist/{hoc → esm/hoc}/portal.hoc.d.ts +0 -0
  149. /package/dist/{hook → esm/hook}/index.d.ts +0 -0
  150. /package/dist/{hook → esm/hook}/usePortal.d.ts +0 -0
  151. /package/dist/{hook → esm/hook}/useTheme.d.ts +0 -0
  152. /package/dist/{main.d.ts → esm/main.d.ts} +0 -0
  153. /package/dist/{nextjs-registry → esm/nextjs-registry}/index.d.ts +0 -0
  154. /package/dist/{types → esm/types}/node.type.d.ts +0 -0
  155. /package/dist/{util → esm/util}/mount-tracker.util.d.ts +0 -0
  156. /package/dist/{util → esm/util}/navigation-cache-manager.util.d.ts +0 -0
  157. /package/dist/{util → esm/util}/node.util.d.ts +0 -0
  158. /package/dist/{util → esm/util}/theme.util.d.ts +0 -0
@@ -1,73 +0,0 @@
1
- const _excluded=["provider"];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 _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{BaseNode,Node}from"../core.node.js";// --- Function Overloads ---
2
- /**
3
- * Higher-Order Component (HOC) to create and manage React portals with optional provider wrapping.
4
- * This function supports two overloads:
5
- * 1. `Portal(providerNodeInstance, component)` - Creates a portal with a fixed provider node instance.
6
- * 2. `Portal(component)` - Creates a portal without a fixed provider, allowing dynamic providers at launch time.
7
- * @template P The prop types for the component rendered inside the portal, extending BasePortalProps.
8
- * @param provider Optional NodeInstance to wrap the portal content (fixed provider).
9
- * @param component The component function that returns the content to render inside the portal.
10
- * @returns A function that launches the portal instance, accepting props and optional dynamic providers.
11
- * @example
12
- * // Using Portal with a fixed provider
13
- * const MyPortal = Portal(MyProviderNodeInstance, (props) => (
14
- * Div({
15
- * backgroundColor: 'white',
16
- * padding: '20px',
17
- * borderRadius: '8px',
18
- * children: [
19
- * H1({ children: 'Fixed Provider Portal' }),
20
- * Button({
21
- * onClick: () => props.portal.unmount(),
22
- * children: 'Close',
23
- * }),
24
- * ],
25
- * })
26
- * ));
27
- *
28
- * // Launching the portal
29
- * const portalInstance = MyPortal({ someProp: 'value' });
30
- * @example
31
- * // Using Portal without a fixed provider
32
- * const MyPortal = Portal((props) => (
33
- * Div({
34
- * backgroundColor: 'white',
35
- * padding: '20px',
36
- * borderRadius: '8px',
37
- * children: [
38
- * H1({ children: 'Dynamic Provider Portal' }),
39
- * Button({
40
- * onClick: () => props.portal.unmount(),
41
- * children: 'Close',
42
- * }),
43
- * ],
44
- * })
45
- * ));
46
- *
47
- * // Launching the portal with a dynamic provider
48
- * const portalInstance = MyPortal({ provider: AnotherProviderNodeInstance, someProp: 'value' });
49
- */// --- Implementation ---
50
- export function Portal(a,b){// --- Initialization ---
51
- let c,d,e={unmount:()=>{console.warn("Portal instance not yet created. Cannot unmount.")},update:a=>{console.warn("Portal instance not yet created. Cannot update.",a)}};// --- Argument Parsing and Overload Handling ---
52
- // Determines which Portal overload was called (e.g., with fixed provider or just component).
53
- if("function"==typeof b&&a instanceof BaseNode)// Handles the case where a fixed provider (single) is passed.
54
- c=[a],d=b;else if("function"==typeof a&&b===void 0)// Handles the case where only the component function is passed.
55
- d=a;else throw new Error("Invalid arguments for Portal HOC. Use Portal(component) or Portal(providerNodeInstance, component).");// --- Core Content Renderer Function ---
56
- // This function is the actual React component that will be rendered inside the portal.
57
- const f=(a={})=>{const b=d(_objectSpread(_objectSpread({},a),{},{portal:e// Passes the portal control object to the content component
58
- }));// If the result is a BaseNode, render it.
59
- return b instanceof BaseNode?b.render():b};// --- Portal Launcher Function (Returned to User) ---
60
- // This is the function that developers call to actually create and manage a portal instance.
61
- return function Func(a={}){// --- Helper for Deep Content Injection ---
62
- // Recursively injects content into the deepest child of a provider chain.
63
- function injectContentDeeply(a,b){const c=a.rawProps?.children;// If no children, or children is not a NodeInstance, inject directly
64
- if(!c||!(c instanceof BaseNode))return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:b}));// Recursively inject into the deepest node
65
- const d=injectContentDeeply(c,b);return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:d}))}// --- Provider Wrapping Logic ---
66
- // Iterates through the combined providers (fixed + dynamic) to wrap the content.
67
- // Providers are applied in reverse order to ensure the innermost content is wrapped by the outermost provider.
68
- let b;// Combine fixed and dynamic providers
69
- const d=[];a.provider&&d.push(a.provider);const g=[...(c??[]),...d],{provider:h}=a,i=_objectWithoutProperties(a,_excluded),j=Node(f,i);// Separates props for the portal's content from internal props like 'provider'.
70
- // Creates the base node for the portal's content.
71
- return b=0<g.length?g.reduceRight((a,b)=>{if(!(b instanceof BaseNode))return console.warn("Portal: Item in provider is not a valid NodeInstance. Skipping.",b),a;const c=b.rawProps?.children instanceof BaseNode;// If the provider already has nested children, inject content deeply.
72
- // Otherwise, simply set currentWrappedContent as its direct child.
73
- return c?injectContentDeeply(b,a):Node(b.element,_objectSpread(_objectSpread({},b.rawProps),{},{children:a}))},j):j,e=b.toPortal(),e}}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hook/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
@@ -1 +0,0 @@
1
- export*from"./usePortal.js";export*from"./useTheme.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePortal.d.ts","sourceRoot":"","sources":["../../src/hook/usePortal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAkC,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAmB,UAAU,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGvF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,IAAI,GAAE,CAAsB;;;sBAGhC,CAAC;EAgCvC"}
@@ -1,4 +0,0 @@
1
- "use client";import{useCallback,useEffect,useRef}from"react";import{Node}from"../core.node.js";/**
2
- * Hook for managing a portal that renders node components outside the React component tree.
3
- * @deprecated This hook is unstable and will likely be removed in future versions
4
- */export function usePortal(a=[]){const b=useRef({}),c=useCallback(a=>(b.current.component=a,new Proxy(a,{apply:(a,c,[d])=>(b.current.props=d,a.call(c,d))})),[]);return useEffect(()=>{const{portal:a,component:c,props:d}=b.current;a&&c&&a.update(Node(c,d))},a),useEffect(()=>()=>{b.current.portal?.unmount(),b.current.portal=void 0,b.current.component=void 0,b.current.props=void 0},[]),{portal:b.current.portal,setPortal:a=>b.current.portal=a,createComponent:c}}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hook/useTheme.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,4EA+BpB,CAAA"}
@@ -1,8 +0,0 @@
1
- "use client";import{useContext,useEffect}from"react";import{ThemeContext}from"../components/theme-provider.client.js";/**
2
- * A hook that provides access to the theme context.
3
- * It also handles side effects like updating localStorage and applying the theme to the document root.
4
- * @returns {ThemeContextValue} The theme context value.
5
- * @throws {Error} If used outside a ThemeProvider.
6
- */export const useTheme=()=>{const a=useContext(ThemeContext);if(!a)throw new Error("useTheme must be used within a ThemeProvider");const{theme:b}=a;return useEffect(()=>{// Sync theme mode with localStorage
7
- const a=localStorage.getItem("theme");a&&a===b.mode||localStorage.setItem("theme",b.mode);// Apply theme to document root
8
- const c=document.documentElement;"dark"===b.mode?(c.setAttribute("data-theme","dark"),c.classList.add("dark-theme"),c.classList.remove("light-theme")):(c.setAttribute("data-theme","light"),c.classList.add("light-theme"),c.classList.remove("dark-theme"))},[b.mode,b.system]),a};
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAG5D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAG7E,cAAc,mBAAmB,CAAA;AAGjC,cAAc,yBAAyB,CAAA;AAGvC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,mCAAmC,CAAA;AAGjD,cAAc,oBAAoB,CAAA"}
package/dist/main.js DELETED
@@ -1,7 +0,0 @@
1
- // Common
2
- export{setDebugMode}from"./constant/common.const.js";// Core
3
- export{Node,createNode,createChildrenFirstNode}from"./core.node.js";// High Order Components
4
- export*from"./hoc/index.js";// Types
5
- export*from"./types/node.type.js";// Components
6
- export*from"./components/react.node.js";export*from"./components/html.node.js";export*from"./components/theme-provider.js";// Hooks
7
- export*from"./hook/index.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nextjs-registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,oCAAoC,CAAA;AAG/D,eAAO,MAAM,aAAa;;CAA6B,CAAA"}
@@ -1 +0,0 @@
1
- import _StyleRegistry from"../components/registry.client.js";import{createNode}from"../core.node.js";export const StyleRegistry=createNode(_StyleRegistry);
@@ -1 +0,0 @@
1
- export{};
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.type.d.ts","sourceRoot":"","sources":["../../src/types/node.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAI5C,KAAK,YAAY,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;CACxD,CAAC,MAAM,CAAC,CAAC,CAAA;AAGV,MAAM,MAAM,gBAAgB,CAAC,CAAC,I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M,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAA;CACpC;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAC5E,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAC5E,UAAU,CAAA;AAEf;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,eAAe,EAAE,MAAM,eAAe,CAAC,GACvJ,eAAe,CAAA;AAEjB,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,YAAY,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB"}
@@ -1 +0,0 @@
1
- export{};
@@ -1 +0,0 @@
1
- {"version":3,"file":"mount-tracker.util.d.ts","sourceRoot":"","sources":["../../src/util/mount-tracker.util.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,eAAiB;IAExB,OAAc,YAAY,cAAoB;IAC9C,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA4B;IAE5D;;OAEG;IACH,OAAc,UAAU,CAAC,GAAG,EAAE,MAAM,QAMnC;IAED;;;;OAIG;IACH,OAAc,YAAY,CAAC,GAAG,EAAE,MAAM,WAerC;IAED;;;OAGG;IACH,OAAc,OAAO,SAMpB;CACF"}
@@ -1,15 +0,0 @@
1
- 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{__DEBUG__}from"../constant/common.const.js";/**
2
- * MountTrackerUtil keeps track of which BaseNode instances are currently mounted in the DOM.
3
- * It provides a simple registry for mount/unmount state that other systems
4
- * (like NavigationCacheManager) can query for safe cache eviction.
5
- */export class MountTrackerUtil{constructor(){}// Debug only
6
- /**
7
- * Tracks a node as mounted. Adds its stable key and a WeakRef to the node to the map of mounted nodes.
8
- */static trackMount(a){this.mountedNodes.add(a),__DEBUG__&&this._unmountCallCount.delete(a)}/**
9
- * Removes its stable key from the set of mounted nodes.
10
- * In development mode, it also tracks multiple unmount calls for debugging purposes.
11
- * @returns True if the node was previously tracked as mounted and is now removed, false otherwise.
12
- */static untrackMount(a){const b=this.mountedNodes.delete(a);if(__DEBUG__&&!b){const b=(this._unmountCallCount.get(a)||0)+1;this._unmountCallCount.set(a,b),1<b&&console.warn(`[MeoNode] untrackMount called ${b} times for an already unmounted node: ${a}. This could indicate a memory leak or a bug in a component's lifecycle.`)}return b}/**
13
- * Cleans up all internal state of the MountTrackerUtil.
14
- * Removes all tracked nodes and debug counters.
15
- */static cleanup(){this.mountedNodes.clear(),__DEBUG__&&this._unmountCallCount.clear()}}_defineProperty(MountTrackerUtil,"mountedNodes",new Set),_defineProperty(MountTrackerUtil,"_unmountCallCount",new Map);
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation-cache-manager.util.d.ts","sourceRoot":"","sources":["../../src/util/navigation-cache-manager.util.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,CAAC,CAAC;IACd,UAAU,MAAM;QACd,4BAA4B,CAAC,EAAE,OAAO,CAAA;KACvC;CACF;AAED;;GAEG;AACH,qBAAa,0BAA0B;IACrC,OAAO,eAAiB;IAExB,OAAO,CAAC,MAAM,CAAC,SAAS,CAA0C;IAClE,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAwC;IACzE,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAA2C;IAC/E,OAAO,CAAC,MAAM,CAAC,UAAU,CAAQ;IAEjC,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,eAAe,CAA8B;IAErD,OAAc,WAAW,IAAI,0BAA0B,CAKtD;IAED;;OAEG;IACI,KAAK,SAaX;IAED;;;OAGG;IACH,OAAO,CAAC,KAAK;IAkBb;;OAEG;IACH,OAAO,CAAC,iBAAiB,CA4BxB;IAED;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmB5B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;CAW1B"}
@@ -1,19 +0,0 @@
1
- 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{__DEBUG__}from"../constant/common.const.js";import{BaseNode}from"../core.node.js";import{MountTrackerUtil}from"./mount-tracker.util.js";/**
2
- * Lightweight navigation handler that clears cache on SPA navigation.
3
- */export class NavigationCacheManagerUtil{constructor(){/**
4
- * Debounced navigation handler. Clears mounted element cache and props cache.
5
- */_defineProperty(this,"_isListening",!1),_defineProperty(this,"_cleanupTimeout",null),_defineProperty(this,"_handleNavigation",()=>{this._cleanupTimeout&&clearTimeout(this._cleanupTimeout);const a=BaseNode.elementCache.size,b=100>a?50:500>a?100:200;this._cleanupTimeout=setTimeout(()=>{const a=BaseNode.propProcessingCache.size;let b=0;// Only clean UNMOUNTED elements
6
- BaseNode.elementCache.keys().forEach(a=>{MountTrackerUtil.mountedNodes.has(a)||(BaseNode.elementCache.delete(a),b++)}),200<a&&BaseNode.propProcessingCache.clear(),__DEBUG__&&console.log(`[MeoNode] Navigation: cleared ${b} unmounted elements, ${a} props entries`)},b)})}static getInstance(){return this._instance||(this._instance=new NavigationCacheManagerUtil),this._instance}/**
7
- * Start listening for navigation events. Idempotent.
8
- */start(){this._isListening||"undefined"==typeof window||(// Setup automatic cleanup on page unload
9
- this._isListening=!0,window.addEventListener("popstate",this._handleNavigation),this._patchHistoryMethods(),this._setupAutoCleanup(),__DEBUG__&&console.log("[MeoNode] NavigationCacheManagerUtil started"))}/**
10
- * Stops listening for navigation events and restores original browser APIs.
11
- * This is important for cleanup during HMR or when unmounting the library.
12
- */_stop(){this._isListening&&"undefined"!=typeof window&&(window.removeEventListener("popstate",this._handleNavigation),this._cleanupTimeout&&(clearTimeout(this._cleanupTimeout),this._cleanupTimeout=null),this._isListening=!1,__DEBUG__&&console.log("[MeoNode] NavigationCacheManagerUtil stopped"))}/**
13
- * Patch history.pushState/replaceState to detect SPA navigation.
14
- */_patchHistoryMethods(){NavigationCacheManagerUtil._isPatched||(NavigationCacheManagerUtil._originalPushState=history.pushState,NavigationCacheManagerUtil._originalReplaceState=history.replaceState,history.pushState=(...a)=>{NavigationCacheManagerUtil._originalPushState.apply(history,a),this._handleNavigation()},history.replaceState=(...a)=>{NavigationCacheManagerUtil._originalReplaceState.apply(history,a),this._handleNavigation()},NavigationCacheManagerUtil._isPatched=!0)}/**
15
- * Setup automatic cleanup on page unload.
16
- * Covers HMR, navigation away, and browser close.
17
- */_setupAutoCleanup(){// Only set up once
18
- window.__MEONODE_CLEANUP_REGISTERED||(// Handle page unload (navigation away, refresh, close)
19
- window.addEventListener("beforeunload",()=>{this._stop(),BaseNode.clearCaches()}),window.__MEONODE_CLEANUP_REGISTERED=!0)}}_defineProperty(NavigationCacheManagerUtil,"_instance",null),_defineProperty(NavigationCacheManagerUtil,"_originalPushState",null),_defineProperty(NavigationCacheManagerUtil,"_originalReplaceState",null),_defineProperty(NavigationCacheManagerUtil,"_isPatched",!1);
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.util.d.ts","sourceRoot":"","sources":["../../src/util/node.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,KAAK,SAAS,EAAiC,MAAM,OAAO,CAAA;AACnH,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACd,cAAc,EAEd,UAAU,EAEX,MAAM,yBAAyB,CAAA;AAKhC,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAExD;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,OAAO,eAAiB;IAGxB,OAAc,QAAQ,UAAgC;IAGtD,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAgC;IAGtE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,OAAM;IAC9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,MAAK;IAGhD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAgC;IAKxD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAA2D;IAGjG,OAAc,oBAAoB;;;;;OAM/B;IAEH;;;;;;;;;;OAUG;IACH,OAAc,cAAc,wCAS3B;IAED;;;;;;OAMG;IACH,OAAc,WAAW,yBAAgH;IAEzI;;;;;OAKG;IACH,OAAc,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAc5C;IAED;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,OAAO;IA0BtB;;;;;;;;OAQG;IACH,OAAc,mBAAmB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,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;;;;;;;;;OAWG;IACH,OAAc,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,YAAY,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CA4DrJ;IAED;;;;;;;;;;;;OAYG;IACH,OAAc,mBAAmB,CAAC,EAChC,gBAAgB,EAChB,SAAS,EACT,cAAc,EACf,EAAE;QACD,gBAAgB,EAAE,WAAW,CAAA;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,cAAc,CAAC,EAAE,OAAO,CAAA;KACzB,wUA8BA;IAED;;;;;;OAMG;IACH,OAAc,0BAA0B,CAAC,IAAI,EAAE,YAAY,WA0C1D;IAED;;;;OAIG;IACH,OAAc,kBAAkB,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,SAAS,EAAE,IAAI,CAAA;KAAE,QAgBtF;CACF"}
@@ -1,241 +0,0 @@
1
- const _excluded=["ref","key","children","css","props","disableEmotion"],_excluded2=["style"];var _NodeUtil;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 _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,isValidElement}from"react";import{isForwardRef,isMemo,isReactClassComponent}from"../helper/react-is.helper.js";import{getCSSProps,getDOMProps,getElementTypeName,omitUndefined}from"../helper/common.helper.js";import{__DEBUG__}from"../constant/common.const.js";import{BaseNode}from"../core.node.js";import{createRoot}from"react-dom/client";/**
2
- * NodeUtil provides a collection of static utility methods and properties
3
- * used internally by BaseNode for various tasks such as hashing, shallow comparison,
4
- * and stable element ID generation. This centralizes common helper functions,
5
- * improving modularity and maintainability of the core library.
6
- */export class NodeUtil{constructor(){}// Determines if the current environment is server-side (Node.js) or client-side (browser).
7
- /**
8
- * Combines FNV-1a and djb2 hash functions for a more robust signature.
9
- * This hybrid approach provides better distribution than either algorithm alone.
10
- * @param str The string to hash.
11
- * @returns A combined hash string in base-36 format.
12
- */static hashString(a){let b=2166136261,c=5381;// FNV offset basis
13
- // djb2 init
14
- for(let d=0;d<a.length;d++){const e=a.charCodeAt(d);// FNV-1a
15
- // djb2
16
- b^=e,b=Math.imul(b,16777619),c=33*c^e}return`${(b>>>0).toString(36)}_${(c>>>0).toString(36)}`}/**
17
- * Generates a fast structural hash for CSS objects without full serialization.
18
- * This is an optimized hashing method that samples the first 10 keys for performance.
19
- * @param css The CSS object to hash.
20
- * @returns A hash string representing the CSS object structure.
21
- */static hashCSS(a){const b=this._cssCache.get(a);if(b)return b;// Fast structural hash without full serialization
22
- const c=Object.keys(a);let d=c.length;for(let b=0;b<Math.min(c.length,10);b++){// Sample first 10
23
- const e=c[b],f=a[e],g=e.charCodeAt(0);d=(d<<5)-d+g,d&=d,"string"==typeof f&&(d=(d<<5)-d+f.length)}const e=d.toString(36);return this._cssCache.set(a,e),e}/**
24
- * Creates a unique, stable signature from the element type and props.
25
- * This signature includes the element's type to prevent collisions between different components
26
- * and handles primitive values in arrays and objects for better caching.
27
- * On server environments, returns undefined as signatures are not needed for server-side rendering.
28
- * @param element The element type to include in the signature.
29
- * @param props The props object to include in the signature.
30
- * @returns A unique signature string or undefined on the server.
31
- */static createPropSignature(a,b){if(NodeUtil.isServer)return;const c=getElementTypeName(a),d=Object.keys(b);// Optimization: Only sort if there's more than one key to ensure stability
32
- 1<d.length&&d.sort();const e=[`${c}:`];if("function"==typeof a){let b=NodeUtil._functionSignatureCache.get(a);b||(b=NodeUtil.hashString(a.toString()),NodeUtil._functionSignatureCache.set(a,b)),e.push(b)}for(const c of d){const a=b[c];let d;const f=typeof a;if("string"==f||"number"===f||"boolean"===f)d=`${c}:${a};`;else if(null===a)d=`${c}:null;`;else if(a===void 0)d=`${c}:undefined;`;else if("css"===c&&"object"==typeof a)d=`css:${this.hashCSS(a)};`;else if(Array.isArray(a)){// Hash primitive values in arrays for better cache hits
33
- const b=a.filter(a=>{const b=typeof a;return"string"==b||"number"===b||"boolean"===b||null===a});d=b.length===a.length?`${c}:[${b.join(",")}];`:`${c}:[${a.length}];`}else if(a&&a.isBaseNode)d=`${c}:${a.stableKey};`;else{// Include sorted keys for object structure signature
34
- const b=Object.keys(a).sort();d=`${c}:{${b.join(",")}};`}e.push(d)}return NodeUtil.hashString(e.join(","))}/**
35
- * Extracts "critical" props from a given set of props. Critical props are those
36
- * that are frequently used for styling or event handling, such as `on*` handlers,
37
- * `aria-*` attributes, `data-*` attributes, `css`, `className`, and `style`.
38
- * This method is used to optimize prop processing by focusing on props that are
39
- * most likely to influence rendering or behavior.
40
- * @param props The original props object.
41
- * @param keys The keys to process from the props object.
42
- * @returns An object containing only the critical props with an added count property.
43
- */static extractCriticalProps(a,b){const c={_keyCount:b.length};let d=0;for(const e of b){if(50<=d)break;// Fast path: direct Set check first (O(1))
44
- if(NodeUtil.CRITICAL_PROPS.has(e)){c[e]=a[e],d++;continue}// Inline prefix checks using charCode (faster than startsWith for short prefixes)
45
- const f=e.charCodeAt(0);// Check 'on' prefix (111 = 'o', 110 = 'n')
46
- if(111===f&&110===e.charCodeAt(1)){c[e]=a[e],d++;continue}// Check 'aria' prefix (97 = 'a', 114 = 'r', 105 = 'i')
47
- if(97===f&&114===e.charCodeAt(1)&&105===e.charCodeAt(2)&&97===e.charCodeAt(3)){c[e]=a[e],d++;continue}// Check 'data' prefix (100 = 'd', 97 = 'a', 116 = 't')
48
- if(100===f&&97===e.charCodeAt(1)&&116===e.charCodeAt(2)&&97===e.charCodeAt(3)){c[e]=a[e],d++;continue}// Style prop check last (most expensive), only for smaller objects
49
- 100>=b.length&&NodeUtil.isStyleProp(e)&&(c[e]=a[e],d++)}return c}/**
50
- * Retrieves computed CSS props from the cache with LRU tracking.
51
- * Access time and hit count are tracked for smarter eviction.
52
- * Falls back to direct computation if no signature is provided or running on server.
53
- * @param cacheableProps The props to compute CSS properties from.
54
- * @param signature The cache signature to use for lookup.
55
- * @returns An object containing the CSS props.
56
- */static getCachedCssProps(a,b){if(NodeUtil.isServer||!b)return{cssProps:getCSSProps(a)};const c=BaseNode.propProcessingCache.get(b);if(c)return c.lastAccess=Date.now(),c.hitCount++,{cssProps:c.cssProps};const d=getCSSProps(a);return BaseNode.propProcessingCache.set(b,{cssProps:d,signature:b,lastAccess:Date.now(),hitCount:1}),BaseNode.propProcessingCache.size>NodeUtil.CACHE_SIZE_LIMIT&&!BaseNode.scheduledCleanup&&(BaseNode.scheduledCleanup=!0,"undefined"==typeof requestIdleCallback?setTimeout(()=>{NodeUtil._evictLRUEntries(),BaseNode.scheduledCleanup=!1},100):requestIdleCallback(()=>{NodeUtil._evictLRUEntries(),BaseNode.scheduledCleanup=!1},{timeout:2e3})),{cssProps:d}}/**
57
- * Implements an LRU eviction strategy that removes multiple entries at once.
58
- * It uses a scoring system where older and less frequently used entries have a higher eviction priority.
59
- * This batch eviction approach improves performance by avoiding frequent cache cleanup operations.
60
- */static _evictLRUEntries(){const a=Date.now(),b=new MinHeap((c,a)=>a.score-c.score);// Create max-heap (using min-heap with inverted comparison) to get highest scores first
61
- for(const[c,d]of BaseNode.propProcessingCache.entries()){const e=this._calculateEvictionScore(d,a);b.push({key:c,score:e})}// O(log n) eviction of top N entries
62
- for(let a=0;a<NodeUtil.CACHE_CLEANUP_BATCH;a++){const a=b.pop();if(a)BaseNode.propProcessingCache.delete(a.key);else// No more items to evict
63
- break}}/**
64
- * Calculates an eviction score based on age and frequency of access.
65
- * Higher scores mean more likelihood to be evicted.
66
- * The scoring system uses weighted factors: 30% recency and 70% frequency.
67
- * @param value The cache entry to score.
68
- * @param now The current timestamp for calculating age.
69
- * @returns A numeric score representing how likely the entry should be evicted.
70
- */static _calculateEvictionScore(a,b){const c=b-a.lastAccess,d=a.hitCount;// Weighted scoring: recency 30%, frequency 70% - favors frequently accessed items
71
- return .3*(c/1e3)+.7*(1e3/(d+1))}/**
72
- * The main prop processing pipeline. It separates cacheable and non-cacheable props,
73
- * generates a signature for caching, and assembles the final props object.
74
- * This method applies optimizations like fast-path for simple props and hybrid caching strategy.
75
- * @param element The element type for which props are being processed.
76
- * @param rawProps The original props to process.
77
- * @param stableKey The stable key used for child normalization (optional).
78
- * @returns The processed props object ready for rendering.
79
- */static processProps(a,b={},c){const{ref:d,key:e,children:f,css:g,props:i={},disableEmotion:h}=b,j=_objectWithoutProperties(b,_excluded);// --- Fast Path Optimization ---
80
- if(0===Object.keys(j).length&&!g)return omitUndefined({ref:d,key:e,disableEmotion:h,nativeProps:omitUndefined(i),children:NodeUtil._processChildren(f,h)});// --- Hybrid Caching Strategy ---
81
- const k={},l={},m=Object.keys(j);// 1. Categorize props into cacheable (primitives) and non-cacheable (objects/functions).
82
- // Optimization: Use Object.keys loop instead of for..in for better performance and safety
83
- for(let d=0;d<m.length;d++){const a=m[d],b=j[a],c=typeof b;"string"===c||"number"===c||"boolean"===c?k[a]=b:l[a]=b}// 2. Pass element type to signature generation
84
- const n=NodeUtil.createPropSignature(a,k),{cssProps:o}=NodeUtil.getCachedCssProps(k,n),p=getCSSProps(l),q=getDOMProps(j),r=_objectSpread(_objectSpread(_objectSpread({},o),p),g),s=NodeUtil._processChildren(f,h,c);// 3. Process non-cacheable props on every render to ensure correctness for functions and objects.
85
- // DOM props are always processed fresh.
86
- // 4. Assemble the final CSS object.
87
- // --- Child Normalization ---
88
- // --- Final Assembly ---
89
- return omitUndefined(_objectSpread(_objectSpread({ref:d,key:e,css:r},q),{},{disableEmotion:h,nativeProps:omitUndefined(i),children:s}))}/**
90
- * Processes and normalizes children of the node.
91
- * Converts raw children (React elements, primitives, or other BaseNodes) into a consistent format.
92
- * Applies optimizations for single and multiple children scenarios.
93
- * @param children The raw children to process.
94
- * @param disableEmotion If true, emotion styling will be disabled for these children.
95
- * @param parentStableKey The stable key of the parent node, used for generating unique keys for children.
96
- * @returns The processed children in normalized format.
97
- */static _processChildren(a,b,c){return a?"function"==typeof a?a:Array.isArray(a)?1===a.length?NodeUtil.processRawNode(a[0],b,`${c}_0`):a.map((a,d)=>NodeUtil.processRawNode(a,b,`${c}_${d}`)):NodeUtil.processRawNode(a,b,c):void 0;// Fast path for non-array (single child)
98
- // Fast path for single element array
99
- // General case: multiple children
100
- }/**
101
- * Determines if a node should update based on its dependency array.
102
- * Uses a shallow comparison, similar to React's `useMemo` and `useCallback`.
103
- * On server environments, always returns true since SSR has no concept of re-renders.
104
- * @param prevDeps Previous dependency array to compare.
105
- * @param newDeps New dependency array to compare.
106
- * @param parentBlocked Flag indicating if the parent is blocked from updating.
107
- * @returns True if the node should update, false otherwise.
108
- */static shouldNodeUpdate(a,b,c){// SSR has no concept of re-renders, so deps system doesn't apply
109
- return!!NodeUtil.isServer||!c&&(!(void 0!==b)||!(void 0!==a)||b.length!==a.length||!!b.some((b,c)=>!Object.is(b,a[c])));// No deps array means always update.
110
- // First render for this keyed component, or no previous deps.
111
- // Length change means update.
112
- // Shallow compare deps. If any have changed, update.
113
- // Deps are the same, no update needed.
114
- }/**
115
- * The core normalization function for a single child. It takes any valid `NodeElement`
116
- * (primitive, React element, function, `BaseNode` instance) and converts it into a standardized `BaseNode`
117
- * instance if it isn't one already. This ensures a consistent structure for the iterative renderer.
118
- * Handles various node types including primitives, BaseNode instances, function-as-children, React elements,
119
- * component classes, and component instances.
120
- * @param node The node element to process and normalize.
121
- * @param disableEmotion If true, emotion styling will be disabled for this node.
122
- * @param stableKey The stable key for positional information in parent-child relationships.
123
- * @returns The normalized node element in BaseNode format.
124
- */static processRawNode(a,b,c){// Primitives and null/undefined are returned as-is.
125
- if(null===a||a===void 0||"string"==typeof a||"number"==typeof a||"boolean"==typeof a)return a;// If it's already a BaseNode, clone it with a positional key if available.
126
- if(NodeUtil.isNodeInstance(a)){const d=c||b&&!a.rawProps.disableEmotion;if(d){// Create a new BaseNode instance.
127
- const d=new BaseNode(a.element,a.rawProps,a.dependencies);// Augment the internal stableKey with positional information.
128
- // This is purely for BaseNode's internal caching, not for React's 'key' prop.
129
- return d.stableKey=`${c}:${d.stableKey}`,b&&!d.rawProps.disableEmotion&&(d.rawProps.disableEmotion=!0),d}return a}// Handle function-as-a-child (render props).
130
- if(NodeUtil.isFunctionChild(a))return new BaseNode(NodeUtil.functionRenderer,{props:{render:a,disableEmotion:b}},void 0);// Handle standard React elements.
131
- if(isValidElement(a)){const c=a.props,{style:d}=c,e=_objectWithoutProperties(c,_excluded2),f=_objectSpread(_objectSpread({},e),d||{});return new BaseNode(a.type,_objectSpread(_objectSpread(_objectSpread({},f),null!==a.key&&void 0!==a.key?{key:a.key}:{}),{},{disableEmotion:b}),void 0)}// Handle component classes and memos.
132
- return isReactClassComponent(a)||isMemo(a)||isForwardRef(a)?new BaseNode(a,{disableEmotion:b},void 0):a instanceof React.Component?NodeUtil.processRawNode(a.render(),b,c):a;// Handle component instances.
133
- }/**
134
- * A helper to reliably identify if a given function is a "function-as-a-child" (render prop)
135
- * rather than a standard Function Component.
136
- * Distinguishes between render prop functions and component functions by checking for React component signatures.
137
- * @param node The node to check.
138
- * @returns True if the node is a function-as-a-child, false otherwise.
139
- */static isFunctionChild(a){if("function"!=typeof a||isReactClassComponent(a)||isMemo(a)||isForwardRef(a))return!1;try{return!(a.prototype&&"function"==typeof a.prototype.render)}catch(a){return __DEBUG__&&console.error("MeoNode: Error checking if a node is a function child.",a),!0}}/**
140
- * A special internal React component used to render "function-as-a-child" (render prop) patterns.
141
- * When a `BaseNode` receives a function as its `children` prop, it wraps that function
142
- * inside this `functionRenderer` component. This component then executes the render function
143
- * and processes its return value, normalizing it into a renderable ReactNode.
144
- *
145
- * This allows `BaseNode` to support render props while maintaining its internal processing
146
- * and normalization logic for the dynamically generated content.
147
- * @param render The function-as-a-child to execute.
148
- * @param disableEmotion Inherited flag to disable Emotion styling for children.
149
- * @returns The processed and rendered output of the render function, or null if an error occurs.
150
- */static functionRenderer({render:a,disableEmotion:b}){let c;try{// Execute the render prop function to get its output.
151
- c=a()}catch(a){// If the render function throws, treat its output as null to prevent crashes.
152
- __DEBUG__&&console.error("MeoNode: Error executing function-as-a-child.",a),c=null}// Handle null or undefined results directly, as they are valid React render outputs.
153
- if(null===c||c===void 0)return c;// If the result is already a BaseNode instance, process it.
154
- if(NodeUtil.isNodeInstance(c))// If emotion is disabled for the parent and not explicitly re-enabled on the child,
155
- // create a new BaseNode with emotion disabled and render it.
156
- return b&&!c.rawProps.disableEmotion?new BaseNode(c.element,_objectSpread(_objectSpread({},c.rawProps),{},{disableEmotion:!0})).render():c.render();// Otherwise, render the existing BaseNode directly.
157
- // If the result is an array, it likely contains multiple children.
158
- if(Array.isArray(c)){// Helper to generate a stable key for array items, crucial for React's reconciliation.
159
- const a=(a,b)=>{try{// Attempt to get a meaningful name for the element type.
160
- return`${getElementTypeName(a)}-${b}`}catch(a){// Fallback to a generic key if type name cannot be determined.
161
- return __DEBUG__&&console.error("MeoNode: Could not determine element type name for key in function-as-a-child.",a),`item-${b}`}};// Map over the array, processing each item and assigning a key.
162
- return c.map((c,d)=>NodeUtil.renderProcessedNode({processedElement:NodeUtil.processRawNode(c,b),passedKey:a(c,d),disableEmotion:b}))}// If the result is a React component instance (e.g., `new MyClassComponent()`).
163
- if(c instanceof React.Component)return NodeUtil.renderProcessedNode({processedElement:NodeUtil.processRawNode(c.render(),b),disableEmotion:b});// Handle primitive types directly, as they are valid React children.
164
- if("string"==typeof c||"number"==typeof c||"boolean"==typeof c)return c;// For any other non-primitive, non-array result, process it as a single NodeElement.
165
- const d=NodeUtil.processRawNode(c,b);// If processing yields a valid element, render it.
166
- return d?NodeUtil.renderProcessedNode({processedElement:d,disableEmotion:b}):c;// Fallback: return the original result if it couldn't be processed into a renderable node.
167
- }/**
168
- * Renders a processed `NodeElement` into a ReactNode.
169
- * This helper is primarily used by `functionRenderer` to handle the output of render props,
170
- * ensuring that `BaseNode` instances are correctly rendered and other React elements or primitives
171
- * are passed through. It also applies `disableEmotion` and `key` props as needed.
172
- *
173
- * This method is part of the child processing pipeline, converting internal `NodeElement` representations
174
- * into actual React elements that can be rendered by React.
175
- * @param processedElement The processed node element to render.
176
- * @param passedKey Optional key to apply to the rendered element.
177
- * @param disableEmotion Flag to disable emotion styling if needed.
178
- * @returns The rendered ReactNode.
179
- */static renderProcessedNode({processedElement:a,passedKey:b,disableEmotion:c}){// Initialize an object to hold common props that might be applied to the new BaseNode.
180
- const d={};// If a `passedKey` is provided, add it to `commonBaseNodeProps`.
181
- // This key is typically used for React's reconciliation process.
182
- // If the processed element is already a BaseNode instance.
183
- if(void 0!==b&&(d.key=b),NodeUtil.isNodeInstance(a)){// Get the existing key from the raw props of the BaseNode.
184
- const e=a.rawProps?.key;// Apply the `disableEmotion` flag to the raw props of the BaseNode.
185
- // If the existing key is the same as the passed key, render the existing BaseNode directly.
186
- // This avoids unnecessary re-creation of the BaseNode instance.
187
- return a.rawProps.disableEmotion=c,e===b?a.render():new BaseNode(a.element,_objectSpread(_objectSpread({},a.rawProps),d)).render();// Otherwise, create a new BaseNode instance, merging existing raw props with common props, then render it.
188
- }// If the processed element is a React class component (e.g., `class MyComponent extends React.Component`).
189
- // Create a new BaseNode for it, applying common props and `disableEmotion`, then render.
190
- return isReactClassComponent(a)?new BaseNode(a,_objectSpread(_objectSpread({},d),{},{disableEmotion:c})).render():a instanceof React.Component?a.render():"function"==typeof a?createElement(a,{key:b}):a;// If the processed element is an instance of a React component (e.g., `new MyComponent()`).
191
- // Directly call its `render` method.
192
- // If the processed element is a function (likely a functional component or a render prop that returned a component type).
193
- // Create a React element directly using `createElement`, passing the `passedKey`.
194
- // For any other type (primitives, null, undefined, etc.), return it as a ReactNode.
195
- }/**
196
- * Ensures that the necessary DOM element and React root are available for portal rendering.
197
- * This is only executed on the client-side.
198
- * Handles cleanup of stale infrastructure and creates new infrastructure as needed.
199
- * @param node The node instance that requires portal infrastructure.
200
- * @returns True if portal infrastructure is ready, false on server or if setup fails.
201
- */static ensurePortalInfrastructure(a){if(NodeUtil.isServer)return!1;let b=NodeUtil.portalInfrastructure.get(a);// Check if infrastructure exists and is still connected
202
- if(b?.domElement?.isConnected&&b?.reactRoot)return!0;// Clean up stale or disconnected infrastructure
203
- if(b&&(!b.domElement?.isConnected||!b.reactRoot)){try{b.reactRoot?.unmount?.()}catch(a){__DEBUG__&&console.error("MeoNode: Error unmounting stale portal root.",a)}NodeUtil.cleanupPortalInfra(b),NodeUtil.portalInfrastructure.delete(a),b=void 0}// Create new infrastructure
204
- const c=document.createElement("div");document.body.appendChild(c);const d=createRoot(c),e={render:d.render.bind(d),unmount:d.unmount.bind(d),update:()=>{}// Placeholder, will be overridden
205
- };return b={domElement:c,reactRoot:e},NodeUtil.portalInfrastructure.set(a,b),BaseNode.portalCleanupRegistry.register(a,{domElement:c,reactRoot:e},a),!0}/**
206
- * Cleans up portal infrastructure by unmounting the React root and removing the DOM element.
207
- * This ensures proper memory cleanup and prevents memory leaks.
208
- * @param infra The infrastructure object containing the DOM element and React root to clean up.
209
- */static cleanupPortalInfra(a){try{a.reactRoot?.unmount&&a.reactRoot.unmount()}catch(a){__DEBUG__&&console.error("Portal cleanup error:",a)}try{a.domElement?.isConnected&&a.domElement.remove()}catch(a){__DEBUG__&&console.error("DOM removal error:",a)}}}/**
210
- * A min-heap implementation for efficient priority queue operations.
211
- * Used for O(log n) eviction in the LRU cache system.
212
- */_NodeUtil=NodeUtil,_defineProperty(NodeUtil,"isServer","undefined"==typeof window),_defineProperty(NodeUtil,"_functionSignatureCache",new WeakMap),_defineProperty(NodeUtil,"CACHE_SIZE_LIMIT",500),_defineProperty(NodeUtil,"CACHE_CLEANUP_BATCH",50),_defineProperty(NodeUtil,"_cssCache",new WeakMap),_defineProperty(NodeUtil,"CRITICAL_PROPS",new Set(["css","className","disableEmotion","props"])),_defineProperty(NodeUtil,"portalInfrastructure",new WeakMap),_defineProperty(NodeUtil,"isNodeInstance",a=>"object"==typeof a&&null!==a&&"element"in a&&"function"==typeof a.render&&"function"==typeof a.toPortal&&"isBaseNode"in a),_defineProperty(NodeUtil,"isStyleProp",_NodeUtil.isServer||"undefined"==typeof document?()=>!1:a=>a in document.body.style);class MinHeap{/**
213
- * Constructs a new MinHeap with the provided comparator function.
214
- * @param comparator A function that compares two elements and returns a negative value if the first is smaller,
215
- * zero if they are equal, or a positive value if the first is larger.
216
- */constructor(a){_defineProperty(this,"heap",[]),this.comparator=a}/**
217
- * Returns the number of elements in the heap.
218
- * @returns The current size of the heap.
219
- */size(){return this.heap.length}/**
220
- * Checks if the heap is empty.
221
- * @returns True if the heap has no elements, false otherwise.
222
- */isEmpty(){return 0===this.size()}/**
223
- * Adds a new value to the heap and maintains the heap property by bubbling it up to the correct position.
224
- * @param value The value to add to the heap.
225
- */push(a){this.heap.push(a),this.bubbleUp()}/**
226
- * Removes and returns the smallest element from the heap (the root).
227
- * After removal, it maintains the heap property by bubbling down the new root.
228
- * @returns The smallest element in the heap, or undefined if the heap is empty.
229
- */pop(){if(!this.isEmpty()){this.swap(0,this.size()-1);const a=this.heap.pop();return this.bubbleDown(),a}}/**
230
- * Moves the element at the specified index up the heap until the heap property is restored.
231
- * This is used after inserting a new element to maintain the heap structure.
232
- * @param index The index of the element to bubble up. Defaults to the last element in the heap.
233
- */bubbleUp(a=this.size()-1){for(;0<a;){const b=Math.floor((a-1)/2);if(0>=this.comparator(this.heap[b],this.heap[a]))break;this.swap(b,a),a=b}}/**
234
- * Moves the element at the specified index down the heap until the heap property is restored.
235
- * This is used after removing the root element to maintain the heap structure.
236
- * @param index The index of the element to bubble down. Defaults to the root element (index 0).
237
- */bubbleDown(a=0){for(const b=this.size()-1;;){const c=2*a+1,d=2*a+2;let e=a;if(c<=b&&0>this.comparator(this.heap[c],this.heap[e])&&(e=c),d<=b&&0>this.comparator(this.heap[d],this.heap[e])&&(e=d),e===a)break;this.swap(a,e),a=e}}/**
238
- * Swaps the elements at the two specified indices in the heap array.
239
- * @param i The index of the first element to swap.
240
- * @param j The index of the second element to swap.
241
- */swap(a,b){[this.heap[a],this.heap[b]]=[this.heap[b],this.heap[a]]}}
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.util.d.ts","sourceRoot":"","sources":["../../src/util/theme.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAe,MAAM,yBAAyB,CAAA;AA+F1E,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAmC;IAE5D,OAAO,eAAiB;IAExB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAc,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,cAAc,GAAG,IAAI,CA2BnF;IAED,OAAc,aAAa,uDAM1B;IAED;;;;;;;;OAQG;IACH,OAAc,mBAAmB,GAAI,CAAC;;YA0HrC;IAED,OAAc,eAAe,aAE5B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqDG;IACH,OAAc,mBAAmB,yBAmEhC;CACF"}
@@ -1,112 +0,0 @@
1
- const _excluded=["flex"];var _ThemeUtil;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 _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{ObjHelper}from"../helper/obj.helper.js";import{getValueByPath}from"../helper/common.helper.js";/**
2
- * Cache manager for theme resolution operations.
3
- */class ThemeResolverCache{constructor(){_defineProperty(this,"CACHE_SIZE_LIMIT",500),_defineProperty(this,"CACHE_EVICTION_BATCH_SIZE",50),_defineProperty(this,"_resolutionCache",new Map),_defineProperty(this,"_pathLookupCache",new Map),_defineProperty(this,"_themeRegex",/theme\.([a-zA-Z0-9_.-]+)/g)}static getInstance(){return ThemeResolverCache._instance||(ThemeResolverCache._instance=new ThemeResolverCache),ThemeResolverCache._instance}getResolution(a,b){const c=this._generateCacheKey(a,b),d=this._resolutionCache.get(c);return d&&(this._resolutionCache.delete(c),this._resolutionCache.set(c,d)),d||null}setResolution(a,b,c){const d=this._generateCacheKey(a,b);this._resolutionCache.set(d,c),this._resolutionCache.size>this.CACHE_SIZE_LIMIT&&this._evict(this._resolutionCache)}getPathLookup(a,b){const c=`${ObjHelper.stringify(a)}_${b}`,d=this._pathLookupCache.get(c);return d&&(this._pathLookupCache.delete(c),this._pathLookupCache.set(c,d)),d??null}setPathLookup(a,b,c){const d=`${ObjHelper.stringify(a)}_${b}`;this._pathLookupCache.set(d,c),this._pathLookupCache.size>this.CACHE_SIZE_LIMIT&&this._evict(this._pathLookupCache)}getThemeRegex(){return this._themeRegex.lastIndex=0,this._themeRegex}shouldCache(){return"undefined"==typeof window}clear(){this._resolutionCache.clear(),this._pathLookupCache.clear()}/**
4
- * Generate a stable cache key from object and theme, including the theme mode.
5
- */_generateCacheKey(a,b){// Including theme.mode is critical for cache correctness.
6
- return`${ObjHelper.stringify(a)}_${b.mode}_${ObjHelper.stringify(b.system)}`}_evict(a){const b=a.keys();for(let c=0;c<this.CACHE_EVICTION_BATCH_SIZE;c++){const c=b.next().value;if(c)a.delete(c);else break}}}_defineProperty(ThemeResolverCache,"_instance",null);export class ThemeUtil{constructor(){}/**
7
- * Parses a CSS flex shorthand property into its individual components.
8
- *
9
- * The CSS flex property is a shorthand for flex-grow, flex-shrink, and flex-basis.
10
- * This parser handles the most common flex shorthand patterns to extract the shrink value
11
- * when it's explicitly set by the user.
12
- *
13
- * Supported patterns:
14
- * - Keywords: 'none' | 'auto' | 'initial'
15
- * - Single number: '1' → {grow: 1, shrink: 1, basis: '0%'}
16
- * - Full shorthand: '1 0 auto' → {grow: 1, shrink: 0, basis: 'auto'}
17
- * @param flex The CSS flex property value to parse
18
- * @returns FlexComponents object with parsed values, or null if unparseable
19
- * @example
20
- * parseFlexShorthand('none') // → {grow: 0, shrink: 0, basis: 'auto'}
21
- * parseFlexShorthand('1') // → {grow: 1, shrink: 1, basis: '0%'}
22
- * parseFlexShorthand('1 0 auto') // → {grow: 1, shrink: 0, basis: 'auto'}
23
- */static parseFlexShorthand(a){// Early returns for invalid inputs
24
- if(null===a||a===void 0)return null;// Handle numeric flex values (e.g., flex: 1)
25
- if("number"==typeof a)return{grow:a,shrink:1,basis:"0%"};if("string"!=typeof a)return null;const b=a.trim().toLowerCase();if(!b)return null;// Handle CSS keyword values
26
- return"none"===b?{grow:0,shrink:0,basis:"auto"}:"auto"===b?{grow:1,shrink:1,basis:"auto"}:"initial"===b?{grow:0,shrink:1,basis:"auto"}:null}}/**
27
- * Resolves theme variable references in an object's values iteratively.
28
- * This function uses a manual work stack to traverse the object, which prevents
29
- * "Maximum call stack size exceeded" errors for deeply nested objects.
30
- * It performs a "smart merge" by using a copy-on-write strategy, creating new
31
- * objects/arrays only when a value inside them has changed. This preserves
32
- * object references for unchanged parts of the tree, which is critical for
33
- * React's reconciliation and memoization.
34
- *//**
35
- * Resolves default CSS styles to fix common flexbox layout issues.
36
- *
37
- * PRIMARY PURPOSE: Fix the flexbox scrolling problem
38
- * ================================================
39
- *
40
- * THE PROBLEM:
41
- * By default, flex items have `min-width: auto` and `min-height: auto`, which means they
42
- * cannot shrink below their content size. This prevents scrollable containers from working
43
- * properly when they are flex items.
44
- *
45
- * THE SOLUTION:
46
- * 1. Set `minHeight: 0` and `minWidth: 0` to allow flex items to shrink
47
- * 2. Control `flexShrink` behavior based on context to prevent unwanted shrinking
48
- * 3. Respect user's explicit values to avoid overriding intentional styling
49
- *
50
- * FLEX SHRINK BEHAVIOR RULES:
51
- * ===========================
52
- *
53
- * For FLEX CONTAINERS:
54
- * - If overflow is NOT handled AND no wrapping → flexShrink: 0 (prevent shrinking)
55
- * - If overflow is handled OR wrapping enabled → flexShrink: undefined (allow default)
56
- *
57
- * For NON-FLEX CONTAINERS (flex items):
58
- * - Always → flexShrink: 0 (prevent unwanted shrinking)
59
- *
60
- * NESTED SCENARIOS:
61
- * ================
62
- * An element can be both a flex container AND a flex item simultaneously.
63
- * This function handles this correctly by checking if the element itself is a container,
64
- * not whether it's inside a flex context.
65
- *
66
- * EXPLICIT VALUE PRESERVATION:
67
- * ===========================
68
- * - If user sets `flexShrink` explicitly → never override
69
- * - If user sets `flex` shorthand → extract and use the shrink value from it
70
- * - Otherwise → apply smart defaults based on context
71
- * @param style The input CSSProperties object to process
72
- * @returns Processed CSSProperties with resolved defaults
73
- * @example
74
- * // Fix scrollable flex item
75
- * resolveDefaultStyle({
76
- * overflow: 'auto',
77
- * height: '200px'
78
- * })
79
- * // → { overflow: 'auto', height: '200px', flexShrink: 0, minHeight: 0, minWidth: 0 }
80
- * @example
81
- * // Flex container with wrapping (allows shrinking)
82
- * resolveDefaultStyle({
83
- * display: 'flex',
84
- * flexWrap: 'wrap'
85
- * })
86
- * // → { display: 'flex', flexWrap: 'wrap', minHeight: 0, minWidth: 0 }
87
- */_ThemeUtil=ThemeUtil,_defineProperty(ThemeUtil,"themeCache",ThemeResolverCache.getInstance()),_defineProperty(ThemeUtil,"isPlainObject",a=>{if("object"!=typeof a||null===a)return!1;const b=Object.getPrototypeOf(a);return null===b||b===Object.prototype}),_defineProperty(ThemeUtil,"resolveObjWithTheme",(a,b,c={})=>{const{processFunctions:d=!1}=c;if(!b||!b.system||"object"!=typeof b.system||0===Object.keys(b.system).length||!a||0===Object.keys(a).length)return a;const e=b.system;if(_ThemeUtil.themeCache.shouldCache()){const c=_ThemeUtil.themeCache.getResolution(a,b);if(null!==c)return c}const f=[{value:a,isProcessed:!1}],g=new Map,h=new Set,i=a=>{const b=_ThemeUtil.themeCache.getThemeRegex();let c=!1;const d=a.replace(b,(a,b)=>{let d=_ThemeUtil.themeCache.getPathLookup(e,b);if(null===d&&(d=getValueByPath(e,b),_ThemeUtil.themeCache.setPathLookup(e,b,d)),void 0!==d&&null!==d){if(c=!0,"object"==typeof d){if(!Array.isArray(d)&&"default"in d)return d.default;throw new Error("The provided theme path is invalid!")}return d}return a});return c?d:a};// Used for cycle detection within the current traversal path.
88
- for(;0<f.length;){const a=f[f.length-1],c=a.value;if(!_ThemeUtil.isPlainObject(c)&&!Array.isArray(c)){f.pop();continue}if(g.has(c)){f.pop();continue}if(!a.isProcessed){a.isProcessed=!0,h.add(c);const b=Array.isArray(c)?c:Object.values(c);for(let a=b.length-1;0<=a;a--){const c=b[a];// Only push containers that are not already in the current path (cycle detection).
89
- (_ThemeUtil.isPlainObject(c)||Array.isArray(c))&&!h.has(c)&&f.push({value:c,isProcessed:!1})}}else{f.pop(),h.delete(c);// Unwind the path
90
- let a=c;if(Array.isArray(c)){let b=null;for(let a=0;a<c.length;a++){const d=c[a],e=g.get(d)??d;e!==d&&(null===b&&(b=[...c]),b[a]=e)}null!==b&&(a=b)}else{let e=null;for(const a in c)if(Object.prototype.hasOwnProperty.call(c,a)){const f=c[a];let h=g.get(f)??f;if("function"==typeof h&&d){const a=h(b);h="string"==typeof a&&a.includes("theme.")?i(a):a}else"string"==typeof h&&h.includes("theme.")&&(h=i(h));h!==f&&(null===e&&(e=_objectSpread({},c)),e[a]=h)}null!==e&&(a=e)}g.set(c,a)}}const j=g.get(a)??a;return _ThemeUtil.themeCache.shouldCache()&&_ThemeUtil.themeCache.setResolution(a,b,j),j}),_defineProperty(ThemeUtil,"clearThemeCache",()=>{_ThemeUtil.themeCache.clear()}),_defineProperty(ThemeUtil,"resolveDefaultStyle",a=>{if(null===a||a===void 0||"string"==typeof a||"number"==typeof a||"boolean"==typeof a)return{};// === STEP 1: EXTRACT FLEX PROPERTY ===
91
- // Extract flex shorthand to handle it separately from individual flex properties
92
- const b=a,{flex:c}=b,d=_objectWithoutProperties(b,_excluded),e="flex"===d.display||"inline-flex"===d.display,f=!!(d.overflow||d.overflowY||d.overflowX),g=d.flexFlow?.includes("wrap")||"wrap"===d.flexWrap||"wrap-reverse"===d.flexWrap,h="flexShrink"in a&&a.flexShrink!==void 0,i=c?_ThemeUtil.parseFlexShorthand(c):null;// === STEP 2: ANALYZE LAYOUT CONTEXT ===
93
- // Determine what kind of element we're dealing with
94
- // Check if overflow is set (any overflow value indicates potential scrolling)
95
- // Check if flex wrapping is enabled (allows items to wrap to new lines)
96
- // === STEP 3: CHECK FOR EXPLICIT USER VALUES ===
97
- // Respect user's explicit flexShrink setting
98
- // Extract shrink value from flex shorthand if provided
99
- // === STEP 4: DETERMINE FLEX SHRINK BEHAVIOR ===
100
- let j;// Only set flexShrink if user hasn't explicitly provided it
101
- if(!h)// If flex shorthand contains a shrink value, use that
102
- if(i)j=i.shrink;else// Apply context-based defaults
103
- if(!e)// NON-FLEX CONTAINER LOGIC:
104
- // Default flex-shrink to 0 to prevent unwanted shrinking of flex items
105
- j=0;else// FLEX CONTAINER LOGIC:
106
- // Only prevent shrinking when container is constrained (no overflow handling, no wrapping)
107
- if(!f){const a="column"===d.flexDirection||"column-reverse"===d.flexDirection,b="row"===d.flexDirection||"row-reverse"===d.flexDirection||!d.flexDirection;a&&!g?j=0:b&&!g&&(j=0)}// === STEP 5: RETURN RESOLVED STYLES ===
108
- // Combine all processed styles with essential defaults
109
- return _objectSpread({flex:c,// Preserve original flex shorthand
110
- flexShrink:j,// Apply computed or explicit flexShrink
111
- minHeight:0,// Fix flex item scrolling issues
112
- minWidth:0},d)});
File without changes