@tamagui/core 3.0.5 → 3.0.6

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;
@@ -15080,7 +14996,7 @@ function queueNativeViewState(entry) {
15080
14996
  }
15081
14997
  pending.push(entry);
15082
14998
  }
15083
- var nativeTextInputColorProps, nativeOutlineProps, nativeIntrinsicSizeProps, engine, scopeStates, mappingKeys, compiledMappings, scopeMappings, nextTableId, pendingLinks, unlinkedPending, releases, settleQueued, pending, flushListener;
14999
+ var nativeTextInputColorProps, nativeOutlineProps, nativeIntrinsicSizeProps, engine, scopeStates, mappingKeys, compiledMappings, scopeMappings, nextTableId, pendingHosts, pendingStates, maxPendingHosts, idleFlushQueued, pending, flushListener;
15084
15000
  var init_nativeStyleEngine_native = __esmMin((() => {
15085
15001
  init_createVariable_native();
15086
15002
  init_objectSpread2();
@@ -15110,10 +15026,10 @@ var init_nativeStyleEngine_native = __esmMin((() => {
15110
15026
  compiledMappings = /* @__PURE__ */ new Map();
15111
15027
  scopeMappings = /* @__PURE__ */ new Map();
15112
15028
  nextTableId = 1;
15113
- pendingLinks = [];
15114
- unlinkedPending = 0;
15115
- releases = /* @__PURE__ */ new Map();
15116
- settleQueued = false;
15029
+ pendingHosts = [];
15030
+ pendingStates = [];
15031
+ maxPendingHosts = 4096;
15032
+ idleFlushQueued = false;
15117
15033
  pending = null;
15118
15034
  flushListener = null;
15119
15035
  }));
@@ -15166,13 +15082,26 @@ var init__withNativeStyle_native = __esmMin((() => {
15166
15082
  var TextAncestorProvider = TextAncestor === null || TextAncestor === void 0 ? void 0 : TextAncestor.Provider;
15167
15083
  var HostText = host === "text" && !("userSelect" in baseStyle) && !("verticalAlign" in baseStyle) ? baseViews === null || baseViews === void 0 ? void 0 : baseViews.NativeText : void 0;
15168
15084
  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();
15085
+ var entries = /* @__PURE__ */ new Map();
15086
+ var createEntry = function() {
15087
+ var entry = {
15088
+ style: [baseStyle, null],
15089
+ hostTextStyle: [hostTextBase, null],
15090
+ stateName: "",
15091
+ theme: null,
15092
+ state: null,
15093
+ ref: function(node) {
15094
+ if (node) linkHost(node, entry.state);
15095
+ }
15096
+ };
15097
+ return entry;
15098
+ };
15171
15099
  var ScopeContext = ThemeStateContext;
15172
15100
  var engineOf = getNativeStyleEngine;
15173
15101
  var scopeState = getThemeState;
15174
15102
  var resolve = resolveNativeStyleMapping;
15175
- var linkMapping = linkNativeStyleMapping;
15103
+ var linkState = createNativeStyleLinkState;
15104
+ var linkHost = linkNativeStyleHost;
15176
15105
  var assignRef = setRef;
15177
15106
  var render = function(props, key) {
15178
15107
  var scopeId = (0, react.use)(ScopeContext);
@@ -15192,26 +15121,30 @@ var init__withNativeStyle_native = __esmMin((() => {
15192
15121
  var { name, theme } = themeState;
15193
15122
  var asHostText = HostText && !inText;
15194
15123
  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);
15124
+ var entry = entries.get(scopeId);
15125
+ if (!entry) {
15126
+ entry = createEntry();
15127
+ entries.set(scopeId, entry);
15128
+ }
15129
+ if (entry.stateName !== name || entry.theme !== theme) {
15130
+ var themed = resolve(themeStyleKeys, name, theme);
15131
+ entry.style[1] = themed;
15132
+ entry.hostTextStyle[1] = themed;
15133
+ entry.stateName = name;
15134
+ entry.theme = theme;
15135
+ entry.state = linkState(themeStyleKeys, scopeId, name, theme);
15136
+ }
15137
+ var style = asHostText ? entry.hostTextStyle : entry.style;
15202
15138
  var wrapped = resetsText || asHostText && mayRenderText(rest.children);
15139
+ var state = entry.state;
15140
+ var hostRef = ref == null ? entry.ref : function(node) {
15141
+ if (!node) return assignRef(ref, null);
15142
+ linkHost(node, state);
15143
+ if (typeof ref === "function") return ref(node);
15144
+ assignRef(ref, node);
15145
+ };
15203
15146
  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
- },
15147
+ ref: hostRef,
15215
15148
  style
15216
15149
  }), wrapped ? void 0 : key);
15217
15150
  if (!wrapped) return element;
@@ -17553,7 +17486,7 @@ function configuredValue(state, property, raw) {
17553
17486
  var usedSafeArea = state.flatUsesSafeArea;
17554
17487
  out = grammar.embeddedTokens(raw, function(word) {
17555
17488
  var resolved = configuredValue(state, property, word, false, nativeColors);
17556
- if (resolved !== word || !shadowRecipeProperties.has(property) || !/^[a-z][\w-]*$/i.test(word)) return resolved;
17489
+ if (resolved !== word || !shadowRecipeProperties.has(property) || shadowRecipeKeywords.has(word) || !/^[a-z][\w-]*$/i.test(word)) return resolved;
17557
17490
  if (word === "currentColor") {
17558
17491
  var inherited = configuredValue(state, "color", "color", false, nativeColors);
17559
17492
  return inherited === "color" ? word : inherited;
@@ -17993,7 +17926,7 @@ function emitVariantStyle(state, key, value, original, condition, disabled) {
17993
17926
  pass[passParentCursor] = parent;
17994
17927
  pass[passVariantOutput] = parentVariantOutput;
17995
17928
  }
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;
17929
+ 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
17930
  var init_getSplitStyles_native = __esmMin((() => {
17998
17931
  init_transitionResolver_native();
17999
17932
  init_index_native$6();
@@ -18500,6 +18433,7 @@ var init_getSplitStyles_native = __esmMin((() => {
18500
18433
  "textShadow",
18501
18434
  "filter"
18502
18435
  ]);
18436
+ shadowRecipeKeywords = /* @__PURE__ */ new Set(["inset", "none"]);
18503
18437
  }));
18504
18438
  //#endregion
18505
18439
  //#region ../web/dist/esm/helpers/NativeTextBinding.native.js
@@ -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;
@@ -4170,13 +4086,26 @@ var _withNativeStyle = function(Component, baseStyle, themeStyleKeys, host) {
4170
4086
  var TextAncestorProvider = TextAncestor === null || TextAncestor === void 0 ? void 0 : TextAncestor.Provider;
4171
4087
  var HostText = host === "text" && !("userSelect" in baseStyle) && !("verticalAlign" in baseStyle) ? baseViews === null || baseViews === void 0 ? void 0 : baseViews.NativeText : void 0;
4172
4088
  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();
4089
+ var entries = /* @__PURE__ */ new Map();
4090
+ var createEntry = function() {
4091
+ var entry = {
4092
+ style: [baseStyle, null],
4093
+ hostTextStyle: [hostTextBase, null],
4094
+ stateName: "",
4095
+ theme: null,
4096
+ state: null,
4097
+ ref: function(node) {
4098
+ if (node) linkHost(node, entry.state);
4099
+ }
4100
+ };
4101
+ return entry;
4102
+ };
4175
4103
  var ScopeContext = ThemeStateContext;
4176
4104
  var engineOf = getNativeStyleEngine;
4177
4105
  var scopeState = getThemeState;
4178
4106
  var resolve = resolveNativeStyleMapping;
4179
- var linkMapping = linkNativeStyleMapping;
4107
+ var linkState = createNativeStyleLinkState;
4108
+ var linkHost = linkNativeStyleHost;
4180
4109
  var assignRef = setRef;
4181
4110
  var render = function(props, key) {
4182
4111
  var scopeId = (0, react.use)(ScopeContext);
@@ -4196,26 +4125,30 @@ var _withNativeStyle = function(Component, baseStyle, themeStyleKeys, host) {
4196
4125
  var { name, theme } = themeState;
4197
4126
  var asHostText = HostText && !inText;
4198
4127
  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);
4128
+ var entry = entries.get(scopeId);
4129
+ if (!entry) {
4130
+ entry = createEntry();
4131
+ entries.set(scopeId, entry);
4132
+ }
4133
+ if (entry.stateName !== name || entry.theme !== theme) {
4134
+ var themed = resolve(themeStyleKeys, name, theme);
4135
+ entry.style[1] = themed;
4136
+ entry.hostTextStyle[1] = themed;
4137
+ entry.stateName = name;
4138
+ entry.theme = theme;
4139
+ entry.state = linkState(themeStyleKeys, scopeId, name, theme);
4140
+ }
4141
+ var style = asHostText ? entry.hostTextStyle : entry.style;
4206
4142
  var wrapped = resetsText || asHostText && mayRenderText(rest.children);
4143
+ var state = entry.state;
4144
+ var hostRef = ref == null ? entry.ref : function(node) {
4145
+ if (!node) return assignRef(ref, null);
4146
+ linkHost(node, state);
4147
+ if (typeof ref === "function") return ref(node);
4148
+ assignRef(ref, node);
4149
+ };
4207
4150
  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
- },
4151
+ ref: hostRef,
4219
4152
  style
4220
4153
  }), wrapped ? void 0 : key);
4221
4154
  if (!wrapped) return element;
@@ -7347,6 +7280,7 @@ var shadowRecipeProperties = /* @__PURE__ */ new Set([
7347
7280
  "textShadow",
7348
7281
  "filter"
7349
7282
  ]);
7283
+ var shadowRecipeKeywords = /* @__PURE__ */ new Set(["inset", "none"]);
7350
7284
  function configuredValue(state, property, raw) {
7351
7285
  var embedded = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, nativeColors = arguments.length > 4 ? arguments[4] : void 0;
7352
7286
  var grammar = getConfigRevisionState(state.conf);
@@ -7524,7 +7458,7 @@ function configuredValue(state, property, raw) {
7524
7458
  var usedSafeArea = state.flatUsesSafeArea;
7525
7459
  out = grammar.embeddedTokens(raw, function(word) {
7526
7460
  var resolved = configuredValue(state, property, word, false, nativeColors);
7527
- if (resolved !== word || !shadowRecipeProperties.has(property) || !/^[a-z][\w-]*$/i.test(word)) return resolved;
7461
+ if (resolved !== word || !shadowRecipeProperties.has(property) || shadowRecipeKeywords.has(word) || !/^[a-z][\w-]*$/i.test(word)) return resolved;
7528
7462
  if (word === "currentColor") {
7529
7463
  var inherited = configuredValue(state, "color", "color", false, nativeColors);
7530
7464
  return inherited === "color" ? word : inherited;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
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.6",
141
+ "@tamagui/constants": "3.0.6",
142
+ "@tamagui/helpers": "3.0.6",
143
+ "@tamagui/react-native-media-driver": "3.0.6",
144
+ "@tamagui/react-native-use-pressable": "3.0.6",
145
+ "@tamagui/use-element-layout": "3.0.6",
146
+ "@tamagui/use-event": "3.0.6",
147
+ "@tamagui/web": "3.0.6"
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.6",
151
+ "@tamagui/native-bundle": "3.0.6",
152
+ "@tamagui/react-native-web-lite": "3.0.6",
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": "ee01c1a5d113f9d0f4e9e26c35154165ce25add6"
168
168
  }