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.
@@ -6937,16 +6937,17 @@ var require_useThemeState_native = __commonJS({
6937
6937
  }
6938
6938
  });
6939
6939
  module2.exports = __toCommonJS2(useThemeState_exports);
6940
- 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(), shouldForce = !1, forceUpdateThemes2 = function() {
6940
+ 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(), shouldForce = !1, forceUpdateThemes2 = function() {
6941
6941
  cacheVersion++, shouldForce = !0, allListeners.forEach(function(cb) {
6942
6942
  return cb();
6943
6943
  });
6944
6944
  }, getThemeState = function(id) {
6945
6945
  return states.get(id);
6946
- }, cache = /* @__PURE__ */ new Map(), cacheVersion = 0, themes = null, rootThemeState = null, getRootThemeState = function() {
6946
+ }, cacheVersion = 0, themes = null, rootThemeState = null, getRootThemeState = function() {
6947
6947
  return rootThemeState;
6948
6948
  }, useThemeState = function(props) {
6949
6949
  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);
6950
+ if (!parentId && !isRoot) throw new Error("No parent?");
6950
6951
  if (disable) return states.get(parentId) || {
6951
6952
  id: "",
6952
6953
  name: "light",
@@ -6958,16 +6959,16 @@ var require_useThemeState_native = __commonJS({
6958
6959
  return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, function() {
6959
6960
  pendingUpdate.set(id, shouldForce ? "force" : !0), cb();
6960
6961
  }), function() {
6961
- allListeners.delete(id), listenersByParent[parentId].delete(id);
6962
+ allListeners.delete(id), listenersByParent[parentId].delete(id), localStates.delete(id), states.delete(id), pendingUpdate.delete(id);
6962
6963
  };
6963
6964
  }, [
6964
6965
  id,
6965
6966
  parentId
6966
6967
  ]), propsKey = getPropsKey(props), getSnapshot = function() {
6967
- var _keys_current, _props_needsUpdate, last = states.get(id), needsUpdate = props.name === "light" || props.name === "dark" ? !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, parentState = states.get(parentId), cacheKey = `${cacheVersion}${id}${propsKey}${(parentState == null ? void 0 : parentState.name) || ""}${isRoot}`;
6968
- if (!needsUpdate && cache.has(cacheKey)) return cache.get(cacheKey);
6969
- var next = getSnapshotFrom(last, props, propsKey, isRoot, id, parentId, needsUpdate, pendingUpdate.get(id));
6970
- return last !== next && (pendingUpdate.delete(id), states.set(id, next), cache.set(id, next)), next;
6968
+ 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));
6969
+ return pendingUpdate.delete(id), (!local || rerender) && (local = {
6970
+ ...next
6971
+ }, localStates.set(id, local)), Object.assign(local, next), local.id = id, states.set(id, next), local;
6971
6972
  }, state = (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
6972
6973
  return (0, import_constants4.useIsomorphicLayoutEffect)(function() {
6973
6974
  if (!hasRenderedOnce.get(keys)) {
@@ -6982,29 +6983,37 @@ var require_useThemeState_native = __commonJS({
6982
6983
  }, [
6983
6984
  keys,
6984
6985
  propsKey
6985
- ]), state.id === id ? {
6986
- ...state,
6987
- isNew: !0
6988
- } : state;
6989
- }, getSnapshotFrom = function(lastState, props, propsKey) {
6986
+ ]), state;
6987
+ }, getNextState = function(lastState, props, propsKey) {
6990
6988
  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);
6991
6989
  themes || (themes = (0, import_config.getConfig)().themes);
6992
- var name = !propsKey && pendingUpdate2 !== "force" ? null : getNewThemeName(parentState == null ? void 0 : parentState.name, props, pendingUpdate2 === "force" ? !0 : !!needsUpdate), isSameAsParent = !!(!name && propsKey);
6990
+ 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)));
6993
6991
  if (0)
6994
6992
  var message;
6995
- if (parentState && isSameAsParent) return parentState;
6993
+ if (isSameAsParent) return [
6994
+ shouldRerender,
6995
+ {
6996
+ ...parentState,
6997
+ isNew: !1
6998
+ }
6999
+ ];
6996
7000
  if (!name) {
6997
7001
  var next = lastState ?? parentState;
6998
7002
  if (!next) throw new Error("No theme and no parent?");
6999
- if (needsUpdate && pendingUpdate2) {
7003
+ if (shouldRerender) {
7000
7004
  var updated = {
7001
7005
  ...parentState || lastState
7002
7006
  };
7003
- return updated;
7007
+ return [
7008
+ !0,
7009
+ updated
7010
+ ];
7004
7011
  }
7005
- return next;
7012
+ return [
7013
+ !1,
7014
+ next
7015
+ ];
7006
7016
  }
7007
- if (pendingUpdate2 !== "force" && lastState && lastState.name === name) return lastState;
7008
7017
  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 = {
7009
7018
  id,
7010
7019
  name,
@@ -7013,11 +7022,21 @@ var require_useThemeState_native = __commonJS({
7013
7022
  parentId,
7014
7023
  parentName: parentState == null ? void 0 : parentState.name,
7015
7024
  inverses,
7016
- isInverse
7025
+ isInverse,
7026
+ isNew: !0
7017
7027
  };
7018
- isRoot && (rootThemeState = nextState);
7028
+ if (isRoot && (rootThemeState = nextState), pendingUpdate2 !== "force" && lastState && lastState.name === name) return [
7029
+ !1,
7030
+ nextState
7031
+ ];
7019
7032
  var shouldAvoidRerender = pendingUpdate2 !== "force" && lastState && !needsUpdate && nextState.name === lastState.name;
7020
- return shouldAvoidRerender ? (Object.assign(lastState, nextState), lastState) : nextState;
7033
+ return shouldAvoidRerender ? [
7034
+ !1,
7035
+ nextState
7036
+ ] : [
7037
+ !0,
7038
+ nextState
7039
+ ];
7021
7040
  };
7022
7041
  function scheduleUpdate(id) {
7023
7042
  for (var queue = [