@tamagui/core 1.124.10 → 1.124.12
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/dist/native.js +76 -29
- package/dist/native.js.map +2 -2
- package/dist/test.native.js +40 -21
- package/dist/test.native.js.map +2 -2
- package/package.json +7 -7
package/dist/native.js
CHANGED
|
@@ -6222,16 +6222,34 @@ var require_useThemeState_native = __commonJS({
|
|
|
6222
6222
|
}
|
|
6223
6223
|
});
|
|
6224
6224
|
module2.exports = __toCommonJS2(useThemeState_exports);
|
|
6225
|
-
var import_constants2 = require_index_native2(), import_react3 = require("react"), import_config = require_config_native(), ThemeStateContext = (0, import_react3.createContext)(""), keysToId = /* @__PURE__ */ new WeakMap(), allListeners = /* @__PURE__ */ new Map(), listenersByParent = {}, hasRenderedOnce = /* @__PURE__ */ new WeakMap(), pendingUpdate = /* @__PURE__ */ new Map(), states = /* @__PURE__ */ new Map(),
|
|
6225
|
+
var import_constants2 = require_index_native2(), import_react3 = require("react"), import_config = require_config_native(), ThemeStateContext = (0, import_react3.createContext)(""), keysToId = /* @__PURE__ */ new WeakMap(), allListeners = /* @__PURE__ */ new Map(), listenersByParent = {}, hasRenderedOnce = /* @__PURE__ */ new WeakMap(), pendingUpdate = /* @__PURE__ */ new Map(), states = /* @__PURE__ */ new Map(), localStates = /* @__PURE__ */ new Map();
|
|
6226
|
+
process.env.NODE_ENV === "development" && (globalThis.getTamaguiThemes = function() {
|
|
6227
|
+
function buildTree(id) {
|
|
6228
|
+
var node = states.get(id);
|
|
6229
|
+
if (!node) return null;
|
|
6230
|
+
var children = Array.from(states.values()).filter(function(child) {
|
|
6231
|
+
return (child == null ? void 0 : child.parentId) === id;
|
|
6232
|
+
}).map(function(child) {
|
|
6233
|
+
return buildTree(child.id);
|
|
6234
|
+
}).filter(Boolean);
|
|
6235
|
+
return {
|
|
6236
|
+
...node,
|
|
6237
|
+
children
|
|
6238
|
+
};
|
|
6239
|
+
}
|
|
6240
|
+
rootThemeState && console.info(buildTree(rootThemeState.id));
|
|
6241
|
+
});
|
|
6242
|
+
var shouldForce = !1, forceUpdateThemes2 = function() {
|
|
6226
6243
|
cacheVersion++, shouldForce = !0, allListeners.forEach(function(cb) {
|
|
6227
6244
|
return cb();
|
|
6228
6245
|
});
|
|
6229
6246
|
}, getThemeState = function(id) {
|
|
6230
6247
|
return states.get(id);
|
|
6231
|
-
},
|
|
6248
|
+
}, cacheVersion = 0, themes = null, rootThemeState = null, getRootThemeState = function() {
|
|
6232
6249
|
return rootThemeState;
|
|
6233
6250
|
}, useThemeState = function(props) {
|
|
6234
6251
|
var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, keys = arguments.length > 2 ? arguments[2] : void 0, { disable } = props, parentId = (0, import_react3.useContext)(ThemeStateContext);
|
|
6252
|
+
if (!parentId && !isRoot) throw new Error("No parent?");
|
|
6235
6253
|
if (disable) return states.get(parentId) || {
|
|
6236
6254
|
id: "",
|
|
6237
6255
|
name: "light",
|
|
@@ -6243,16 +6261,24 @@ var require_useThemeState_native = __commonJS({
|
|
|
6243
6261
|
return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, function() {
|
|
6244
6262
|
pendingUpdate.set(id, shouldForce ? "force" : !0), cb();
|
|
6245
6263
|
}), function() {
|
|
6246
|
-
allListeners.delete(id), listenersByParent[parentId].delete(id);
|
|
6264
|
+
allListeners.delete(id), listenersByParent[parentId].delete(id), localStates.delete(id), states.delete(id), pendingUpdate.delete(id);
|
|
6247
6265
|
};
|
|
6248
6266
|
}, [
|
|
6249
6267
|
id,
|
|
6250
6268
|
parentId
|
|
6251
6269
|
]), propsKey = getPropsKey(props), getSnapshot = function() {
|
|
6252
|
-
var _keys_current, _props_needsUpdate,
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6270
|
+
var _keys_current, _props_needsUpdate, local = localStates.get(id), needsUpdate = isRoot || props.name === "light" || props.name === "dark" || props.name === null ? !0 : hasRenderedOnce.get(keys) ? !(keys == null || (_keys_current = keys.current) === null || _keys_current === void 0) && _keys_current.size ? !0 : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props) : !0, [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, pendingUpdate.get(id));
|
|
6271
|
+
return pendingUpdate.delete(id), (!local || rerender) && (local = {
|
|
6272
|
+
...next
|
|
6273
|
+
}, localStates.set(id, local)), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && (console.groupCollapsed(` ${id} \u{1FA84} ${rerender}`, local.name, ">", next.name), console.info({
|
|
6274
|
+
props,
|
|
6275
|
+
propsKey,
|
|
6276
|
+
isRoot,
|
|
6277
|
+
parentId,
|
|
6278
|
+
local,
|
|
6279
|
+
next,
|
|
6280
|
+
needsUpdate
|
|
6281
|
+
}), console.groupEnd()), Object.assign(local, next), local.id = id, states.set(id, next), local;
|
|
6256
6282
|
};
|
|
6257
6283
|
process.env.NODE_ENV === "development" && globalThis.time && globalThis.time`theme-prep-uses`;
|
|
6258
6284
|
var state = (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
@@ -6271,31 +6297,39 @@ var require_useThemeState_native = __commonJS({
|
|
|
6271
6297
|
}, [
|
|
6272
6298
|
keys,
|
|
6273
6299
|
propsKey
|
|
6274
|
-
]), state
|
|
6275
|
-
|
|
6276
|
-
isNew: !0
|
|
6277
|
-
} : state;
|
|
6278
|
-
}, getSnapshotFrom = function(lastState, props, propsKey) {
|
|
6300
|
+
]), state;
|
|
6301
|
+
}, getNextState = function(lastState, props, propsKey) {
|
|
6279
6302
|
var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, id = arguments.length > 4 ? arguments[4] : void 0, parentId = arguments.length > 5 ? arguments[5] : void 0, needsUpdate = arguments.length > 6 ? arguments[6] : void 0, pendingUpdate2 = arguments.length > 7 ? arguments[7] : void 0, { debug } = props, parentState = states.get(parentId);
|
|
6280
6303
|
themes || (themes = (0, import_config.getConfig)().themes);
|
|
6281
|
-
var name = !propsKey &&
|
|
6304
|
+
var name = !propsKey && (!lastState || !(lastState != null && lastState.isNew)) ? null : getNewThemeName(parentState == null ? void 0 : parentState.name, props, pendingUpdate2 === "force" ? !0 : !!needsUpdate), isSameAsParent = parentState && (!name || name === parentState.name), shouldRerender = !!(needsUpdate && (pendingUpdate2 || (lastState == null ? void 0 : lastState.name) !== (parentState == null ? void 0 : parentState.name)));
|
|
6282
6305
|
if (process.env.NODE_ENV === "development" && debug && debug !== "profile") {
|
|
6283
|
-
var message = ` \xB7 useTheme(${id})
|
|
6306
|
+
var message = ` \xB7 useTheme(${id}) => ${name} needsUpdate ${needsUpdate} shouldRerender ${shouldRerender}`;
|
|
6284
6307
|
console.info(message);
|
|
6285
6308
|
}
|
|
6286
|
-
if (
|
|
6309
|
+
if (isSameAsParent) return [
|
|
6310
|
+
shouldRerender,
|
|
6311
|
+
{
|
|
6312
|
+
...parentState,
|
|
6313
|
+
isNew: !1
|
|
6314
|
+
}
|
|
6315
|
+
];
|
|
6287
6316
|
if (!name) {
|
|
6288
6317
|
var next = lastState ?? parentState;
|
|
6289
6318
|
if (!next) throw new Error("No theme and no parent?");
|
|
6290
|
-
if (
|
|
6319
|
+
if (shouldRerender) {
|
|
6291
6320
|
var updated = {
|
|
6292
6321
|
...parentState || lastState
|
|
6293
6322
|
};
|
|
6294
|
-
return
|
|
6323
|
+
return [
|
|
6324
|
+
!0,
|
|
6325
|
+
updated
|
|
6326
|
+
];
|
|
6295
6327
|
}
|
|
6296
|
-
return
|
|
6328
|
+
return [
|
|
6329
|
+
!1,
|
|
6330
|
+
next
|
|
6331
|
+
];
|
|
6297
6332
|
}
|
|
6298
|
-
if (pendingUpdate2 !== "force" && lastState && lastState.name === name) return lastState;
|
|
6299
6333
|
var scheme = getScheme(name), _parentState_inverses, parentInverses = (_parentState_inverses = parentState == null ? void 0 : parentState.inverses) !== null && _parentState_inverses !== void 0 ? _parentState_inverses : 0, isInverse = parentState && scheme !== parentState.scheme, inverses = parentInverses + (isInverse ? 1 : 0), nextState = {
|
|
6300
6334
|
id,
|
|
6301
6335
|
name,
|
|
@@ -6304,16 +6338,26 @@ var require_useThemeState_native = __commonJS({
|
|
|
6304
6338
|
parentId,
|
|
6305
6339
|
parentName: parentState == null ? void 0 : parentState.name,
|
|
6306
6340
|
inverses,
|
|
6307
|
-
isInverse
|
|
6341
|
+
isInverse,
|
|
6342
|
+
isNew: !0
|
|
6308
6343
|
};
|
|
6309
|
-
isRoot && (rootThemeState = nextState)
|
|
6344
|
+
if (isRoot && (rootThemeState = nextState), pendingUpdate2 !== "force" && lastState && lastState.name === name) return [
|
|
6345
|
+
!1,
|
|
6346
|
+
nextState
|
|
6347
|
+
];
|
|
6310
6348
|
var shouldAvoidRerender = pendingUpdate2 !== "force" && lastState && !needsUpdate && nextState.name === lastState.name;
|
|
6311
6349
|
return process.env.NODE_ENV === "development" && debug && debug !== "profile" && (console.groupCollapsed(` \xB7 useTheme(${id}) \u23ED\uFE0F ${name} shouldAvoidRerender: ${shouldAvoidRerender}`), console.info({
|
|
6312
6350
|
lastState,
|
|
6313
6351
|
needsUpdate,
|
|
6314
6352
|
nextState,
|
|
6315
6353
|
pendingUpdate: pendingUpdate2
|
|
6316
|
-
}), console.groupEnd()), shouldAvoidRerender ?
|
|
6354
|
+
}), console.groupEnd()), shouldAvoidRerender ? [
|
|
6355
|
+
!1,
|
|
6356
|
+
nextState
|
|
6357
|
+
] : [
|
|
6358
|
+
!0,
|
|
6359
|
+
nextState
|
|
6360
|
+
];
|
|
6317
6361
|
};
|
|
6318
6362
|
function scheduleUpdate(id) {
|
|
6319
6363
|
for (var queue = [
|
|
@@ -6750,7 +6794,11 @@ var require_Theme_native = __commonJS({
|
|
|
6750
6794
|
Theme.avoidForwardRef = !0;
|
|
6751
6795
|
function getThemedChildren(themeState, children, props) {
|
|
6752
6796
|
var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, stateRef = arguments.length > 4 ? arguments[4] : void 0, { shallow, forceClassName } = props, state = stateRef.current, hasEverThemed = state.hasEverThemed, shouldRenderChildrenWithTheme = hasEverThemed || themeState.isNew || isRoot || (0, import_useThemeState.hasThemeUpdatingProps)(props);
|
|
6753
|
-
if (
|
|
6797
|
+
if (process.env.NODE_ENV === "development" && props.debug && (children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThemeDebug.ThemeDebug, {
|
|
6798
|
+
themeState,
|
|
6799
|
+
themeProps: props,
|
|
6800
|
+
children
|
|
6801
|
+
})), !shouldRenderChildrenWithTheme) return children;
|
|
6754
6802
|
children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_useThemeState.ThemeStateContext.Provider, {
|
|
6755
6803
|
value: themeState.id,
|
|
6756
6804
|
children
|
|
@@ -6768,20 +6816,19 @@ var require_Theme_native = __commonJS({
|
|
|
6768
6816
|
})) : child;
|
|
6769
6817
|
});
|
|
6770
6818
|
}
|
|
6771
|
-
if (process.env.NODE_ENV === "development" && props.debug &&
|
|
6819
|
+
if (process.env.NODE_ENV === "development" && props.debug && console.warn(" getThemedChildren", {
|
|
6772
6820
|
requiresExtraWrapper,
|
|
6773
6821
|
forceClassName,
|
|
6774
6822
|
themeState,
|
|
6775
6823
|
state,
|
|
6776
6824
|
...getThemeClassNameAndStyle(themeState, props, isRoot)
|
|
6777
|
-
}),
|
|
6778
|
-
themeState,
|
|
6779
|
-
themeProps: props,
|
|
6780
|
-
children
|
|
6781
|
-
})), forceClassName === !1) return children;
|
|
6825
|
+
}), forceClassName === !1) return children;
|
|
6782
6826
|
if (import_constants2.isWeb) {
|
|
6783
6827
|
var { className, style } = getThemeClassNameAndStyle(themeState, props, isRoot);
|
|
6784
6828
|
if (children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
6829
|
+
...process.env.NODE_ENV === "development" && {
|
|
6830
|
+
"data-theme-id": themeState.id
|
|
6831
|
+
},
|
|
6785
6832
|
className: `${className} _dsp_contents is_Theme`,
|
|
6786
6833
|
style,
|
|
6787
6834
|
children
|