@tamagui/core 3.0.5 → 3.0.7

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.cjs CHANGED
@@ -1855,7 +1855,7 @@ var absoluteFillObject, absoluteFill, init_StyleSheet = __esmMin((() => {
1855
1855
  StyleSheet.flatten = flatten;
1856
1856
  StyleSheet.getSheet = getSheet;
1857
1857
  StyleSheet.hairlineWidth = 1;
1858
- })), _requestIdleCallback, isSupported, requestIdleCallback;
1858
+ })), _requestIdleCallback, isSupported, requestIdleCallback$1;
1859
1859
  var init_requestIdleCallback = __esmMin((() => {
1860
1860
  init_canUseDOM();
1861
1861
  _requestIdleCallback = function(cb, options) {
@@ -1870,7 +1870,7 @@ var init_requestIdleCallback = __esmMin((() => {
1870
1870
  }, 1);
1871
1871
  };
1872
1872
  isSupported = canUseDOM$1 && typeof window.requestIdleCallback !== "undefined";
1873
- requestIdleCallback = isSupported ? window.requestIdleCallback : _requestIdleCallback;
1873
+ requestIdleCallback$1 = isSupported ? window.requestIdleCallback : _requestIdleCallback;
1874
1874
  isSupported && window.cancelIdleCallback;
1875
1875
  }));
1876
1876
  //#endregion
@@ -2192,7 +2192,7 @@ var init_invariant = __esmMin((() => {}));
2192
2192
  function _scheduleUpdate() {
2193
2193
  if (!_nextUpdateHandle) {
2194
2194
  if (_deadline > 0) _nextUpdateHandle = setTimeout(_processUpdate);
2195
- else _nextUpdateHandle = requestIdleCallback(_processUpdate);
2195
+ else _nextUpdateHandle = requestIdleCallback$1(_processUpdate);
2196
2196
  }
2197
2197
  }
2198
2198
  function _processUpdate() {
@@ -14840,11 +14840,10 @@ function syncTableState(compiled, stateName, theme) {
14840
14840
  }
14841
14841
  function setNativeStyleEngine(next) {
14842
14842
  if (engine !== next) {
14843
- settleReleases();
14844
14843
  compiledMappings.clear();
14845
14844
  scopeMappings.clear();
14846
- pendingLinks = [];
14847
- unlinkedPending = 0;
14845
+ pendingHosts = [];
14846
+ pendingStates = [];
14848
14847
  }
14849
14848
  engine = next;
14850
14849
  if (next) {
@@ -14882,7 +14881,7 @@ function updateNativeStyleScope(scopeId, stateName, theme) {
14882
14881
  if (linked) {
14883
14882
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
14884
14883
  try {
14885
- for (var _iterator = linked.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
14884
+ for (var _iterator = linked[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
14886
14885
  var compiled = _step.value;
14887
14886
  syncTableState(compiled, stateName, theme);
14888
14887
  }
@@ -14902,159 +14901,76 @@ function updateNativeStyleScope(scopeId, stateName, theme) {
14902
14901
  }
14903
14902
  function removeNativeStyleScope(scopeId) {
14904
14903
  if (!scopeStates.delete(scopeId)) return;
14904
+ queueMicrotask(function() {
14905
+ if (!scopeStates.has(scopeId)) scopeMappings.delete(scopeId);
14906
+ });
14905
14907
  engine === null || engine === void 0 || engine.removeScope(scopeId);
14906
14908
  }
14907
14909
  function resolveNativeStyleMapping(mapping, stateName, theme) {
14908
14910
  return resolveCompiledMapping(getCompiledMapping(mapping), stateName, theme).renderProps;
14909
14911
  }
14910
- function trackScopeMapping(link, delta) {
14911
- var linked = scopeMappings.get(link.scopeId);
14912
- if (!linked) scopeMappings.set(link.scopeId, linked = /* @__PURE__ */ new Map());
14913
- var _linked_get;
14914
- var count = ((_linked_get = linked.get(link.compiled)) !== null && _linked_get !== void 0 ? _linked_get : 0) + delta;
14915
- if (count) linked.set(link.compiled, count);
14916
- else {
14917
- linked.delete(link.compiled);
14918
- if (!linked.size) scopeMappings.delete(link.scopeId);
14919
- }
14912
+ function createNativeStyleLinkState(mapping, scopeId, stateName, theme) {
14913
+ return {
14914
+ mapping,
14915
+ scopeId,
14916
+ stateName,
14917
+ theme
14918
+ };
14919
+ }
14920
+ function idleFlush() {
14921
+ idleFlushQueued = false;
14922
+ flushNativeStyleLinks();
14923
+ }
14924
+ function addScopeMapping(scopeId, compiled) {
14925
+ var linked = scopeMappings.get(scopeId);
14926
+ if (!linked) scopeMappings.set(scopeId, linked = /* @__PURE__ */ new Set());
14927
+ linked.add(compiled);
14920
14928
  }
14921
14929
  function flushNativeStyleLinks() {
14922
- settleReleases();
14923
- if (!pendingLinks.length) return;
14924
- var links = pendingLinks;
14925
- pendingLinks = [];
14926
- unlinkedPending = 0;
14930
+ if (!pendingHosts.length) return;
14931
+ var hosts = pendingHosts;
14932
+ var states = pendingStates;
14933
+ pendingHosts = [];
14934
+ pendingStates = [];
14927
14935
  if (!engine) return;
14928
- var live = links.filter(function(link2) {
14929
- return link2.id === 0;
14930
- });
14931
- if (!live.length) return;
14932
- var refs = [];
14933
- var tableIds = [];
14934
- var scopeIndexes = [];
14936
+ var tableIds = new Array(hosts.length);
14937
+ var scopeIndexes = new Array(hosts.length);
14935
14938
  var scopes = [];
14936
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
14937
- try {
14938
- for (var _iterator = live[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
14939
- var link = _step.value;
14940
- var scopeIndex = scopes.indexOf(link.scopeId);
14941
- if (scopeIndex === -1) scopeIndex = scopes.push(link.scopeId) - 1;
14942
- refs.push(link.ref);
14943
- tableIds.push(link.compiled.tableId);
14944
- scopeIndexes.push(scopeIndex);
14945
- }
14946
- } catch (err) {
14947
- _didIteratorError = true;
14948
- _iteratorError = err;
14949
- } finally {
14950
- try {
14951
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
14952
- } finally {
14953
- if (_didIteratorError) throw _iteratorError;
14954
- }
14955
- }
14956
- var firstId = engine.linkTables(refs, tableIds, scopeIndexes, scopes);
14957
- for (var i = 0; i < live.length; i++) {
14958
- var link1 = live[i];
14959
- link1.id = firstId + i;
14960
- link1.owner = engine;
14961
- link1.ref = null;
14962
- trackScopeMapping(link1, 1);
14963
- }
14964
- }
14965
- function settleReleases() {
14966
- settleQueued = false;
14967
- if (!releases.size) return;
14968
- var settling = [...releases.values()];
14969
- releases.clear();
14970
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
14971
- try {
14972
- for (var _iterator = settling[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _step.value.settle();
14973
- } catch (err) {
14974
- _didIteratorError = true;
14975
- _iteratorError = err;
14976
- } finally {
14977
- try {
14978
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
14979
- } finally {
14980
- if (_didIteratorError) throw _iteratorError;
14981
- }
14939
+ var last;
14940
+ var tableId = 0;
14941
+ var scopeIndex = 0;
14942
+ for (var i = 0; i < hosts.length; i++) {
14943
+ var state = states[i];
14944
+ if (state !== last) {
14945
+ last = state;
14946
+ var compiled = getCompiledMapping(state.mapping);
14947
+ syncTableState(compiled, state.stateName, state.theme);
14948
+ addScopeMapping(state.scopeId, compiled);
14949
+ tableId = compiled.tableId;
14950
+ scopeIndex = scopes.indexOf(state.scopeId);
14951
+ if (scopeIndex === -1) scopeIndex = scopes.push(state.scopeId) - 1;
14952
+ }
14953
+ tableIds[i] = tableId;
14954
+ scopeIndexes[i] = scopeIndex;
14955
+ }
14956
+ engine.linkTables(hosts, tableIds, scopeIndexes, scopes);
14957
+ }
14958
+ function linkNativeStyleHost(host, state) {
14959
+ if (!engine) return;
14960
+ var live = scopeStates.get(state.scopeId);
14961
+ if (live && (live.name !== state.stateName || live.theme !== state.theme)) {
14962
+ var compiled = getCompiledMapping(state.mapping);
14963
+ syncTableState(compiled, live.name, live.theme);
14964
+ addScopeMapping(state.scopeId, compiled);
14965
+ engine.link(host, compiled.tableId, state.scopeId, true);
14966
+ return;
14982
14967
  }
14983
- }
14984
- function releasable(ref, compiled, scopeId, id, settle) {
14985
- var handle = {
14986
- id,
14987
- unlink: function() {
14988
- var prior = releases.get(ref);
14989
- if (prior && prior.handle !== handle) prior.settle();
14990
- releases.set(ref, {
14991
- compiled,
14992
- scopeId,
14993
- handle,
14994
- settle
14995
- });
14996
- if (!settleQueued) {
14997
- settleQueued = true;
14998
- queueMicrotask(settleReleases);
14999
- }
15000
- }
15001
- };
15002
- return handle;
15003
- }
15004
- function linkNativeStyleMapping(ref, mapping, scopeId, stateName, theme) {
15005
- if (!engine) return null;
15006
- var compiled = getCompiledMapping(mapping);
15007
- var scopeState = scopeStates.get(scopeId);
15008
- var stale = scopeState && (scopeState.name !== stateName || scopeState.theme !== theme);
15009
- var kept = releases.get(ref);
15010
- if (kept) {
15011
- releases.delete(ref);
15012
- if (!stale && kept.compiled === compiled && kept.scopeId === scopeId) return kept.handle;
15013
- kept.settle();
15014
- }
15015
- if (stale) {
15016
- syncTableState(compiled, scopeState.name, scopeState.theme);
15017
- var handle = engine.link(ref, compiled.tableId, scopeId, true);
15018
- if (!handle) return null;
15019
- var link = {
15020
- ref: null,
15021
- compiled,
15022
- scopeId,
15023
- id: handle.id,
15024
- owner: engine
15025
- };
15026
- trackScopeMapping(link, 1);
15027
- return releasable(ref, compiled, scopeId, handle.id, function() {
15028
- if (link.id === -1) return;
15029
- link.id = -1;
15030
- if (link.owner === engine) trackScopeMapping(link, -1);
15031
- handle.unlink();
15032
- });
14968
+ pendingHosts.push(host);
14969
+ pendingStates.push(state);
14970
+ if (pendingHosts.length >= maxPendingHosts && !idleFlushQueued) {
14971
+ idleFlushQueued = true;
14972
+ requestIdleCallback(idleFlush);
15033
14973
  }
15034
- syncTableState(compiled, stateName, theme);
15035
- var link1 = {
15036
- ref,
15037
- compiled,
15038
- scopeId,
15039
- id: 0,
15040
- owner: null
15041
- };
15042
- pendingLinks.push(link1);
15043
- return releasable(ref, compiled, scopeId, 0, function() {
15044
- var id = link1.id;
15045
- if (id === -1) return;
15046
- link1.id = -1;
15047
- link1.ref = null;
15048
- if (id > 0) {
15049
- if (link1.owner === engine) trackScopeMapping(link1, -1);
15050
- link1.owner.unlink(id);
15051
- } else if (++unlinkedPending > 512 && unlinkedPending * 2 > pendingLinks.length) {
15052
- pendingLinks = pendingLinks.filter(function(pending2) {
15053
- return pending2.id === 0;
15054
- });
15055
- unlinkedPending = 0;
15056
- }
15057
- });
15058
14974
  }
15059
14975
  function setNativeStyleEngineFlushListener(cb) {
15060
14976
  flushListener = cb;
@@ -15073,14 +14989,25 @@ function queueNativeViewState(entry) {
15073
14989
  pending = [];
15074
14990
  queueMicrotask(function() {
15075
14991
  var entries = pending;
14992
+ var dropped = superseded;
15076
14993
  pending = null;
14994
+ superseded = null;
14995
+ if (dropped) entries = entries.filter(function(queued, index) {
14996
+ var _dropped_get;
14997
+ return index >= ((_dropped_get = dropped.get(queued.id)) !== null && _dropped_get !== void 0 ? _dropped_get : 0);
14998
+ });
14999
+ if (!entries.length) return;
15077
15000
  engine === null || engine === void 0 || engine.applyViewStates(entries);
15078
15001
  flushListener === null || flushListener === void 0 || flushListener(entries);
15079
15002
  });
15080
15003
  }
15081
15004
  pending.push(entry);
15082
15005
  }
15083
- var nativeTextInputColorProps, nativeOutlineProps, nativeIntrinsicSizeProps, engine, scopeStates, mappingKeys, compiledMappings, scopeMappings, nextTableId, pendingLinks, unlinkedPending, releases, settleQueued, pending, flushListener;
15006
+ function supersedeNativeViewStates(id) {
15007
+ if (!pending) return;
15008
+ (superseded || (superseded = /* @__PURE__ */ new Map())).set(id, pending.length);
15009
+ }
15010
+ var nativeTextInputColorProps, nativeOutlineProps, nativeIntrinsicSizeProps, engine, scopeStates, mappingKeys, compiledMappings, scopeMappings, nextTableId, pendingHosts, pendingStates, maxPendingHosts, idleFlushQueued, pending, flushListener, superseded;
15084
15011
  var init_nativeStyleEngine_native = __esmMin((() => {
15085
15012
  init_createVariable_native();
15086
15013
  init_objectSpread2();
@@ -15110,12 +15037,13 @@ var init_nativeStyleEngine_native = __esmMin((() => {
15110
15037
  compiledMappings = /* @__PURE__ */ new Map();
15111
15038
  scopeMappings = /* @__PURE__ */ new Map();
15112
15039
  nextTableId = 1;
15113
- pendingLinks = [];
15114
- unlinkedPending = 0;
15115
- releases = /* @__PURE__ */ new Map();
15116
- settleQueued = false;
15040
+ pendingHosts = [];
15041
+ pendingStates = [];
15042
+ maxPendingHosts = 4096;
15043
+ idleFlushQueued = false;
15117
15044
  pending = null;
15118
15045
  flushListener = null;
15046
+ superseded = null;
15119
15047
  }));
15120
15048
  //#endregion
15121
15049
  //#region ../web/dist/esm/setupHooks.native.js
@@ -15166,13 +15094,26 @@ var init__withNativeStyle_native = __esmMin((() => {
15166
15094
  var TextAncestorProvider = TextAncestor === null || TextAncestor === void 0 ? void 0 : TextAncestor.Provider;
15167
15095
  var HostText = host === "text" && !("userSelect" in baseStyle) && !("verticalAlign" in baseStyle) ? baseViews === null || baseViews === void 0 ? void 0 : baseViews.NativeText : void 0;
15168
15096
  var hostTextBase = HostText ? _objectSpread2(_objectSpread2({ overflow: "hidden" }, baseStyle), typeof baseStyle.fontWeight === "number" && { fontWeight: String(baseStyle.fontWeight) }) : baseStyle;
15169
- var styles = /* @__PURE__ */ new Map();
15170
- var hostTextStyles = /* @__PURE__ */ new Map();
15097
+ var entries = /* @__PURE__ */ new Map();
15098
+ var createEntry = function() {
15099
+ var entry = {
15100
+ style: [baseStyle, null],
15101
+ hostTextStyle: [hostTextBase, null],
15102
+ stateName: "",
15103
+ theme: null,
15104
+ state: null,
15105
+ ref: function(node) {
15106
+ if (node) linkHost(node, entry.state);
15107
+ }
15108
+ };
15109
+ return entry;
15110
+ };
15171
15111
  var ScopeContext = ThemeStateContext;
15172
15112
  var engineOf = getNativeStyleEngine;
15173
15113
  var scopeState = getThemeState;
15174
15114
  var resolve = resolveNativeStyleMapping;
15175
- var linkMapping = linkNativeStyleMapping;
15115
+ var linkState = createNativeStyleLinkState;
15116
+ var linkHost = linkNativeStyleHost;
15176
15117
  var assignRef = setRef;
15177
15118
  var render = function(props, key) {
15178
15119
  var scopeId = (0, react.use)(ScopeContext);
@@ -15192,26 +15133,30 @@ var init__withNativeStyle_native = __esmMin((() => {
15192
15133
  var { name, theme } = themeState;
15193
15134
  var asHostText = HostText && !inText;
15194
15135
  var Rendered = asHostText ? HostText : Component;
15195
- var cache = asHostText ? hostTextStyles : styles;
15196
- var style = cache.get(scopeId);
15197
- if (!style) {
15198
- style = [asHostText ? hostTextBase : baseStyle, null];
15199
- cache.set(scopeId, style);
15200
- }
15201
- style[1] = resolve(themeStyleKeys, name, theme);
15136
+ var entry = entries.get(scopeId);
15137
+ if (!entry) {
15138
+ entry = createEntry();
15139
+ entries.set(scopeId, entry);
15140
+ }
15141
+ if (entry.stateName !== name || entry.theme !== theme) {
15142
+ var themed = resolve(themeStyleKeys, name, theme);
15143
+ entry.style[1] = themed;
15144
+ entry.hostTextStyle[1] = themed;
15145
+ entry.stateName = name;
15146
+ entry.theme = theme;
15147
+ entry.state = linkState(themeStyleKeys, scopeId, name, theme);
15148
+ }
15149
+ var style = asHostText ? entry.hostTextStyle : entry.style;
15202
15150
  var wrapped = resetsText || asHostText && mayRenderText(rest.children);
15151
+ var state = entry.state;
15152
+ var hostRef = ref == null ? entry.ref : function(node) {
15153
+ if (!node) return assignRef(ref, null);
15154
+ linkHost(node, state);
15155
+ if (typeof ref === "function") return ref(node);
15156
+ assignRef(ref, node);
15157
+ };
15203
15158
  var element = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Rendered, _objectSpread2(_objectSpread2(_objectSpread2({}, asHostText && hostTextProps), rest), {}, {
15204
- ref: function(node) {
15205
- var refCleanup;
15206
- if (typeof ref === "function") refCleanup = ref(node);
15207
- else assignRef(ref, node);
15208
- var link = linkMapping(node, themeStyleKeys, scopeId, name, theme);
15209
- return function() {
15210
- link === null || link === void 0 || link.unlink();
15211
- if (typeof refCleanup === "function") refCleanup();
15212
- else assignRef(ref, null);
15213
- };
15214
- },
15159
+ ref: hostRef,
15215
15160
  style
15216
15161
  }), wrapped ? void 0 : key);
15217
15162
  if (!wrapped) return element;
@@ -17553,7 +17498,7 @@ function configuredValue(state, property, raw) {
17553
17498
  var usedSafeArea = state.flatUsesSafeArea;
17554
17499
  out = grammar.embeddedTokens(raw, function(word) {
17555
17500
  var resolved = configuredValue(state, property, word, false, nativeColors);
17556
- if (resolved !== word || !shadowRecipeProperties.has(property) || !/^[a-z][\w-]*$/i.test(word)) return resolved;
17501
+ if (resolved !== word || !shadowRecipeProperties.has(property) || shadowRecipeKeywords.has(word) || !/^[a-z][\w-]*$/i.test(word)) return resolved;
17557
17502
  if (word === "currentColor") {
17558
17503
  var inherited = configuredValue(state, "color", "color", false, nativeColors);
17559
17504
  return inherited === "color" ? word : inherited;
@@ -17993,7 +17938,7 @@ function emitVariantStyle(state, key, value, original, condition, disabled) {
17993
17938
  pass[passParentCursor] = parent;
17994
17939
  pass[passVariantOutput] = parentVariantOutput;
17995
17940
  }
17996
- var shouldTrackStyleTokenProvenance, conditionValue, conditionPlatform, conditionKey, conditionSelector, conditionTheme, conditionWrappers, conditionAtoms, conditionRanks, conditionResolvedFlag, conditionPlatformPseudoFlag, passClassName, passShouldDoClasses, passContainerValue, passContainerName, passContainerType, passFrontendGroup, passFrontendContainer, passFrontendContainerType, passSourceLayer, passParentCursor, passMapSourceKey, passVariantOutput, passFlags, sourceLayerBase, sourceLayerVariant, sourceLayerResolver, sourceLayerProps, sourceLayerStyle, passNoSkipFlag, passDisableShorthandsFlag, passNoExpandFlag, passNoMergeFlag, passHocFlag, passTextFlag, passInputFlag, passAsChildStyleFlag, getSplitStyles, stylePieceStaticConfig, compileStylePieceRuntime, resolvedStylePieceCache, resolveStyleObject, recordInline, recordNormalize, recordRetract, recordDefault, recordCSS, borderTargets, valueCacheConf, valueCacheRevision, valueCaches, valueCacheEntries, valueCacheRoot, parsedSlices, shadowRecipeProperties;
17941
+ var shouldTrackStyleTokenProvenance, conditionValue, conditionPlatform, conditionKey, conditionSelector, conditionTheme, conditionWrappers, conditionAtoms, conditionRanks, conditionResolvedFlag, conditionPlatformPseudoFlag, passClassName, passShouldDoClasses, passContainerValue, passContainerName, passContainerType, passFrontendGroup, passFrontendContainer, passFrontendContainerType, passSourceLayer, passParentCursor, passMapSourceKey, passVariantOutput, passFlags, sourceLayerBase, sourceLayerVariant, sourceLayerResolver, sourceLayerProps, sourceLayerStyle, passNoSkipFlag, passDisableShorthandsFlag, passNoExpandFlag, passNoMergeFlag, passHocFlag, passTextFlag, passInputFlag, passAsChildStyleFlag, getSplitStyles, stylePieceStaticConfig, compileStylePieceRuntime, resolvedStylePieceCache, resolveStyleObject, recordInline, recordNormalize, recordRetract, recordDefault, recordCSS, borderTargets, valueCacheConf, valueCacheRevision, valueCaches, valueCacheEntries, valueCacheRoot, parsedSlices, shadowRecipeProperties, shadowRecipeKeywords;
17997
17942
  var init_getSplitStyles_native = __esmMin((() => {
17998
17943
  init_transitionResolver_native();
17999
17944
  init_index_native$6();
@@ -18500,6 +18445,7 @@ var init_getSplitStyles_native = __esmMin((() => {
18500
18445
  "textShadow",
18501
18446
  "filter"
18502
18447
  ]);
18448
+ shadowRecipeKeywords = /* @__PURE__ */ new Set(["inset", "none"]);
18503
18449
  }));
18504
18450
  //#endregion
18505
18451
  //#region ../web/dist/esm/helpers/NativeTextBinding.native.js
@@ -19296,6 +19242,7 @@ function createComponent(staticConfig) {
19296
19242
  var nativeEngine = getNativeStyleEngine();
19297
19243
  var canNativeUpdate = !!nativeEngine && !isPassthrough && !isHOC && !willBeAnimated && !groupName && !props.disableNativeStyle;
19298
19244
  stateRef.current.nativePushedStates = canNativeUpdate ? /* @__PURE__ */ new Set() : void 0;
19245
+ if (stateRef.current.nativeLink) supersedeNativeViewStates(stateRef.current.nativeLink.id);
19299
19246
  stateRef.current.nativeThemeState = void 0;
19300
19247
  stateRef.current.nativeActiveState = canNativeUpdate ? themeState === null || themeState === void 0 ? void 0 : themeState.name : void 0;
19301
19248
  var pushViewState = canNativeUpdate ? function(stateName, style2) {
@@ -3895,11 +3895,10 @@ function syncTableState(compiled, stateName, theme) {
3895
3895
  }
3896
3896
  function setNativeStyleEngine(next) {
3897
3897
  if (engine !== next) {
3898
- settleReleases();
3899
3898
  compiledMappings.clear();
3900
3899
  scopeMappings.clear();
3901
- pendingLinks = [];
3902
- unlinkedPending = 0;
3900
+ pendingHosts = [];
3901
+ pendingStates = [];
3903
3902
  }
3904
3903
  engine = next;
3905
3904
  if (next) {
@@ -3937,7 +3936,7 @@ function updateNativeStyleScope(scopeId, stateName, theme) {
3937
3936
  if (linked) {
3938
3937
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
3939
3938
  try {
3940
- for (var _iterator = linked.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
3939
+ for (var _iterator = linked[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
3941
3940
  var compiled = _step.value;
3942
3941
  syncTableState(compiled, stateName, theme);
3943
3942
  }
@@ -3957,163 +3956,80 @@ function updateNativeStyleScope(scopeId, stateName, theme) {
3957
3956
  }
3958
3957
  function removeNativeStyleScope(scopeId) {
3959
3958
  if (!scopeStates.delete(scopeId)) return;
3959
+ queueMicrotask(function() {
3960
+ if (!scopeStates.has(scopeId)) scopeMappings.delete(scopeId);
3961
+ });
3960
3962
  engine === null || engine === void 0 || engine.removeScope(scopeId);
3961
3963
  }
3962
3964
  function resolveNativeStyleMapping(mapping, stateName, theme) {
3963
3965
  return resolveCompiledMapping(getCompiledMapping(mapping), stateName, theme).renderProps;
3964
3966
  }
3965
- var pendingLinks = [];
3966
- var unlinkedPending = 0;
3967
- function trackScopeMapping(link, delta) {
3968
- var linked = scopeMappings.get(link.scopeId);
3969
- if (!linked) scopeMappings.set(link.scopeId, linked = /* @__PURE__ */ new Map());
3970
- var _linked_get;
3971
- var count = ((_linked_get = linked.get(link.compiled)) !== null && _linked_get !== void 0 ? _linked_get : 0) + delta;
3972
- if (count) linked.set(link.compiled, count);
3973
- else {
3974
- linked.delete(link.compiled);
3975
- if (!linked.size) scopeMappings.delete(link.scopeId);
3976
- }
3967
+ function createNativeStyleLinkState(mapping, scopeId, stateName, theme) {
3968
+ return {
3969
+ mapping,
3970
+ scopeId,
3971
+ stateName,
3972
+ theme
3973
+ };
3974
+ }
3975
+ var pendingHosts = [];
3976
+ var pendingStates = [];
3977
+ var maxPendingHosts = 4096;
3978
+ var idleFlushQueued = false;
3979
+ function idleFlush() {
3980
+ idleFlushQueued = false;
3981
+ flushNativeStyleLinks();
3982
+ }
3983
+ function addScopeMapping(scopeId, compiled) {
3984
+ var linked = scopeMappings.get(scopeId);
3985
+ if (!linked) scopeMappings.set(scopeId, linked = /* @__PURE__ */ new Set());
3986
+ linked.add(compiled);
3977
3987
  }
3978
3988
  function flushNativeStyleLinks() {
3979
- settleReleases();
3980
- if (!pendingLinks.length) return;
3981
- var links = pendingLinks;
3982
- pendingLinks = [];
3983
- unlinkedPending = 0;
3989
+ if (!pendingHosts.length) return;
3990
+ var hosts = pendingHosts;
3991
+ var states = pendingStates;
3992
+ pendingHosts = [];
3993
+ pendingStates = [];
3984
3994
  if (!engine) return;
3985
- var live = links.filter(function(link2) {
3986
- return link2.id === 0;
3987
- });
3988
- if (!live.length) return;
3989
- var refs = [];
3990
- var tableIds = [];
3991
- var scopeIndexes = [];
3995
+ var tableIds = new Array(hosts.length);
3996
+ var scopeIndexes = new Array(hosts.length);
3992
3997
  var scopes = [];
3993
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
3994
- try {
3995
- for (var _iterator = live[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
3996
- var link = _step.value;
3997
- var scopeIndex = scopes.indexOf(link.scopeId);
3998
- if (scopeIndex === -1) scopeIndex = scopes.push(link.scopeId) - 1;
3999
- refs.push(link.ref);
4000
- tableIds.push(link.compiled.tableId);
4001
- scopeIndexes.push(scopeIndex);
4002
- }
4003
- } catch (err) {
4004
- _didIteratorError = true;
4005
- _iteratorError = err;
4006
- } finally {
4007
- try {
4008
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
4009
- } finally {
4010
- if (_didIteratorError) throw _iteratorError;
4011
- }
4012
- }
4013
- var firstId = engine.linkTables(refs, tableIds, scopeIndexes, scopes);
4014
- for (var i = 0; i < live.length; i++) {
4015
- var link1 = live[i];
4016
- link1.id = firstId + i;
4017
- link1.owner = engine;
4018
- link1.ref = null;
4019
- trackScopeMapping(link1, 1);
4020
- }
4021
- }
4022
- var releases = /* @__PURE__ */ new Map();
4023
- var settleQueued = false;
4024
- function settleReleases() {
4025
- settleQueued = false;
4026
- if (!releases.size) return;
4027
- var settling = [...releases.values()];
4028
- releases.clear();
4029
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
4030
- try {
4031
- for (var _iterator = settling[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _step.value.settle();
4032
- } catch (err) {
4033
- _didIteratorError = true;
4034
- _iteratorError = err;
4035
- } finally {
4036
- try {
4037
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
4038
- } finally {
4039
- if (_didIteratorError) throw _iteratorError;
4040
- }
3998
+ var last;
3999
+ var tableId = 0;
4000
+ var scopeIndex = 0;
4001
+ for (var i = 0; i < hosts.length; i++) {
4002
+ var state = states[i];
4003
+ if (state !== last) {
4004
+ last = state;
4005
+ var compiled = getCompiledMapping(state.mapping);
4006
+ syncTableState(compiled, state.stateName, state.theme);
4007
+ addScopeMapping(state.scopeId, compiled);
4008
+ tableId = compiled.tableId;
4009
+ scopeIndex = scopes.indexOf(state.scopeId);
4010
+ if (scopeIndex === -1) scopeIndex = scopes.push(state.scopeId) - 1;
4011
+ }
4012
+ tableIds[i] = tableId;
4013
+ scopeIndexes[i] = scopeIndex;
4014
+ }
4015
+ engine.linkTables(hosts, tableIds, scopeIndexes, scopes);
4016
+ }
4017
+ function linkNativeStyleHost(host, state) {
4018
+ if (!engine) return;
4019
+ var live = scopeStates.get(state.scopeId);
4020
+ if (live && (live.name !== state.stateName || live.theme !== state.theme)) {
4021
+ var compiled = getCompiledMapping(state.mapping);
4022
+ syncTableState(compiled, live.name, live.theme);
4023
+ addScopeMapping(state.scopeId, compiled);
4024
+ engine.link(host, compiled.tableId, state.scopeId, true);
4025
+ return;
4041
4026
  }
4042
- }
4043
- function releasable(ref, compiled, scopeId, id, settle) {
4044
- var handle = {
4045
- id,
4046
- unlink: function() {
4047
- var prior = releases.get(ref);
4048
- if (prior && prior.handle !== handle) prior.settle();
4049
- releases.set(ref, {
4050
- compiled,
4051
- scopeId,
4052
- handle,
4053
- settle
4054
- });
4055
- if (!settleQueued) {
4056
- settleQueued = true;
4057
- queueMicrotask(settleReleases);
4058
- }
4059
- }
4060
- };
4061
- return handle;
4062
- }
4063
- function linkNativeStyleMapping(ref, mapping, scopeId, stateName, theme) {
4064
- if (!engine) return null;
4065
- var compiled = getCompiledMapping(mapping);
4066
- var scopeState = scopeStates.get(scopeId);
4067
- var stale = scopeState && (scopeState.name !== stateName || scopeState.theme !== theme);
4068
- var kept = releases.get(ref);
4069
- if (kept) {
4070
- releases.delete(ref);
4071
- if (!stale && kept.compiled === compiled && kept.scopeId === scopeId) return kept.handle;
4072
- kept.settle();
4073
- }
4074
- if (stale) {
4075
- syncTableState(compiled, scopeState.name, scopeState.theme);
4076
- var handle = engine.link(ref, compiled.tableId, scopeId, true);
4077
- if (!handle) return null;
4078
- var link = {
4079
- ref: null,
4080
- compiled,
4081
- scopeId,
4082
- id: handle.id,
4083
- owner: engine
4084
- };
4085
- trackScopeMapping(link, 1);
4086
- return releasable(ref, compiled, scopeId, handle.id, function() {
4087
- if (link.id === -1) return;
4088
- link.id = -1;
4089
- if (link.owner === engine) trackScopeMapping(link, -1);
4090
- handle.unlink();
4091
- });
4027
+ pendingHosts.push(host);
4028
+ pendingStates.push(state);
4029
+ if (pendingHosts.length >= maxPendingHosts && !idleFlushQueued) {
4030
+ idleFlushQueued = true;
4031
+ requestIdleCallback(idleFlush);
4092
4032
  }
4093
- syncTableState(compiled, stateName, theme);
4094
- var link1 = {
4095
- ref,
4096
- compiled,
4097
- scopeId,
4098
- id: 0,
4099
- owner: null
4100
- };
4101
- pendingLinks.push(link1);
4102
- return releasable(ref, compiled, scopeId, 0, function() {
4103
- var id = link1.id;
4104
- if (id === -1) return;
4105
- link1.id = -1;
4106
- link1.ref = null;
4107
- if (id > 0) {
4108
- if (link1.owner === engine) trackScopeMapping(link1, -1);
4109
- link1.owner.unlink(id);
4110
- } else if (++unlinkedPending > 512 && unlinkedPending * 2 > pendingLinks.length) {
4111
- pendingLinks = pendingLinks.filter(function(pending2) {
4112
- return pending2.id === 0;
4113
- });
4114
- unlinkedPending = 0;
4115
- }
4116
- });
4117
4033
  }
4118
4034
  var pending = null;
4119
4035
  var flushListener = null;
@@ -4128,19 +4044,31 @@ function updateNativeStyleLink(ref, host) {
4128
4044
  ref.nativePushedKeys = void 0;
4129
4045
  if (host && engine && ref.nativeStyleUpdate) ref.nativeLink = engine.link(host, {});
4130
4046
  }
4047
+ var superseded = null;
4131
4048
  function queueNativeViewState(entry) {
4132
4049
  if (!engine) return;
4133
4050
  if (!pending) {
4134
4051
  pending = [];
4135
4052
  queueMicrotask(function() {
4136
4053
  var entries = pending;
4054
+ var dropped = superseded;
4137
4055
  pending = null;
4056
+ superseded = null;
4057
+ if (dropped) entries = entries.filter(function(queued, index) {
4058
+ var _dropped_get;
4059
+ return index >= ((_dropped_get = dropped.get(queued.id)) !== null && _dropped_get !== void 0 ? _dropped_get : 0);
4060
+ });
4061
+ if (!entries.length) return;
4138
4062
  engine === null || engine === void 0 || engine.applyViewStates(entries);
4139
4063
  flushListener === null || flushListener === void 0 || flushListener(entries);
4140
4064
  });
4141
4065
  }
4142
4066
  pending.push(entry);
4143
4067
  }
4068
+ function supersedeNativeViewStates(id) {
4069
+ if (!pending) return;
4070
+ (superseded || (superseded = /* @__PURE__ */ new Map())).set(id, pending.length);
4071
+ }
4144
4072
  //#endregion
4145
4073
  //#region ../web/dist/esm/setupHooks.native.js
4146
4074
  var hooks = {};
@@ -4170,13 +4098,26 @@ var _withNativeStyle = function(Component, baseStyle, themeStyleKeys, host) {
4170
4098
  var TextAncestorProvider = TextAncestor === null || TextAncestor === void 0 ? void 0 : TextAncestor.Provider;
4171
4099
  var HostText = host === "text" && !("userSelect" in baseStyle) && !("verticalAlign" in baseStyle) ? baseViews === null || baseViews === void 0 ? void 0 : baseViews.NativeText : void 0;
4172
4100
  var hostTextBase = HostText ? _objectSpread2(_objectSpread2({ overflow: "hidden" }, baseStyle), typeof baseStyle.fontWeight === "number" && { fontWeight: String(baseStyle.fontWeight) }) : baseStyle;
4173
- var styles = /* @__PURE__ */ new Map();
4174
- var hostTextStyles = /* @__PURE__ */ new Map();
4101
+ var entries = /* @__PURE__ */ new Map();
4102
+ var createEntry = function() {
4103
+ var entry = {
4104
+ style: [baseStyle, null],
4105
+ hostTextStyle: [hostTextBase, null],
4106
+ stateName: "",
4107
+ theme: null,
4108
+ state: null,
4109
+ ref: function(node) {
4110
+ if (node) linkHost(node, entry.state);
4111
+ }
4112
+ };
4113
+ return entry;
4114
+ };
4175
4115
  var ScopeContext = ThemeStateContext;
4176
4116
  var engineOf = getNativeStyleEngine;
4177
4117
  var scopeState = getThemeState;
4178
4118
  var resolve = resolveNativeStyleMapping;
4179
- var linkMapping = linkNativeStyleMapping;
4119
+ var linkState = createNativeStyleLinkState;
4120
+ var linkHost = linkNativeStyleHost;
4180
4121
  var assignRef = setRef;
4181
4122
  var render = function(props, key) {
4182
4123
  var scopeId = (0, react.use)(ScopeContext);
@@ -4196,26 +4137,30 @@ var _withNativeStyle = function(Component, baseStyle, themeStyleKeys, host) {
4196
4137
  var { name, theme } = themeState;
4197
4138
  var asHostText = HostText && !inText;
4198
4139
  var Rendered = asHostText ? HostText : Component;
4199
- var cache = asHostText ? hostTextStyles : styles;
4200
- var style = cache.get(scopeId);
4201
- if (!style) {
4202
- style = [asHostText ? hostTextBase : baseStyle, null];
4203
- cache.set(scopeId, style);
4204
- }
4205
- style[1] = resolve(themeStyleKeys, name, theme);
4140
+ var entry = entries.get(scopeId);
4141
+ if (!entry) {
4142
+ entry = createEntry();
4143
+ entries.set(scopeId, entry);
4144
+ }
4145
+ if (entry.stateName !== name || entry.theme !== theme) {
4146
+ var themed = resolve(themeStyleKeys, name, theme);
4147
+ entry.style[1] = themed;
4148
+ entry.hostTextStyle[1] = themed;
4149
+ entry.stateName = name;
4150
+ entry.theme = theme;
4151
+ entry.state = linkState(themeStyleKeys, scopeId, name, theme);
4152
+ }
4153
+ var style = asHostText ? entry.hostTextStyle : entry.style;
4206
4154
  var wrapped = resetsText || asHostText && mayRenderText(rest.children);
4155
+ var state = entry.state;
4156
+ var hostRef = ref == null ? entry.ref : function(node) {
4157
+ if (!node) return assignRef(ref, null);
4158
+ linkHost(node, state);
4159
+ if (typeof ref === "function") return ref(node);
4160
+ assignRef(ref, node);
4161
+ };
4207
4162
  var element = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Rendered, _objectSpread2(_objectSpread2(_objectSpread2({}, asHostText && hostTextProps), rest), {}, {
4208
- ref: function(node) {
4209
- var refCleanup;
4210
- if (typeof ref === "function") refCleanup = ref(node);
4211
- else assignRef(ref, node);
4212
- var link = linkMapping(node, themeStyleKeys, scopeId, name, theme);
4213
- return function() {
4214
- link === null || link === void 0 || link.unlink();
4215
- if (typeof refCleanup === "function") refCleanup();
4216
- else assignRef(ref, null);
4217
- };
4218
- },
4163
+ ref: hostRef,
4219
4164
  style
4220
4165
  }), wrapped ? void 0 : key);
4221
4166
  if (!wrapped) return element;
@@ -7347,6 +7292,7 @@ var shadowRecipeProperties = /* @__PURE__ */ new Set([
7347
7292
  "textShadow",
7348
7293
  "filter"
7349
7294
  ]);
7295
+ var shadowRecipeKeywords = /* @__PURE__ */ new Set(["inset", "none"]);
7350
7296
  function configuredValue(state, property, raw) {
7351
7297
  var embedded = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, nativeColors = arguments.length > 4 ? arguments[4] : void 0;
7352
7298
  var grammar = getConfigRevisionState(state.conf);
@@ -7524,7 +7470,7 @@ function configuredValue(state, property, raw) {
7524
7470
  var usedSafeArea = state.flatUsesSafeArea;
7525
7471
  out = grammar.embeddedTokens(raw, function(word) {
7526
7472
  var resolved = configuredValue(state, property, word, false, nativeColors);
7527
- if (resolved !== word || !shadowRecipeProperties.has(property) || !/^[a-z][\w-]*$/i.test(word)) return resolved;
7473
+ if (resolved !== word || !shadowRecipeProperties.has(property) || shadowRecipeKeywords.has(word) || !/^[a-z][\w-]*$/i.test(word)) return resolved;
7528
7474
  if (word === "currentColor") {
7529
7475
  var inherited = configuredValue(state, "color", "color", false, nativeColors);
7530
7476
  return inherited === "color" ? word : inherited;
@@ -8912,6 +8858,7 @@ ${banner}
8912
8858
  var nativeEngine = getNativeStyleEngine();
8913
8859
  var canNativeUpdate = !!nativeEngine && !isPassthrough && !isHOC && !willBeAnimated && !groupName && !props.disableNativeStyle;
8914
8860
  stateRef.current.nativePushedStates = canNativeUpdate ? /* @__PURE__ */ new Set() : void 0;
8861
+ if (stateRef.current.nativeLink) supersedeNativeViewStates(stateRef.current.nativeLink.id);
8915
8862
  stateRef.current.nativeThemeState = void 0;
8916
8863
  stateRef.current.nativeActiveState = canNativeUpdate ? themeState === null || themeState === void 0 ? void 0 : themeState.name : void 0;
8917
8864
  var pushViewState = canNativeUpdate ? function(stateName, style2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -137,19 +137,19 @@
137
137
  "clean:build": "tamagui-build clean:build"
138
138
  },
139
139
  "dependencies": {
140
- "@tamagui/compose-refs": "3.0.5",
141
- "@tamagui/constants": "3.0.5",
142
- "@tamagui/helpers": "3.0.5",
143
- "@tamagui/react-native-media-driver": "3.0.5",
144
- "@tamagui/react-native-use-pressable": "3.0.5",
145
- "@tamagui/use-element-layout": "3.0.5",
146
- "@tamagui/use-event": "3.0.5",
147
- "@tamagui/web": "3.0.5"
140
+ "@tamagui/compose-refs": "3.0.7",
141
+ "@tamagui/constants": "3.0.7",
142
+ "@tamagui/helpers": "3.0.7",
143
+ "@tamagui/react-native-media-driver": "3.0.7",
144
+ "@tamagui/react-native-use-pressable": "3.0.7",
145
+ "@tamagui/use-element-layout": "3.0.7",
146
+ "@tamagui/use-event": "3.0.7",
147
+ "@tamagui/web": "3.0.7"
148
148
  },
149
149
  "devDependencies": {
150
- "@tamagui/build": "3.0.5",
151
- "@tamagui/native-bundle": "3.0.5",
152
- "@tamagui/react-native-web-lite": "3.0.5",
150
+ "@tamagui/build": "3.0.7",
151
+ "@tamagui/native-bundle": "3.0.7",
152
+ "@tamagui/react-native-web-lite": "3.0.7",
153
153
  "@testing-library/react": "^16.1.0",
154
154
  "csstype": "^3.0.10",
155
155
  "react": "19.2.3",
@@ -164,5 +164,5 @@
164
164
  "./dist/cjs": "./dist/esm/index.native.js",
165
165
  "./theme-update": "./dist/esm/theme-update.native.js"
166
166
  },
167
- "releaseSourceCommit": "2500e65729dfd41ce27b4b3271f22f9c1d1ff5a3"
167
+ "releaseSourceCommit": "96f8bc1f222af0381729a2e2202370aa4a9808ef"
168
168
  }