tamagui 1.124.10 → 1.124.11
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 +54 -54
package/dist/native.js
CHANGED
|
@@ -7321,16 +7321,34 @@ var require_useThemeState_native = __commonJS({
|
|
|
7321
7321
|
}
|
|
7322
7322
|
});
|
|
7323
7323
|
module2.exports = __toCommonJS2(useThemeState_exports);
|
|
7324
|
-
var import_constants4 = require_index_native6(), 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(),
|
|
7324
|
+
var import_constants4 = require_index_native6(), 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();
|
|
7325
|
+
process.env.NODE_ENV === "development" && (globalThis.getTamaguiThemes = function() {
|
|
7326
|
+
function buildTree(id) {
|
|
7327
|
+
var node = states.get(id);
|
|
7328
|
+
if (!node) return null;
|
|
7329
|
+
var children = Array.from(states.values()).filter(function(child) {
|
|
7330
|
+
return (child == null ? void 0 : child.parentId) === id;
|
|
7331
|
+
}).map(function(child) {
|
|
7332
|
+
return buildTree(child.id);
|
|
7333
|
+
}).filter(Boolean);
|
|
7334
|
+
return {
|
|
7335
|
+
...node,
|
|
7336
|
+
children
|
|
7337
|
+
};
|
|
7338
|
+
}
|
|
7339
|
+
rootThemeState && console.info(buildTree(rootThemeState.id));
|
|
7340
|
+
});
|
|
7341
|
+
var shouldForce = !1, forceUpdateThemes2 = function() {
|
|
7325
7342
|
cacheVersion++, shouldForce = !0, allListeners.forEach(function(cb) {
|
|
7326
7343
|
return cb();
|
|
7327
7344
|
});
|
|
7328
7345
|
}, getThemeState = function(id) {
|
|
7329
7346
|
return states.get(id);
|
|
7330
|
-
},
|
|
7347
|
+
}, cacheVersion = 0, themes = null, rootThemeState = null, getRootThemeState = function() {
|
|
7331
7348
|
return rootThemeState;
|
|
7332
7349
|
}, useThemeState = function(props) {
|
|
7333
7350
|
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);
|
|
7351
|
+
if (!parentId && !isRoot) throw new Error("No parent?");
|
|
7334
7352
|
if (disable) return states.get(parentId) || {
|
|
7335
7353
|
id: "",
|
|
7336
7354
|
name: "light",
|
|
@@ -7342,16 +7360,24 @@ var require_useThemeState_native = __commonJS({
|
|
|
7342
7360
|
return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, function() {
|
|
7343
7361
|
pendingUpdate.set(id, shouldForce ? "force" : !0), cb();
|
|
7344
7362
|
}), function() {
|
|
7345
|
-
allListeners.delete(id), listenersByParent[parentId].delete(id);
|
|
7363
|
+
allListeners.delete(id), listenersByParent[parentId].delete(id), localStates.delete(id), states.delete(id), pendingUpdate.delete(id);
|
|
7346
7364
|
};
|
|
7347
7365
|
}, [
|
|
7348
7366
|
id,
|
|
7349
7367
|
parentId
|
|
7350
7368
|
]), propsKey = getPropsKey(props), getSnapshot = function() {
|
|
7351
|
-
var _keys_current, _props_needsUpdate,
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7369
|
+
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));
|
|
7370
|
+
return pendingUpdate.delete(id), (!local || rerender) && (local = {
|
|
7371
|
+
...next
|
|
7372
|
+
}, 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({
|
|
7373
|
+
props,
|
|
7374
|
+
propsKey,
|
|
7375
|
+
isRoot,
|
|
7376
|
+
parentId,
|
|
7377
|
+
local,
|
|
7378
|
+
next,
|
|
7379
|
+
needsUpdate
|
|
7380
|
+
}), console.groupEnd()), Object.assign(local, next), local.id = id, states.set(id, next), local;
|
|
7355
7381
|
};
|
|
7356
7382
|
process.env.NODE_ENV === "development" && globalThis.time && globalThis.time`theme-prep-uses`;
|
|
7357
7383
|
var state = (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
@@ -7370,31 +7396,39 @@ var require_useThemeState_native = __commonJS({
|
|
|
7370
7396
|
}, [
|
|
7371
7397
|
keys,
|
|
7372
7398
|
propsKey
|
|
7373
|
-
]), state
|
|
7374
|
-
|
|
7375
|
-
isNew: !0
|
|
7376
|
-
} : state;
|
|
7377
|
-
}, getSnapshotFrom = function(lastState, props, propsKey) {
|
|
7399
|
+
]), state;
|
|
7400
|
+
}, getNextState = function(lastState, props, propsKey) {
|
|
7378
7401
|
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);
|
|
7379
7402
|
themes || (themes = (0, import_config.getConfig)().themes);
|
|
7380
|
-
var name = !propsKey &&
|
|
7403
|
+
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)));
|
|
7381
7404
|
if (process.env.NODE_ENV === "development" && debug && debug !== "profile") {
|
|
7382
|
-
var message = ` \xB7 useTheme(${id})
|
|
7405
|
+
var message = ` \xB7 useTheme(${id}) => ${name} needsUpdate ${needsUpdate} shouldRerender ${shouldRerender}`;
|
|
7383
7406
|
console.info(message);
|
|
7384
7407
|
}
|
|
7385
|
-
if (
|
|
7408
|
+
if (isSameAsParent) return [
|
|
7409
|
+
shouldRerender,
|
|
7410
|
+
{
|
|
7411
|
+
...parentState,
|
|
7412
|
+
isNew: !1
|
|
7413
|
+
}
|
|
7414
|
+
];
|
|
7386
7415
|
if (!name) {
|
|
7387
7416
|
var next = lastState ?? parentState;
|
|
7388
7417
|
if (!next) throw new Error("No theme and no parent?");
|
|
7389
|
-
if (
|
|
7418
|
+
if (shouldRerender) {
|
|
7390
7419
|
var updated = {
|
|
7391
7420
|
...parentState || lastState
|
|
7392
7421
|
};
|
|
7393
|
-
return
|
|
7422
|
+
return [
|
|
7423
|
+
!0,
|
|
7424
|
+
updated
|
|
7425
|
+
];
|
|
7394
7426
|
}
|
|
7395
|
-
return
|
|
7427
|
+
return [
|
|
7428
|
+
!1,
|
|
7429
|
+
next
|
|
7430
|
+
];
|
|
7396
7431
|
}
|
|
7397
|
-
if (pendingUpdate2 !== "force" && lastState && lastState.name === name) return lastState;
|
|
7398
7432
|
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 = {
|
|
7399
7433
|
id,
|
|
7400
7434
|
name,
|
|
@@ -7403,16 +7437,26 @@ var require_useThemeState_native = __commonJS({
|
|
|
7403
7437
|
parentId,
|
|
7404
7438
|
parentName: parentState == null ? void 0 : parentState.name,
|
|
7405
7439
|
inverses,
|
|
7406
|
-
isInverse
|
|
7440
|
+
isInverse,
|
|
7441
|
+
isNew: !0
|
|
7407
7442
|
};
|
|
7408
|
-
isRoot && (rootThemeState = nextState)
|
|
7443
|
+
if (isRoot && (rootThemeState = nextState), pendingUpdate2 !== "force" && lastState && lastState.name === name) return [
|
|
7444
|
+
!1,
|
|
7445
|
+
nextState
|
|
7446
|
+
];
|
|
7409
7447
|
var shouldAvoidRerender = pendingUpdate2 !== "force" && lastState && !needsUpdate && nextState.name === lastState.name;
|
|
7410
7448
|
return process.env.NODE_ENV === "development" && debug && debug !== "profile" && (console.groupCollapsed(` \xB7 useTheme(${id}) \u23ED\uFE0F ${name} shouldAvoidRerender: ${shouldAvoidRerender}`), console.info({
|
|
7411
7449
|
lastState,
|
|
7412
7450
|
needsUpdate,
|
|
7413
7451
|
nextState,
|
|
7414
7452
|
pendingUpdate: pendingUpdate2
|
|
7415
|
-
}), console.groupEnd()), shouldAvoidRerender ?
|
|
7453
|
+
}), console.groupEnd()), shouldAvoidRerender ? [
|
|
7454
|
+
!1,
|
|
7455
|
+
nextState
|
|
7456
|
+
] : [
|
|
7457
|
+
!0,
|
|
7458
|
+
nextState
|
|
7459
|
+
];
|
|
7416
7460
|
};
|
|
7417
7461
|
function scheduleUpdate(id) {
|
|
7418
7462
|
for (var queue = [
|
|
@@ -7849,7 +7893,11 @@ var require_Theme_native = __commonJS({
|
|
|
7849
7893
|
Theme2.avoidForwardRef = !0;
|
|
7850
7894
|
function getThemedChildren(themeState, children, props) {
|
|
7851
7895
|
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);
|
|
7852
|
-
if (
|
|
7896
|
+
if (process.env.NODE_ENV === "development" && props.debug && (children = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ThemeDebug.ThemeDebug, {
|
|
7897
|
+
themeState,
|
|
7898
|
+
themeProps: props,
|
|
7899
|
+
children
|
|
7900
|
+
})), !shouldRenderChildrenWithTheme) return children;
|
|
7853
7901
|
children = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_useThemeState.ThemeStateContext.Provider, {
|
|
7854
7902
|
value: themeState.id,
|
|
7855
7903
|
children
|
|
@@ -7867,20 +7915,19 @@ var require_Theme_native = __commonJS({
|
|
|
7867
7915
|
})) : child;
|
|
7868
7916
|
});
|
|
7869
7917
|
}
|
|
7870
|
-
if (process.env.NODE_ENV === "development" && props.debug &&
|
|
7918
|
+
if (process.env.NODE_ENV === "development" && props.debug && console.warn(" getThemedChildren", {
|
|
7871
7919
|
requiresExtraWrapper,
|
|
7872
7920
|
forceClassName,
|
|
7873
7921
|
themeState,
|
|
7874
7922
|
state,
|
|
7875
7923
|
...getThemeClassNameAndStyle(themeState, props, isRoot)
|
|
7876
|
-
}),
|
|
7877
|
-
themeState,
|
|
7878
|
-
themeProps: props,
|
|
7879
|
-
children
|
|
7880
|
-
})), forceClassName === !1) return children;
|
|
7924
|
+
}), forceClassName === !1) return children;
|
|
7881
7925
|
if (import_constants4.isWeb) {
|
|
7882
7926
|
var { className, style } = getThemeClassNameAndStyle(themeState, props, isRoot);
|
|
7883
7927
|
if (children = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {
|
|
7928
|
+
...process.env.NODE_ENV === "development" && {
|
|
7929
|
+
"data-theme-id": themeState.id
|
|
7930
|
+
},
|
|
7884
7931
|
className: `${className} _dsp_contents is_Theme`,
|
|
7885
7932
|
style,
|
|
7886
7933
|
children
|