@tamagui/web 2.4.5 → 2.5.0

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.
Files changed (35) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/cjs/createComponent.cjs +3 -1
  3. package/dist/cjs/createComponent.native.js +3 -1
  4. package/dist/cjs/createComponent.native.js.map +1 -1
  5. package/dist/cjs/helpers/getSplitStyles.cjs +31 -2
  6. package/dist/cjs/helpers/getSplitStyles.native.js +80 -48
  7. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  8. package/dist/cjs/helpers/styleProvenance.cjs +43 -0
  9. package/dist/cjs/helpers/styleProvenance.native.js +46 -0
  10. package/dist/cjs/helpers/styleProvenance.native.js.map +1 -0
  11. package/dist/esm/createComponent.mjs +3 -1
  12. package/dist/esm/createComponent.mjs.map +1 -1
  13. package/dist/esm/createComponent.native.js +3 -1
  14. package/dist/esm/createComponent.native.js.map +1 -1
  15. package/dist/esm/helpers/getSplitStyles.mjs +29 -3
  16. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  17. package/dist/esm/helpers/getSplitStyles.native.js +78 -49
  18. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  19. package/dist/esm/helpers/styleProvenance.mjs +16 -0
  20. package/dist/esm/helpers/styleProvenance.mjs.map +1 -0
  21. package/dist/esm/helpers/styleProvenance.native.js +16 -0
  22. package/dist/esm/helpers/styleProvenance.native.js.map +1 -0
  23. package/package.json +14 -14
  24. package/src/createComponent.tsx +2 -0
  25. package/src/helpers/getSplitStyles.tsx +71 -9
  26. package/src/helpers/styleProvenance.ts +49 -0
  27. package/src/types.tsx +4 -0
  28. package/types/createComponent.d.ts.map +1 -1
  29. package/types/helpers/getSplitStyles.d.ts +2 -0
  30. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  31. package/types/helpers/styleProvenance.d.ts +11 -0
  32. package/types/helpers/styleProvenance.d.ts.map +1 -0
  33. package/types/types.d.ts +1 -0
  34. package/types/types.d.ts.map +1 -1
  35. package/.turbo/turbo-test$colon$web.log +0 -16
@@ -20,12 +20,14 @@ import { defaultMediaImportance, pseudoDescriptors, pseudoPriorities } from "./p
20
20
  import { skipProps } from "./skipProps.native.js";
21
21
  import { sortString } from "./sortString.native.js";
22
22
  import { styleOriginalValues } from "./styleOriginalValues.native.js";
23
+ import { STYLE_TOKEN_PROVENANCE_KEY, getStyleTokenProvenance, setStyleTokenProvenance } from "./styleProvenance.native.js";
23
24
  import { transformsToString } from "./transformsToString.native.js";
24
25
  function _type_of(obj) {
25
26
  "@swc/helpers - typeof";
26
27
 
27
28
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
28
29
  }
30
+ var shouldTrackStyleTokenProvenance = process.env.NODE_ENV === "development" && process.env.TAMAGUI_ENABLE_STYLE_TOKEN_PROVENANCE === "1";
29
31
  var conf;
30
32
  var PROP_SPLIT = "-";
31
33
  function normalizeGroupKey(key, groupContext) {
@@ -78,9 +80,12 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
78
80
  }
79
81
  }
80
82
  if (keyInit in skipProps && !noSkip && !isHOC) {
81
- var _driver_animations;
82
83
  if (keyInit === "group") ;
83
- if (keyInit === "transition" && typeof valInit === "string" && !(driver === null || driver === void 0 ? void 0 : (_driver_animations = driver.animations) === null || _driver_animations === void 0 ? void 0 : _driver_animations[valInit])) {} else return "continue";
84
+ if (keyInit === "transition" && typeof valInit === "string") {
85
+ var _driver_animations;
86
+ var animationConfig = driver === null || driver === void 0 ? void 0 : (_driver_animations = driver.animations) === null || _driver_animations === void 0 ? void 0 : _driver_animations[valInit];
87
+ if (animationConfig && (driver === null || driver === void 0 ? void 0 : driver.outputStyle) === "css" && process.env.IS_STATIC === "is_static") valInit = `all ${animationConfig}`;else if (animationConfig) return "continue";
88
+ } else return "continue";
84
89
  }
85
90
  var isValidStyleKeyInit = isValidStyleKey(keyInit, validStyles$1, accept);
86
91
  if (!isValidStyleKeyInit) {
@@ -139,45 +144,45 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
139
144
  if (valInit && (keyInit === "fontFamily" || keyInit === shorthands["fontFamily"]) && valInit in conf.fontsParsed) styleState.fontFamily = valInit;
140
145
  }
141
146
  var disablePropMap = isMediaOrPseudo || !isStyleLikeKey;
142
- propMapper(keyInit, valInit, styleState, disablePropMap, function (key5, val2, originalVal) {
147
+ propMapper(keyInit, valInit, styleState, disablePropMap, function (key6, val2, originalVal) {
143
148
  var _parentStaticConfig_variants;
144
- var isStyledContextProp = styledContext && key5 in styledContext;
149
+ var isStyledContextProp = styledContext && key6 in styledContext;
145
150
  if (!isHOC && disablePropMap && !isStyledContextProp && !isMediaOrPseudo) {
146
- viewProps[key5] = val2;
151
+ viewProps[key6] = val2;
147
152
  return;
148
153
  }
149
154
  if (process.env.NODE_ENV === "development" && debug === "verbose") {
150
- console.groupCollapsed(" 💠 expanded", keyInit, "=>", key5);
155
+ console.groupCollapsed(" 💠 expanded", keyInit, "=>", key6);
151
156
  log(val2);
152
157
  console.groupEnd();
153
158
  }
154
159
  if (val2 == null) return;
155
- if (key5 === "pointerEvents") {
156
- viewProps[key5] = val2;
160
+ if (key6 === "pointerEvents") {
161
+ viewProps[key6] = val2;
157
162
  return;
158
163
  }
159
- if (!isHOC && isValidStyleKey(key5, validStyles$1, accept) || isAndroid && key5 === "elevation") {
160
- mergeStyle(styleState, key5, val2, 1, false, originalVal);
164
+ if (!isHOC && isValidStyleKey(key6, validStyles$1, accept) || isAndroid && key6 === "elevation") {
165
+ mergeStyle(styleState, key6, val2, 1, false, originalVal);
161
166
  return;
162
167
  }
163
- isPseudo = key5 in validPseudoKeys;
164
- isMedia = isPseudo ? false : getMediaKey(key5);
168
+ isPseudo = key6 in validPseudoKeys;
169
+ isMedia = isPseudo ? false : getMediaKey(key6);
165
170
  isMediaOrPseudo = Boolean(isMedia || isPseudo);
166
- isVariant = variants && key5 in variants;
167
- if (isMedia === "group") key5 = normalizeGroupKey(key5, groupContext);
168
- if (shouldSkipNativeHoverProp(key5, isMedia)) return;
169
- if ((inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(key5)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened === null || inlineWhenUnflattened === void 0 ? void 0 : inlineWhenUnflattened.has(key5))) {
171
+ isVariant = variants && key6 in variants;
172
+ if (isMedia === "group") key6 = normalizeGroupKey(key6, groupContext);
173
+ if (shouldSkipNativeHoverProp(key6, isMedia)) return;
174
+ if ((inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(key6)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened === null || inlineWhenUnflattened === void 0 ? void 0 : inlineWhenUnflattened.has(key6))) {
170
175
  var _props_key;
171
- viewProps[key5] = (_props_key = props[key5]) !== null && _props_key !== void 0 ? _props_key : val2;
176
+ viewProps[key6] = (_props_key = props[key6]) !== null && _props_key !== void 0 ? _props_key : val2;
172
177
  }
173
178
  if (styleProps.noExpand && isPseudo || isHOC && (isMediaOrPseudo || (parentStaticConfig === null || parentStaticConfig === void 0 ? void 0 : (_parentStaticConfig_variants = parentStaticConfig.variants) === null || _parentStaticConfig_variants === void 0 ? void 0 : _parentStaticConfig_variants[keyInit]))) {
174
- passDownProp(viewProps, key5, val2, isMediaOrPseudo);
179
+ passDownProp(viewProps, key6, val2, isMediaOrPseudo);
175
180
  if (process.env.NODE_ENV === "development" && debug === "verbose") {
176
- console.groupCollapsed(` - passing down prop ${key5}`);
181
+ console.groupCollapsed(` - passing down prop ${key6}`);
177
182
  log({
178
183
  val: val2,
179
184
  after: {
180
- ...viewProps[key5]
185
+ ...viewProps[key6]
181
186
  }
182
187
  });
183
188
  console.groupEnd();
@@ -186,23 +191,23 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
186
191
  }
187
192
  if (isPseudo) {
188
193
  if (!val2) return;
189
- var pseudoStyleObject = getSubStyle(styleState, key5, val2, styleProps.noClass && !(process.env.IS_STATIC === "is_static"));
194
+ var pseudoStyleObject = getSubStyle(styleState, key6, val2, styleProps.noClass && !(process.env.IS_STATIC === "is_static"));
190
195
  if (!shouldDoClasses || process.env.IS_STATIC === "is_static") {
191
196
  var _pseudos, _key;
192
197
  pseudos || (pseudos = {});
193
- (_pseudos = pseudos)[_key = key5] || (_pseudos[_key] = {});
198
+ (_pseudos = pseudos)[_key = key6] || (_pseudos[_key] = {});
194
199
  if (process.env.IS_STATIC === "is_static") {
195
- Object.assign(pseudos[key5], pseudoStyleObject);
200
+ Object.assign(pseudos[key6], pseudoStyleObject);
196
201
  return;
197
202
  }
198
203
  }
199
- var descriptor = pseudoDescriptors[key5];
200
- var isEnter = key5 === "enterStyle";
201
- var isExit = key5 === "exitStyle";
204
+ var descriptor = pseudoDescriptors[key6];
205
+ var isEnter = key6 === "enterStyle";
206
+ var isExit = key6 === "exitStyle";
202
207
  if (!descriptor) return;
203
208
  if (shouldDoClasses && !isExit) {
204
209
  var pseudoStyles = getStyleAtomic(pseudoStyleObject, descriptor);
205
- if (process.env.NODE_ENV === "development" && debug === "verbose") console.info("pseudo:", key5, pseudoStyleObject, pseudoStyles);
210
+ if (process.env.NODE_ENV === "development" && debug === "verbose") console.info("pseudo:", key6, pseudoStyleObject, pseudoStyles);
206
211
  var _iteratorNormalCompletion3 = true,
207
212
  _didIteratorError3 = false,
208
213
  _iteratorError3 = void 0;
@@ -228,7 +233,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
228
233
  if (isExit) isDisabled = !styleProps.isExiting;
229
234
  if (isEnter && componentState.unmounted === false) isDisabled = true;
230
235
  if (process.env.NODE_ENV === "development" && debug === "verbose") {
231
- console.groupCollapsed("pseudo", key5, {
236
+ console.groupCollapsed("pseudo", key6, {
232
237
  isDisabled
233
238
  });
234
239
  log({
@@ -250,8 +255,8 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
250
255
  if (process.env.IS_STATIC === "is_static") {
251
256
  var _pseudos1, _key1;
252
257
  pseudos || (pseudos = {});
253
- (_pseudos1 = pseudos)[_key1 = key5] || (_pseudos1[_key1] = {});
254
- pseudos[key5][pkey] = _$val;
258
+ (_pseudos1 = pseudos)[_key1 = key6] || (_pseudos1[_key1] = {});
259
+ pseudos[key6][pkey] = _$val;
255
260
  }
256
261
  mergeStyle(styleState, pkey, _$val, importance, false, pseudoOriginalValues === null || pseudoOriginalValues === void 0 ? void 0 : pseudoOriginalValues[pkey]);
257
262
  }
@@ -264,25 +269,25 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
264
269
  }
265
270
  }
266
271
  if (!isDisabled) for (var _$key in val2) {
267
- var k = shorthands[_$key] || _$key;
268
- styleState.usedKeys[k] = Math.max(importance, styleState.usedKeys[k] || 0);
272
+ var k2 = shorthands[_$key] || _$key;
273
+ styleState.usedKeys[k2] = Math.max(importance, styleState.usedKeys[k2] || 0);
269
274
  }
270
275
  }
271
276
  return;
272
277
  }
273
278
  if (isMedia) {
274
279
  if (!val2) return;
275
- var mediaKeyShort = key5.slice(isMedia == "theme" ? 7 : 1);
280
+ var mediaKeyShort = key6.slice(isMedia == "theme" ? 7 : 1);
276
281
  hasMedia || (hasMedia = true);
277
282
  if (val2["space"] || !shouldDoClasses || styleProps.willBeAnimated) {
278
283
  if (!hasMedia || typeof hasMedia === "boolean") hasMedia = /* @__PURE__ */new Set();
279
284
  hasMedia.add(mediaKeyShort);
280
285
  }
281
286
  if (isMedia === "platform") {
282
- if (!isActivePlatform(key5)) return;
287
+ if (!isActivePlatform(key6)) return;
283
288
  }
284
- if (process.env.NODE_ENV === "development" && debug === "verbose") log(` \u{1F4FA} ${key5}`, {
285
- key: key5,
289
+ if (process.env.NODE_ENV === "development" && debug === "verbose") log(` \u{1F4FA} ${key6}`, {
290
+ key: key6,
286
291
  val: val2,
287
292
  props,
288
293
  shouldDoClasses,
@@ -293,7 +298,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
293
298
  var priority = mediaStylesSeen;
294
299
  mediaStylesSeen += 1;
295
300
  if (shouldDoClasses) {
296
- var mediaStyles = getCSSStylesAtomic(getSubStyle(styleState, key5, val2, false));
301
+ var mediaStyles = getCSSStylesAtomic(getSubStyle(styleState, key6, val2, false));
297
302
  var _iteratorNormalCompletion12 = true,
298
303
  _didIteratorError12 = false,
299
304
  _iteratorError12 = void 0;
@@ -320,14 +325,14 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
320
325
  }
321
326
  }
322
327
  } else {
323
- let mergeMediaStyle2 = function (key6, val3, originalVal2) {
328
+ let mergeMediaStyle2 = function (key7, val3, originalVal2) {
324
329
  var _styleState4;
325
- if (!isValidStyleKey(key6, validStyles$1, accept)) {
326
- viewProps[key6] = val3;
330
+ if (!isValidStyleKey(key7, validStyles$1, accept)) {
331
+ viewProps[key7] = val3;
327
332
  return;
328
333
  }
329
334
  (_styleState4 = styleState).style || (_styleState4.style = {});
330
- if (mergeMediaByImportance(styleState, mediaKeyShort, key6, val3, mediaState$1[mediaKeyShort], importanceBump, debug, originalVal2) && key6 === "fontFamily") styleState.fontFamily = mediaStyle1.fontFamily;
335
+ if (mergeMediaByImportance(styleState, mediaKeyShort, key7, val3, mediaState$1[mediaKeyShort], importanceBump, debug, originalVal2) && key7 === "fontFamily") styleState.fontFamily = mediaStyle1.fontFamily;
331
336
  };
332
337
  var isThemeMedia = isMedia === "theme";
333
338
  var isGroupMedia = isMedia === "group";
@@ -339,7 +344,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
339
344
  }
340
345
  if (process.env.NODE_ENV === "development" && debug === "verbose") log(` \u{1F4FA} \u2705 ENABLED ${mediaKeyShort}`);
341
346
  }
342
- var mediaStyle1 = getSubStyle(styleState, key5, val2, true);
347
+ var mediaStyle1 = getSubStyle(styleState, key6, val2, true);
343
348
  var importanceBump = 0;
344
349
  if (isThemeMedia) {
345
350
  if (supportsDynamicColorIOS && getSetting("fastSchemeChange")) {
@@ -468,7 +473,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
468
473
  }
469
474
  if (!isVariant) {
470
475
  if (isStyledContextProp) return;
471
- viewProps[key5] = val2;
476
+ viewProps[key6] = val2;
472
477
  }
473
478
  });
474
479
  if (process.env.NODE_ENV === "development" && debug === "verbose") {
@@ -540,9 +545,9 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
540
545
  fallbackProps
541
546
  } = styleProps;
542
547
  if (fallbackProps) styleState.props = new Proxy(props, {
543
- get(_, key5, val2) {
544
- if (!Reflect.has(props, key5)) return Reflect.get(fallbackProps, key5);
545
- return Reflect.get(props, key5);
548
+ get(_, key6, val2) {
549
+ if (!Reflect.has(props, key6)) return Reflect.get(fallbackProps, key6);
550
+ return Reflect.get(props, key6);
546
551
  }
547
552
  });
548
553
  }
@@ -612,7 +617,12 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
612
617
  if (style) if (style["$$css"]) Object.assign(styleState.classNames, style);else {
613
618
  var _styleState2;
614
619
  (_styleState2 = styleState).style || (_styleState2.style = {});
615
- Object.assign(styleState.style, normalizeStyle(style));
620
+ var normalized = normalizeStyle(style);
621
+ Object.assign(styleState.style, normalized);
622
+ if (shouldTrackStyleTokenProvenance) {
623
+ var styleOriginals = styleOriginalValues.get(normalized);
624
+ for (var k in normalized) recordStyleTokenProvenance(styleState, k, styleOriginals === null || styleOriginals === void 0 ? void 0 : styleOriginals[k]);
625
+ }
616
626
  }
617
627
  }
618
628
  }
@@ -638,6 +648,18 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
638
648
  if (process.env.NODE_ENV === "development" && debug && debug !== "profile") log(`Found fontFamily native: ${style1.fontFamily}`, faceInfo);
639
649
  }
640
650
  if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`split-styles-pre-result`;
651
+ if (shouldTrackStyleTokenProvenance && styleState.style && styleState.tokenProvenance) {
652
+ var provenance = {};
653
+ var hasProvenance = false;
654
+ for (var key4 in styleState.tokenProvenance) {
655
+ provenance[key4] = {
656
+ token: styleState.tokenProvenance[key4],
657
+ theme: themeName
658
+ };
659
+ hasProvenance = true;
660
+ }
661
+ if (hasProvenance) setStyleTokenProvenance(styleState.style, provenance);
662
+ }
641
663
  var result = {
642
664
  hasMedia,
643
665
  fontFamily: styleState.fontFamily,
@@ -672,7 +694,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
672
694
  rulesToInsert,
673
695
  parentSplitStyles
674
696
  };
675
- for (var key4 in logs) log(key4, logs[key4]);
697
+ for (var key5 in logs) log(key5, logs[key5]);
676
698
  } catch (e) {}
677
699
  console.groupEnd();
678
700
  }
@@ -722,9 +744,16 @@ function mergeStyle(styleState, key, val, importance) {
722
744
  (_styleState2 = styleState).style || (_styleState2.style = {});
723
745
  usedKeys[key] = importance;
724
746
  styleState.style[key] = key === "transform" && Array.isArray(out) ? [...out] : out;
747
+ if (shouldTrackStyleTokenProvenance) recordStyleTokenProvenance(styleState, key, originalVal);
725
748
  }
726
749
  }
727
750
  }
751
+ function recordStyleTokenProvenance(styleState, key, originalVal) {
752
+ if (typeof originalVal === "string" && originalVal[0] === "$") {
753
+ var _styleState;
754
+ ((_styleState = styleState).tokenProvenance || (_styleState.tokenProvenance = {}))[key] = originalVal;
755
+ } else if (styleState.tokenProvenance && key in styleState.tokenProvenance) delete styleState.tokenProvenance[key];
756
+ }
728
757
  var getSubStyle = function (styleState, subKey, styleIn, avoidMergeTransform) {
729
758
  var {
730
759
  staticConfig,
@@ -892,5 +921,5 @@ function applyDefaultStyle(pkey, styleState) {
892
921
  var defaultValues = animatableDefaults[pkey];
893
922
  if (defaultValues != null && !(pkey in styleState.usedKeys) && (!styleState.style || !(pkey in styleState.style))) mergeStyle(styleState, pkey, defaultValues, 1);
894
923
  }
895
- export { PROP_SPLIT, getSplitStyles, getSubStyle, styleOriginalValues, useSplitStyles };
924
+ export { PROP_SPLIT, STYLE_TOKEN_PROVENANCE_KEY, getSplitStyles, getStyleTokenProvenance, getSubStyle, styleOriginalValues, useSplitStyles };
896
925
  //# sourceMappingURL=getSplitStyles.native.js.map