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