@tamagui/core 1.125.9 → 1.125.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 CHANGED
@@ -5929,7 +5929,8 @@ var require_createShallowSetState_native = __commonJS({
5929
5929
  var import_react3 = require("react"), callImmediate = function(cb) {
5930
5930
  return cb();
5931
5931
  };
5932
- function createShallowSetState(setter, onlyAllow, transition, debug, callback) {
5932
+ function createShallowSetState(setter, onlyAllow, transition, debugIn, callback) {
5933
+ var debug = !0;
5933
5934
  return (0, import_react3.useCallback)(function(next) {
5934
5935
  var wrap = transition ? import_react3.startTransition : callImmediate;
5935
5936
  wrap(function() {
@@ -5942,7 +5943,8 @@ var require_createShallowSetState_native = __commonJS({
5942
5943
  setter,
5943
5944
  onlyAllow ? onlyAllow.join("") : "",
5944
5945
  transition,
5945
- debug
5946
+ debug,
5947
+ callback
5946
5948
  ]);
5947
5949
  }
5948
5950
  function mergeIfNotShallowEqual(prev, next, onlyAllow, debug) {
@@ -6093,32 +6095,12 @@ var require_useThemeState_native = __commonJS({
6093
6095
  hasThemeUpdatingProps: function() {
6094
6096
  return hasThemeUpdatingProps;
6095
6097
  },
6096
- keysToId: function() {
6097
- return keysToId;
6098
- },
6099
6098
  useThemeState: function() {
6100
6099
  return useThemeState;
6101
6100
  }
6102
6101
  });
6103
6102
  module2.exports = __toCommonJS2(useThemeState_exports);
6104
- 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();
6105
- process.env.NODE_ENV === "development" && (globalThis.getTamaguiThemes = function() {
6106
- function buildTree(id) {
6107
- var node = states.get(id);
6108
- if (!node) return null;
6109
- var children = Array.from(states.values()).filter(function(child) {
6110
- return (child == null ? void 0 : child.parentId) === id;
6111
- }).map(function(child) {
6112
- return buildTree(child.id);
6113
- }).filter(Boolean);
6114
- return {
6115
- ...node,
6116
- children
6117
- };
6118
- }
6119
- rootThemeState && console.info(buildTree(rootThemeState.id));
6120
- });
6121
- var shouldForce = !1, forceUpdateThemes2 = function() {
6103
+ var import_constants2 = require_index_native2(), import_react3 = require("react"), import_config = require_config_native(), ThemeStateContext = (0, import_react3.createContext)(""), allListeners = /* @__PURE__ */ new Map(), listenersByParent = {}, HasRenderedOnce = /* @__PURE__ */ new WeakMap(), HadTheme = /* @__PURE__ */ new WeakMap(), PendingUpdate = /* @__PURE__ */ new Map(), states = /* @__PURE__ */ new Map(), localStates = /* @__PURE__ */ new Map(), shouldForce = !1, forceUpdateThemes2 = function() {
6122
6104
  cacheVersion++, shouldForce = !0, allListeners.forEach(function(cb) {
6123
6105
  return cb();
6124
6106
  });
@@ -6138,16 +6120,16 @@ var require_useThemeState_native = __commonJS({
6138
6120
  var id = (0, import_react3.useId)(), subscribe = (0, import_react3.useCallback)(function(cb) {
6139
6121
  var _listenersByParent, _parentId;
6140
6122
  return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, function() {
6141
- pendingUpdate.set(id, shouldForce ? "force" : !0), cb();
6123
+ PendingUpdate.set(id, shouldForce ? "force" : !0), cb();
6142
6124
  }), function() {
6143
- allListeners.delete(id), listenersByParent[parentId].delete(id), localStates.delete(id), states.delete(id), pendingUpdate.delete(id);
6125
+ allListeners.delete(id), listenersByParent[parentId].delete(id), localStates.delete(id), states.delete(id), PendingUpdate.delete(id);
6144
6126
  };
6145
6127
  }, [
6146
6128
  id,
6147
6129
  parentId
6148
6130
  ]), propsKey = getPropsKey(props), getSnapshot = function() {
6149
- 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));
6150
- return pendingUpdate.delete(id), (!local || rerender) && (local = {
6131
+ 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));
6132
+ return PendingUpdate.delete(id), (!local || rerender) && (local = {
6151
6133
  ...next
6152
6134
  }, 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({
6153
6135
  props,
@@ -6162,25 +6144,27 @@ var require_useThemeState_native = __commonJS({
6162
6144
  process.env.NODE_ENV === "development" && globalThis.time && globalThis.time`theme-prep-uses`;
6163
6145
  var state = (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
6164
6146
  return (0, import_constants2.useIsomorphicLayoutEffect)(function() {
6165
- if (!hasRenderedOnce.get(keys)) {
6166
- hasRenderedOnce.set(keys, !0);
6147
+ if (!HasRenderedOnce.get(keys)) {
6148
+ HasRenderedOnce.set(keys, !0);
6167
6149
  return;
6168
6150
  }
6169
- if (propsKey) {
6170
- if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
6171
- var _states_get;
6172
- console.warn(` \xB7 useTheme(${id}) scheduleUpdate`, propsKey, (_states_get = states.get(id)) === null || _states_get === void 0 ? void 0 : _states_get.name);
6173
- }
6174
- scheduleUpdate(id);
6151
+ if (!propsKey) {
6152
+ HadTheme.get(keys) && scheduleUpdate(id), HadTheme.set(keys, !1);
6153
+ return;
6175
6154
  }
6155
+ if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
6156
+ var _states_get;
6157
+ console.warn(` \xB7 useTheme(${id}) scheduleUpdate`, propsKey, (_states_get = states.get(id)) === null || _states_get === void 0 ? void 0 : _states_get.name);
6158
+ }
6159
+ scheduleUpdate(id), HadTheme.set(keys, !0);
6176
6160
  }, [
6177
6161
  keys,
6178
6162
  propsKey
6179
6163
  ]), state;
6180
6164
  }, getNextState = function(lastState, props, propsKey) {
6181
- 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);
6165
+ 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, pendingUpdate = arguments.length > 7 ? arguments[7] : void 0, { debug } = props, parentState = states.get(parentId);
6182
6166
  themes || (themes = (0, import_config.getConfig)().themes);
6183
- 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)));
6167
+ var name = !propsKey && (!lastState || !(lastState != null && lastState.isNew)) ? null : getNewThemeName(parentState == null ? void 0 : parentState.name, props, pendingUpdate === "force" ? !0 : !!needsUpdate), isSameAsParent = parentState && (!name || name === parentState.name), shouldRerender = !!(needsUpdate && (pendingUpdate || (lastState == null ? void 0 : lastState.name) !== (parentState == null ? void 0 : parentState.name)));
6184
6168
  if (process.env.NODE_ENV === "development" && debug && debug !== "profile") {
6185
6169
  var message = ` \xB7 useTheme(${id}) => ${name} needsUpdate ${needsUpdate} shouldRerender ${shouldRerender}`;
6186
6170
  console.info(message);
@@ -6220,16 +6204,16 @@ var require_useThemeState_native = __commonJS({
6220
6204
  isInverse,
6221
6205
  isNew: !0
6222
6206
  };
6223
- if (isRoot && (rootThemeState = nextState), pendingUpdate2 !== "force" && lastState && lastState.name === name) return [
6207
+ if (isRoot && (rootThemeState = nextState), pendingUpdate !== "force" && lastState && lastState.name === name) return [
6224
6208
  !1,
6225
6209
  nextState
6226
6210
  ];
6227
- var shouldAvoidRerender = pendingUpdate2 !== "force" && lastState && !needsUpdate && nextState.name === lastState.name;
6211
+ var shouldAvoidRerender = pendingUpdate !== "force" && lastState && !needsUpdate && nextState.name === lastState.name;
6228
6212
  return process.env.NODE_ENV === "development" && debug && debug !== "profile" && (console.groupCollapsed(` \xB7 useTheme(${id}) \u23ED\uFE0F ${name} shouldAvoidRerender: ${shouldAvoidRerender}`), console.info({
6229
6213
  lastState,
6230
6214
  needsUpdate,
6231
6215
  nextState,
6232
- pendingUpdate: pendingUpdate2
6216
+ pendingUpdate
6233
6217
  }), console.groupEnd()), shouldAvoidRerender ? [
6234
6218
  !1,
6235
6219
  nextState
@@ -6420,7 +6404,7 @@ var require_getThemeProxied_native = __commonJS({
6420
6404
  }
6421
6405
  });
6422
6406
  module2.exports = __toCommonJS2(getThemeProxied_exports);
6423
- var import_constants2 = require_index_native2(), import_config = require_config_native(), import_createVariable = require_createVariable_native(), import_doesRootSchemeMatchSystem = require_doesRootSchemeMatchSystem_native(), import_useThemeState = require_useThemeState_native(), cache2 = /* @__PURE__ */ new Map(), curKeys, curProps, curState, emptyObject = {};
6407
+ var import_constants2 = require_index_native2(), import_config = require_config_native(), import_createVariable = require_createVariable_native(), import_doesRootSchemeMatchSystem = require_doesRootSchemeMatchSystem_native(), cache2 = /* @__PURE__ */ new Map(), curKeys, curProps, curState, emptyObject = {};
6424
6408
  function getThemeProxied(_props, _state, _keys) {
6425
6409
  if (!(_state != null && _state.theme)) return emptyObject;
6426
6410
  if (curKeys = _keys, curProps = _props, curState = _state, cache2.has(curState.theme)) {
@@ -6429,10 +6413,7 @@ var require_getThemeProxied_native = __commonJS({
6429
6413
  }
6430
6414
  var config = (0, import_config.getConfig)();
6431
6415
  function track(key) {
6432
- if (curKeys && (curKeys.current || (curKeys.current = /* @__PURE__ */ new Set()), curKeys.current.add(key), process.env.NODE_ENV === "development" && curProps.debug)) {
6433
- var _globalThis_states, realId = import_useThemeState.keysToId.get(curKeys);
6434
- console.info(` \u{1F3A8} useTheme(${realId}) tracking new key: ${key}`, curKeys, (_globalThis_states = globalThis.states) === null || _globalThis_states === void 0 ? void 0 : _globalThis_states.get(realId + 1));
6435
- }
6416
+ curKeys && (curKeys.current || (curKeys.current = /* @__PURE__ */ new Set()), curKeys.current.add(key), process.env.NODE_ENV === "development" && curProps.debug && console.info(` \u{1F3A8} useTheme() tracking new key: ${key}`, curKeys));
6436
6417
  }
6437
6418
  var proxied1 = Object.fromEntries(Object.entries(_state.theme).flatMap(function(param) {
6438
6419
  var [key, value] = param, proxied2 = {
@@ -7017,10 +6998,8 @@ var require_useComponentState_native = __commonJS({
7017
6998
  import_constants2.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (state.disabled = disabled, disabled && Object.assign(state, import_defaultComponentState.defaultComponentStateMounted), setState({
7018
6999
  ...state
7019
7000
  }));
7020
- var groupName = props.group, setStateWrapper;
7021
- if (groupName) {
7022
- var groupContextState = groups.state;
7023
- setStateWrapper = function(state2) {
7001
+ var groupName = props.group, groupContextState = groups == null ? void 0 : groups.state, setStateWrapper = (0, import_react3.useMemo)(function() {
7002
+ if (groupContextState && groupName) return function(state2) {
7024
7003
  curStateRef.group.emit(groupName, {
7025
7004
  pseudo: state2
7026
7005
  });
@@ -7030,8 +7009,11 @@ var require_useComponentState_native = __commonJS({
7030
7009
  };
7031
7010
  groupContextState[groupName] = next;
7032
7011
  };
7033
- }
7034
- var setStateShallow = (0, import_createShallowSetState.createShallowSetState)(setState, disabled ? [
7012
+ }, [
7013
+ groupContextState,
7014
+ curStateRef,
7015
+ groupName
7016
+ ]), setStateShallow = (0, import_createShallowSetState.createShallowSetState)(setState, disabled ? [
7035
7017
  "disabled"
7036
7018
  ] : void 0, !1, props.debug, setStateWrapper);
7037
7019
  if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
@@ -8641,6 +8623,7 @@ var require_createTamagui_native = __commonJS({
8641
8623
  var import_constants2 = require_index_native2(), import_config = require_config_native(), import_createVariables = require_createVariables_native(), import_getThemeCSSRules = require_getThemeCSSRules_native(), import_insertStyleRule = require_insertStyleRule_native(), import_proxyThemeToParents = require_proxyThemeToParents_native(), import_registerCSSVariable = require_registerCSSVariable_native(), import_themes = require_themes_native(), import_useMedia = require_useMedia_native(), import_insertFont = require_insertFont_native(), import_Tamagui = require_Tamagui_native(), createdConfigs = /* @__PURE__ */ new WeakMap();
8642
8624
  function createTamagui2(configIn) {
8643
8625
  var _configIn_settings;
8626
+ if (process.env.NODE_ENV === "test" && globalThis.__tamaguiConfig) return console.warn("Warning: You somehow have duplicate Tamagui dependencies, this can cause issues. Tamagui is working around this by loading a previously loaded config in test mode. "), globalThis.__tamaguiConfig;
8644
8627
  if (createdConfigs.has(configIn)) return configIn;
8645
8628
  var tokensParsed = {}, tokens = (0, import_createVariables.createVariables)(configIn.tokens || {});
8646
8629
  if (configIn.tokens) {
@@ -8788,7 +8771,7 @@ ${JSON.stringify(variable, null, 2)}`);
8788
8771
  specificTokens,
8789
8772
  defaultFontToken
8790
8773
  };
8791
- if ((0, import_config.setConfig)(config), (0, import_useMedia.configureMedia)(config), createdConfigs.set(config, !0), import_config.configListeners.size && (import_config.configListeners.forEach(function(cb) {
8774
+ if ((0, import_config.setConfig)(config), (0, import_useMedia.configureMedia)(config), createdConfigs.set(config, !0), process.env.NODE_ENV === "test" && (globalThis.__tamaguiConfig = config), import_config.configListeners.size && (import_config.configListeners.forEach(function(cb) {
8792
8775
  return cb(config);
8793
8776
  }), import_config.configListeners.clear()), process.env.NODE_ENV === "development") {
8794
8777
  var _process_env_DEBUG;