@tamagui/static 1.115.2 → 1.115.4
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/package.json +16 -16
- package/dist/check-dep-versions.cjs +0 -267
- package/dist/check-dep-versions.cjs.map +0 -6
- package/dist/checkDeps.cjs +0 -32
- package/dist/checkDeps.cjs.map +0 -6
- package/dist/constants.cjs +0 -49
- package/dist/constants.cjs.map +0 -6
- package/dist/exports.cjs +0 -40
- package/dist/exports.cjs.map +0 -6
- package/dist/extractor/accessSafe.cjs +0 -46
- package/dist/extractor/accessSafe.cjs.map +0 -6
- package/dist/extractor/babelParse.cjs +0 -54
- package/dist/extractor/babelParse.cjs.map +0 -6
- package/dist/extractor/buildClassName.cjs +0 -62
- package/dist/extractor/buildClassName.cjs.map +0 -6
- package/dist/extractor/bundle.cjs +0 -146
- package/dist/extractor/bundle.cjs.map +0 -6
- package/dist/extractor/bundleConfig.cjs +0 -322
- package/dist/extractor/bundleConfig.cjs.map +0 -6
- package/dist/extractor/createEvaluator.cjs +0 -70
- package/dist/extractor/createEvaluator.cjs.map +0 -6
- package/dist/extractor/createExtractor.cjs +0 -1008
- package/dist/extractor/createExtractor.cjs.map +0 -6
- package/dist/extractor/createLogger.cjs +0 -45
- package/dist/extractor/createLogger.cjs.map +0 -6
- package/dist/extractor/ensureImportingConcat.cjs +0 -48
- package/dist/extractor/ensureImportingConcat.cjs.map +0 -6
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -44
- package/dist/extractor/esbuildAliasPlugin.cjs.map +0 -6
- package/dist/extractor/evaluateAstNode.cjs +0 -83
- package/dist/extractor/evaluateAstNode.cjs.map +0 -6
- package/dist/extractor/extractHelpers.cjs +0 -120
- package/dist/extractor/extractHelpers.cjs.map +0 -6
- package/dist/extractor/extractMediaStyle.cjs +0 -129
- package/dist/extractor/extractMediaStyle.cjs.map +0 -6
- package/dist/extractor/extractToClassNames.cjs +0 -254
- package/dist/extractor/extractToClassNames.cjs.map +0 -6
- package/dist/extractor/extractToNative.cjs +0 -274
- package/dist/extractor/extractToNative.cjs.map +0 -6
- package/dist/extractor/findTopmostFunction.cjs +0 -34
- package/dist/extractor/findTopmostFunction.cjs.map +0 -6
- package/dist/extractor/generatedUid.cjs +0 -47
- package/dist/extractor/generatedUid.cjs.map +0 -6
- package/dist/extractor/getPrefixLogs.cjs +0 -28
- package/dist/extractor/getPrefixLogs.cjs.map +0 -6
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -67
- package/dist/extractor/getPropValueFromAttributes.cjs.map +0 -6
- package/dist/extractor/getSourceModule.cjs +0 -68
- package/dist/extractor/getSourceModule.cjs.map +0 -6
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -148
- package/dist/extractor/getStaticBindingsForScope.cjs.map +0 -6
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +0 -29
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs.map +0 -6
- package/dist/extractor/hoistClassNames.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs.map +0 -6
- package/dist/extractor/literalToAst.cjs +0 -84
- package/dist/extractor/literalToAst.cjs.map +0 -6
- package/dist/extractor/loadFile.cjs +0 -11
- package/dist/extractor/loadFile.cjs.map +0 -6
- package/dist/extractor/loadTamagui.cjs +0 -284
- package/dist/extractor/loadTamagui.cjs.map +0 -6
- package/dist/extractor/logLines.cjs +0 -35
- package/dist/extractor/logLines.cjs.map +0 -6
- package/dist/extractor/normalizeTernaries.cjs +0 -68
- package/dist/extractor/normalizeTernaries.cjs.map +0 -6
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -38
- package/dist/extractor/propsToFontFamilyCache.cjs.map +0 -6
- package/dist/extractor/regenerateConfig.cjs +0 -144
- package/dist/extractor/regenerateConfig.cjs.map +0 -6
- package/dist/extractor/removeUnusedHooks.cjs +0 -76
- package/dist/extractor/removeUnusedHooks.cjs.map +0 -6
- package/dist/extractor/timer.cjs +0 -43
- package/dist/extractor/timer.cjs.map +0 -6
- package/dist/extractor/validHTMLAttributes.cjs +0 -73
- package/dist/extractor/validHTMLAttributes.cjs.map +0 -6
- package/dist/extractor/watchTamaguiConfig.cjs +0 -58
- package/dist/extractor/watchTamaguiConfig.cjs.map +0 -6
- package/dist/getPragmaOptions.cjs +0 -54
- package/dist/getPragmaOptions.cjs.map +0 -6
- package/dist/helpers/memoize.cjs +0 -37
- package/dist/helpers/memoize.cjs.map +0 -6
- package/dist/helpers/requireTamaguiCore.cjs +0 -33
- package/dist/helpers/requireTamaguiCore.cjs.map +0 -6
- package/dist/index.cjs +0 -40
- package/dist/index.cjs.map +0 -6
- package/dist/registerRequire.cjs +0 -102
- package/dist/registerRequire.cjs.map +0 -6
- package/dist/server.cjs +0 -75
- package/dist/server.cjs.map +0 -6
- package/dist/setup.cjs +0 -0
- package/dist/setup.cjs.map +0 -6
- package/dist/types.cjs +0 -16
- package/dist/types.cjs.map +0 -6
@@ -1,1008 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all) __defProp(target, name, {
|
9
|
-
get: all[name],
|
10
|
-
enumerable: !0
|
11
|
-
});
|
12
|
-
},
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
15
|
-
get: () => from[key],
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
17
|
-
});
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
26
|
-
value: mod,
|
27
|
-
enumerable: !0
|
28
|
-
}) : target, mod)),
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
30
|
-
value: !0
|
31
|
-
}), mod);
|
32
|
-
var createExtractor_exports = {};
|
33
|
-
__export(createExtractor_exports, {
|
34
|
-
createExtractor: () => createExtractor
|
35
|
-
});
|
36
|
-
module.exports = __toCommonJS(createExtractor_exports);
|
37
|
-
var import_traverse = __toESM(require("@babel/traverse")),
|
38
|
-
t = __toESM(require("@babel/types")),
|
39
|
-
import_cli_color = require("@tamagui/cli-color"),
|
40
|
-
import_web = require("@tamagui/web"),
|
41
|
-
import_node_path = require("node:path"),
|
42
|
-
reactNativeWebInternals = __toESM(require("@tamagui/react-native-web-internals")),
|
43
|
-
import_constants = require("../constants.cjs"),
|
44
|
-
import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs"),
|
45
|
-
import_createEvaluator = require("./createEvaluator.cjs"),
|
46
|
-
import_evaluateAstNode = require("./evaluateAstNode.cjs"),
|
47
|
-
import_extractHelpers = require("./extractHelpers.cjs"),
|
48
|
-
import_findTopmostFunction = require("./findTopmostFunction.cjs"),
|
49
|
-
import_getStaticBindingsForScope = require("./getStaticBindingsForScope.cjs"),
|
50
|
-
import_literalToAst = require("./literalToAst.cjs"),
|
51
|
-
import_loadTamagui = require("./loadTamagui.cjs"),
|
52
|
-
import_logLines = require("./logLines.cjs"),
|
53
|
-
import_normalizeTernaries = require("./normalizeTernaries.cjs"),
|
54
|
-
import_propsToFontFamilyCache = require("./propsToFontFamilyCache.cjs"),
|
55
|
-
import_removeUnusedHooks = require("./removeUnusedHooks.cjs"),
|
56
|
-
import_timer = require("./timer.cjs"),
|
57
|
-
import_validHTMLAttributes = require("./validHTMLAttributes.cjs");
|
58
|
-
const UNTOUCHED_PROPS = {
|
59
|
-
key: !0,
|
60
|
-
style: !0,
|
61
|
-
className: !0
|
62
|
-
},
|
63
|
-
createTernary = x => x;
|
64
|
-
let hasLoggedBaseInfo = !1;
|
65
|
-
function isFullyDisabled(props) {
|
66
|
-
return props.disableExtraction && props.disableDebugAttr;
|
67
|
-
}
|
68
|
-
function createExtractor({
|
69
|
-
logger = console,
|
70
|
-
platform = "web"
|
71
|
-
} = {
|
72
|
-
logger: console
|
73
|
-
}) {
|
74
|
-
const INLINE_EXTRACTABLE = {
|
75
|
-
ref: "ref",
|
76
|
-
key: "key",
|
77
|
-
...(platform === "web" && {
|
78
|
-
onPress: "onClick",
|
79
|
-
onHoverIn: "onMouseEnter",
|
80
|
-
onHoverOut: "onMouseLeave",
|
81
|
-
onPressIn: "onMouseDown",
|
82
|
-
onPressOut: "onMouseUp"
|
83
|
-
})
|
84
|
-
},
|
85
|
-
componentState = {
|
86
|
-
focus: !1,
|
87
|
-
focusVisible: !1,
|
88
|
-
hover: !1,
|
89
|
-
unmounted: !0,
|
90
|
-
press: !1,
|
91
|
-
pressIn: !1,
|
92
|
-
disabled: !1
|
93
|
-
},
|
94
|
-
styleProps = {
|
95
|
-
resolveValues: "variable",
|
96
|
-
noClassNames: !1,
|
97
|
-
isAnimated: !1
|
98
|
-
},
|
99
|
-
shouldAddDebugProp =
|
100
|
-
// really basic disable this for next.js because it messes with ssr
|
101
|
-
!process.env.npm_package_dependencies_next && !0 && process.env.IDENTIFY_TAGS !== "false" && (process.env.NODE_ENV === "development" || process.env.DEBUG || process.env.IDENTIFY_TAGS);
|
102
|
-
let projectInfo = null;
|
103
|
-
function loadSync(props) {
|
104
|
-
return isFullyDisabled(props) ? null : projectInfo ||= (0, import_loadTamagui.loadTamaguiSync)(props);
|
105
|
-
}
|
106
|
-
async function load(props) {
|
107
|
-
return isFullyDisabled(props) ? null : projectInfo ||= await (0, import_loadTamagui.loadTamagui)(props);
|
108
|
-
}
|
109
|
-
return {
|
110
|
-
options: {
|
111
|
-
logger
|
112
|
-
},
|
113
|
-
cleanupBeforeExit: import_getStaticBindingsForScope.cleanupBeforeExit,
|
114
|
-
loadTamagui: load,
|
115
|
-
loadTamaguiSync: loadSync,
|
116
|
-
getTamagui() {
|
117
|
-
return projectInfo?.tamaguiConfig;
|
118
|
-
},
|
119
|
-
parseSync: (f, props) => {
|
120
|
-
const projectInfo2 = loadSync(props);
|
121
|
-
return parseWithConfig(projectInfo2 || {}, f, props);
|
122
|
-
},
|
123
|
-
parse: async (f, props) => {
|
124
|
-
const projectInfo2 = await load(props);
|
125
|
-
return parseWithConfig(projectInfo2 || {}, f, props);
|
126
|
-
}
|
127
|
-
};
|
128
|
-
function parseWithConfig({
|
129
|
-
components,
|
130
|
-
tamaguiConfig
|
131
|
-
}, fileOrPath, options) {
|
132
|
-
const {
|
133
|
-
config = "tamagui.config.ts",
|
134
|
-
importsWhitelist = ["constants.js"],
|
135
|
-
evaluateVars = !0,
|
136
|
-
sourcePath = "",
|
137
|
-
onExtractTag,
|
138
|
-
onStyleRule,
|
139
|
-
getFlattenedNode,
|
140
|
-
disable,
|
141
|
-
disableExtraction,
|
142
|
-
disableExtractInlineMedia,
|
143
|
-
disableExtractVariables,
|
144
|
-
disableDebugAttr,
|
145
|
-
enableDynamicEvaluation = !1,
|
146
|
-
disableOptimizeHooks,
|
147
|
-
includeExtensions = [".ts", ".tsx", ".jsx"],
|
148
|
-
extractStyledDefinitions = !1,
|
149
|
-
prefixLogs,
|
150
|
-
excludeProps,
|
151
|
-
platform: platform2,
|
152
|
-
...restProps
|
153
|
-
} = options,
|
154
|
-
validHooks = disableOptimizeHooks ? {} : {
|
155
|
-
useMedia: !0,
|
156
|
-
useTheme: !0
|
157
|
-
};
|
158
|
-
if (sourcePath.includes(".tamagui-dynamic-eval")) return null;
|
159
|
-
const {
|
160
|
-
normalizeStyle,
|
161
|
-
getSplitStyles,
|
162
|
-
mediaQueryConfig,
|
163
|
-
propMapper,
|
164
|
-
proxyThemeVariables,
|
165
|
-
pseudoDescriptors
|
166
|
-
} = (0, import_requireTamaguiCore.requireTamaguiCore)(platform2);
|
167
|
-
let shouldPrintDebug = options.shouldPrintDebug || !1;
|
168
|
-
if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath)) return null;
|
169
|
-
if (!isFullyDisabled(options) && !components) throw new Error("Must provide components");
|
170
|
-
if (sourcePath && includeExtensions && !includeExtensions.some(ext => sourcePath.endsWith(ext))) return shouldPrintDebug && logger.info(`Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(", ")}`), null;
|
171
|
-
function isValidStyleKey(name, staticConfig) {
|
172
|
-
if (!projectInfo) throw new Error("Tamagui extractor not loaded yet");
|
173
|
-
return platform2 === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)] ? !1 : !!(staticConfig.validStyles?.[name] || pseudoDescriptors[name] ||
|
174
|
-
// don't disable variants or else you lose many things flattening
|
175
|
-
staticConfig.variants?.[name] || projectInfo?.tamaguiConfig?.shorthands[name] || name[0] === "$" && mediaQueryConfig[name.slice(1)]);
|
176
|
-
}
|
177
|
-
const isTargetingHTML = platform2 === "web",
|
178
|
-
ogDebug = shouldPrintDebug,
|
179
|
-
tm = (0, import_timer.timer)(),
|
180
|
-
propsWithFileInfo = {
|
181
|
-
...options,
|
182
|
-
sourcePath,
|
183
|
-
allLoadedComponents: components ? [...components] : []
|
184
|
-
};
|
185
|
-
hasLoggedBaseInfo || (hasLoggedBaseInfo = !0, shouldPrintDebug && logger.info(["loaded components:", propsWithFileInfo.allLoadedComponents.map(comp => Object.keys(comp.nameToInfo).join(", ")).join(", ")].join(" ")), process.env.DEBUG?.startsWith("tamagui") && logger.info(["loaded:", propsWithFileInfo.allLoadedComponents.map(x => x.moduleName)].join(`
|
186
|
-
`))), tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig?.themes || (console.error(`\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file:
|
187
|
-
|
188
|
-
You may not need the compiler! Remember you can run Tamagui with no configuration at all.
|
189
|
-
|
190
|
-
You may have not "export default" your config (you can also "export const config").
|
191
|
-
|
192
|
-
Or this may be due to duplicated dependency versions:
|
193
|
-
- try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches.
|
194
|
-
- or search your lockfile for mis-matches.
|
195
|
-
`), console.info(" Got config:", tamaguiConfig), process.exit(0));
|
196
|
-
const firstThemeName = Object.keys(tamaguiConfig?.themes || {})[0],
|
197
|
-
firstTheme = tamaguiConfig?.themes[firstThemeName] || {};
|
198
|
-
if (!firstTheme || typeof firstTheme != "object") {
|
199
|
-
const err = `Missing theme ${firstThemeName}, an error occurred when importing your config`;
|
200
|
-
throw console.info(err, "Got config:", tamaguiConfig), console.info("Looking for theme:", firstThemeName), new Error(err);
|
201
|
-
}
|
202
|
-
const proxiedTheme = proxyThemeVariables(firstTheme),
|
203
|
-
themeAccessListeners = /* @__PURE__ */new Set(),
|
204
|
-
defaultTheme = new Proxy(proxiedTheme, {
|
205
|
-
get(target, key) {
|
206
|
-
return Reflect.has(target, key) && themeAccessListeners.forEach(cb => cb(String(key))), Reflect.get(target, key);
|
207
|
-
}
|
208
|
-
}),
|
209
|
-
body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
210
|
-
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(k => k.moduleName).join(", ")}`), logger.info(`valid import paths: ${JSON.stringify((0, import_extractHelpers.getValidComponentsPaths)(propsWithFileInfo))}`));
|
211
|
-
let doesUseValidImport = !1,
|
212
|
-
hasImportedTheme = !1;
|
213
|
-
const importDeclarations = [];
|
214
|
-
for (const bodyPath of body) {
|
215
|
-
if (bodyPath.type !== "ImportDeclaration") continue;
|
216
|
-
const node = "node" in bodyPath ? bodyPath.node : bodyPath,
|
217
|
-
moduleName = node.source.value,
|
218
|
-
valid = (0, import_extractHelpers.isValidImport)(propsWithFileInfo, moduleName);
|
219
|
-
if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(` - import ${moduleName} ${valid}`), extractStyledDefinitions && valid && node.specifiers.some(specifier => specifier.local.name === "styled")) {
|
220
|
-
doesUseValidImport = !0;
|
221
|
-
break;
|
222
|
-
}
|
223
|
-
if (valid) {
|
224
|
-
const names = node.specifiers.map(specifier => specifier.local.name),
|
225
|
-
isValidComponent = names.some(name => !!((0, import_extractHelpers.isValidImport)(propsWithFileInfo, moduleName, name) || validHooks[name]));
|
226
|
-
if (shouldPrintDebug === "verbose" && logger.info(` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(", ")} from '${moduleName}' - (valid: ${JSON.stringify((0, import_extractHelpers.getValidComponentsPaths)(propsWithFileInfo))})`), isValidComponent) {
|
227
|
-
doesUseValidImport = !0;
|
228
|
-
break;
|
229
|
-
}
|
230
|
-
}
|
231
|
-
}
|
232
|
-
if (shouldPrintDebug && logger.info(`${JSON.stringify({
|
233
|
-
doesUseValidImport,
|
234
|
-
hasImportedTheme
|
235
|
-
}, null, 2)}
|
236
|
-
`), !doesUseValidImport) return null;
|
237
|
-
function getValidImportedComponent(componentName) {
|
238
|
-
const importDeclaration = importDeclarations.find(dec => dec.specifiers.some(spec => spec.local.name === componentName));
|
239
|
-
return importDeclaration ? (0, import_extractHelpers.getValidImport)(propsWithFileInfo, importDeclaration.source.value, componentName) : null;
|
240
|
-
}
|
241
|
-
tm.mark("import-check", !!shouldPrintDebug);
|
242
|
-
let couldntParse = !1;
|
243
|
-
const modifiedComponents = /* @__PURE__ */new Set(),
|
244
|
-
bindingCache = {},
|
245
|
-
callTraverse = a => fileOrPath.type === "File" ? (0, import_traverse.default)(fileOrPath, a) : fileOrPath.traverse(a),
|
246
|
-
shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath);
|
247
|
-
let programPath = null;
|
248
|
-
const res = {
|
249
|
-
styled: 0,
|
250
|
-
flattened: 0,
|
251
|
-
optimized: 0,
|
252
|
-
modified: 0,
|
253
|
-
found: 0
|
254
|
-
},
|
255
|
-
version = `${Math.random()}`;
|
256
|
-
if (callTraverse({
|
257
|
-
// @ts-ignore
|
258
|
-
Program: {
|
259
|
-
enter(path) {
|
260
|
-
programPath = path;
|
261
|
-
}
|
262
|
-
},
|
263
|
-
// styled() calls
|
264
|
-
CallExpression(path) {
|
265
|
-
if (disable || shouldDisableExtraction || extractStyledDefinitions === !1 || !t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled") return;
|
266
|
-
const variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown",
|
267
|
-
parentNode = path.node.arguments[0];
|
268
|
-
if (!t.isIdentifier(parentNode)) return;
|
269
|
-
const parentName = parentNode.name,
|
270
|
-
definition = path.node.arguments[1];
|
271
|
-
if (!parentName || !definition || !t.isObjectExpression(definition)) return;
|
272
|
-
let Component = getValidImportedComponent(variableName);
|
273
|
-
if (!Component) {
|
274
|
-
if (enableDynamicEvaluation !== !0) return;
|
275
|
-
try {
|
276
|
-
shouldPrintDebug && logger.info(`Unknown component: ${variableName} = styled(${parentName}) attempting dynamic load: ${sourcePath}`);
|
277
|
-
const out2 = (0, import_loadTamagui.loadTamaguiSync)({
|
278
|
-
forceExports: !0,
|
279
|
-
components: [sourcePath],
|
280
|
-
cacheKey: version
|
281
|
-
});
|
282
|
-
if (!out2?.components) {
|
283
|
-
shouldPrintDebug && logger.info(`Couldn't load, got ${out2}`);
|
284
|
-
return;
|
285
|
-
}
|
286
|
-
if (propsWithFileInfo.allLoadedComponents = [...propsWithFileInfo.allLoadedComponents, ...out2.components], Component = out2.components.flatMap(x => x.nameToInfo[variableName] ?? [])[0], !out2.cached) {
|
287
|
-
const foundNames = out2.components?.map(x => Object.keys(x.nameToInfo).join(", ")).join(", ").trim();
|
288
|
-
foundNames && (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` | Tamagui found dynamic components: ${foundNames}`);
|
289
|
-
}
|
290
|
-
} catch {
|
291
|
-
shouldPrintDebug && logger.info(`skip optimize styled(${variableName}), unable to pre-process (DEBUG=tamagui for more)`);
|
292
|
-
}
|
293
|
-
}
|
294
|
-
if (!Component) {
|
295
|
-
shouldPrintDebug && logger.info(" No component found");
|
296
|
-
return;
|
297
|
-
}
|
298
|
-
const componentSkipProps = /* @__PURE__ */new Set([...(Component.staticConfig.inlineWhenUnflattened || []), ...(Component.staticConfig.inlineProps || []),
|
299
|
-
// for now skip variants, will return to them
|
300
|
-
"variants", "defaultVariants",
|
301
|
-
// skip fontFamily its basically a "variant", important for theme use to be value always
|
302
|
-
"fontFamily", "name", "focusStyle", "focusVisibleStyle", "disabledStyle", "hoverStyle", "pressStyle"]),
|
303
|
-
skipped = /* @__PURE__ */new Set(),
|
304
|
-
styles = {},
|
305
|
-
staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(path.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug),
|
306
|
-
attemptEval = evaluateVars ? (0, import_createEvaluator.createEvaluator)({
|
307
|
-
props: propsWithFileInfo,
|
308
|
-
staticNamespace,
|
309
|
-
sourcePath,
|
310
|
-
shouldPrintDebug
|
311
|
-
}) : import_evaluateAstNode.evaluateAstNode,
|
312
|
-
attemptEvalSafe = (0, import_createEvaluator.createSafeEvaluator)(attemptEval);
|
313
|
-
for (const property of definition.properties) {
|
314
|
-
if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) ||
|
315
|
-
// TODO make pseudos and variants work
|
316
|
-
// skip pseudos
|
317
|
-
pseudoDescriptors[property.key.name] ||
|
318
|
-
// skip variants
|
319
|
-
Component.staticConfig.variants?.[property.key.name] || componentSkipProps.has(property.key.name)) {
|
320
|
-
skipped.add(property);
|
321
|
-
continue;
|
322
|
-
}
|
323
|
-
const out2 = attemptEvalSafe(property.value);
|
324
|
-
out2 === import_constants.FAILED_EVAL ? skipped.add(property) : styles[property.key.name] = out2;
|
325
|
-
}
|
326
|
-
const out = getSplitStyles(styles, Component.staticConfig, defaultTheme, "", componentState, styleProps, void 0, void 0, void 0, shouldPrintDebug),
|
327
|
-
classNames = {
|
328
|
-
...out.classNames
|
329
|
-
};
|
330
|
-
if (shouldPrintDebug && logger.info([`Extracted styled(${variableName})
|
331
|
-
`, JSON.stringify(styles, null, 2), `
|
332
|
-
classNames:`, JSON.stringify(classNames, null, 2), `
|
333
|
-
rulesToInsert:`, out.rulesToInsert].join(" ")), definition.properties = definition.properties.map(prop => {
|
334
|
-
if (skipped.has(prop) || !t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) return prop;
|
335
|
-
const key = prop.key.name,
|
336
|
-
value = classNames[key];
|
337
|
-
return value ? t.objectProperty(t.stringLiteral(key), t.stringLiteral(value)) : prop;
|
338
|
-
}), out.rulesToInsert) for (const key in out.rulesToInsert) {
|
339
|
-
const styleObject = out.rulesToInsert[key];
|
340
|
-
onStyleRule?.(styleObject[import_web.StyleObjectIdentifier], styleObject[import_web.StyleObjectRules]);
|
341
|
-
}
|
342
|
-
res.styled++, shouldPrintDebug && logger.info(`Extracted styled(${variableName})`);
|
343
|
-
},
|
344
|
-
JSXElement(traversePath) {
|
345
|
-
tm.mark("jsx-element", !!shouldPrintDebug);
|
346
|
-
const node = traversePath.node.openingElement,
|
347
|
-
ogAttributes = node.attributes.map(attr => ({
|
348
|
-
...attr
|
349
|
-
})),
|
350
|
-
componentName = (0, import_extractHelpers.findComponentName)(traversePath.scope),
|
351
|
-
closingElement = traversePath.node.closingElement;
|
352
|
-
if (closingElement && t.isJSXMemberExpression(closingElement?.name) || !t.isJSXIdentifier(node.name)) {
|
353
|
-
shouldPrintDebug && logger.info(" skip non-identifier element");
|
354
|
-
return;
|
355
|
-
}
|
356
|
-
const binding = traversePath.scope.getBinding(node.name.name);
|
357
|
-
let moduleName = "";
|
358
|
-
if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !(0, import_extractHelpers.isValidImport)(propsWithFileInfo, moduleName, binding.identifier.name))) {
|
359
|
-
shouldPrintDebug && logger.info(` - Binding in component ${componentName} not valid import: "${binding.identifier.name}" isn't in ${moduleName}
|
360
|
-
`);
|
361
|
-
return;
|
362
|
-
}
|
363
|
-
const component = (0, import_extractHelpers.getValidComponent)(propsWithFileInfo, moduleName, node.name.name);
|
364
|
-
if (!component || !component.staticConfig) {
|
365
|
-
shouldPrintDebug && logger.info(`
|
366
|
-
- No Tamagui conf for: ${node.name.name}
|
367
|
-
`);
|
368
|
-
return;
|
369
|
-
}
|
370
|
-
const originalNodeName = node.name.name;
|
371
|
-
res.found++;
|
372
|
-
const filePath = `./${(0, import_node_path.relative)(process.cwd(), sourcePath)}`,
|
373
|
-
lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "",
|
374
|
-
codePosition = `${filePath}:${lineNumbers}`,
|
375
|
-
debugPropValue = node.attributes.filter(n => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug").map(n => n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1)[0];
|
376
|
-
if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`\x1B[33m\x1B[0m ${componentName} | ${codePosition} -------------------`), logger.info(["\x1B[1m", "\x1B[32m", `<${originalNodeName} />`, disableDebugAttr ? "" : "\u{1F41B}"].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(`${(0, import_node_path.basename)(filePath)}:${lineNumbers}`)))), shouldDisableExtraction) {
|
377
|
-
shouldPrintDebug === "verbose" && logger.info(` \u274C Extraction disabled: ${JSON.stringify(disableExtraction)}
|
378
|
-
`);
|
379
|
-
return;
|
380
|
-
}
|
381
|
-
try {
|
382
|
-
let evaluateAttribute = function (path) {
|
383
|
-
const attribute = path.node,
|
384
|
-
attr = {
|
385
|
-
type: "attr",
|
386
|
-
value: attribute
|
387
|
-
};
|
388
|
-
if (t.isJSXSpreadAttribute(attribute)) {
|
389
|
-
const arg = attribute.argument,
|
390
|
-
conditional = t.isConditionalExpression(arg) ?
|
391
|
-
// <YStack {...isSmall ? { color: 'red } : { color: 'blue }}
|
392
|
-
[arg.test, arg.consequent, arg.alternate] : t.isLogicalExpression(arg) && arg.operator === "&&" ?
|
393
|
-
// <YStack {...isSmall && { color: 'red }}
|
394
|
-
[arg.left, arg.right, null] : null;
|
395
|
-
if (conditional) {
|
396
|
-
const [test, alt, cons] = conditional;
|
397
|
-
if (!test) throw new Error("no test");
|
398
|
-
return [alt, cons].some(side => side && !isStaticObject(side)) ? (shouldPrintDebug && logger.info(`not extractable ${alt} ${cons}`), attr) : [...(createTernariesFromObjectProperties(test, alt) || []), ...(cons && createTernariesFromObjectProperties(t.unaryExpression("!", test), cons) || [])].map(ternary => ({
|
399
|
-
type: "ternary",
|
400
|
-
value: ternary
|
401
|
-
}));
|
402
|
-
}
|
403
|
-
}
|
404
|
-
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string") return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set(`${Math.random()}`, "spread"), attr;
|
405
|
-
const name = attribute.name.name;
|
406
|
-
if (excludeProps?.has(name)) return shouldPrintDebug && logger.info([" excluding prop", name].join(" ")), null;
|
407
|
-
if (inlineProps.has(name)) return inlined.set(name, name), shouldPrintDebug && logger.info([" ! inlining, inline prop", name].join(" ")), attr;
|
408
|
-
if (UNTOUCHED_PROPS[name]) return attr;
|
409
|
-
if (INLINE_EXTRACTABLE[name]) return inlined.set(name, INLINE_EXTRACTABLE[name]), attr;
|
410
|
-
if (name.startsWith("data-")) return attr;
|
411
|
-
if ((name === "enterStyle" || name === "exitStyle") && t.isJSXExpressionContainer(attribute?.value)) return shouldDeopt = !0, attr;
|
412
|
-
if (name[0] === "$" && t.isJSXExpressionContainer(attribute?.value)) {
|
413
|
-
const shortname = name.slice(1);
|
414
|
-
if (mediaQueryConfig[shortname]) {
|
415
|
-
if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia) return attr;
|
416
|
-
const expression = attribute.value.expression;
|
417
|
-
if (!t.isJSXEmptyExpression(expression)) {
|
418
|
-
const ternaries2 = createTernariesFromObjectProperties(t.stringLiteral(shortname), expression, {
|
419
|
-
inlineMediaQuery: shortname
|
420
|
-
});
|
421
|
-
if (ternaries2) return ternaries2.map(value2 => ({
|
422
|
-
type: "ternary",
|
423
|
-
value: value2
|
424
|
-
}));
|
425
|
-
}
|
426
|
-
}
|
427
|
-
}
|
428
|
-
const [value, valuePath] = t.isJSXExpressionContainer(attribute?.value) ? [attribute.value.expression, path.get("value")] : [attribute.value, path.get("value")],
|
429
|
-
remove = () => {
|
430
|
-
Array.isArray(valuePath) ? valuePath.map(p => p.remove()) : valuePath.remove();
|
431
|
-
};
|
432
|
-
if (name === "ref") return shouldPrintDebug && logger.info([" ! inlining, ref", name].join(" ")), inlined.set("ref", "ref"), attr;
|
433
|
-
if (name === "tag") return {
|
434
|
-
type: "attr",
|
435
|
-
value: path.node
|
436
|
-
};
|
437
|
-
if (disableExtractVariables === !0 && value && value.type === "StringLiteral" && value.value[0] === "$") return shouldPrintDebug && logger.info([` ! inlining, native disable extract: ${name} =`, value.value].join(" ")), inlined.set(name, !0), attr;
|
438
|
-
if (name === "theme") return inlined.set("theme", attr.value), attr;
|
439
|
-
const styleValue = attemptEvalSafe(value);
|
440
|
-
if (!variants[name] && !isValidStyleKey(name, staticConfig)) {
|
441
|
-
let keys = [name],
|
442
|
-
out = null;
|
443
|
-
out = propMapper(name, 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));
|
444
|
-
let didInline = !1;
|
445
|
-
const attributes = keys.map(key => {
|
446
|
-
const val = out[key];
|
447
|
-
return isValidStyleKey(key, staticConfig) ? {
|
448
|
-
type: "style",
|
449
|
-
value: {
|
450
|
-
[key]: styleValue
|
451
|
-
},
|
452
|
-
name: key,
|
453
|
-
attr: path.node
|
454
|
-
} : import_validHTMLAttributes.validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-") ||
|
455
|
-
// this is debug stuff added by vite / new jsx transform
|
456
|
-
key === "__source" || key === "__self" ? attr : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key), didInline = !0, inlined.set(key, val), val);
|
457
|
-
});
|
458
|
-
return didInline ? (shouldPrintDebug && logger.info(` bailing flattening due to attributes ${attributes.map(x => x.toString())}`), attr) : attributes;
|
459
|
-
}
|
460
|
-
if (styleValue !== import_constants.FAILED_EVAL) return inlineWhenUnflattened.has(name) && (inlineWhenUnflattenedOGVals[name] = {
|
461
|
-
styleValue,
|
462
|
-
attr
|
463
|
-
}), isValidStyleKey(name, staticConfig) ? (shouldPrintDebug && logger.info(` style: ${name} = ${JSON.stringify(styleValue)}`), name in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
|
464
|
-
type: "style",
|
465
|
-
value: {
|
466
|
-
[name]: styleValue
|
467
|
-
},
|
468
|
-
name,
|
469
|
-
attr: path.node
|
470
|
-
}) : (variants[name] && variantValues.set(name, styleValue), inlined.set(name, !0), attr);
|
471
|
-
if (t.isBinaryExpression(value)) {
|
472
|
-
shouldPrintDebug && logger.info(` binary expression ${name} = ${value}`);
|
473
|
-
const {
|
474
|
-
operator,
|
475
|
-
left,
|
476
|
-
right
|
477
|
-
} = value,
|
478
|
-
lVal = attemptEvalSafe(left),
|
479
|
-
rVal = attemptEvalSafe(right);
|
480
|
-
if (shouldPrintDebug && logger.info(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`), lVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(right)) {
|
481
|
-
const ternary = addBinaryConditional(operator, left, right);
|
482
|
-
if (ternary) return ternary;
|
483
|
-
}
|
484
|
-
if (rVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(left)) {
|
485
|
-
const ternary = addBinaryConditional(operator, right, left);
|
486
|
-
if (ternary) return ternary;
|
487
|
-
}
|
488
|
-
return shouldPrintDebug && logger.info(" evalBinaryExpression cant extract"), inlined.set(name, !0), attr;
|
489
|
-
}
|
490
|
-
const staticConditional = getStaticConditional(value);
|
491
|
-
if (staticConditional) return shouldPrintDebug === "verbose" && logger.info(` static conditional ${name} ${value}`), {
|
492
|
-
type: "ternary",
|
493
|
-
value: staticConditional
|
494
|
-
};
|
495
|
-
const staticLogical = getStaticLogical(value);
|
496
|
-
if (staticLogical) return shouldPrintDebug === "verbose" && logger.info(` static ternary ${name} = ${value}`), {
|
497
|
-
type: "ternary",
|
498
|
-
value: staticLogical
|
499
|
-
};
|
500
|
-
if (options.experimentalFlattenDynamicValues && isValidStyleKey(name, staticConfig)) return {
|
501
|
-
type: "dynamic-style",
|
502
|
-
value,
|
503
|
-
name: tamaguiConfig?.shorthands[name] || name
|
504
|
-
};
|
505
|
-
return inlined.set(name, !0), shouldPrintDebug && logger.info(` ! inline no match ${name} ${value}`), attr;
|
506
|
-
function addBinaryConditional(operator, staticExpr, cond) {
|
507
|
-
if (getStaticConditional(cond)) {
|
508
|
-
const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate)),
|
509
|
-
cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent));
|
510
|
-
return shouldPrintDebug && logger.info([" binaryConditional", cond.test, cons, alt].join(" ")), {
|
511
|
-
type: "ternary",
|
512
|
-
value: {
|
513
|
-
test: cond.test,
|
514
|
-
remove,
|
515
|
-
alternate: {
|
516
|
-
[name]: alt
|
517
|
-
},
|
518
|
-
consequent: {
|
519
|
-
[name]: cons
|
520
|
-
}
|
521
|
-
}
|
522
|
-
};
|
523
|
-
}
|
524
|
-
return null;
|
525
|
-
}
|
526
|
-
function getStaticConditional(value2) {
|
527
|
-
if (t.isConditionalExpression(value2)) try {
|
528
|
-
const aVal = attemptEval(value2.alternate),
|
529
|
-
cVal = attemptEval(value2.consequent);
|
530
|
-
if (shouldPrintDebug) {
|
531
|
-
const type = value2.test.type;
|
532
|
-
logger.info([" static ternary", type, cVal, aVal].join(" "));
|
533
|
-
}
|
534
|
-
return {
|
535
|
-
test: value2.test,
|
536
|
-
remove,
|
537
|
-
consequent: {
|
538
|
-
[name]: cVal
|
539
|
-
},
|
540
|
-
alternate: {
|
541
|
-
[name]: aVal
|
542
|
-
}
|
543
|
-
};
|
544
|
-
} catch (err) {
|
545
|
-
shouldPrintDebug && logger.info([" cant eval ternary", err.message].join(" "));
|
546
|
-
}
|
547
|
-
return null;
|
548
|
-
}
|
549
|
-
function getStaticLogical(value2) {
|
550
|
-
if (t.isLogicalExpression(value2) && value2.operator === "&&") try {
|
551
|
-
const val = attemptEval(value2.right);
|
552
|
-
return shouldPrintDebug && logger.info([" staticLogical", value2.left, name, val].join(" ")), {
|
553
|
-
test: value2.left,
|
554
|
-
remove,
|
555
|
-
consequent: {
|
556
|
-
[name]: val
|
557
|
-
},
|
558
|
-
alternate: null
|
559
|
-
};
|
560
|
-
} catch (err) {
|
561
|
-
shouldPrintDebug && logger.info([" cant static eval logical", err].join(" "));
|
562
|
-
}
|
563
|
-
return null;
|
564
|
-
}
|
565
|
-
},
|
566
|
-
isStaticObject = function (obj) {
|
567
|
-
return t.isObjectExpression(obj) && obj.properties.every(prop => {
|
568
|
-
if (!t.isObjectProperty(prop)) return logger.info(["not object prop", prop].join(" ")), !1;
|
569
|
-
const propName = prop.key.name;
|
570
|
-
return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([" not a valid style prop!", propName].join(" ")), !1) : !0;
|
571
|
-
});
|
572
|
-
},
|
573
|
-
createTernariesFromObjectProperties = function (test, side, ternaryPartial = {}) {
|
574
|
-
if (!side) return null;
|
575
|
-
if (!isStaticObject(side)) throw new Error("not extractable");
|
576
|
-
return side.properties.flatMap(property => {
|
577
|
-
if (!t.isObjectProperty(property)) throw new Error("expected object property");
|
578
|
-
if (t.isIdentifier(property.key)) {
|
579
|
-
const key = property.key.name,
|
580
|
-
mediaQueryKey = key.slice(1);
|
581
|
-
if (key[0] === "$" && mediaQueryConfig[mediaQueryKey]) if (t.isExpression(property.value)) {
|
582
|
-
const ternaries2 = createTernariesFromObjectProperties(t.stringLiteral(mediaQueryKey), property.value, {
|
583
|
-
inlineMediaQuery: mediaQueryKey
|
584
|
-
});
|
585
|
-
if (ternaries2) return ternaries2.map(value => ({
|
586
|
-
...ternaryPartial,
|
587
|
-
...value,
|
588
|
-
// ensure media query test stays on left side (see getMediaQueryTernary)
|
589
|
-
test: t.logicalExpression("&&", value.test, test)
|
590
|
-
}));
|
591
|
-
logger.info(["\u26A0\uFE0F no ternaries?", property].join(" "));
|
592
|
-
} else logger.info(["\u26A0\uFE0F not expression", property].join(" "));
|
593
|
-
}
|
594
|
-
if (t.isConditionalExpression(property.value)) {
|
595
|
-
const [truthy, falsy] = [t.objectExpression([t.objectProperty(property.key, property.value.consequent)]), t.objectExpression([t.objectProperty(property.key, property.value.alternate)])].map(x => attemptEval(x));
|
596
|
-
return [createTernary({
|
597
|
-
remove() {},
|
598
|
-
...ternaryPartial,
|
599
|
-
test: t.logicalExpression("&&", test, property.value.test),
|
600
|
-
consequent: truthy,
|
601
|
-
alternate: null
|
602
|
-
}), createTernary({
|
603
|
-
...ternaryPartial,
|
604
|
-
test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
|
605
|
-
consequent: falsy,
|
606
|
-
alternate: null,
|
607
|
-
remove() {}
|
608
|
-
})];
|
609
|
-
}
|
610
|
-
const obj = t.objectExpression([t.objectProperty(property.key, property.value)]),
|
611
|
-
consequent = attemptEval(obj);
|
612
|
-
return createTernary({
|
613
|
-
remove() {},
|
614
|
-
...ternaryPartial,
|
615
|
-
test,
|
616
|
-
consequent,
|
617
|
-
alternate: null
|
618
|
-
});
|
619
|
-
});
|
620
|
-
},
|
621
|
-
mergeToEnd = function (obj, key, val) {
|
622
|
-
key in obj && delete obj[key], obj[key] = val;
|
623
|
-
},
|
624
|
-
normalizeStyleWithoutVariants = function (style) {
|
625
|
-
let res2 = {};
|
626
|
-
for (const key in style) if (staticConfig.variants && key in staticConfig.variants) mergeToEnd(res2, key, style[key]);else {
|
627
|
-
const expanded = normalizeStyle({
|
628
|
-
[key]: style[key]
|
629
|
-
}, !0);
|
630
|
-
for (const key2 in expanded) mergeToEnd(res2, key2, expanded[key2]);
|
631
|
-
}
|
632
|
-
return res2;
|
633
|
-
},
|
634
|
-
mergeStyles = function (prev2, next) {
|
635
|
-
for (const key in next) pseudoDescriptors[key] ? (prev2[key] = prev2[key] || {}, Object.assign(prev2[key], next[key])) : mergeToEnd(prev2, key, next[key]);
|
636
|
-
};
|
637
|
-
const {
|
638
|
-
staticConfig
|
639
|
-
} = component,
|
640
|
-
defaultProps = {
|
641
|
-
...(staticConfig.defaultProps || {})
|
642
|
-
},
|
643
|
-
variants = staticConfig.variants || {},
|
644
|
-
isTextView = staticConfig.isText || !1,
|
645
|
-
validStyles = staticConfig?.validStyles ?? {};
|
646
|
-
let tagName = defaultProps.tag ?? (isTextView ? "span" : "div");
|
647
|
-
traversePath.get("openingElement").get("attributes").forEach(path => {
|
648
|
-
const attr = path.node;
|
649
|
-
if (t.isJSXSpreadAttribute(attr) || attr.name.name !== "tag") return;
|
650
|
-
const val = attr.value;
|
651
|
-
t.isStringLiteral(val) && (tagName = val.value);
|
652
|
-
}), shouldPrintDebug === "verbose" && console.info(` Start tag ${tagName}`);
|
653
|
-
const flatNode = getFlattenedNode?.({
|
654
|
-
isTextView,
|
655
|
-
tag: tagName
|
656
|
-
}),
|
657
|
-
inlineProps = /* @__PURE__ */new Set([
|
658
|
-
// adding some always inline props
|
659
|
-
"dataSet", ...(restProps.inlineProps || []), ...(staticConfig.inlineProps || [])]),
|
660
|
-
deoptProps = /* @__PURE__ */new Set([
|
661
|
-
// always de-opt animation these
|
662
|
-
"animation", "animateOnly", "animatePresence", "disableOptimization", ...(isTargetingHTML ? [] : ["pressStyle", "focusStyle", "focusVisibleStyle", "disabledStyle"]),
|
663
|
-
// when using a non-CSS driver, de-opt on enterStyle/exitStyle
|
664
|
-
...(tamaguiConfig?.animations.isReactNative ? ["enterStyle", "exitStyle"] : [])]),
|
665
|
-
inlineWhenUnflattened = /* @__PURE__ */new Set([...(staticConfig.inlineWhenUnflattened || [])]),
|
666
|
-
staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug),
|
667
|
-
attemptEval = evaluateVars ? (0, import_createEvaluator.createEvaluator)({
|
668
|
-
props: propsWithFileInfo,
|
669
|
-
staticNamespace,
|
670
|
-
sourcePath,
|
671
|
-
traversePath,
|
672
|
-
shouldPrintDebug
|
673
|
-
}) : import_evaluateAstNode.evaluateAstNode,
|
674
|
-
attemptEvalSafe = (0, import_createEvaluator.createSafeEvaluator)(attemptEval);
|
675
|
-
if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse) return;
|
676
|
-
tm.mark("jsx-element-flattened", !!shouldPrintDebug);
|
677
|
-
let attrs = [],
|
678
|
-
shouldDeopt = !1;
|
679
|
-
const inlined = /* @__PURE__ */new Map(),
|
680
|
-
variantValues = /* @__PURE__ */new Map();
|
681
|
-
let hasSetOptimized = !1;
|
682
|
-
const inlineWhenUnflattenedOGVals = {},
|
683
|
-
propMapperStyleState = {
|
684
|
-
staticConfig,
|
685
|
-
usedKeys: {},
|
686
|
-
classNames: {},
|
687
|
-
style: {},
|
688
|
-
theme: defaultTheme,
|
689
|
-
viewProps: defaultProps,
|
690
|
-
conf: tamaguiConfig,
|
691
|
-
props: defaultProps,
|
692
|
-
componentState,
|
693
|
-
styleProps: {
|
694
|
-
...styleProps,
|
695
|
-
resolveValues: "auto"
|
696
|
-
},
|
697
|
-
debug: shouldPrintDebug
|
698
|
-
};
|
699
|
-
if (attrs = traversePath.get("openingElement").get("attributes").flatMap(path => {
|
700
|
-
try {
|
701
|
-
const res2 = evaluateAttribute(path);
|
702
|
-
return res2 || path.remove(), res2;
|
703
|
-
} catch (err) {
|
704
|
-
return shouldPrintDebug && (logger.info(["Recoverable error extracting attribute", err.message, shouldPrintDebug === "verbose" ? err.stack : ""].join(" ")), shouldPrintDebug === "verbose" && logger.info(`node ${path.node?.type}`)), inlined.set(`${Math.random()}`, "spread"), {
|
705
|
-
type: "attr",
|
706
|
-
value: path.node
|
707
|
-
};
|
708
|
-
}
|
709
|
-
}).flat(4).filter(import_extractHelpers.isPresent), shouldPrintDebug && logger.info([` - attrs (before):
|
710
|
-
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" ")), couldntParse || shouldDeopt) {
|
711
|
-
shouldPrintDebug && logger.info([" avoid optimizing:", {
|
712
|
-
couldntParse,
|
713
|
-
shouldDeopt
|
714
|
-
}].join(" ")), node.attributes = ogAttributes;
|
715
|
-
return;
|
716
|
-
}
|
717
|
-
const parentFn = (0, import_findTopmostFunction.findTopmostFunction)(traversePath);
|
718
|
-
parentFn && modifiedComponents.add(parentFn);
|
719
|
-
const hasSpread = attrs.some(x => x.type === "attr" && t.isJSXSpreadAttribute(x.value)),
|
720
|
-
hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every(x => x.type === "JSXText"));
|
721
|
-
let themeVal = inlined.get("theme");
|
722
|
-
platform2 !== "native" && inlined.delete("theme");
|
723
|
-
for (const [key] of [...inlined]) {
|
724
|
-
const isStaticObjectVariant = staticConfig.variants?.[key] && variantValues.has(key);
|
725
|
-
(INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
|
726
|
-
}
|
727
|
-
const canFlattenProps = inlined.size === 0;
|
728
|
-
let shouldFlatten = !!(flatNode && !shouldDeopt && canFlattenProps && !hasSpread && !staticConfig.isStyledHOC && !staticConfig.isHOC && !staticConfig.isReactNative && staticConfig.neverFlatten !== !0 && (staticConfig.neverFlatten !== "jsx" || hasOnlyStringChildren));
|
729
|
-
const usedThemeKeys = /* @__PURE__ */new Set();
|
730
|
-
if (themeAccessListeners.add(key => {
|
731
|
-
disableExtractVariables && (usedThemeKeys.add(key), shouldFlatten = !1, shouldPrintDebug === "verbose" && logger.info([" ! accessing theme key, avoid flatten", key].join(" ")));
|
732
|
-
}), shouldFlatten) {
|
733
|
-
let skipMap = !1;
|
734
|
-
const defaultStyleAttrs = Object.keys(defaultProps).flatMap(key => {
|
735
|
-
if (skipMap) return [];
|
736
|
-
const value = defaultProps[key];
|
737
|
-
if (key === "theme" && !themeVal) return platform2 === "native" && (shouldFlatten = !1, skipMap = !0, inlined.set("theme", {
|
738
|
-
value: t.stringLiteral(value)
|
739
|
-
})), themeVal = {
|
740
|
-
value: t.stringLiteral(value)
|
741
|
-
}, [];
|
742
|
-
if (!isValidStyleKey(key, staticConfig)) return [];
|
743
|
-
const name = tamaguiConfig?.shorthands[key] || key;
|
744
|
-
if (value === void 0) {
|
745
|
-
logger.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`), shouldDeopt = !0;
|
746
|
-
return;
|
747
|
-
}
|
748
|
-
return name[0] === "$" && mediaQueryConfig[name.slice(1)] ? (defaultProps[key] = void 0, evaluateAttribute({
|
749
|
-
node: t.jsxAttribute(t.jsxIdentifier(name), t.jsxExpressionContainer(t.objectExpression(Object.keys(value).filter(k => typeof value[k] < "u").map(k => t.objectProperty(t.identifier(k), (0, import_literalToAst.literalToAst)(value[k]))))))
|
750
|
-
})) : {
|
751
|
-
type: "style",
|
752
|
-
name,
|
753
|
-
value: {
|
754
|
-
[name]: value
|
755
|
-
}
|
756
|
-
};
|
757
|
-
});
|
758
|
-
skipMap || defaultStyleAttrs.length && (attrs = [...defaultStyleAttrs, ...attrs]);
|
759
|
-
}
|
760
|
-
let ternaries = [];
|
761
|
-
attrs = attrs.reduce((out, cur) => {
|
762
|
-
const next = attrs[attrs.indexOf(cur) + 1];
|
763
|
-
if (cur.type === "ternary" && ternaries.push(cur.value), (!next || next.type !== "ternary") && ternaries.length) {
|
764
|
-
const normalized = (0, import_normalizeTernaries.normalizeTernaries)(ternaries).map(({
|
765
|
-
alternate,
|
766
|
-
consequent,
|
767
|
-
...rest
|
768
|
-
}) => ({
|
769
|
-
type: "ternary",
|
770
|
-
value: {
|
771
|
-
...rest,
|
772
|
-
alternate: alternate || null,
|
773
|
-
consequent: consequent || null
|
774
|
-
}
|
775
|
-
}));
|
776
|
-
try {
|
777
|
-
return [...out, ...normalized];
|
778
|
-
} finally {
|
779
|
-
shouldPrintDebug && logger.info(` normalizeTernaries (${ternaries.length} => ${normalized.length})`), ternaries = [];
|
780
|
-
}
|
781
|
-
}
|
782
|
-
return cur.type === "ternary" || out.push(cur), out;
|
783
|
-
}, []).flat();
|
784
|
-
const shouldWrapTheme = shouldFlatten && themeVal;
|
785
|
-
if (shouldWrapTheme && (programPath ? (shouldPrintDebug && logger.info([" - wrapping theme", themeVal].join(" ")), attrs = attrs.filter(x => !(x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme")), hasImportedTheme || (hasImportedTheme = !0, programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/web")))), traversePath.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [traversePath.node]))) : console.warn(`No program path found, avoiding importing flattening / importing theme in ${sourcePath}`)), shouldPrintDebug) try {
|
786
|
-
logger.info([" flatten?", shouldFlatten, (0, import_extractHelpers.objToStr)({
|
787
|
-
hasSpread,
|
788
|
-
shouldDeopt,
|
789
|
-
canFlattenProps,
|
790
|
-
shouldWrapTheme,
|
791
|
-
hasOnlyStringChildren
|
792
|
-
}), "inlined", inlined.size, [...inlined]].join(" "));
|
793
|
-
} catch {}
|
794
|
-
if (shouldDeopt || !shouldFlatten) {
|
795
|
-
shouldPrintDebug && logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`), node.attributes = ogAttributes;
|
796
|
-
return;
|
797
|
-
}
|
798
|
-
shouldPrintDebug && logger.info([` - attrs (flattened):
|
799
|
-
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" "));
|
800
|
-
let foundStaticProps = {};
|
801
|
-
for (const key in attrs) {
|
802
|
-
const cur = attrs[key];
|
803
|
-
if (cur.type === "style") {
|
804
|
-
const expanded = normalizeStyleWithoutVariants(cur.value);
|
805
|
-
for (const key2 in expanded) mergeToEnd(foundStaticProps, key2, expanded[key2]);
|
806
|
-
continue;
|
807
|
-
}
|
808
|
-
if (cur.type === "attr") {
|
809
|
-
if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name)) continue;
|
810
|
-
const key2 = cur.value.name.name,
|
811
|
-
value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
|
812
|
-
value !== import_constants.FAILED_EVAL && mergeToEnd(foundStaticProps, key2, value);
|
813
|
-
}
|
814
|
-
}
|
815
|
-
const completeProps = {};
|
816
|
-
for (const key in defaultProps) key in foundStaticProps || (completeProps[key] = defaultProps[key]);
|
817
|
-
for (const key in foundStaticProps) completeProps[key] = foundStaticProps[key];
|
818
|
-
attrs = attrs.reduce((acc, cur) => {
|
819
|
-
if (!cur) return acc;
|
820
|
-
if (cur.type === "attr" && !t.isJSXSpreadAttribute(cur.value) && shouldFlatten) {
|
821
|
-
const name = cur.value.name.name;
|
822
|
-
if (typeof name == "string") {
|
823
|
-
if (name === "tag") return acc;
|
824
|
-
if (variants[name] && variantValues.has(name)) {
|
825
|
-
const styleState = {
|
826
|
-
...propMapperStyleState,
|
827
|
-
props: completeProps
|
828
|
-
};
|
829
|
-
let out = Object.fromEntries(propMapper(name, variantValues.get(name), styleState) || []);
|
830
|
-
if (out && isTargetingHTML) {
|
831
|
-
const cn = out.className;
|
832
|
-
out = reactNativeWebInternals.createDOMProps(isTextView ? "span" : "div", out), out.className = cn;
|
833
|
-
}
|
834
|
-
shouldPrintDebug && logger.info([" - expanded variant", name, out].join(" "));
|
835
|
-
for (const key2 in out) {
|
836
|
-
const value2 = out[key2];
|
837
|
-
isValidStyleKey(key2, staticConfig) ? acc.push({
|
838
|
-
type: "style",
|
839
|
-
value: {
|
840
|
-
[key2]: value2
|
841
|
-
},
|
842
|
-
name: key2,
|
843
|
-
attr: cur.value
|
844
|
-
}) : acc.push({
|
845
|
-
type: "attr",
|
846
|
-
value: t.jsxAttribute(t.jsxIdentifier(key2), t.jsxExpressionContainer(typeof value2 == "string" ? t.stringLiteral(value2) : (0, import_literalToAst.literalToAst)(value2)))
|
847
|
-
});
|
848
|
-
}
|
849
|
-
}
|
850
|
-
}
|
851
|
-
}
|
852
|
-
if (cur.type !== "style") return acc.push(cur), acc;
|
853
|
-
let key = Object.keys(cur.value)[0];
|
854
|
-
const value = cur.value[key],
|
855
|
-
fullKey = tamaguiConfig?.shorthands[key];
|
856
|
-
return fullKey && (cur.value = {
|
857
|
-
[fullKey]: value
|
858
|
-
}, key = fullKey), disableExtractVariables && value[0] === "$" && (usedThemeKeys.has(key) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([` keeping variable inline: ${key} =`, value].join(" ")), acc.push({
|
859
|
-
type: "attr",
|
860
|
-
value: t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(t.stringLiteral(value)))
|
861
|
-
}), acc) : (acc.push(cur), acc);
|
862
|
-
}, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info([` - attrs (expanded):
|
863
|
-
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" "));
|
864
|
-
let prev = null;
|
865
|
-
const getProps = (props, includeProps = !1, debugName = "") => {
|
866
|
-
if (!props) return shouldPrintDebug && logger.info([" getProps() no props"].join(" ")), {};
|
867
|
-
if (excludeProps?.size) for (const key in props) excludeProps.has(key) && (shouldPrintDebug && logger.info([" delete excluded", key].join(" ")), delete props[key]);
|
868
|
-
const before = process.env.IS_STATIC;
|
869
|
-
process.env.IS_STATIC = "is_static";
|
870
|
-
try {
|
871
|
-
const out = getSplitStyles(props, staticConfig, defaultTheme, "", componentState, {
|
872
|
-
...styleProps,
|
873
|
-
noClassNames: !0,
|
874
|
-
fallbackProps: completeProps
|
875
|
-
}, void 0, void 0, void 0, debugPropValue || shouldPrintDebug
|
876
|
-
// options.experimentalFlattenThemesOnNative
|
877
|
-
);
|
878
|
-
let outProps = {
|
879
|
-
...(includeProps ? out.viewProps : {}),
|
880
|
-
...out.style,
|
881
|
-
...out.pseudos
|
882
|
-
};
|
883
|
-
for (const key in outProps) deoptProps.has(key) && (shouldFlatten = !1);
|
884
|
-
return shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
|
885
|
-
getProps (props in): ${(0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(props))}`), logger.info(`
|
886
|
-
getProps (outProps): ${(0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(outProps))}`)), out.fontFamily && ((0, import_propsToFontFamilyCache.setPropsToFontFamily)(outProps, out.fontFamily), shouldPrintDebug && logger.info(`
|
887
|
-
\u{1F4AC} new font fam: ${out.fontFamily}`)), outProps;
|
888
|
-
} catch (err) {
|
889
|
-
return logger.info(["error", err.message, err.stack].join(" ")), {};
|
890
|
-
} finally {
|
891
|
-
process.env.IS_STATIC = before;
|
892
|
-
}
|
893
|
-
};
|
894
|
-
shouldFlatten && attrs.unshift({
|
895
|
-
type: "style",
|
896
|
-
value: defaultProps
|
897
|
-
}), attrs = attrs.reduce((acc, cur) => {
|
898
|
-
if (cur.type === "style") {
|
899
|
-
const key = Object.keys(cur.value)[0],
|
900
|
-
value = cur.value[key];
|
901
|
-
if (
|
902
|
-
// !isStyleAndAttr[key] &&
|
903
|
-
!shouldFlatten &&
|
904
|
-
// de-opt if non-style
|
905
|
-
!validStyles[key] && !pseudoDescriptors[key] && !(key.startsWith("data-") || key.startsWith("aria-"))) return shouldPrintDebug && logger.info([" - keeping as non-style", key].join(" ")), prev = cur, acc.push({
|
906
|
-
type: "attr",
|
907
|
-
value: t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(typeof value == "string" ? t.stringLiteral(value) : (0, import_literalToAst.literalToAst)(value)))
|
908
|
-
}), acc.push(cur), acc;
|
909
|
-
if (prev?.type === "style") return mergeStyles(prev.value, cur.value), acc;
|
910
|
-
}
|
911
|
-
return cur.type === "style" && (prev = cur), acc.push(cur), acc;
|
912
|
-
}, []), shouldPrintDebug && logger.info([` - attrs (combined \u{1F500}):
|
913
|
-
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" "));
|
914
|
-
let getStyleError = null;
|
915
|
-
for (const attr of attrs) try {
|
916
|
-
switch (shouldPrintDebug && console.info(` Processing ${attr.type}:`), attr.type) {
|
917
|
-
case "ternary":
|
918
|
-
{
|
919
|
-
const a = getProps(attr.value.alternate, !1, "ternary.alternate"),
|
920
|
-
c = getProps(attr.value.consequent, !1, "ternary.consequent");
|
921
|
-
a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ", (0, import_extractHelpers.attrStr)(attr)].join(" "));
|
922
|
-
continue;
|
923
|
-
}
|
924
|
-
case "style":
|
925
|
-
{
|
926
|
-
const styles = getProps(attr.value, !1, "style");
|
927
|
-
styles && (attr.value = styles), shouldPrintDebug && logger.info([" * styles (in)", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(attr.value))].join(" ")), shouldPrintDebug && logger.info([" * styles (out)", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(styles))].join(" "));
|
928
|
-
continue;
|
929
|
-
}
|
930
|
-
case "attr":
|
931
|
-
if (shouldFlatten && t.isJSXAttribute(attr.value)) {
|
932
|
-
const key = attr.value.name.name;
|
933
|
-
if (key === "style" || key === "className" || key === "tag") continue;
|
934
|
-
const value = attemptEvalSafe(attr.value.value || t.booleanLiteral(!0));
|
935
|
-
if (value !== import_constants.FAILED_EVAL) {
|
936
|
-
const outProps = getProps({
|
937
|
-
[key]: value
|
938
|
-
}, !0, `attr.${key}`),
|
939
|
-
outKey = Object.keys(outProps)[0];
|
940
|
-
if (outKey) {
|
941
|
-
const outVal = outProps[outKey];
|
942
|
-
attr.value = t.jsxAttribute(t.jsxIdentifier(outKey), t.jsxExpressionContainer(typeof outVal == "string" ? t.stringLiteral(outVal) : (0, import_literalToAst.literalToAst)(outVal)));
|
943
|
-
}
|
944
|
-
}
|
945
|
-
}
|
946
|
-
}
|
947
|
-
} catch (err) {
|
948
|
-
getStyleError = err;
|
949
|
-
}
|
950
|
-
if (shouldPrintDebug && logger.info([` - attrs (ternaries/combined):
|
951
|
-
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" ")), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError) return logger.info([" \u26A0\uFE0F postprocessing error, deopt", getStyleError].join(" ")), node.attributes = ogAttributes, null;
|
952
|
-
const existingStyleKeys = /* @__PURE__ */new Set();
|
953
|
-
for (let i = attrs.length - 1; i >= 0; i--) {
|
954
|
-
const attr = attrs[i];
|
955
|
-
if (shouldFlatten && attr.type === "attr" && t.isJSXAttribute(attr.value) && t.isJSXIdentifier(attr.value.name)) {
|
956
|
-
const name = attr.value.name.name;
|
957
|
-
INLINE_EXTRACTABLE[name] && (attr.value.name.name = INLINE_EXTRACTABLE[name]);
|
958
|
-
}
|
959
|
-
if (attr.type === "style") for (const key in attr.value) existingStyleKeys.has(key) ? (shouldPrintDebug && logger.info([` >> delete existing ${key}`].join(" ")), delete attr.value[key]) : existingStyleKeys.add(key);
|
960
|
-
attr.type === "dynamic-style" && (existingStyleKeys.has(attr.name) ? attrs[i] = void 0 : existingStyleKeys.add(attr.name));
|
961
|
-
}
|
962
|
-
if (options.experimentalFlattenThemesOnNative && (attrs = attrs.filter(Boolean)), !shouldFlatten && inlineWhenUnflattened.size) {
|
963
|
-
for (const [index, attr] of attrs.entries()) if (attr.type === "style") for (const key in attr.value) {
|
964
|
-
if (!inlineWhenUnflattened.has(key)) continue;
|
965
|
-
const val = inlineWhenUnflattenedOGVals[key];
|
966
|
-
val ? (delete attr.value[key], attrs.splice(index - 1, 0, val.attr)) : delete attr.value[key];
|
967
|
-
}
|
968
|
-
}
|
969
|
-
if (attrs = attrs.filter(x => !((x.type === "style" || x.type === "dynamic-style") && Object.keys(x.value).length === 0)), shouldFlatten && (shouldPrintDebug && logger.info([" [\u2705] flattening", originalNodeName, flatNode].join(" ")), node.name.name = flatNode, res.flattened++, closingElement && (closingElement.name.name = flatNode)), !shouldFlatten && platform2 === "native") return shouldPrintDebug && logger.info(`Disabled flattening except for simple cases on native for now: ${JSON.stringify({
|
970
|
-
flatNode,
|
971
|
-
shouldDeopt,
|
972
|
-
canFlattenProps,
|
973
|
-
hasSpread,
|
974
|
-
"staticConfig.isStyledHOC": staticConfig.isStyledHOC,
|
975
|
-
"!staticConfig.isHOC": !staticConfig.isHOC,
|
976
|
-
"staticConfig.isReactNative": staticConfig.isReactNative,
|
977
|
-
"staticConfig.neverFlatten": staticConfig.neverFlatten
|
978
|
-
}, null, 2)}`), node.attributes = ogAttributes, null;
|
979
|
-
shouldPrintDebug && (logger.info([` - inlined props (${inlined.size}):`, shouldDeopt ? " deopted" : "", hasSpread ? " has spread" : "", staticConfig.neverFlatten ? "neverFlatten" : ""].join(" ")), logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`), logger.info(` - attrs (end):
|
980
|
-
${(0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))}`)), onExtractTag({
|
981
|
-
parserProps: propsWithFileInfo,
|
982
|
-
attrs,
|
983
|
-
node,
|
984
|
-
lineNumbers,
|
985
|
-
filePath,
|
986
|
-
config: tamaguiConfig,
|
987
|
-
attemptEval,
|
988
|
-
jsxPath: traversePath,
|
989
|
-
originalNodeName,
|
990
|
-
isFlattened: shouldFlatten,
|
991
|
-
programPath,
|
992
|
-
completeProps,
|
993
|
-
staticConfig
|
994
|
-
});
|
995
|
-
} catch (err) {
|
996
|
-
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);
|
997
|
-
} finally {
|
998
|
-
debugPropValue && (shouldPrintDebug = ogDebug);
|
999
|
-
}
|
1000
|
-
}
|
1001
|
-
}), tm.mark("jsx-done", !!shouldPrintDebug), modifiedComponents.size) {
|
1002
|
-
const all = Array.from(modifiedComponents);
|
1003
|
-
shouldPrintDebug && logger.info(` [\u{1FA9D}] hook check ${all.length}`);
|
1004
|
-
for (const comp of all) (0, import_removeUnusedHooks.removeUnusedHooks)(comp, shouldPrintDebug);
|
1005
|
-
}
|
1006
|
-
return tm.done(shouldPrintDebug === "verbose"), res;
|
1007
|
-
}
|
1008
|
-
}
|