@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.
- package/CHANGELOG.md +35 -5
- package/dist/components/meonode-unmounter.client.d.ts +19 -0
- package/dist/components/meonode-unmounter.client.d.ts.map +1 -0
- package/dist/components/meonode-unmounter.client.js +13 -0
- package/dist/components/registry.client.d.ts +9 -1
- package/dist/components/registry.client.d.ts.map +1 -1
- package/dist/components/registry.client.js +14 -1
- package/dist/components/styled-renderer.client.d.ts.map +1 -1
- package/dist/components/styled-renderer.client.js +2 -2
- package/dist/constants/common.const.d.ts +2 -1
- package/dist/constants/common.const.d.ts.map +1 -1
- package/dist/constants/common.const.js +1 -1
- package/dist/core.node.d.ts +43 -125
- package/dist/core.node.d.ts.map +1 -1
- package/dist/core.node.js +51 -186
- package/dist/helper/common.helper.d.ts +1 -1
- package/dist/helper/common.helper.d.ts.map +1 -1
- package/dist/hoc/component.hoc.js +2 -2
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -2
- package/dist/types/node.type.d.ts +3 -17
- package/dist/types/node.type.d.ts.map +1 -1
- package/dist/util/mount-tracker.util.d.ts +26 -0
- package/dist/util/mount-tracker.util.d.ts.map +1 -0
- package/dist/util/mount-tracker.util.js +15 -0
- package/dist/util/navigation-cache-manager.util.d.ts +36 -0
- package/dist/util/navigation-cache-manager.util.d.ts.map +1 -0
- package/dist/util/navigation-cache-manager.util.js +19 -0
- package/dist/util/node.util.d.ts +155 -0
- package/dist/util/node.util.d.ts.map +1 -0
- package/dist/util/node.util.js +172 -0
- package/dist/util/theme.util.d.ts +108 -0
- package/dist/util/theme.util.d.ts.map +1 -0
- package/dist/util/theme.util.js +117 -0
- package/package.json +5 -2
- package/dist/helper/mount-tracker.helper.d.ts +0 -16
- package/dist/helper/mount-tracker.helper.d.ts.map +0 -1
- package/dist/helper/mount-tracker.helper.js +0 -8
- package/dist/helper/navigation-cache-manager.helper.d.ts +0 -38
- package/dist/helper/navigation-cache-manager.helper.d.ts.map +0 -1
- package/dist/helper/navigation-cache-manager.helper.js +0 -34
- package/dist/helper/node.helper.d.ts +0 -70
- package/dist/helper/node.helper.d.ts.map +0 -1
- package/dist/helper/node.helper.js +0 -112
- package/dist/helper/safe-cache-manager.helper.d.ts +0 -21
- package/dist/helper/safe-cache-manager.helper.d.ts.map +0 -1
- package/dist/helper/safe-cache-manager.helper.js +0 -33
- package/dist/helper/theme.helper.d.ts +0 -15
- package/dist/helper/theme.helper.d.ts.map +0 -1
- package/dist/helper/theme.helper.js +0 -16
package/dist/core.node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _BaseNode,_excluded=["
|
|
1
|
+
var _BaseNode,_excluded=["ref","children"],_excluded2=["key"],_excluded3=["children","key","css","nativeProps","disableEmotion"];function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _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{createElement,isValidElement,Fragment}from"react";import{isFragment,isValidElementType}from"./helper/react-is.helper.js";import{getComponentType,getElementTypeName,hasNoStyleTag}from"./helper/common.helper.js";import StyledRenderer from"./components/styled-renderer.client.js";import{__DEBUG__}from"./constants/common.const.js";import{MountTrackerUtil}from"./util/mount-tracker.util.js";import MeoNodeUnmounter from"./components/meonode-unmounter.client.js";import{NavigationCacheManagerUtil}from"./util/navigation-cache-manager.util.js";import{NodeUtil}from"./util/node.util.js";import{ThemeUtil}from"./util/theme.util.js";/**
|
|
2
2
|
* The core abstraction of the MeoNode library. It wraps a React element or component,
|
|
3
3
|
* providing a unified interface for processing props, normalizing children, and handling styles.
|
|
4
4
|
* This class is central to the library's ability to offer a JSX-free, fluent API for building UIs.
|
|
@@ -6,47 +6,20 @@ var _BaseNode,_excluded=["key","children","ref"],_excluded2=["ref","key","childr
|
|
|
6
6
|
* @class BaseNode
|
|
7
7
|
* @template E - The type of React element or component this node represents.
|
|
8
8
|
*/export class BaseNode{constructor(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=2<arguments.length?arguments[2]:void 0;// Element type validation is performed once at construction to prevent invalid nodes from being created.
|
|
9
|
-
if(_defineProperty(this,"rawProps",{}),_defineProperty(this,"isBaseNode",!0),_defineProperty(this,"_lastPropsRef",null)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var e=b.key,f=b.children,g=b.ref,h=_objectWithoutProperties(b,_excluded);this._stableKey=this._getCachedSignature(h),void 0!==e&&null!==e&&(this._stableKey="".concat(e+"",":").concat(this._stableKey)),BaseNode._isServer||BaseNode._navigationStarted||(NavigationCacheManager.getInstance().start(),BaseNode._navigationStarted=!0)}/**
|
|
9
|
+
if(_defineProperty(this,"instanceId",Math.random().toString(36).slice(2)+Date.now().toString(36)),_defineProperty(this,"rawProps",{}),_defineProperty(this,"isBaseNode",!0),_defineProperty(this,"_lastPropsRef",null),!isValidElementType(a)){var d=getComponentType(a);throw new Error("Invalid element type: ".concat(d," provided!"))}this.element=a,this.rawProps=b,this._deps=c;// Extract commonly handled props; the remaining `propsForSignature` are used to compute a stable hash.
|
|
10
|
+
var e=b.ref,f=b.children,g=_objectWithoutProperties(b,_excluded);// Generate or get cached stable key
|
|
11
|
+
this.stableKey=this._getStableKey(g),NodeUtil.isServer||BaseNode._navigationStarted||(NavigationCacheManagerUtil.getInstance().start(),BaseNode._navigationStarted=!0)}/**
|
|
13
12
|
* Lazily processes and retrieves the final, normalized props for the node.
|
|
14
13
|
* The props are processed only once and then cached for subsequent accesses.
|
|
15
14
|
* @getter props
|
|
16
|
-
*/get props(){return this._props||(this._props=this.
|
|
15
|
+
*/get props(){return this._props||(this._props=NodeUtil.processProps(this.element,this.rawProps,this.stableKey)),this._props}/**
|
|
17
16
|
* Returns the dependency list associated with this node.
|
|
18
17
|
* Used by the renderer to decide if the node (and subtree) should update.
|
|
19
18
|
* Mirrors React hook semantics: `undefined` means always update; when an
|
|
20
19
|
* array is provided a shallow comparison against previous deps determines
|
|
21
20
|
* whether a re-render is required.
|
|
22
21
|
* @getter deps
|
|
23
|
-
*/get dependencies(){return this._deps}
|
|
24
|
-
/**
|
|
25
|
-
* FNV-1a hash function.
|
|
26
|
-
* @method _fnv1aHash
|
|
27
|
-
*/static _fnv1aHash(a){// FNV offset basis
|
|
28
|
-
for(var b=Math.imul,c=2166136261,d=0;d<a.length;d++)c^=a.charCodeAt(d),c=b(c,16777619);return c>>>0;// Convert to unsigned 32-bit integer
|
|
29
|
-
}/**
|
|
30
|
-
* djb2 hash function.
|
|
31
|
-
* @method _djb2Hash
|
|
32
|
-
*/static _djb2Hash(a){for(var b=5381,c=0;c<a.length;c++)b=33*b^a.charCodeAt(c);return b>>>0;// Convert to unsigned 32-bit integer
|
|
33
|
-
}/**
|
|
34
|
-
* Combines FNV-1a and djb2 hash functions for a more robust signature.
|
|
35
|
-
* @method _hashString
|
|
36
|
-
*/static _hashString(a){var b=BaseNode._fnv1aHash(a),c=BaseNode._djb2Hash(a);return"".concat(b.toString(36),"_").concat(c.toString(36));// Combine and convert to base36
|
|
37
|
-
}/**
|
|
38
|
-
* Performs a shallow equality check between two objects.
|
|
39
|
-
* @method _shallowEqual
|
|
40
|
-
*/_shallowEqual(c,a){var b=Object.keys(c),d=Object.keys(a);return!(b.length!==d.length)&&b.every(function(b){return c[b]===a[b]})}/**
|
|
41
|
-
* Generates a stable identifier for the given element type.
|
|
42
|
-
* For primitive types (strings), it returns the string itself.
|
|
43
|
-
* For component types (functions, classes, exotic components), it generates
|
|
44
|
-
* and caches a unique ID using a WeakMap to ensure stability across calls.
|
|
45
|
-
* @method _getStableElementId
|
|
46
|
-
*/static _getStableElementId(a){if(a===StrictMode)return"StrictMode";if("string"==typeof a)return a;// On server, avoid WeakMap caching. Directly return a stable string identifier.
|
|
47
|
-
if(BaseNode._isServer)try{return getElementTypeName(a)}catch(a){// Fallback for components without a name
|
|
48
|
-
return"ServerComponentFallback_".concat(BaseNode._elementIdCounter++)}// Client-side: Use WeakMap to maintain stable IDs across calls
|
|
49
|
-
return BaseNode._elementIdMap.has(a)||BaseNode._elementIdMap.set(a,"Component_".concat(BaseNode._elementIdCounter++)),BaseNode._elementIdMap.get(a)}/**
|
|
22
|
+
*/get dependencies(){return this._deps}/**
|
|
50
23
|
* Generates or returns a cached signature representing the props shape and values.
|
|
51
24
|
* The signature is used as a stable key for caching prop-derived computations (e.g. CSS extraction).
|
|
52
25
|
* - Uses a fast reference check to return the previous signature if the same props object is passed.
|
|
@@ -54,129 +27,18 @@ return BaseNode._elementIdMap.has(a)||BaseNode._elementIdMap.set(a,"Component_".
|
|
|
54
27
|
* containing only style-related keys, event handlers, className/css and a `_keyCount` to avoid
|
|
55
28
|
* expensive serialization of huge objects while still retaining reasonable cache discrimination.
|
|
56
29
|
* - Stores the last props reference and computed signature to speed up repeated calls with the same object.
|
|
30
|
+
* @param key Key passed for prefix if exist
|
|
57
31
|
* @param props The props object to create a signature for.
|
|
58
32
|
* @returns A compact string signature suitable for use as a cache key.
|
|
59
|
-
*/
|
|
60
|
-
*
|
|
61
|
-
* This
|
|
62
|
-
*
|
|
63
|
-
* @method _createPropSignature
|
|
64
|
-
*/static _createPropSignature(a,b){// Safe element identification that works with Next.js Client Components
|
|
65
|
-
var c;if(BaseNode._isServer)c=BaseNode._getStableElementId(a);else try{c=getElementTypeName(a)}catch(b){__DEV__&&console.error("MeoNode: Could not determine element name for signature.",b),c=BaseNode._getStableElementId(a)}var d,e=Object.keys(b).sort(),f="".concat(c,":"),g=_createForOfIteratorHelper(e);try{for(g.s();!(d=g.n()).done;){var h=d.value,i=b[h],j=void 0,k=_typeof(i);if("string"===k||"number"===k||"boolean"===k)j="".concat(h,":").concat(i,";");else if(null===i)j="".concat(h,":null;");else if(i===void 0)j="".concat(h,":undefined;");else if(Array.isArray(i)){// Hash primitive values in arrays for better cache hits
|
|
66
|
-
var l=i.filter(function(a){var b=_typeof(a);return"string"===b||"number"===b||"boolean"===b||null===a});j=l.length===i.length?"".concat(h,":[").concat(l.join(","),"];"):"".concat(h,":[").concat(i.length,"];")}else{// Include sorted keys for object structure signature
|
|
67
|
-
var m=Object.keys(i).sort();j="".concat(h,":{").concat(m.join(","),"};")}f+=j}}catch(a){g.e(a)}finally{g.f()}return BaseNode._hashString(f)}/**
|
|
68
|
-
* Retrieves computed CSS props from the cache with LRU tracking.
|
|
69
|
-
* Access time and hit count are tracked for smarter eviction.
|
|
70
|
-
* @method _getCachedCssProps
|
|
71
|
-
*/static _getCachedCssProps(a,b){if(BaseNode._isServer)return{cssProps:getCSSProps(a)};var c=BaseNode._propProcessingCache.get(b);if(c)return c.lastAccess=Date.now(),c.hitCount++,{cssProps:c.cssProps};var d=getCSSProps(a);return BaseNode._propProcessingCache.set(b,{cssProps:d,signature:b,lastAccess:Date.now(),hitCount:1}),BaseNode._propProcessingCache.size>BaseNode.CACHE_SIZE_LIMIT&&!BaseNode._scheduledCleanup&&(BaseNode._scheduledCleanup=!0,"undefined"==typeof requestIdleCallback?setTimeout(function(){BaseNode._evictLRUEntries(),BaseNode._scheduledCleanup=!1},100):requestIdleCallback(function(){BaseNode._evictLRUEntries(),BaseNode._scheduledCleanup=!1},{timeout:2e3})),{cssProps:d}}/**
|
|
72
|
-
* Implements an LRU eviction strategy that removes multiple entries at once.
|
|
73
|
-
* It uses a scoring system where older and less frequently used entries have a higher eviction priority.
|
|
74
|
-
* @method _evictLRUEntries
|
|
75
|
-
*/static _evictLRUEntries(){var a,b=Date.now(),c=[],d=_createForOfIteratorHelper(BaseNode._propProcessingCache.entries());// Calculate eviction scores for all entries
|
|
76
|
-
try{for(d.s();!(a=d.n()).done;){var e=_slicedToArray(a.value,2),f=e[0],g=e[1],h=b-g.lastAccess,j=g.hitCount,k=h/1e3+1e3/(j+1);// Score: older age + lower frequency = higher score (more likely to evict)
|
|
77
|
-
// Normalize: age in seconds, frequency as inverse
|
|
78
|
-
c.push({key:f,score:k})}// Sort by score (highest = most evictable)
|
|
79
|
-
}catch(a){d.e(a)}finally{d.f()}c.sort(function(c,a){return a.score-c.score});// Remove top N entries
|
|
80
|
-
for(var l=Math.min(BaseNode.CACHE_CLEANUP_BATCH,c.length),m=0;m<l;m++)BaseNode._propProcessingCache["delete"](c[m].key)}/**
|
|
81
|
-
* The main prop processing pipeline, which now passes the element type for improved caching.
|
|
82
|
-
* @method _processProps
|
|
83
|
-
*/_processProps(){var a=this.rawProps,b=a.ref,c=a.key,d=a.children,e=a.css,f=a.props,g=void 0===f?{}:f,h=a.disableEmotion,i=_objectWithoutProperties(a,_excluded2);// --- Fast Path Optimization ---
|
|
84
|
-
if(0===Object.keys(i).length&&!e)return omitUndefined({ref:b,key:c,disableEmotion:h,nativeProps:omitUndefined(g),children:this._processChildren(d,h)});// --- Hybrid Caching Strategy ---
|
|
85
|
-
var j={},k={};// 1. Categorize props into cacheable (primitives) and non-cacheable (objects/functions).
|
|
86
|
-
for(var l in i)if(Object.prototype.hasOwnProperty.call(i,l)){var m=i[l],n=_typeof(m);"string"===n||"number"===n||"boolean"===n?j[l]=m:k[l]=m}// 2. Pass element type to signature generation
|
|
87
|
-
var o=BaseNode._createPropSignature(this.element,j),p=BaseNode._getCachedCssProps(j,o),q=p.cssProps,r=getCSSProps(k),s=getDOMProps(i),t=_objectSpread(_objectSpread(_objectSpread({},q),r),e),u=this._processChildren(d,h,this._stableKey);// 3. Process non-cacheable props on every render to ensure correctness for functions and objects.
|
|
88
|
-
// DOM props are always processed fresh.
|
|
89
|
-
// 4. Assemble the final CSS object.
|
|
90
|
-
// --- Child Normalization ---
|
|
91
|
-
// --- Final Assembly ---
|
|
92
|
-
return omitUndefined(_objectSpread(_objectSpread({ref:b,key:c,css:t},s),{},{disableEmotion:h,nativeProps:omitUndefined(g),children:u}))}/**
|
|
93
|
-
* Determines if a node should update based on its dependency array.
|
|
94
|
-
* Uses a shallow comparison, similar to React's `useMemo` and `useCallback`.
|
|
95
|
-
* @method _shouldNodeUpdate
|
|
96
|
-
*/static _shouldNodeUpdate(a,b,c){// SSR has no concept of re-renders, so deps system doesn't apply
|
|
97
|
-
return!!BaseNode._isServer||!c&&(!(void 0!==b)||!(void 0!==a)||b.length!==a.length||!!b.some(function(b,c){return!Object.is(b,a[c])}));// No deps array means always update.
|
|
98
|
-
// First render for this keyed component, or no previous deps.
|
|
99
|
-
// Length change means update.
|
|
100
|
-
// Shallow compare deps. If any have changed, update.
|
|
101
|
-
// Deps are the same, no update needed.
|
|
102
|
-
}// --- Child Processing ---
|
|
103
|
-
/**
|
|
104
|
-
* Processes the `children` prop of a node. It handles single children, arrays of children,
|
|
105
|
-
* and function-as-a-child render props, passing them to `_processRawNode` for normalization.
|
|
106
|
-
* @method _processChildren
|
|
107
|
-
*/_processChildren(a,b,c){return a?"function"==typeof a?a:Array.isArray(a)?a.map(function(a,d){return BaseNode._processRawNode(a,b,"".concat(c,"_").concat(d))}):BaseNode._processRawNode(a,b,c):void 0}/**
|
|
108
|
-
* The core normalization function for a single child. It takes any valid `NodeElement`
|
|
109
|
-
* (primitive, React element, function, `BaseNode` instance) and converts it into a standardized `BaseNode`
|
|
110
|
-
* instance if it isn't one already. This ensures a consistent structure for the iterative renderer.
|
|
111
|
-
* @method _processRawNode
|
|
112
|
-
*/static _processRawNode(a,b,c){// Primitives and null/undefined are returned as-is.
|
|
113
|
-
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.
|
|
114
|
-
if(isNodeInstance(a)){var d=c||b&&!a.rawProps.disableEmotion;if(d){// Create a new BaseNode instance.
|
|
115
|
-
var e=new BaseNode(a.element,a.rawProps,a.dependencies);// Augment the internal _stableKey with positional information.
|
|
116
|
-
// This is purely for BaseNode's internal caching, not for React's 'key' prop.
|
|
117
|
-
return e._stableKey="".concat(c,":").concat(e._stableKey),b&&!e.rawProps.disableEmotion&&(e.rawProps.disableEmotion=!0),e}return a}// Handle function-as-a-child (render props).
|
|
118
|
-
if(BaseNode._isFunctionChild(a))return new BaseNode(BaseNode._functionRenderer,{props:{render:a,disableEmotion:b}},void 0);// Handle standard React elements.
|
|
119
|
-
if(isValidElement(a)){var f=a.props,g=f.style,h=_objectWithoutProperties(f,_excluded3),i=_objectSpread(_objectSpread({},h),g||{});return new BaseNode(a.type,_objectSpread(_objectSpread(_objectSpread({},i),null!==a.key&&void 0!==a.key?{key:a.key}:{}),{},{disableEmotion:b}),void 0)}// Handle component classes and memos.
|
|
120
|
-
return isReactClassComponent(a)||isMemo(a)||isForwardRef(a)?new BaseNode(a,{disableEmotion:b},void 0):a instanceof React.Component?BaseNode._processRawNode(a.render(),b,c):a;// Handle component instances.
|
|
121
|
-
}/**
|
|
122
|
-
* A helper to reliably identify if a given function is a "function-as-a-child" (render prop)
|
|
123
|
-
* rather than a standard Function Component.
|
|
124
|
-
* @method _isFunctionChild
|
|
125
|
-
*/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 __DEV__&&console.error("MeoNode: Error checking if a node is a function child.",a),!0}}/**
|
|
126
|
-
* A special internal React component used to render "function-as-a-child" (render prop) patterns.
|
|
127
|
-
* When a `BaseNode` receives a function as its `children` prop, it wraps that function
|
|
128
|
-
* inside this `_functionRenderer` component. This component then executes the render function
|
|
129
|
-
* and processes its return value, normalizing it into a renderable ReactNode.
|
|
130
|
-
*
|
|
131
|
-
* This allows `BaseNode` to support render props while maintaining its internal processing
|
|
132
|
-
* and normalization logic for the dynamically generated content.
|
|
133
|
-
* @method _functionRenderer
|
|
134
|
-
* @param {Object} props The properties passed to the renderer.
|
|
135
|
-
* @param {Function} props.render The function-as-a-child to execute.
|
|
136
|
-
* @param {boolean} [props.disableEmotion] Inherited flag to disable Emotion styling for children.
|
|
137
|
-
* @returns {ReactNode | null | undefined} The processed and rendered output of the render function.
|
|
138
|
-
*/static _functionRenderer(a){var b,c=a.render,d=a.disableEmotion;try{// Execute the render prop function to get its output.
|
|
139
|
-
b=c()}catch(a){// If the render function throws, treat its output as null to prevent crashes.
|
|
140
|
-
__DEV__&&console.error("MeoNode: Error executing function-as-a-child.",a),b=null}// Handle null or undefined results directly, as they are valid React render outputs.
|
|
141
|
-
if(null===b||b===void 0)return b;// If the result is already a BaseNode instance, process it.
|
|
142
|
-
if(isNodeInstance(b))// If emotion is disabled for the parent and not explicitly re-enabled on the child,
|
|
143
|
-
// create a new BaseNode with emotion disabled and render it.
|
|
144
|
-
return d&&!b.rawProps.disableEmotion?new BaseNode(b.element,_objectSpread(_objectSpread({},b.rawProps),{},{disableEmotion:!0})).render():b.render();// Otherwise, render the existing BaseNode directly.
|
|
145
|
-
// If the result is an array, it likely contains multiple children.
|
|
146
|
-
if(Array.isArray(b)){// Helper to generate a stable key for array items, crucial for React's reconciliation.
|
|
147
|
-
var e=function safeGetKey(a,b){try{// Attempt to get a meaningful name for the element type.
|
|
148
|
-
return"".concat(getElementTypeName(a),"-").concat(b)}catch(a){// Fallback to a generic key if type name cannot be determined.
|
|
149
|
-
return __DEV__&&console.error("MeoNode: Could not determine element type name for key in function-as-a-child.",a),"item-".concat(b)}};// Map over the array, processing each item and assigning a key.
|
|
150
|
-
return b.map(function(a,b){return BaseNode._renderProcessedNode({processedElement:BaseNode._processRawNode(a,d),passedKey:e(a,b),disableEmotion:d})})}if(b instanceof React.Component)return BaseNode._renderProcessedNode({processedElement:BaseNode._processRawNode(b.render(),d),disableEmotion:d});// Handle primitive types directly, as they are valid React children.
|
|
151
|
-
if("string"==typeof b||"number"==typeof b||"boolean"==typeof b)return b;// For any other non-primitive, non-array result, process it as a single NodeElement.
|
|
152
|
-
var f=BaseNode._processRawNode(b,d);// If processing yields a valid element, render it.
|
|
153
|
-
return f?BaseNode._renderProcessedNode({processedElement:f,disableEmotion:d}):b;// Fallback: return the original result if it couldn't be processed into a renderable node.
|
|
154
|
-
}/**
|
|
155
|
-
* Renders a processed `NodeElement` into a ReactNode.
|
|
156
|
-
* This helper is primarily used by `_functionRenderer` to handle the output of render props,
|
|
157
|
-
* ensuring that `BaseNode` instances are correctly rendered and other React elements or primitives
|
|
158
|
-
* are passed through. It also applies `disableEmotion` and `key` props as needed.
|
|
33
|
+
*/_getStableKey(a){var b=a.key,c=_objectWithoutProperties(a,_excluded2);if(!NodeUtil.isServer){if(c===this._lastPropsRef)return this._lastSignature;if(this._lastPropsRef&&NodeUtil.shallowEqual(c,this._lastPropsRef))return this._lastPropsRef=c,this._lastSignature;var d=Object.keys(c),e=d.length;if(100<e){var f=NodeUtil.extractCriticalProps(c,d);this._lastSignature=NodeUtil.createPropSignature(this.element,f),__DEBUG__&&200<e&&console.warn("MeoNode: Large props (".concat(e," keys) on \"").concat(getElementTypeName(this.element),"\". Consider splitting."))}else this._lastSignature=NodeUtil.createPropSignature(this.element,c);return this._lastPropsRef=c,void 0!==b&&null!==b?"".concat(b+"",":").concat(this._lastSignature):this._lastSignature}}/**
|
|
34
|
+
* FinalizationRegistry for cleaning up `elementCache` entries when the associated `BaseNode` instance
|
|
35
|
+
* is garbage-collected. This helps prevent memory leaks by ensuring that cache entries for
|
|
36
|
+
* unreferenced nodes are eventually removed.
|
|
159
37
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* @
|
|
163
|
-
|
|
164
|
-
// If a `passedKey` is provided, add it to `commonBaseNodeProps`.
|
|
165
|
-
// This key is typically used for React's reconciliation process.
|
|
166
|
-
// If the processed element is already a BaseNode instance.
|
|
167
|
-
if(void 0!==c&&(e.key=c),isNodeInstance(b)){var f,g=null===(f=b.rawProps)||void 0===f?void 0:f.key;// Get the existing key from the raw props of the BaseNode.
|
|
168
|
-
// Apply the `disableEmotion` flag to the raw props of the BaseNode.
|
|
169
|
-
// If the existing key is the same as the passed key, render the existing BaseNode directly.
|
|
170
|
-
// This avoids unnecessary re-creation of the BaseNode instance.
|
|
171
|
-
return b.rawProps.disableEmotion=d,g===c?b.render():new BaseNode(b.element,_objectSpread(_objectSpread({},b.rawProps),e)).render();// Otherwise, create a new BaseNode instance, merging existing raw props with common props, then render it.
|
|
172
|
-
}// If the processed element is a React class component (e.g., `class MyComponent extends React.Component`).
|
|
173
|
-
// Create a new BaseNode for it, applying common props and `disableEmotion`, then render.
|
|
174
|
-
return isReactClassComponent(b)?new BaseNode(b,_objectSpread(_objectSpread({},e),{},{disableEmotion:d})).render():b instanceof React.Component?b.render():"function"==typeof b?createElement(b,{key:c}):b;// If the processed element is an instance of a React component (e.g., `new MyComponent()`).
|
|
175
|
-
// Directly call its `render` method.
|
|
176
|
-
// If the processed element is a function (likely a functional component or a render prop that returned a component type).
|
|
177
|
-
// Create a React element directly using `createElement`, passing the `passedKey`.
|
|
178
|
-
// For any other type (primitives, null, undefined, etc.), return it as a ReactNode.
|
|
179
|
-
}// --- Iterative Renderer with Deps Support ---
|
|
38
|
+
* The held value must include `cacheKey` which is used to identify and delete the corresponding
|
|
39
|
+
* entry from `BaseNode.elementCache`.
|
|
40
|
+
* @public
|
|
41
|
+
*/// --- Iterative Renderer with Deps Support ---
|
|
180
42
|
/**
|
|
181
43
|
* Renders the `BaseNode` and its entire subtree into a ReactElement, with support for opt-in reactivity
|
|
182
44
|
* via dependency arrays and inherited blocking.
|
|
@@ -190,56 +52,59 @@ return isReactClassComponent(b)?new BaseNode(b,_objectSpread(_objectSpread({},e)
|
|
|
190
52
|
* 2. **Complete Phase:** After all of a node's descendants have been rendered, the loop returns to the node.
|
|
191
53
|
* It then collects the rendered children from a temporary map and creates its own React element.
|
|
192
54
|
* @method render
|
|
193
|
-
*/render(){var a=!!(0<arguments.length&&arguments[0]!==void 0)&&arguments[0]
|
|
194
|
-
var b=this.
|
|
195
|
-
// Decide whether this node (and its subtree) should update given dependency arrays.
|
|
55
|
+
*/render(){var a=!!(0<arguments.length&&arguments[0]!==void 0)&&arguments[0];!NodeUtil.isServer&&this.stableKey&&MountTrackerUtil.trackMount(this.stableKey);// On server, we never reuse cached elements because that can cause hydration mismatches.
|
|
56
|
+
var b=NodeUtil.isServer||!this.stableKey?void 0:BaseNode.elementCache.get(this.stableKey),c=NodeUtil.shouldNodeUpdate(null===b||void 0===b?void 0:b.prevDeps,this._deps,a);// Decide whether this node (and its subtree) should update given dependency arrays.
|
|
196
57
|
// Fast return: if nothing should update and we have a cached element, reuse it.
|
|
197
|
-
if(!
|
|
58
|
+
if(!c&&null!==b&&void 0!==b&&b.renderedElement)return b.accessCount+=1,b.renderedElement;// When this node doesn't need update, its children are considered "blocked" and may be skipped.
|
|
198
59
|
// Work stack for iterative, non-recursive traversal.
|
|
199
60
|
// Each entry tracks the BaseNode, whether its children were pushed (isProcessed) and whether it is blocked.
|
|
200
61
|
// Map to collect rendered React elements for processed BaseNode instances.
|
|
201
62
|
// Iterative depth-first traversal with explicit begin/complete phases to avoid recursion.
|
|
202
|
-
for(var
|
|
203
|
-
for(var
|
|
63
|
+
for(var d=[{node:this,isProcessed:!1,blocked:!c}],e=new Map;0<d.length;){var f=d[d.length-1],g=f.node,h=f.isProcessed,j=f.blocked;if(!h){f.isProcessed=!0;var k=g.props.children;if(k)// Only consider BaseNode children for further traversal; primitives and React elements are terminal.
|
|
64
|
+
for(var l=(Array.isArray(k)?k:[k]).filter(NodeUtil.isNodeInstance),m=l.length-1;0<=m;m--){var n=l[m],o=NodeUtil.isServer||!n.stableKey?void 0:BaseNode.elementCache.get(n.stableKey),p=NodeUtil.shouldNodeUpdate(null===o||void 0===o?void 0:o.prevDeps,n._deps,j);// Respect server/client differences for child cache lookup.
|
|
204
65
|
// Determine whether the child should update given its deps and the parent's blocked state.
|
|
205
66
|
// If child doesn't need update and has cached element, reuse it immediately (no push).
|
|
206
|
-
if(!
|
|
207
|
-
var
|
|
208
|
-
var
|
|
209
|
-
var
|
|
210
|
-
if(
|
|
67
|
+
if(!p&&null!==o&&void 0!==o&&o.renderedElement){e.set(n,o.renderedElement);continue}// Otherwise push child for processing; childBlocked inherits parent's blocked state.
|
|
68
|
+
var q=j||!p;d.push({node:n,isProcessed:!1,blocked:q})}}else{d.pop();// Extract node props. Non-present props default to undefined via destructuring.
|
|
69
|
+
var r=g.props,s=r.children,t=r.key,u=r.css,v=r.nativeProps,w=r.disableEmotion,x=_objectWithoutProperties(r,_excluded3),y=[];s&&(y=(Array.isArray(s)?s:[s]).map(function(a){return NodeUtil.isNodeInstance(a)?e.get(a):isValidElement(a)?a:a}));// Merge element props: explicit other props + DOM native props + React key.
|
|
70
|
+
var z=_objectSpread(_objectSpread({},x),{},{key:t},v),A=void 0;// Handle fragments specially: create fragment element with key and children.
|
|
71
|
+
if(g.element===Fragment||isFragment(g.element))A=createElement(g.element,{key:t},...y);else{// StyledRenderer for emotion-based styling unless explicitly disabled or no styles are present.
|
|
211
72
|
// StyledRenderer handles SSR hydration and emotion CSS injection when css prop exists or element has style tags.
|
|
212
|
-
var
|
|
213
|
-
if(!
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
* This is only executed on the client-side.
|
|
218
|
-
* @method registerUnmount
|
|
219
|
-
*/static registerUnmount(a){BaseNode._isServer||MountTracker.trackUnmount(a)}// --- Portal System ---
|
|
220
|
-
/**
|
|
221
|
-
* Ensures that the necessary DOM element and React root are available for portal rendering.
|
|
222
|
-
* This is only executed on the client-side.
|
|
223
|
-
* @method _ensurePortalInfrastructure
|
|
224
|
-
*/_ensurePortalInfrastructure(){var a,b;if(BaseNode._isServer)return!1;var c=BaseNode._portalInfrastructure.get(this);// Check if infrastructure exists and is still connected
|
|
225
|
-
if(null!==(a=c)&&void 0!==a&&null!==(a=a.domElement)&&void 0!==a&&a.isConnected)return!0;// Clean up disconnected infrastructure
|
|
226
|
-
if(null!==(b=c)&&void 0!==b&&b.domElement&&!c.domElement.isConnected){try{c.reactRoot.unmount()}catch(a){__DEV__&&console.error("MeoNode: Error unmounting disconnected portal root.",a)}BaseNode._portalInfrastructure["delete"](this),c=void 0}// Create new infrastructure
|
|
227
|
-
var d=document.createElement("div");document.body.appendChild(d);var e=createRoot(d),f={render:e.render.bind(e),unmount:e.unmount.bind(e),update:function update(){}// Placeholder, will be overridden
|
|
228
|
-
};return c={domElement:d,reactRoot:f},BaseNode._portalInfrastructure.set(this,c),!0}/**
|
|
73
|
+
var B=!w&&(u||!hasNoStyleTag(g.element));A=B?createElement(StyledRenderer,_objectSpread(_objectSpread({element:g.element},z),{},{css:u,suppressHydrationWarning:!0}),...y):createElement(g.element,z,...y)}// Cache the generated element on client-side to speed up future renders.
|
|
74
|
+
if(!NodeUtil.isServer&&g.stableKey){var C=BaseNode.elementCache.get(g.stableKey);if(C)C.prevDeps=g._deps,C.renderedElement=A,C.accessCount+=1;else{// Create new cache entry and register for cleanup
|
|
75
|
+
var D={prevDeps:g._deps,renderedElement:A,nodeRef:new WeakRef(g),createdAt:Date.now(),accessCount:1,instanceId:g.instanceId};BaseNode.elementCache.set(g.stableKey,D),BaseNode.cacheCleanupRegistry.register(g,{cacheKey:g.stableKey,instanceId:g.instanceId},g)}}// Store the rendered element so parent nodes can reference it.
|
|
76
|
+
e.set(g,A)}}// Get the final rendered element for the root node of this render cycle.
|
|
77
|
+
var E=e.get(this);return!NodeUtil.isServer&&this.stableKey?createElement(MeoNodeUnmounter,{stableKey:this.stableKey},E):E}/**
|
|
229
78
|
* Renders the node into a React Portal, mounting it directly under `document.body`.
|
|
230
79
|
* Returns a handle with `update` and `unmount` methods to control the portal's lifecycle.
|
|
231
80
|
* @method toPortal
|
|
232
|
-
*/toPortal(){var a=this;if(!
|
|
233
|
-
return d.update=function(a){try{var b=isNodeInstance(a)?a.render():a;d.render(b)}catch(a){
|
|
234
|
-
|
|
81
|
+
*/toPortal(){var a=this;if(!NodeUtil.ensurePortalInfrastructure(this))throw new Error("toPortal() can only be called in a client-side environment");var b=NodeUtil.portalInfrastructure.get(this),c=b.domElement,d=b.reactRoot;(function renderCurrent(){try{d.render(a.render())}catch(a){__DEBUG__&&console.error("[MeoNode] Portal render error:",a)}})();// Track if already unmounted to make unmount idempotent
|
|
82
|
+
var e=!1,f=d.unmount.bind(d);return d.update=function(a){if(e)return void(__DEBUG__&&console.warn("[MeoNode] Attempt to update already-unmounted portal"));try{var b=NodeUtil.isNodeInstance(a)?a.render():a;d.render(b)}catch(a){__DEBUG__&&console.error("[MeoNode] Portal update error:",a)}},d.unmount=function(){// Idempotent guard
|
|
83
|
+
if(e)return void(__DEBUG__&&console.warn("[MeoNode] Portal already unmounted"));e=!0;// Unregister FIRST to prevent FinalizationRegistry from firing
|
|
84
|
+
try{BaseNode.portalCleanupRegistry.unregister(a)}catch(a){__DEBUG__&&console.warn("[MeoNode] Portal unregister warning:",a)}// Remove from WeakMap
|
|
85
|
+
NodeUtil.portalInfrastructure["delete"](a);// Now do the actual cleanup
|
|
86
|
+
try{null!==c&&void 0!==c&&c.isConnected&&f()}catch(a){__DEBUG__&&console.error("[MeoNode] Portal unmount error:",a)}try{null!==c&&void 0!==c&&c.isConnected&&c.remove()}catch(a){__DEBUG__&&console.error("[MeoNode] Portal DOM cleanup error:",a)}},d}/**
|
|
235
87
|
* A static method to clear all internal caches.
|
|
88
|
+
*
|
|
89
|
+
* This method performs manual cleanup of all cache entries, calling their
|
|
90
|
+
* `onEvict` callbacks before clearing. Note that FinalizationRegistry entries
|
|
91
|
+
* are not manually cleared as they will be garbage collected naturally when
|
|
92
|
+
* the associated nodes are collected.
|
|
236
93
|
* @method clearCaches
|
|
237
|
-
*/static clearCaches(){
|
|
94
|
+
*/static clearCaches(){// Collect all cache keys first
|
|
95
|
+
var a=Array.from(BaseNode.elementCache.keys());__DEBUG__&&console.log("[MeoNode] clearCaches: Clearing ".concat(a.length," entries"));// Call onEvict for all entries (idempotent)
|
|
96
|
+
for(var b=0,c=a;b<c.length;b++){var d=c[b],e=BaseNode.elementCache.get(d);if(e){var f,g=null===(f=e.nodeRef)||void 0===f?void 0:f.deref();// Try to unregister from FinalizationRegistry
|
|
97
|
+
if(g)try{BaseNode.cacheCleanupRegistry.unregister(g)}catch(a){__DEBUG__&&console.warn("[MeoNode] Could not unregister ".concat(d," from FinalizationRegistry"))}}}// Clear all caches
|
|
98
|
+
// Clear mount tracking
|
|
99
|
+
BaseNode.propProcessingCache.clear(),BaseNode.elementCache.clear(),ThemeUtil.clearThemeCache(),MountTrackerUtil.cleanup(),__DEBUG__&&console.log("[MeoNode] All caches cleared")}// --- Utilities ---
|
|
100
|
+
}// --- Factory Functions ---
|
|
238
101
|
/**
|
|
239
102
|
* The primary factory function for creating a `BaseNode` instance.
|
|
240
103
|
* It's the simplest way to wrap a component or element.
|
|
241
104
|
* @function Node
|
|
242
|
-
*/_BaseNode=BaseNode,_defineProperty(BaseNode,"
|
|
105
|
+
*/_BaseNode=BaseNode,_defineProperty(BaseNode,"elementCache",new Map),_defineProperty(BaseNode,"propProcessingCache",new Map),_defineProperty(BaseNode,"scheduledCleanup",!1),_defineProperty(BaseNode,"_navigationStarted",!1),_defineProperty(BaseNode,"cacheCleanupRegistry",new FinalizationRegistry(function(a){var b=a.cacheKey,c=a.instanceId,d=_BaseNode.elementCache.get(b);MountTrackerUtil.mountedNodes.has(b)&&(null===d||void 0===d?void 0:d.instanceId)===c&&(_BaseNode.elementCache["delete"](b),MountTrackerUtil.untrackMount(b))})),_defineProperty(BaseNode,"portalCleanupRegistry",new FinalizationRegistry(function(a){var b=a.domElement,c=a.reactRoot;__DEBUG__&&console.log("[MeoNode] FinalizationRegistry auto-cleaning portal");// Guard: Check if already unmounted
|
|
106
|
+
try{c&&"function"==typeof c.unmount&&c.unmount()}catch(a){__DEBUG__&&console.error("[MeoNode] Portal auto-cleanup unmount error:",a)}// Guard: Check if DOM element still connected
|
|
107
|
+
try{null!==b&&void 0!==b&&b.isConnected&&b.remove()}catch(a){__DEBUG__&&console.error("[MeoNode] Portal auto-cleanup DOM removal error:",a)}}));function Node(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=2<arguments.length?arguments[2]:void 0;return new BaseNode(a,b,c)}/**
|
|
243
108
|
* Static alias on the `Node` factory for clearing all internal caches used by `BaseNode`.
|
|
244
109
|
*
|
|
245
110
|
* Use cases include:
|
|
@@ -26,7 +26,7 @@ export declare const getValueByPath: (obj: any, path: string) => any;
|
|
|
26
26
|
* getComponentType(React.memo(() => <div/>)) // 'memo'
|
|
27
27
|
* getComponentType(() => <div/>) // 'function'
|
|
28
28
|
*/
|
|
29
|
-
export declare const getComponentType: (component?: NodeInstance
|
|
29
|
+
export declare const getComponentType: (component?: NodeInstance | NodeElement) => string;
|
|
30
30
|
/**
|
|
31
31
|
* Generates a string name for an ElementType or ReactElement.
|
|
32
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.helper.d.ts","sourceRoot":"","sources":["../../src/helper/common.helper.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAExF,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGvE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,iCAE1B,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"common.helper.d.ts","sourceRoot":"","sources":["../../src/helper/common.helper.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAExF,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGvE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,iCAE1B,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,oDAmC5B,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAsFxD;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,GAAG,CAAC,MAAM,CAA0B,CAAA;AAEjE;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAU3F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAUjH;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,OAAO,CAGxD;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAQ1F;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQlE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{BaseNode,Node}from"../core.node.js";import{getElementTypeName}from"../helper/common.helper.js";import{
|
|
1
|
+
import{BaseNode,Node}from"../core.node.js";import{getElementTypeName}from"../helper/common.helper.js";import{NodeUtil}from"../util/node.util.js";/**
|
|
2
2
|
* Props definition for components wrapped using the `Component` higher-order function.
|
|
3
3
|
*
|
|
4
4
|
* This type adapts based on whether the underlying component defines its own props:
|
|
@@ -47,4 +47,4 @@ import{BaseNode,Node}from"../core.node.js";import{getElementTypeName}from"../hel
|
|
|
47
47
|
*//**
|
|
48
48
|
* Internal implementation of the `Component` HOC.
|
|
49
49
|
* Handles BaseNode conversion and wrapper creation.
|
|
50
|
-
*/export function Component(a){function Func(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=1<arguments.length?arguments[1]:void 0;return Node(c,a,b).render()}var b=getElementTypeName(a),c=function Renderer(b){var c=a(b);return c instanceof BaseNode||isNodeInstance(c)?Node(c.element,c.rawProps).render():c};return c.displayName="Renderer(".concat(b,")"),Func.displayName="Component(".concat(b,")"),Func}
|
|
50
|
+
*/export function Component(a){function Func(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=1<arguments.length?arguments[1]:void 0;return Node(c,a,b).render()}var b=getElementTypeName(a),c=function Renderer(b){var c=a(b);return c instanceof BaseNode||NodeUtil.isNodeInstance(c)?Node(c.element,c.rawProps).render():c};return c.displayName="Renderer(".concat(b,")"),Func.displayName="Component(".concat(b,")"),Func}
|
package/dist/main.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
export { setDebugMode } from './constants/common.const.js';
|
|
1
2
|
export { Node, createNode, createChildrenFirstNode } from './core.node.js';
|
|
2
3
|
export * from './hoc/index.js';
|
|
3
|
-
export * from './helper/node.helper.js';
|
|
4
4
|
export * from './types/node.type.js';
|
|
5
5
|
export * from './components/react.node.js';
|
|
6
6
|
export * from './components/html.node.js';
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAG7D,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
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
// Common
|
|
2
|
+
export{setDebugMode}from"./constants/common.const.js";// Core
|
|
1
3
|
export{Node,createNode,createChildrenFirstNode}from"./core.node.js";// High Order Components
|
|
2
|
-
export*from"./hoc/index.js";//
|
|
3
|
-
export*from"./helper/node.helper.js";// Types
|
|
4
|
+
export*from"./hoc/index.js";// Types
|
|
4
5
|
export*from"./types/node.type.js";// Components
|
|
5
6
|
export*from"./components/react.node.js";export*from"./components/html.node.js";export*from"./components/theme-provider.js";// Hooks
|
|
6
7
|
export*from"./hook/index.js";
|
|
@@ -51,31 +51,17 @@ export interface PropProcessingCache {
|
|
|
51
51
|
export interface ElementCacheEntry {
|
|
52
52
|
renderedElement: ReactElement<FinalNodeProps>;
|
|
53
53
|
prevDeps?: DependencyList;
|
|
54
|
-
|
|
55
|
-
nodeRef: WeakRef<BaseNode<any>>;
|
|
54
|
+
nodeRef: WeakRef<NodeInstance>;
|
|
56
55
|
createdAt: number;
|
|
57
56
|
accessCount: number;
|
|
57
|
+
instanceId: string;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Forward declaration of the BaseNode interface to avoid circular dependencies.
|
|
61
61
|
* Defines the core structure and capabilities of a BaseNode instance.
|
|
62
62
|
* @template E - The type of React element/component that this node represents
|
|
63
63
|
*/
|
|
64
|
-
export
|
|
65
|
-
/** The underlying React element or component type that this node will render */
|
|
66
|
-
readonly element: E;
|
|
67
|
-
/** Original props passed during node construction, preserved for cloning/recreation */
|
|
68
|
-
readonly rawProps: Partial<NodeProps<E>>;
|
|
69
|
-
readonly isBaseNode: true;
|
|
70
|
-
/** The dependency list for memoization */
|
|
71
|
-
readonly dependencies: DependencyList | undefined;
|
|
72
|
-
/** Lazily processed and retrieved final, normalized props for the node. */
|
|
73
|
-
readonly props: FinalNodeProps;
|
|
74
|
-
/** Converts this node instance into a renderable React element/tree */
|
|
75
|
-
render(): ReactElement;
|
|
76
|
-
/** Creates Portal-compatible React elements for rendering outside the DOM tree */
|
|
77
|
-
toPortal(): NodePortal;
|
|
78
|
-
}
|
|
64
|
+
export type NodeInstance<E extends NodeElementType = NodeElementType> = BaseNode<E>;
|
|
79
65
|
/**
|
|
80
66
|
* Infers the props type for a given NodeElement.
|
|
81
67
|
* - For intrinsic JSX elements (e.g., 'div', 'span'), returns the corresponding JSX.IntrinsicElements props.
|
|
@@ -1 +1 @@
|
|
|
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,gCAAgC,CAAA;AACnE,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,IAAI,YAAY,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;AAE9E;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,EAAE,CAAA;AAE3C,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,IACnC,CAAC,SAAS,eAAe,CAAC,aAAa,CAAC,GAAG,IAAI,GAAG,C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E,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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
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
|
+
*/
|
|
6
|
+
export declare class MountTrackerUtil {
|
|
7
|
+
private constructor();
|
|
8
|
+
static mountedNodes: Set<string>;
|
|
9
|
+
private static _unmountCallCount;
|
|
10
|
+
/**
|
|
11
|
+
* Tracks a node as mounted. Adds its stable key and a WeakRef to the node to the map of mounted nodes.
|
|
12
|
+
*/
|
|
13
|
+
static trackMount(key: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Removes its stable key from the set of mounted nodes.
|
|
16
|
+
* In development mode, it also tracks multiple unmount calls for debugging purposes.
|
|
17
|
+
* @returns True if the node was previously tracked as mounted and is now removed, false otherwise.
|
|
18
|
+
*/
|
|
19
|
+
static untrackMount(key: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Cleans up all internal state of the MountTrackerUtil.
|
|
22
|
+
* Removes all tracked nodes and debug counters.
|
|
23
|
+
*/
|
|
24
|
+
static cleanup(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=mount-tracker.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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{__DEBUG__}from"../constants/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){var b=this.mountedNodes["delete"](a);if(__DEBUG__&&!b){var c=(this._unmountCallCount.get(a)||0)+1;this._unmountCallCount.set(a,c),1<c&&console.warn("[MeoNode] untrackMount called ".concat(c," times for an already unmounted node: ").concat(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);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight navigation handler that clears cache on SPA navigation.
|
|
3
|
+
*/
|
|
4
|
+
export declare class NavigationCacheManagerUtil {
|
|
5
|
+
private constructor();
|
|
6
|
+
private static _instance;
|
|
7
|
+
private static _originalPushState;
|
|
8
|
+
private static _originalReplaceState;
|
|
9
|
+
private static _isPatched;
|
|
10
|
+
private _isListening;
|
|
11
|
+
private _cleanupTimeout;
|
|
12
|
+
static getInstance(): NavigationCacheManagerUtil;
|
|
13
|
+
/**
|
|
14
|
+
* Start listening for navigation events. Idempotent.
|
|
15
|
+
*/
|
|
16
|
+
start(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Stops listening for navigation events and restores original browser APIs.
|
|
19
|
+
* This is important for cleanup during HMR or when unmounting the library.
|
|
20
|
+
*/
|
|
21
|
+
private _stop;
|
|
22
|
+
/**
|
|
23
|
+
* Debounced navigation handler. Clears mounted element cache and props cache.
|
|
24
|
+
*/
|
|
25
|
+
private _handleNavigation;
|
|
26
|
+
/**
|
|
27
|
+
* Patch history.pushState/replaceState to detect SPA navigation.
|
|
28
|
+
*/
|
|
29
|
+
private _patchHistoryMethods;
|
|
30
|
+
/**
|
|
31
|
+
* Setup automatic cleanup on page unload.
|
|
32
|
+
* Covers HMR, navigation away, and browser close.
|
|
33
|
+
*/
|
|
34
|
+
private _setupAutoCleanup;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=navigation-cache-manager.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-cache-manager.util.d.ts","sourceRoot":"","sources":["../../src/util/navigation-cache-manager.util.ts"],"names":[],"mappings":"AAIA;;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,CAAY;IAEnC,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"}
|