@tamagui/static 1.0.0-beta.202 → 1.0.0-beta.208
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/extractor/createExtractor.js +52 -43
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/extractMediaStyle.js +2 -2
- package/dist/cjs/extractor/extractMediaStyle.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +0 -3
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/extractor/loadTamagui.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +55 -46
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/extractMediaStyle.js +2 -2
- package/dist/esm/extractor/extractMediaStyle.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.js +0 -3
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/extractor/loadTamagui.js.map +2 -2
- package/dist/jsx/extractor/createExtractor.js +55 -46
- package/dist/jsx/extractor/extractMediaStyle.js +2 -2
- package/dist/jsx/extractor/extractToClassNames.js +0 -3
- package/package.json +7 -7
|
@@ -90,6 +90,10 @@ const validHooks = {
|
|
|
90
90
|
};
|
|
91
91
|
const createTernary = /* @__PURE__ */ __name((x) => x, "createTernary");
|
|
92
92
|
function createExtractor() {
|
|
93
|
+
if (!process.env.TAMAGUI_TARGET) {
|
|
94
|
+
console.log('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either "web" or "native"');
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
93
97
|
const shouldAddDebugProp = !process.env.npm_package_dependencies_next && process.env.TAMAGUI_TARGET !== "native" && process.env.IDENTIFY_TAGS !== "false" && (process.env.NODE_ENV === "development" || process.env.DEBUG || process.env.IDENTIFY_TAGS);
|
|
94
98
|
require("esbuild-register/dist/node").register({
|
|
95
99
|
target: "es2019",
|
|
@@ -229,16 +233,17 @@ function createExtractor() {
|
|
|
229
233
|
}
|
|
230
234
|
const originalNodeName = node.name.name;
|
|
231
235
|
res.found++;
|
|
236
|
+
const filePath = sourcePath.replace(process.cwd(), ".");
|
|
237
|
+
const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
|
|
238
|
+
const preName = componentName ? `${componentName}.` : "";
|
|
239
|
+
const tagId = `${preName}${node.name.name}@${filePath.replace("./", "")}:${lineNumbers}`;
|
|
232
240
|
if (shouldPrintDebug) {
|
|
233
241
|
console.log(`
|
|
234
|
-
<${originalNodeName}
|
|
242
|
+
<${originalNodeName} /> (${tagId})`);
|
|
235
243
|
}
|
|
236
|
-
const filePath = sourcePath.replace(process.cwd(), ".");
|
|
237
|
-
const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
|
|
238
244
|
if (shouldAddDebugProp && !disableDebugAttr) {
|
|
239
|
-
const preName = componentName ? `${componentName}.` : "";
|
|
240
245
|
res.modified++;
|
|
241
|
-
node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(
|
|
246
|
+
node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(tagId)));
|
|
242
247
|
}
|
|
243
248
|
const shouldLog = !hasLogged;
|
|
244
249
|
if (shouldLog) {
|
|
@@ -275,6 +280,7 @@ function createExtractor() {
|
|
|
275
280
|
...staticConfig.inlineProps || []
|
|
276
281
|
]);
|
|
277
282
|
const deoptProps = /* @__PURE__ */ new Set([
|
|
283
|
+
"animation",
|
|
278
284
|
...props.deoptProps || [],
|
|
279
285
|
...staticConfig.deoptProps || []
|
|
280
286
|
]);
|
|
@@ -499,7 +505,7 @@ function createExtractor() {
|
|
|
499
505
|
let keys = [name];
|
|
500
506
|
let out = null;
|
|
501
507
|
if (staticConfig.propMapper) {
|
|
502
|
-
out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps,
|
|
508
|
+
out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps, "auto");
|
|
503
509
|
if (out) {
|
|
504
510
|
out = import_core_node.rnw.createDOMProps(isTextView ? "span" : "div", out);
|
|
505
511
|
delete out.className;
|
|
@@ -509,6 +515,10 @@ function createExtractor() {
|
|
|
509
515
|
let didInline = false;
|
|
510
516
|
const attributes = keys.map((key) => {
|
|
511
517
|
const val = out[key];
|
|
518
|
+
if (key === "theme") {
|
|
519
|
+
inlined.set(key, val);
|
|
520
|
+
return attr;
|
|
521
|
+
}
|
|
512
522
|
if (isValidStyleKey(key)) {
|
|
513
523
|
return {
|
|
514
524
|
type: "style",
|
|
@@ -518,10 +528,7 @@ function createExtractor() {
|
|
|
518
528
|
};
|
|
519
529
|
}
|
|
520
530
|
if (import_validHTMLAttributes.validHTMLAttributes[key]) {
|
|
521
|
-
return
|
|
522
|
-
type: "attr",
|
|
523
|
-
value: t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer((0, import_literalToAst.literalToAst)(val)))
|
|
524
|
-
};
|
|
531
|
+
return attr;
|
|
525
532
|
}
|
|
526
533
|
if (shouldPrintDebug) {
|
|
527
534
|
console.log(" ! inlining, non-static", key);
|
|
@@ -531,7 +538,9 @@ function createExtractor() {
|
|
|
531
538
|
return val;
|
|
532
539
|
});
|
|
533
540
|
if (didInline) {
|
|
534
|
-
|
|
541
|
+
if (shouldPrintDebug) {
|
|
542
|
+
console.log(" bailing flattening due to attributes", attributes);
|
|
543
|
+
}
|
|
535
544
|
return attr;
|
|
536
545
|
}
|
|
537
546
|
return attributes;
|
|
@@ -831,28 +840,24 @@ function createExtractor() {
|
|
|
831
840
|
const themeVal = inlined.get("theme");
|
|
832
841
|
inlined.delete("theme");
|
|
833
842
|
const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k]);
|
|
834
|
-
const shouldWrapInnerTheme = !!(hasOnlyStringChildren && themeVal);
|
|
835
|
-
const canFlattenProps = inlined.size === 0 ||
|
|
843
|
+
const shouldWrapInnerTheme = allOtherPropsExtractable && !!(hasOnlyStringChildren && themeVal);
|
|
844
|
+
const canFlattenProps = inlined.size === 0 || shouldWrapInnerTheme || allOtherPropsExtractable;
|
|
836
845
|
let shouldFlatten = !shouldDeopt && canFlattenProps && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
|
|
837
|
-
if (shouldWrapInnerTheme) {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
} else {
|
|
842
|
-
if (typeof themeVal === "string") {
|
|
843
|
-
if (!hasImportedTheme) {
|
|
844
|
-
hasImportedTheme = true;
|
|
845
|
-
programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/core")));
|
|
846
|
-
}
|
|
847
|
-
const children = parents.children;
|
|
848
|
-
parents.children = [
|
|
849
|
-
t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
|
|
850
|
-
t.jsxAttribute(t.jsxIdentifier("name"), t.stringLiteral(`${themeVal}`))
|
|
851
|
-
]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), children)
|
|
852
|
-
];
|
|
853
|
-
} else {
|
|
854
|
-
}
|
|
846
|
+
if (shouldFlatten && shouldWrapInnerTheme) {
|
|
847
|
+
if (typeof themeVal !== "string") {
|
|
848
|
+
console.warn("??");
|
|
849
|
+
return;
|
|
855
850
|
}
|
|
851
|
+
if (shouldPrintDebug) {
|
|
852
|
+
console.log(" - wrapping theme", allOtherPropsExtractable, themeVal);
|
|
853
|
+
}
|
|
854
|
+
if (!hasImportedTheme) {
|
|
855
|
+
hasImportedTheme = true;
|
|
856
|
+
programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/core")));
|
|
857
|
+
}
|
|
858
|
+
traversePath.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
|
|
859
|
+
t.jsxAttribute(t.jsxIdentifier("name"), t.stringLiteral(`${themeVal}`))
|
|
860
|
+
]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [traversePath.node]));
|
|
856
861
|
}
|
|
857
862
|
if (shouldFlatten && staticConfig.defaultProps) {
|
|
858
863
|
const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {
|
|
@@ -991,6 +996,7 @@ function createExtractor() {
|
|
|
991
996
|
if (shouldPrintDebug) {
|
|
992
997
|
console.log(" - attrs (combined \u{1F500}): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
993
998
|
}
|
|
999
|
+
const completeProps = __spreadValues(__spreadValues({}, staticConfig.defaultProps), completeStaticProps);
|
|
994
1000
|
const getStyles = /* @__PURE__ */ __name((props2, debugName = "") => {
|
|
995
1001
|
if (!props2)
|
|
996
1002
|
return;
|
|
@@ -1004,9 +1010,22 @@ function createExtractor() {
|
|
|
1004
1010
|
}
|
|
1005
1011
|
}
|
|
1006
1012
|
const out = (0, import_core_node.getSplitStyles)(props2, staticConfig, defaultTheme, {
|
|
1007
|
-
noClassNames: true
|
|
1013
|
+
noClassNames: true,
|
|
1014
|
+
fallbackProps: completeProps,
|
|
1015
|
+
focus: false,
|
|
1016
|
+
hover: false,
|
|
1017
|
+
mounted: true,
|
|
1018
|
+
press: false,
|
|
1019
|
+
pressIn: false
|
|
1008
1020
|
});
|
|
1009
1021
|
const outStyle = __spreadValues(__spreadValues({}, out.style), out.pseudos);
|
|
1022
|
+
for (const key in outStyle) {
|
|
1023
|
+
if (staticConfig.validStyles) {
|
|
1024
|
+
if (!staticConfig.validStyles[key] && !import_core_node.pseudos[key]) {
|
|
1025
|
+
delete outStyle[key];
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1010
1029
|
if (shouldPrintDebug === "verbose") {
|
|
1011
1030
|
console.log(` getStyles ${debugName} (props):
|
|
1012
1031
|
`, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(props2)));
|
|
@@ -1015,16 +1034,9 @@ function createExtractor() {
|
|
|
1015
1034
|
console.log(` getStyles ${debugName} (out.style):
|
|
1016
1035
|
`, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(outStyle || {}), true));
|
|
1017
1036
|
}
|
|
1018
|
-
for (const key in outStyle) {
|
|
1019
|
-
if (staticConfig.validStyles) {
|
|
1020
|
-
if (!staticConfig.validStyles[key] && !import_core_node.pseudos[key]) {
|
|
1021
|
-
delete outStyle[key];
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
1037
|
return outStyle;
|
|
1026
1038
|
}, "getStyles");
|
|
1027
|
-
const completeStylesProcessed = getStyles(
|
|
1039
|
+
const completeStylesProcessed = getStyles(completeProps, "completeStylesProcessed");
|
|
1028
1040
|
if (!completeStylesProcessed) {
|
|
1029
1041
|
throw new Error(`Impossible, no styles`);
|
|
1030
1042
|
}
|
|
@@ -1105,9 +1117,6 @@ function createExtractor() {
|
|
|
1105
1117
|
}
|
|
1106
1118
|
}
|
|
1107
1119
|
}
|
|
1108
|
-
if (shouldPrintDebug) {
|
|
1109
|
-
console.log(" - attrs (after):\n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
1110
|
-
}
|
|
1111
1120
|
if (shouldFlatten) {
|
|
1112
1121
|
if (shouldPrintDebug) {
|
|
1113
1122
|
console.log(" [\u2705] flattening", originalNodeName, flatNode);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/createExtractor.ts"],
|
|
4
|
-
"sourcesContent": ["import traverse, { NodePath, Visitor } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport {\n StackProps,\n StaticConfigParsed,\n TamaguiInternalConfig,\n getSplitStyles,\n mediaQueryConfig,\n pseudos,\n rnw,\n} from '@tamagui/core-node'\nimport { stylePropsTransform } from '@tamagui/helpers'\nimport { difference, pick } from 'lodash'\n\nimport { FAILED_EVAL } from '../constants'\nimport {\n ExtractedAttr,\n ExtractedAttrAttr,\n ExtractedAttrStyle,\n ExtractorParseProps,\n Ternary,\n} from '../types'\nimport { createEvaluator, createSafeEvaluator } from './createEvaluator'\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { attrStr, findComponentName, isInsideTamagui, isPresent, objToStr } from './extractHelpers'\nimport { findTopmostFunction } from './findTopmostFunction'\nimport { getStaticBindingsForScope } from './getStaticBindingsForScope'\nimport { literalToAst } from './literalToAst'\nimport { loadTamagui } from './loadTamagui'\nimport { logLines } from './logLines'\nimport { normalizeTernaries } from './normalizeTernaries'\nimport { removeUnusedHooks } from './removeUnusedHooks'\nimport { validHTMLAttributes } from './validHTMLAttributes'\n\nconst UNTOUCHED_PROPS = {\n key: true,\n style: true,\n className: true,\n}\n\nconst INLINE_EXTRACTABLE = {\n ref: 'ref',\n key: 'key',\n onPress: 'onClick',\n onHoverIn: 'onMouseEnter',\n onHoverOut: 'onMouseLeave',\n onPressIn: 'onMouseDown',\n onPressOut: 'onMouseUp',\n}\n\nconst isAttr = (x: ExtractedAttr): x is ExtractedAttrAttr => x.type === 'attr'\n\nconst validHooks = {\n useMedia: true,\n useTheme: true,\n}\n\nexport type Extractor = ReturnType<typeof createExtractor>\n\nconst createTernary = (x: Ternary) => x\n\nexport function createExtractor() {\n const shouldAddDebugProp =\n // really basic disable this for next.js because it messes with ssr\n !process.env.npm_package_dependencies_next &&\n process.env.TAMAGUI_TARGET !== 'native' &&\n process.env.IDENTIFY_TAGS !== 'false' &&\n (process.env.NODE_ENV === 'development' || process.env.DEBUG || process.env.IDENTIFY_TAGS)\n\n // ts imports\n require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n let loadedTamaguiConfig: TamaguiInternalConfig\n let hasLogged = false\n\n return {\n getTamagui() {\n return loadedTamaguiConfig\n },\n parse: (\n fileOrPath: NodePath<t.Program> | t.File,\n {\n config = 'tamagui.config.ts',\n importsWhitelist = ['constants.js'],\n evaluateVars = true,\n shouldPrintDebug = false,\n sourcePath = '',\n onExtractTag,\n getFlattenedNode,\n disable,\n disableExtraction,\n disableExtractInlineMedia,\n disableExtractVariables,\n disableDebugAttr,\n prefixLogs,\n excludeProps,\n ...props\n }: ExtractorParseProps\n ) => {\n if (disable) {\n return null\n }\n\n if (sourcePath === '') {\n throw new Error(`Must provide a source file name`)\n }\n if (!Array.isArray(props.components)) {\n throw new Error(`Must provide components array with list of Tamagui component modules`)\n }\n\n // we require it after parse because we need to set some global/env stuff before importing\n // otherwise we'd import `rnw` and cause it to evaluate react-native-web which causes errors\n const { components, tamaguiConfig } = loadTamagui({\n config,\n components: props.components || ['tamagui'],\n })\n\n loadedTamaguiConfig = tamaguiConfig\n\n const defaultTheme = tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]]\n const body = fileOrPath.type === 'Program' ? fileOrPath.get('body') : fileOrPath.program.body\n\n /**\n * Step 1: Determine if importing any statically extractable components\n */\n const isInternalImport = (importStr: string) => {\n return isInsideTamagui(sourcePath) && importStr[0] === '.'\n }\n\n const validComponents: { [key: string]: any } = Object.keys(components)\n // check if uppercase to avoid hitting media query proxy before init\n .filter((key) => key[0].toUpperCase() === key[0] && !!components[key]?.staticConfig)\n .reduce((obj, name) => {\n obj[name] = components[name]\n return obj\n }, {})\n\n let doesUseValidImport = false\n let hasImportedTheme = false\n\n for (const bodyPath of body) {\n if (bodyPath.type !== 'ImportDeclaration') continue\n const node = ('node' in bodyPath ? bodyPath.node : bodyPath) as any\n const from = node.source.value\n if (props.components.includes(from) || isInternalImport(from)) {\n if (\n node.specifiers.some((specifier) => {\n const name = specifier.local.name\n return validComponents[name] || validHooks[name]\n })\n ) {\n doesUseValidImport = true\n break\n }\n }\n }\n\n if (shouldPrintDebug) {\n console.log(sourcePath, { doesUseValidImport })\n }\n\n if (!doesUseValidImport) {\n return null\n }\n\n let couldntParse = false\n const modifiedComponents = new Set<NodePath<any>>()\n\n // only keeping a cache around per-file, reset it if it changes\n const bindingCache: Record<string, string | null> = {}\n\n const callTraverse = (a: Visitor<{}>) => {\n return fileOrPath.type === 'File' ? traverse(fileOrPath, a) : fileOrPath.traverse(a)\n }\n\n /**\n * Step 2: Statically extract from JSX < /> nodes\n */\n let programPath: NodePath<t.Program>\n\n const res = {\n flattened: 0,\n optimized: 0,\n modified: 0,\n found: 0,\n }\n\n callTraverse({\n Program: {\n enter(path) {\n programPath = path\n },\n },\n JSXElement(traversePath) {\n const node = traversePath.node.openingElement\n const ogAttributes = node.attributes\n const componentName = findComponentName(traversePath.scope)\n const closingElement = traversePath.node.closingElement\n\n // skip non-identifier opening elements (member expressions, etc.)\n if (t.isJSXMemberExpression(closingElement?.name) || !t.isJSXIdentifier(node.name)) {\n return\n }\n\n // validate its a proper import from tamagui (or internally inside tamagui)\n const binding = traversePath.scope.getBinding(node.name.name)\n\n if (binding) {\n if (!t.isImportDeclaration(binding.path.parent)) {\n return\n }\n const source = binding.path.parent.source\n if (!props.components.includes(source.value) && !isInternalImport(source.value)) {\n return\n }\n if (!validComponents[binding.identifier.name]) {\n return\n }\n }\n\n const component = validComponents[node.name.name] as { staticConfig?: StaticConfigParsed }\n if (!component || !component.staticConfig) {\n return\n }\n\n const originalNodeName = node.name.name\n\n // found a valid tag\n res.found++\n\n if (shouldPrintDebug) {\n console.log(`\\n<${originalNodeName} />`)\n }\n\n const filePath = sourcePath.replace(process.cwd(), '.')\n const lineNumbers = node.loc\n ? node.loc.start.line +\n (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : '')\n : ''\n\n // add data-is\n if (shouldAddDebugProp && !disableDebugAttr) {\n const preName = componentName ? `${componentName}.` : ''\n res.modified++\n node.attributes.unshift(\n t.jsxAttribute(\n t.jsxIdentifier('data-is'),\n t.stringLiteral(\n `${preName}${node.name.name}@${filePath.replace('./', '')}:${lineNumbers}`\n )\n )\n )\n }\n\n const shouldLog = !hasLogged\n if (shouldLog) {\n const prefix = ' |'\n console.log(\n prefixLogs || prefix,\n ' total \u00B7 optimized \u00B7 flattened '\n )\n hasLogged = true\n }\n if (disableExtraction) {\n return\n }\n\n const { staticConfig } = component\n const isTextView = staticConfig.isText || false\n const validStyles = staticConfig?.validStyles ?? {}\n\n function isValidStyleKey(name: string) {\n return !!(\n !!validStyles[name] ||\n !!pseudos[name] ||\n staticConfig.variants?.[name] ||\n tamaguiConfig.shorthands[name] ||\n (name[0] === '$' ? !!mediaQueryConfig[name.slice(1)] : false)\n )\n }\n\n // find tag=\"a\" tag=\"main\" etc dom indicators\n let tagName = staticConfig.defaultProps?.tag ?? (isTextView ? 'span' : 'div')\n traversePath\n .get('openingElement')\n .get('attributes')\n .forEach((path) => {\n const attr = path.node\n if (t.isJSXSpreadAttribute(attr)) return\n if (attr.name.name !== 'tag') return\n const val = attr.value\n if (!t.isStringLiteral(val)) return\n tagName = val.value\n })\n\n const flatNode = getFlattenedNode({ isTextView, tag: tagName })\n\n const inlineProps = new Set([\n ...(props.inlineProps || []),\n ...(staticConfig.inlineProps || []),\n ])\n const deoptProps = new Set([\n ...(props.deoptProps || []),\n ...(staticConfig.deoptProps || []),\n ])\n\n // Generate scope object at this level\n const staticNamespace = getStaticBindingsForScope(\n traversePath.scope,\n importsWhitelist,\n sourcePath,\n bindingCache,\n shouldPrintDebug\n )\n\n const attemptEval = !evaluateVars\n ? evaluateAstNode\n : createEvaluator({\n // @ts-ignore\n tamaguiConfig,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n })\n const attemptEvalSafe = createSafeEvaluator(attemptEval)\n\n if (shouldPrintDebug) {\n console.log(' staticNamespace', Object.keys(staticNamespace).join(', '))\n }\n\n //\n // SPREADS SETUP\n //\n\n // TODO restore\n // const hasDeopt = (obj: Object) => {\n // return Object.keys(obj).some(isDeoptedProp)\n // }\n\n // flatten any easily evaluatable spreads\n const flattenedAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n traversePath\n .get('openingElement')\n .get('attributes')\n .forEach((path) => {\n const attr = path.node\n if (!t.isJSXSpreadAttribute(attr)) {\n flattenedAttrs.push(attr)\n return\n }\n let arg: any\n try {\n arg = attemptEval(attr.argument)\n } catch (e: any) {\n if (shouldPrintDebug) {\n console.log(' couldnt parse spread', e.message)\n }\n flattenedAttrs.push(attr)\n return\n }\n if (arg !== undefined) {\n try {\n if (typeof arg !== 'object' || arg == null) {\n if (shouldPrintDebug) {\n console.log(' non object or null arg', arg)\n }\n flattenedAttrs.push(attr)\n } else {\n for (const k in arg) {\n const value = arg[k]\n // this is a null prop:\n if (!value && typeof value === 'object') {\n console.log('shouldnt we handle this?', k, value, arg)\n continue\n }\n flattenedAttrs.push(\n t.jsxAttribute(\n t.jsxIdentifier(k),\n t.jsxExpressionContainer(literalToAst(value))\n )\n )\n }\n }\n } catch (err) {\n console.warn('cant parse spread, caught err', err)\n couldntParse = true\n }\n }\n })\n\n if (couldntParse) {\n return\n }\n\n // set flattened\n node.attributes = flattenedAttrs\n\n // add in NON-STYLE default props\n if (staticConfig.defaultProps) {\n for (const key in staticConfig.defaultProps) {\n if (isValidStyleKey(key)) {\n continue\n }\n const serialize = require('babel-literal-to-ast')\n const val = staticConfig.defaultProps[key]\n try {\n const serializedDefaultProp = serialize(val)\n node.attributes.unshift(\n t.jsxAttribute(\n t.jsxIdentifier(key),\n typeof val === 'string'\n ? t.stringLiteral(val)\n : t.jsxExpressionContainer(serializedDefaultProp)\n )\n )\n } catch (err) {\n console.warn(\n `\u26A0\uFE0F Error evaluating default prop for component ${node.name.name}, prop ${key}\\n error: ${err}\\n value:`,\n val,\n '\\n defaultProps:',\n staticConfig.defaultProps\n )\n }\n }\n }\n\n let attrs: ExtractedAttr[] = []\n let shouldDeopt = false\n const inlined = new Map<string, boolean | string>()\n let hasSetOptimized = false\n\n // RUN first pass\n\n // normalize all conditionals so we can evaluate away easier later\n // at the same time lets normalize shorthand media queries into spreads:\n // that way we can parse them with the same logic later on\n //\n // {...media.sm && { color: x ? 'red' : 'blue' }}\n // => {...media.sm && x && { color: 'red' }}\n // => {...media.sm && !x && { color: 'blue' }}\n //\n // $sm={{ color: 'red' }}\n // => {...media.sm && { color: 'red' }}\n //\n // $sm={{ color: x ? 'red' : 'blue' }}\n // => {...media.sm && x && { color: 'red' }}\n // => {...media.sm && !x && { color: 'blue' }}\n\n attrs = traversePath\n .get('openingElement')\n .get('attributes')\n .flatMap((path) => {\n try {\n const res = evaluateAttribute(path)\n if (!res) {\n path.remove()\n }\n return res\n } catch (err: any) {\n if (shouldPrintDebug) {\n console.log('Error extracting attribute', err.message, err.stack)\n console.log('node', path.node)\n }\n return {\n type: 'attr',\n value: path.node,\n } as const\n }\n })\n .flat(4)\n .filter(isPresent)\n\n if (shouldPrintDebug) {\n console.log(' - attrs (before):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // START function evaluateAttribute\n function evaluateAttribute(\n path: NodePath<t.JSXAttribute | t.JSXSpreadAttribute>\n ): ExtractedAttr | ExtractedAttr[] | null {\n const attribute = path.node\n const attr: ExtractedAttr = { type: 'attr', value: attribute }\n // ...spreads\n if (t.isJSXSpreadAttribute(attribute)) {\n const arg = attribute.argument\n const conditional = t.isConditionalExpression(arg)\n ? // <YStack {...isSmall ? { color: 'red } : { color: 'blue }}\n ([arg.test, arg.consequent, arg.alternate] as const)\n : t.isLogicalExpression(arg) && arg.operator === '&&'\n ? // <YStack {...isSmall && { color: 'red }}\n ([arg.left, arg.right, null] as const)\n : null\n\n if (conditional) {\n const [test, alt, cons] = conditional\n if (!test) throw new Error(`no test`)\n if ([alt, cons].some((side) => side && !isExtractable(side))) {\n if (shouldPrintDebug) {\n console.log('not extractable', alt, cons)\n }\n return attr\n }\n // split into individual ternaries per object property\n return [\n ...(createTernariesFromObjectProperties(test, alt) || []),\n ...((cons &&\n createTernariesFromObjectProperties(t.unaryExpression('!', test), cons)) ||\n []),\n ].map((ternary) => ({\n type: 'ternary',\n value: ternary,\n }))\n }\n }\n // END ...spreads\n\n // directly keep these\n // couldn't evaluate spread, undefined name, or name is not string\n if (\n t.isJSXSpreadAttribute(attribute) ||\n !attribute.name ||\n typeof attribute.name.name !== 'string'\n ) {\n if (shouldPrintDebug) {\n console.log(' ! inlining, spread attr')\n }\n inlined.set(`${Math.random()}`, 'spread')\n return attr\n }\n\n const name = attribute.name.name\n\n if (excludeProps?.has(name)) {\n if (shouldPrintDebug) {\n console.log(' excluding prop', name)\n }\n return null\n }\n\n if (inlineProps.has(name)) {\n inlined.set(name, name)\n if (shouldPrintDebug) {\n console.log(' ! inlining, inline prop', name)\n }\n return attr\n }\n\n // can still optimize the object... see hoverStyle on native\n if (deoptProps.has(name)) {\n shouldDeopt = true\n inlined.set(name, name)\n if (shouldPrintDebug) {\n console.log(' ! inlining, deopted prop', name)\n }\n return attr\n }\n\n // pass className, key, and style props through untouched\n if (UNTOUCHED_PROPS[name]) {\n return attr\n }\n\n if (INLINE_EXTRACTABLE[name]) {\n inlined.set(name, INLINE_EXTRACTABLE[name])\n return attr\n }\n\n if (name.startsWith('data-')) {\n return attr\n }\n\n // shorthand media queries\n if (name[0] === '$' && t.isJSXExpressionContainer(attribute?.value)) {\n // allow disabling this extraction\n if (disableExtractInlineMedia) {\n return attr\n }\n\n const shortname = name.slice(1)\n if (mediaQueryConfig[shortname]) {\n const expression = attribute.value.expression\n if (!t.isJSXEmptyExpression(expression)) {\n const ternaries = createTernariesFromObjectProperties(\n t.stringLiteral(shortname),\n expression,\n {\n inlineMediaQuery: shortname,\n }\n )\n if (ternaries) {\n return ternaries.map((value) => ({\n type: 'ternary',\n value,\n }))\n }\n }\n }\n }\n\n const [value, valuePath] = (() => {\n if (t.isJSXExpressionContainer(attribute?.value)) {\n return [attribute.value.expression!, path.get('value')!] as const\n } else {\n return [attribute.value!, path.get('value')!] as const\n }\n })()\n\n const remove = () => {\n Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove()\n }\n\n if (name === 'ref') {\n if (shouldPrintDebug) {\n console.log(' ! inlining, ref', name)\n }\n inlined.set('ref', 'ref')\n return attr\n }\n\n if (name === 'tag') {\n return {\n type: 'attr',\n value: path.node,\n }\n }\n\n // native shouldn't extract variables\n if (disableExtractVariables) {\n if (value) {\n if (value.type === 'StringLiteral' && value.value[0] === '$') {\n if (shouldPrintDebug) {\n console.log(` ! inlining, native disable extract: ${name} =`, value.value)\n }\n inlined.set(name, true)\n return attr\n }\n }\n }\n\n // if value can be evaluated, extract it and filter it out\n const styleValue = attemptEvalSafe(value)\n\n // never flatten if a prop isn't a valid static attribute\n // only post prop-mapping\n if (!isValidStyleKey(name)) {\n let keys = [name]\n let out: any = null\n if (staticConfig.propMapper) {\n // for now passing empty props {}, a bit odd, need to at least document\n // for now we don't expose custom components so just noting behavior\n out = staticConfig.propMapper(\n name,\n styleValue,\n defaultTheme,\n staticConfig.defaultProps,\n staticConfig\n )\n if (out) {\n // translate to DOM-compat\n out = rnw.createDOMProps(isTextView ? 'span' : 'div', out)\n // remove className - we dont use rnw styling\n delete out.className\n\n keys = Object.keys(out)\n }\n }\n\n let didInline = false\n const attributes = keys.map((key) => {\n const val = out[key]\n if (isValidStyleKey(key)) {\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\n } as const\n }\n if (validHTMLAttributes[key]) {\n return {\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(literalToAst(val))\n ),\n } as const\n }\n if (shouldPrintDebug) {\n console.log(' ! inlining, non-static', key)\n }\n didInline = true\n inlined.set(key, val)\n return val\n })\n\n // weird logic whats going on here\n if (didInline) {\n console.log('we inlined something off', { attributes })\n // bail\n return attr\n }\n\n // return evaluated attributes\n return attributes\n }\n\n // FAILED = dynamic or ternary, keep going\n if (styleValue !== FAILED_EVAL) {\n if (isValidStyleKey(name)) {\n if (shouldPrintDebug) {\n console.log(` style: ${name} =`, styleValue)\n }\n if (!(name in staticConfig.defaultProps)) {\n if (!hasSetOptimized) {\n res.optimized++\n hasSetOptimized = true\n }\n }\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\n }\n } else {\n inlined.set(name, true)\n return attr\n }\n }\n\n // ternaries!\n\n // binary ternary, we can eventually make this smarter but step 1\n // basically for the common use case of:\n // opacity={(conditional ? 0 : 1) * scale}\n if (t.isBinaryExpression(value)) {\n if (shouldPrintDebug) {\n console.log(` binary expression ${name} = `, value)\n }\n const { operator, left, right } = value\n // if one side is a ternary, and the other side is evaluatable, we can maybe extract\n const lVal = attemptEvalSafe(left)\n const rVal = attemptEvalSafe(right)\n if (shouldPrintDebug) {\n console.log(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`)\n }\n if (lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {\n const ternary = addBinaryConditional(operator, left, right)\n if (ternary) return ternary\n }\n if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {\n const ternary = addBinaryConditional(operator, right, left)\n if (ternary) return ternary\n }\n if (shouldPrintDebug) {\n console.log(` evalBinaryExpression cant extract`)\n }\n inlined.set(name, true)\n return attr\n }\n\n const staticConditional = getStaticConditional(value)\n if (staticConditional) {\n if (shouldPrintDebug) {\n console.log(` static conditional ${name} = `, value)\n }\n return { type: 'ternary', value: staticConditional }\n }\n\n const staticLogical = getStaticLogical(value)\n if (staticLogical) {\n if (shouldPrintDebug) {\n console.log(` static ternary ${name} = `, value)\n }\n return { type: 'ternary', value: staticLogical }\n }\n\n // if we've made it this far, the prop stays inline\n inlined.set(name, true)\n if (shouldPrintDebug) {\n console.log(` ! inline no match ${name}`, value)\n }\n\n //\n // RETURN ATTR\n //\n return attr\n\n // attr helpers:\n function addBinaryConditional(\n operator: any,\n staticExpr: any,\n cond: t.ConditionalExpression\n ): ExtractedAttr | null {\n if (getStaticConditional(cond)) {\n const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate))\n const cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent))\n if (shouldPrintDebug) {\n console.log(' binaryConditional', cond.test, cons, alt)\n }\n return {\n type: 'ternary',\n value: {\n test: cond.test,\n remove,\n alternate: { [name]: alt },\n consequent: { [name]: cons },\n },\n }\n }\n return null\n }\n\n function getStaticConditional(value: t.Node): Ternary | null {\n if (t.isConditionalExpression(value)) {\n try {\n if (shouldPrintDebug) {\n console.log('attempt', value.alternate, value.consequent)\n }\n const aVal = attemptEval(value.alternate)\n const cVal = attemptEval(value.consequent)\n if (shouldPrintDebug) {\n const type = value.test.type\n console.log(' static ternary', type, cVal, aVal)\n }\n return {\n test: value.test,\n remove,\n consequent: { [name]: cVal },\n alternate: { [name]: aVal },\n }\n } catch (err: any) {\n if (shouldPrintDebug) {\n console.log(' cant eval ternary', err.message)\n }\n }\n }\n return null\n }\n\n function getStaticLogical(value: t.Node): Ternary | null {\n if (t.isLogicalExpression(value)) {\n if (value.operator === '&&') {\n try {\n const val = attemptEval(value.right)\n if (shouldPrintDebug) {\n console.log(' staticLogical', value.left, name, val)\n }\n return {\n test: value.left,\n remove,\n consequent: { [name]: val },\n alternate: null,\n }\n } catch (err) {\n if (shouldPrintDebug) {\n console.log(' cant static eval logical', err)\n }\n }\n }\n }\n return null\n }\n } // END function evaluateAttribute\n\n function isExtractable(obj: t.Node): obj is t.ObjectExpression {\n return (\n t.isObjectExpression(obj) &&\n obj.properties.every((prop) => {\n if (!t.isObjectProperty(prop)) {\n console.log('not object prop', prop)\n return false\n }\n const propName = prop.key['name']\n if (!isValidStyleKey(propName) && propName !== 'tag') {\n if (shouldPrintDebug) {\n console.log(' not a valid style prop!', propName)\n }\n return false\n }\n return true\n })\n )\n }\n\n // side = {\n // color: 'red',\n // background: x ? 'red' : 'green',\n // $gtSm: { color: 'green' }\n // }\n // => Ternary<test, { color: 'red' }, null>\n // => Ternary<test && x, { background: 'red' }, null>\n // => Ternary<test && !x, { background: 'green' }, null>\n // => Ternary<test && '$gtSm', { color: 'green' }, null>\n function createTernariesFromObjectProperties(\n test: t.Expression,\n side: t.Expression | null,\n ternaryPartial: Partial<Ternary> = {}\n ): null | Ternary[] {\n if (!side) {\n return null\n }\n if (!isExtractable(side)) {\n throw new Error('not extractable')\n }\n return side.properties.flatMap((property) => {\n if (!t.isObjectProperty(property)) {\n throw new Error('expected object property')\n }\n // handle media queries inside spread/conditional objects\n if (t.isIdentifier(property.key)) {\n const key = property.key.name\n const mediaQueryKey = key.slice(1)\n const isMediaQuery = key[0] === '$' && mediaQueryConfig[mediaQueryKey]\n if (isMediaQuery) {\n if (t.isExpression(property.value)) {\n const ternaries = createTernariesFromObjectProperties(\n t.stringLiteral(mediaQueryKey),\n property.value,\n {\n inlineMediaQuery: mediaQueryKey,\n }\n )\n if (ternaries) {\n return ternaries.map((value) => ({\n ...ternaryPartial,\n ...value,\n // ensure media query test stays on left side (see getMediaQueryTernary)\n test: t.logicalExpression('&&', value.test, test),\n }))\n } else {\n console.log('\u26A0\uFE0F no ternaries?', property)\n }\n } else {\n console.log('\u26A0\uFE0F not expression', property)\n }\n }\n }\n // this could be a recurse here if we want to get fancy\n if (t.isConditionalExpression(property.value)) {\n // merge up into the parent conditional, split into two\n const [truthy, falsy] = [\n t.objectExpression([t.objectProperty(property.key, property.value.consequent)]),\n t.objectExpression([t.objectProperty(property.key, property.value.alternate)]),\n ].map((x) => attemptEval(x))\n return [\n createTernary({\n remove() {},\n ...ternaryPartial,\n test: t.logicalExpression('&&', test, property.value.test),\n consequent: truthy,\n alternate: null,\n }),\n createTernary({\n ...ternaryPartial,\n test: t.logicalExpression(\n '&&',\n test,\n t.unaryExpression('!', property.value.test)\n ),\n consequent: falsy,\n alternate: null,\n remove() {},\n }),\n ]\n }\n const obj = t.objectExpression([t.objectProperty(property.key, property.value)])\n const consequent = attemptEval(obj)\n return createTernary({\n remove() {},\n ...ternaryPartial,\n test,\n consequent,\n alternate: null,\n })\n })\n }\n\n // now update to new values\n node.attributes = attrs.filter(isAttr).map((x) => x.value)\n\n if (couldntParse || shouldDeopt) {\n if (shouldPrintDebug) {\n console.log(` avoid optimizing:`, { couldntParse, shouldDeopt })\n }\n node.attributes = ogAttributes\n return\n }\n\n // before deopt, can still optimize\n const parentFn = findTopmostFunction(traversePath)\n if (parentFn) {\n modifiedComponents.add(parentFn)\n }\n\n // combine ternaries\n let ternaries: Ternary[] = []\n attrs = attrs\n .reduce<(ExtractedAttr | ExtractedAttr[])[]>((out, cur) => {\n const next = attrs[attrs.indexOf(cur) + 1]\n if (cur.type === 'ternary') {\n ternaries.push(cur.value)\n }\n if ((!next || next.type !== 'ternary') && ternaries.length) {\n // finish, process\n const normalized = normalizeTernaries(ternaries).map(\n ({ alternate, consequent, ...rest }) => {\n return {\n type: 'ternary' as const,\n value: {\n ...rest,\n alternate: alternate || null,\n consequent: consequent || null,\n },\n }\n }\n )\n try {\n return [...out, ...normalized]\n } finally {\n if (shouldPrintDebug) {\n console.log(\n ` normalizeTernaries (${ternaries.length} => ${normalized.length})`\n )\n }\n ternaries = []\n }\n }\n if (cur.type === 'ternary') {\n return out\n }\n out.push(cur)\n return out\n }, [])\n .flat()\n\n // evaluates all static attributes into a simple object\n const completeStaticProps = {\n ...Object.keys(attrs).reduce((acc, index) => {\n const cur = attrs[index] as ExtractedAttr\n if (cur.type === 'style') {\n Object.assign(acc, cur.value)\n }\n if (cur.type === 'attr') {\n if (t.isJSXSpreadAttribute(cur.value)) {\n return acc\n }\n if (!t.isJSXIdentifier(cur.value.name)) {\n return acc\n }\n const key = cur.value.name.name\n // undefined = boolean true\n const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true))\n if (value === FAILED_EVAL) {\n return acc\n }\n acc[key] = value\n }\n return acc\n }, {}),\n }\n\n // flatten logic!\n // fairly simple check to see if all children are text\n const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x))\n\n const hasOnlyStringChildren =\n !hasSpread &&\n (node.selfClosing ||\n (traversePath.node.children &&\n traversePath.node.children.every((x) => x.type === 'JSXText')))\n\n const themeVal = inlined.get('theme')\n inlined.delete('theme')\n const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k])\n const shouldWrapInnerTheme = !!(hasOnlyStringChildren && themeVal)\n const canFlattenProps =\n inlined.size === 0 ||\n (allOtherPropsExtractable && shouldWrapInnerTheme) ||\n allOtherPropsExtractable\n\n let shouldFlatten =\n !shouldDeopt &&\n canFlattenProps &&\n !hasSpread &&\n staticConfig.neverFlatten !== true &&\n (staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)\n\n // wrap theme around children on flatten\n if (shouldWrapInnerTheme) {\n const parents = traversePath.parentPath.node\n if (!t.isJSXElement(parents) && !t.isJSXFragment(parents)) {\n // cant support this bail\n shouldFlatten = false\n } else {\n if (typeof themeVal === 'string') {\n // insert import\n if (!hasImportedTheme) {\n hasImportedTheme = true\n programPath.node.body.push(\n t.importDeclaration(\n [t.importSpecifier(t.identifier('_TamaguiTheme'), t.identifier('Theme'))],\n t.stringLiteral('@tamagui/core')\n )\n )\n }\n\n const children = parents.children\n parents.children = [\n t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier('_TamaguiTheme'), [\n t.jsxAttribute(t.jsxIdentifier('name'), t.stringLiteral(`${themeVal}`)),\n ]),\n t.jsxClosingElement(t.jsxIdentifier('_TamaguiTheme')),\n children\n ),\n ]\n } else {\n // failed eval\n }\n }\n }\n\n // only if we flatten, ensure the default styles are there\n if (shouldFlatten && staticConfig.defaultProps) {\n const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {\n if (!isValidStyleKey(key)) {\n return\n }\n try {\n const serialize = require('babel-literal-to-ast')\n const val = staticConfig.defaultProps[key]\n const value = serialize(val)\n const name = tamaguiConfig.shorthands[key] || key\n return {\n type: 'style',\n name,\n value,\n } as ExtractedAttrStyle\n } catch (err) {\n console.warn(\n `\u26A0\uFE0F Error evaluating default style for component, prop ${key}\\n error: ${err}`\n )\n shouldDeopt = true\n }\n }) as ExtractedAttr[]\n\n if (defaultStyleAttrs.length) {\n attrs = [...defaultStyleAttrs, ...attrs]\n }\n }\n\n if (shouldDeopt) {\n node.attributes = ogAttributes\n return\n }\n\n // insert overrides - this inserts null props for things that are set in classNames\n // only when not flattening, so the downstream component can skip applying those styles\n const ensureOverridden = {}\n if (!shouldFlatten) {\n for (const cur of attrs) {\n if (cur.type === 'style') {\n // TODO need to loop over initial props not just style props\n for (const key in cur.value) {\n const shouldEnsureOverridden = !!staticConfig.ensureOverriddenProp?.[key]\n const isSetInAttrsAlready = attrs.some(\n (x) =>\n x.type === 'attr' &&\n x.value.type === 'JSXAttribute' &&\n x.value.name.name === key\n )\n\n if (!isSetInAttrsAlready) {\n const isVariant = !!staticConfig.variants?.[cur.name || '']\n if (isVariant || shouldEnsureOverridden) {\n ensureOverridden[key] = true\n }\n }\n }\n }\n }\n }\n\n if (shouldPrintDebug) {\n console.log(' - attrs (flattened): \\n', logLines(attrs.map(attrStr).join(', ')))\n console.log(' - ensureOverriden:', Object.keys(ensureOverridden).join(', '))\n }\n\n // expand shorthands, de-opt variables\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (!cur) {\n return acc\n }\n\n if (cur.type === 'attr' && !t.isJSXSpreadAttribute(cur.value)) {\n if (shouldFlatten) {\n if (cur.value.name.name === 'tag') {\n // remove tag=\"\"\n return acc\n }\n }\n }\n\n if (cur.type !== 'style') {\n acc.push(cur)\n return acc\n }\n\n let key = Object.keys(cur.value)[0]\n const value = cur.value[key]\n const fullKey = tamaguiConfig.shorthands[key]\n\n // expand shorthands\n if (fullKey) {\n cur.value = { [fullKey]: value }\n key = fullKey\n }\n\n // finally we have all styles + expansions, lets see if we need to skip\n // any and keep them as attrs\n if (disableExtractVariables) {\n if (value[0] === '$') {\n if (shouldPrintDebug) {\n console.log(` keeping variable inline: ${key} =`, value)\n }\n acc.push({\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(t.stringLiteral(value))\n ),\n })\n return acc\n }\n }\n\n acc.push(cur)\n return acc\n }, [])\n\n if (shouldPrintDebug) {\n console.log(' - attrs (expanded): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // merge styles, leave undefined values\n let prev: ExtractedAttr | null = null\n\n function mergeStyles(prev: StackProps, next: StackProps) {\n for (const key in next) {\n // merge pseudos\n if (pseudos[key]) {\n prev[key] = prev[key] || {}\n Object.assign(prev[key], next[key])\n } else {\n prev[key] = next[key]\n }\n }\n }\n\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n const key = Object.keys(cur.value)[0]\n const value = cur.value[key]\n\n const shouldKeepOriginalAttr =\n // !isStyleAndAttr[key] &&\n !shouldFlatten &&\n // de-opt transform styles so it merges properly if not flattened\n // we handle this later on\n // (stylePropsTransform[key] ||\n // de-opt if non-style\n !validStyles[key] &&\n !pseudos[key] &&\n !key.startsWith('data-')\n\n if (shouldKeepOriginalAttr) {\n if (shouldPrintDebug) {\n console.log(' - keeping as non-style', key)\n }\n prev = cur\n acc.push({\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(\n typeof value === 'string' ? t.stringLiteral(value) : literalToAst(value)\n )\n ),\n })\n acc.push(cur)\n return acc\n }\n\n if (ensureOverridden[key]) {\n acc.push({\n type: 'attr',\n value:\n cur.attr ||\n t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(t.nullLiteral())),\n })\n }\n\n if (prev?.type === 'style') {\n mergeStyles(prev.value as StackProps, cur.value as StackProps)\n return acc\n }\n }\n\n prev = cur\n acc.push(cur)\n return acc\n }, [])\n\n if (shouldPrintDebug) {\n console.log(' - attrs (combined \uD83D\uDD00): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // post process\n const getStyles = (props: Object | null, debugName = '') => {\n if (!props) return\n if (!Object.keys(props).length) return\n if (excludeProps && !!excludeProps.size) {\n for (const key in props) {\n if (excludeProps.has(key)) {\n delete props[key]\n }\n }\n }\n const out = getSplitStyles(\n props,\n staticConfig,\n defaultTheme,\n {\n noClassNames: true,\n }\n // , {\n // noClassNames: process.env.TAMAGUI_TARGET !== 'web',\n // }\n )\n const outStyle = {\n ...out.style,\n ...out.pseudos,\n }\n if (shouldPrintDebug === 'verbose') {\n // // prettier-ignore\n console.log(` getStyles ${debugName} (props):\\n`, logLines(objToStr(props)))\n // // prettier-ignore\n console.log(\n ` getStyles ${debugName} (out.viewProps):\\n`,\n logLines(objToStr(out.viewProps))\n )\n // prettier-ignore\n console.log(` getStyles ${debugName} (out.style):\\n`, logLines(objToStr(outStyle || {}), true))\n }\n for (const key in outStyle) {\n if (staticConfig.validStyles) {\n if (!staticConfig.validStyles[key] && !pseudos[key]) {\n delete outStyle[key]\n }\n }\n }\n return outStyle\n }\n\n // used to ensure we pass the entire prop bundle to getStyles\n const completeStylesProcessed = getStyles(\n {\n ...staticConfig.defaultProps,\n ...completeStaticProps,\n },\n 'completeStylesProcessed'\n )\n\n if (!completeStylesProcessed) {\n throw new Error(`Impossible, no styles`)\n }\n\n // any extra styles added in postprocess should be added to first group as they wont be overriden\n const stylesToAddToInitialGroup = shouldFlatten\n ? difference(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps))\n : []\n\n if (stylesToAddToInitialGroup.length) {\n const toAdd = pick(completeStylesProcessed, ...stylesToAddToInitialGroup)\n const firstGroup = attrs.find((x) => x.type === 'style')\n if (shouldPrintDebug) {\n console.log(' toAdd', objToStr(toAdd))\n }\n if (!firstGroup) {\n attrs.unshift({ type: 'style', value: toAdd })\n } else {\n Object.assign(firstGroup.value, toAdd)\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' -- stylesToAddToInitialGroup', stylesToAddToInitialGroup.join(', '), { shouldFlatten })\n // prettier-ignore\n console.log(' -- completeStaticProps:\\n', logLines(objToStr(completeStaticProps)))\n // prettier-ignore\n console.log(' -- completeStylesProcessed:\\n', logLines(objToStr(completeStylesProcessed)))\n }\n\n let getStyleError: any = null\n\n // fix up ternaries, combine final style values\n for (const attr of attrs) {\n try {\n if (shouldPrintDebug) console.log(' *', attrStr(attr))\n switch (attr.type) {\n case 'ternary':\n const a = getStyles(attr.value.alternate, 'ternary.alternate')\n const c = getStyles(attr.value.consequent, 'ternary.consequent')\n if (a) attr.value.alternate = a\n if (c) attr.value.consequent = c\n if (shouldPrintDebug) console.log(' => tern ', attrStr(attr))\n continue\n case 'style':\n // expand variants and such\n // get the keys we need\n const styles = getStyles(attr.value, 'style')\n if (styles) {\n // but actually resolve them to the full object\n // TODO media/psuedo merging\n attr.value = Object.fromEntries(\n Object.keys(styles).map((k) => [k, completeStylesProcessed[k]])\n )\n } else {\n console.warn('?????????')\n }\n // for (const keyIn in attr.value) {\n // const [key, value] = (() => {\n // if (keyIn in stylePropsTransform) {\n // // TODO this logic needs to be a bit more right, because could have spread in between transforms...\n // // could just output flat transforms as webkit now supports on recent versions\n // return ['transform', completeStylesProcessed['transform']] as const\n // } else {\n // return [keyIn, completeStylesProcessed[keyIn] ?? attr.value[keyIn]] as const\n // }\n // })()\n // // if (shouldPrintDebug) console.log('style', { keyIn, key, value })\n // delete attr.value[keyIn]\n // attr.value[key] = value\n // }\n continue\n }\n } catch (err) {\n // any error de-opt\n getStyleError = err\n }\n }\n\n if (getStyleError) {\n console.log(' \u26A0\uFE0F postprocessing error, deopt', getStyleError)\n node.attributes = ogAttributes\n return node\n }\n\n // final lazy extra loop:\n const existingStyleKeys = new Set()\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attr = attrs[i]\n\n // if flattening map inline props to proper flattened names\n if (shouldFlatten && canFlattenProps) {\n if (attr.type === 'attr') {\n if (t.isJSXAttribute(attr.value)) {\n if (t.isJSXIdentifier(attr.value.name)) {\n const name = attr.value.name.name\n if (INLINE_EXTRACTABLE[name]) {\n // map to HTML only name\n attr.value.name.name = INLINE_EXTRACTABLE[name]\n }\n }\n }\n }\n }\n\n // remove duplicate styles\n // so if you have:\n // style({ color: 'red' }), ...someProps, style({ color: 'green' })\n // this will mutate:\n // style({}), ...someProps, style({ color: 'green' })\n if (attr.type === 'style') {\n for (const key in attr.value) {\n if (existingStyleKeys.has(key)) {\n delete attr.value[key]\n } else {\n existingStyleKeys.add(key)\n }\n }\n }\n }\n\n if (shouldPrintDebug) {\n console.log(' - attrs (after):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n if (shouldFlatten) {\n // DO FLATTEN\n if (shouldPrintDebug) {\n console.log(' [\u2705] flattening', originalNodeName, flatNode)\n }\n node.name.name = flatNode\n res.flattened++\n if (closingElement) {\n closingElement.name.name = flatNode\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(` \u274A\u274A inline props (${inlined.size}):`, shouldDeopt ? ' deopted' : '', hasSpread ? ' has spread' : '', staticConfig.neverFlatten ? 'neverFlatten' : '')\n console.log(' - attrs (end):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n onExtractTag({\n attrs,\n node,\n lineNumbers,\n filePath,\n attemptEval,\n jsxPath: traversePath,\n originalNodeName,\n isFlattened: shouldFlatten,\n programPath,\n })\n },\n })\n\n /**\n * Step 3: Remove dead code from removed media query / theme hooks\n */\n if (modifiedComponents.size) {\n const all = Array.from(modifiedComponents)\n if (shouldPrintDebug) {\n console.log(' [\uD83E\uDE9D] hook check', all.length)\n }\n for (const comp of all) {\n removeUnusedHooks(comp, shouldPrintDebug)\n }\n }\n\n return res\n },\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA4C;AAC5C,QAAmB;AACnB,uBAQO;AAEP,oBAAiC;AAEjC,uBAA4B;AAQ5B,6BAAqD;AACrD,6BAAgC;AAChC,4BAAiF;AACjF,iCAAoC;AACpC,uCAA0C;AAC1C,0BAA6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;AACjB,gBAAI;AACJ,gBAAI,gBAAgB;AAClB,6BAAe,KAAK,OAAO;AAAA,YAC7B;AAAA,UACF;AAEA,cAAI,kBAAkB;AAEpB,oBAAQ,IAAI,+BAAqB,QAAQ,UAAU,cAAc,aAAa,IAAI,YAAY,gBAAgB,IAAI,aAAa,eAAe,iBAAiB,EAAE;AACjK,oBAAQ,IAAI,sBAAsB,8BAAS,MAAM,IAAI,6BAAO,EAAE,KAAK,IAAI,CAAC,CAAC;AAAA,UAC3E;AAEA,uBAAa;AAAA,YACX;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAS;AAAA,YACT;AAAA,YACA,aAAa;AAAA,YACb;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAKD,UAAI,mBAAmB,MAAM;AAC3B,cAAM,MAAM,MAAM,KAAK,kBAAkB;AACzC,YAAI,kBAAkB;AACpB,kBAAQ,IAAI,4BAAqB,IAAI,MAAM;AAAA,QAC7C;AACA,mBAAW,QAAQ,KAAK;AACtB,0DAAkB,MAAM,gBAAgB;AAAA,QAC1C;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAn9CgB;",
|
|
4
|
+
"sourcesContent": ["import traverse, { NodePath, Visitor } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport {\n StackProps,\n StaticConfigParsed,\n TamaguiInternalConfig,\n getSplitStyles,\n mediaQueryConfig,\n pseudos,\n rnw,\n} from '@tamagui/core-node'\nimport { stylePropsTransform } from '@tamagui/helpers'\nimport { difference, pick } from 'lodash'\n\nimport { FAILED_EVAL } from '../constants'\nimport {\n ExtractedAttr,\n ExtractedAttrAttr,\n ExtractedAttrStyle,\n ExtractorParseProps,\n Ternary,\n} from '../types'\nimport { createEvaluator, createSafeEvaluator } from './createEvaluator'\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { attrStr, findComponentName, isInsideTamagui, isPresent, objToStr } from './extractHelpers'\nimport { findTopmostFunction } from './findTopmostFunction'\nimport { getStaticBindingsForScope } from './getStaticBindingsForScope'\nimport { literalToAst } from './literalToAst'\nimport { loadTamagui } from './loadTamagui'\nimport { logLines } from './logLines'\nimport { normalizeTernaries } from './normalizeTernaries'\nimport { removeUnusedHooks } from './removeUnusedHooks'\nimport { validHTMLAttributes } from './validHTMLAttributes'\n\nconst UNTOUCHED_PROPS = {\n key: true,\n style: true,\n className: true,\n}\n\nconst INLINE_EXTRACTABLE = {\n ref: 'ref',\n key: 'key',\n onPress: 'onClick',\n onHoverIn: 'onMouseEnter',\n onHoverOut: 'onMouseLeave',\n onPressIn: 'onMouseDown',\n onPressOut: 'onMouseUp',\n}\n\nconst isAttr = (x: ExtractedAttr): x is ExtractedAttrAttr => x.type === 'attr'\n\nconst validHooks = {\n useMedia: true,\n useTheme: true,\n}\n\nexport type Extractor = ReturnType<typeof createExtractor>\n\nconst createTernary = (x: Ternary) => x\n\nexport function createExtractor() {\n if (!process.env.TAMAGUI_TARGET) {\n console.log('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either \"web\" or \"native\"')\n process.exit(1)\n }\n\n const shouldAddDebugProp =\n // really basic disable this for next.js because it messes with ssr\n !process.env.npm_package_dependencies_next &&\n process.env.TAMAGUI_TARGET !== 'native' &&\n process.env.IDENTIFY_TAGS !== 'false' &&\n (process.env.NODE_ENV === 'development' || process.env.DEBUG || process.env.IDENTIFY_TAGS)\n\n // ts imports\n require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n let loadedTamaguiConfig: TamaguiInternalConfig\n let hasLogged = false\n\n return {\n getTamagui() {\n return loadedTamaguiConfig\n },\n parse: (\n fileOrPath: NodePath<t.Program> | t.File,\n {\n config = 'tamagui.config.ts',\n importsWhitelist = ['constants.js'],\n evaluateVars = true,\n shouldPrintDebug = false,\n sourcePath = '',\n onExtractTag,\n getFlattenedNode,\n disable,\n disableExtraction,\n disableExtractInlineMedia,\n disableExtractVariables,\n disableDebugAttr,\n prefixLogs,\n excludeProps,\n ...props\n }: ExtractorParseProps\n ) => {\n if (disable) {\n return null\n }\n\n if (sourcePath === '') {\n throw new Error(`Must provide a source file name`)\n }\n if (!Array.isArray(props.components)) {\n throw new Error(`Must provide components array with list of Tamagui component modules`)\n }\n\n // we require it after parse because we need to set some global/env stuff before importing\n // otherwise we'd import `rnw` and cause it to evaluate react-native-web which causes errors\n const { components, tamaguiConfig } = loadTamagui({\n config,\n components: props.components || ['tamagui'],\n })\n\n loadedTamaguiConfig = tamaguiConfig as any\n\n const defaultTheme = tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]]\n const body = fileOrPath.type === 'Program' ? fileOrPath.get('body') : fileOrPath.program.body\n\n /**\n * Step 1: Determine if importing any statically extractable components\n */\n const isInternalImport = (importStr: string) => {\n return isInsideTamagui(sourcePath) && importStr[0] === '.'\n }\n\n const validComponents: { [key: string]: any } = Object.keys(components)\n // check if uppercase to avoid hitting media query proxy before init\n .filter((key) => key[0].toUpperCase() === key[0] && !!components[key]?.staticConfig)\n .reduce((obj, name) => {\n obj[name] = components[name]\n return obj\n }, {})\n\n let doesUseValidImport = false\n let hasImportedTheme = false\n\n for (const bodyPath of body) {\n if (bodyPath.type !== 'ImportDeclaration') continue\n const node = ('node' in bodyPath ? bodyPath.node : bodyPath) as any\n const from = node.source.value\n if (props.components.includes(from) || isInternalImport(from)) {\n if (\n node.specifiers.some((specifier) => {\n const name = specifier.local.name\n return validComponents[name] || validHooks[name]\n })\n ) {\n doesUseValidImport = true\n break\n }\n }\n }\n\n if (shouldPrintDebug) {\n console.log(sourcePath, { doesUseValidImport })\n }\n\n if (!doesUseValidImport) {\n return null\n }\n\n let couldntParse = false\n const modifiedComponents = new Set<NodePath<any>>()\n\n // only keeping a cache around per-file, reset it if it changes\n const bindingCache: Record<string, string | null> = {}\n\n const callTraverse = (a: Visitor<{}>) => {\n return fileOrPath.type === 'File' ? traverse(fileOrPath, a) : fileOrPath.traverse(a)\n }\n\n /**\n * Step 2: Statically extract from JSX < /> nodes\n */\n let programPath: NodePath<t.Program>\n\n const res = {\n flattened: 0,\n optimized: 0,\n modified: 0,\n found: 0,\n }\n\n callTraverse({\n Program: {\n enter(path) {\n programPath = path\n },\n },\n JSXElement(traversePath) {\n const node = traversePath.node.openingElement\n const ogAttributes = node.attributes\n const componentName = findComponentName(traversePath.scope)\n const closingElement = traversePath.node.closingElement\n\n // skip non-identifier opening elements (member expressions, etc.)\n if (t.isJSXMemberExpression(closingElement?.name) || !t.isJSXIdentifier(node.name)) {\n return\n }\n\n // validate its a proper import from tamagui (or internally inside tamagui)\n const binding = traversePath.scope.getBinding(node.name.name)\n\n if (binding) {\n if (!t.isImportDeclaration(binding.path.parent)) {\n return\n }\n const source = binding.path.parent.source\n if (!props.components.includes(source.value) && !isInternalImport(source.value)) {\n return\n }\n if (!validComponents[binding.identifier.name]) {\n return\n }\n }\n\n const component = validComponents[node.name.name] as { staticConfig?: StaticConfigParsed }\n if (!component || !component.staticConfig) {\n return\n }\n\n const originalNodeName = node.name.name\n\n // found a valid tag\n res.found++\n\n const filePath = sourcePath.replace(process.cwd(), '.')\n const lineNumbers = node.loc\n ? node.loc.start.line +\n (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : '')\n : ''\n const preName = componentName ? `${componentName}.` : ''\n const tagId = `${preName}${node.name.name}@${filePath.replace('./', '')}:${lineNumbers}`\n\n if (shouldPrintDebug) {\n console.log(`\\n<${originalNodeName} /> (${tagId})`)\n }\n\n // add data-is\n if (shouldAddDebugProp && !disableDebugAttr) {\n res.modified++\n node.attributes.unshift(\n t.jsxAttribute(t.jsxIdentifier('data-is'), t.stringLiteral(tagId))\n )\n }\n\n const shouldLog = !hasLogged\n if (shouldLog) {\n const prefix = ' |'\n console.log(\n prefixLogs || prefix,\n ' total \u00B7 optimized \u00B7 flattened '\n )\n hasLogged = true\n }\n if (disableExtraction) {\n return\n }\n\n const { staticConfig } = component\n const isTextView = staticConfig.isText || false\n const validStyles = staticConfig?.validStyles ?? {}\n\n function isValidStyleKey(name: string) {\n return !!(\n !!validStyles[name] ||\n !!pseudos[name] ||\n staticConfig.variants?.[name] ||\n tamaguiConfig.shorthands[name] ||\n (name[0] === '$' ? !!mediaQueryConfig[name.slice(1)] : false)\n )\n }\n\n // find tag=\"a\" tag=\"main\" etc dom indicators\n let tagName = staticConfig.defaultProps?.tag ?? (isTextView ? 'span' : 'div')\n traversePath\n .get('openingElement')\n .get('attributes')\n .forEach((path) => {\n const attr = path.node\n if (t.isJSXSpreadAttribute(attr)) return\n if (attr.name.name !== 'tag') return\n const val = attr.value\n if (!t.isStringLiteral(val)) return\n tagName = val.value\n })\n\n const flatNode = getFlattenedNode({ isTextView, tag: tagName })\n\n const inlineProps = new Set([\n ...(props.inlineProps || []),\n ...(staticConfig.inlineProps || []),\n ])\n const deoptProps = new Set([\n // always de-opt animation\n 'animation',\n ...(props.deoptProps || []),\n ...(staticConfig.deoptProps || []),\n ])\n\n // Generate scope object at this level\n const staticNamespace = getStaticBindingsForScope(\n traversePath.scope,\n importsWhitelist,\n sourcePath,\n bindingCache,\n shouldPrintDebug\n )\n\n const attemptEval = !evaluateVars\n ? evaluateAstNode\n : createEvaluator({\n // @ts-ignore\n tamaguiConfig,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n })\n const attemptEvalSafe = createSafeEvaluator(attemptEval)\n\n if (shouldPrintDebug) {\n console.log(' staticNamespace', Object.keys(staticNamespace).join(', '))\n }\n\n //\n // SPREADS SETUP\n //\n\n // TODO restore\n // const hasDeopt = (obj: Object) => {\n // return Object.keys(obj).some(isDeoptedProp)\n // }\n\n // flatten any easily evaluatable spreads\n const flattenedAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n traversePath\n .get('openingElement')\n .get('attributes')\n .forEach((path) => {\n const attr = path.node\n if (!t.isJSXSpreadAttribute(attr)) {\n flattenedAttrs.push(attr)\n return\n }\n let arg: any\n try {\n arg = attemptEval(attr.argument)\n } catch (e: any) {\n if (shouldPrintDebug) {\n console.log(' couldnt parse spread', e.message)\n }\n flattenedAttrs.push(attr)\n return\n }\n if (arg !== undefined) {\n try {\n if (typeof arg !== 'object' || arg == null) {\n if (shouldPrintDebug) {\n console.log(' non object or null arg', arg)\n }\n flattenedAttrs.push(attr)\n } else {\n for (const k in arg) {\n const value = arg[k]\n // this is a null prop:\n if (!value && typeof value === 'object') {\n console.log('shouldnt we handle this?', k, value, arg)\n continue\n }\n flattenedAttrs.push(\n t.jsxAttribute(\n t.jsxIdentifier(k),\n t.jsxExpressionContainer(literalToAst(value))\n )\n )\n }\n }\n } catch (err) {\n console.warn('cant parse spread, caught err', err)\n couldntParse = true\n }\n }\n })\n\n if (couldntParse) {\n return\n }\n\n // set flattened\n node.attributes = flattenedAttrs\n\n // add in NON-STYLE default props\n if (staticConfig.defaultProps) {\n for (const key in staticConfig.defaultProps) {\n if (isValidStyleKey(key)) {\n continue\n }\n const serialize = require('babel-literal-to-ast')\n const val = staticConfig.defaultProps[key]\n try {\n const serializedDefaultProp = serialize(val)\n node.attributes.unshift(\n t.jsxAttribute(\n t.jsxIdentifier(key),\n typeof val === 'string'\n ? t.stringLiteral(val)\n : t.jsxExpressionContainer(serializedDefaultProp)\n )\n )\n } catch (err) {\n console.warn(\n `\u26A0\uFE0F Error evaluating default prop for component ${node.name.name}, prop ${key}\\n error: ${err}\\n value:`,\n val,\n '\\n defaultProps:',\n staticConfig.defaultProps\n )\n }\n }\n }\n\n let attrs: ExtractedAttr[] = []\n let shouldDeopt = false\n const inlined = new Map<string, boolean | string>()\n let hasSetOptimized = false\n\n // RUN first pass\n\n // normalize all conditionals so we can evaluate away easier later\n // at the same time lets normalize shorthand media queries into spreads:\n // that way we can parse them with the same logic later on\n //\n // {...media.sm && { color: x ? 'red' : 'blue' }}\n // => {...media.sm && x && { color: 'red' }}\n // => {...media.sm && !x && { color: 'blue' }}\n //\n // $sm={{ color: 'red' }}\n // => {...media.sm && { color: 'red' }}\n //\n // $sm={{ color: x ? 'red' : 'blue' }}\n // => {...media.sm && x && { color: 'red' }}\n // => {...media.sm && !x && { color: 'blue' }}\n\n attrs = traversePath\n .get('openingElement')\n .get('attributes')\n .flatMap((path) => {\n try {\n const res = evaluateAttribute(path)\n if (!res) {\n path.remove()\n }\n return res\n } catch (err: any) {\n if (shouldPrintDebug) {\n console.log('Error extracting attribute', err.message, err.stack)\n console.log('node', path.node)\n }\n return {\n type: 'attr',\n value: path.node,\n } as const\n }\n })\n .flat(4)\n .filter(isPresent)\n\n if (shouldPrintDebug) {\n console.log(' - attrs (before):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // START function evaluateAttribute\n function evaluateAttribute(\n path: NodePath<t.JSXAttribute | t.JSXSpreadAttribute>\n ): ExtractedAttr | ExtractedAttr[] | null {\n const attribute = path.node\n const attr: ExtractedAttr = { type: 'attr', value: attribute }\n // ...spreads\n if (t.isJSXSpreadAttribute(attribute)) {\n const arg = attribute.argument\n const conditional = t.isConditionalExpression(arg)\n ? // <YStack {...isSmall ? { color: 'red } : { color: 'blue }}\n ([arg.test, arg.consequent, arg.alternate] as const)\n : t.isLogicalExpression(arg) && arg.operator === '&&'\n ? // <YStack {...isSmall && { color: 'red }}\n ([arg.left, arg.right, null] as const)\n : null\n\n if (conditional) {\n const [test, alt, cons] = conditional\n if (!test) throw new Error(`no test`)\n if ([alt, cons].some((side) => side && !isExtractable(side))) {\n if (shouldPrintDebug) {\n console.log('not extractable', alt, cons)\n }\n return attr\n }\n // split into individual ternaries per object property\n return [\n ...(createTernariesFromObjectProperties(test, alt) || []),\n ...((cons &&\n createTernariesFromObjectProperties(t.unaryExpression('!', test), cons)) ||\n []),\n ].map((ternary) => ({\n type: 'ternary',\n value: ternary,\n }))\n }\n }\n // END ...spreads\n\n // directly keep these\n // couldn't evaluate spread, undefined name, or name is not string\n if (\n t.isJSXSpreadAttribute(attribute) ||\n !attribute.name ||\n typeof attribute.name.name !== 'string'\n ) {\n if (shouldPrintDebug) {\n console.log(' ! inlining, spread attr')\n }\n inlined.set(`${Math.random()}`, 'spread')\n return attr\n }\n\n const name = attribute.name.name\n\n if (excludeProps?.has(name)) {\n if (shouldPrintDebug) {\n console.log(' excluding prop', name)\n }\n return null\n }\n\n if (inlineProps.has(name)) {\n inlined.set(name, name)\n if (shouldPrintDebug) {\n console.log(' ! inlining, inline prop', name)\n }\n return attr\n }\n\n // can still optimize the object... see hoverStyle on native\n if (deoptProps.has(name)) {\n shouldDeopt = true\n inlined.set(name, name)\n if (shouldPrintDebug) {\n console.log(' ! inlining, deopted prop', name)\n }\n return attr\n }\n\n // pass className, key, and style props through untouched\n if (UNTOUCHED_PROPS[name]) {\n return attr\n }\n\n if (INLINE_EXTRACTABLE[name]) {\n inlined.set(name, INLINE_EXTRACTABLE[name])\n return attr\n }\n\n if (name.startsWith('data-')) {\n return attr\n }\n\n // shorthand media queries\n if (name[0] === '$' && t.isJSXExpressionContainer(attribute?.value)) {\n // allow disabling this extraction\n if (disableExtractInlineMedia) {\n return attr\n }\n\n const shortname = name.slice(1)\n if (mediaQueryConfig[shortname]) {\n const expression = attribute.value.expression\n if (!t.isJSXEmptyExpression(expression)) {\n const ternaries = createTernariesFromObjectProperties(\n t.stringLiteral(shortname),\n expression,\n {\n inlineMediaQuery: shortname,\n }\n )\n if (ternaries) {\n return ternaries.map((value) => ({\n type: 'ternary',\n value,\n }))\n }\n }\n }\n }\n\n const [value, valuePath] = (() => {\n if (t.isJSXExpressionContainer(attribute?.value)) {\n return [attribute.value.expression!, path.get('value')!] as const\n } else {\n return [attribute.value!, path.get('value')!] as const\n }\n })()\n\n const remove = () => {\n Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove()\n }\n\n if (name === 'ref') {\n if (shouldPrintDebug) {\n console.log(' ! inlining, ref', name)\n }\n inlined.set('ref', 'ref')\n return attr\n }\n\n if (name === 'tag') {\n return {\n type: 'attr',\n value: path.node,\n }\n }\n\n // native shouldn't extract variables\n if (disableExtractVariables) {\n if (value) {\n if (value.type === 'StringLiteral' && value.value[0] === '$') {\n if (shouldPrintDebug) {\n console.log(` ! inlining, native disable extract: ${name} =`, value.value)\n }\n inlined.set(name, true)\n return attr\n }\n }\n }\n\n // if value can be evaluated, extract it and filter it out\n const styleValue = attemptEvalSafe(value)\n\n // never flatten if a prop isn't a valid static attribute\n // only post prop-mapping\n if (!isValidStyleKey(name)) {\n let keys = [name]\n let out: any = null\n if (staticConfig.propMapper) {\n // for now passing empty props {}, a bit odd, need to at least document\n // for now we don't expose custom components so just noting behavior\n out = staticConfig.propMapper(\n name,\n styleValue,\n defaultTheme,\n staticConfig.defaultProps,\n 'auto'\n )\n if (out) {\n // translate to DOM-compat\n out = rnw.createDOMProps(isTextView ? 'span' : 'div', out)\n // remove className - we dont use rnw styling\n delete out.className\n\n keys = Object.keys(out)\n }\n }\n\n let didInline = false\n const attributes = keys.map((key) => {\n const val = out[key]\n if (key === 'theme') {\n inlined.set(key, val)\n return attr\n }\n if (isValidStyleKey(key)) {\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\n } as const\n }\n if (validHTMLAttributes[key]) {\n return attr\n }\n if (shouldPrintDebug) {\n console.log(' ! inlining, non-static', key)\n }\n didInline = true\n inlined.set(key, val)\n return val\n })\n\n // weird logic whats going on here\n if (didInline) {\n if (shouldPrintDebug) {\n console.log(' bailing flattening due to attributes', attributes)\n }\n // bail\n return attr\n }\n\n // return evaluated attributes\n return attributes\n }\n\n // FAILED = dynamic or ternary, keep going\n if (styleValue !== FAILED_EVAL) {\n if (isValidStyleKey(name)) {\n if (shouldPrintDebug) {\n console.log(` style: ${name} =`, styleValue)\n }\n if (!(name in staticConfig.defaultProps)) {\n if (!hasSetOptimized) {\n res.optimized++\n hasSetOptimized = true\n }\n }\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\n }\n } else {\n inlined.set(name, true)\n return attr\n }\n }\n\n // ternaries!\n\n // binary ternary, we can eventually make this smarter but step 1\n // basically for the common use case of:\n // opacity={(conditional ? 0 : 1) * scale}\n if (t.isBinaryExpression(value)) {\n if (shouldPrintDebug) {\n console.log(` binary expression ${name} = `, value)\n }\n const { operator, left, right } = value\n // if one side is a ternary, and the other side is evaluatable, we can maybe extract\n const lVal = attemptEvalSafe(left)\n const rVal = attemptEvalSafe(right)\n if (shouldPrintDebug) {\n console.log(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`)\n }\n if (lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {\n const ternary = addBinaryConditional(operator, left, right)\n if (ternary) return ternary\n }\n if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {\n const ternary = addBinaryConditional(operator, right, left)\n if (ternary) return ternary\n }\n if (shouldPrintDebug) {\n console.log(` evalBinaryExpression cant extract`)\n }\n inlined.set(name, true)\n return attr\n }\n\n const staticConditional = getStaticConditional(value)\n if (staticConditional) {\n if (shouldPrintDebug) {\n console.log(` static conditional ${name} = `, value)\n }\n return { type: 'ternary', value: staticConditional }\n }\n\n const staticLogical = getStaticLogical(value)\n if (staticLogical) {\n if (shouldPrintDebug) {\n console.log(` static ternary ${name} = `, value)\n }\n return { type: 'ternary', value: staticLogical }\n }\n\n // if we've made it this far, the prop stays inline\n inlined.set(name, true)\n if (shouldPrintDebug) {\n console.log(` ! inline no match ${name}`, value)\n }\n\n //\n // RETURN ATTR\n //\n return attr\n\n // attr helpers:\n function addBinaryConditional(\n operator: any,\n staticExpr: any,\n cond: t.ConditionalExpression\n ): ExtractedAttr | null {\n if (getStaticConditional(cond)) {\n const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate))\n const cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent))\n if (shouldPrintDebug) {\n console.log(' binaryConditional', cond.test, cons, alt)\n }\n return {\n type: 'ternary',\n value: {\n test: cond.test,\n remove,\n alternate: { [name]: alt },\n consequent: { [name]: cons },\n },\n }\n }\n return null\n }\n\n function getStaticConditional(value: t.Node): Ternary | null {\n if (t.isConditionalExpression(value)) {\n try {\n if (shouldPrintDebug) {\n console.log('attempt', value.alternate, value.consequent)\n }\n const aVal = attemptEval(value.alternate)\n const cVal = attemptEval(value.consequent)\n if (shouldPrintDebug) {\n const type = value.test.type\n console.log(' static ternary', type, cVal, aVal)\n }\n return {\n test: value.test,\n remove,\n consequent: { [name]: cVal },\n alternate: { [name]: aVal },\n }\n } catch (err: any) {\n if (shouldPrintDebug) {\n console.log(' cant eval ternary', err.message)\n }\n }\n }\n return null\n }\n\n function getStaticLogical(value: t.Node): Ternary | null {\n if (t.isLogicalExpression(value)) {\n if (value.operator === '&&') {\n try {\n const val = attemptEval(value.right)\n if (shouldPrintDebug) {\n console.log(' staticLogical', value.left, name, val)\n }\n return {\n test: value.left,\n remove,\n consequent: { [name]: val },\n alternate: null,\n }\n } catch (err) {\n if (shouldPrintDebug) {\n console.log(' cant static eval logical', err)\n }\n }\n }\n }\n return null\n }\n } // END function evaluateAttribute\n\n function isExtractable(obj: t.Node): obj is t.ObjectExpression {\n return (\n t.isObjectExpression(obj) &&\n obj.properties.every((prop) => {\n if (!t.isObjectProperty(prop)) {\n console.log('not object prop', prop)\n return false\n }\n const propName = prop.key['name']\n if (!isValidStyleKey(propName) && propName !== 'tag') {\n if (shouldPrintDebug) {\n console.log(' not a valid style prop!', propName)\n }\n return false\n }\n return true\n })\n )\n }\n\n // side = {\n // color: 'red',\n // background: x ? 'red' : 'green',\n // $gtSm: { color: 'green' }\n // }\n // => Ternary<test, { color: 'red' }, null>\n // => Ternary<test && x, { background: 'red' }, null>\n // => Ternary<test && !x, { background: 'green' }, null>\n // => Ternary<test && '$gtSm', { color: 'green' }, null>\n function createTernariesFromObjectProperties(\n test: t.Expression,\n side: t.Expression | null,\n ternaryPartial: Partial<Ternary> = {}\n ): null | Ternary[] {\n if (!side) {\n return null\n }\n if (!isExtractable(side)) {\n throw new Error('not extractable')\n }\n return side.properties.flatMap((property) => {\n if (!t.isObjectProperty(property)) {\n throw new Error('expected object property')\n }\n // handle media queries inside spread/conditional objects\n if (t.isIdentifier(property.key)) {\n const key = property.key.name\n const mediaQueryKey = key.slice(1)\n const isMediaQuery = key[0] === '$' && mediaQueryConfig[mediaQueryKey]\n if (isMediaQuery) {\n if (t.isExpression(property.value)) {\n const ternaries = createTernariesFromObjectProperties(\n t.stringLiteral(mediaQueryKey),\n property.value,\n {\n inlineMediaQuery: mediaQueryKey,\n }\n )\n if (ternaries) {\n return ternaries.map((value) => ({\n ...ternaryPartial,\n ...value,\n // ensure media query test stays on left side (see getMediaQueryTernary)\n test: t.logicalExpression('&&', value.test, test),\n }))\n } else {\n console.log('\u26A0\uFE0F no ternaries?', property)\n }\n } else {\n console.log('\u26A0\uFE0F not expression', property)\n }\n }\n }\n // this could be a recurse here if we want to get fancy\n if (t.isConditionalExpression(property.value)) {\n // merge up into the parent conditional, split into two\n const [truthy, falsy] = [\n t.objectExpression([t.objectProperty(property.key, property.value.consequent)]),\n t.objectExpression([t.objectProperty(property.key, property.value.alternate)]),\n ].map((x) => attemptEval(x))\n return [\n createTernary({\n remove() {},\n ...ternaryPartial,\n test: t.logicalExpression('&&', test, property.value.test),\n consequent: truthy,\n alternate: null,\n }),\n createTernary({\n ...ternaryPartial,\n test: t.logicalExpression(\n '&&',\n test,\n t.unaryExpression('!', property.value.test)\n ),\n consequent: falsy,\n alternate: null,\n remove() {},\n }),\n ]\n }\n const obj = t.objectExpression([t.objectProperty(property.key, property.value)])\n const consequent = attemptEval(obj)\n return createTernary({\n remove() {},\n ...ternaryPartial,\n test,\n consequent,\n alternate: null,\n })\n })\n }\n\n // now update to new values\n node.attributes = attrs.filter(isAttr).map((x) => x.value)\n\n if (couldntParse || shouldDeopt) {\n if (shouldPrintDebug) {\n console.log(` avoid optimizing:`, { couldntParse, shouldDeopt })\n }\n node.attributes = ogAttributes\n return\n }\n\n // before deopt, can still optimize\n const parentFn = findTopmostFunction(traversePath)\n if (parentFn) {\n modifiedComponents.add(parentFn)\n }\n\n // combine ternaries\n let ternaries: Ternary[] = []\n attrs = attrs\n .reduce<(ExtractedAttr | ExtractedAttr[])[]>((out, cur) => {\n const next = attrs[attrs.indexOf(cur) + 1]\n if (cur.type === 'ternary') {\n ternaries.push(cur.value)\n }\n if ((!next || next.type !== 'ternary') && ternaries.length) {\n // finish, process\n const normalized = normalizeTernaries(ternaries).map(\n ({ alternate, consequent, ...rest }) => {\n return {\n type: 'ternary' as const,\n value: {\n ...rest,\n alternate: alternate || null,\n consequent: consequent || null,\n },\n }\n }\n )\n try {\n return [...out, ...normalized]\n } finally {\n if (shouldPrintDebug) {\n console.log(\n ` normalizeTernaries (${ternaries.length} => ${normalized.length})`\n )\n }\n ternaries = []\n }\n }\n if (cur.type === 'ternary') {\n return out\n }\n out.push(cur)\n return out\n }, [])\n .flat()\n\n // evaluates all static attributes into a simple object\n const completeStaticProps = {\n ...Object.keys(attrs).reduce((acc, index) => {\n const cur = attrs[index] as ExtractedAttr\n if (cur.type === 'style') {\n Object.assign(acc, cur.value)\n }\n if (cur.type === 'attr') {\n if (t.isJSXSpreadAttribute(cur.value)) {\n return acc\n }\n if (!t.isJSXIdentifier(cur.value.name)) {\n return acc\n }\n const key = cur.value.name.name\n // undefined = boolean true\n const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true))\n if (value === FAILED_EVAL) {\n return acc\n }\n acc[key] = value\n }\n return acc\n }, {}),\n }\n\n // flatten logic!\n // fairly simple check to see if all children are text\n const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x))\n\n const hasOnlyStringChildren =\n !hasSpread &&\n (node.selfClosing ||\n (traversePath.node.children &&\n traversePath.node.children.every((x) => x.type === 'JSXText')))\n\n const themeVal = inlined.get('theme')\n inlined.delete('theme')\n const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k])\n const shouldWrapInnerTheme =\n allOtherPropsExtractable && !!(hasOnlyStringChildren && themeVal)\n const canFlattenProps =\n inlined.size === 0 || shouldWrapInnerTheme || allOtherPropsExtractable\n\n let shouldFlatten =\n !shouldDeopt &&\n canFlattenProps &&\n !hasSpread &&\n staticConfig.neverFlatten !== true &&\n (staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)\n\n // wrap theme around children on flatten\n if (shouldFlatten && shouldWrapInnerTheme) {\n if (typeof themeVal !== 'string') {\n console.warn('??')\n return\n }\n\n if (shouldPrintDebug) {\n console.log(' - wrapping theme', allOtherPropsExtractable, themeVal)\n }\n\n // add import\n if (!hasImportedTheme) {\n hasImportedTheme = true\n programPath.node.body.push(\n t.importDeclaration(\n [t.importSpecifier(t.identifier('_TamaguiTheme'), t.identifier('Theme'))],\n t.stringLiteral('@tamagui/core')\n )\n )\n }\n\n traversePath.replaceWith(\n t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier('_TamaguiTheme'), [\n t.jsxAttribute(t.jsxIdentifier('name'), t.stringLiteral(`${themeVal}`)),\n ]),\n t.jsxClosingElement(t.jsxIdentifier('_TamaguiTheme')),\n [traversePath.node]\n )\n )\n }\n\n // only if we flatten, ensure the default styles are there\n if (shouldFlatten && staticConfig.defaultProps) {\n const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {\n if (!isValidStyleKey(key)) {\n return\n }\n try {\n const serialize = require('babel-literal-to-ast')\n const val = staticConfig.defaultProps[key]\n const value = serialize(val)\n const name = tamaguiConfig.shorthands[key] || key\n return {\n type: 'style',\n name,\n value,\n } as ExtractedAttrStyle\n } catch (err) {\n console.warn(\n `\u26A0\uFE0F Error evaluating default style for component, prop ${key}\\n error: ${err}`\n )\n shouldDeopt = true\n }\n }) as ExtractedAttr[]\n\n if (defaultStyleAttrs.length) {\n attrs = [...defaultStyleAttrs, ...attrs]\n }\n }\n\n if (shouldDeopt) {\n node.attributes = ogAttributes\n return\n }\n\n // insert overrides - this inserts null props for things that are set in classNames\n // only when not flattening, so the downstream component can skip applying those styles\n const ensureOverridden = {}\n if (!shouldFlatten) {\n for (const cur of attrs) {\n if (cur.type === 'style') {\n // TODO need to loop over initial props not just style props\n for (const key in cur.value) {\n const shouldEnsureOverridden = !!staticConfig.ensureOverriddenProp?.[key]\n const isSetInAttrsAlready = attrs.some(\n (x) =>\n x.type === 'attr' &&\n x.value.type === 'JSXAttribute' &&\n x.value.name.name === key\n )\n\n if (!isSetInAttrsAlready) {\n const isVariant = !!staticConfig.variants?.[cur.name || '']\n if (isVariant || shouldEnsureOverridden) {\n ensureOverridden[key] = true\n }\n }\n }\n }\n }\n }\n\n if (shouldPrintDebug) {\n console.log(' - attrs (flattened): \\n', logLines(attrs.map(attrStr).join(', ')))\n console.log(' - ensureOverriden:', Object.keys(ensureOverridden).join(', '))\n }\n\n // expand shorthands, de-opt variables\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (!cur) {\n return acc\n }\n\n if (cur.type === 'attr' && !t.isJSXSpreadAttribute(cur.value)) {\n if (shouldFlatten) {\n if (cur.value.name.name === 'tag') {\n // remove tag=\"\"\n return acc\n }\n }\n }\n\n if (cur.type !== 'style') {\n acc.push(cur)\n return acc\n }\n\n let key = Object.keys(cur.value)[0]\n const value = cur.value[key]\n const fullKey = tamaguiConfig.shorthands[key]\n\n // expand shorthands\n if (fullKey) {\n cur.value = { [fullKey]: value }\n key = fullKey\n }\n\n // finally we have all styles + expansions, lets see if we need to skip\n // any and keep them as attrs\n if (disableExtractVariables) {\n if (value[0] === '$') {\n if (shouldPrintDebug) {\n console.log(` keeping variable inline: ${key} =`, value)\n }\n acc.push({\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(t.stringLiteral(value))\n ),\n })\n return acc\n }\n }\n\n acc.push(cur)\n return acc\n }, [])\n\n if (shouldPrintDebug) {\n console.log(' - attrs (expanded): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // merge styles, leave undefined values\n let prev: ExtractedAttr | null = null\n\n function mergeStyles(prev: StackProps, next: StackProps) {\n for (const key in next) {\n // merge pseudos\n if (pseudos[key]) {\n prev[key] = prev[key] || {}\n Object.assign(prev[key], next[key])\n } else {\n prev[key] = next[key]\n }\n }\n }\n\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n const key = Object.keys(cur.value)[0]\n const value = cur.value[key]\n\n const shouldKeepOriginalAttr =\n // !isStyleAndAttr[key] &&\n !shouldFlatten &&\n // de-opt transform styles so it merges properly if not flattened\n // we handle this later on\n // (stylePropsTransform[key] ||\n // de-opt if non-style\n !validStyles[key] &&\n !pseudos[key] &&\n !key.startsWith('data-')\n\n if (shouldKeepOriginalAttr) {\n if (shouldPrintDebug) {\n console.log(' - keeping as non-style', key)\n }\n prev = cur\n acc.push({\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(\n typeof value === 'string' ? t.stringLiteral(value) : literalToAst(value)\n )\n ),\n })\n acc.push(cur)\n return acc\n }\n\n if (ensureOverridden[key]) {\n acc.push({\n type: 'attr',\n value:\n cur.attr ||\n t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(t.nullLiteral())),\n })\n }\n\n if (prev?.type === 'style') {\n mergeStyles(prev.value as StackProps, cur.value as StackProps)\n return acc\n }\n }\n\n prev = cur\n acc.push(cur)\n return acc\n }, [])\n\n if (shouldPrintDebug) {\n console.log(' - attrs (combined \uD83D\uDD00): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n const completeProps = {\n ...staticConfig.defaultProps,\n ...completeStaticProps,\n }\n\n // post process\n const getStyles = (props: Object | null, debugName = '') => {\n if (!props) return\n if (!Object.keys(props).length) return\n if (excludeProps && !!excludeProps.size) {\n for (const key in props) {\n if (excludeProps.has(key)) {\n delete props[key]\n }\n }\n }\n const out = getSplitStyles(props, staticConfig, defaultTheme, {\n noClassNames: true,\n fallbackProps: completeProps,\n focus: false,\n hover: false,\n mounted: true,\n press: false,\n pressIn: false,\n })\n const outStyle = {\n ...out.style,\n ...out.pseudos,\n }\n for (const key in outStyle) {\n if (staticConfig.validStyles) {\n if (!staticConfig.validStyles[key] && !pseudos[key]) {\n delete outStyle[key]\n }\n }\n }\n if (shouldPrintDebug === 'verbose') {\n // prettier-ignore\n console.log(` getStyles ${debugName} (props):\\n`, logLines(objToStr(props)))\n // prettier-ignore\n console.log(` getStyles ${debugName} (out.viewProps):\\n`, logLines(objToStr(out.viewProps)))\n // prettier-ignore\n console.log(` getStyles ${debugName} (out.style):\\n`, logLines(objToStr(outStyle || {}), true))\n }\n return outStyle\n }\n\n // used to ensure we pass the entire prop bundle to getStyles\n const completeStylesProcessed = getStyles(completeProps, 'completeStylesProcessed')\n\n if (!completeStylesProcessed) {\n throw new Error(`Impossible, no styles`)\n }\n\n // any extra styles added in postprocess should be added to first group as they wont be overriden\n // const stylesToAddToInitialGroup = difference(\n // Object.keys(completeStylesProcessed),\n // Object.keys(completeStaticProps)\n // )\n const stylesToAddToInitialGroup = shouldFlatten\n ? difference(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps))\n : []\n\n if (stylesToAddToInitialGroup.length) {\n const toAdd = pick(completeStylesProcessed, ...stylesToAddToInitialGroup)\n const firstGroup = attrs.find((x) => x.type === 'style')\n if (shouldPrintDebug) {\n console.log(' toAdd', objToStr(toAdd))\n }\n if (!firstGroup) {\n attrs.unshift({ type: 'style', value: toAdd })\n } else {\n Object.assign(firstGroup.value, toAdd)\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' -- stylesToAddToInitialGroup', stylesToAddToInitialGroup.join(', '), { shouldFlatten })\n // prettier-ignore\n console.log(' -- completeStaticProps:\\n', logLines(objToStr(completeStaticProps)))\n // prettier-ignore\n console.log(' -- completeStylesProcessed:\\n', logLines(objToStr(completeStylesProcessed)))\n }\n\n let getStyleError: any = null\n\n // fix up ternaries, combine final style values\n for (const attr of attrs) {\n try {\n if (shouldPrintDebug) console.log(' *', attrStr(attr))\n switch (attr.type) {\n case 'ternary':\n const a = getStyles(attr.value.alternate, 'ternary.alternate')\n const c = getStyles(attr.value.consequent, 'ternary.consequent')\n if (a) attr.value.alternate = a\n if (c) attr.value.consequent = c\n if (shouldPrintDebug) console.log(' => tern ', attrStr(attr))\n continue\n case 'style':\n // expand variants and such\n // get the keys we need\n const styles = getStyles(attr.value, 'style')\n if (styles) {\n // but actually resolve them to the full object\n // TODO media/psuedo merging\n attr.value = Object.fromEntries(\n Object.keys(styles).map((k) => [k, completeStylesProcessed[k]])\n )\n } else {\n console.warn('?????????')\n }\n // for (const keyIn in attr.value) {\n // const [key, value] = (() => {\n // if (keyIn in stylePropsTransform) {\n // // TODO this logic needs to be a bit more right, because could have spread in between transforms...\n // // could just output flat transforms as webkit now supports on recent versions\n // return ['transform', completeStylesProcessed['transform']] as const\n // } else {\n // return [keyIn, completeStylesProcessed[keyIn] ?? attr.value[keyIn]] as const\n // }\n // })()\n // // if (shouldPrintDebug) console.log('style', { keyIn, key, value })\n // delete attr.value[keyIn]\n // attr.value[key] = value\n // }\n continue\n }\n } catch (err) {\n // any error de-opt\n getStyleError = err\n }\n }\n\n if (getStyleError) {\n console.log(' \u26A0\uFE0F postprocessing error, deopt', getStyleError)\n node.attributes = ogAttributes\n return node\n }\n\n // final lazy extra loop:\n const existingStyleKeys = new Set()\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attr = attrs[i]\n\n // if flattening map inline props to proper flattened names\n if (shouldFlatten && canFlattenProps) {\n if (attr.type === 'attr') {\n if (t.isJSXAttribute(attr.value)) {\n if (t.isJSXIdentifier(attr.value.name)) {\n const name = attr.value.name.name\n if (INLINE_EXTRACTABLE[name]) {\n // map to HTML only name\n attr.value.name.name = INLINE_EXTRACTABLE[name]\n }\n }\n }\n }\n }\n\n // remove duplicate styles\n // so if you have:\n // style({ color: 'red' }), ...someProps, style({ color: 'green' })\n // this will mutate:\n // style({}), ...someProps, style({ color: 'green' })\n if (attr.type === 'style') {\n for (const key in attr.value) {\n if (existingStyleKeys.has(key)) {\n delete attr.value[key]\n } else {\n existingStyleKeys.add(key)\n }\n }\n }\n }\n\n if (shouldFlatten) {\n // DO FLATTEN\n if (shouldPrintDebug) {\n console.log(' [\u2705] flattening', originalNodeName, flatNode)\n }\n node.name.name = flatNode\n res.flattened++\n if (closingElement) {\n closingElement.name.name = flatNode\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(` \u274A\u274A inline props (${inlined.size}):`, shouldDeopt ? ' deopted' : '', hasSpread ? ' has spread' : '', staticConfig.neverFlatten ? 'neverFlatten' : '')\n console.log(' - attrs (end):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n onExtractTag({\n attrs,\n node,\n lineNumbers,\n filePath,\n attemptEval,\n jsxPath: traversePath,\n originalNodeName,\n isFlattened: shouldFlatten,\n programPath,\n })\n },\n })\n\n /**\n * Step 3: Remove dead code from removed media query / theme hooks\n */\n if (modifiedComponents.size) {\n const all = Array.from(modifiedComponents)\n if (shouldPrintDebug) {\n console.log(' [\uD83E\uDE9D] hook check', all.length)\n }\n for (const comp of all) {\n removeUnusedHooks(comp, shouldPrintDebug)\n }\n }\n\n return res\n },\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA4C;AAC5C,QAAmB;AACnB,uBAQO;AAEP,oBAAiC;AAEjC,uBAA4B;AAQ5B,6BAAqD;AACrD,6BAAgC;AAChC,4BAAiF;AACjF,iCAAoC;AACpC,uCAA0C;AAC1C,0BAA6B;AAC7B,yBAA4B;AAC5B,sBAAyB;AACzB,gCAAmC;AACnC,+BAAkC;AAClC,iCAAoC;AAEpC,MAAM,kBAAkB;AAAA,EACtB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AACb;AAEA,MAAM,qBAAqB;AAAA,EACzB,KAAK;AAAA,EACL,KAAK;AAAA,EACL,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AA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ACjK,oBAAQ,IAAI,sBAAsB,8BAAS,MAAM,IAAI,6BAAO,EAAE,KAAK,IAAI,CAAC,CAAC;AAAA,UAC3E;AAEA,uBAAa;AAAA,YACX;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAS;AAAA,YACT;AAAA,YACA,aAAa;AAAA,YACb;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAKD,UAAI,mBAAmB,MAAM;AAC3B,cAAM,MAAM,MAAM,KAAK,kBAAkB;AACzC,YAAI,kBAAkB;AACpB,kBAAQ,IAAI,4BAAqB,IAAI,MAAM;AAAA,QAC7C;AACA,mBAAW,QAAQ,KAAK;AACtB,0DAAkB,MAAM,gBAAgB;AAAA,QAC1C;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AA78CgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -98,8 +98,8 @@ function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importan
|
|
|
98
98
|
rules: [styleRule]
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
|
-
if (shouldPrintDebug) {
|
|
102
|
-
console.log(" media styles:", importance, singleMediaStyles.map((x) => x.identifier).join(", "));
|
|
101
|
+
if (shouldPrintDebug === "verbose") {
|
|
102
|
+
console.log(" media styles:", importance, styleObj, singleMediaStyles.map((x) => x.identifier).join(", "));
|
|
103
103
|
}
|
|
104
104
|
mediaStyles = [...mediaStyles, ...singleMediaStyles];
|
|
105
105
|
}
|