@meonode/ui 0.4.5 → 0.4.7

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 (51) hide show
  1. package/CHANGELOG.md +35 -5
  2. package/dist/components/meonode-unmounter.client.d.ts +19 -0
  3. package/dist/components/meonode-unmounter.client.d.ts.map +1 -0
  4. package/dist/components/meonode-unmounter.client.js +13 -0
  5. package/dist/components/registry.client.d.ts +9 -1
  6. package/dist/components/registry.client.d.ts.map +1 -1
  7. package/dist/components/registry.client.js +14 -1
  8. package/dist/components/styled-renderer.client.d.ts.map +1 -1
  9. package/dist/components/styled-renderer.client.js +2 -2
  10. package/dist/constants/common.const.d.ts +2 -1
  11. package/dist/constants/common.const.d.ts.map +1 -1
  12. package/dist/constants/common.const.js +1 -1
  13. package/dist/core.node.d.ts +43 -125
  14. package/dist/core.node.d.ts.map +1 -1
  15. package/dist/core.node.js +51 -186
  16. package/dist/helper/common.helper.d.ts +1 -1
  17. package/dist/helper/common.helper.d.ts.map +1 -1
  18. package/dist/hoc/component.hoc.js +2 -2
  19. package/dist/main.d.ts +1 -1
  20. package/dist/main.d.ts.map +1 -1
  21. package/dist/main.js +3 -2
  22. package/dist/types/node.type.d.ts +3 -17
  23. package/dist/types/node.type.d.ts.map +1 -1
  24. package/dist/util/mount-tracker.util.d.ts +26 -0
  25. package/dist/util/mount-tracker.util.d.ts.map +1 -0
  26. package/dist/util/mount-tracker.util.js +15 -0
  27. package/dist/util/navigation-cache-manager.util.d.ts +36 -0
  28. package/dist/util/navigation-cache-manager.util.d.ts.map +1 -0
  29. package/dist/util/navigation-cache-manager.util.js +19 -0
  30. package/dist/util/node.util.d.ts +155 -0
  31. package/dist/util/node.util.d.ts.map +1 -0
  32. package/dist/util/node.util.js +172 -0
  33. package/dist/util/theme.util.d.ts +108 -0
  34. package/dist/util/theme.util.d.ts.map +1 -0
  35. package/dist/util/theme.util.js +117 -0
  36. package/package.json +5 -2
  37. package/dist/helper/mount-tracker.helper.d.ts +0 -16
  38. package/dist/helper/mount-tracker.helper.d.ts.map +0 -1
  39. package/dist/helper/mount-tracker.helper.js +0 -8
  40. package/dist/helper/navigation-cache-manager.helper.d.ts +0 -38
  41. package/dist/helper/navigation-cache-manager.helper.d.ts.map +0 -1
  42. package/dist/helper/navigation-cache-manager.helper.js +0 -34
  43. package/dist/helper/node.helper.d.ts +0 -70
  44. package/dist/helper/node.helper.d.ts.map +0 -1
  45. package/dist/helper/node.helper.js +0 -112
  46. package/dist/helper/safe-cache-manager.helper.d.ts +0 -21
  47. package/dist/helper/safe-cache-manager.helper.d.ts.map +0 -1
  48. package/dist/helper/safe-cache-manager.helper.js +0 -33
  49. package/dist/helper/theme.helper.d.ts +0 -15
  50. package/dist/helper/theme.helper.d.ts.map +0 -1
  51. package/dist/helper/theme.helper.js +0 -16
package/package.json CHANGED
@@ -1,21 +1,24 @@
1
1
  {
2
2
  "name": "@meonode/ui",
3
3
  "description": "A structured approach to component composition, direct CSS-first prop styling, built-in theming, smart prop handling (including raw property pass-through), and dynamic children.",
4
- "version": "0.4.5",
4
+ "version": "0.4.7",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "types": "./dist/main.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": "./dist/main.js",
11
+ "require": "./dist/main.js",
11
12
  "types": "./dist/main.d.ts"
12
13
  },
13
14
  "./client": {
14
15
  "import": "./dist/client.js",
16
+ "require": "./dist/client.js",
15
17
  "types": "./dist/client.d.ts"
16
18
  },
17
19
  "./nextjs-registry": {
18
20
  "import": "./dist/nextjs-registry/index.js",
21
+ "require": "./dist/nextjs-registry/index.js",
19
22
  "types": "./dist/nextjs-registry/index.d.ts"
20
23
  }
21
24
  },
@@ -28,7 +31,7 @@
28
31
  "scripts": {
29
32
  "watch:build": "yarn dlx nodemon --watch src --ext ts,tsx,js,json --exec \"yarn build\"",
30
33
  "lint": "eslint --fix",
31
- "test": "node --stack-size=10000 --experimental-vm-modules node_modules/jest/bin/jest.js --ci --verbose",
34
+ "test": "NODE_OPTIONS='--expose-gc' node --stack-size=10000 --experimental-vm-modules node_modules/jest/bin/jest.js --ci --verbose",
32
35
  "prebuild": "yarn lint && yarn test",
33
36
  "build": "yarn prebuild && rm -rf ./dist && babel src --out-dir dist --extensions \".ts,.tsx,.js\" && tsgo -p tsconfig.build.json --diagnostics && tsc-alias -p tsconfig.build.json",
34
37
  "publish:pre": "./prepublish.sh && yarn build && yarn version -i prerelease && yarn npm publish --tag next",
@@ -1,16 +0,0 @@
1
- import { BaseNode } from '../core.node.js';
2
- /**
3
- * MountTracker keeps track of which BaseNode instances are currently mounted in the DOM.
4
- * It listens for navigation events to trigger cleanup of unmounted nodes from the cache.
5
- */
6
- export declare class MountTracker {
7
- private static _mountedNodes;
8
- private static _navigationListener;
9
- static trackMount(node: BaseNode<any>): void;
10
- static trackUnmount(node: BaseNode<any>): void;
11
- static isMounted(node: BaseNode<any>): boolean;
12
- private static _ensureNavigationListener;
13
- private static _onNavigation;
14
- static cleanup(): void;
15
- }
16
- //# sourceMappingURL=mount-tracker.helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mount-tracker.helper.d.ts","sourceRoot":"","sources":["../../src/helper/mount-tracker.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAG5C;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAoB;IAChD,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAA4B;IAE9D,OAAc,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,QAG3C;IAED,OAAc,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,QAE7C;IAED,OAAc,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO,CAEpD;IAED,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAuBxC,OAAO,CAAC,MAAM,CAAC,aAAa;IAoB5B,OAAc,OAAO,SAMpB;CACF"}
@@ -1,8 +0,0 @@
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 _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(b,c){var d="undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(!d){if(Array.isArray(b)||(d=_unsupportedIterableToArray(b))||c&&b&&"number"==typeof b.length){d&&(b=d);var e=0,f=function F(){};return{s:f,n:function n(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}},e:function e(a){throw a},f:f}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var g,h=!0,i=!1;return{s:function s(){d=d.call(b)},n:function n(){var a=d.next();return h=a.done,a},e:function e(a){i=!0,g=a},f:function f(){try{h||null==d["return"]||d["return"]()}finally{if(i)throw g}}}}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}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}from"../core.node.js";import{__DEV__}from"../constants/common.const.js";/**
2
- * MountTracker keeps track of which BaseNode instances are currently mounted in the DOM.
3
- * It listens for navigation events to trigger cleanup of unmounted nodes from the cache.
4
- */export class MountTracker{static trackMount(a){this._mountedNodes.add(a._stableKey),this._ensureNavigationListener()}static trackUnmount(a){this._mountedNodes["delete"](a._stableKey)}static isMounted(a){return this._mountedNodes.has(a._stableKey)}static _ensureNavigationListener(){var a=this;if(!(this._navigationListener||"undefined"==typeof window)){this._navigationListener=function(){return a._onNavigation()},window.addEventListener("popstate",this._navigationListener);// Override pushState/replaceState
5
- var b=history.pushState;history.pushState=function(){for(var a,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];b.apply(this,d),null===(a=MountTracker._navigationListener)||void 0===a||a.call(MountTracker)};var c=history.replaceState;history.replaceState=function(){for(var a,b=arguments.length,d=Array(b),e=0;e<b;e++)d[e]=arguments[e];c.apply(this,d),null===(a=MountTracker._navigationListener)||void 0===a||a.call(MountTracker)}}// Single listener for all navigation events
6
- }static _onNavigation(){// Only clear cache for UNMOUNTED nodes
7
- var a,b=[],c=_createForOfIteratorHelper(BaseNode._elementCache.entries());try{for(c.s();!(a=c.n()).done;){var d=_slicedToArray(a.value,1),e=d[0];this._mountedNodes.has(e)||b.push(e)}// Clear only unmounted nodes
8
- }catch(a){c.e(a)}finally{c.f()}b.forEach(function(a){return BaseNode._elementCache["delete"](a)}),__DEV__&&console.log("MeoNode: Cleared ".concat(b.length," unmounted elements on navigation"))}static cleanup(){this._navigationListener&&(window.removeEventListener("popstate",this._navigationListener),this._navigationListener=null),this._mountedNodes.clear()}}_defineProperty(MountTracker,"_mountedNodes",new Set),_defineProperty(MountTracker,"_navigationListener",null);
@@ -1,38 +0,0 @@
1
- /**
2
- * NavigationCacheManager listens for navigation events in the browser
3
- * and triggers safe cleanup of the element cache to prevent memory leaks.
4
- * It supports standard browser navigation as well as SPA routing changes.
5
- *
6
- * Framework-agnostic: Works with Next.js, React Router, Vue Router, etc.
7
- */
8
- export declare class NavigationCacheManager {
9
- private static _instance;
10
- private static _originalPushState;
11
- private static _originalReplaceState;
12
- private static _isPatched;
13
- private _isListening;
14
- private _cleanupTimeout;
15
- private _memoryCheckInterval;
16
- private constructor();
17
- static getInstance(): NavigationCacheManager;
18
- /**
19
- * Starts listening for navigation events to trigger cache cleanup.
20
- * This method is idempotent and safe to call multiple times.
21
- */
22
- start(): void;
23
- /**
24
- * Stops listening for navigation events and restores original browser APIs.
25
- * This is important for cleanup during HMR or when unmounting the library.
26
- */
27
- private _stop;
28
- private _handleNavigation;
29
- private _patchHistoryMethods;
30
- private _unpatchHistoryMethods;
31
- private _startMemoryMonitoring;
32
- /**
33
- * Setup automatic cleanup on page unload.
34
- * Covers HMR, navigation away, and browser close.
35
- */
36
- private _setupAutoCleanup;
37
- }
38
- //# sourceMappingURL=navigation-cache-manager.helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation-cache-manager.helper.d.ts","sourceRoot":"","sources":["../../src/helper/navigation-cache-manager.helper.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAsC;IAC9D,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,CAAY;IACnC,OAAO,CAAC,oBAAoB,CAAY;IAExC,OAAO,eAEN;IAED,OAAc,WAAW,IAAI,sBAAsB,CAKlD;IAED;;;OAGG;IACI,KAAK,SAoBX;IAED;;;OAGG;IACH,OAAO,CAAC,KAAK;IA0Bb,OAAO,CAAC,iBAAiB,CAWxB;IAED,OAAO,CAAC,oBAAoB;IA2B5B,OAAO,CAAC,sBAAsB;IAkB9B,OAAO,CAAC,sBAAsB;IAqB9B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;CAyB1B"}
@@ -1,34 +0,0 @@
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 _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{SafeCacheManager}from"./safe-cache-manager.helper.js";import{__DEV__}from"../constants/common.const.js";import{BaseNode}from"../core.node.js";/**
2
- * NavigationCacheManager listens for navigation events in the browser
3
- * and triggers safe cleanup of the element cache to prevent memory leaks.
4
- * It supports standard browser navigation as well as SPA routing changes.
5
- *
6
- * Framework-agnostic: Works with Next.js, React Router, Vue Router, etc.
7
- */export class NavigationCacheManager{constructor(){var a=this;_defineProperty(this,"_isListening",!1),_defineProperty(this,"_cleanupTimeout",null),_defineProperty(this,"_memoryCheckInterval",null),_defineProperty(this,"_handleNavigation",function(){a._cleanupTimeout&&clearTimeout(a._cleanupTimeout),a._cleanupTimeout=setTimeout(function(){var a=SafeCacheManager.safeCleanup();__DEV__&&0<a&&console.log("[MeoNode] Navigation detected. Safely evicted ".concat(a," unmounted elements from cache."))},100)})}// Private constructor for singleton
8
- static getInstance(){return this._instance||(this._instance=new NavigationCacheManager),this._instance}/**
9
- * Starts listening for navigation events to trigger cache cleanup.
10
- * This method is idempotent and safe to call multiple times.
11
- */start(){this._isListening||"undefined"==typeof window||(// Listen for standard browser navigation event
12
- // Patch history methods to catch SPA routing changes
13
- // Optional: Start memory pressure monitoring
14
- // Setup automatic cleanup on page unload ← ADD THIS
15
- this._isListening=!0,window.addEventListener("popstate",this._handleNavigation),this._patchHistoryMethods(),this._startMemoryMonitoring(),this._setupAutoCleanup(),__DEV__&&console.log("[MeoNode] NavigationCacheManager started"))}/**
16
- * Stops listening for navigation events and restores original browser APIs.
17
- * This is important for cleanup during HMR or when unmounting the library.
18
- */_stop(){this._isListening&&"undefined"!=typeof window&&(// Restore original history methods
19
- window.removeEventListener("popstate",this._handleNavigation),this._unpatchHistoryMethods(),this._cleanupTimeout&&(clearTimeout(this._cleanupTimeout),this._cleanupTimeout=null),this._memoryCheckInterval&&(clearInterval(this._memoryCheckInterval),this._memoryCheckInterval=null),this._isListening=!1,__DEV__&&console.log("[MeoNode] NavigationCacheManager stopped"))}_patchHistoryMethods(){var a=this;// Guard against multiple patches (HMR safety)
20
- NavigationCacheManager._isPatched||(// Store original methods
21
- // Patch pushState
22
- // Patch replaceState
23
- NavigationCacheManager._originalPushState=history.pushState,NavigationCacheManager._originalReplaceState=history.replaceState,history.pushState=function(){for(var b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];NavigationCacheManager._originalPushState.apply(history,c),a._handleNavigation()},history.replaceState=function(){for(var b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];NavigationCacheManager._originalReplaceState.apply(history,c),a._handleNavigation()},NavigationCacheManager._isPatched=!0,__DEV__&&console.log("[MeoNode] History methods patched for SPA navigation detection"))}_unpatchHistoryMethods(){NavigationCacheManager._isPatched&&(NavigationCacheManager._originalPushState&&(history.pushState=NavigationCacheManager._originalPushState),NavigationCacheManager._originalReplaceState&&(history.replaceState=NavigationCacheManager._originalReplaceState),NavigationCacheManager._isPatched=!1,__DEV__&&console.log("[MeoNode] History methods restored"));// Restore original methods
24
- }_startMemoryMonitoring(){// Only in development or if explicitly enabled
25
- __DEV__&&"undefined"!=typeof performance&&"memory"in performance&&(this._memoryCheckInterval=setInterval(function(){var a=performance.memory;if(a){var b=a.usedJSHeapSize/a.jsHeapSizeLimit;// Trigger emergency cleanup at 85% memory usage
26
- if(.85<b){var c=SafeCacheManager.emergencyCleanup();console.warn("[MeoNode] High memory usage (".concat((100*b).toFixed(1),"%). ")+"Emergency cleanup evicted ".concat(c," entries."))}}},3e4));// Check if Performance Memory API is available (Chrome/Edge only)
27
- }/**
28
- * Setup automatic cleanup on page unload.
29
- * Covers HMR, navigation away, and browser close.
30
- */_setupAutoCleanup(){var a=this;// Only set up once
31
- window.__MEONODE_CLEANUP_REGISTERED||(// Handle page unload (navigation away, refresh, close)
32
- // Handle visibility change (tab switching, minimize)
33
- // Good opportunity for lazy cleanup
34
- window.addEventListener("beforeunload",function(){a._stop(),BaseNode.clearCaches()}),document.addEventListener("visibilitychange",function(){document.hidden&&setTimeout(function(){document.hidden&&SafeCacheManager.safeCleanup()},5e3)}),window.__MEONODE_CLEANUP_REGISTERED=!0)}}_defineProperty(NavigationCacheManager,"_instance",null),_defineProperty(NavigationCacheManager,"_originalPushState",null),_defineProperty(NavigationCacheManager,"_originalReplaceState",null),_defineProperty(NavigationCacheManager,"_isPatched",!1);
@@ -1,70 +0,0 @@
1
- import type { CSSInterpolation } from '@emotion/serialize';
2
- import { BaseNode } from '../core.node.js';
3
- /**
4
- * Type guard to check if an object is a NodeInstance.
5
- *
6
- * A NodeInstance is expected to be a non-null object with:
7
- * - an 'element' property,
8
- * - a 'render' method,
9
- * - a 'toPortal' method,
10
- * - and an 'isBaseNode' property.
11
- * @param obj The object to check.
12
- * @returns True if the object is a NodeInstance, false otherwise.
13
- */
14
- export declare const isNodeInstance: (obj: unknown) => obj is BaseNode<any>;
15
- /**
16
- * Resolves default CSS styles to fix common flexbox layout issues.
17
- *
18
- * PRIMARY PURPOSE: Fix the flexbox scrolling problem
19
- * ================================================
20
- *
21
- * THE PROBLEM:
22
- * By default, flex items have `min-width: auto` and `min-height: auto`, which means they
23
- * cannot shrink below their content size. This prevents scrollable containers from working
24
- * properly when they are flex items.
25
- *
26
- * THE SOLUTION:
27
- * 1. Set `minHeight: 0` and `minWidth: 0` to allow flex items to shrink
28
- * 2. Control `flexShrink` behavior based on context to prevent unwanted shrinking
29
- * 3. Respect user's explicit values to avoid overriding intentional styling
30
- *
31
- * FLEX SHRINK BEHAVIOR RULES:
32
- * ===========================
33
- *
34
- * For FLEX CONTAINERS:
35
- * - If overflow is NOT handled AND no wrapping → flexShrink: 0 (prevent shrinking)
36
- * - If overflow is handled OR wrapping enabled → flexShrink: undefined (allow default)
37
- *
38
- * For NON-FLEX CONTAINERS (flex items):
39
- * - Always → flexShrink: 0 (prevent unwanted shrinking)
40
- *
41
- * NESTED SCENARIOS:
42
- * ================
43
- * An element can be both a flex container AND a flex item simultaneously.
44
- * This function handles this correctly by checking if the element itself is a container,
45
- * not whether it's inside a flex context.
46
- *
47
- * EXPLICIT VALUE PRESERVATION:
48
- * ===========================
49
- * - If user sets `flexShrink` explicitly → never override
50
- * - If user sets `flex` shorthand → extract and use the shrink value from it
51
- * - Otherwise → apply smart defaults based on context
52
- * @param style The input CSSProperties object to process
53
- * @returns Processed CSSProperties with resolved defaults
54
- * @example
55
- * // Fix scrollable flex item
56
- * resolveDefaultStyle({
57
- * overflow: 'auto',
58
- * height: '200px'
59
- * })
60
- * // → { overflow: 'auto', height: '200px', flexShrink: 0, minHeight: 0, minWidth: 0 }
61
- * @example
62
- * // Flex container with wrapping (allows shrinking)
63
- * resolveDefaultStyle({
64
- * display: 'flex',
65
- * flexWrap: 'wrap'
66
- * })
67
- * // → { display: 'flex', flexWrap: 'wrap', minHeight: 0, minWidth: 0 }
68
- */
69
- export declare const resolveDefaultStyle: (style: CSSInterpolation) => {};
70
- //# sourceMappingURL=node.helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.helper.d.ts","sourceRoot":"","sources":["../../src/helper/node.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,oBAAoB,CAAA;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,wCAS1B,CAAA;AA8DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,eAAO,MAAM,mBAAmB,iCAmE/B,CAAA"}
@@ -1,112 +0,0 @@
1
- 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
- * Type guard to check if an object is a NodeInstance.
3
- *
4
- * A NodeInstance is expected to be a non-null object with:
5
- * - an 'element' property,
6
- * - a 'render' method,
7
- * - a 'toPortal' method,
8
- * - and an 'isBaseNode' property.
9
- * @param obj The object to check.
10
- * @returns True if the object is a NodeInstance, false otherwise.
11
- */export var isNodeInstance=function isNodeInstance(a){return"object"===_typeof(a)&&null!==a&&"element"in a&&"function"==typeof a.render&&"function"==typeof a.toPortal&&"isBaseNode"in a};/**
12
- * Parsed flex shorthand components for CSS flex property
13
- * @interface FlexComponents
14
- * @property grow - The flex-grow value (how much the item should grow)
15
- * @property shrink - The flex-shrink value (how much the item should shrink)
16
- * @property basis - The flex-basis value (initial main size before free space is distributed)
17
- *//**
18
- * Parses a CSS flex shorthand property into its individual components.
19
- *
20
- * The CSS flex property is a shorthand for flex-grow, flex-shrink, and flex-basis.
21
- * This parser handles the most common flex shorthand patterns to extract the shrink value
22
- * when it's explicitly set by the user.
23
- *
24
- * Supported patterns:
25
- * - Keywords: 'none' | 'auto' | 'initial'
26
- * - Single number: '1' → {grow: 1, shrink: 1, basis: '0%'}
27
- * - Full shorthand: '1 0 auto' → {grow: 1, shrink: 0, basis: 'auto'}
28
- * @param flex The CSS flex property value to parse
29
- * @returns FlexComponents object with parsed values, or null if unparseable
30
- * @example
31
- * parseFlexShorthand('none') // → {grow: 0, shrink: 0, basis: 'auto'}
32
- * parseFlexShorthand('1') // → {grow: 1, shrink: 1, basis: '0%'}
33
- * parseFlexShorthand('1 0 auto') // → {grow: 1, shrink: 0, basis: 'auto'}
34
- */function parseFlexShorthand(a){// Early returns for invalid inputs
35
- if(null===a||a===void 0)return null;// Handle numeric flex values (e.g., flex: 1)
36
- if("number"==typeof a)return{grow:a,shrink:1,basis:"0%"};if("string"!=typeof a)return null;var b=a.trim().toLowerCase();if(!b)return null;// Handle CSS keyword values
37
- 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}/**
38
- * Resolves default CSS styles to fix common flexbox layout issues.
39
- *
40
- * PRIMARY PURPOSE: Fix the flexbox scrolling problem
41
- * ================================================
42
- *
43
- * THE PROBLEM:
44
- * By default, flex items have `min-width: auto` and `min-height: auto`, which means they
45
- * cannot shrink below their content size. This prevents scrollable containers from working
46
- * properly when they are flex items.
47
- *
48
- * THE SOLUTION:
49
- * 1. Set `minHeight: 0` and `minWidth: 0` to allow flex items to shrink
50
- * 2. Control `flexShrink` behavior based on context to prevent unwanted shrinking
51
- * 3. Respect user's explicit values to avoid overriding intentional styling
52
- *
53
- * FLEX SHRINK BEHAVIOR RULES:
54
- * ===========================
55
- *
56
- * For FLEX CONTAINERS:
57
- * - If overflow is NOT handled AND no wrapping → flexShrink: 0 (prevent shrinking)
58
- * - If overflow is handled OR wrapping enabled → flexShrink: undefined (allow default)
59
- *
60
- * For NON-FLEX CONTAINERS (flex items):
61
- * - Always → flexShrink: 0 (prevent unwanted shrinking)
62
- *
63
- * NESTED SCENARIOS:
64
- * ================
65
- * An element can be both a flex container AND a flex item simultaneously.
66
- * This function handles this correctly by checking if the element itself is a container,
67
- * not whether it's inside a flex context.
68
- *
69
- * EXPLICIT VALUE PRESERVATION:
70
- * ===========================
71
- * - If user sets `flexShrink` explicitly → never override
72
- * - If user sets `flex` shorthand → extract and use the shrink value from it
73
- * - Otherwise → apply smart defaults based on context
74
- * @param style The input CSSProperties object to process
75
- * @returns Processed CSSProperties with resolved defaults
76
- * @example
77
- * // Fix scrollable flex item
78
- * resolveDefaultStyle({
79
- * overflow: 'auto',
80
- * height: '200px'
81
- * })
82
- * // → { overflow: 'auto', height: '200px', flexShrink: 0, minHeight: 0, minWidth: 0 }
83
- * @example
84
- * // Flex container with wrapping (allows shrinking)
85
- * resolveDefaultStyle({
86
- * display: 'flex',
87
- * flexWrap: 'wrap'
88
- * })
89
- * // → { display: 'flex', flexWrap: 'wrap', minHeight: 0, minWidth: 0 }
90
- */export var resolveDefaultStyle=function resolveDefaultStyle(a){var b;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
- var c=a,d=c.flex,e=_objectWithoutProperties(c,_excluded),f="flex"===e.display||"inline-flex"===e.display,g=!!(e.overflow||e.overflowY||e.overflowX),h=(null===(b=e.flexFlow)||void 0===b?void 0:b.includes("wrap"))||"wrap"===e.flexWrap||"wrap-reverse"===e.flexWrap,i="flexShrink"in a&&a.flexShrink!==void 0,j=d?parseFlexShorthand(d):null,k=void 0;// === 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
- // Only set flexShrink if user hasn't explicitly provided it
101
- if(!i)// If flex shorthand contains a shrink value, use that
102
- if(j)k=j.shrink;else// Apply context-based defaults
103
- if(!f)// NON-FLEX CONTAINER LOGIC:
104
- // Default flex-shrink to 0 to prevent unwanted shrinking of flex items
105
- k=0;else// FLEX CONTAINER LOGIC:
106
- // Only prevent shrinking when container is constrained (no overflow handling, no wrapping)
107
- if(!g){var l="column"===e.flexDirection||"column-reverse"===e.flexDirection,m="row"===e.flexDirection||"row-reverse"===e.flexDirection||!e.flexDirection;l&&!h?k=0:m&&!h&&(k=0)}// === STEP 5: RETURN RESOLVED STYLES ===
108
- // Combine all processed styles with essential defaults
109
- return _objectSpread({flex:d,// Preserve original flex shorthand
110
- flexShrink:k,// Apply computed or explicit flexShrink
111
- minHeight:0,// Fix flex item scrolling issues
112
- minWidth:0},e)};
@@ -1,21 +0,0 @@
1
- /**
2
- * SafeCacheManager provides methods to clean up the element cache
3
- * in a way that minimizes the risk of removing elements that are still in use.
4
- * It uses various eviction policies to determine which entries can be safely removed.
5
- */
6
- export declare class SafeCacheManager {
7
- private static _evictionPolicies;
8
- /**
9
- * Performs a safe cleanup of the element cache.
10
- * It applies standard eviction policies to remove unmounted and old entries.
11
- * This is typically called after a navigation event.
12
- */
13
- static safeCleanup(): number;
14
- /**
15
- * Performs an emergency cleanup of the element cache.
16
- * This uses a more aggressive eviction policy and is intended to be called
17
- * when memory pressure is detected.
18
- */
19
- static emergencyCleanup(): number;
20
- }
21
- //# sourceMappingURL=safe-cache-manager.helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe-cache-manager.helper.d.ts","sourceRoot":"","sources":["../../src/helper/safe-cache-manager.helper.ts"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAgD/B;IAED;;;;OAIG;IACH,OAAc,WAAW,IAAI,MAAM,CAclC;IAED;;;;OAIG;IACH,OAAc,gBAAgB,IAAI,MAAM,CAUvC;CACF"}
@@ -1,33 +0,0 @@
1
- function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))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 _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 _createForOfIteratorHelper(b,c){var d="undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(!d){if(Array.isArray(b)||(d=_unsupportedIterableToArray(b))||c&&b&&"number"==typeof b.length){d&&(b=d);var e=0,f=function F(){};return{s:f,n:function n(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}},e:function e(a){throw a},f:f}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var g,h=!0,i=!1;return{s:function s(){d=d.call(b)},n:function n(){var a=d.next();return h=a.done,a},e:function e(a){i=!0,g=a},f:function f(){try{h||null==d["return"]||d["return"]()}finally{if(i)throw g}}}}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}import{BaseNode}from"../core.node.js";import{MountTracker}from"./mount-tracker.helper.js";// Estimates the "size" of a React element based on its props and children.
2
- // This is a heuristic to help with eviction decisions.
3
- function _estimateElementSize(a){if(!a)return 0;var b=1;if(a.props&&(b+=Object.keys(a.props).length,a.props.children)){var c,d=Array.isArray(a.props.children)?a.props.children:[a.props.children],e=_createForOfIteratorHelper(d);try{for(e.s();!(c=e.n()).done;){var f=c.value;"object"===_typeof(f)&&null!==f&&"props"in f&&(b+=_estimateElementSize(f))}}catch(a){e.e(a)}finally{e.f()}}return b}/**
4
- * SafeCacheManager provides methods to clean up the element cache
5
- * in a way that minimizes the risk of removing elements that are still in use.
6
- * It uses various eviction policies to determine which entries can be safely removed.
7
- */export class SafeCacheManager{/**
8
- * Performs a safe cleanup of the element cache.
9
- * It applies standard eviction policies to remove unmounted and old entries.
10
- * This is typically called after a navigation event.
11
- */static safeCleanup(){var a,b=[this._evictionPolicies.evictUnmounted,this._evictionPolicies.evictOldUnmounted],c=0,d=_createForOfIteratorHelper(BaseNode._elementCache.entries());try{var e=function _loop(){var d=_slicedToArray(a.value,2),e=d[0],f=d[1];// An entry is evicted if ANY policy decides it should be.
12
- if(b.some(function(a){return a(f)})){var g;// Trigger unmount tracking.
13
- null===(g=f.onEvict)||void 0===g||g.call(f),BaseNode._elementCache["delete"](e),c++}};for(d.s();!(a=d.n()).done;)e()}catch(a){d.e(a)}finally{d.f()}return c}/**
14
- * Performs an emergency cleanup of the element cache.
15
- * This uses a more aggressive eviction policy and is intended to be called
16
- * when memory pressure is detected.
17
- */static emergencyCleanup(){var a,b=0,c=_createForOfIteratorHelper(BaseNode._elementCache.entries());try{for(c.s();!(a=c.n()).done;){var d=_slicedToArray(a.value,2),e=d[0],f=d[1];if(this._evictionPolicies.emergencyEviction(f)){var g;null===(g=f.onEvict)||void 0===g||g.call(f),BaseNode._elementCache["delete"](e),b++}}}catch(a){c.e(a)}finally{c.f()}return b}}_defineProperty(SafeCacheManager,"_evictionPolicies",{/**
18
- * Evicts entries that are either not mounted or whose node instance has been garbage-collected.
19
- * This is the primary policy for preventing memory leaks from stale cache entries.
20
- */evictUnmounted:function evictUnmounted(a){var b=a.nodeRef.deref();return!b||!MountTracker.isMounted(b)},/**
21
- * Evicts unmounted entries that are older than a specified threshold (e.g., 10 minutes).
22
- * This is useful for cleaning up caches during long-running sessions.
23
- */evictOldUnmounted:function evictOldUnmounted(a){var b=a.nodeRef.deref();return!b||!MountTracker.isMounted(b)&&Date.now()-a.createdAt>600000;// 10 minutes
24
- },/**
25
- * An aggressive eviction policy for high memory pressure scenarios.
26
- * It preserves mounted components but otherwise evicts based on a score
27
- * calculated from element size and usage frequency.
28
- */emergencyEviction:function emergencyEviction(a){var b=a.nodeRef.deref();if(!b)return!0;// Evict if GC'd
29
- if(MountTracker.isMounted(b))return!1;// Still preserve mounted components.
30
- // Preferentially evict large, infrequently used components.
31
- var c=_estimateElementSize(a.renderedElement),d=1e3/(a.accessCount+1);// Inversely proportional to access count.
32
- return 1e3<c*d;// Eviction threshold.
33
- }});
@@ -1,15 +0,0 @@
1
- import type { Theme } from '../types/node.type.js';
2
- /**
3
- * Resolves theme variable references in an object's values iteratively.
4
- * This function uses a manual work stack to traverse the object, which prevents
5
- * "Maximum call stack size exceeded" errors for deeply nested objects.
6
- * It performs a "smart merge" by using a copy-on-write strategy, creating new
7
- * objects/arrays only when a value inside them has changed. This preserves
8
- * object references for unchanged parts of the tree, which is critical for
9
- * React's reconciliation and memoization.
10
- */
11
- export declare const resolveObjWithTheme: (obj?: Record<string, any>, theme?: Theme | undefined, options?: {
12
- processFunctions?: boolean | undefined;
13
- }) => any;
14
- export declare const clearThemeCache: () => void;
15
- //# sourceMappingURL=theme.helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.helper.d.ts","sourceRoot":"","sources":["../../src/helper/theme.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAe,MAAM,yBAAyB,CAAA;AA0GjE;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB;;SAoH/B,CAAA;AAED,eAAO,MAAM,eAAe,YAE3B,CAAA"}
@@ -1,16 +0,0 @@
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";var CACHE_SIZE_LIMIT=500,CACHE_EVICTION_BATCH_SIZE=50;/**
2
- * Cache manager for theme resolution operations.
3
- */class ThemeResolverCache{constructor(){_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}/**
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"".concat(ObjHelper.stringify(a),"_").concat(b.mode,"_").concat(ObjHelper.stringify(b.system))}getResolution(a,b){var 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){var d=this._generateCacheKey(a,b);this._resolutionCache.set(d,c),this._resolutionCache.size>CACHE_SIZE_LIMIT&&this._evict(this._resolutionCache)}getPathLookup(a,b){var c="".concat(ObjHelper.stringify(a),"_").concat(b),d=this._pathLookupCache.get(c);return d&&(this._pathLookupCache["delete"](c),this._pathLookupCache.set(c,d)),d||null}setPathLookup(a,b,c){var d="".concat(ObjHelper.stringify(a),"_").concat(b);this._pathLookupCache.set(d,c),this._pathLookupCache.size>CACHE_SIZE_LIMIT&&this._evict(this._pathLookupCache)}_evict(a){for(var b,c=a.keys(),d=0;d<CACHE_EVICTION_BATCH_SIZE&&(b=c.next().value,b);d++)a["delete"](b)}getThemeRegex(){return this._themeRegex.lastIndex=0,this._themeRegex}shouldCache(){return"undefined"==typeof window}clear(){this._resolutionCache.clear(),this._pathLookupCache.clear()}}_defineProperty(ThemeResolverCache,"_instance",null);var themeCache=ThemeResolverCache.getInstance(),isPlainObject=function isPlainObject(a){if("object"!==_typeof(a)||null===a)return!1;var b=Object.getPrototypeOf(a);return null===b||b===Object.prototype};/**
7
- * Resolves theme variable references in an object's values iteratively.
8
- * This function uses a manual work stack to traverse the object, which prevents
9
- * "Maximum call stack size exceeded" errors for deeply nested objects.
10
- * It performs a "smart merge" by using a copy-on-write strategy, creating new
11
- * objects/arrays only when a value inside them has changed. This preserves
12
- * object references for unchanged parts of the tree, which is critical for
13
- * React's reconciliation and memoization.
14
- */export var resolveObjWithTheme=function resolveObjWithTheme(){var a,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=1<arguments.length?arguments[1]:void 0,d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},e=d.processFunctions;if(!c||!c.system||"object"!==_typeof(c.system)||0===Object.keys(c.system).length||0===Object.keys(b).length)return b;var f=c.system;if(themeCache.shouldCache()){var g=themeCache.getResolution(b,c);if(null!==g)return g}// Used for cycle detection within the current traversal path.
15
- for(var h=[{value:b,isProcessed:!1}],j=new Map,k=new Set,l=function processThemeString(a){var b=themeCache.getThemeRegex(),c=!1,d=a.replace(b,function(a,b){var d=themeCache.getPathLookup(f,b);return null===d&&(d=getValueByPath(f,b),themeCache.setPathLookup(f,b,d)),void 0!==d&&null!==d?(c=!0,"object"===_typeof(d)&&!Array.isArray(d)&&"default"in d?d["default"]:d):a});return c?d:a};0<h.length;){var m=h[h.length-1],n=m.value;if(!isPlainObject(n)&&!Array.isArray(n)){h.pop();continue}if(j.has(n)){h.pop();continue}if(!m.isProcessed){m.isProcessed=!0,k.add(n);for(var o,p=Array.isArray(n)?n:Object.values(n),q=p.length-1;0<=q;q--)o=p[q],(isPlainObject(o)||Array.isArray(o))&&!k.has(o)&&h.push({value:o,isProcessed:!1})}else{h.pop(),k["delete"](n);// Unwind the path
16
- var r=n;if(Array.isArray(n)){for(var s=null,t=0;t<n.length;t++){var u,v=n[t],w=null!==(u=j.get(v))&&void 0!==u?u:v;w!==v&&(null===s&&(s=[...n]),s[t]=w)}null!==s&&(r=s)}else{var x=null;for(var y in n)if(Object.prototype.hasOwnProperty.call(n,y)){var z,A=n[y],B=null!==(z=j.get(A))&&void 0!==z?z:A;if("function"==typeof B&&void 0!==e&&e){var C=B(c);B="string"==typeof C&&C.includes("theme.")?l(C):C}else"string"==typeof B&&B.includes("theme.")&&(B=l(B));B!==A&&(null===x&&(x=_objectSpread({},n)),x[y]=B)}null!==x&&(r=x)}j.set(n,r)}}var D=null!==(a=j.get(b))&&void 0!==a?a:b;return themeCache.shouldCache()&&themeCache.setResolution(b,c,D),D};export var clearThemeCache=function clearThemeCache(){themeCache.clear()};