@tamagui/static 1.110.5 → 1.111.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.
- package/dist/cjs/checkDeps.native.js +3 -131
- package/dist/cjs/checkDeps.native.js.map +1 -1
- package/dist/cjs/extractor/babelParse.native.js +3 -3
- package/dist/cjs/extractor/babelParse.native.js.map +1 -1
- package/dist/cjs/extractor/buildClassName.native.js +5 -5
- package/dist/cjs/extractor/buildClassName.native.js.map +1 -1
- package/dist/cjs/extractor/bundle.native.js +35 -260
- package/dist/cjs/extractor/bundle.native.js.map +2 -2
- package/dist/cjs/extractor/bundleConfig.native.js +153 -429
- package/dist/cjs/extractor/bundleConfig.native.js.map +2 -2
- package/dist/cjs/extractor/createEvaluator.native.js +2 -2
- package/dist/cjs/extractor/createEvaluator.native.js.map +1 -1
- package/dist/cjs/extractor/createExtractor.native.js +488 -730
- package/dist/cjs/extractor/createExtractor.native.js.map +2 -2
- package/dist/cjs/extractor/createLogger.native.js +2 -2
- package/dist/cjs/extractor/createLogger.native.js.map +1 -1
- package/dist/cjs/extractor/esbuildAliasPlugin.native.js +3 -3
- package/dist/cjs/extractor/esbuildAliasPlugin.native.js.map +1 -1
- package/dist/cjs/extractor/extractHelpers.native.js +17 -71
- package/dist/cjs/extractor/extractHelpers.native.js.map +2 -2
- package/dist/cjs/extractor/extractMediaStyle.native.js +21 -73
- package/dist/cjs/extractor/extractMediaStyle.native.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.native.js +243 -423
- package/dist/cjs/extractor/extractToClassNames.native.js.map +2 -2
- package/dist/cjs/extractor/extractToNative.native.js +30 -93
- package/dist/cjs/extractor/extractToNative.native.js.map +2 -2
- package/dist/cjs/extractor/generateTamaguiStudioConfig.native.js +43 -365
- package/dist/cjs/extractor/generateTamaguiStudioConfig.native.js.map +2 -2
- package/dist/cjs/extractor/generatedUid.native.js +1 -5
- package/dist/cjs/extractor/generatedUid.native.js.map +1 -1
- package/dist/cjs/extractor/getPrefixLogs.native.js +1 -1
- package/dist/cjs/extractor/getPrefixLogs.native.js.map +1 -1
- package/dist/cjs/extractor/getPropValueFromAttributes.native.js +2 -1
- package/dist/cjs/extractor/getPropValueFromAttributes.native.js.map +2 -2
- package/dist/cjs/extractor/getStaticBindingsForScope.native.js +91 -292
- package/dist/cjs/extractor/getStaticBindingsForScope.native.js.map +2 -2
- package/dist/cjs/extractor/hoistClassNames.native.js +1 -1
- package/dist/cjs/extractor/hoistClassNames.native.js.map +1 -1
- package/dist/cjs/extractor/literalToAst.native.js +15 -69
- package/dist/cjs/extractor/literalToAst.native.js.map +1 -1
- package/dist/cjs/extractor/loadFile.native.js +5 -8
- package/dist/cjs/extractor/loadFile.native.js.map +1 -1
- package/dist/cjs/extractor/loadTamagui.native.js +155 -574
- package/dist/cjs/extractor/loadTamagui.native.js.map +2 -2
- package/dist/cjs/extractor/logLines.native.js +1 -1
- package/dist/cjs/extractor/logLines.native.js.map +1 -1
- package/dist/cjs/extractor/normalizeTernaries.native.js +4 -59
- package/dist/cjs/extractor/normalizeTernaries.native.js.map +1 -1
- package/dist/cjs/extractor/propsToFontFamilyCache.native.js +1 -1
- package/dist/cjs/extractor/propsToFontFamilyCache.native.js.map +1 -1
- package/dist/cjs/extractor/removeUnusedHooks.native.js +1 -1
- package/dist/cjs/extractor/removeUnusedHooks.native.js.map +1 -1
- package/dist/cjs/extractor/timer.native.js +2 -2
- package/dist/cjs/extractor/timer.native.js.map +1 -1
- package/dist/cjs/extractor/watchTamaguiConfig.native.js +25 -166
- package/dist/cjs/extractor/watchTamaguiConfig.native.js.map +2 -2
- package/dist/cjs/getPragmaOptions.native.js +1 -1
- package/dist/cjs/getPragmaOptions.native.js.map +1 -1
- package/dist/cjs/helpers/requireTamaguiCore.native.js.map +1 -1
- package/dist/cjs/minifyCSS.native.js +1 -1
- package/dist/cjs/minifyCSS.native.js.map +2 -2
- package/dist/cjs/registerRequire.native.js +18 -37
- package/dist/cjs/registerRequire.native.js.map +1 -1
- package/dist/cjs/server.native.js +21 -163
- package/dist/cjs/server.native.js.map +2 -2
- package/dist/esm/checkDeps.native.js +3 -131
- package/dist/esm/checkDeps.native.js.map +1 -1
- package/dist/esm/checkDeps.native.mjs +10 -0
- package/dist/esm/checkDeps.native.mjs.map +1 -0
- package/dist/esm/constants.native.mjs +12 -0
- package/dist/esm/constants.native.mjs.map +1 -0
- package/dist/esm/exports.native.mjs +16 -0
- package/dist/esm/exports.native.mjs.map +1 -0
- package/dist/esm/extractor/accessSafe.native.mjs +12 -0
- package/dist/esm/extractor/accessSafe.native.mjs.map +1 -0
- package/dist/esm/extractor/babelParse.native.js +3 -3
- package/dist/esm/extractor/babelParse.native.js.map +1 -1
- package/dist/esm/extractor/babelParse.native.mjs +19 -0
- package/dist/esm/extractor/babelParse.native.mjs.map +1 -0
- package/dist/esm/extractor/buildClassName.native.js +5 -5
- package/dist/esm/extractor/buildClassName.native.js.map +1 -1
- package/dist/esm/extractor/buildClassName.native.mjs +30 -0
- package/dist/esm/extractor/buildClassName.native.mjs.map +1 -0
- package/dist/esm/extractor/bundle.native.js +34 -258
- package/dist/esm/extractor/bundle.native.js.map +2 -2
- package/dist/esm/extractor/bundle.native.mjs +132 -0
- package/dist/esm/extractor/bundle.native.mjs.map +1 -0
- package/dist/esm/extractor/bundleConfig.native.js +154 -429
- package/dist/esm/extractor/bundleConfig.native.js.map +2 -2
- package/dist/esm/extractor/bundleConfig.native.mjs +322 -0
- package/dist/esm/extractor/bundleConfig.native.mjs.map +1 -0
- package/dist/esm/extractor/createEvaluator.native.js +2 -2
- package/dist/esm/extractor/createEvaluator.native.js.map +1 -1
- package/dist/esm/extractor/createEvaluator.native.mjs +38 -0
- package/dist/esm/extractor/createEvaluator.native.mjs.map +1 -0
- package/dist/esm/extractor/createExtractor.native.js +498 -739
- package/dist/esm/extractor/createExtractor.native.js.map +2 -2
- package/dist/esm/extractor/createExtractor.native.mjs +1140 -0
- package/dist/esm/extractor/createExtractor.native.mjs.map +1 -0
- package/dist/esm/extractor/createLogger.native.js +2 -2
- package/dist/esm/extractor/createLogger.native.js.map +1 -1
- package/dist/esm/extractor/createLogger.native.mjs +25 -0
- package/dist/esm/extractor/createLogger.native.mjs.map +1 -0
- package/dist/esm/extractor/ensureImportingConcat.native.mjs +20 -0
- package/dist/esm/extractor/ensureImportingConcat.native.mjs.map +1 -0
- package/dist/esm/extractor/esbuildAliasPlugin.native.js +3 -3
- package/dist/esm/extractor/esbuildAliasPlugin.native.js.map +1 -1
- package/dist/esm/extractor/esbuildAliasPlugin.native.mjs +29 -0
- package/dist/esm/extractor/esbuildAliasPlugin.native.mjs.map +1 -0
- package/dist/esm/extractor/evaluateAstNode.native.mjs +49 -0
- package/dist/esm/extractor/evaluateAstNode.native.mjs.map +1 -0
- package/dist/esm/extractor/extractHelpers.native.js +18 -72
- package/dist/esm/extractor/extractHelpers.native.js.map +2 -2
- package/dist/esm/extractor/extractHelpers.native.mjs +122 -0
- package/dist/esm/extractor/extractHelpers.native.mjs.map +1 -0
- package/dist/esm/extractor/extractMediaStyle.native.js +21 -73
- package/dist/esm/extractor/extractMediaStyle.native.js.map +1 -1
- package/dist/esm/extractor/extractMediaStyle.native.mjs +125 -0
- package/dist/esm/extractor/extractMediaStyle.native.mjs.map +1 -0
- package/dist/esm/extractor/extractToClassNames.native.js +242 -421
- package/dist/esm/extractor/extractToClassNames.native.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.native.mjs +315 -0
- package/dist/esm/extractor/extractToClassNames.native.mjs.map +1 -0
- package/dist/esm/extractor/extractToNative.native.js +31 -93
- package/dist/esm/extractor/extractToNative.native.js.map +2 -2
- package/dist/esm/extractor/extractToNative.native.mjs +268 -0
- package/dist/esm/extractor/extractToNative.native.mjs.map +1 -0
- package/dist/esm/extractor/findTopmostFunction.native.mjs +11 -0
- package/dist/esm/extractor/findTopmostFunction.native.mjs.map +1 -0
- package/dist/esm/extractor/generateTamaguiStudioConfig.native.js +43 -364
- package/dist/esm/extractor/generateTamaguiStudioConfig.native.js.map +2 -2
- package/dist/esm/extractor/generateTamaguiStudioConfig.native.mjs +139 -0
- package/dist/esm/extractor/generateTamaguiStudioConfig.native.mjs.map +1 -0
- package/dist/esm/extractor/generatedUid.native.js +1 -5
- package/dist/esm/extractor/generatedUid.native.js.map +1 -1
- package/dist/esm/extractor/generatedUid.native.mjs +13 -0
- package/dist/esm/extractor/generatedUid.native.mjs.map +1 -0
- package/dist/esm/extractor/getPrefixLogs.native.js +1 -1
- package/dist/esm/extractor/getPrefixLogs.native.js.map +1 -1
- package/dist/esm/extractor/getPrefixLogs.native.mjs +6 -0
- package/dist/esm/extractor/getPrefixLogs.native.mjs.map +1 -0
- package/dist/esm/extractor/getPropValueFromAttributes.native.js +2 -1
- package/dist/esm/extractor/getPropValueFromAttributes.native.js.map +1 -1
- package/dist/esm/extractor/getPropValueFromAttributes.native.mjs +35 -0
- package/dist/esm/extractor/getPropValueFromAttributes.native.mjs.map +1 -0
- package/dist/esm/extractor/getSourceModule.native.mjs +50 -0
- package/dist/esm/extractor/getSourceModule.native.mjs.map +1 -0
- package/dist/esm/extractor/getStaticBindingsForScope.native.js +91 -292
- package/dist/esm/extractor/getStaticBindingsForScope.native.js.map +2 -2
- package/dist/esm/extractor/getStaticBindingsForScope.native.mjs +159 -0
- package/dist/esm/extractor/getStaticBindingsForScope.native.mjs.map +1 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.mjs +6 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.mjs.map +1 -0
- package/dist/esm/extractor/hoistClassNames.native.js +1 -1
- package/dist/esm/extractor/hoistClassNames.native.js.map +1 -1
- package/dist/esm/extractor/hoistClassNames.native.mjs +30 -0
- package/dist/esm/extractor/hoistClassNames.native.mjs.map +1 -0
- package/dist/esm/extractor/literalToAst.native.js +15 -69
- package/dist/esm/extractor/literalToAst.native.js.map +1 -1
- package/dist/esm/extractor/literalToAst.native.mjs +55 -0
- package/dist/esm/extractor/literalToAst.native.mjs.map +1 -0
- package/dist/esm/extractor/loadFile.native.js +5 -8
- package/dist/esm/extractor/loadFile.native.js.map +1 -1
- package/dist/esm/extractor/loadFile.native.mjs +20 -0
- package/dist/esm/extractor/loadFile.native.mjs.map +1 -0
- package/dist/esm/extractor/loadTamagui.native.js +155 -573
- package/dist/esm/extractor/loadTamagui.native.js.map +2 -2
- package/dist/esm/extractor/loadTamagui.native.mjs +284 -0
- package/dist/esm/extractor/loadTamagui.native.mjs.map +1 -0
- package/dist/esm/extractor/logLines.native.js +1 -1
- package/dist/esm/extractor/logLines.native.js.map +1 -1
- package/dist/esm/extractor/logLines.native.mjs +31 -0
- package/dist/esm/extractor/logLines.native.mjs.map +1 -0
- package/dist/esm/extractor/normalizeTernaries.native.js +4 -59
- package/dist/esm/extractor/normalizeTernaries.native.js.map +1 -1
- package/dist/esm/extractor/normalizeTernaries.native.mjs +38 -0
- package/dist/esm/extractor/normalizeTernaries.native.mjs.map +1 -0
- package/dist/esm/extractor/propsToFontFamilyCache.native.js +1 -1
- package/dist/esm/extractor/propsToFontFamilyCache.native.js.map +1 -1
- package/dist/esm/extractor/propsToFontFamilyCache.native.mjs +13 -0
- package/dist/esm/extractor/propsToFontFamilyCache.native.mjs.map +1 -0
- package/dist/esm/extractor/removeUnusedHooks.native.js +2 -2
- package/dist/esm/extractor/removeUnusedHooks.native.js.map +1 -1
- package/dist/esm/extractor/removeUnusedHooks.native.mjs +83 -0
- package/dist/esm/extractor/removeUnusedHooks.native.mjs.map +1 -0
- package/dist/esm/extractor/timer.native.js +2 -2
- package/dist/esm/extractor/timer.native.js.map +1 -1
- package/dist/esm/extractor/timer.native.mjs +22 -0
- package/dist/esm/extractor/timer.native.mjs.map +1 -0
- package/dist/esm/extractor/validHTMLAttributes.native.mjs +50 -0
- package/dist/esm/extractor/validHTMLAttributes.native.mjs.map +1 -0
- package/dist/esm/extractor/watchTamaguiConfig.native.js +25 -166
- package/dist/esm/extractor/watchTamaguiConfig.native.js.map +2 -2
- package/dist/esm/extractor/watchTamaguiConfig.native.mjs +33 -0
- package/dist/esm/extractor/watchTamaguiConfig.native.mjs.map +1 -0
- package/dist/esm/getPragmaOptions.native.js +1 -1
- package/dist/esm/getPragmaOptions.native.js.map +1 -1
- package/dist/esm/getPragmaOptions.native.mjs +51 -0
- package/dist/esm/getPragmaOptions.native.mjs.map +1 -0
- package/dist/esm/helpers/memoize.native.mjs +15 -0
- package/dist/esm/helpers/memoize.native.mjs.map +1 -0
- package/dist/esm/helpers/requireTamaguiCore.native.js.map +1 -1
- package/dist/esm/helpers/requireTamaguiCore.native.mjs +13 -0
- package/dist/esm/helpers/requireTamaguiCore.native.mjs.map +1 -0
- package/dist/esm/index.native.mjs +5 -0
- package/dist/esm/index.native.mjs.map +1 -0
- package/dist/esm/minifyCSS.native.js +1 -1
- package/dist/esm/minifyCSS.native.js.map +2 -2
- package/dist/esm/minifyCSS.native.mjs +16 -0
- package/dist/esm/minifyCSS.native.mjs.map +1 -0
- package/dist/esm/registerRequire.native.js +17 -35
- package/dist/esm/registerRequire.native.js.map +1 -1
- package/dist/esm/registerRequire.native.mjs +86 -0
- package/dist/esm/registerRequire.native.mjs.map +1 -0
- package/dist/esm/server.native.js +21 -163
- package/dist/esm/server.native.js.map +2 -2
- package/dist/esm/server.native.mjs +44 -0
- package/dist/esm/server.native.mjs.map +1 -0
- package/dist/esm/setup.native.mjs +2 -0
- package/dist/esm/setup.native.mjs.map +1 -0
- package/dist/esm/types.native.mjs +2 -0
- package/dist/esm/types.native.mjs.map +1 -0
- package/package.json +14 -14
@@ -19,224 +19,6 @@ import { setPropsToFontFamily } from "./propsToFontFamilyCache";
|
|
19
19
|
import { removeUnusedHooks } from "./removeUnusedHooks";
|
20
20
|
import { timer } from "./timer";
|
21
21
|
import { validHTMLAttributes } from "./validHTMLAttributes";
|
22
|
-
function _array_like_to_array(arr, len) {
|
23
|
-
(len == null || len > arr.length) && (len = arr.length);
|
24
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
25
|
-
return arr2;
|
26
|
-
}
|
27
|
-
function _array_with_holes(arr) {
|
28
|
-
if (Array.isArray(arr)) return arr;
|
29
|
-
}
|
30
|
-
function _array_without_holes(arr) {
|
31
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
32
|
-
}
|
33
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
34
|
-
try {
|
35
|
-
var info = gen[key](arg), value = info.value;
|
36
|
-
} catch (error) {
|
37
|
-
reject(error);
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
|
41
|
-
}
|
42
|
-
function _async_to_generator(fn) {
|
43
|
-
return function() {
|
44
|
-
var self = this, args = arguments;
|
45
|
-
return new Promise(function(resolve, reject) {
|
46
|
-
var gen = fn.apply(self, args);
|
47
|
-
function _next(value) {
|
48
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
49
|
-
}
|
50
|
-
function _throw(err) {
|
51
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
52
|
-
}
|
53
|
-
_next(void 0);
|
54
|
-
});
|
55
|
-
};
|
56
|
-
}
|
57
|
-
function _define_property(obj, key, value) {
|
58
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
59
|
-
value,
|
60
|
-
enumerable: !0,
|
61
|
-
configurable: !0,
|
62
|
-
writable: !0
|
63
|
-
}) : obj[key] = value, obj;
|
64
|
-
}
|
65
|
-
function _iterable_to_array(iter) {
|
66
|
-
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
67
|
-
}
|
68
|
-
function _iterable_to_array_limit(arr, i) {
|
69
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
70
|
-
if (_i != null) {
|
71
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
72
|
-
try {
|
73
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
74
|
-
;
|
75
|
-
} catch (err) {
|
76
|
-
_d = !0, _e = err;
|
77
|
-
} finally {
|
78
|
-
try {
|
79
|
-
!_n && _i.return != null && _i.return();
|
80
|
-
} finally {
|
81
|
-
if (_d) throw _e;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
return _arr;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
function _non_iterable_rest() {
|
88
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
89
|
-
}
|
90
|
-
function _non_iterable_spread() {
|
91
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
92
|
-
}
|
93
|
-
function _object_spread(target) {
|
94
|
-
for (var i = 1; i < arguments.length; i++) {
|
95
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
96
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
97
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
98
|
-
}))), ownKeys2.forEach(function(key) {
|
99
|
-
_define_property(target, key, source[key]);
|
100
|
-
});
|
101
|
-
}
|
102
|
-
return target;
|
103
|
-
}
|
104
|
-
function ownKeys(object, enumerableOnly) {
|
105
|
-
var keys = Object.keys(object);
|
106
|
-
if (Object.getOwnPropertySymbols) {
|
107
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
108
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
109
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
110
|
-
})), keys.push.apply(keys, symbols);
|
111
|
-
}
|
112
|
-
return keys;
|
113
|
-
}
|
114
|
-
function _object_spread_props(target, source) {
|
115
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
116
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
117
|
-
}), target;
|
118
|
-
}
|
119
|
-
function _object_without_properties(source, excluded) {
|
120
|
-
if (source == null) return {};
|
121
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
122
|
-
if (Object.getOwnPropertySymbols) {
|
123
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
124
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
125
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
126
|
-
}
|
127
|
-
return target;
|
128
|
-
}
|
129
|
-
function _object_without_properties_loose(source, excluded) {
|
130
|
-
if (source == null) return {};
|
131
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
132
|
-
for (i = 0; i < sourceKeys.length; i++)
|
133
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
134
|
-
return target;
|
135
|
-
}
|
136
|
-
function _sliced_to_array(arr, i) {
|
137
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
138
|
-
}
|
139
|
-
function _to_consumable_array(arr) {
|
140
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
141
|
-
}
|
142
|
-
function _type_of(obj) {
|
143
|
-
"@swc/helpers - typeof";
|
144
|
-
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
145
|
-
}
|
146
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
147
|
-
if (o) {
|
148
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
149
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
150
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
151
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
152
|
-
}
|
153
|
-
}
|
154
|
-
function _ts_generator(thisArg, body) {
|
155
|
-
var f, y, t2, g, _ = {
|
156
|
-
label: 0,
|
157
|
-
sent: function() {
|
158
|
-
if (t2[0] & 1) throw t2[1];
|
159
|
-
return t2[1];
|
160
|
-
},
|
161
|
-
trys: [],
|
162
|
-
ops: []
|
163
|
-
};
|
164
|
-
return g = {
|
165
|
-
next: verb(0),
|
166
|
-
throw: verb(1),
|
167
|
-
return: verb(2)
|
168
|
-
}, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
|
169
|
-
return this;
|
170
|
-
}), g;
|
171
|
-
function verb(n) {
|
172
|
-
return function(v) {
|
173
|
-
return step([
|
174
|
-
n,
|
175
|
-
v
|
176
|
-
]);
|
177
|
-
};
|
178
|
-
}
|
179
|
-
function step(op) {
|
180
|
-
if (f) throw new TypeError("Generator is already executing.");
|
181
|
-
for (; _; ) try {
|
182
|
-
if (f = 1, y && (t2 = op[0] & 2 ? y.return : op[0] ? y.throw || ((t2 = y.return) && t2.call(y), 0) : y.next) && !(t2 = t2.call(y, op[1])).done) return t2;
|
183
|
-
switch (y = 0, t2 && (op = [
|
184
|
-
op[0] & 2,
|
185
|
-
t2.value
|
186
|
-
]), op[0]) {
|
187
|
-
case 0:
|
188
|
-
case 1:
|
189
|
-
t2 = op;
|
190
|
-
break;
|
191
|
-
case 4:
|
192
|
-
return _.label++, {
|
193
|
-
value: op[1],
|
194
|
-
done: !1
|
195
|
-
};
|
196
|
-
case 5:
|
197
|
-
_.label++, y = op[1], op = [
|
198
|
-
0
|
199
|
-
];
|
200
|
-
continue;
|
201
|
-
case 7:
|
202
|
-
op = _.ops.pop(), _.trys.pop();
|
203
|
-
continue;
|
204
|
-
default:
|
205
|
-
if (t2 = _.trys, !(t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
206
|
-
_ = 0;
|
207
|
-
continue;
|
208
|
-
}
|
209
|
-
if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
|
210
|
-
_.label = op[1];
|
211
|
-
break;
|
212
|
-
}
|
213
|
-
if (op[0] === 6 && _.label < t2[1]) {
|
214
|
-
_.label = t2[1], t2 = op;
|
215
|
-
break;
|
216
|
-
}
|
217
|
-
if (t2 && _.label < t2[2]) {
|
218
|
-
_.label = t2[2], _.ops.push(op);
|
219
|
-
break;
|
220
|
-
}
|
221
|
-
t2[2] && _.ops.pop(), _.trys.pop();
|
222
|
-
continue;
|
223
|
-
}
|
224
|
-
op = body.call(thisArg, _);
|
225
|
-
} catch (e) {
|
226
|
-
op = [
|
227
|
-
6,
|
228
|
-
e
|
229
|
-
], y = 0;
|
230
|
-
} finally {
|
231
|
-
f = t2 = 0;
|
232
|
-
}
|
233
|
-
if (op[0] & 5) throw op[1];
|
234
|
-
return {
|
235
|
-
value: op[0] ? op[1] : void 0,
|
236
|
-
done: !0
|
237
|
-
};
|
238
|
-
}
|
239
|
-
}
|
240
22
|
var UNTOUCHED_PROPS = {
|
241
23
|
key: !0,
|
242
24
|
style: !0,
|
@@ -248,18 +30,19 @@ function isFullyDisabled(props) {
|
|
248
30
|
return props.disableExtraction && props.disableDebugAttr;
|
249
31
|
}
|
250
32
|
function createExtractor() {
|
251
|
-
var
|
33
|
+
var { logger = console, platform = "web" } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
252
34
|
logger: console
|
253
|
-
},
|
35
|
+
}, INLINE_EXTRACTABLE = {
|
254
36
|
ref: "ref",
|
255
|
-
key: "key"
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
37
|
+
key: "key",
|
38
|
+
...platform === "web" && {
|
39
|
+
onPress: "onClick",
|
40
|
+
onHoverIn: "onMouseEnter",
|
41
|
+
onHoverOut: "onMouseLeave",
|
42
|
+
onPressIn: "onMouseDown",
|
43
|
+
onPressOut: "onMouseUp"
|
44
|
+
}
|
45
|
+
}, componentState = {
|
263
46
|
focus: !1,
|
264
47
|
focusVisible: !1,
|
265
48
|
hover: !1,
|
@@ -278,35 +61,8 @@ function createExtractor() {
|
|
278
61
|
function loadSync(props) {
|
279
62
|
return isFullyDisabled(props) ? null : projectInfo || (projectInfo = loadTamaguiSync(props));
|
280
63
|
}
|
281
|
-
function load(props) {
|
282
|
-
return
|
283
|
-
}
|
284
|
-
function _load() {
|
285
|
-
return _load = _async_to_generator(function(props) {
|
286
|
-
var _tmp;
|
287
|
-
return _ts_generator(this, function(_state) {
|
288
|
-
switch (_state.label) {
|
289
|
-
case 0:
|
290
|
-
return isFullyDisabled(props) ? [
|
291
|
-
2,
|
292
|
-
null
|
293
|
-
] : (_tmp = projectInfo, _tmp ? [
|
294
|
-
3,
|
295
|
-
2
|
296
|
-
] : [
|
297
|
-
4,
|
298
|
-
loadTamagui(props)
|
299
|
-
]);
|
300
|
-
case 1:
|
301
|
-
_tmp = projectInfo = _state.sent(), _state.label = 2;
|
302
|
-
case 2:
|
303
|
-
return [
|
304
|
-
2,
|
305
|
-
_tmp
|
306
|
-
];
|
307
|
-
}
|
308
|
-
});
|
309
|
-
}), _load.apply(this, arguments);
|
64
|
+
async function load(props) {
|
65
|
+
return isFullyDisabled(props) ? null : projectInfo || (projectInfo = await loadTamagui(props));
|
310
66
|
}
|
311
67
|
return {
|
312
68
|
options: {
|
@@ -315,70 +71,32 @@ function createExtractor() {
|
|
315
71
|
cleanupBeforeExit,
|
316
72
|
loadTamagui: load,
|
317
73
|
loadTamaguiSync: loadSync,
|
318
|
-
getTamagui
|
319
|
-
return projectInfo
|
74
|
+
getTamagui() {
|
75
|
+
return projectInfo?.tamaguiConfig;
|
320
76
|
},
|
321
77
|
parseSync: function(f, props) {
|
322
78
|
var projectInfo2 = loadSync(props);
|
323
79
|
return parseWithConfig(projectInfo2 || {}, f, props);
|
324
80
|
},
|
325
|
-
parse:
|
326
|
-
var
|
327
|
-
|
328
|
-
|
329
|
-
switch (_state.label) {
|
330
|
-
case 0:
|
331
|
-
return [
|
332
|
-
4,
|
333
|
-
load(props)
|
334
|
-
];
|
335
|
-
case 1:
|
336
|
-
return projectInfo2 = _state.sent(), [
|
337
|
-
2,
|
338
|
-
parseWithConfig(projectInfo2 || {}, f, props)
|
339
|
-
];
|
340
|
-
}
|
341
|
-
});
|
342
|
-
});
|
343
|
-
return function(f, props) {
|
344
|
-
return _ref2.apply(this, arguments);
|
345
|
-
};
|
346
|
-
}()
|
81
|
+
parse: async function(f, props) {
|
82
|
+
var projectInfo2 = await load(props);
|
83
|
+
return parseWithConfig(projectInfo2 || {}, f, props);
|
84
|
+
}
|
347
85
|
};
|
348
86
|
function parseWithConfig(param, fileOrPath, options) {
|
349
|
-
var
|
87
|
+
var { components, tamaguiConfig } = param, { config = "tamagui.config.ts", importsWhitelist = [
|
350
88
|
"constants.js"
|
351
|
-
]
|
89
|
+
], evaluateVars = !0, sourcePath = "", onExtractTag, onStyleRule, getFlattenedNode, disable, disableExtraction, disableExtractInlineMedia, disableExtractVariables, disableDebugAttr, enableDynamicEvaluation = !1, disableOptimizeHooks, includeExtensions = [
|
352
90
|
".ts",
|
353
91
|
".tsx",
|
354
92
|
".jsx"
|
355
|
-
]
|
356
|
-
"config",
|
357
|
-
"importsWhitelist",
|
358
|
-
"evaluateVars",
|
359
|
-
"sourcePath",
|
360
|
-
"onExtractTag",
|
361
|
-
"onStyleRule",
|
362
|
-
"getFlattenedNode",
|
363
|
-
"disable",
|
364
|
-
"disableExtraction",
|
365
|
-
"disableExtractInlineMedia",
|
366
|
-
"disableExtractVariables",
|
367
|
-
"disableDebugAttr",
|
368
|
-
"enableDynamicEvaluation",
|
369
|
-
"disableOptimizeHooks",
|
370
|
-
"includeExtensions",
|
371
|
-
"extractStyledDefinitions",
|
372
|
-
"prefixLogs",
|
373
|
-
"excludeProps",
|
374
|
-
"platform"
|
375
|
-
]), validHooks = disableOptimizeHooks ? {} : {
|
93
|
+
], extractStyledDefinitions = !1, prefixLogs, excludeProps, platform: platform2, ...restProps } = options, validHooks = disableOptimizeHooks ? {} : {
|
376
94
|
useMedia: !0,
|
377
95
|
useTheme: !0
|
378
96
|
};
|
379
97
|
if (sourcePath.includes(".tamagui-dynamic-eval"))
|
380
98
|
return null;
|
381
|
-
var
|
99
|
+
var { normalizeStyle, getSplitStyles, mediaQueryConfig, propMapper, proxyThemeVariables, pseudoDescriptors } = requireTamaguiCore(platform2), shouldPrintDebug = options.shouldPrintDebug || !1;
|
382
100
|
if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath))
|
383
101
|
return null;
|
384
102
|
if (!isFullyDisabled(options) && !components)
|
@@ -386,17 +104,20 @@ function createExtractor() {
|
|
386
104
|
if (sourcePath && includeExtensions && !includeExtensions.some(function(ext) {
|
387
105
|
return sourcePath.endsWith(ext);
|
388
106
|
}))
|
389
|
-
return shouldPrintDebug && logger.info(
|
107
|
+
return shouldPrintDebug && logger.info(`Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(", ")}`), null;
|
390
108
|
function isValidStyleKey(name, staticConfig) {
|
391
109
|
var _staticConfig_validStyles, _staticConfig_variants, _projectInfo_tamaguiConfig;
|
392
110
|
if (!projectInfo)
|
393
111
|
throw new Error("Tamagui extractor not loaded yet");
|
394
112
|
return platform2 === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)] ? !1 : !!(!((_staticConfig_validStyles = staticConfig.validStyles) === null || _staticConfig_validStyles === void 0) && _staticConfig_validStyles[name] || pseudoDescriptors[name] || !((_staticConfig_variants = staticConfig.variants) === null || _staticConfig_variants === void 0) && _staticConfig_variants[name] || !(projectInfo == null || (_projectInfo_tamaguiConfig = projectInfo.tamaguiConfig) === null || _projectInfo_tamaguiConfig === void 0) && _projectInfo_tamaguiConfig.shorthands[name] || name[0] === "$" && mediaQueryConfig[name.slice(1)]);
|
395
113
|
}
|
396
|
-
var isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm = timer(), propsWithFileInfo =
|
114
|
+
var isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm = timer(), propsWithFileInfo = {
|
115
|
+
...options,
|
397
116
|
sourcePath,
|
398
|
-
allLoadedComponents: components ?
|
399
|
-
|
117
|
+
allLoadedComponents: components ? [
|
118
|
+
...components
|
119
|
+
] : []
|
120
|
+
};
|
400
121
|
if (!hasLoggedBaseInfo) {
|
401
122
|
var _process_env_DEBUG;
|
402
123
|
hasLoggedBaseInfo = !0, shouldPrintDebug && logger.info([
|
@@ -412,7 +133,7 @@ function createExtractor() {
|
|
412
133
|
].join(`
|
413
134
|
`));
|
414
135
|
}
|
415
|
-
tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig
|
136
|
+
tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig?.themes || (console.error(`\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file:
|
416
137
|
|
417
138
|
You may not need the compiler! Remember you can run Tamagui with no configuration at all.
|
418
139
|
|
@@ -422,28 +143,28 @@ function createExtractor() {
|
|
422
143
|
- try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches.
|
423
144
|
- or search your lockfile for mis-matches.
|
424
145
|
`), console.info(" Got config:", tamaguiConfig), process.exit(0));
|
425
|
-
var firstThemeName = Object.keys(
|
426
|
-
if (!firstTheme ||
|
427
|
-
var _$err =
|
146
|
+
var firstThemeName = Object.keys(tamaguiConfig?.themes || {})[0], firstTheme = tamaguiConfig?.themes[firstThemeName] || {};
|
147
|
+
if (!firstTheme || typeof firstTheme != "object") {
|
148
|
+
var _$err = `Missing theme ${firstThemeName}, an error occurred when importing your config`;
|
428
149
|
throw console.info(_$err, "Got config:", tamaguiConfig), console.info("Looking for theme:", firstThemeName), new Error(_$err);
|
429
150
|
}
|
430
151
|
var proxiedTheme = proxyThemeVariables(firstTheme), themeAccessListeners = /* @__PURE__ */ new Set(), defaultTheme = new Proxy(proxiedTheme, {
|
431
|
-
get
|
152
|
+
get(target, key) {
|
432
153
|
return Reflect.has(target, key) && themeAccessListeners.forEach(function(cb) {
|
433
154
|
return cb(String(key));
|
434
155
|
}), Reflect.get(target, key);
|
435
156
|
}
|
436
157
|
}), body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
437
|
-
isFullyDisabled(options) || Object.keys(components || []).length === 0 && (console.warn("Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)"), process.env.DEBUG === "tamagui" && console.info("components", Object.keys(components || []), components)), shouldPrintDebug === "verbose" && (logger.info(
|
158
|
+
isFullyDisabled(options) || Object.keys(components || []).length === 0 && (console.warn("Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)"), process.env.DEBUG === "tamagui" && console.info("components", Object.keys(components || []), components)), shouldPrintDebug === "verbose" && (logger.info(`allLoadedComponent modules ${propsWithFileInfo.allLoadedComponents.map(function(k) {
|
438
159
|
return k.moduleName;
|
439
|
-
}).join(", "))
|
160
|
+
}).join(", ")}`), logger.info(`valid import paths: ${JSON.stringify(getValidComponentsPaths(propsWithFileInfo))}`));
|
440
161
|
var doesUseValidImport = !1, hasImportedTheme = !1, importDeclarations = [], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
441
162
|
try {
|
442
163
|
for (var _loop = function() {
|
443
164
|
var bodyPath = _step.value;
|
444
165
|
if (bodyPath.type !== "ImportDeclaration") return "continue";
|
445
166
|
var node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid = isValidImport(propsWithFileInfo, moduleName);
|
446
|
-
if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(
|
167
|
+
if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(` - import ${moduleName} ${valid}`), extractStyledDefinitions && valid && node.specifiers.some(function(specifier) {
|
447
168
|
return specifier.local.name === "styled";
|
448
169
|
}))
|
449
170
|
return doesUseValidImport = !0, "break";
|
@@ -453,7 +174,7 @@ function createExtractor() {
|
|
453
174
|
}), isValidComponent = names.some(function(name) {
|
454
175
|
return !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name]);
|
455
176
|
});
|
456
|
-
if (shouldPrintDebug === "verbose" && logger.info(
|
177
|
+
if (shouldPrintDebug === "verbose" && logger.info(` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(", ")} from '${moduleName}' - (valid: ${JSON.stringify(getValidComponentsPaths(propsWithFileInfo))})`), isValidComponent)
|
457
178
|
return doesUseValidImport = !0, "break";
|
458
179
|
}
|
459
180
|
}, _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
@@ -470,11 +191,11 @@ function createExtractor() {
|
|
470
191
|
throw _iteratorError;
|
471
192
|
}
|
472
193
|
}
|
473
|
-
if (shouldPrintDebug && logger.info(
|
194
|
+
if (shouldPrintDebug && logger.info(`${JSON.stringify({
|
474
195
|
doesUseValidImport,
|
475
196
|
hasImportedTheme
|
476
|
-
}, null, 2)
|
477
|
-
`)
|
197
|
+
}, null, 2)}
|
198
|
+
`), !doesUseValidImport)
|
478
199
|
return null;
|
479
200
|
function getValidImportedComponent(componentName) {
|
480
201
|
var importDeclaration = importDeclarations.find(function(dec) {
|
@@ -493,16 +214,16 @@ function createExtractor() {
|
|
493
214
|
optimized: 0,
|
494
215
|
modified: 0,
|
495
216
|
found: 0
|
496
|
-
}, version =
|
217
|
+
}, version = `${Math.random()}`;
|
497
218
|
if (callTraverse({
|
498
219
|
// @ts-ignore
|
499
220
|
Program: {
|
500
|
-
enter
|
221
|
+
enter(path) {
|
501
222
|
programPath = path;
|
502
223
|
}
|
503
224
|
},
|
504
225
|
// styled() calls
|
505
|
-
CallExpression
|
226
|
+
CallExpression(path) {
|
506
227
|
if (!(disable || shouldDisableExtraction || extractStyledDefinitions === !1) && !(!t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled")) {
|
507
228
|
var variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown", parentNode = path.node.arguments[0];
|
508
229
|
if (t.isIdentifier(parentNode)) {
|
@@ -513,7 +234,7 @@ function createExtractor() {
|
|
513
234
|
if (enableDynamicEvaluation !== !0)
|
514
235
|
return;
|
515
236
|
try {
|
516
|
-
shouldPrintDebug && logger.info(
|
237
|
+
shouldPrintDebug && logger.info(`Unknown component: ${variableName} = styled(${parentName}) attempting dynamic load: ${sourcePath}`);
|
517
238
|
var out = loadTamaguiSync({
|
518
239
|
forceExports: !0,
|
519
240
|
components: [
|
@@ -521,28 +242,33 @@ function createExtractor() {
|
|
521
242
|
],
|
522
243
|
cacheKey: version
|
523
244
|
});
|
524
|
-
if (!
|
525
|
-
shouldPrintDebug && logger.info(
|
245
|
+
if (!out?.components) {
|
246
|
+
shouldPrintDebug && logger.info(`Couldn't load, got ${out}`);
|
526
247
|
return;
|
527
248
|
}
|
528
|
-
if (propsWithFileInfo.allLoadedComponents =
|
249
|
+
if (propsWithFileInfo.allLoadedComponents = [
|
250
|
+
...propsWithFileInfo.allLoadedComponents,
|
251
|
+
...out.components
|
252
|
+
], Component = out.components.flatMap(function(x) {
|
529
253
|
var _x_nameToInfo_variableName;
|
530
254
|
return (_x_nameToInfo_variableName = x.nameToInfo[variableName]) !== null && _x_nameToInfo_variableName !== void 0 ? _x_nameToInfo_variableName : [];
|
531
255
|
})[0], !out.cached) {
|
532
256
|
var _out_components, foundNames = (_out_components = out.components) === null || _out_components === void 0 ? void 0 : _out_components.map(function(x) {
|
533
257
|
return Object.keys(x.nameToInfo).join(", ");
|
534
258
|
}).join(", ").trim();
|
535
|
-
foundNames && colorLog(Color.FgYellow,
|
259
|
+
foundNames && colorLog(Color.FgYellow, ` | Tamagui found dynamic components: ${foundNames}`);
|
536
260
|
}
|
537
261
|
} catch {
|
538
|
-
shouldPrintDebug && logger.info(
|
262
|
+
shouldPrintDebug && logger.info(`skip optimize styled(${variableName}), unable to pre-process (DEBUG=tamagui for more)`);
|
539
263
|
}
|
540
264
|
}
|
541
265
|
if (!Component) {
|
542
266
|
shouldPrintDebug && logger.info(" No component found");
|
543
267
|
return;
|
544
268
|
}
|
545
|
-
var componentSkipProps = new Set(
|
269
|
+
var componentSkipProps = /* @__PURE__ */ new Set([
|
270
|
+
...Component.staticConfig.inlineWhenUnflattened || [],
|
271
|
+
...Component.staticConfig.inlineProps || [],
|
546
272
|
// for now skip variants, will return to them
|
547
273
|
"variants",
|
548
274
|
"defaultVariants",
|
@@ -554,7 +280,7 @@ function createExtractor() {
|
|
554
280
|
"disabledStyle",
|
555
281
|
"hoverStyle",
|
556
282
|
"pressStyle"
|
557
|
-
])
|
283
|
+
]), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace = getStaticBindingsForScope(path.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug), attemptEval = evaluateVars ? createEvaluator({
|
558
284
|
props: propsWithFileInfo,
|
559
285
|
staticNamespace,
|
560
286
|
sourcePath,
|
@@ -582,10 +308,12 @@ function createExtractor() {
|
|
582
308
|
throw _iteratorError2;
|
583
309
|
}
|
584
310
|
}
|
585
|
-
var out2 = getSplitStyles(styles, Component.staticConfig, defaultTheme, "", componentState, styleProps, void 0, void 0, void 0, shouldPrintDebug), classNames =
|
311
|
+
var out2 = getSplitStyles(styles, Component.staticConfig, defaultTheme, "", componentState, styleProps, void 0, void 0, void 0, shouldPrintDebug), classNames = {
|
312
|
+
...out2.classNames
|
313
|
+
};
|
586
314
|
if (shouldPrintDebug && logger.info([
|
587
|
-
|
588
|
-
|
315
|
+
`Extracted styled(${variableName})
|
316
|
+
`,
|
589
317
|
JSON.stringify(styles, null, 2),
|
590
318
|
`
|
591
319
|
classNames:`,
|
@@ -601,58 +329,330 @@ function createExtractor() {
|
|
601
329
|
}), out2.rulesToInsert)
|
602
330
|
for (var key in out2.rulesToInsert) {
|
603
331
|
var styleObject = out2.rulesToInsert[key];
|
604
|
-
onStyleRule
|
332
|
+
onStyleRule?.(styleObject[StyleObjectIdentifier], styleObject[StyleObjectRules]);
|
605
333
|
}
|
606
|
-
res.styled++, shouldPrintDebug && logger.info(
|
334
|
+
res.styled++, shouldPrintDebug && logger.info(`Extracted styled(${variableName})`);
|
607
335
|
}
|
608
336
|
}
|
609
337
|
}
|
610
338
|
},
|
611
|
-
JSXElement
|
339
|
+
JSXElement(traversePath) {
|
612
340
|
tm.mark("jsx-element", !!shouldPrintDebug);
|
613
341
|
var node = traversePath.node.openingElement, ogAttributes = node.attributes.map(function(attr3) {
|
614
|
-
return
|
342
|
+
return {
|
343
|
+
...attr3
|
344
|
+
};
|
615
345
|
}), componentName = findComponentName(traversePath.scope), closingElement = traversePath.node.closingElement;
|
616
|
-
if (closingElement && t.isJSXMemberExpression(closingElement
|
346
|
+
if (closingElement && t.isJSXMemberExpression(closingElement?.name) || !t.isJSXIdentifier(node.name)) {
|
617
347
|
shouldPrintDebug && logger.info(" skip non-identifier element");
|
618
348
|
return;
|
619
349
|
}
|
620
350
|
var binding = traversePath.scope.getBinding(node.name.name), moduleName = "";
|
621
351
|
if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !isValidImport(propsWithFileInfo, moduleName, binding.identifier.name))) {
|
622
|
-
shouldPrintDebug && logger.info(
|
623
|
-
`)
|
352
|
+
shouldPrintDebug && logger.info(` - Binding in component ${componentName} not valid import: "${binding.identifier.name}" isn't in ${moduleName}
|
353
|
+
`);
|
624
354
|
return;
|
625
355
|
}
|
626
356
|
var component = getValidComponent(propsWithFileInfo, moduleName, node.name.name);
|
627
357
|
if (!component || !component.staticConfig) {
|
628
358
|
shouldPrintDebug && logger.info(`
|
629
|
-
- No Tamagui conf for:
|
630
|
-
`)
|
359
|
+
- No Tamagui conf for: ${node.name.name}
|
360
|
+
`);
|
631
361
|
return;
|
632
362
|
}
|
633
363
|
var originalNodeName = node.name.name;
|
634
364
|
res.found++;
|
635
|
-
var filePath =
|
365
|
+
var filePath = `./${relative(process.cwd(), sourcePath)}`, lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "", codePosition = `${filePath}:${lineNumbers}`, debugPropValue = node.attributes.filter(function(n) {
|
636
366
|
return t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug";
|
637
367
|
}).map(function(n) {
|
638
368
|
return n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1;
|
639
369
|
})[0];
|
640
|
-
if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(
|
370
|
+
if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`\x1B[33m\x1B[0m ${componentName} | ${codePosition} -------------------`), logger.info([
|
641
371
|
"\x1B[1m",
|
642
372
|
"\x1B[32m",
|
643
|
-
|
373
|
+
`<${originalNodeName} />`,
|
644
374
|
disableDebugAttr ? "" : "\u{1F41B}"
|
645
|
-
].join(" "))), shouldAddDebugProp && !disableDebugAttr && (res.modified++, node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(node.name.name))), componentName && node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-in"), t.stringLiteral(componentName))), node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-at"), t.stringLiteral(
|
646
|
-
shouldPrintDebug === "verbose" && logger.info(
|
647
|
-
`)
|
375
|
+
].join(" "))), shouldAddDebugProp && !disableDebugAttr && (res.modified++, node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(node.name.name))), componentName && node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-in"), t.stringLiteral(componentName))), node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-at"), t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)))), shouldDisableExtraction) {
|
376
|
+
shouldPrintDebug === "verbose" && logger.info(` \u274C Extraction disabled: ${JSON.stringify(disableExtraction)}
|
377
|
+
`);
|
648
378
|
return;
|
649
379
|
}
|
650
380
|
try {
|
651
|
-
let
|
381
|
+
let evaluateAttribute2 = function(path) {
|
382
|
+
var attribute = path.node, attr3 = {
|
383
|
+
type: "attr",
|
384
|
+
value: attribute
|
385
|
+
};
|
386
|
+
if (t.isJSXSpreadAttribute(attribute)) {
|
387
|
+
var arg = attribute.argument, conditional = t.isConditionalExpression(arg) ? (
|
388
|
+
// <YStack {...isSmall ? { color: 'red } : { color: 'blue }}
|
389
|
+
[
|
390
|
+
arg.test,
|
391
|
+
arg.consequent,
|
392
|
+
arg.alternate
|
393
|
+
]
|
394
|
+
) : t.isLogicalExpression(arg) && arg.operator === "&&" ? (
|
395
|
+
// <YStack {...isSmall && { color: 'red }}
|
396
|
+
[
|
397
|
+
arg.left,
|
398
|
+
arg.right,
|
399
|
+
null
|
400
|
+
]
|
401
|
+
) : null;
|
402
|
+
if (conditional) {
|
403
|
+
var [test, alt, cons] = conditional;
|
404
|
+
if (!test) throw new Error("no test");
|
405
|
+
return [
|
406
|
+
alt,
|
407
|
+
cons
|
408
|
+
].some(function(side) {
|
409
|
+
return side && !isStaticObject2(side);
|
410
|
+
}) ? (shouldPrintDebug && logger.info(`not extractable ${alt} ${cons}`), attr3) : [
|
411
|
+
...createTernariesFromObjectProperties2(test, alt) || [],
|
412
|
+
...cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || []
|
413
|
+
].map(function(ternary2) {
|
414
|
+
return {
|
415
|
+
type: "ternary",
|
416
|
+
value: ternary2
|
417
|
+
};
|
418
|
+
});
|
419
|
+
}
|
420
|
+
}
|
421
|
+
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string")
|
422
|
+
return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set(`${Math.random()}`, "spread"), attr3;
|
423
|
+
var name2 = attribute.name.name;
|
424
|
+
if (excludeProps?.has(name2))
|
425
|
+
return shouldPrintDebug && logger.info([
|
426
|
+
" excluding prop",
|
427
|
+
name2
|
428
|
+
].join(" ")), null;
|
429
|
+
if (inlineProps.has(name2))
|
430
|
+
return inlined.set(name2, name2), shouldPrintDebug && logger.info([
|
431
|
+
" ! inlining, inline prop",
|
432
|
+
name2
|
433
|
+
].join(" ")), attr3;
|
434
|
+
if (UNTOUCHED_PROPS[name2])
|
435
|
+
return attr3;
|
436
|
+
if (INLINE_EXTRACTABLE[name2])
|
437
|
+
return inlined.set(name2, INLINE_EXTRACTABLE[name2]), attr3;
|
438
|
+
if (name2.startsWith("data-"))
|
439
|
+
return attr3;
|
440
|
+
if ((name2 === "enterStyle" || name2 === "exitStyle") && t.isJSXExpressionContainer(attribute?.value))
|
441
|
+
return shouldDeopt = !0, attr3;
|
442
|
+
if (name2[0] === "$" && t.isJSXExpressionContainer(attribute?.value)) {
|
443
|
+
var shortname = name2.slice(1);
|
444
|
+
if (mediaQueryConfig[shortname]) {
|
445
|
+
if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia)
|
446
|
+
return attr3;
|
447
|
+
var expression = attribute.value.expression;
|
448
|
+
if (!t.isJSXEmptyExpression(expression)) {
|
449
|
+
var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(shortname), expression, {
|
450
|
+
inlineMediaQuery: shortname
|
451
|
+
});
|
452
|
+
if (ternaries2)
|
453
|
+
return ternaries2.map(function(value3) {
|
454
|
+
return {
|
455
|
+
type: "ternary",
|
456
|
+
value: value3
|
457
|
+
};
|
458
|
+
});
|
459
|
+
}
|
460
|
+
}
|
461
|
+
}
|
462
|
+
var [value2, valuePath] = function() {
|
463
|
+
return t.isJSXExpressionContainer(attribute?.value) ? [
|
464
|
+
attribute.value.expression,
|
465
|
+
path.get("value")
|
466
|
+
] : [
|
467
|
+
attribute.value,
|
468
|
+
path.get("value")
|
469
|
+
];
|
470
|
+
}(), remove = function() {
|
471
|
+
Array.isArray(valuePath) ? valuePath.map(function(p) {
|
472
|
+
return p.remove();
|
473
|
+
}) : valuePath.remove();
|
474
|
+
};
|
475
|
+
if (name2 === "ref")
|
476
|
+
return shouldPrintDebug && logger.info([
|
477
|
+
" ! inlining, ref",
|
478
|
+
name2
|
479
|
+
].join(" ")), inlined.set("ref", "ref"), attr3;
|
480
|
+
if (name2 === "tag")
|
481
|
+
return {
|
482
|
+
type: "attr",
|
483
|
+
value: path.node
|
484
|
+
};
|
485
|
+
if (disableExtractVariables === !0 && value2 && value2.type === "StringLiteral" && value2.value[0] === "$")
|
486
|
+
return shouldPrintDebug && logger.info([
|
487
|
+
` ! inlining, native disable extract: ${name2} =`,
|
488
|
+
value2.value
|
489
|
+
].join(" ")), inlined.set(name2, !0), attr3;
|
490
|
+
if (name2 === "theme")
|
491
|
+
return inlined.set("theme", attr3.value), attr3;
|
492
|
+
var styleValue = attemptEvalSafe(value2);
|
493
|
+
if (!variants[name2] && !isValidStyleKey(name2, staticConfig)) {
|
494
|
+
var keys = [
|
495
|
+
name2
|
496
|
+
], out = null;
|
497
|
+
out = propMapper(name2, styleValue, propMapperStyleState), out && (Array.isArray(out) ? (out = Object.fromEntries(out), keys = Object.keys(out)) : (logger.warn("Error expected array but got", out), couldntParse = !0, shouldDeopt = !0)), out && (isTargetingHTML && (out = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
|
498
|
+
var didInline = !1, attributes = keys.map(function(key9) {
|
499
|
+
var val2 = out[key9], isStyle = isValidStyleKey(key9, staticConfig);
|
500
|
+
return isStyle ? {
|
501
|
+
type: "style",
|
502
|
+
value: {
|
503
|
+
[key9]: styleValue
|
504
|
+
},
|
505
|
+
name: key9,
|
506
|
+
attr: path.node
|
507
|
+
} : validHTMLAttributes[key9] || key9.startsWith("aria-") || key9.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
|
508
|
+
key9 === "__source" || key9 === "__self" ? attr3 : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key9), didInline = !0, inlined.set(key9, val2), val2);
|
509
|
+
});
|
510
|
+
return didInline ? (shouldPrintDebug && logger.info(` bailing flattening due to attributes ${attributes.map(function(x) {
|
511
|
+
return x.toString();
|
512
|
+
})}`), attr3) : attributes;
|
513
|
+
}
|
514
|
+
if (styleValue !== FAILED_EVAL)
|
515
|
+
return inlineWhenUnflattened.has(name2) && (inlineWhenUnflattenedOGVals[name2] = {
|
516
|
+
styleValue,
|
517
|
+
attr: attr3
|
518
|
+
}), isValidStyleKey(name2, staticConfig) ? (shouldPrintDebug && logger.info(` style: ${name2} = ${styleValue}`), name2 in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
|
519
|
+
type: "style",
|
520
|
+
value: {
|
521
|
+
[name2]: styleValue
|
522
|
+
},
|
523
|
+
name: name2,
|
524
|
+
attr: path.node
|
525
|
+
}) : (variants[name2] && variantValues.set(name2, styleValue), inlined.set(name2, !0), attr3);
|
526
|
+
if (t.isBinaryExpression(value2)) {
|
527
|
+
shouldPrintDebug && logger.info(` binary expression ${name2} = ${value2}`);
|
528
|
+
var { operator, left, right } = value2, lVal = attemptEvalSafe(left), rVal = attemptEvalSafe(right);
|
529
|
+
if (shouldPrintDebug && logger.info(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
|
530
|
+
var ternary = addBinaryConditional(operator, left, right);
|
531
|
+
if (ternary) return ternary;
|
532
|
+
}
|
533
|
+
if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
|
534
|
+
var ternary1 = addBinaryConditional(operator, right, left);
|
535
|
+
if (ternary1) return ternary1;
|
536
|
+
}
|
537
|
+
return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name2, !0), attr3;
|
538
|
+
}
|
539
|
+
var staticConditional = getStaticConditional(value2);
|
540
|
+
if (staticConditional)
|
541
|
+
return shouldPrintDebug === "verbose" && logger.info(` static conditional ${name2} ${value2}`), {
|
542
|
+
type: "ternary",
|
543
|
+
value: staticConditional
|
544
|
+
};
|
545
|
+
var staticLogical = getStaticLogical(value2);
|
546
|
+
if (staticLogical)
|
547
|
+
return shouldPrintDebug === "verbose" && logger.info(` static ternary ${name2} = ${value2}`), {
|
548
|
+
type: "ternary",
|
549
|
+
value: staticLogical
|
550
|
+
};
|
551
|
+
if (options.experimentalFlattenDynamicValues && isValidStyleKey(name2, staticConfig))
|
552
|
+
return {
|
553
|
+
type: "dynamic-style",
|
554
|
+
value: value2,
|
555
|
+
name: tamaguiConfig?.shorthands[name2] || name2
|
556
|
+
};
|
557
|
+
return inlined.set(name2, !0), shouldPrintDebug && logger.info(` ! inline no match ${name2} ${value2}`), attr3;
|
558
|
+
function addBinaryConditional(operator2, staticExpr, cond) {
|
559
|
+
if (getStaticConditional(cond)) {
|
560
|
+
var alt2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.alternate)), cons2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.consequent));
|
561
|
+
return shouldPrintDebug && logger.info([
|
562
|
+
" binaryConditional",
|
563
|
+
cond.test,
|
564
|
+
cons2,
|
565
|
+
alt2
|
566
|
+
].join(" ")), {
|
567
|
+
type: "ternary",
|
568
|
+
value: {
|
569
|
+
test: cond.test,
|
570
|
+
remove,
|
571
|
+
alternate: {
|
572
|
+
[name2]: alt2
|
573
|
+
},
|
574
|
+
consequent: {
|
575
|
+
[name2]: cons2
|
576
|
+
}
|
577
|
+
}
|
578
|
+
};
|
579
|
+
}
|
580
|
+
return null;
|
581
|
+
}
|
582
|
+
function getStaticConditional(value3) {
|
583
|
+
if (t.isConditionalExpression(value3))
|
584
|
+
try {
|
585
|
+
var aVal = attemptEval(value3.alternate), cVal = attemptEval(value3.consequent);
|
586
|
+
if (shouldPrintDebug) {
|
587
|
+
var type = value3.test.type;
|
588
|
+
logger.info([
|
589
|
+
" static ternary",
|
590
|
+
type,
|
591
|
+
cVal,
|
592
|
+
aVal
|
593
|
+
].join(" "));
|
594
|
+
}
|
595
|
+
return {
|
596
|
+
test: value3.test,
|
597
|
+
remove,
|
598
|
+
consequent: {
|
599
|
+
[name2]: cVal
|
600
|
+
},
|
601
|
+
alternate: {
|
602
|
+
[name2]: aVal
|
603
|
+
}
|
604
|
+
};
|
605
|
+
} catch (err) {
|
606
|
+
shouldPrintDebug && logger.info([
|
607
|
+
" cant eval ternary",
|
608
|
+
err.message
|
609
|
+
].join(" "));
|
610
|
+
}
|
611
|
+
return null;
|
612
|
+
}
|
613
|
+
function getStaticLogical(value3) {
|
614
|
+
if (t.isLogicalExpression(value3) && value3.operator === "&&")
|
615
|
+
try {
|
616
|
+
var val2 = attemptEval(value3.right);
|
617
|
+
return shouldPrintDebug && logger.info([
|
618
|
+
" staticLogical",
|
619
|
+
value3.left,
|
620
|
+
name2,
|
621
|
+
val2
|
622
|
+
].join(" ")), {
|
623
|
+
test: value3.left,
|
624
|
+
remove,
|
625
|
+
consequent: {
|
626
|
+
[name2]: val2
|
627
|
+
},
|
628
|
+
alternate: null
|
629
|
+
};
|
630
|
+
} catch (err) {
|
631
|
+
shouldPrintDebug && logger.info([
|
632
|
+
" cant static eval logical",
|
633
|
+
err
|
634
|
+
].join(" "));
|
635
|
+
}
|
636
|
+
return null;
|
637
|
+
}
|
638
|
+
}, isStaticObject2 = function(obj) {
|
639
|
+
return t.isObjectExpression(obj) && obj.properties.every(function(prop) {
|
640
|
+
if (!t.isObjectProperty(prop))
|
641
|
+
return logger.info([
|
642
|
+
"not object prop",
|
643
|
+
prop
|
644
|
+
].join(" ")), !1;
|
645
|
+
var propName = prop.key.name;
|
646
|
+
return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([
|
647
|
+
" not a valid style prop!",
|
648
|
+
propName
|
649
|
+
].join(" ")), !1) : !0;
|
650
|
+
});
|
651
|
+
}, createTernariesFromObjectProperties2 = function(test, side) {
|
652
652
|
var ternaryPartial = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
653
653
|
if (!side)
|
654
654
|
return null;
|
655
|
-
if (!
|
655
|
+
if (!isStaticObject2(side))
|
656
656
|
throw new Error("not extractable");
|
657
657
|
return side.properties.flatMap(function(property) {
|
658
658
|
if (!t.isObjectProperty(property))
|
@@ -666,10 +666,12 @@ function createExtractor() {
|
|
666
666
|
});
|
667
667
|
if (ternaries2)
|
668
668
|
return ternaries2.map(function(value2) {
|
669
|
-
return
|
669
|
+
return {
|
670
|
+
...ternaryPartial,
|
671
|
+
...value2,
|
670
672
|
// ensure media query test stays on left side (see getMediaQueryTernary)
|
671
673
|
test: t.logicalExpression("&&", value2.test, test)
|
672
|
-
}
|
674
|
+
};
|
673
675
|
});
|
674
676
|
logger.info([
|
675
677
|
"\u26A0\uFE0F no ternaries?",
|
@@ -682,7 +684,7 @@ function createExtractor() {
|
|
682
684
|
].join(" "));
|
683
685
|
}
|
684
686
|
if (t.isConditionalExpression(property.value)) {
|
685
|
-
var
|
687
|
+
var [truthy, falsy] = [
|
686
688
|
t.objectExpression([
|
687
689
|
t.objectProperty(property.key, property.value.consequent)
|
688
690
|
]),
|
@@ -691,356 +693,102 @@ function createExtractor() {
|
|
691
693
|
])
|
692
694
|
].map(function(x) {
|
693
695
|
return attemptEval(x);
|
694
|
-
})
|
696
|
+
});
|
695
697
|
return [
|
696
|
-
createTernary(
|
697
|
-
remove
|
698
|
-
}
|
699
|
-
|
698
|
+
createTernary({
|
699
|
+
remove() {
|
700
|
+
},
|
701
|
+
...ternaryPartial,
|
700
702
|
test: t.logicalExpression("&&", test, property.value.test),
|
701
703
|
consequent: truthy,
|
702
704
|
alternate: null
|
703
|
-
})
|
704
|
-
createTernary(
|
705
|
+
}),
|
706
|
+
createTernary({
|
707
|
+
...ternaryPartial,
|
705
708
|
test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
|
706
709
|
consequent: falsy,
|
707
710
|
alternate: null,
|
708
|
-
remove
|
711
|
+
remove() {
|
709
712
|
}
|
710
|
-
})
|
713
|
+
})
|
711
714
|
];
|
712
715
|
}
|
713
716
|
var obj = t.objectExpression([
|
714
717
|
t.objectProperty(property.key, property.value)
|
715
718
|
]), consequent = attemptEval(obj);
|
716
|
-
return createTernary(
|
717
|
-
remove
|
718
|
-
}
|
719
|
-
|
719
|
+
return createTernary({
|
720
|
+
remove() {
|
721
|
+
},
|
722
|
+
...ternaryPartial,
|
720
723
|
test,
|
721
724
|
consequent,
|
722
725
|
alternate: null
|
723
|
-
}));
|
724
|
-
});
|
725
|
-
};
|
726
|
-
var createTernariesFromObjectProperties = createTernariesFromObjectProperties2, evaluateAttribute = (
|
727
|
-
// START function evaluateAttribute
|
728
|
-
function(path) {
|
729
|
-
var attribute = path.node, attr3 = {
|
730
|
-
type: "attr",
|
731
|
-
value: attribute
|
732
|
-
};
|
733
|
-
if (t.isJSXSpreadAttribute(attribute)) {
|
734
|
-
var arg = attribute.argument, conditional = t.isConditionalExpression(arg) ? (
|
735
|
-
// <YStack {...isSmall ? { color: 'red } : { color: 'blue }}
|
736
|
-
[
|
737
|
-
arg.test,
|
738
|
-
arg.consequent,
|
739
|
-
arg.alternate
|
740
|
-
]
|
741
|
-
) : t.isLogicalExpression(arg) && arg.operator === "&&" ? (
|
742
|
-
// <YStack {...isSmall && { color: 'red }}
|
743
|
-
[
|
744
|
-
arg.left,
|
745
|
-
arg.right,
|
746
|
-
null
|
747
|
-
]
|
748
|
-
) : null;
|
749
|
-
if (conditional) {
|
750
|
-
var _conditional = _sliced_to_array(conditional, 3), test = _conditional[0], alt = _conditional[1], cons = _conditional[2];
|
751
|
-
if (!test) throw new Error("no test");
|
752
|
-
return [
|
753
|
-
alt,
|
754
|
-
cons
|
755
|
-
].some(function(side) {
|
756
|
-
return side && !isStaticObject(side);
|
757
|
-
}) ? (shouldPrintDebug && logger.info("not extractable ".concat(alt, " ").concat(cons)), attr3) : _to_consumable_array(createTernariesFromObjectProperties2(test, alt) || []).concat(_to_consumable_array(cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || [])).map(function(ternary2) {
|
758
|
-
return {
|
759
|
-
type: "ternary",
|
760
|
-
value: ternary2
|
761
|
-
};
|
762
|
-
});
|
763
|
-
}
|
764
|
-
}
|
765
|
-
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string")
|
766
|
-
return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set("".concat(Math.random()), "spread"), attr3;
|
767
|
-
var name2 = attribute.name.name;
|
768
|
-
if (excludeProps != null && excludeProps.has(name2))
|
769
|
-
return shouldPrintDebug && logger.info([
|
770
|
-
" excluding prop",
|
771
|
-
name2
|
772
|
-
].join(" ")), null;
|
773
|
-
if (inlineProps.has(name2))
|
774
|
-
return inlined.set(name2, name2), shouldPrintDebug && logger.info([
|
775
|
-
" ! inlining, inline prop",
|
776
|
-
name2
|
777
|
-
].join(" ")), attr3;
|
778
|
-
if (UNTOUCHED_PROPS[name2])
|
779
|
-
return attr3;
|
780
|
-
if (INLINE_EXTRACTABLE[name2])
|
781
|
-
return inlined.set(name2, INLINE_EXTRACTABLE[name2]), attr3;
|
782
|
-
if (name2.startsWith("data-"))
|
783
|
-
return attr3;
|
784
|
-
if ((name2 === "enterStyle" || name2 === "exitStyle") && t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value))
|
785
|
-
return shouldDeopt = !0, attr3;
|
786
|
-
if (name2[0] === "$" && t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
|
787
|
-
var shortname = name2.slice(1);
|
788
|
-
if (mediaQueryConfig[shortname]) {
|
789
|
-
if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia)
|
790
|
-
return attr3;
|
791
|
-
var expression = attribute.value.expression;
|
792
|
-
if (!t.isJSXEmptyExpression(expression)) {
|
793
|
-
var ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(shortname), expression, {
|
794
|
-
inlineMediaQuery: shortname
|
795
|
-
});
|
796
|
-
if (ternaries2)
|
797
|
-
return ternaries2.map(function(value3) {
|
798
|
-
return {
|
799
|
-
type: "ternary",
|
800
|
-
value: value3
|
801
|
-
};
|
802
|
-
});
|
803
|
-
}
|
804
|
-
}
|
805
|
-
}
|
806
|
-
var _ref2 = _sliced_to_array(function() {
|
807
|
-
return t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value) ? [
|
808
|
-
attribute.value.expression,
|
809
|
-
path.get("value")
|
810
|
-
] : [
|
811
|
-
attribute.value,
|
812
|
-
path.get("value")
|
813
|
-
];
|
814
|
-
}(), 2), value2 = _ref2[0], valuePath = _ref2[1], remove = function() {
|
815
|
-
Array.isArray(valuePath) ? valuePath.map(function(p) {
|
816
|
-
return p.remove();
|
817
|
-
}) : valuePath.remove();
|
818
|
-
};
|
819
|
-
if (name2 === "ref")
|
820
|
-
return shouldPrintDebug && logger.info([
|
821
|
-
" ! inlining, ref",
|
822
|
-
name2
|
823
|
-
].join(" ")), inlined.set("ref", "ref"), attr3;
|
824
|
-
if (name2 === "tag")
|
825
|
-
return {
|
826
|
-
type: "attr",
|
827
|
-
value: path.node
|
828
|
-
};
|
829
|
-
if (disableExtractVariables === !0 && value2 && value2.type === "StringLiteral" && value2.value[0] === "$")
|
830
|
-
return shouldPrintDebug && logger.info([
|
831
|
-
" ! inlining, native disable extract: ".concat(name2, " ="),
|
832
|
-
value2.value
|
833
|
-
].join(" ")), inlined.set(name2, !0), attr3;
|
834
|
-
if (name2 === "theme")
|
835
|
-
return inlined.set("theme", attr3.value), attr3;
|
836
|
-
var styleValue = attemptEvalSafe(value2);
|
837
|
-
if (!variants[name2] && !isValidStyleKey(name2, staticConfig)) {
|
838
|
-
var keys = [
|
839
|
-
name2
|
840
|
-
], out = null;
|
841
|
-
out = propMapper(name2, styleValue, propMapperStyleState), out && (Array.isArray(out) ? (out = Object.fromEntries(out), keys = Object.keys(out)) : (logger.warn("Error expected array but got", out), couldntParse = !0, shouldDeopt = !0)), out && (isTargetingHTML && (out = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
|
842
|
-
var didInline = !1, attributes = keys.map(function(key9) {
|
843
|
-
var val2 = out[key9], isStyle = isValidStyleKey(key9, staticConfig);
|
844
|
-
return isStyle ? {
|
845
|
-
type: "style",
|
846
|
-
value: _define_property({}, key9, styleValue),
|
847
|
-
name: key9,
|
848
|
-
attr: path.node
|
849
|
-
} : validHTMLAttributes[key9] || key9.startsWith("aria-") || key9.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
|
850
|
-
key9 === "__source" || key9 === "__self" ? attr3 : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key9), didInline = !0, inlined.set(key9, val2), val2);
|
851
|
-
});
|
852
|
-
return didInline ? (shouldPrintDebug && logger.info(" bailing flattening due to attributes ".concat(attributes.map(function(x) {
|
853
|
-
return x.toString();
|
854
|
-
}))), attr3) : attributes;
|
855
|
-
}
|
856
|
-
if (styleValue !== FAILED_EVAL)
|
857
|
-
return inlineWhenUnflattened.has(name2) && (inlineWhenUnflattenedOGVals[name2] = {
|
858
|
-
styleValue,
|
859
|
-
attr: attr3
|
860
|
-
}), isValidStyleKey(name2, staticConfig) ? (shouldPrintDebug && logger.info(" style: ".concat(name2, " = ").concat(styleValue)), name2 in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
|
861
|
-
type: "style",
|
862
|
-
value: _define_property({}, name2, styleValue),
|
863
|
-
name: name2,
|
864
|
-
attr: path.node
|
865
|
-
}) : (variants[name2] && variantValues.set(name2, styleValue), inlined.set(name2, !0), attr3);
|
866
|
-
if (t.isBinaryExpression(value2)) {
|
867
|
-
shouldPrintDebug && logger.info(" binary expression ".concat(name2, " = ").concat(value2));
|
868
|
-
var operator = value2.operator, left = value2.left, right = value2.right, lVal = attemptEvalSafe(left), rVal = attemptEvalSafe(right);
|
869
|
-
if (shouldPrintDebug && logger.info(" evalBinaryExpression lVal ".concat(String(lVal), ", rVal ").concat(String(rVal))), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
|
870
|
-
var ternary = addBinaryConditional(operator, left, right);
|
871
|
-
if (ternary) return ternary;
|
872
|
-
}
|
873
|
-
if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
|
874
|
-
var ternary1 = addBinaryConditional(operator, right, left);
|
875
|
-
if (ternary1) return ternary1;
|
876
|
-
}
|
877
|
-
return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name2, !0), attr3;
|
878
|
-
}
|
879
|
-
var staticConditional = getStaticConditional(value2);
|
880
|
-
if (staticConditional)
|
881
|
-
return shouldPrintDebug === "verbose" && logger.info(" static conditional ".concat(name2, " ").concat(value2)), {
|
882
|
-
type: "ternary",
|
883
|
-
value: staticConditional
|
884
|
-
};
|
885
|
-
var staticLogical = getStaticLogical(value2);
|
886
|
-
if (staticLogical)
|
887
|
-
return shouldPrintDebug === "verbose" && logger.info(" static ternary ".concat(name2, " = ").concat(value2)), {
|
888
|
-
type: "ternary",
|
889
|
-
value: staticLogical
|
890
|
-
};
|
891
|
-
if (options.experimentalFlattenDynamicValues && isValidStyleKey(name2, staticConfig))
|
892
|
-
return {
|
893
|
-
type: "dynamic-style",
|
894
|
-
value: value2,
|
895
|
-
name: (tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[name2]) || name2
|
896
|
-
};
|
897
|
-
return inlined.set(name2, !0), shouldPrintDebug && logger.info(" ! inline no match ".concat(name2, " ").concat(value2)), attr3;
|
898
|
-
function addBinaryConditional(operator2, staticExpr, cond) {
|
899
|
-
if (getStaticConditional(cond)) {
|
900
|
-
var alt2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.alternate)), cons2 = attemptEval(t.binaryExpression(operator2, staticExpr, cond.consequent));
|
901
|
-
return shouldPrintDebug && logger.info([
|
902
|
-
" binaryConditional",
|
903
|
-
cond.test,
|
904
|
-
cons2,
|
905
|
-
alt2
|
906
|
-
].join(" ")), {
|
907
|
-
type: "ternary",
|
908
|
-
value: {
|
909
|
-
test: cond.test,
|
910
|
-
remove,
|
911
|
-
alternate: _define_property({}, name2, alt2),
|
912
|
-
consequent: _define_property({}, name2, cons2)
|
913
|
-
}
|
914
|
-
};
|
915
|
-
}
|
916
|
-
return null;
|
917
|
-
}
|
918
|
-
function getStaticConditional(value3) {
|
919
|
-
if (t.isConditionalExpression(value3))
|
920
|
-
try {
|
921
|
-
var aVal = attemptEval(value3.alternate), cVal = attemptEval(value3.consequent);
|
922
|
-
if (shouldPrintDebug) {
|
923
|
-
var type = value3.test.type;
|
924
|
-
logger.info([
|
925
|
-
" static ternary",
|
926
|
-
type,
|
927
|
-
cVal,
|
928
|
-
aVal
|
929
|
-
].join(" "));
|
930
|
-
}
|
931
|
-
return {
|
932
|
-
test: value3.test,
|
933
|
-
remove,
|
934
|
-
consequent: _define_property({}, name2, cVal),
|
935
|
-
alternate: _define_property({}, name2, aVal)
|
936
|
-
};
|
937
|
-
} catch (err) {
|
938
|
-
shouldPrintDebug && logger.info([
|
939
|
-
" cant eval ternary",
|
940
|
-
err.message
|
941
|
-
].join(" "));
|
942
|
-
}
|
943
|
-
return null;
|
944
|
-
}
|
945
|
-
function getStaticLogical(value3) {
|
946
|
-
if (t.isLogicalExpression(value3) && value3.operator === "&&")
|
947
|
-
try {
|
948
|
-
var val2 = attemptEval(value3.right);
|
949
|
-
return shouldPrintDebug && logger.info([
|
950
|
-
" staticLogical",
|
951
|
-
value3.left,
|
952
|
-
name2,
|
953
|
-
val2
|
954
|
-
].join(" ")), {
|
955
|
-
test: value3.left,
|
956
|
-
remove,
|
957
|
-
consequent: _define_property({}, name2, val2),
|
958
|
-
alternate: null
|
959
|
-
};
|
960
|
-
} catch (err) {
|
961
|
-
shouldPrintDebug && logger.info([
|
962
|
-
" cant static eval logical",
|
963
|
-
err
|
964
|
-
].join(" "));
|
965
|
-
}
|
966
|
-
return null;
|
967
|
-
}
|
968
|
-
}
|
969
|
-
), isStaticObject = (
|
970
|
-
// END function evaluateAttribute
|
971
|
-
function(obj) {
|
972
|
-
return t.isObjectExpression(obj) && obj.properties.every(function(prop) {
|
973
|
-
if (!t.isObjectProperty(prop))
|
974
|
-
return logger.info([
|
975
|
-
"not object prop",
|
976
|
-
prop
|
977
|
-
].join(" ")), !1;
|
978
|
-
var propName = prop.key.name;
|
979
|
-
return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([
|
980
|
-
" not a valid style prop!",
|
981
|
-
propName
|
982
|
-
].join(" ")), !1) : !0;
|
983
726
|
});
|
984
|
-
}
|
985
|
-
|
727
|
+
});
|
728
|
+
}, mergeToEnd2 = function(obj, key9, val2) {
|
986
729
|
key9 in obj && delete obj[key9], obj[key9] = val2;
|
987
|
-
},
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
), mergeStyles = function(prev2, next) {
|
730
|
+
}, normalizeStyleWithoutVariants2 = function(style) {
|
731
|
+
var res2 = {};
|
732
|
+
for (var key9 in style)
|
733
|
+
if (staticConfig.variants && key9 in staticConfig.variants)
|
734
|
+
mergeToEnd2(res2, key9, style[key9]);
|
735
|
+
else {
|
736
|
+
var expanded2 = normalizeStyle({
|
737
|
+
[key9]: style[key9]
|
738
|
+
}, !0);
|
739
|
+
for (var key12 in expanded2)
|
740
|
+
mergeToEnd2(res2, key12, expanded2[key12]);
|
741
|
+
}
|
742
|
+
return res2;
|
743
|
+
}, mergeStyles2 = function(prev2, next) {
|
1002
744
|
for (var key9 in next)
|
1003
|
-
pseudoDescriptors[key9] ? (prev2[key9] = prev2[key9] || {}, Object.assign(prev2[key9], next[key9])) :
|
1004
|
-
}
|
745
|
+
pseudoDescriptors[key9] ? (prev2[key9] = prev2[key9] || {}, Object.assign(prev2[key9], next[key9])) : mergeToEnd2(prev2, key9, next[key9]);
|
746
|
+
};
|
747
|
+
var evaluateAttribute = evaluateAttribute2, isStaticObject = isStaticObject2, createTernariesFromObjectProperties = createTernariesFromObjectProperties2, mergeToEnd = mergeToEnd2, normalizeStyleWithoutVariants = normalizeStyleWithoutVariants2, mergeStyles = mergeStyles2, { staticConfig } = component, defaultProps = {
|
748
|
+
...staticConfig.defaultProps || {}
|
749
|
+
}, variants = staticConfig.variants || {}, isTextView = staticConfig.isText || !1, _staticConfig_validStyles, validStyles = (_staticConfig_validStyles = staticConfig?.validStyles) !== null && _staticConfig_validStyles !== void 0 ? _staticConfig_validStyles : {}, _defaultProps_tag, tagName = (_defaultProps_tag = defaultProps.tag) !== null && _defaultProps_tag !== void 0 ? _defaultProps_tag : isTextView ? "span" : "div";
|
1005
750
|
traversePath.get("openingElement").get("attributes").forEach(function(path) {
|
1006
751
|
var attr3 = path.node;
|
1007
752
|
if (!t.isJSXSpreadAttribute(attr3) && attr3.name.name === "tag") {
|
1008
753
|
var val2 = attr3.value;
|
1009
754
|
t.isStringLiteral(val2) && (tagName = val2.value);
|
1010
755
|
}
|
1011
|
-
}), shouldPrintDebug === "verbose" && console.info(
|
1012
|
-
var flatNode = getFlattenedNode
|
756
|
+
}), shouldPrintDebug === "verbose" && console.info(` Start tag ${tagName}`);
|
757
|
+
var flatNode = getFlattenedNode?.({
|
1013
758
|
isTextView,
|
1014
759
|
tag: tagName
|
1015
|
-
}), inlineProps = new Set([
|
760
|
+
}), inlineProps = /* @__PURE__ */ new Set([
|
1016
761
|
// adding some always inline props
|
1017
|
-
"dataSet"
|
1018
|
-
|
762
|
+
"dataSet",
|
763
|
+
...restProps.inlineProps || [],
|
764
|
+
...staticConfig.inlineProps || []
|
765
|
+
]), deoptProps = /* @__PURE__ */ new Set([
|
1019
766
|
// always de-opt animation these
|
1020
767
|
"animation",
|
1021
768
|
"animateOnly",
|
1022
769
|
"animatePresence",
|
1023
|
-
"disableOptimization"
|
1024
|
-
|
1025
|
-
_to_consumable_array(isTargetingHTML ? [] : [
|
770
|
+
"disableOptimization",
|
771
|
+
...isTargetingHTML ? [] : [
|
1026
772
|
"pressStyle",
|
1027
773
|
"focusStyle",
|
1028
774
|
"focusVisibleStyle",
|
1029
775
|
"disabledStyle"
|
1030
|
-
]
|
776
|
+
],
|
1031
777
|
// when using a non-CSS driver, de-opt on enterStyle/exitStyle
|
1032
|
-
|
778
|
+
...tamaguiConfig?.animations.isReactNative ? [
|
1033
779
|
"enterStyle",
|
1034
780
|
"exitStyle"
|
1035
|
-
] : []
|
1036
|
-
)
|
781
|
+
] : []
|
782
|
+
]), inlineWhenUnflattened = /* @__PURE__ */ new Set([
|
783
|
+
...staticConfig.inlineWhenUnflattened || []
|
784
|
+
]), staticNamespace = getStaticBindingsForScope(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug), attemptEval = evaluateVars ? createEvaluator({
|
1037
785
|
props: propsWithFileInfo,
|
1038
786
|
staticNamespace,
|
1039
787
|
sourcePath,
|
1040
788
|
traversePath,
|
1041
789
|
shouldPrintDebug
|
1042
790
|
}) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
|
1043
|
-
if (shouldPrintDebug && logger.info(
|
791
|
+
if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse)
|
1044
792
|
return;
|
1045
793
|
tm.mark("jsx-element-flattened", !!shouldPrintDebug);
|
1046
794
|
var attrs = [], shouldDeopt = !1, inlined = /* @__PURE__ */ new Map(), variantValues = /* @__PURE__ */ new Map(), hasSetOptimized = !1, inlineWhenUnflattenedOGVals = {}, propMapperStyleState = {
|
@@ -1053,14 +801,15 @@ function createExtractor() {
|
|
1053
801
|
conf: tamaguiConfig,
|
1054
802
|
props: defaultProps,
|
1055
803
|
componentState,
|
1056
|
-
styleProps:
|
804
|
+
styleProps: {
|
805
|
+
...styleProps,
|
1057
806
|
resolveValues: "auto"
|
1058
|
-
}
|
807
|
+
},
|
1059
808
|
debug: shouldPrintDebug
|
1060
809
|
};
|
1061
810
|
if (attrs = traversePath.get("openingElement").get("attributes").flatMap(function(path) {
|
1062
811
|
try {
|
1063
|
-
var res2 =
|
812
|
+
var res2 = evaluateAttribute2(path);
|
1064
813
|
return tm.mark("jsx-element-evaluate-attr", !!shouldPrintDebug), res2 || path.remove(), res2;
|
1065
814
|
} catch (err) {
|
1066
815
|
if (shouldPrintDebug && (logger.info([
|
@@ -1069,9 +818,9 @@ function createExtractor() {
|
|
1069
818
|
shouldPrintDebug === "verbose" ? err.stack : ""
|
1070
819
|
].join(" ")), shouldPrintDebug === "verbose")) {
|
1071
820
|
var _path_node;
|
1072
|
-
logger.info(
|
821
|
+
logger.info(`node ${(_path_node = path.node) === null || _path_node === void 0 ? void 0 : _path_node.type}`);
|
1073
822
|
}
|
1074
|
-
return inlined.set(
|
823
|
+
return inlined.set(`${Math.random()}`, "spread"), {
|
1075
824
|
type: "attr",
|
1076
825
|
value: path.node
|
1077
826
|
};
|
@@ -1098,21 +847,11 @@ function createExtractor() {
|
|
1098
847
|
return x.type === "JSXText";
|
1099
848
|
})), themeVal = inlined.get("theme");
|
1100
849
|
platform2 !== "native" && inlined.delete("theme");
|
1101
|
-
var
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
}
|
1107
|
-
} catch (err) {
|
1108
|
-
_didIteratorError2 = !0, _iteratorError2 = err;
|
1109
|
-
} finally {
|
1110
|
-
try {
|
1111
|
-
!_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
|
1112
|
-
} finally {
|
1113
|
-
if (_didIteratorError2)
|
1114
|
-
throw _iteratorError2;
|
1115
|
-
}
|
850
|
+
for (var _i = 0, _iter = [
|
851
|
+
...inlined
|
852
|
+
]; _i < _iter.length; _i++) {
|
853
|
+
var [key] = _iter[_i], _staticConfig_variants, isStaticObjectVariant = ((_staticConfig_variants = staticConfig.variants) === null || _staticConfig_variants === void 0 ? void 0 : _staticConfig_variants[key]) && variantValues.has(key);
|
854
|
+
(INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
|
1116
855
|
}
|
1117
856
|
var canFlattenProps = inlined.size === 0, shouldFlatten = !!(flatNode && !shouldDeopt && canFlattenProps && !hasSpread && !staticConfig.isStyledHOC && !staticConfig.isHOC && !staticConfig.isReactNative && staticConfig.neverFlatten !== !0 && (staticConfig.neverFlatten !== "jsx" || hasOnlyStringChildren)), usedThemeKeys = /* @__PURE__ */ new Set();
|
1118
857
|
if (themeAccessListeners.add(function(key9) {
|
@@ -1132,13 +871,13 @@ function createExtractor() {
|
|
1132
871
|
}, [];
|
1133
872
|
if (!isValidStyleKey(key9, staticConfig))
|
1134
873
|
return [];
|
1135
|
-
var name2 =
|
874
|
+
var name2 = tamaguiConfig?.shorthands[key9] || key9;
|
1136
875
|
if (value2 === void 0) {
|
1137
|
-
logger.warn(
|
876
|
+
logger.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key9} ${value2}`), shouldDeopt = !0;
|
1138
877
|
return;
|
1139
878
|
}
|
1140
879
|
if (name2[0] === "$" && mediaQueryConfig[name2.slice(1)])
|
1141
|
-
return defaultProps[key9] = void 0,
|
880
|
+
return defaultProps[key9] = void 0, evaluateAttribute2({
|
1142
881
|
node: t.jsxAttribute(t.jsxIdentifier(name2), t.jsxExpressionContainer(t.objectExpression(Object.keys(value2).filter(function(k) {
|
1143
882
|
return typeof value2[k] < "u";
|
1144
883
|
}).map(function(k) {
|
@@ -1148,33 +887,39 @@ function createExtractor() {
|
|
1148
887
|
var attr3 = {
|
1149
888
|
type: "style",
|
1150
889
|
name: name2,
|
1151
|
-
value:
|
890
|
+
value: {
|
891
|
+
[name2]: value2
|
892
|
+
}
|
1152
893
|
};
|
1153
894
|
return attr3;
|
1154
895
|
});
|
1155
|
-
skipMap || defaultStyleAttrs.length && (attrs =
|
896
|
+
skipMap || defaultStyleAttrs.length && (attrs = [
|
897
|
+
...defaultStyleAttrs,
|
898
|
+
...attrs
|
899
|
+
]);
|
1156
900
|
}
|
1157
901
|
var ternaries = [];
|
1158
902
|
attrs = attrs.reduce(function(out, cur2) {
|
1159
903
|
var next = attrs[attrs.indexOf(cur2) + 1];
|
1160
904
|
if (cur2.type === "ternary" && ternaries.push(cur2.value), (!next || next.type !== "ternary") && ternaries.length) {
|
1161
|
-
var normalized = normalizeTernaries(ternaries).map(function(
|
1162
|
-
var
|
1163
|
-
"alternate",
|
1164
|
-
"consequent"
|
1165
|
-
]);
|
905
|
+
var normalized = normalizeTernaries(ternaries).map(function(param2) {
|
906
|
+
var { alternate, consequent, ...rest } = param2;
|
1166
907
|
return {
|
1167
908
|
type: "ternary",
|
1168
|
-
value:
|
909
|
+
value: {
|
910
|
+
...rest,
|
1169
911
|
alternate: alternate || null,
|
1170
912
|
consequent: consequent || null
|
1171
|
-
}
|
913
|
+
}
|
1172
914
|
};
|
1173
915
|
});
|
1174
916
|
try {
|
1175
|
-
return
|
917
|
+
return [
|
918
|
+
...out,
|
919
|
+
...normalized
|
920
|
+
];
|
1176
921
|
} finally {
|
1177
|
-
shouldPrintDebug && logger.info(
|
922
|
+
shouldPrintDebug && logger.info(` normalizeTernaries (${ternaries.length} => ${normalized.length})`), ternaries = [];
|
1178
923
|
}
|
1179
924
|
}
|
1180
925
|
return cur2.type === "ternary" || out.push(cur2), out;
|
@@ -1191,7 +936,7 @@ function createExtractor() {
|
|
1191
936
|
t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
|
1192
937
|
]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [
|
1193
938
|
traversePath.node
|
1194
|
-
]))) : console.warn(
|
939
|
+
]))) : console.warn(`No program path found, avoiding importing flattening / importing theme in ${sourcePath}`)), shouldPrintDebug)
|
1195
940
|
try {
|
1196
941
|
logger.info([
|
1197
942
|
" flatten?",
|
@@ -1205,12 +950,14 @@ function createExtractor() {
|
|
1205
950
|
}),
|
1206
951
|
"inlined",
|
1207
952
|
inlined.size,
|
1208
|
-
|
953
|
+
[
|
954
|
+
...inlined
|
955
|
+
]
|
1209
956
|
].join(" "));
|
1210
957
|
} catch {
|
1211
958
|
}
|
1212
959
|
if (shouldDeopt || !shouldFlatten) {
|
1213
|
-
shouldPrintDebug && logger.info(
|
960
|
+
shouldPrintDebug && logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`), node.attributes = ogAttributes;
|
1214
961
|
return;
|
1215
962
|
}
|
1216
963
|
shouldPrintDebug && logger.info([
|
@@ -1222,16 +969,16 @@ function createExtractor() {
|
|
1222
969
|
for (var key1 in attrs) {
|
1223
970
|
var cur = attrs[key1];
|
1224
971
|
if (cur.type === "style") {
|
1225
|
-
var expanded =
|
972
|
+
var expanded = normalizeStyleWithoutVariants2(cur.value);
|
1226
973
|
for (var key2 in expanded)
|
1227
|
-
|
974
|
+
mergeToEnd2(foundStaticProps, key2, expanded[key2]);
|
1228
975
|
continue;
|
1229
976
|
}
|
1230
977
|
if (cur.type === "attr") {
|
1231
978
|
if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name))
|
1232
979
|
continue;
|
1233
980
|
var key3 = cur.value.name.name, value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
|
1234
|
-
value !== FAILED_EVAL &&
|
981
|
+
value !== FAILED_EVAL && mergeToEnd2(foundStaticProps, key3, value);
|
1235
982
|
}
|
1236
983
|
}
|
1237
984
|
var completeProps = {};
|
@@ -1247,9 +994,10 @@ function createExtractor() {
|
|
1247
994
|
if (name2 === "tag")
|
1248
995
|
return acc;
|
1249
996
|
if (variants[name2] && variantValues.has(name2)) {
|
1250
|
-
var styleState =
|
997
|
+
var styleState = {
|
998
|
+
...propMapperStyleState,
|
1251
999
|
props: completeProps
|
1252
|
-
}
|
1000
|
+
}, out = Object.fromEntries(propMapper(name2, variantValues.get(name2), styleState) || []);
|
1253
1001
|
if (out && isTargetingHTML) {
|
1254
1002
|
var cn = out.className;
|
1255
1003
|
out = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), out.className = cn;
|
@@ -1263,7 +1011,9 @@ function createExtractor() {
|
|
1263
1011
|
var value2 = out[key9];
|
1264
1012
|
isValidStyleKey(key9, staticConfig) ? acc.push({
|
1265
1013
|
type: "style",
|
1266
|
-
value:
|
1014
|
+
value: {
|
1015
|
+
[key9]: value2
|
1016
|
+
},
|
1267
1017
|
name: key9,
|
1268
1018
|
attr: cur2.value
|
1269
1019
|
}) : acc.push({
|
@@ -1276,9 +1026,11 @@ function createExtractor() {
|
|
1276
1026
|
}
|
1277
1027
|
if (cur2.type !== "style")
|
1278
1028
|
return acc.push(cur2), acc;
|
1279
|
-
var key12 = Object.keys(cur2.value)[0], value12 = cur2.value[key12], fullKey = tamaguiConfig
|
1280
|
-
return fullKey && (cur2.value =
|
1281
|
-
|
1029
|
+
var key12 = Object.keys(cur2.value)[0], value12 = cur2.value[key12], fullKey = tamaguiConfig?.shorthands[key12];
|
1030
|
+
return fullKey && (cur2.value = {
|
1031
|
+
[fullKey]: value12
|
1032
|
+
}, key12 = fullKey), disableExtractVariables && value12[0] === "$" && (usedThemeKeys.has(key12) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([
|
1033
|
+
` keeping variable inline: ${key12} =`,
|
1282
1034
|
value12
|
1283
1035
|
].join(" ")), acc.push({
|
1284
1036
|
type: "attr",
|
@@ -1295,23 +1047,28 @@ function createExtractor() {
|
|
1295
1047
|
return shouldPrintDebug && logger.info([
|
1296
1048
|
" getProps() no props"
|
1297
1049
|
].join(" ")), {};
|
1298
|
-
if (excludeProps
|
1050
|
+
if (excludeProps?.size)
|
1299
1051
|
for (var key9 in props)
|
1300
1052
|
excludeProps.has(key9) && (shouldPrintDebug && logger.info([
|
1301
1053
|
" delete excluded",
|
1302
1054
|
key9
|
1303
1055
|
].join(" ")), delete props[key9]);
|
1304
1056
|
try {
|
1305
|
-
var out = getSplitStyles(props, staticConfig, defaultTheme, "", componentState,
|
1057
|
+
var out = getSplitStyles(props, staticConfig, defaultTheme, "", componentState, {
|
1058
|
+
...styleProps,
|
1306
1059
|
noClassNames: !0,
|
1307
1060
|
fallbackProps: completeProps
|
1308
|
-
}
|
1061
|
+
}, void 0, void 0, void 0, debugPropValue || shouldPrintDebug, options.experimentalFlattenThemesOnNative), outProps2 = {
|
1062
|
+
...includeProps ? out.viewProps : {},
|
1063
|
+
...out.style,
|
1064
|
+
...out.pseudos
|
1065
|
+
};
|
1309
1066
|
for (var key12 in outProps2)
|
1310
1067
|
deoptProps.has(key12) && (shouldFlatten = !1);
|
1311
|
-
return shouldPrintDebug && (logger.info(
|
1312
|
-
getProps (props in):
|
1313
|
-
getProps (outProps):
|
1314
|
-
\u{1F4AC} new font fam:
|
1068
|
+
return shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
|
1069
|
+
getProps (props in): ${logLines(objToStr(props))}`), logger.info(`
|
1070
|
+
getProps (outProps): ${logLines(objToStr(outProps2))}`)), out.fontFamily && (setPropsToFontFamily(outProps2, out.fontFamily), shouldPrintDebug && logger.info(`
|
1071
|
+
\u{1F4AC} new font fam: ${out.fontFamily}`)), outProps2;
|
1315
1072
|
} catch (err) {
|
1316
1073
|
return logger.info([
|
1317
1074
|
"error",
|
@@ -1338,8 +1095,8 @@ function createExtractor() {
|
|
1338
1095
|
type: "attr",
|
1339
1096
|
value: t.jsxAttribute(t.jsxIdentifier(key9), t.jsxExpressionContainer(typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)))
|
1340
1097
|
}), acc.push(cur2), acc;
|
1341
|
-
if (
|
1342
|
-
return
|
1098
|
+
if (prev?.type === "style")
|
1099
|
+
return mergeStyles2(prev.value, cur2.value), acc;
|
1343
1100
|
}
|
1344
1101
|
return cur2.type === "style" && (prev = cur2), acc.push(cur2), acc;
|
1345
1102
|
}, []), shouldPrintDebug && logger.info([
|
@@ -1347,12 +1104,12 @@ function createExtractor() {
|
|
1347
1104
|
`,
|
1348
1105
|
logLines(attrs.map(attrStr).join(", "))
|
1349
1106
|
].join(" "));
|
1350
|
-
var getStyleError = null,
|
1107
|
+
var getStyleError = null, _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
|
1351
1108
|
try {
|
1352
|
-
for (var
|
1353
|
-
var attr =
|
1109
|
+
for (var _iterator2 = attrs[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
|
1110
|
+
var attr = _step2.value;
|
1354
1111
|
try {
|
1355
|
-
switch (shouldPrintDebug && console.info(
|
1112
|
+
switch (shouldPrintDebug && console.info(` Processing ${attr.type}:`), attr.type) {
|
1356
1113
|
case "ternary": {
|
1357
1114
|
var a = getProps(attr.value.alternate, !1, "ternary.alternate"), c = getProps(attr.value.consequent, !1, "ternary.consequent");
|
1358
1115
|
a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([
|
@@ -1379,7 +1136,9 @@ function createExtractor() {
|
|
1379
1136
|
continue;
|
1380
1137
|
var value1 = attemptEvalSafe(attr.value.value || t.booleanLiteral(!0));
|
1381
1138
|
if (value1 !== FAILED_EVAL) {
|
1382
|
-
var outProps = getProps(
|
1139
|
+
var outProps = getProps({
|
1140
|
+
[key6]: value1
|
1141
|
+
}, !0, `attr.${key6}`), outKey = Object.keys(outProps)[0];
|
1383
1142
|
if (outKey) {
|
1384
1143
|
var outVal = outProps[outKey];
|
1385
1144
|
attr.value = t.jsxAttribute(t.jsxIdentifier(outKey), t.jsxExpressionContainer(typeof outVal == "string" ? t.stringLiteral(outVal) : literalToAst(outVal)));
|
@@ -1392,13 +1151,13 @@ function createExtractor() {
|
|
1392
1151
|
}
|
1393
1152
|
}
|
1394
1153
|
} catch (err) {
|
1395
|
-
|
1154
|
+
_didIteratorError2 = !0, _iteratorError2 = err;
|
1396
1155
|
} finally {
|
1397
1156
|
try {
|
1398
|
-
!
|
1157
|
+
!_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
|
1399
1158
|
} finally {
|
1400
|
-
if (
|
1401
|
-
throw
|
1159
|
+
if (_didIteratorError2)
|
1160
|
+
throw _iteratorError2;
|
1402
1161
|
}
|
1403
1162
|
}
|
1404
1163
|
if (shouldPrintDebug && logger.info([
|
@@ -1419,15 +1178,15 @@ function createExtractor() {
|
|
1419
1178
|
if (attr1.type === "style")
|
1420
1179
|
for (var key7 in attr1.value)
|
1421
1180
|
existingStyleKeys.has(key7) ? (shouldPrintDebug && logger.info([
|
1422
|
-
|
1181
|
+
` >> delete existing ${key7}`
|
1423
1182
|
].join(" ")), delete attr1.value[key7]) : existingStyleKeys.add(key7);
|
1424
1183
|
attr1.type === "dynamic-style" && (existingStyleKeys.has(attr1.name) ? attrs[i] = void 0 : existingStyleKeys.add(attr1.name));
|
1425
1184
|
}
|
1426
1185
|
if (options.experimentalFlattenThemesOnNative && (attrs = attrs.filter(Boolean)), !shouldFlatten && inlineWhenUnflattened.size) {
|
1427
|
-
var
|
1186
|
+
var _iteratorNormalCompletion12 = !0, _didIteratorError12 = !1, _iteratorError12 = void 0;
|
1428
1187
|
try {
|
1429
|
-
for (var
|
1430
|
-
var
|
1188
|
+
for (var _iterator12 = attrs.entries()[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = !0) {
|
1189
|
+
var [index, attr2] = _step12.value;
|
1431
1190
|
if (attr2.type === "style") {
|
1432
1191
|
for (var key8 in attr2.value)
|
1433
1192
|
if (inlineWhenUnflattened.has(key8)) {
|
@@ -1437,13 +1196,13 @@ function createExtractor() {
|
|
1437
1196
|
}
|
1438
1197
|
}
|
1439
1198
|
} catch (err) {
|
1440
|
-
|
1199
|
+
_didIteratorError12 = !0, _iteratorError12 = err;
|
1441
1200
|
} finally {
|
1442
1201
|
try {
|
1443
|
-
!
|
1202
|
+
!_iteratorNormalCompletion12 && _iterator12.return != null && _iterator12.return();
|
1444
1203
|
} finally {
|
1445
|
-
if (
|
1446
|
-
throw
|
1204
|
+
if (_didIteratorError12)
|
1205
|
+
throw _iteratorError12;
|
1447
1206
|
}
|
1448
1207
|
}
|
1449
1208
|
}
|
@@ -1456,7 +1215,7 @@ function createExtractor() {
|
|
1456
1215
|
].join(" ")), node.name.name = flatNode, res.flattened++, closingElement && (closingElement.name.name = flatNode));
|
1457
1216
|
var isNativeNotFlat = !shouldFlatten && platform2 === "native";
|
1458
1217
|
if (isNativeNotFlat)
|
1459
|
-
return shouldPrintDebug && logger.info(
|
1218
|
+
return shouldPrintDebug && logger.info(`Disabled flattening except for simple cases on native for now: ${JSON.stringify({
|
1460
1219
|
flatNode,
|
1461
1220
|
shouldDeopt,
|
1462
1221
|
canFlattenProps,
|
@@ -1465,14 +1224,14 @@ function createExtractor() {
|
|
1465
1224
|
"!staticConfig.isHOC": !staticConfig.isHOC,
|
1466
1225
|
"staticConfig.isReactNative": staticConfig.isReactNative,
|
1467
1226
|
"staticConfig.neverFlatten": staticConfig.neverFlatten
|
1468
|
-
}, null, 2))
|
1227
|
+
}, null, 2)}`), node.attributes = ogAttributes, null;
|
1469
1228
|
shouldPrintDebug && (logger.info([
|
1470
|
-
|
1229
|
+
` - inlined props (${inlined.size}):`,
|
1471
1230
|
shouldDeopt ? " deopted" : "",
|
1472
1231
|
hasSpread ? " has spread" : "",
|
1473
1232
|
staticConfig.neverFlatten ? "neverFlatten" : ""
|
1474
|
-
].join(" ")), logger.info(
|
1475
|
-
|
1233
|
+
].join(" ")), logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`), logger.info(` - attrs (end):
|
1234
|
+
${logLines(attrs.map(attrStr).join(", "))}`)), onExtractTag({
|
1476
1235
|
parserProps: propsWithFileInfo,
|
1477
1236
|
attrs,
|
1478
1237
|
node,
|
@@ -1488,14 +1247,14 @@ function createExtractor() {
|
|
1488
1247
|
staticConfig
|
1489
1248
|
});
|
1490
1249
|
} catch (err) {
|
1491
|
-
node.attributes = ogAttributes, console.error(
|
1250
|
+
node.attributes = ogAttributes, console.error(`@tamagui/static error, reverting optimization. In ${filePath} ${lineNumbers} on ${originalNodeName}: ${err.message}. For stack trace set environment TAMAGUI_DEBUG=1`), process.env.TAMAGUI_DEBUG === "1" && console.error(err.stack);
|
1492
1251
|
} finally {
|
1493
1252
|
debugPropValue && (shouldPrintDebug = ogDebug);
|
1494
1253
|
}
|
1495
1254
|
}
|
1496
1255
|
}), tm.mark("jsx-done", !!shouldPrintDebug), modifiedComponents.size) {
|
1497
1256
|
var all = Array.from(modifiedComponents);
|
1498
|
-
shouldPrintDebug && logger.info(
|
1257
|
+
shouldPrintDebug && logger.info(` [\u{1FA9D}] hook check ${all.length}`);
|
1499
1258
|
var _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
|
1500
1259
|
try {
|
1501
1260
|
for (var _iterator1 = all[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|