@tamagui/core 1.124.3 → 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.
package/dist/native.js CHANGED
@@ -4777,12 +4777,10 @@ var require_webPropsToSkip_native = __commonJS({
4777
4777
  contain: 1,
4778
4778
  boxSizing: 1,
4779
4779
  touchAction: 1,
4780
- boxShadow: 1,
4781
4780
  outlineStyle: 1,
4782
4781
  outlineOffset: 1,
4783
4782
  outlineWidth: 1,
4784
4783
  outlineColor: 1,
4785
- filter: 1,
4786
4784
  backdropFilter: 1,
4787
4785
  backgroundImage: 1,
4788
4786
  mixBlendMode: 1,
@@ -6211,20 +6209,23 @@ var require_useThemeState_native = __commonJS({
6211
6209
  hasThemeUpdatingProps: function() {
6212
6210
  return hasThemeUpdatingProps;
6213
6211
  },
6212
+ keysToId: function() {
6213
+ return keysToId;
6214
+ },
6214
6215
  useThemeState: function() {
6215
6216
  return useThemeState;
6216
6217
  }
6217
6218
  });
6218
6219
  module2.exports = __toCommonJS2(useThemeState_exports);
6219
- 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 = {}, states = /* @__PURE__ */ new Map(), forceUpdateThemes2 = function() {
6220
- allListeners.forEach(function(cb) {
6220
+ 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(), shouldForce = !1, forceUpdateThemes2 = function() {
6221
+ cacheVersion++, shouldForce = !0, allListeners.forEach(function(cb) {
6221
6222
  return cb();
6222
6223
  });
6223
6224
  }, getThemeState = function(id) {
6224
6225
  return states.get(id);
6225
- }, rootThemeState = null, getRootThemeState = function() {
6226
+ }, cache2 = /* @__PURE__ */ new Map(), cacheVersion = 0, themes = null, rootThemeState = null, getRootThemeState = function() {
6226
6227
  return rootThemeState;
6227
- }, HasRenderedOnce = /* @__PURE__ */ new WeakMap(), useThemeState = function(props) {
6228
+ }, useThemeState = function(props) {
6228
6229
  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);
6229
6230
  if (disable) return states.get(parentId) || {
6230
6231
  id: "",
@@ -6234,24 +6235,28 @@ var require_useThemeState_native = __commonJS({
6234
6235
  };
6235
6236
  var id = (0, import_react3.useId)(), subscribe = (0, import_react3.useCallback)(function(cb) {
6236
6237
  var _listenersByParent, _parentId;
6237
- return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, cb), function() {
6238
+ return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, function() {
6239
+ pendingUpdate.set(id, shouldForce ? "force" : !0), cb();
6240
+ }), function() {
6238
6241
  allListeners.delete(id), listenersByParent[parentId].delete(id);
6239
6242
  };
6240
6243
  }, [
6241
6244
  id,
6242
- parentId,
6243
- keys
6245
+ parentId
6244
6246
  ]), propsKey = getPropsKey(props), getSnapshot = function() {
6245
- return getSnapshotFrom(props, propsKey, isRoot, id, parentId, keys);
6247
+ 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}`;
6248
+ if (!needsUpdate && cache2.has(cacheKey)) return cache2.get(cacheKey);
6249
+ var next = getSnapshotFrom(last, props, propsKey, isRoot, id, parentId, needsUpdate, pendingUpdate.get(id));
6250
+ return last !== next && (pendingUpdate.delete(id), states.set(id, next), cache2.set(id, next), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.warn(` \xB7 useTheme(${id}) UPDATE from`, last, "to", next)), next;
6246
6251
  };
6247
6252
  process.env.NODE_ENV === "development" && globalThis.time && globalThis.time`theme-prep-uses`;
6248
6253
  var state = (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
6249
6254
  return (0, import_constants2.useIsomorphicLayoutEffect)(function() {
6255
+ if (!hasRenderedOnce.get(keys)) {
6256
+ hasRenderedOnce.set(keys, !0);
6257
+ return;
6258
+ }
6250
6259
  if (propsKey) {
6251
- if (!HasRenderedOnce.has(keys)) {
6252
- HasRenderedOnce.set(keys, !0);
6253
- return;
6254
- }
6255
6260
  if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
6256
6261
  var _states_get;
6257
6262
  console.warn(` \xB7 useTheme(${id}) scheduleUpdate`, propsKey, (_states_get = states.get(id)) === null || _states_get === void 0 ? void 0 : _states_get.name);
@@ -6261,29 +6266,30 @@ var require_useThemeState_native = __commonJS({
6261
6266
  }, [
6262
6267
  keys,
6263
6268
  propsKey
6264
- ]), process.env.NODE_ENV === "development" && props.debug && (console.groupCollapsed(` \xB7 useTheme(${id}) =>`, state.name, id === state.id ? "\u{1F389}" : "\u23ED\uFE0F"), console.info({
6265
- state,
6266
- parentId,
6267
- props,
6268
- propsKey,
6269
- id,
6270
- parentState: states.get(parentId)
6271
- }), console.groupEnd()), state.id === id ? {
6269
+ ]), state.id === id ? {
6272
6270
  ...state,
6273
6271
  isNew: !0
6274
6272
  } : state;
6275
- }, themes = null, getSnapshotFrom = function(props, propsKey) {
6276
- 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);
6273
+ }, getSnapshotFrom = function(lastState, props, propsKey) {
6274
+ 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);
6277
6275
  themes || (themes = (0, import_config.getConfig)().themes);
6278
- var lastState = states.get(id), name = propsKey ? getNewThemeName(parentState == null ? void 0 : parentState.name, props, !!needsUpdate) : null;
6276
+ var name = !propsKey && pendingUpdate2 !== "force" ? null : getNewThemeName(parentState == null ? void 0 : parentState.name, props, pendingUpdate2 === "force" ? !0 : !!needsUpdate), isSameAsParent = !!(!name && propsKey);
6279
6277
  if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
6280
6278
  var message = ` \xB7 useTheme(${id}) snapshot ${name}, parent ${parentState == null ? void 0 : parentState.id} needsUpdate ${needsUpdate}`;
6281
6279
  console.info(message);
6282
6280
  }
6283
- var isSameAsParent = !name && propsKey;
6284
6281
  if (parentState && isSameAsParent) return parentState;
6285
- if (!name) return lastState && !needsUpdate ? lastState : (states.set(id, parentState), parentState);
6286
- if (lastState && lastState.name === name) return lastState;
6282
+ if (!name) {
6283
+ var next = lastState ?? parentState;
6284
+ if (needsUpdate && pendingUpdate2) {
6285
+ var updated = {
6286
+ ...parentState || lastState
6287
+ };
6288
+ return updated;
6289
+ }
6290
+ return next;
6291
+ }
6292
+ if (pendingUpdate2 !== "force" && lastState && lastState.name === name) return lastState;
6287
6293
  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 = {
6288
6294
  id,
6289
6295
  name,
@@ -6294,7 +6300,7 @@ var require_useThemeState_native = __commonJS({
6294
6300
  inverses,
6295
6301
  isInverse
6296
6302
  };
6297
- return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && (console.groupCollapsed(` \xB7 useTheme(${id}) \u23ED\uFE0F ${name}`), console.info("state", nextState), console.groupEnd()), states.set(id, nextState), isRoot && (rootThemeState = nextState), nextState;
6303
+ return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && (console.groupCollapsed(` \xB7 useTheme(${id}) \u23ED\uFE0F2 ${name}`), console.info("state", nextState), console.groupEnd()), isRoot && (rootThemeState = nextState), pendingUpdate2 !== "force" && lastState && !needsUpdate ? (Object.assign(lastState, nextState), lastState) : nextState;
6298
6304
  };
6299
6305
  function scheduleUpdate(id) {
6300
6306
  for (var queue = [
@@ -6332,7 +6338,7 @@ var require_useThemeState_native = __commonJS({
6332
6338
  return validSchemes[name.split("_")[0]];
6333
6339
  }
6334
6340
  function getNewThemeName() {
6335
- 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;
6341
+ 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;
6336
6342
  if (name && reset) throw new Error(process.env.NODE_ENV === "production" ? "\u274C004" : "Cannot reset and set a new name at the same time.");
6337
6343
  if (reset) {
6338
6344
  if (!parentName) throw new Error("\u203C\uFE0F");
@@ -6366,7 +6372,8 @@ var require_useThemeState_native = __commonJS({
6366
6372
  }
6367
6373
  if (found) break;
6368
6374
  }
6369
- if (found && inverse) {
6375
+ if (inverse) {
6376
+ found || (found = parentName);
6370
6377
  var scheme = found.split("_")[0];
6371
6378
  found = found.replace(new RegExp(`^${scheme}`), scheme === "light" ? "dark" : "light");
6372
6379
  }
@@ -6477,41 +6484,45 @@ var require_getThemeProxied_native = __commonJS({
6477
6484
  }
6478
6485
  });
6479
6486
  module2.exports = __toCommonJS2(getThemeProxied_exports);
6480
- 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, emptyObject = {};
6481
- function getThemeProxied(_props, state, _keys) {
6482
- var theme = state == null ? void 0 : state.theme;
6483
- if (!theme) return emptyObject;
6484
- if (curKeys = _keys, curProps = _props, cache2.has(theme)) {
6485
- var proxied = cache2.get(theme);
6487
+ 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 = {};
6488
+ function getThemeProxied(_props, _state, _keys) {
6489
+ if (!(_state != null && _state.theme)) return emptyObject;
6490
+ if (curKeys = _keys, curProps = _props, curState = _state, cache2.has(curState.theme)) {
6491
+ var proxied = cache2.get(curState.theme);
6486
6492
  return proxied;
6487
6493
  }
6488
- var { name, scheme } = state, config = (0, import_config.getConfig)();
6494
+ var config = (0, import_config.getConfig)();
6489
6495
  function track(key) {
6490
- 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}`));
6496
+ if (curKeys && (curKeys.current || (curKeys.current = /* @__PURE__ */ new Set()), curKeys.current.add(key), process.env.NODE_ENV === "development" && curProps.debug)) {
6497
+ var _globalThis_states, realId = import_useThemeState.keysToId.get(curKeys);
6498
+ 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));
6499
+ }
6491
6500
  }
6492
- var proxied1 = Object.fromEntries(Object.entries(theme).flatMap(function(param) {
6501
+ var proxied1 = Object.fromEntries(Object.entries(_state.theme).flatMap(function(param) {
6493
6502
  var [key, value] = param, proxied2 = {
6494
6503
  ...value,
6495
6504
  get val() {
6496
6505
  return globalThis.tamaguiAvoidTracking || track(key), value.val;
6497
6506
  },
6498
6507
  get(platform) {
6499
- var outVal = (0, import_createVariable.getVariable)(value), shouldOptimize = scheme && platform !== "web" && import_constants2.isIos && !curProps.deopt && (0, import_config.getSetting)("fastSchemeChange") && state.inverses === 0 && (0, import_doesRootSchemeMatchSystem.doesRootSchemeMatchSystem)();
6500
- if (shouldOptimize) {
6501
- 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 = {
6502
- dynamic: {
6503
- [scheme]: color,
6504
- [oppositeScheme]: oppositeColor
6505
- }
6506
- };
6507
- return dynamicVal;
6508
- }
6509
- return process.env.NODE_ENV === "development" && curProps.debug && console.info(` \u{1F3A8} useTheme() tracking new key because of:
6508
+ if (curState) {
6509
+ var outVal = (0, import_createVariable.getVariable)(value), { name, scheme, inverses } = curState, shouldOptimize = scheme && platform !== "web" && import_constants2.isIos && !curProps.deopt && (0, import_config.getSetting)("fastSchemeChange") && inverses === 0 && (0, import_doesRootSchemeMatchSystem.doesRootSchemeMatchSystem)();
6510
+ if (shouldOptimize) {
6511
+ 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 = {
6512
+ dynamic: {
6513
+ [scheme]: color,
6514
+ [oppositeScheme]: oppositeColor
6515
+ }
6516
+ };
6517
+ return dynamicVal;
6518
+ }
6519
+ return process.env.NODE_ENV === "development" && curProps.debug && console.info(` \u{1F3A8} useTheme() tracking new key because of:
6510
6520
  not web: ${platform !== "web"}
6511
6521
  isIOS: ${import_constants2.isIos}
6512
6522
  deopt: ${curProps.deopt}
6513
6523
  fastScheme: ${(0, import_config.getSetting)("fastSchemeChange")}
6514
6524
  `), track(key), outVal;
6525
+ }
6515
6526
  }
6516
6527
  };
6517
6528
  return [
@@ -6525,7 +6536,7 @@ var require_getThemeProxied_native = __commonJS({
6525
6536
  ]
6526
6537
  ];
6527
6538
  }));
6528
- return cache2.set(theme, proxied1), proxied1;
6539
+ return cache2.set(_state.theme, proxied1), proxied1;
6529
6540
  }
6530
6541
  }
6531
6542
  });