tamagui 1.124.4 → 1.124.5

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.
@@ -2012,13 +2012,11 @@ var require_useControllableState_native = __commonJS({
2012
2012
  };
2013
2013
  function useControllableState(param) {
2014
2014
  var { prop, defaultProp, onChange, strategy = "prop-wins", preventUpdate, transition } = param, [state, setState] = React4.useState(prop ?? defaultProp), previous = React4.useRef(state), propWins = strategy === "prop-wins" && prop !== void 0, value = propWins ? prop : state, onChangeCb = (0, import_use_event.useEvent)(onChange || idFn), transitionFn = transition ? import_start_transition.startTransition : emptyCallbackFn;
2015
- React4.useEffect(function() {
2016
- prop !== void 0 && (previous.current = prop, transitionFn(function() {
2017
- setState(prop);
2018
- }));
2019
- }, [
2020
- prop
2021
- ]), React4.useEffect(function() {
2015
+ prop !== state && transitionFn(function() {
2016
+ setState(function(prev) {
2017
+ if (prev !== prop) return previous.current = prop, prop;
2018
+ });
2019
+ }), React4.useEffect(function() {
2022
2020
  propWins || state !== previous.current && (previous.current = state, onChangeCb(state));
2023
2021
  }, [
2024
2022
  onChangeCb,
@@ -6924,20 +6922,23 @@ var require_useThemeState_native = __commonJS({
6924
6922
  hasThemeUpdatingProps: function() {
6925
6923
  return hasThemeUpdatingProps;
6926
6924
  },
6925
+ keysToId: function() {
6926
+ return keysToId;
6927
+ },
6927
6928
  useThemeState: function() {
6928
6929
  return useThemeState;
6929
6930
  }
6930
6931
  });
6931
6932
  module2.exports = __toCommonJS2(useThemeState_exports);
6932
- var import_constants4 = require_index_native6(), import_react3 = require("react"), import_config = require_config_native(), ThemeStateContext = (0, import_react3.createContext)(""), allListeners = /* @__PURE__ */ new Map(), listenersByParent = {}, states = /* @__PURE__ */ new Map(), forceUpdateThemes2 = function() {
6933
- allListeners.forEach(function(cb) {
6933
+ 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() {
6934
+ cacheVersion++, shouldForce = !0, allListeners.forEach(function(cb) {
6934
6935
  return cb();
6935
6936
  });
6936
6937
  }, getThemeState = function(id) {
6937
6938
  return states.get(id);
6938
- }, rootThemeState = null, getRootThemeState = function() {
6939
+ }, cache = /* @__PURE__ */ new Map(), cacheVersion = 0, themes = null, rootThemeState = null, getRootThemeState = function() {
6939
6940
  return rootThemeState;
6940
- }, HasRenderedOnce = /* @__PURE__ */ new WeakMap(), useThemeState = function(props) {
6941
+ }, useThemeState = function(props) {
6941
6942
  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);
6942
6943
  if (disable) return states.get(parentId) || {
6943
6944
  id: "",
@@ -6947,22 +6948,26 @@ var require_useThemeState_native = __commonJS({
6947
6948
  };
6948
6949
  var id = (0, import_react3.useId)(), subscribe = (0, import_react3.useCallback)(function(cb) {
6949
6950
  var _listenersByParent, _parentId;
6950
- return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, cb), function() {
6951
+ return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, function() {
6952
+ pendingUpdate.set(id, shouldForce ? "force" : !0), cb();
6953
+ }), function() {
6951
6954
  allListeners.delete(id), listenersByParent[parentId].delete(id);
6952
6955
  };
6953
6956
  }, [
6954
6957
  id,
6955
- parentId,
6956
- keys
6958
+ parentId
6957
6959
  ]), propsKey = getPropsKey(props), getSnapshot = function() {
6958
- return getSnapshotFrom(props, propsKey, isRoot, id, parentId, keys);
6960
+ 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}`;
6961
+ if (!needsUpdate && cache.has(cacheKey)) return cache.get(cacheKey);
6962
+ var next = getSnapshotFrom(last, props, propsKey, isRoot, id, parentId, needsUpdate, pendingUpdate.get(id));
6963
+ return last !== next && (pendingUpdate.delete(id), states.set(id, next), cache.set(id, next)), next;
6959
6964
  }, state = (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
6960
6965
  return (0, import_constants4.useIsomorphicLayoutEffect)(function() {
6966
+ if (!hasRenderedOnce.get(keys)) {
6967
+ hasRenderedOnce.set(keys, !0);
6968
+ return;
6969
+ }
6961
6970
  if (propsKey) {
6962
- if (!HasRenderedOnce.has(keys)) {
6963
- HasRenderedOnce.set(keys, !0);
6964
- return;
6965
- }
6966
6971
  if (0)
6967
6972
  var _states_get;
6968
6973
  scheduleUpdate(id);
@@ -6974,16 +6979,24 @@ var require_useThemeState_native = __commonJS({
6974
6979
  ...state,
6975
6980
  isNew: !0
6976
6981
  } : state;
6977
- }, themes = null, getSnapshotFrom = function(props, propsKey) {
6978
- var isRoot = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, id = arguments.length > 3 ? arguments[3] : void 0, parentId = arguments.length > 4 ? arguments[4] : void 0, keys = arguments.length > 5 ? arguments[5] : void 0, _keys_current, _props_needsUpdate, needsUpdate = (keys == null || (_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) || ((_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props)), parentState = states.get(parentId);
6982
+ }, getSnapshotFrom = function(lastState, props, propsKey) {
6983
+ 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, parentState = states.get(parentId);
6979
6984
  themes || (themes = (0, import_config.getConfig)().themes);
6980
- var lastState = states.get(id), name = propsKey ? getNewThemeName(parentState == null ? void 0 : parentState.name, props, !!needsUpdate) : null;
6985
+ var name = !propsKey && pendingUpdate2 !== "force" ? null : getNewThemeName(parentState == null ? void 0 : parentState.name, props, pendingUpdate2 === "force" ? !0 : !!needsUpdate), isSameAsParent = !!(!name && propsKey);
6981
6986
  if (0)
6982
6987
  var message;
6983
- var isSameAsParent = !name && propsKey;
6984
6988
  if (parentState && isSameAsParent) return parentState;
6985
- if (!name) return lastState && !needsUpdate ? lastState : (states.set(id, parentState), parentState);
6986
- if (lastState && lastState.name === name) return lastState;
6989
+ if (!name) {
6990
+ var next = lastState ?? parentState;
6991
+ if (needsUpdate && pendingUpdate2) {
6992
+ var updated = {
6993
+ ...parentState || lastState
6994
+ };
6995
+ return updated;
6996
+ }
6997
+ return next;
6998
+ }
6999
+ if (pendingUpdate2 !== "force" && lastState && lastState.name === name) return lastState;
6987
7000
  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 = {
6988
7001
  id,
6989
7002
  name,
@@ -6994,7 +7007,7 @@ var require_useThemeState_native = __commonJS({
6994
7007
  inverses,
6995
7008
  isInverse
6996
7009
  };
6997
- return states.set(id, nextState), isRoot && (rootThemeState = nextState), nextState;
7010
+ return isRoot && (rootThemeState = nextState), pendingUpdate2 !== "force" && lastState && !needsUpdate ? (Object.assign(lastState, nextState), lastState) : nextState;
6998
7011
  };
6999
7012
  function scheduleUpdate(id) {
7000
7013
  for (var queue = [
@@ -7032,7 +7045,7 @@ var require_useThemeState_native = __commonJS({
7032
7045
  return validSchemes[name.split("_")[0]];
7033
7046
  }
7034
7047
  function getNewThemeName() {
7035
- var parentName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", { name, reset, componentName, inverse } = arguments.length > 1 ? arguments[1] : void 0, forceUpdate = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
7048
+ var parentName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", { name, reset, componentName, inverse, debug } = arguments.length > 1 ? arguments[1] : void 0, forceUpdate = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
7036
7049
  if (name && reset) throw new Error("Cannot reset and set a new name at the same time.");
7037
7050
  if (reset) {
7038
7051
  if (!parentName) throw new Error("\u203C\uFE0F");
@@ -7066,7 +7079,8 @@ var require_useThemeState_native = __commonJS({
7066
7079
  }
7067
7080
  if (found) break;
7068
7081
  }
7069
- if (found && inverse) {
7082
+ if (inverse) {
7083
+ found || (found = parentName);
7070
7084
  var scheme = found.split("_")[0];
7071
7085
  found = found.replace(new RegExp(`^${scheme}`), scheme === "light" ? "dark" : "light");
7072
7086
  }
@@ -7177,36 +7191,38 @@ var require_getThemeProxied_native = __commonJS({
7177
7191
  }
7178
7192
  });
7179
7193
  module2.exports = __toCommonJS2(getThemeProxied_exports);
7180
- var import_constants4 = require_index_native6(), import_config = require_config_native(), import_createVariable = require_createVariable_native(), import_doesRootSchemeMatchSystem = require_doesRootSchemeMatchSystem_native(), cache = /* @__PURE__ */ new Map(), curKeys, curProps, emptyObject = {};
7181
- function getThemeProxied(_props, state, _keys) {
7182
- var theme = state == null ? void 0 : state.theme;
7183
- if (!theme) return emptyObject;
7184
- if (curKeys = _keys, curProps = _props, cache.has(theme)) {
7185
- var proxied = cache.get(theme);
7194
+ var import_constants4 = require_index_native6(), import_config = require_config_native(), import_createVariable = require_createVariable_native(), import_doesRootSchemeMatchSystem = require_doesRootSchemeMatchSystem_native(), import_useThemeState = require_useThemeState_native(), cache = /* @__PURE__ */ new Map(), curKeys, curProps, curState, emptyObject = {};
7195
+ function getThemeProxied(_props, _state, _keys) {
7196
+ if (!(_state != null && _state.theme)) return emptyObject;
7197
+ if (curKeys = _keys, curProps = _props, curState = _state, cache.has(curState.theme)) {
7198
+ var proxied = cache.get(curState.theme);
7186
7199
  return proxied;
7187
7200
  }
7188
- var { name, scheme } = state, config = (0, import_config.getConfig)();
7201
+ var config = (0, import_config.getConfig)();
7189
7202
  function track(key) {
7190
- curKeys && (curKeys.current || (curKeys.current = /* @__PURE__ */ new Set()), curKeys.current.add(key));
7203
+ if (curKeys && (curKeys.current || (curKeys.current = /* @__PURE__ */ new Set()), curKeys.current.add(key), !1))
7204
+ var _globalThis_states, realId;
7191
7205
  }
7192
- var proxied1 = Object.fromEntries(Object.entries(theme).flatMap(function(param) {
7206
+ var proxied1 = Object.fromEntries(Object.entries(_state.theme).flatMap(function(param) {
7193
7207
  var [key, value] = param, proxied2 = {
7194
7208
  ...value,
7195
7209
  get val() {
7196
7210
  return globalThis.tamaguiAvoidTracking || track(key), value.val;
7197
7211
  },
7198
7212
  get(platform2) {
7199
- var outVal = (0, import_createVariable.getVariable)(value), shouldOptimize = scheme && platform2 !== "web" && import_constants4.isIos && !curProps.deopt && (0, import_config.getSetting)("fastSchemeChange") && state.inverses === 0 && (0, import_doesRootSchemeMatchSystem.doesRootSchemeMatchSystem)();
7200
- if (shouldOptimize) {
7201
- var _config_themes_name, _config_themes_oppositeName, oppositeScheme = scheme === "dark" ? "light" : "dark", oppositeName = name.replace(scheme, oppositeScheme), color = (0, import_createVariable.getVariable)((_config_themes_name = config.themes[name]) === null || _config_themes_name === void 0 ? void 0 : _config_themes_name[key]), oppositeColor = (0, import_createVariable.getVariable)((_config_themes_oppositeName = config.themes[oppositeName]) === null || _config_themes_oppositeName === void 0 ? void 0 : _config_themes_oppositeName[key]), dynamicVal = {
7202
- dynamic: {
7203
- [scheme]: color,
7204
- [oppositeScheme]: oppositeColor
7205
- }
7206
- };
7207
- return dynamicVal;
7213
+ if (curState) {
7214
+ var outVal = (0, import_createVariable.getVariable)(value), { name, scheme, inverses } = curState, shouldOptimize = scheme && platform2 !== "web" && import_constants4.isIos && !curProps.deopt && (0, import_config.getSetting)("fastSchemeChange") && inverses === 0 && (0, import_doesRootSchemeMatchSystem.doesRootSchemeMatchSystem)();
7215
+ if (shouldOptimize) {
7216
+ var _config_themes_name, _config_themes_oppositeName, oppositeScheme = scheme === "dark" ? "light" : "dark", oppositeName = name.replace(scheme, oppositeScheme), color = (0, import_createVariable.getVariable)((_config_themes_name = config.themes[name]) === null || _config_themes_name === void 0 ? void 0 : _config_themes_name[key]), oppositeColor = (0, import_createVariable.getVariable)((_config_themes_oppositeName = config.themes[oppositeName]) === null || _config_themes_oppositeName === void 0 ? void 0 : _config_themes_oppositeName[key]), dynamicVal = {
7217
+ dynamic: {
7218
+ [scheme]: color,
7219
+ [oppositeScheme]: oppositeColor
7220
+ }
7221
+ };
7222
+ return dynamicVal;
7223
+ }
7224
+ return track(key), outVal;
7208
7225
  }
7209
- return track(key), outVal;
7210
7226
  }
7211
7227
  };
7212
7228
  return [
@@ -7220,7 +7236,7 @@ var require_getThemeProxied_native = __commonJS({
7220
7236
  ]
7221
7237
  ];
7222
7238
  }));
7223
- return cache.set(theme, proxied1), proxied1;
7239
+ return cache.set(_state.theme, proxied1), proxied1;
7224
7240
  }
7225
7241
  }
7226
7242
  });
@@ -29305,8 +29321,9 @@ var require_mutateTheme_native = __commonJS({
29305
29321
  return (0, import_start_transition.startTransition)(function() {
29306
29322
  for (var themeName in allThemesProxied) {
29307
29323
  var theme2 = allThemesProxied[themeName];
29308
- updateThemeConfig(themeName, theme2), updateThemeStates(themeName, theme2);
29324
+ updateThemeConfig(themeName, theme2);
29309
29325
  }
29326
+ updateThemeStates();
29310
29327
  }), {
29311
29328
  themes: allThemesProxied,
29312
29329
  themesRaw: allThemesRaw,
@@ -29330,14 +29347,14 @@ var require_mutateTheme_native = __commonJS({
29330
29347
  };
29331
29348
  return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
29332
29349
  [themeName]: theme1
29333
- })), updateThemeConfig(themeName, themeProxied), updateThemeStates(themeName, themeProxied)), response;
29350
+ })), updateThemeConfig(themeName, themeProxied), updateThemeStates()), response;
29334
29351
  }
29335
29352
  }
29336
29353
  function updateThemeConfig(themeName, theme) {
29337
29354
  var config = (0, import_web.getConfig)();
29338
29355
  config.themes[themeName] = theme, (0, import_web.updateConfig)("themes", config.themes);
29339
29356
  }
29340
- function updateThemeStates(themeName, theme) {
29357
+ function updateThemeStates() {
29341
29358
  (0, import_web.forceUpdateThemes)();
29342
29359
  }
29343
29360
  function insertThemeCSS(themes) {