@tamagui/web 2.3.3 → 2.4.0-1783110557100
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/.turbo/turbo-build.log +1 -1
- package/dist/cjs/Tamagui.native.js.map +1 -1
- package/dist/cjs/_withStableStyle.native.js.map +1 -1
- package/dist/cjs/animationDriverTypes.test-d.native.js.map +1 -1
- package/dist/cjs/config.native.js.map +1 -1
- package/dist/cjs/constants/constants.native.js.map +1 -1
- package/dist/cjs/constants/isDevTools.native.js.map +1 -1
- package/dist/cjs/contexts/ComponentContext.native.js.map +1 -1
- package/dist/cjs/contexts/GroupContext.native.js.map +1 -1
- package/dist/cjs/createComponent.cjs +4 -3
- package/dist/cjs/createComponent.native.js +7 -6
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/createFont.native.js.map +1 -1
- package/dist/cjs/createShorthands.native.js.map +1 -1
- package/dist/cjs/createTamagui.native.js.map +1 -1
- package/dist/cjs/createTokens.native.js.map +1 -1
- package/dist/cjs/createVariable.native.js.map +1 -1
- package/dist/cjs/createVariables.native.js.map +1 -1
- package/dist/cjs/defaultComponentState.native.js.map +1 -1
- package/dist/cjs/eventHandling.cjs +1 -1
- package/dist/cjs/eventHandling.native.js +12 -36
- package/dist/cjs/eventHandling.native.js.map +1 -1
- package/dist/cjs/helpers/createDesignSystem.native.js.map +1 -1
- package/dist/cjs/helpers/createMediaStyle.native.js.map +1 -1
- package/dist/cjs/helpers/createStyledContext.native.js.map +1 -1
- package/dist/cjs/helpers/defaultAnimationDriver.native.js.map +1 -1
- package/dist/cjs/helpers/defaultOffset.native.js.map +1 -1
- package/dist/cjs/helpers/expandStyle.native.js.map +1 -1
- package/dist/cjs/helpers/expandStyles.native.js.map +1 -1
- package/dist/cjs/helpers/getDefaultProps.native.js.map +1 -1
- package/dist/cjs/helpers/getDynamicVal.native.js.map +1 -1
- package/dist/cjs/helpers/getExpandedShorthands.native.js.map +1 -1
- package/dist/cjs/helpers/getFontLanguage.native.js.map +1 -1
- package/dist/cjs/helpers/getGroupPropParts.native.js.map +1 -1
- package/dist/cjs/helpers/getShorthandValue.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.cjs +5 -0
- package/dist/cjs/helpers/getSplitStyles.native.js +9 -0
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/getTokenForKey.native.js.map +1 -1
- package/dist/cjs/helpers/getVariantExtras.native.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/cjs/helpers/isActivePlatform.native.js.map +1 -1
- package/dist/cjs/helpers/isActiveTheme.native.js.map +1 -1
- package/dist/cjs/helpers/isObj.native.js.map +1 -1
- package/dist/cjs/helpers/isTamaguiComponent.native.js.map +1 -1
- package/dist/cjs/helpers/isTamaguiElement.native.js.map +1 -1
- package/dist/cjs/helpers/log.native.js.map +1 -1
- package/dist/cjs/helpers/mainThreadPressEvents.native.js +20 -3
- package/dist/cjs/helpers/mainThreadPressEvents.native.js.map +1 -1
- package/dist/cjs/helpers/mediaObjectToString.native.js.map +1 -1
- package/dist/cjs/helpers/mediaState.native.js.map +1 -1
- package/dist/cjs/helpers/mergeProps.native.js.map +1 -1
- package/dist/cjs/helpers/mergeRenderElementProps.native.js.map +1 -1
- package/dist/cjs/helpers/mergeSlotStyleProps.native.js.map +1 -1
- package/dist/cjs/helpers/mergeVariants.native.js.map +1 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.js.map +1 -1
- package/dist/cjs/helpers/normalizeStyle.native.js.map +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.native.js.map +1 -1
- package/dist/cjs/helpers/objectIdentityKey.native.js.map +1 -1
- package/dist/cjs/helpers/parseNativeStyle.native.js.map +1 -1
- package/dist/cjs/helpers/pointerEvents.native.js +26 -20
- package/dist/cjs/helpers/pointerEvents.native.js.map +1 -1
- package/dist/cjs/helpers/propMapper.native.js +40 -15
- package/dist/cjs/helpers/propMapper.native.js.map +1 -1
- package/dist/cjs/helpers/proxyThemeToParents.native.js.map +1 -1
- package/dist/cjs/helpers/proxyThemeVariables.native.js.map +1 -1
- package/dist/cjs/helpers/pseudoDescriptors.native.js.map +1 -1
- package/dist/cjs/helpers/pseudoTransitions.native.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.native.js.map +1 -1
- package/dist/cjs/helpers/resolveAnimationDriver.native.js.map +1 -1
- package/dist/cjs/helpers/resolveCompoundTokens.native.js.map +1 -1
- package/dist/cjs/helpers/skipProps.native.js.map +1 -1
- package/dist/cjs/helpers/sortString.native.js.map +1 -1
- package/dist/cjs/helpers/styleOriginalValues.native.js.map +1 -1
- package/dist/cjs/helpers/subscribeToContextGroup.native.js.map +1 -1
- package/dist/cjs/helpers/themeable.native.js.map +1 -1
- package/dist/cjs/helpers/themes.native.js.map +1 -1
- package/dist/cjs/helpers/timer.native.js.map +1 -1
- package/dist/cjs/helpers/transformsToString.native.js.map +1 -1
- package/dist/cjs/helpers/useRenderElement.native.js.map +1 -1
- package/dist/cjs/helpers/wrapStyleTags.native.js.map +1 -1
- package/dist/cjs/hooks/getThemeProxied.native.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.cjs +25 -1
- package/dist/cjs/hooks/useComponentState.native.js +25 -1
- package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
- package/dist/cjs/hooks/useDisableSSR.native.js.map +1 -1
- package/dist/cjs/hooks/useIsTouchDevice.native.js.map +1 -1
- package/dist/cjs/hooks/useMedia.cjs +107 -42
- package/dist/cjs/hooks/useMedia.native.js +149 -60
- package/dist/cjs/hooks/useMedia.native.js.map +1 -1
- package/dist/cjs/hooks/useProps.native.js.map +1 -1
- package/dist/cjs/hooks/useTheme.cjs +17 -4
- package/dist/cjs/hooks/useTheme.native.js +18 -4
- package/dist/cjs/hooks/useTheme.native.js.map +1 -1
- package/dist/cjs/hooks/useThemeName.native.js.map +1 -1
- package/dist/cjs/hooks/useThemeState.cjs +132 -67
- package/dist/cjs/hooks/useThemeState.native.js +144 -70
- package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.native.js +2 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/inject-styles.native.js.map +1 -1
- package/dist/cjs/insertFont.native.js.map +1 -1
- package/dist/cjs/interfaces/CSSColorNames.native.js.map +1 -1
- package/dist/cjs/interfaces/GetRef.native.js.map +1 -1
- package/dist/cjs/interfaces/RNExclusiveTypes.native.js.map +1 -1
- package/dist/cjs/interfaces/TamaguiComponentEvents.native.js.map +1 -1
- package/dist/cjs/interfaces/TamaguiComponentPropsBaseBase.native.js.map +1 -1
- package/dist/cjs/opacityModifier.test-d.native.js.map +1 -1
- package/dist/cjs/setupHooks.native.js.map +1 -1
- package/dist/cjs/setupReactNative.native.js.map +1 -1
- package/dist/cjs/styled.native.js.map +1 -1
- package/dist/cjs/styledHtml.test-d.native.js.map +1 -1
- package/dist/cjs/styledNonStyleProps.test-d.native.js.map +1 -1
- package/dist/cjs/type-utils.native.js.map +1 -1
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/views/Configuration.native.js.map +1 -1
- package/dist/cjs/views/Slot.native.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
- package/dist/cjs/views/Text.native.js.map +1 -1
- package/dist/cjs/views/Theme.cjs +1 -1
- package/dist/cjs/views/Theme.native.js +1 -1
- package/dist/cjs/views/Theme.native.js.map +1 -1
- package/dist/cjs/views/ThemeProvider.native.js.map +1 -1
- package/dist/cjs/views/View.native.js.map +1 -1
- package/dist/esm/createComponent.mjs +4 -3
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +10 -8
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/eventHandling.mjs +1 -1
- package/dist/esm/eventHandling.mjs.map +1 -1
- package/dist/esm/eventHandling.native.js +12 -36
- package/dist/esm/eventHandling.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +5 -0
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +9 -0
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/mainThreadPressEvents.native.js +20 -3
- package/dist/esm/helpers/mainThreadPressEvents.native.js.map +1 -1
- package/dist/esm/helpers/pointerEvents.native.js +26 -20
- package/dist/esm/helpers/pointerEvents.native.js.map +1 -1
- package/dist/esm/helpers/propMapper.native.js +40 -15
- package/dist/esm/helpers/propMapper.native.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +26 -2
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +26 -2
- package/dist/esm/hooks/useComponentState.native.js.map +1 -1
- package/dist/esm/hooks/useMedia.mjs +108 -43
- package/dist/esm/hooks/useMedia.mjs.map +1 -1
- package/dist/esm/hooks/useMedia.native.js +150 -61
- package/dist/esm/hooks/useMedia.native.js.map +1 -1
- package/dist/esm/hooks/useTheme.mjs +17 -4
- package/dist/esm/hooks/useTheme.mjs.map +1 -1
- package/dist/esm/hooks/useTheme.native.js +18 -4
- package/dist/esm/hooks/useTheme.native.js.map +1 -1
- package/dist/esm/hooks/useThemeState.mjs +133 -68
- package/dist/esm/hooks/useThemeState.mjs.map +1 -1
- package/dist/esm/hooks/useThemeState.native.js +145 -71
- package/dist/esm/hooks/useThemeState.native.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +3 -3
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/views/Theme.mjs +1 -1
- package/dist/esm/views/Theme.mjs.map +1 -1
- package/dist/esm/views/Theme.native.js +1 -1
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/package.json +13 -13
- package/src/createComponent.tsx +18 -7
- package/src/eventHandling.native.ts +28 -40
- package/src/eventHandling.ts +2 -1
- package/src/helpers/getSplitStyles.tsx +33 -0
- package/src/helpers/mainThreadPressEvents.native.ts +25 -3
- package/src/helpers/pointerEvents.native.ts +26 -19
- package/src/helpers/propMapper.ts +23 -0
- package/src/hooks/useComponentState.ts +39 -2
- package/src/hooks/useMedia.tsx +147 -42
- package/src/hooks/useTheme.tsx +27 -5
- package/src/hooks/useThemeState.ts +263 -137
- package/src/index.ts +7 -1
- package/src/types.tsx +53 -5
- package/src/views/Theme.tsx +4 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/eventHandling.d.ts +1 -1
- package/types/eventHandling.d.ts.map +1 -1
- package/types/eventHandling.native.d.ts +2 -2
- package/types/eventHandling.native.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/mainThreadPressEvents.native.d.ts.map +1 -1
- package/types/helpers/pointerEvents.native.d.ts.map +1 -1
- package/types/helpers/propMapper.d.ts.map +1 -1
- package/types/hooks/useComponentState.d.ts +1 -1
- package/types/hooks/useComponentState.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts +1 -1
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/hooks/useThemeState.d.ts +1 -1
- package/types/hooks/useThemeState.d.ts.map +1 -1
- package/types/index.d.ts +2 -2
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +3 -1
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
-
import { createContext,
|
|
2
|
+
import { createContext, useContext, useEffect, useId, useReducer, useRef } from "react";
|
|
3
3
|
import { getConfig } from "../config.mjs";
|
|
4
4
|
import { MISSING_THEME_MESSAGE } from "../constants/constants.mjs";
|
|
5
5
|
const ThemeStateContext = createContext("");
|
|
@@ -24,7 +24,8 @@ let themeNameCacheVer = -1;
|
|
|
24
24
|
let themes = null;
|
|
25
25
|
let rootThemeState = null;
|
|
26
26
|
const getRootThemeState = () => rootThemeState;
|
|
27
|
-
const
|
|
27
|
+
const incReducer = c => c + 1;
|
|
28
|
+
const useThemeState = (props, isRoot = false, keys, schemeKeys, cascadeOnChange = false) => {
|
|
28
29
|
"use no memo";
|
|
29
30
|
|
|
30
31
|
const {
|
|
@@ -40,69 +41,68 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}${props.componentName ? `
|
|
|
40
41
|
theme: getConfig().themes.light
|
|
41
42
|
};
|
|
42
43
|
const id = useId();
|
|
43
|
-
const subscribe = useCallback(cb => {
|
|
44
|
-
listenersByParent[parentId] = listenersByParent[parentId] || /* @__PURE__ */new Set();
|
|
45
|
-
listenersByParent[parentId].add(id);
|
|
46
|
-
allListeners.set(id, () => {
|
|
47
|
-
PendingUpdate.set(id, shouldForce ? "force" : true);
|
|
48
|
-
cb();
|
|
49
|
-
});
|
|
50
|
-
return () => {
|
|
51
|
-
allListeners.delete(id);
|
|
52
|
-
listenersByParent[parentId].delete(id);
|
|
53
|
-
localStates.delete(id);
|
|
54
|
-
states.delete(id);
|
|
55
|
-
PendingUpdate.delete(id);
|
|
56
|
-
};
|
|
57
|
-
}, [id, parentId]);
|
|
58
44
|
const propsKey = getPropsKey(props);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (process.env.NODE_ENV === "development" && props.debug === "verbose") {
|
|
79
|
-
console.groupCollapsed(` ${id} getSnapshot ${rerender}`, local.name, ">", next.name);
|
|
80
|
-
console.info({
|
|
81
|
-
props,
|
|
82
|
-
propsKey,
|
|
83
|
-
isRoot,
|
|
84
|
-
parentId,
|
|
85
|
-
local,
|
|
86
|
-
next,
|
|
87
|
-
needsUpdate,
|
|
88
|
-
isSchemeOnlyChange,
|
|
89
|
-
allKeysSchemeOptimized,
|
|
90
|
-
canSkipForSchemeChange
|
|
91
|
-
});
|
|
92
|
-
console.groupEnd();
|
|
93
|
-
}
|
|
94
|
-
if (next !== local) {
|
|
95
|
-
Object.assign(local, next);
|
|
96
|
-
local.id = id;
|
|
97
|
-
}
|
|
98
|
-
local._parentName = parentState?.name;
|
|
99
|
-
local._propsKey = propsKey;
|
|
100
|
-
states.set(id, next);
|
|
101
|
-
return local;
|
|
102
|
-
};
|
|
45
|
+
const ref = useRef(null);
|
|
46
|
+
if (!ref.current) ref.current = {
|
|
47
|
+
id,
|
|
48
|
+
parentId,
|
|
49
|
+
props,
|
|
50
|
+
propsKey,
|
|
51
|
+
isRoot,
|
|
52
|
+
keys,
|
|
53
|
+
schemeKeys,
|
|
54
|
+
renderVersion: 0
|
|
55
|
+
};else {
|
|
56
|
+
ref.current.props = props;
|
|
57
|
+
ref.current.propsKey = propsKey;
|
|
58
|
+
ref.current.isRoot = isRoot;
|
|
59
|
+
ref.current.keys = keys;
|
|
60
|
+
ref.current.schemeKeys = schemeKeys;
|
|
61
|
+
ref.current.parentId = parentId;
|
|
62
|
+
}
|
|
63
|
+
ref.current.renderVersion++;
|
|
103
64
|
if (process.env.NODE_ENV === "development" && globalThis.time) globalThis.time`theme-prep-uses`;
|
|
104
|
-
const
|
|
105
|
-
|
|
65
|
+
const [, forceUpdate] = useReducer(incReducer, 0);
|
|
66
|
+
const state = getSnapshotImpl(ref.current);
|
|
67
|
+
ref.current.lastSnap = state;
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const r = ref.current;
|
|
70
|
+
const renderVersion = r.renderVersion;
|
|
71
|
+
if (r.unsubscribe && r.subscribedParentId !== r.parentId) cleanupThemeSubscription(r);
|
|
72
|
+
if (shouldSubscribeToTheme(r, cascadeOnChange)) {
|
|
73
|
+
if (!r.unsubscribe) {
|
|
74
|
+
const pid = r.parentId;
|
|
75
|
+
const sid = r.id;
|
|
76
|
+
const cb = () => {
|
|
77
|
+
const next = getSnapshotImpl(r);
|
|
78
|
+
if (next !== r.lastSnap) {
|
|
79
|
+
r.lastSnap = next;
|
|
80
|
+
forceUpdate();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
listenersByParent[pid] = listenersByParent[pid] || /* @__PURE__ */new Set();
|
|
84
|
+
listenersByParent[pid].add(sid);
|
|
85
|
+
allListeners.set(sid, () => {
|
|
86
|
+
PendingUpdate.set(sid, shouldForce ? "force" : true);
|
|
87
|
+
cb();
|
|
88
|
+
});
|
|
89
|
+
r.subscribedParentId = pid;
|
|
90
|
+
r.unsubscribe = () => {
|
|
91
|
+
allListeners.delete(sid);
|
|
92
|
+
listenersByParent[pid]?.delete(sid);
|
|
93
|
+
localStates.delete(sid);
|
|
94
|
+
states.delete(sid);
|
|
95
|
+
PendingUpdate.delete(sid);
|
|
96
|
+
r.unsubscribe = void 0;
|
|
97
|
+
r.subscribedParentId = void 0;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
} else if (r.unsubscribe) cleanupThemeSubscription(r);
|
|
101
|
+
return () => {
|
|
102
|
+
if (r.renderVersion === renderVersion) cleanupThemeState(r);
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
if (cascadeOnChange) useIsomorphicLayoutEffect(() => {
|
|
106
106
|
if (!HasRenderedOnce.get(keys)) {
|
|
107
107
|
HasRenderedOnce.set(keys, true);
|
|
108
108
|
return;
|
|
@@ -118,6 +118,70 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}${props.componentName ? `
|
|
|
118
118
|
}, [keys, propsKey]);
|
|
119
119
|
return state;
|
|
120
120
|
};
|
|
121
|
+
const shouldSubscribeToTheme = (r, cascadeOnChange) => r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || !!r.keys.current?.size || !!r.props.needsUpdate?.();
|
|
122
|
+
function cleanupThemeSubscription(r) {
|
|
123
|
+
r.unsubscribe?.();
|
|
124
|
+
}
|
|
125
|
+
function cleanupThemeState(r) {
|
|
126
|
+
if (r.unsubscribe) cleanupThemeSubscription(r);else {
|
|
127
|
+
localStates.delete(r.id);
|
|
128
|
+
states.delete(r.id);
|
|
129
|
+
PendingUpdate.delete(r.id);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const getSnapshotImpl = r => {
|
|
133
|
+
const {
|
|
134
|
+
id,
|
|
135
|
+
parentId,
|
|
136
|
+
props,
|
|
137
|
+
propsKey,
|
|
138
|
+
isRoot,
|
|
139
|
+
keys,
|
|
140
|
+
schemeKeys
|
|
141
|
+
} = r;
|
|
142
|
+
let local = localStates.get(id);
|
|
143
|
+
const parentState = states.get(parentId);
|
|
144
|
+
if (local && !PendingUpdate.has(id)) {
|
|
145
|
+
if (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;
|
|
146
|
+
}
|
|
147
|
+
const isSchemeOnlyChange = false;
|
|
148
|
+
const keysSize = keys?.current?.size ?? 0;
|
|
149
|
+
const allKeysSchemeOptimized = (schemeKeys?.current?.size ?? 0) === keysSize && keysSize > 0;
|
|
150
|
+
const canSkipForSchemeChange = isSchemeOnlyChange;
|
|
151
|
+
const needsUpdate = props.passThrough ? false : isRoot || props.name === "light" || props.name === "dark" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : keys?.current?.size ? true : props.needsUpdate?.();
|
|
152
|
+
const [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));
|
|
153
|
+
PendingUpdate.delete(id);
|
|
154
|
+
if (!local || rerender) {
|
|
155
|
+
local = {
|
|
156
|
+
...next
|
|
157
|
+
};
|
|
158
|
+
localStates.set(id, local);
|
|
159
|
+
}
|
|
160
|
+
if (process.env.NODE_ENV === "development" && props.debug === "verbose") {
|
|
161
|
+
console.groupCollapsed(` ${id} getSnapshot ${rerender}`, local.name, ">", next.name);
|
|
162
|
+
console.info({
|
|
163
|
+
props,
|
|
164
|
+
propsKey,
|
|
165
|
+
isRoot,
|
|
166
|
+
parentId,
|
|
167
|
+
local,
|
|
168
|
+
next,
|
|
169
|
+
needsUpdate,
|
|
170
|
+
isSchemeOnlyChange,
|
|
171
|
+
allKeysSchemeOptimized,
|
|
172
|
+
canSkipForSchemeChange
|
|
173
|
+
});
|
|
174
|
+
console.groupEnd();
|
|
175
|
+
}
|
|
176
|
+
if (next !== local) {
|
|
177
|
+
Object.assign(local, next);
|
|
178
|
+
local.id = id;
|
|
179
|
+
}
|
|
180
|
+
local._parentName = parentState?.name;
|
|
181
|
+
local._propsKey = propsKey;
|
|
182
|
+
states.set(id, next);
|
|
183
|
+
return local;
|
|
184
|
+
};
|
|
121
185
|
const getNextState = (lastState, props, propsKey, isRoot = false, id, parentId, needsUpdate, pendingUpdate) => {
|
|
122
186
|
const {
|
|
123
187
|
debug
|
|
@@ -152,12 +216,13 @@ const getNextState = (lastState, props, propsKey, isRoot = false, id, parentId,
|
|
|
152
216
|
}];
|
|
153
217
|
}
|
|
154
218
|
if (!name) {
|
|
155
|
-
const next = lastState ?? parentState
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
219
|
+
const next = lastState ?? parentState ?? rootThemeState ?? {
|
|
220
|
+
id,
|
|
221
|
+
name: "light",
|
|
222
|
+
theme: getConfig().themes.light
|
|
223
|
+
};
|
|
159
224
|
if (shouldRerender) return [true, {
|
|
160
|
-
...(parentState || lastState)
|
|
225
|
+
...(parentState || lastState || next)
|
|
161
226
|
}];
|
|
162
227
|
return [false, next];
|
|
163
228
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIsomorphicLayoutEffect","createContext","useCallback","useContext","useId","useSyncExternalStore","getConfig","MISSING_THEME_MESSAGE","ThemeStateContext","allListeners","Map","listenersByParent","HasRenderedOnce","WeakMap","HadTheme","PendingUpdate","states","localStates","shouldForce","forceUpdateThemes","cacheVersion","forEach","cb","getThemeState","id","get","themeNameCache","themeNameCacheVer","themes","rootThemeState","getRootThemeState","useThemeState","props","isRoot","keys","schemeKeys","disable","parentId","Error","process","env","NODE_ENV","name","componentName","theme","light","subscribe","Set","add","set","delete","propsKey","getPropsKey","getSnapshot","local","parentState","has","_parentName","_propsKey","isSchemeOnlyChange","keysSize","current","size","allKeysSchemeOptimized","canSkipForSchemeChange","needsUpdate","passThrough","rerender","next","getNextState","debug","console","groupCollapsed","info","groupEnd","Object","assign","globalThis","time","state","scheduleUpdate","warn","lastState","pendingUpdate","isNew","getNewThemeName","isSameAsParent","shouldRerender","Boolean","message","trace","scheme","getScheme","isInverse","nextState","parentName","shouldAvoidRerender","queue","visited","length","children","shift","childId","push","validSchemes","dark","split","forceUpdate","reset","unstyled","cacheKey","clear","cached","themes2","result2","lastPartIndex","lastIndexOf","name2","slice","result","parentParts","lastName","toLowerCase","pop","subNames","filter","found","nameHasScheme","subName","potentialBases","i","join","outer","base","candidates","potential","max","forceClassName","hasThemeUpdatingProps"],"sources":["useThemeState.mjs"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useCallback, useContext, useId, useSyncExternalStore } from \"react\";\nimport { getConfig } from \"../config\";\nimport { MISSING_THEME_MESSAGE } from \"../constants/constants\";\n\nconst ThemeStateContext = createContext(\"\");\nconst allListeners = /* @__PURE__ */ new Map();\nconst listenersByParent = {};\nconst HasRenderedOnce = /* @__PURE__ */ new WeakMap();\nconst HadTheme = /* @__PURE__ */ new WeakMap();\nconst PendingUpdate = /* @__PURE__ */ new Map();\nconst states = /* @__PURE__ */ new Map();\nconst localStates = /* @__PURE__ */ new Map();\nlet shouldForce = false;\nconst forceUpdateThemes = () => {\n\tcacheVersion++;\n\tshouldForce = true;\n\tallListeners.forEach((cb) => cb());\n\tshouldForce = false;\n};\nconst getThemeState = (id) => states.get(id);\nlet cacheVersion = 0;\nconst themeNameCache = /* @__PURE__ */ new Map();\nlet themeNameCacheVer = -1;\nlet themes = null;\nlet rootThemeState = null;\nconst getRootThemeState = () => rootThemeState;\nconst useThemeState = (props, isRoot = false, keys, schemeKeys) => {\n\t\"use no memo\";\n\tconst { disable } = props;\n\tconst parentId = useContext(ThemeStateContext);\n\tif (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === \"development\" ? `${MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}${props.componentName ? ` (component: ${props.componentName})` : \"\"}, but no parent theme context was found (parentId: ${parentId}).` : MISSING_THEME_MESSAGE);\n\tif (disable) return states.get(parentId) || {\n\t\tid: \"\",\n\t\tname: \"light\",\n\t\ttheme: getConfig().themes.light\n\t};\n\tconst id = useId();\n\tconst subscribe = useCallback((cb) => {\n\t\tlistenersByParent[parentId] = listenersByParent[parentId] || /* @__PURE__ */ new Set();\n\t\tlistenersByParent[parentId].add(id);\n\t\tallListeners.set(id, () => {\n\t\t\tPendingUpdate.set(id, shouldForce ? \"force\" : true);\n\t\t\tcb();\n\t\t});\n\t\treturn () => {\n\t\t\tallListeners.delete(id);\n\t\t\tlistenersByParent[parentId].delete(id);\n\t\t\tlocalStates.delete(id);\n\t\t\tstates.delete(id);\n\t\t\tPendingUpdate.delete(id);\n\t\t};\n\t}, [id, parentId]);\n\tconst propsKey = getPropsKey(props);\n\tconst getSnapshot = () => {\n\t\tlet local = localStates.get(id);\n\t\tconst parentState = states.get(parentId);\n\t\tif (local && !PendingUpdate.has(id)) {\n\t\t\tif (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;\n\t\t}\n\t\tconst isSchemeOnlyChange = false;\n\t\tconst keysSize = keys?.current?.size ?? 0;\n\t\tconst allKeysSchemeOptimized = (schemeKeys?.current?.size ?? 0) === keysSize && keysSize > 0;\n\t\tconst canSkipForSchemeChange = isSchemeOnlyChange;\n\t\tconst needsUpdate = props.passThrough ? false : isRoot || props.name === \"light\" || props.name === \"dark\" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : keys?.current?.size ? true : props.needsUpdate?.();\n\t\tconst [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));\n\t\tPendingUpdate.delete(id);\n\t\tif (!local || rerender) {\n\t\t\tlocal = { ...next };\n\t\t\tlocalStates.set(id, local);\n\t\t}\n\t\tif (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n\t\t\tconsole.groupCollapsed(` ${id} getSnapshot ${rerender}`, local.name, \">\", next.name);\n\t\t\tconsole.info({\n\t\t\t\tprops,\n\t\t\t\tpropsKey,\n\t\t\t\tisRoot,\n\t\t\t\tparentId,\n\t\t\t\tlocal,\n\t\t\t\tnext,\n\t\t\t\tneedsUpdate,\n\t\t\t\tisSchemeOnlyChange,\n\t\t\t\tallKeysSchemeOptimized,\n\t\t\t\tcanSkipForSchemeChange\n\t\t\t});\n\t\t\tconsole.groupEnd();\n\t\t}\n\t\tif (next !== local) {\n\t\t\tObject.assign(local, next);\n\t\t\tlocal.id = id;\n\t\t}\n\t\tlocal._parentName = parentState?.name;\n\t\tlocal._propsKey = propsKey;\n\t\tstates.set(id, next);\n\t\treturn local;\n\t};\n\tif (process.env.NODE_ENV === \"development\" && globalThis.time) globalThis.time`theme-prep-uses`;\n\tconst state = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!HasRenderedOnce.get(keys)) {\n\t\t\tHasRenderedOnce.set(keys, true);\n\t\t\treturn;\n\t\t}\n\t\tif (!propsKey) {\n\t\t\tif (HadTheme.get(keys)) scheduleUpdate(id);\n\t\t\tHadTheme.set(keys, false);\n\t\t\treturn;\n\t\t}\n\t\tif (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") console.warn(` \\xB7 useTheme(${id}) scheduleUpdate`, propsKey, states.get(id)?.name);\n\t\tscheduleUpdate(id);\n\t\tHadTheme.set(keys, true);\n\t}, [keys, propsKey]);\n\treturn state;\n};\nconst getNextState = (lastState, props, propsKey, isRoot = false, id, parentId, needsUpdate, pendingUpdate) => {\n\tconst { debug } = props;\n\tconst parentState = states.get(parentId);\n\tif (props.passThrough) return [false, lastState || parentState || { name: \"\" }];\n\tif (!themes) themes = getConfig().themes;\n\tconst name = !propsKey && (!lastState || !lastState?.isNew) ? null : getNewThemeName(parentState?.name, props, pendingUpdate === \"force\" ? true : !!needsUpdate);\n\tconst isSameAsParent = parentState && (!name || name === parentState.name);\n\tconst shouldRerender = Boolean(pendingUpdate === \"force\" || needsUpdate && (pendingUpdate || lastState?.name !== parentState?.name));\n\tif (process.env.NODE_ENV === \"development\" && debug === \"verbose\") {\n\t\tconst message = ` \\xB7 useTheme(${id}) getNextState => ${name} needsUpdate ${needsUpdate} shouldRerender ${shouldRerender}`;\n\t\tconsole.groupCollapsed(message);\n\t\tconsole.trace({\n\t\t\tname,\n\t\t\tlastState,\n\t\t\tparentState,\n\t\t\tprops,\n\t\t\tpropsKey,\n\t\t\tid,\n\t\t\tisSameAsParent\n\t\t});\n\t\tconsole.groupEnd();\n\t}\n\tif (isSameAsParent) {\n\t\tif (!shouldRerender && lastState && lastState.name === parentState.name) return [false, lastState];\n\t\treturn [shouldRerender, {\n\t\t\t...parentState,\n\t\t\tisNew: false\n\t\t}];\n\t}\n\tif (!name) {\n\t\tconst next = lastState ?? parentState;\n\t\tif (!next) throw new Error(process.env.NODE_ENV === \"development\" ? `${MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}${props.componentName ? ` (component: ${props.componentName})` : \"\"}, but no theme state was resolved (parentId: ${parentId}, id: ${id}).` : MISSING_THEME_MESSAGE);\n\t\tif (shouldRerender) return [true, { ...parentState || lastState }];\n\t\treturn [false, next];\n\t}\n\tconst scheme = getScheme(name);\n\tconst isInverse = parentState && scheme !== parentState.scheme;\n\tconst nextState = {\n\t\tid,\n\t\tname,\n\t\ttheme: themes[name],\n\t\tscheme,\n\t\tparentId,\n\t\tparentName: parentState?.name,\n\t\tisInverse,\n\t\tisNew: true\n\t};\n\tif (isRoot) rootThemeState = nextState;\n\tif (pendingUpdate !== \"force\" && lastState && lastState.name === name) return [false, nextState];\n\tconst shouldAvoidRerender = pendingUpdate !== \"force\" && lastState && !needsUpdate && nextState.name === lastState.name;\n\tif (process.env.NODE_ENV === \"development\" && debug === \"verbose\") {\n\t\tconsole.groupCollapsed(` \\xB7 useTheme(${id}) \\u23ED\\uFE0F ${name} shouldAvoidRerender: ${shouldAvoidRerender}`);\n\t\tconsole.info({\n\t\t\tlastState,\n\t\t\tneedsUpdate,\n\t\t\tnextState,\n\t\t\tpendingUpdate\n\t\t});\n\t\tconsole.groupEnd();\n\t}\n\tif (shouldAvoidRerender) return [false, nextState];\n\treturn [true, nextState];\n};\nfunction scheduleUpdate(id) {\n\tconst queue = [id];\n\tconst visited = /* @__PURE__ */ new Set();\n\twhile (queue.length) {\n\t\tconst children = listenersByParent[queue.shift()];\n\t\tif (children) {\n\t\t\tfor (const childId of children) if (!visited.has(childId)) {\n\t\t\t\tvisited.add(childId);\n\t\t\t\tqueue.push(childId);\n\t\t\t}\n\t\t}\n\t}\n\tvisited.forEach((childId) => {\n\t\tallListeners.get(childId)?.();\n\t});\n}\nconst validSchemes = {\n\tlight: \"light\",\n\tdark: \"dark\"\n};\nfunction getScheme(name) {\n\treturn validSchemes[name.split(\"_\")[0]];\n}\nfunction getNewThemeName(parentName = \"\", props, forceUpdate = false) {\n\tconst { name, reset } = props;\n\tconst componentName = props.unstyled ? void 0 : props.componentName;\n\tif (name && reset) throw new Error(process.env.NODE_ENV === \"production\" ? `\\u274C004` : \"Cannot reset and set a new name at the same time.\");\n\tconst cacheKey = `${parentName}|${name || \"\"}|${componentName || \"\"}|${reset ? 1 : 0}|${forceUpdate ? 1 : 0}`;\n\tif (themeNameCacheVer !== cacheVersion) {\n\t\tthemeNameCache.clear();\n\t\tthemeNameCacheVer = cacheVersion;\n\t} else {\n\t\tconst cached = themeNameCache.get(cacheKey);\n\t\tif (cached !== void 0) return cached;\n\t}\n\tconst { themes: themes2 } = getConfig();\n\tif (reset) {\n\t\tif (parentName === \"light\" || parentName === \"dark\") {\n\t\t\tconst result2 = parentName === \"light\" ? \"dark\" : \"light\";\n\t\t\tthemeNameCache.set(cacheKey, result2);\n\t\t\treturn result2;\n\t\t}\n\t\tconst lastPartIndex = parentName.lastIndexOf(\"_\");\n\t\tconst name2 = lastPartIndex <= 0 ? parentName : parentName.slice(lastPartIndex);\n\t\tconst scheme = parentName.slice(0, lastPartIndex);\n\t\tconst result = themes2[name2] ? name2 : scheme;\n\t\tthemeNameCache.set(cacheKey, result);\n\t\treturn result;\n\t}\n\tconst parentParts = parentName.split(\"_\");\n\tconst lastName = parentParts[parentParts.length - 1];\n\tif (lastName && lastName[0].toLowerCase() !== lastName[0]) parentParts.pop();\n\tconst subNames = [\n\t\tname && componentName ? `${name}_${componentName}` : void 0,\n\t\tname,\n\t\tcomponentName\n\t].filter(Boolean);\n\tlet found = null;\n\tif (name) {\n\t\tconst nameHasScheme = getScheme(name);\n\t\tif (nameHasScheme) {\n\t\t\tfor (const subName of subNames) if (subName in themes2) {\n\t\t\t\tfound = subName;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!found && !nameHasScheme) {\n\t\t\tif (getScheme(parentName)) {\n\t\t\t\tconst potentialBases = [];\n\t\t\t\tfor (let i = parentParts.length; i >= 1; i--) potentialBases.push(parentParts.slice(0, i).join(\"_\"));\n\t\t\t\touter: for (const base of potentialBases) {\n\t\t\t\t\tconst candidates = [componentName ? `${base}_${name}_${componentName}` : void 0, `${base}_${name}`].filter(Boolean);\n\t\t\t\t\tfor (const potential of candidates) if (potential in themes2) {\n\t\t\t\t\t\tfound = potential;\n\t\t\t\t\t\tbreak outer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (!found) if (!name && componentName) {\n\t\tconst potential = `${parentParts.join(\"_\")}_${componentName}`;\n\t\tif (potential in themes2) found = potential;\n\t} else {\n\t\tconst max = parentParts.length;\n\t\tfor (let i = 0; i <= max; i++) {\n\t\t\tconst base = (i === 0 ? parentParts : parentParts.slice(0, -i)).join(\"_\");\n\t\t\tfor (const subName of subNames) {\n\t\t\t\tconst potential = base ? `${base}_${subName}` : subName;\n\t\t\t\tif (potential in themes2) {\n\t\t\t\t\tfound = potential;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (found) break;\n\t\t}\n\t}\n\tif (!forceUpdate && found === parentName && !validSchemes[found]) {\n\t\tthemeNameCache.set(cacheKey, null);\n\t\treturn null;\n\t}\n\tthemeNameCache.set(cacheKey, found);\n\treturn found;\n}\nconst getPropsKey = ({ name, reset, forceClassName, componentName }) => `${name || \"\"}${reset || \"\"}${forceClassName || \"\"}${componentName || \"\"}`;\nconst hasThemeUpdatingProps = (props) => \"name\" in props || \"reset\" in props || \"forceClassName\" in props;\n\nexport { ThemeStateContext, forceUpdateThemes, getRootThemeState, getThemeState, hasThemeUpdatingProps, useThemeState };"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,oBAAoB;AAC9D,SAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,KAAK,EAAEC,oBAAoB,QAAQ,OAAO;AAC3F,SAASC,SAAS,QAAQ,eAAW;AACrC,SAASC,qBAAqB,QAAQ,4BAAwB;AAE9D,MAAMC,iBAAiB,GAAGP,aAAa,CAAC,EAAE,CAAC;AAC3C,MAAMQ,YAAY,GAAG,eAAgB,IAAIC,GAAG,CAAC,CAAC;AAC9C,MAAMC,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAMC,eAAe,GAAG,eAAgB,IAAIC,OAAO,CAAC,CAAC;AACrD,MAAMC,QAAQ,GAAG,eAAgB,IAAID,OAAO,CAAC,CAAC;AAC9C,MAAME,aAAa,GAAG,eAAgB,IAAIL,GAAG,CAAC,CAAC;AAC/C,MAAMM,MAAM,GAAG,eAAgB,IAAIN,GAAG,CAAC,CAAC;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AK,CAAC;EACnC,OAAOA,KAAK;AACb;AACA,MAAM1E,WAAW,GAAGA,CAAC;EAAEV,IAAI;EAAEkE,KAAK;EAAE6B,cAAc;EAAE9F;AAAc,CAAC,KAAK,GAAGD,IAAI,IAAI,EAAE,GAAGkE,KAAK,IAAI,EAAE,GAAG6B,cAAc,IAAI,EAAE,GAAG9F,aAAa,IAAI,EAAE,EAAE;AAClJ,MAAM+F,qBAAqB,GAAI1G,KAAK,IAAK,MAAM,IAAIA,KAAK,IAAI,OAAO,IAAIA,KAAK,IAAI,gBAAgB,IAAIA,KAAK;AAEzG,SAASxB,iBAAiB,EAAEW,iBAAiB,EAAEW,iBAAiB,EAAEP,aAAa,EAAEmH,qBAAqB,EAAE3G,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useIsomorphicLayoutEffect","createContext","useContext","useEffect","useId","useReducer","useRef","getConfig","MISSING_THEME_MESSAGE","ThemeStateContext","allListeners","Map","listenersByParent","HasRenderedOnce","WeakMap","HadTheme","PendingUpdate","states","localStates","shouldForce","forceUpdateThemes","cacheVersion","forEach","cb","getThemeState","id","get","themeNameCache","themeNameCacheVer","themes","rootThemeState","getRootThemeState","incReducer","c","useThemeState","props","isRoot","keys","schemeKeys","cascadeOnChange","disable","parentId","Error","process","env","NODE_ENV","name","componentName","theme","light","propsKey","getPropsKey","ref","current","renderVersion","globalThis","time","forceUpdate","state","getSnapshotImpl","lastSnap","r","unsubscribe","subscribedParentId","cleanupThemeSubscription","shouldSubscribeToTheme","pid","sid","next","Set","add","set","delete","cleanupThemeState","scheduleUpdate","debug","console","warn","hasThemeUpdatingProps","size","needsUpdate","local","parentState","has","_parentName","_propsKey","isSchemeOnlyChange","keysSize","allKeysSchemeOptimized","canSkipForSchemeChange","passThrough","rerender","getNextState","groupCollapsed","info","groupEnd","Object","assign","lastState","pendingUpdate","isNew","getNewThemeName","isSameAsParent","shouldRerender","Boolean","message","trace","scheme","getScheme","isInverse","nextState","parentName","shouldAvoidRerender","queue","visited","length","children","shift","childId","push","validSchemes","dark","split","reset","unstyled","cacheKey","clear","cached","themes2","result2","lastPartIndex","lastIndexOf","name2","slice","result","parentParts","lastName","toLowerCase","pop","subNames","filter","found","nameHasScheme","subName","potentialBases","i","join","outer","base","candidates","potential","max","forceClassName"],"sources":["useThemeState.mjs"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useEffect, useId, useReducer, useRef } from \"react\";\nimport { getConfig } from \"../config\";\nimport { MISSING_THEME_MESSAGE } from \"../constants/constants\";\n\nconst ThemeStateContext = createContext(\"\");\nconst allListeners = /* @__PURE__ */ new Map();\nconst listenersByParent = {};\nconst HasRenderedOnce = /* @__PURE__ */ new WeakMap();\nconst HadTheme = /* @__PURE__ */ new WeakMap();\nconst PendingUpdate = /* @__PURE__ */ new Map();\nconst states = /* @__PURE__ */ new Map();\nconst localStates = /* @__PURE__ */ new Map();\nlet shouldForce = false;\nconst forceUpdateThemes = () => {\n\tcacheVersion++;\n\tshouldForce = true;\n\tallListeners.forEach((cb) => cb());\n\tshouldForce = false;\n};\nconst getThemeState = (id) => states.get(id);\nlet cacheVersion = 0;\nconst themeNameCache = /* @__PURE__ */ new Map();\nlet themeNameCacheVer = -1;\nlet themes = null;\nlet rootThemeState = null;\nconst getRootThemeState = () => rootThemeState;\nconst incReducer = (c) => c + 1;\nconst useThemeState = (props, isRoot = false, keys, schemeKeys, cascadeOnChange = false) => {\n\t\"use no memo\";\n\tconst { disable } = props;\n\tconst parentId = useContext(ThemeStateContext);\n\tif (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === \"development\" ? `${MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}${props.componentName ? ` (component: ${props.componentName})` : \"\"}, but no parent theme context was found (parentId: ${parentId}).` : MISSING_THEME_MESSAGE);\n\tif (disable) return states.get(parentId) || {\n\t\tid: \"\",\n\t\tname: \"light\",\n\t\ttheme: getConfig().themes.light\n\t};\n\tconst id = useId();\n\tconst propsKey = getPropsKey(props);\n\tconst ref = useRef(null);\n\tif (!ref.current) ref.current = {\n\t\tid,\n\t\tparentId,\n\t\tprops,\n\t\tpropsKey,\n\t\tisRoot,\n\t\tkeys,\n\t\tschemeKeys,\n\t\trenderVersion: 0\n\t};\n\telse {\n\t\tref.current.props = props;\n\t\tref.current.propsKey = propsKey;\n\t\tref.current.isRoot = isRoot;\n\t\tref.current.keys = keys;\n\t\tref.current.schemeKeys = schemeKeys;\n\t\tref.current.parentId = parentId;\n\t}\n\tref.current.renderVersion++;\n\tif (process.env.NODE_ENV === \"development\" && globalThis.time) globalThis.time`theme-prep-uses`;\n\tconst [, forceUpdate] = useReducer(incReducer, 0);\n\tconst state = getSnapshotImpl(ref.current);\n\tref.current.lastSnap = state;\n\tuseEffect(() => {\n\t\tconst r = ref.current;\n\t\tconst renderVersion = r.renderVersion;\n\t\tif (r.unsubscribe && r.subscribedParentId !== r.parentId) cleanupThemeSubscription(r);\n\t\tif (shouldSubscribeToTheme(r, cascadeOnChange)) {\n\t\t\tif (!r.unsubscribe) {\n\t\t\t\tconst pid = r.parentId;\n\t\t\t\tconst sid = r.id;\n\t\t\t\tconst cb = () => {\n\t\t\t\t\tconst next = getSnapshotImpl(r);\n\t\t\t\t\tif (next !== r.lastSnap) {\n\t\t\t\t\t\tr.lastSnap = next;\n\t\t\t\t\t\tforceUpdate();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tlistenersByParent[pid] = listenersByParent[pid] || /* @__PURE__ */ new Set();\n\t\t\t\tlistenersByParent[pid].add(sid);\n\t\t\t\tallListeners.set(sid, () => {\n\t\t\t\t\tPendingUpdate.set(sid, shouldForce ? \"force\" : true);\n\t\t\t\t\tcb();\n\t\t\t\t});\n\t\t\t\tr.subscribedParentId = pid;\n\t\t\t\tr.unsubscribe = () => {\n\t\t\t\t\tallListeners.delete(sid);\n\t\t\t\t\tlistenersByParent[pid]?.delete(sid);\n\t\t\t\t\tlocalStates.delete(sid);\n\t\t\t\t\tstates.delete(sid);\n\t\t\t\t\tPendingUpdate.delete(sid);\n\t\t\t\t\tr.unsubscribe = void 0;\n\t\t\t\t\tr.subscribedParentId = void 0;\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (r.unsubscribe) cleanupThemeSubscription(r);\n\t\treturn () => {\n\t\t\tif (r.renderVersion === renderVersion) cleanupThemeState(r);\n\t\t};\n\t});\n\tif (cascadeOnChange) useIsomorphicLayoutEffect(() => {\n\t\tif (!HasRenderedOnce.get(keys)) {\n\t\t\tHasRenderedOnce.set(keys, true);\n\t\t\treturn;\n\t\t}\n\t\tif (!propsKey) {\n\t\t\tif (HadTheme.get(keys)) scheduleUpdate(id);\n\t\t\tHadTheme.set(keys, false);\n\t\t\treturn;\n\t\t}\n\t\tif (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") console.warn(` \\xB7 useTheme(${id}) scheduleUpdate`, propsKey, states.get(id)?.name);\n\t\tscheduleUpdate(id);\n\t\tHadTheme.set(keys, true);\n\t}, [keys, propsKey]);\n\treturn state;\n};\nconst shouldSubscribeToTheme = (r, cascadeOnChange) => r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || !!r.keys.current?.size || !!r.props.needsUpdate?.();\nfunction cleanupThemeSubscription(r) {\n\tr.unsubscribe?.();\n}\nfunction cleanupThemeState(r) {\n\tif (r.unsubscribe) cleanupThemeSubscription(r);\n\telse {\n\t\tlocalStates.delete(r.id);\n\t\tstates.delete(r.id);\n\t\tPendingUpdate.delete(r.id);\n\t}\n}\nconst getSnapshotImpl = (r) => {\n\tconst { id, parentId, props, propsKey, isRoot, keys, schemeKeys } = r;\n\tlet local = localStates.get(id);\n\tconst parentState = states.get(parentId);\n\tif (local && !PendingUpdate.has(id)) {\n\t\tif (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;\n\t}\n\tconst isSchemeOnlyChange = false;\n\tconst keysSize = keys?.current?.size ?? 0;\n\tconst allKeysSchemeOptimized = (schemeKeys?.current?.size ?? 0) === keysSize && keysSize > 0;\n\tconst canSkipForSchemeChange = isSchemeOnlyChange;\n\tconst needsUpdate = props.passThrough ? false : isRoot || props.name === \"light\" || props.name === \"dark\" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : keys?.current?.size ? true : props.needsUpdate?.();\n\tconst [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));\n\tPendingUpdate.delete(id);\n\tif (!local || rerender) {\n\t\tlocal = { ...next };\n\t\tlocalStates.set(id, local);\n\t}\n\tif (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n\t\tconsole.groupCollapsed(` ${id} getSnapshot ${rerender}`, local.name, \">\", next.name);\n\t\tconsole.info({\n\t\t\tprops,\n\t\t\tpropsKey,\n\t\t\tisRoot,\n\t\t\tparentId,\n\t\t\tlocal,\n\t\t\tnext,\n\t\t\tneedsUpdate,\n\t\t\tisSchemeOnlyChange,\n\t\t\tallKeysSchemeOptimized,\n\t\t\tcanSkipForSchemeChange\n\t\t});\n\t\tconsole.groupEnd();\n\t}\n\tif (next !== local) {\n\t\tObject.assign(local, next);\n\t\tlocal.id = id;\n\t}\n\tlocal._parentName = parentState?.name;\n\tlocal._propsKey = propsKey;\n\tstates.set(id, next);\n\treturn local;\n};\nconst getNextState = (lastState, props, propsKey, isRoot = false, id, parentId, needsUpdate, pendingUpdate) => {\n\tconst { debug } = props;\n\tconst parentState = states.get(parentId);\n\tif (props.passThrough) return [false, lastState || parentState || { name: \"\" }];\n\tif (!themes) themes = getConfig().themes;\n\tconst name = !propsKey && (!lastState || !lastState?.isNew) ? null : getNewThemeName(parentState?.name, props, pendingUpdate === \"force\" ? true : !!needsUpdate);\n\tconst isSameAsParent = parentState && (!name || name === parentState.name);\n\tconst shouldRerender = Boolean(pendingUpdate === \"force\" || needsUpdate && (pendingUpdate || lastState?.name !== parentState?.name));\n\tif (process.env.NODE_ENV === \"development\" && debug === \"verbose\") {\n\t\tconst message = ` \\xB7 useTheme(${id}) getNextState => ${name} needsUpdate ${needsUpdate} shouldRerender ${shouldRerender}`;\n\t\tconsole.groupCollapsed(message);\n\t\tconsole.trace({\n\t\t\tname,\n\t\t\tlastState,\n\t\t\tparentState,\n\t\t\tprops,\n\t\t\tpropsKey,\n\t\t\tid,\n\t\t\tisSameAsParent\n\t\t});\n\t\tconsole.groupEnd();\n\t}\n\tif (isSameAsParent) {\n\t\tif (!shouldRerender && lastState && lastState.name === parentState.name) return [false, lastState];\n\t\treturn [shouldRerender, {\n\t\t\t...parentState,\n\t\t\tisNew: false\n\t\t}];\n\t}\n\tif (!name) {\n\t\tconst next = lastState ?? parentState ?? rootThemeState ?? {\n\t\t\tid,\n\t\t\tname: \"light\",\n\t\t\ttheme: getConfig().themes.light\n\t\t};\n\t\tif (shouldRerender) return [true, { ...parentState || lastState || next }];\n\t\treturn [false, next];\n\t}\n\tconst scheme = getScheme(name);\n\tconst isInverse = parentState && scheme !== parentState.scheme;\n\tconst nextState = {\n\t\tid,\n\t\tname,\n\t\ttheme: themes[name],\n\t\tscheme,\n\t\tparentId,\n\t\tparentName: parentState?.name,\n\t\tisInverse,\n\t\tisNew: true\n\t};\n\tif (isRoot) rootThemeState = nextState;\n\tif (pendingUpdate !== \"force\" && lastState && lastState.name === name) return [false, nextState];\n\tconst shouldAvoidRerender = pendingUpdate !== \"force\" && lastState && !needsUpdate && nextState.name === lastState.name;\n\tif (process.env.NODE_ENV === \"development\" && debug === \"verbose\") {\n\t\tconsole.groupCollapsed(` \\xB7 useTheme(${id}) \\u23ED\\uFE0F ${name} shouldAvoidRerender: ${shouldAvoidRerender}`);\n\t\tconsole.info({\n\t\t\tlastState,\n\t\t\tneedsUpdate,\n\t\t\tnextState,\n\t\t\tpendingUpdate\n\t\t});\n\t\tconsole.groupEnd();\n\t}\n\tif (shouldAvoidRerender) return [false, nextState];\n\treturn [true, nextState];\n};\nfunction scheduleUpdate(id) {\n\tconst queue = [id];\n\tconst visited = /* @__PURE__ */ new Set();\n\twhile (queue.length) {\n\t\tconst children = listenersByParent[queue.shift()];\n\t\tif (children) {\n\t\t\tfor (const childId of children) if (!visited.has(childId)) {\n\t\t\t\tvisited.add(childId);\n\t\t\t\tqueue.push(childId);\n\t\t\t}\n\t\t}\n\t}\n\tvisited.forEach((childId) => {\n\t\tallListeners.get(childId)?.();\n\t});\n}\nconst validSchemes = {\n\tlight: \"light\",\n\tdark: \"dark\"\n};\nfunction getScheme(name) {\n\treturn validSchemes[name.split(\"_\")[0]];\n}\nfunction getNewThemeName(parentName = \"\", props, forceUpdate = false) {\n\tconst { name, reset } = props;\n\tconst componentName = props.unstyled ? void 0 : props.componentName;\n\tif (name && reset) throw new Error(process.env.NODE_ENV === \"production\" ? `\\u274C004` : \"Cannot reset and set a new name at the same time.\");\n\tconst cacheKey = `${parentName}|${name || \"\"}|${componentName || \"\"}|${reset ? 1 : 0}|${forceUpdate ? 1 : 0}`;\n\tif (themeNameCacheVer !== cacheVersion) {\n\t\tthemeNameCache.clear();\n\t\tthemeNameCacheVer = cacheVersion;\n\t} else {\n\t\tconst cached = themeNameCache.get(cacheKey);\n\t\tif (cached !== void 0) return cached;\n\t}\n\tconst { themes: themes2 } = getConfig();\n\tif (reset) {\n\t\tif (parentName === \"light\" || parentName === \"dark\") {\n\t\t\tconst result2 = parentName === \"light\" ? \"dark\" : \"light\";\n\t\t\tthemeNameCache.set(cacheKey, result2);\n\t\t\treturn result2;\n\t\t}\n\t\tconst lastPartIndex = parentName.lastIndexOf(\"_\");\n\t\tconst name2 = lastPartIndex <= 0 ? parentName : parentName.slice(lastPartIndex);\n\t\tconst scheme = parentName.slice(0, lastPartIndex);\n\t\tconst result = themes2[name2] ? name2 : scheme;\n\t\tthemeNameCache.set(cacheKey, result);\n\t\treturn result;\n\t}\n\tconst parentParts = parentName.split(\"_\");\n\tconst lastName = parentParts[parentParts.length - 1];\n\tif (lastName && lastName[0].toLowerCase() !== lastName[0]) parentParts.pop();\n\tconst subNames = [\n\t\tname && componentName ? `${name}_${componentName}` : void 0,\n\t\tname,\n\t\tcomponentName\n\t].filter(Boolean);\n\tlet found = null;\n\tif (name) {\n\t\tconst nameHasScheme = getScheme(name);\n\t\tif (nameHasScheme) {\n\t\t\tfor (const subName of subNames) if (subName in themes2) {\n\t\t\t\tfound = subName;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!found && !nameHasScheme) {\n\t\t\tif (getScheme(parentName)) {\n\t\t\t\tconst potentialBases = [];\n\t\t\t\tfor (let i = parentParts.length; i >= 1; i--) potentialBases.push(parentParts.slice(0, i).join(\"_\"));\n\t\t\t\touter: for (const base of potentialBases) {\n\t\t\t\t\tconst candidates = [componentName ? `${base}_${name}_${componentName}` : void 0, `${base}_${name}`].filter(Boolean);\n\t\t\t\t\tfor (const potential of candidates) if (potential in themes2) {\n\t\t\t\t\t\tfound = potential;\n\t\t\t\t\t\tbreak outer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (!found) if (!name && componentName) {\n\t\tconst potential = `${parentParts.join(\"_\")}_${componentName}`;\n\t\tif (potential in themes2) found = potential;\n\t} else {\n\t\tconst max = parentParts.length;\n\t\tfor (let i = 0; i <= max; i++) {\n\t\t\tconst base = (i === 0 ? parentParts : parentParts.slice(0, -i)).join(\"_\");\n\t\t\tfor (const subName of subNames) {\n\t\t\t\tconst potential = base ? `${base}_${subName}` : subName;\n\t\t\t\tif (potential in themes2) {\n\t\t\t\t\tfound = potential;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (found) break;\n\t\t}\n\t}\n\tif (!forceUpdate && found === parentName && !validSchemes[found]) {\n\t\tthemeNameCache.set(cacheKey, null);\n\t\treturn null;\n\t}\n\tthemeNameCache.set(cacheKey, found);\n\treturn found;\n}\nconst getPropsKey = ({ name, reset, forceClassName, componentName }) => `${name || \"\"}${reset || \"\"}${forceClassName || \"\"}${componentName || \"\"}`;\nconst hasThemeUpdatingProps = (props) => \"name\" in props || \"reset\" in props || \"forceClassName\" in props;\n\nexport { ThemeStateContext, forceUpdateThemes, getRootThemeState, getThemeState, hasThemeUpdatingProps, useThemeState };"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,oBAAoB;AAC9D,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,KAAK,EAAEC,UAAU,EAAEC,MAAM,QAAQ,OAAO;AACvF,SAASC,SAAS,QAAQ,eAAW;AACrC,SAASC,qBAAqB,QAAQ,4BAAwB;AAE9D,MAAMC,iBAAiB,GAAGR,aAAa,CAAC,EAAE,CAAC;AAC3C,MAAMS,YAAY,GAAG,eAAgB,IAAIC,GAAG,CAAC,CAAC;AAC9C,MAAMC,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAMC,eAAe,GAAG,eAAgB,IAAIC,OAAO,CAAC,CAAC;AACrD,MAAMC,QAAQ,GAAG,eAAgB,IAAID,OAAO,CAAC,CAAC;AAC9C,MAAME,aAAa,GAAG,eAAgB,IAAIL,GAAG,CAAC,CAAC;AAC/C,MAAMM,MAAM,GAAG,eAAgB,IAAIN,GAAG,CAAC,CAAC;AACxC,MAAMO,WAAW,GAAG,eAAgB,IAAIP,GAAG,CAAC,CAAC;AAC7C,IAAIQ,WAAW,GAAG,KAAK;AACvB,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC/BC,YAAY,EAAE;EACdF,WAAW,GAAG,IAAI;EAClBT,YAAY,CAACY,OAAO,CAAEC,EAAE,IAAKA,EAAE,CAAC,CAAC,CAAC;EAClCJ,WAAW,GAAG,KAAK;AACpB,CAAC;AACD,MAAMK,aAAa,GAAIC,EAAE,IAAKR,MAAM,CAACS,GAAG,CAACD,EAAE,CAAC;AAC5C,IAAIJ,YAAY,GAAG,CAAC;AACpB,MAAMM,cAAc,GAAG,eAAgB,IAAIhB,GAAG,CAAC,CAAC;AAChD,IAAIiB,iBAAiB,GAAG,CAAC,CAAC;AAC1B,IAAIC,MAAM,GA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|
2
|
+
import { createContext, useContext, useEffect, useId, useReducer, useRef } from "react";
|
|
3
3
|
import { getConfig, getSetting } from "../config.native.js";
|
|
4
4
|
import { MISSING_THEME_MESSAGE } from "../constants/constants.native.js";
|
|
5
5
|
var ThemeStateContext = createContext("");
|
|
@@ -33,12 +33,16 @@ var getRootThemeState = function () {
|
|
|
33
33
|
var getThemeBaseName = function (name) {
|
|
34
34
|
return name.replace(/^(light|dark)_/, "");
|
|
35
35
|
};
|
|
36
|
+
var incReducer = function (c) {
|
|
37
|
+
return c + 1;
|
|
38
|
+
};
|
|
36
39
|
var useThemeState = function (props) {
|
|
37
40
|
"use no memo";
|
|
38
41
|
|
|
39
42
|
var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false,
|
|
40
43
|
keys = arguments.length > 2 ? arguments[2] : void 0,
|
|
41
|
-
schemeKeys = arguments.length > 3 ? arguments[3] : void 0
|
|
44
|
+
schemeKeys = arguments.length > 3 ? arguments[3] : void 0,
|
|
45
|
+
cascadeOnChange = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
|
|
42
46
|
var {
|
|
43
47
|
disable
|
|
44
48
|
} = props;
|
|
@@ -52,72 +56,69 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}${props.componentName ? `
|
|
|
52
56
|
theme: getConfig().themes.light
|
|
53
57
|
};
|
|
54
58
|
var id = useId();
|
|
55
|
-
var subscribe = useCallback(function (cb) {
|
|
56
|
-
listenersByParent[parentId] = listenersByParent[parentId] || /* @__PURE__ */new Set();
|
|
57
|
-
listenersByParent[parentId].add(id);
|
|
58
|
-
allListeners.set(id, function () {
|
|
59
|
-
PendingUpdate.set(id, shouldForce ? "force" : true);
|
|
60
|
-
cb();
|
|
61
|
-
});
|
|
62
|
-
return function () {
|
|
63
|
-
allListeners.delete(id);
|
|
64
|
-
listenersByParent[parentId].delete(id);
|
|
65
|
-
localStates.delete(id);
|
|
66
|
-
states.delete(id);
|
|
67
|
-
PendingUpdate.delete(id);
|
|
68
|
-
};
|
|
69
|
-
}, [id, parentId]);
|
|
70
59
|
var propsKey = getPropsKey(props);
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
localStates.set(id, local);
|
|
92
|
-
}
|
|
93
|
-
if (process.env.NODE_ENV === "development" && props.debug === "verbose") {
|
|
94
|
-
console.groupCollapsed(` ${id} getSnapshot ${rerender}`, local.name, ">", next.name);
|
|
95
|
-
console.info({
|
|
96
|
-
props,
|
|
97
|
-
propsKey,
|
|
98
|
-
isRoot,
|
|
99
|
-
parentId,
|
|
100
|
-
local,
|
|
101
|
-
next,
|
|
102
|
-
needsUpdate,
|
|
103
|
-
isSchemeOnlyChange,
|
|
104
|
-
allKeysSchemeOptimized,
|
|
105
|
-
canSkipForSchemeChange
|
|
106
|
-
});
|
|
107
|
-
console.groupEnd();
|
|
108
|
-
}
|
|
109
|
-
if (next !== local) {
|
|
110
|
-
Object.assign(local, next);
|
|
111
|
-
local.id = id;
|
|
112
|
-
}
|
|
113
|
-
local._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;
|
|
114
|
-
local._propsKey = propsKey;
|
|
115
|
-
states.set(id, next);
|
|
116
|
-
return local;
|
|
117
|
-
};
|
|
60
|
+
var ref = useRef(null);
|
|
61
|
+
if (!ref.current) ref.current = {
|
|
62
|
+
id,
|
|
63
|
+
parentId,
|
|
64
|
+
props,
|
|
65
|
+
propsKey,
|
|
66
|
+
isRoot,
|
|
67
|
+
keys,
|
|
68
|
+
schemeKeys,
|
|
69
|
+
renderVersion: 0
|
|
70
|
+
};else {
|
|
71
|
+
ref.current.props = props;
|
|
72
|
+
ref.current.propsKey = propsKey;
|
|
73
|
+
ref.current.isRoot = isRoot;
|
|
74
|
+
ref.current.keys = keys;
|
|
75
|
+
ref.current.schemeKeys = schemeKeys;
|
|
76
|
+
ref.current.parentId = parentId;
|
|
77
|
+
}
|
|
78
|
+
ref.current.renderVersion++;
|
|
118
79
|
if (process.env.NODE_ENV === "development" && globalThis.time) globalThis.time`theme-prep-uses`;
|
|
119
|
-
var
|
|
120
|
-
|
|
80
|
+
var [, forceUpdate] = useReducer(incReducer, 0);
|
|
81
|
+
var state = getSnapshotImpl(ref.current);
|
|
82
|
+
ref.current.lastSnap = state;
|
|
83
|
+
useEffect(function () {
|
|
84
|
+
var r = ref.current;
|
|
85
|
+
var renderVersion = r.renderVersion;
|
|
86
|
+
if (r.unsubscribe && r.subscribedParentId !== r.parentId) cleanupThemeSubscription(r);
|
|
87
|
+
if (shouldSubscribeToTheme(r, cascadeOnChange)) {
|
|
88
|
+
if (!r.unsubscribe) {
|
|
89
|
+
var pid = r.parentId;
|
|
90
|
+
var sid = r.id;
|
|
91
|
+
var cb = function () {
|
|
92
|
+
var next = getSnapshotImpl(r);
|
|
93
|
+
if (next !== r.lastSnap) {
|
|
94
|
+
r.lastSnap = next;
|
|
95
|
+
forceUpdate();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
listenersByParent[pid] = listenersByParent[pid] || /* @__PURE__ */new Set();
|
|
99
|
+
listenersByParent[pid].add(sid);
|
|
100
|
+
allListeners.set(sid, function () {
|
|
101
|
+
PendingUpdate.set(sid, shouldForce ? "force" : true);
|
|
102
|
+
cb();
|
|
103
|
+
});
|
|
104
|
+
r.subscribedParentId = pid;
|
|
105
|
+
r.unsubscribe = function () {
|
|
106
|
+
var _listenersByParent_pid;
|
|
107
|
+
allListeners.delete(sid);
|
|
108
|
+
(_listenersByParent_pid = listenersByParent[pid]) === null || _listenersByParent_pid === void 0 || _listenersByParent_pid.delete(sid);
|
|
109
|
+
localStates.delete(sid);
|
|
110
|
+
states.delete(sid);
|
|
111
|
+
PendingUpdate.delete(sid);
|
|
112
|
+
r.unsubscribe = void 0;
|
|
113
|
+
r.subscribedParentId = void 0;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
} else if (r.unsubscribe) cleanupThemeSubscription(r);
|
|
117
|
+
return function () {
|
|
118
|
+
if (r.renderVersion === renderVersion) cleanupThemeState(r);
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
if (cascadeOnChange) useIsomorphicLayoutEffect(function () {
|
|
121
122
|
if (!HasRenderedOnce.get(keys)) {
|
|
122
123
|
HasRenderedOnce.set(keys, true);
|
|
123
124
|
return;
|
|
@@ -136,6 +137,77 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}${props.componentName ? `
|
|
|
136
137
|
}, [keys, propsKey]);
|
|
137
138
|
return state;
|
|
138
139
|
};
|
|
140
|
+
var shouldSubscribeToTheme = function (r, cascadeOnChange) {
|
|
141
|
+
var _r_keys_current, _r_props_needsUpdate, _r_props;
|
|
142
|
+
return r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || !!((_r_keys_current = r.keys.current) === null || _r_keys_current === void 0 ? void 0 : _r_keys_current.size) || !!((_r_props_needsUpdate = (_r_props = r.props).needsUpdate) === null || _r_props_needsUpdate === void 0 ? void 0 : _r_props_needsUpdate.call(_r_props));
|
|
143
|
+
};
|
|
144
|
+
function cleanupThemeSubscription(r) {
|
|
145
|
+
var _r_unsubscribe;
|
|
146
|
+
(_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);
|
|
147
|
+
}
|
|
148
|
+
function cleanupThemeState(r) {
|
|
149
|
+
if (r.unsubscribe) cleanupThemeSubscription(r);else {
|
|
150
|
+
localStates.delete(r.id);
|
|
151
|
+
states.delete(r.id);
|
|
152
|
+
PendingUpdate.delete(r.id);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
var getSnapshotImpl = function (r) {
|
|
156
|
+
var _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;
|
|
157
|
+
var {
|
|
158
|
+
id,
|
|
159
|
+
parentId,
|
|
160
|
+
props,
|
|
161
|
+
propsKey,
|
|
162
|
+
isRoot,
|
|
163
|
+
keys,
|
|
164
|
+
schemeKeys
|
|
165
|
+
} = r;
|
|
166
|
+
var local = localStates.get(id);
|
|
167
|
+
var parentState = states.get(parentId);
|
|
168
|
+
if (local && !PendingUpdate.has(id)) {
|
|
169
|
+
if (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;
|
|
170
|
+
}
|
|
171
|
+
var isSchemeOnlyChange = supportsDynamicColorIOS && getSetting("fastSchemeChange") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);
|
|
172
|
+
var _keys_current_size;
|
|
173
|
+
var keysSize = (_keys_current_size = keys === null || keys === void 0 ? void 0 : (_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) !== null && _keys_current_size !== void 0 ? _keys_current_size : 0;
|
|
174
|
+
var _schemeKeys_current_size;
|
|
175
|
+
var allKeysSchemeOptimized = ((_schemeKeys_current_size = schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) !== null && _schemeKeys_current_size !== void 0 ? _schemeKeys_current_size : 0) === keysSize && keysSize > 0;
|
|
176
|
+
var canSkipForSchemeChange = isSchemeOnlyChange && allKeysSchemeOptimized;
|
|
177
|
+
var needsUpdate = props.passThrough ? false : isRoot || props.name === "light" || props.name === "dark" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);
|
|
178
|
+
var [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));
|
|
179
|
+
PendingUpdate.delete(id);
|
|
180
|
+
if (!local || rerender) {
|
|
181
|
+
local = {
|
|
182
|
+
...next
|
|
183
|
+
};
|
|
184
|
+
localStates.set(id, local);
|
|
185
|
+
}
|
|
186
|
+
if (process.env.NODE_ENV === "development" && props.debug === "verbose") {
|
|
187
|
+
console.groupCollapsed(` ${id} getSnapshot ${rerender}`, local.name, ">", next.name);
|
|
188
|
+
console.info({
|
|
189
|
+
props,
|
|
190
|
+
propsKey,
|
|
191
|
+
isRoot,
|
|
192
|
+
parentId,
|
|
193
|
+
local,
|
|
194
|
+
next,
|
|
195
|
+
needsUpdate,
|
|
196
|
+
isSchemeOnlyChange,
|
|
197
|
+
allKeysSchemeOptimized,
|
|
198
|
+
canSkipForSchemeChange
|
|
199
|
+
});
|
|
200
|
+
console.groupEnd();
|
|
201
|
+
}
|
|
202
|
+
if (next !== local) {
|
|
203
|
+
Object.assign(local, next);
|
|
204
|
+
local.id = id;
|
|
205
|
+
}
|
|
206
|
+
local._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;
|
|
207
|
+
local._propsKey = propsKey;
|
|
208
|
+
states.set(id, next);
|
|
209
|
+
return local;
|
|
210
|
+
};
|
|
139
211
|
var getNextState = function (lastState, props, propsKey) {
|
|
140
212
|
var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false,
|
|
141
213
|
id = arguments.length > 4 ? arguments[4] : void 0,
|
|
@@ -165,12 +237,14 @@ var getNextState = function (lastState, props, propsKey) {
|
|
|
165
237
|
}];
|
|
166
238
|
}
|
|
167
239
|
if (!name) {
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
240
|
+
var _ref, _ref1;
|
|
241
|
+
var next = (_ref1 = (_ref = lastState !== null && lastState !== void 0 ? lastState : parentState) !== null && _ref !== void 0 ? _ref : rootThemeState) !== null && _ref1 !== void 0 ? _ref1 : {
|
|
242
|
+
id,
|
|
243
|
+
name: "light",
|
|
244
|
+
theme: getConfig().themes.light
|
|
245
|
+
};
|
|
172
246
|
if (shouldRerender) return [true, {
|
|
173
|
-
...(parentState || lastState)
|
|
247
|
+
...(parentState || lastState || next)
|
|
174
248
|
}];
|
|
175
249
|
return [false, next];
|
|
176
250
|
}
|