@meonode/ui 0.4.7 → 0.4.9
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 +73 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/components/html.node.d.ts +139 -139
- package/dist/components/html.node.js +139 -139
- package/dist/components/meonode-unmounter.client.d.ts +6 -3
- package/dist/components/meonode-unmounter.client.d.ts.map +1 -1
- package/dist/components/meonode-unmounter.client.js +4 -2
- package/dist/components/react.node.d.ts +3 -3
- package/dist/components/react.node.js +3 -3
- package/dist/components/registry.client.js +6 -6
- package/dist/components/styled-renderer.client.js +2 -2
- package/dist/components/theme-provider.client.js +2 -2
- package/dist/components/theme-provider.d.ts +1 -1
- package/dist/components/theme-provider.js +1 -1
- package/dist/constant/common.const.d.ts.map +1 -0
- package/dist/constant/common.const.js +1 -0
- package/dist/constant/css-properties.const.d.ts.map +1 -0
- package/dist/constant/css-properties.const.js +1 -0
- package/dist/core.node.d.ts +9 -9
- package/dist/core.node.d.ts.map +1 -1
- package/dist/core.node.js +44 -39
- package/dist/helper/common.helper.js +9 -9
- package/dist/helper/obj.helper.js +14 -14
- package/dist/helper/react-is.helper.js +21 -21
- package/dist/hoc/component.hoc.js +1 -1
- package/dist/hoc/portal.hoc.js +13 -13
- package/dist/hook/usePortal.js +2 -2
- package/dist/hook/useTheme.js +3 -3
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/nextjs-registry/index.d.ts +1 -1
- package/dist/nextjs-registry/index.js +1 -1
- package/dist/types/node.type.d.ts +6 -1
- package/dist/types/node.type.d.ts.map +1 -1
- package/dist/util/mount-tracker.util.js +3 -3
- package/dist/util/navigation-cache-manager.util.d.ts +5 -0
- package/dist/util/navigation-cache-manager.util.d.ts.map +1 -1
- package/dist/util/navigation-cache-manager.util.js +7 -7
- package/dist/util/node.util.d.ts +15 -12
- package/dist/util/node.util.d.ts.map +1 -1
- package/dist/util/node.util.js +67 -75
- package/dist/util/theme.util.d.ts +6 -6
- package/dist/util/theme.util.d.ts.map +1 -1
- package/dist/util/theme.util.js +17 -16
- package/package.json +11 -8
- package/dist/constants/common.const.d.ts.map +0 -1
- package/dist/constants/common.const.js +0 -1
- package/dist/constants/css-properties.const.d.ts.map +0 -1
- package/dist/constants/css-properties.const.js +0 -1
- /package/dist/{constants → constant}/common.const.d.ts +0 -0
- /package/dist/{constants → constant}/css-properties.const.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{isContextConsumer,isContextProvider,isElement,isForwardRef,isFragment,isLazy,isMemo,isPortal,isProfiler,isReactClassComponent,isStrictMode,isSuspense,isSuspenseList}from"./react-is.helper.js";import cssProperties from"../constant/css-properties.const.js";import{noStyleTagsSet}from"../constant/common.const.js";/**
|
|
2
2
|
* Retrieves a deeply nested value from an object using a dot-separated string path.
|
|
3
3
|
*
|
|
4
4
|
* This function traverses an object based on the provided path, which is a
|
|
@@ -8,7 +8,7 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
8
8
|
* @param obj The object to traverse, defaults to an empty object if not provided.
|
|
9
9
|
* @param path The dot-separated path string (e.g., 'background.primary').
|
|
10
10
|
* @returns The value at the specified path, or undefined if not found.
|
|
11
|
-
*/export
|
|
11
|
+
*/export const getValueByPath=(a,b)=>b.split(".").reduce((a,b)=>a&&void 0!==a[b]?a[b]:void 0,a);/**
|
|
12
12
|
* Returns a string describing the type of a given React component or element.
|
|
13
13
|
*
|
|
14
14
|
* Checks for common React types (class, forwardRef, memo, etc.) and returns a string
|
|
@@ -21,7 +21,7 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
21
21
|
* getComponentType(React.forwardRef(() => <div/>)) // 'forwardRef'
|
|
22
22
|
* getComponentType(React.memo(() => <div/>)) // 'memo'
|
|
23
23
|
* getComponentType(() => <div/>) // 'function'
|
|
24
|
-
*/export
|
|
24
|
+
*/export const getComponentType=a=>isForwardRef(a)?"forwardRef":isMemo(a)?"memo":isFragment(a)?"fragment":isPortal(a)?"portal":isProfiler(a)?"profiler":isStrictMode(a)?"strict-mode":isSuspense(a)?"suspense":isSuspenseList(a)?"suspense-list":isContextConsumer(a)?"context-consumer":isContextProvider(a)?"context-provider":isLazy(a)?"lazy":isElement(a)?"element":isReactClassComponent(a)?"class":typeof a;/**
|
|
25
25
|
* Generates a string name for an ElementType or ReactElement.
|
|
26
26
|
*
|
|
27
27
|
* This function attempts to extract a meaningful name from a React ElementType
|
|
@@ -32,10 +32,10 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
32
32
|
* If a name cannot be determined, it returns a fallback like 'UnknownElementType' or 'AnonymousComponent'.
|
|
33
33
|
* @param node The ElementType or ReactElement (e.g., 'div', MyComponent, <MyComponent />).
|
|
34
34
|
* @returns A string representation of the element type's name.
|
|
35
|
-
*/export function getElementTypeName(a){
|
|
35
|
+
*/export function getElementTypeName(a){function getDisplayName(a,b){const c=a?.displayName||a?.name;return!c||"render"===c?b:c}if(null===a||a===void 0)return"UnknownElementType";const b=a,c=getComponentType(b);return"string"===c?a:"class"===c?getDisplayName(b,"ClassComponent"):"function"===c?getDisplayName(b,"AnonymousFunctionComponent"):"forwardRef"===c?getDisplayName(b,"")||getDisplayName(b.render,"")||"ForwardRefComponent":"memo"===c?getDisplayName(b,"")||(b.type?getElementTypeName(b.type):"MemoComponent"):"element"===c?getElementTypeName(b.type):"fragment"===c?"Fragment":"portal"===c?"Portal":"profiler"===c?getDisplayName(b,"Profiler"):"strict-mode"===c?"StrictMode":"suspense"===c?getDisplayName(b,"Suspense"):"suspense-list"===c?"SuspenseList":"context-consumer"===c?b._context?.displayName?`${b._context.displayName}.Consumer`:"ContextConsumer":"context-provider"===c?b._context?.displayName?`${b._context.displayName}.Provider`:"ContextProvider":"lazy"===c?getDisplayName(b,"LazyComponent"):"object"===c?getDisplayName(b,"")?getDisplayName(b,""):"function"==typeof b.render?getDisplayName(b.render,"ObjectWithRender"):b.type&&b.type!==a?`Wrapped<${getElementTypeName(b.type)}>`:getDisplayName(b,"ObjectComponent"):"symbol"===c?"symbol"==typeof a?a.description?.replace(/^react\./,"").split(".").map(a=>a[0]?.toUpperCase()+a.slice(1)).join("")||a.toString():"SymbolComponent":"unknown"===c?"UnknownElementType":`UnsupportedType<${c}>`}/**
|
|
36
36
|
* A set of valid CSS property names in camelCase, including CSS custom properties, used for validation.
|
|
37
37
|
* This set contains all CSS properties including non-standard vendor prefixed properties.
|
|
38
|
-
*/export
|
|
38
|
+
*/export const CSSPropertySet=new Set(cssProperties);/**
|
|
39
39
|
* Filters an object to only include valid CSS properties
|
|
40
40
|
* @param props The object containing potential CSS properties
|
|
41
41
|
* @returns An object containing only valid CSS properties
|
|
@@ -46,7 +46,7 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
46
46
|
* invalid: true
|
|
47
47
|
* }) // { backgroundColor: 'red' }
|
|
48
48
|
* ```
|
|
49
|
-
*/export function getCSSProps(a){
|
|
49
|
+
*/export function getCSSProps(a){const b={};for(const c in a)Object.prototype.hasOwnProperty.call(a,c)&&CSSPropertySet.has(c)&&(b[c]=a[c]);return b}/**
|
|
50
50
|
* Filters component props to include only valid DOM properties and attributes.
|
|
51
51
|
*
|
|
52
52
|
* This function iterates through the provided props and retains only those that
|
|
@@ -57,7 +57,7 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
57
57
|
* @typeParam T - The type of the component props.
|
|
58
58
|
* @param props The component props to filter.
|
|
59
59
|
* @returns An object containing only valid DOM props.
|
|
60
|
-
*/export function getDOMProps(a){
|
|
60
|
+
*/export function getDOMProps(a){const b={};for(const c in a)Object.prototype.hasOwnProperty.call(a,c)&&!CSSPropertySet.has(c)&&(b[c]=a[c]);return b}/**
|
|
61
61
|
* Checks if a given tag is in the set of tags that should not receive style props.
|
|
62
62
|
* @param tag The tag name to check (e.g., 'script', 'style').
|
|
63
63
|
* @returns `true` if the tag is in the no-style set, otherwise `false`.
|
|
@@ -66,8 +66,8 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
66
66
|
* @param obj The source object.
|
|
67
67
|
* @param keys The property keys to omit.
|
|
68
68
|
* @returns A new object without the omitted keys.
|
|
69
|
-
*/export function omit(a){
|
|
69
|
+
*/export function omit(a,...b){const c={};for(const d in a)Object.prototype.hasOwnProperty.call(a,d)&&!b.includes(d)&&(c[d]=a[d]);return c}/**
|
|
70
70
|
* Removes keys from an object whose values are `undefined`.
|
|
71
71
|
* @param obj The source object.
|
|
72
72
|
* @returns A new object without keys that have `undefined` values.
|
|
73
|
-
*/export function omitUndefined(a){
|
|
73
|
+
*/export function omitUndefined(a){const b={};for(const c in a)Object.prototype.hasOwnProperty.call(a,c)&&void 0!==a[c]&&(b[c]=a[c]);return b}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
export class ObjHelper{constructor(){}/**
|
|
2
2
|
* Build a serializable representation of `value`.
|
|
3
3
|
* - preserves encoded placeholders for special types
|
|
4
4
|
* - emits { $type: 'Circular', ref: id } for circular refs
|
|
5
|
-
*/static buildSerializable(a,b){
|
|
6
|
-
if(null===a||void 0===a)return a;
|
|
7
|
-
if("string"
|
|
8
|
-
if("function"
|
|
9
|
-
if("symbol"
|
|
10
|
-
if("object"
|
|
5
|
+
*/static buildSerializable(a,b){// Fast path for primitives
|
|
6
|
+
if(null===a||void 0===a)return a;const c=typeof a;// Handle primitives first (most common case)
|
|
7
|
+
if("string"==c||"number"===c||"boolean"===c)return a;// Handle functions
|
|
8
|
+
if("function"==c){let c=b.functionIds.get(a);return void 0===c&&(c=b.nextFunctionId++,b.functionIds.set(a,c)),{$type:"Function",name:a.name||"",id:c}}// Handle other primitives
|
|
9
|
+
if("symbol"==c)return{$type:"Symbol",key:a.description??""};if("bigint"==c)return{$type:"BigInt",value:a.toString()};// Only objects beyond this point
|
|
10
|
+
if("object"!=c)// Fallback for unknown types
|
|
11
11
|
try{return a+""}catch(a){return"<unserializable>"}// Handle built-in object types before circular check (they're less likely to be circular)
|
|
12
12
|
if(a instanceof Date)return{$type:"Date",value:a.toISOString()};if(a instanceof RegExp)return{$type:"RegExp",source:a.source,flags:a.flags};// Circular detection
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if(b.seen.set(a,
|
|
16
|
-
if(a instanceof Set){
|
|
13
|
+
const d=b.seen.get(a);if(void 0!==d)return{$type:"Circular",ref:d};// Assign ID and mark as seen
|
|
14
|
+
const e=b.nextObjId++;// Handle Map
|
|
15
|
+
if(b.seen.set(a,e),a instanceof Map){const c=[];for(const[d,e]of a.entries())c.push([this.buildSerializable(d,b),this.buildSerializable(e,b)]);return{$type:"Map",entries:c}}// Handle Set
|
|
16
|
+
if(a instanceof Set){const c=[];for(const d of a.values())c.push(this.buildSerializable(d,b));return{$type:"Set",values:c}}// Handle Arrays
|
|
17
17
|
if(Array.isArray(a))// Use map for cleaner code and potential engine optimizations
|
|
18
|
-
return a.map(
|
|
19
|
-
try{
|
|
18
|
+
return a.map(a=>this.buildSerializable(a,b));// Handle plain objects
|
|
19
|
+
try{const c=Object.keys(a),d={};for(const e of c)try{d[e]=this.buildSerializable(a[e],b)}catch(a){d[e]="<unserializable>"}return d}catch(a){return"<unserializable>"}}/**
|
|
20
20
|
* Stringify with performance optimizations.
|
|
21
21
|
* @param obj Object to serialize
|
|
22
22
|
* @param space JSON.stringify space parameter
|
|
23
|
-
*/static stringify(a){
|
|
23
|
+
*/static stringify(a,b=0){const c={nextObjId:0,nextFunctionId:0,seen:new Map,functionIds:new Map},d=this.buildSerializable(a,c);return JSON.stringify(d,null,b)}}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
2
|
* Custom React Type Checker (TypeScript Version)
|
|
3
3
|
* Provides utilities for identifying and checking React component/element types.
|
|
4
4
|
* Inspired by react-is package but implemented in TypeScript with type safety.
|
|
5
5
|
*//**
|
|
6
6
|
* Symbol identifiers for React internal component types
|
|
7
7
|
* These are used to identify different kinds of React elements and components
|
|
8
|
-
*/export
|
|
8
|
+
*/export const REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element");export const REACT_PORTAL_TYPE=Symbol.for("react.portal");export const REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");export const REACT_STRICT_MODE_TYPE=Symbol.for("react.strict_mode");export const REACT_PROFILER_TYPE=Symbol.for("react.profiler");export const REACT_PROVIDER_TYPE=Symbol.for("react.provider");export const REACT_CONSUMER_TYPE=Symbol.for("react.consumer");export const REACT_CONTEXT_TYPE=Symbol.for("react.context");export const REACT_FORWARD_REF_TYPE=Symbol.for("react.forward_ref");export const REACT_SUSPENSE_TYPE=Symbol.for("react.suspense");export const REACT_SUSPENSE_LIST_TYPE=Symbol.for("react.suspense_list");export const REACT_MEMO_TYPE=Symbol.for("react.memo");export const REACT_LAZY_TYPE=Symbol.for("react.lazy");export const REACT_VIEW_TRANSITION_TYPE=Symbol.for("react.view_transition");export const REACT_CLIENT_REFERENCE=Symbol.for("react.client.reference");export const REACT_ACTIVITY_TYPE=Symbol.for("react.activity");/**
|
|
9
9
|
* Union type of all possible React internal type symbols.
|
|
10
10
|
* Used to strongly type return values from type checking functions.
|
|
11
11
|
*//**
|
|
@@ -17,78 +17,78 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
17
17
|
* to identify what kind of React element or component it represents.
|
|
18
18
|
* @param {unknown} object The object to check
|
|
19
19
|
* @returns {boolean} - The matching React type symbol or undefined if not a React object
|
|
20
|
-
*/export function typeOf(a){if("object"
|
|
20
|
+
*/export function typeOf(a){if("object"==typeof a&&null!==a){const b=a.$$typeof;switch(b){case REACT_ELEMENT_TYPE:{const c=a.type;switch(c){case REACT_FRAGMENT_TYPE:case REACT_PROFILER_TYPE:case REACT_STRICT_MODE_TYPE:case REACT_SUSPENSE_TYPE:case REACT_SUSPENSE_LIST_TYPE:case REACT_VIEW_TRANSITION_TYPE:return c;default:{const a=c?.$$typeof;return a===REACT_CONTEXT_TYPE||a===REACT_FORWARD_REF_TYPE||a===REACT_LAZY_TYPE||a===REACT_MEMO_TYPE||a===REACT_PROVIDER_TYPE||a===REACT_CONSUMER_TYPE?a:b}}}case REACT_PORTAL_TYPE:return b}}}/**
|
|
21
21
|
* Checks if an object is a React Context Consumer
|
|
22
22
|
* @param {unknown} object Object to check
|
|
23
23
|
* @returns {boolean} - True if object is a Context.Consumer
|
|
24
|
-
*/export
|
|
24
|
+
*/export const isContextConsumer=a=>typeOf(a)===REACT_CONSUMER_TYPE;/**
|
|
25
25
|
* Checks if an object is a React Context Provider
|
|
26
26
|
* @param {unknown} object Object to check
|
|
27
27
|
* @returns {boolean} - True if object is a Context.Provider
|
|
28
|
-
*/export
|
|
28
|
+
*/export const isContextProvider=a=>typeOf(a)===REACT_PROVIDER_TYPE;/**
|
|
29
29
|
* Checks if an object is a valid React element
|
|
30
30
|
* @param {unknown} object Object to check
|
|
31
31
|
* @returns {boolean} - True if object is a React element
|
|
32
|
-
*/export
|
|
32
|
+
*/export const isElement=a=>"object"==typeof a&&null!==a&&a.$$typeof===REACT_ELEMENT_TYPE;/**
|
|
33
33
|
* Checks if an object is a React forwardRef component
|
|
34
34
|
* @param {unknown} object Object to check
|
|
35
35
|
* @returns {boolean} - True if object is a forwardRef component
|
|
36
|
-
*/export
|
|
36
|
+
*/export const isForwardRef=a=>typeOf(a)===REACT_FORWARD_REF_TYPE;/**
|
|
37
37
|
* Checks if an object is a React Fragment
|
|
38
38
|
* @param {unknown} object Object to check
|
|
39
39
|
* @returns {boolean} - True if object is a Fragment
|
|
40
|
-
*/export
|
|
40
|
+
*/export const isFragment=a=>typeOf(a)===REACT_FRAGMENT_TYPE;/**
|
|
41
41
|
* Checks if an object is a React lazy component
|
|
42
42
|
* @param {unknown} object Object to check
|
|
43
43
|
* @returns {boolean} - True if object is a lazy component
|
|
44
|
-
*/export
|
|
44
|
+
*/export const isLazy=a=>typeOf(a)===REACT_LAZY_TYPE;/**
|
|
45
45
|
* Checks if an object is a React memo component
|
|
46
46
|
* @param {unknown} object Object to check
|
|
47
47
|
* @returns {boolean} - True if object is a memo component
|
|
48
|
-
*/export
|
|
48
|
+
*/export const isMemo=a=>typeOf(a)===REACT_MEMO_TYPE;/**
|
|
49
49
|
* Checks if an object is a React portal
|
|
50
50
|
* @param {unknown} object Object to check
|
|
51
51
|
* @returns {boolean} - True if object is a portal
|
|
52
|
-
*/export
|
|
52
|
+
*/export const isPortal=a=>typeOf(a)===REACT_PORTAL_TYPE;/**
|
|
53
53
|
* Checks if an object is a React Profiler
|
|
54
54
|
* @param {unknown} object Object to check
|
|
55
55
|
* @returns {boolean} - True if object is a Profiler
|
|
56
|
-
*/export
|
|
56
|
+
*/export const isProfiler=a=>typeOf(a)===REACT_PROFILER_TYPE;/**
|
|
57
57
|
* Checks if an object is a React StrictMode component
|
|
58
58
|
* @param {unknown} object Object to check
|
|
59
59
|
* @returns {boolean} - True if object is StrictMode
|
|
60
|
-
*/export
|
|
60
|
+
*/export const isStrictMode=a=>typeOf(a)===REACT_STRICT_MODE_TYPE;/**
|
|
61
61
|
* Checks if an object is a React Suspense component
|
|
62
62
|
* @param {unknown} object Object to check
|
|
63
63
|
* @returns {boolean} - True if object is Suspense
|
|
64
|
-
*/export
|
|
64
|
+
*/export const isSuspense=a=>typeOf(a)===REACT_SUSPENSE_TYPE;/**
|
|
65
65
|
* Checks if an object is a React SuspenseList component
|
|
66
66
|
* @param {unknown} object Object to check
|
|
67
67
|
* @returns {boolean} - True if `object` is SuspenseList
|
|
68
|
-
*/export
|
|
68
|
+
*/export const isSuspenseList=a=>typeOf(a)===REACT_SUSPENSE_LIST_TYPE;/**
|
|
69
69
|
* Checks if an object is a React ViewTransition component
|
|
70
70
|
* @param {unknown} object Object to check
|
|
71
71
|
* @returns {boolean} - True if object is ViewTransition
|
|
72
|
-
*/export
|
|
72
|
+
*/export const isViewTransition=a=>typeOf(a)===REACT_VIEW_TRANSITION_TYPE;/**
|
|
73
73
|
* Checks if an object is a React Activity component
|
|
74
74
|
* @param {unknown} object Object to check
|
|
75
75
|
* @returns {boolean} - True if object is Activity
|
|
76
|
-
*/export
|
|
76
|
+
*/export const isActivity=a=>typeOf(a)===REACT_ACTIVITY_TYPE;/**
|
|
77
77
|
* Set of known valid React special element types.
|
|
78
78
|
* Used for quick validation of element types in isValidElementType().
|
|
79
79
|
* Includes Fragment, Profiler, StrictMode, Suspense and SuspenseList.
|
|
80
|
-
*/
|
|
80
|
+
*/const knownValidSymbols=new Set([REACT_FRAGMENT_TYPE,REACT_PROFILER_TYPE,REACT_STRICT_MODE_TYPE,REACT_SUSPENSE_TYPE,REACT_SUSPENSE_LIST_TYPE,REACT_VIEW_TRANSITION_TYPE,REACT_ACTIVITY_TYPE]);/**
|
|
81
81
|
* Checks if a type is a valid React element type that can be rendered.
|
|
82
82
|
* This includes strings (for DOM elements), functions (for components),
|
|
83
83
|
* and various React-specific types like Fragment, Context, etc.
|
|
84
84
|
* @param {any} type The type to validate
|
|
85
85
|
* @returns {boolean} - True if the type can be rendered as a React element
|
|
86
|
-
*/export
|
|
86
|
+
*/export const isValidElementType=a=>{if("string"==typeof a||"number"==typeof a||"bigint"==typeof a||"function"==typeof a)return!0;if(knownValidSymbols.has(a))return!0;if("object"==typeof a&&null!==a){const b=a.$$typeof;return b===REACT_LAZY_TYPE||b===REACT_MEMO_TYPE||b===REACT_CONTEXT_TYPE||b===REACT_CONSUMER_TYPE||b===REACT_FORWARD_REF_TYPE||b===REACT_CLIENT_REFERENCE||b===REACT_PROVIDER_TYPE}return!1};/**
|
|
87
87
|
* Type guard that checks if a component is a React class component.
|
|
88
88
|
* Examines the component's prototype for the isReactComponent marker property
|
|
89
89
|
* that React adds to all class components.
|
|
90
90
|
* @param {unknown} component Component to check
|
|
91
91
|
* @returns {boolean} - True if component is a React class component
|
|
92
|
-
*/export
|
|
92
|
+
*/export const isReactClassComponent=a=>{if("function"!=typeof a)return!1;// Check for `isReactComponent` flag which is set on class components.
|
|
93
93
|
// Also handles components created with React.createClass.
|
|
94
|
-
|
|
94
|
+
const b=a.prototype;return!!(b&&b.isReactComponent)};
|
|
@@ -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(
|
|
50
|
+
*/export function Component(a){function Func(a={},b){return Node(c,a,b).render()}const b=getElementTypeName(a),c=b=>{const c=a(b);return c instanceof BaseNode||NodeUtil.isNodeInstance(c)?Node(c.element,c.rawProps).render():c};return c.displayName=`Renderer(${b})`,Func.displayName=`Component(${b})`,Func}
|
package/dist/hoc/portal.hoc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const _excluded=["provider"];function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import{BaseNode,Node}from"../core.node.js";// --- Function Overloads ---
|
|
2
2
|
/**
|
|
3
3
|
* Higher-Order Component (HOC) to create and manage React portals with optional provider wrapping.
|
|
4
4
|
* This function supports two overloads:
|
|
@@ -48,26 +48,26 @@ var _excluded=["provider"];function _typeof(a){"@babel/helpers - typeof";return
|
|
|
48
48
|
* const portalInstance = MyPortal({ provider: AnotherProviderNodeInstance, someProp: 'value' });
|
|
49
49
|
*/// --- Implementation ---
|
|
50
50
|
export function Portal(a,b){// --- Initialization ---
|
|
51
|
-
|
|
51
|
+
let c,d,e={unmount:()=>{console.warn("Portal instance not yet created. Cannot unmount.")},update:a=>{console.warn("Portal instance not yet created. Cannot update.",a)}};// --- Argument Parsing and Overload Handling ---
|
|
52
52
|
// Determines which Portal overload was called (e.g., with fixed provider or just component).
|
|
53
53
|
if("function"==typeof b&&a instanceof BaseNode)// Handles the case where a fixed provider (single) is passed.
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
c=[a],d=b;else if("function"==typeof a&&b===void 0)// Handles the case where only the component function is passed.
|
|
55
|
+
d=a;else throw new Error("Invalid arguments for Portal HOC. Use Portal(component) or Portal(providerNodeInstance, component).");// --- Core Content Renderer Function ---
|
|
56
56
|
// This function is the actual React component that will be rendered inside the portal.
|
|
57
|
-
|
|
57
|
+
const f=(a={})=>{const b=d(_objectSpread(_objectSpread({},a),{},{portal:e// Passes the portal control object to the content component
|
|
58
58
|
}));// If the result is a BaseNode, render it.
|
|
59
59
|
return b instanceof BaseNode?b.render():b};// --- Portal Launcher Function (Returned to User) ---
|
|
60
60
|
// This is the function that developers call to actually create and manage a portal instance.
|
|
61
|
-
return function Func(){// --- Helper for Deep Content Injection ---
|
|
61
|
+
return function Func(a={}){// --- Helper for Deep Content Injection ---
|
|
62
62
|
// Recursively injects content into the deepest child of a provider chain.
|
|
63
|
-
function injectContentDeeply(a,b){
|
|
64
|
-
if(!
|
|
65
|
-
|
|
63
|
+
function injectContentDeeply(a,b){const c=a.rawProps?.children;// If no children, or children is not a NodeInstance, inject directly
|
|
64
|
+
if(!c||!(c instanceof BaseNode))return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:b}));// Recursively inject into the deepest node
|
|
65
|
+
const d=injectContentDeeply(c,b);return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:d}))}// --- Provider Wrapping Logic ---
|
|
66
66
|
// Iterates through the combined providers (fixed + dynamic) to wrap the content.
|
|
67
67
|
// Providers are applied in reverse order to ensure the innermost content is wrapped by the outermost provider.
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
let b;// Combine fixed and dynamic providers
|
|
69
|
+
const d=[];a.provider&&d.push(a.provider);const g=[...(c??[]),...d],{provider:h}=a,i=_objectWithoutProperties(a,_excluded),j=Node(f,i);// Separates props for the portal's content from internal props like 'provider'.
|
|
70
70
|
// Creates the base node for the portal's content.
|
|
71
|
-
return
|
|
71
|
+
return b=0<g.length?g.reduceRight((a,b)=>{if(!(b instanceof BaseNode))return console.warn("Portal: Item in provider is not a valid NodeInstance. Skipping.",b),a;const c=b.rawProps?.children instanceof BaseNode;// If the provider already has nested children, inject content deeply.
|
|
72
72
|
// Otherwise, simply set currentWrappedContent as its direct child.
|
|
73
|
-
return
|
|
73
|
+
return c?injectContentDeeply(b,a):Node(b.element,_objectSpread(_objectSpread({},b.rawProps),{},{children:a}))},j):j,e=b.toPortal(),e}}
|
package/dist/hook/usePortal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";
|
|
1
|
+
"use client";import{useCallback,useEffect,useRef}from"react";import{Node}from"../core.node.js";/**
|
|
2
2
|
* Hook for managing a portal that renders node components outside the React component tree.
|
|
3
3
|
* @deprecated This hook is unstable and will likely be removed in future versions
|
|
4
|
-
*/export function usePortal(
|
|
4
|
+
*/export function usePortal(a=[]){const b=useRef({}),c=useCallback(a=>(b.current.component=a,new Proxy(a,{apply:(a,c,[d])=>(b.current.props=d,a.call(c,d))})),[]);return useEffect(()=>{const{portal:a,component:c,props:d}=b.current;a&&c&&a.update(Node(c,d))},a),useEffect(()=>()=>{b.current.portal?.unmount(),b.current.portal=void 0,b.current.component=void 0,b.current.props=void 0},[]),{portal:b.current.portal,setPortal:a=>b.current.portal=a,createComponent:c}}
|
package/dist/hook/useTheme.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* It also handles side effects like updating localStorage and applying the theme to the document root.
|
|
4
4
|
* @returns {ThemeContextValue} The theme context value.
|
|
5
5
|
* @throws {Error} If used outside a ThemeProvider.
|
|
6
|
-
*/export
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
*/export const useTheme=()=>{const a=useContext(ThemeContext);if(!a)throw new Error("useTheme must be used within a ThemeProvider");const{theme:b}=a;return useEffect(()=>{// Sync theme mode with localStorage
|
|
7
|
+
const a=localStorage.getItem("theme");a&&a===b.mode||localStorage.setItem("theme",b.mode);// Apply theme to document root
|
|
8
|
+
const c=document.documentElement;"dark"===b.mode?(c.setAttribute("data-theme","dark"),c.classList.add("dark-theme"),c.classList.remove("light-theme")):(c.setAttribute("data-theme","light"),c.classList.add("light-theme"),c.classList.remove("dark-theme"))},[b.mode,b.system]),a};
|
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { setDebugMode } from './
|
|
1
|
+
export { setDebugMode } from './constant/common.const.js';
|
|
2
2
|
export { Node, createNode, createChildrenFirstNode } from './core.node.js';
|
|
3
3
|
export * from './hoc/index.js';
|
|
4
4
|
export * from './types/node.type.js';
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAG5D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAG7E,cAAc,mBAAmB,CAAA;AAGjC,cAAc,yBAAyB,CAAA;AAGvC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,mCAAmC,CAAA;AAGjD,cAAc,oBAAoB,CAAA"}
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Common
|
|
2
|
-
export{setDebugMode}from"./
|
|
2
|
+
export{setDebugMode}from"./constant/common.const.js";// Core
|
|
3
3
|
export{Node,createNode,createChildrenFirstNode}from"./core.node.js";// High Order Components
|
|
4
4
|
export*from"./hoc/index.js";// Types
|
|
5
5
|
export*from"./types/node.type.js";// Components
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _StyleRegistry from '../components/registry.client.js';
|
|
2
|
-
export declare const StyleRegistry: (<AdditionalProps extends Record<string,
|
|
2
|
+
export declare const StyleRegistry: (<AdditionalProps extends Record<string, unknown> = Record<string, unknown>>(props: import("../main").MergedProps<typeof _StyleRegistry, AdditionalProps>, deps?: import("../main").DependencyList | undefined) => import("../main").NodeInstance<typeof _StyleRegistry>) & {
|
|
3
3
|
element: typeof _StyleRegistry;
|
|
4
4
|
};
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _StyleRegistry from"../components/registry.client.js";import{createNode}from"../core.node.js";export
|
|
1
|
+
import _StyleRegistry from"../components/registry.client.js";import{createNode}from"../core.node.js";export const StyleRegistry=createNode(_StyleRegistry);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { type CSSProperties, type ReactNode, type JSX, type ElementType, type ComponentType, type JSXElementConstructor, type Component, type ExoticComponent, type ReactElement, type FragmentProps, type SuspenseProps, type ActivityProps } from 'react';
|
|
2
|
-
import type { NO_STYLE_TAGS } from '../
|
|
2
|
+
import type { NO_STYLE_TAGS } from '../constant/common.const.js';
|
|
3
3
|
import type { ComponentNodeProps } from '../hoc/component.hoc.js';
|
|
4
4
|
import type { CSSObject, CSSInterpolation } from '@emotion/serialize';
|
|
5
5
|
import { BaseNode } from '../core.node.js';
|
|
@@ -237,5 +237,10 @@ export type PortalLauncher<P extends BasePortalProps | Record<string, any>> = (p
|
|
|
237
237
|
* @template AdditionalProps - The additional props to merge in
|
|
238
238
|
*/
|
|
239
239
|
export type MergedProps<E extends NodeElement, AdditionalProps extends Record<string, any>> = Omit<NodeProps<E> & AdditionalProps, keyof AdditionalProps> & AdditionalProps;
|
|
240
|
+
export interface WorkItem {
|
|
241
|
+
node: NodeInstance;
|
|
242
|
+
isProcessed: boolean;
|
|
243
|
+
blocked: boolean;
|
|
244
|
+
}
|
|
240
245
|
export {};
|
|
241
246
|
//# sourceMappingURL=node.type.d.ts.map
|
|
@@ -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,KA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C,GAAG,CAAC,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAC5E,UAAU,CAAA;AAEf;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,eAAe,EAAE,MAAM,eAAe,CAAC,GACvJ,eAAe,CAAA;AAEjB,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,YAAY,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import{__DEBUG__}from"../constant/common.const.js";/**
|
|
2
2
|
* MountTrackerUtil keeps track of which BaseNode instances are currently mounted in the DOM.
|
|
3
3
|
* It provides a simple registry for mount/unmount state that other systems
|
|
4
4
|
* (like NavigationCacheManager) can query for safe cache eviction.
|
|
5
5
|
*/export class MountTrackerUtil{constructor(){}// Debug only
|
|
6
6
|
/**
|
|
7
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
|
|
8
|
+
*/static trackMount(a){this.mountedNodes.add(a),__DEBUG__&&this._unmountCallCount.delete(a)}/**
|
|
9
9
|
* Removes its stable key from the set of mounted nodes.
|
|
10
10
|
* In development mode, it also tracks multiple unmount calls for debugging purposes.
|
|
11
11
|
* @returns True if the node was previously tracked as mounted and is now removed, false otherwise.
|
|
12
|
-
*/static untrackMount(a){
|
|
12
|
+
*/static untrackMount(a){const b=this.mountedNodes.delete(a);if(__DEBUG__&&!b){const b=(this._unmountCallCount.get(a)||0)+1;this._unmountCallCount.set(a,b),1<b&&console.warn(`[MeoNode] untrackMount called ${b} times for an already unmounted node: ${a}. This could indicate a memory leak or a bug in a component's lifecycle.`)}return b}/**
|
|
13
13
|
* Cleans up all internal state of the MountTrackerUtil.
|
|
14
14
|
* Removes all tracked nodes and debug counters.
|
|
15
15
|
*/static cleanup(){this.mountedNodes.clear(),__DEBUG__&&this._unmountCallCount.clear()}}_defineProperty(MountTrackerUtil,"mountedNodes",new Set),_defineProperty(MountTrackerUtil,"_unmountCallCount",new Map);
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"navigation-cache-manager.util.d.ts","sourceRoot":"","sources":["../../src/util/navigation-cache-manager.util.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,CAAC,CAAC;IACd,UAAU,MAAM;QACd,4BAA4B,CAAC,EAAE,OAAO,CAAA;KACvC;CACF;AAED;;GAEG;AACH,qBAAa,0BAA0B;IACrC,OAAO,eAAiB;IAExB,OAAO,CAAC,MAAM,CAAC,SAAS,CAA0C;IAClE,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAwC;IACzE,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAA2C;IAC/E,OAAO,CAAC,MAAM,CAAC,UAAU,CAAQ;IAEjC,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,eAAe,CAA8B;IAErD,OAAc,WAAW,IAAI,0BAA0B,CAKtD;IAED;;OAEG;IACI,KAAK,SAaX;IAED;;;OAGG;IACH,OAAO,CAAC,KAAK;IAkBb;;OAEG;IACH,OAAO,CAAC,iBAAiB,CA4BxB;IAED;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmB5B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;CAW1B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import{__DEBUG__}from"../constant/common.const.js";import{BaseNode}from"../core.node.js";import{MountTrackerUtil}from"./mount-tracker.util.js";/**
|
|
2
2
|
* Lightweight navigation handler that clears cache on SPA navigation.
|
|
3
|
-
*/export class NavigationCacheManagerUtil{constructor(){
|
|
3
|
+
*/export class NavigationCacheManagerUtil{constructor(){/**
|
|
4
4
|
* Debounced navigation handler. Clears mounted element cache and props cache.
|
|
5
|
-
*/_defineProperty(this,"_isListening",!1),_defineProperty(this,"_cleanupTimeout",null),_defineProperty(this,"_handleNavigation",
|
|
6
|
-
BaseNode.elementCache.keys().forEach(
|
|
5
|
+
*/_defineProperty(this,"_isListening",!1),_defineProperty(this,"_cleanupTimeout",null),_defineProperty(this,"_handleNavigation",()=>{this._cleanupTimeout&&clearTimeout(this._cleanupTimeout);const a=BaseNode.elementCache.size,b=100>a?50:500>a?100:200;this._cleanupTimeout=setTimeout(()=>{const a=BaseNode.propProcessingCache.size;let b=0;// Only clean UNMOUNTED elements
|
|
6
|
+
BaseNode.elementCache.keys().forEach(a=>{MountTrackerUtil.mountedNodes.has(a)||(BaseNode.elementCache.delete(a),b++)}),200<a&&BaseNode.propProcessingCache.clear(),__DEBUG__&&console.log(`[MeoNode] Navigation: cleared ${b} unmounted elements, ${a} props entries`)},b)})}static getInstance(){return this._instance||(this._instance=new NavigationCacheManagerUtil),this._instance}/**
|
|
7
7
|
* Start listening for navigation events. Idempotent.
|
|
8
8
|
*/start(){this._isListening||"undefined"==typeof window||(// Setup automatic cleanup on page unload
|
|
9
9
|
this._isListening=!0,window.addEventListener("popstate",this._handleNavigation),this._patchHistoryMethods(),this._setupAutoCleanup(),__DEBUG__&&console.log("[MeoNode] NavigationCacheManagerUtil started"))}/**
|
|
@@ -11,9 +11,9 @@ this._isListening=!0,window.addEventListener("popstate",this._handleNavigation),
|
|
|
11
11
|
* This is important for cleanup during HMR or when unmounting the library.
|
|
12
12
|
*/_stop(){this._isListening&&"undefined"!=typeof window&&(window.removeEventListener("popstate",this._handleNavigation),this._cleanupTimeout&&(clearTimeout(this._cleanupTimeout),this._cleanupTimeout=null),this._isListening=!1,__DEBUG__&&console.log("[MeoNode] NavigationCacheManagerUtil stopped"))}/**
|
|
13
13
|
* Patch history.pushState/replaceState to detect SPA navigation.
|
|
14
|
-
*/_patchHistoryMethods(){
|
|
14
|
+
*/_patchHistoryMethods(){NavigationCacheManagerUtil._isPatched||(NavigationCacheManagerUtil._originalPushState=history.pushState,NavigationCacheManagerUtil._originalReplaceState=history.replaceState,history.pushState=(...a)=>{NavigationCacheManagerUtil._originalPushState.apply(history,a),this._handleNavigation()},history.replaceState=(...a)=>{NavigationCacheManagerUtil._originalReplaceState.apply(history,a),this._handleNavigation()},NavigationCacheManagerUtil._isPatched=!0)}/**
|
|
15
15
|
* Setup automatic cleanup on page unload.
|
|
16
16
|
* Covers HMR, navigation away, and browser close.
|
|
17
|
-
*/_setupAutoCleanup(){
|
|
17
|
+
*/_setupAutoCleanup(){// Only set up once
|
|
18
18
|
window.__MEONODE_CLEANUP_REGISTERED||(// Handle page unload (navigation away, refresh, close)
|
|
19
|
-
window.addEventListener("beforeunload",
|
|
19
|
+
window.addEventListener("beforeunload",()=>{this._stop(),BaseNode.clearCaches()}),window.__MEONODE_CLEANUP_REGISTERED=!0)}}_defineProperty(NavigationCacheManagerUtil,"_instance",null),_defineProperty(NavigationCacheManagerUtil,"_originalPushState",null),_defineProperty(NavigationCacheManagerUtil,"_originalReplaceState",null),_defineProperty(NavigationCacheManagerUtil,"_isPatched",!1);
|