@tamagui/static 1.0.0-alpha.61 → 1.0.0-alpha.62
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 +18 -5
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +3 -0
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +18 -5
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.js +3 -0
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/jsx/extractor/createExtractor.js +18 -5
- package/dist/jsx/extractor/extractToClassNames.js +3 -0
- package/package.json +4 -4
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
|
@@ -458,10 +458,16 @@ function createExtractor() {
|
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name !== "string") {
|
|
461
|
+
if (shouldPrintDebug) {
|
|
462
|
+
console.log(" ! inlining, spread attr");
|
|
463
|
+
}
|
|
461
464
|
inlinePropCount++;
|
|
462
465
|
return attr;
|
|
463
466
|
}
|
|
464
467
|
const name = attribute.name.name;
|
|
468
|
+
if (name.startsWith("data-")) {
|
|
469
|
+
return attr;
|
|
470
|
+
}
|
|
465
471
|
if (isExcludedProp(name)) {
|
|
466
472
|
return null;
|
|
467
473
|
}
|
|
@@ -522,7 +528,7 @@ function createExtractor() {
|
|
|
522
528
|
if (value) {
|
|
523
529
|
if (value.type === "StringLiteral" && value.value[0] === "$") {
|
|
524
530
|
if (shouldPrintDebug) {
|
|
525
|
-
console.log(`
|
|
531
|
+
console.log(` ! inlining, native disable extract: ${name} =`, value.value);
|
|
526
532
|
}
|
|
527
533
|
inlinePropCount++;
|
|
528
534
|
return attr;
|
|
@@ -540,6 +546,9 @@ function createExtractor() {
|
|
|
540
546
|
}
|
|
541
547
|
for (const key of keys) {
|
|
542
548
|
if (!isStaticAttributeName(key)) {
|
|
549
|
+
if (shouldPrintDebug) {
|
|
550
|
+
console.log(" ! inlining, non-static", key);
|
|
551
|
+
}
|
|
543
552
|
inlinePropCount++;
|
|
544
553
|
}
|
|
545
554
|
}
|
|
@@ -833,7 +842,13 @@ function createExtractor() {
|
|
|
833
842
|
delete props2[key];
|
|
834
843
|
}
|
|
835
844
|
}
|
|
845
|
+
if (shouldPrintDebug) {
|
|
846
|
+
props2["debug"] = true;
|
|
847
|
+
}
|
|
836
848
|
const out = (0, import_core_node.postProcessStyles)(props2, staticConfig, defaultTheme);
|
|
849
|
+
if (shouldPrintDebug) {
|
|
850
|
+
delete props2["debug"];
|
|
851
|
+
}
|
|
837
852
|
const next = (out == null ? void 0 : out.style) ?? props2;
|
|
838
853
|
if (shouldPrintDebug) {
|
|
839
854
|
console.log(" -- viewProps:\n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(out.viewProps)));
|
|
@@ -864,8 +879,8 @@ function createExtractor() {
|
|
|
864
879
|
}
|
|
865
880
|
}
|
|
866
881
|
if (shouldPrintDebug) {
|
|
867
|
-
console.log(" completeStaticProps\n",
|
|
868
|
-
console.log(" completeStylesProcessed\n",
|
|
882
|
+
console.log(" completeStaticProps\n", completeStaticProps);
|
|
883
|
+
console.log(" completeStylesProcessed\n", completeStylesProcessed);
|
|
869
884
|
}
|
|
870
885
|
let getStyleError = null;
|
|
871
886
|
for (const attr of attrs) {
|
|
@@ -888,8 +903,6 @@ function createExtractor() {
|
|
|
888
903
|
return [keyIn, completeStylesProcessed[keyIn] ?? attr.value[keyIn]];
|
|
889
904
|
}
|
|
890
905
|
})();
|
|
891
|
-
if (shouldPrintDebug)
|
|
892
|
-
console.log("style", { keyIn, key, value });
|
|
893
906
|
delete attr.value[keyIn];
|
|
894
907
|
attr.value[key] = value;
|
|
895
908
|
}
|
|
@@ -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 type { StaticConfigParsed, TamaguiInternalConfig } from '@tamagui/core'\nimport { mediaQueryConfig, postProcessStyles, pseudos } from '@tamagui/core-node'\nimport { stylePropsTransform } from '@tamagui/helpers'\nimport { difference, pick } from 'lodash'\n\nimport { FAILED_EVAL } from '../constants'\nimport { ExtractedAttr, ExtractedAttrAttr, ExtractorParseProps, Ternary } 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'\n\nconst UNTOUCHED_PROPS = {\n key: true,\n style: true,\n className: true,\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 disableExtraction,\n disableExtractInlineMedia,\n disableExtractVariables,\n disableDebugAttr,\n ...props\n }: ExtractorParseProps\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\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 }\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 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 if (disableExtraction) {\n if (!hasLogged) {\n console.log('\uD83E\uDD5A Tamagui disableExtraction set: no CSS or optimizations will be run')\n hasLogged = true\n }\n return\n }\n\n const { staticConfig } = component\n const isTextView = staticConfig.isText || false\n const validStyles = staticConfig?.validStyles ?? {}\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 deoptProps = new Set([\n ...(props.deoptProps ?? []),\n ...(staticConfig.deoptProps ?? []),\n ])\n const excludeProps = new Set(props.excludeProps ?? [])\n const isExcludedProp = (name: string) => {\n const res = excludeProps.has(name)\n if (res && shouldPrintDebug) console.log(` excluding ${name}`)\n return res\n }\n\n const isDeoptedProp = (name: string) => {\n const res = deoptProps.has(name)\n if (res && shouldPrintDebug) console.log(` deopting ${name}`)\n return res\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 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 (typeof 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 default props\n if (staticConfig.defaultProps) {\n for (const key in staticConfig.defaultProps) {\n if (key === 'StyleSheet') {\n // temp bugfix when wrapping styled(require('react-native-web').Input)\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 let inlinePropCount = 0\n let isFlattened = 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 function isStaticAttributeName(name: string) {\n return !!(\n !!validStyles[name] ||\n staticConfig.validPropsExtra?.[name] ||\n !!pseudos[name] ||\n staticConfig.variants?.[name] ||\n tamaguiConfig.shorthands[name] ||\n (name[0] === '$' ? !!mediaQueryConfig[name.slice(1)] : false)\n )\n }\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 (!isStaticAttributeName(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 <= { color: 'red', background: x ? 'red' : 'green' }\n // | => Ternary<test, { color: 'red' }, null>\n // | => Ternary<test && x, { background: 'red' }, null>\n // | => Ternary<test && !x, { background: '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 // 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 // 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 inlinePropCount++\n return attr\n }\n\n const name = attribute.name.name\n\n if (isExcludedProp(name)) {\n return null\n }\n\n // can still optimize the object... see hoverStyle on native\n if (isDeoptedProp(name)) {\n if (shouldPrintDebug) {\n console.log(' ! inlining, deopt prop', name)\n }\n inlinePropCount++\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 // 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 inlinePropCount++\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(` native, disable extract: ${name} =`, value.value)\n }\n inlinePropCount++\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 (!isStaticAttributeName(name)) {\n let keys = [name]\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 const out = staticConfig.propMapper(\n name,\n styleValue,\n defaultTheme,\n staticConfig.defaultProps\n )\n if (out) {\n keys = Object.keys(out)\n }\n }\n for (const key of keys) {\n if (!isStaticAttributeName(key)) {\n inlinePropCount++\n }\n }\n if (inlinePropCount) {\n return attr\n }\n }\n\n // FAILED = dynamic or ternary, keep going\n if (styleValue !== FAILED_EVAL) {\n if (shouldPrintDebug) {\n console.log(` style: ${name} =`, styleValue)\n }\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\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 inlinePropCount++\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 (shouldPrintDebug) {\n console.log(' ! inline prop via no match', name, value.type)\n }\n // if we've made it this far, the prop stays inline\n inlinePropCount++\n\n if (shouldPrintDebug) {\n console.log(` inlining ${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 // now update to new values\n node.attributes = attrs.filter(isAttr).map((x) => x.value)\n\n if (couldntParse) {\n if (shouldPrintDebug) {\n console.log(` cancel:`, { 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 const hasOnlyStringChildren =\n !hasSpread &&\n (node.selfClosing ||\n (traversePath.node.children &&\n traversePath.node.children.every((x) => x.type === 'JSXText')))\n const shouldFlatten =\n !shouldDeopt &&\n inlinePropCount === 0 &&\n !hasSpread &&\n staticConfig.neverFlatten !== true &&\n (staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)\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 if (!shouldFlatten) {\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\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 acc.push({\n type: 'attr',\n value:\n cur.attr ||\n t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(t.nullLiteral())\n ),\n })\n }\n }\n }\n }\n acc.push(cur)\n return acc\n }, [])\n }\n\n if (shouldPrintDebug) {\n console.log(' - attrs (flattened): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // evaluate away purely style props\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n let key = Object.keys(cur.value)[0]\n let value = cur.value[key]\n const nonShortKey = tamaguiConfig.shorthands[key]\n // expand shorthand here\n if (nonShortKey) {\n cur.value = { [nonShortKey]: value }\n key = nonShortKey\n }\n\n if (!shouldFlatten) {\n if (\n // de-opt transform styles so it merges properly if not flattened\n stylePropsTransform[key] ||\n // de-opt if non-style\n (!validStyles[key] && !pseudos[key] && !key.startsWith('data-'))\n ) {\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 return acc\n }\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 (evaluated): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // combine styles, leave undefined values\n let prev: ExtractedAttr | null = null\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n if (prev?.type === 'style') {\n Object.assign(prev.value, cur.value)\n return acc\n }\n }\n acc.push(cur)\n prev = 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) => {\n if (!props) return\n if (!!excludeProps.size) {\n for (const key in props) {\n if (isExcludedProp(key)) delete props[key]\n }\n }\n const out = postProcessStyles(props, staticConfig, defaultTheme)\n const next = out?.style ?? props\n if (shouldPrintDebug) {\n console.log(' -- viewProps:\\n', logLines(objToStr(out.viewProps)))\n console.log(' -- props:\\n', logLines(objToStr(props)))\n console.log(' -- next:\\n', logLines(objToStr(next)))\n }\n for (const key in next) {\n if (staticConfig.validStyles) {\n if (!staticConfig.validStyles[key] && !pseudos[key]) {\n delete next[key]\n }\n }\n }\n return next\n }\n\n // used to ensure we pass the entire prop bundle to getStyles\n const completeStylesProcessed = getStyles({\n ...staticConfig.defaultProps,\n ...completeStaticProps,\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\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(' 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 switch (attr.type) {\n case 'ternary':\n const a = getStyles(attr.value.alternate)\n const c = getStyles(attr.value.consequent)\n attr.value.alternate = a\n attr.value.consequent = c\n if (shouldPrintDebug) console.log(' => tern ', attrStr(attr))\n continue\n case 'style':\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 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 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 isFlattened = true\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] inline props ', inlinePropCount, shouldDeopt ? ' deopted' : '', hasSpread ? ' spread' : '', '!flatten', staticConfig.neverFlatten)\n console.log(' - attrs (end):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n res.optimized++\n\n onExtractTag({\n attrs,\n node,\n lineNumbers,\n filePath,\n attemptEval,\n jsxPath: traversePath,\n originalNodeName,\n isFlattened,\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,sBAA4C;AAC5C,QAAmB;AAEnB,uBAA6D;AAC7D,qBAAoC;AACpC,oBAAiC;AAEjC,uBAA4B;AAE5B,6BAAqD;AACrD,6BAAgC;AAChC,4BAAiF;AACjF,iCAAoC;AACpC,uCAA0C;AAC1C,0BAA6B;AAC7B,yBAA4B;AAC5B,sBAAyB;AACzB,gCAAmC;AACnC,+BAAkC;AAElC,MAAM,kBAAkB;AAAA,EACtB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AAAA;AAGb,MAAM,SAAS,wBAAC,MAA6C,EAAE,SAAS,QAAzD;AAEf,MAAM,aAAa;AAAA,EACjB,UAAU;AAAA,EACV,UAAU;AAAA;AAKZ,MAAM,gBAAgB,wBAAC,MAAe,GAAhB;AAEf,2BAA2B;AAChC,QAAM,qBAEJ,CAAC,QAAQ,IAAI,iCACb,QAAQ,IAAI,mBAAmB,YAC/B,QAAQ,IAAI,kBAAkB,WAC7B,SAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,SAAS,QAAQ,IAAI;AAG9E,UAAQ,8BAA8B,SAAS;AAAA,IAC7C,QAAQ;AAAA,IACR,QAAQ;AAAA;AAGV,MAAI;AACJ,MAAI,YAAY;AAEhB,SAAO;AAAA,IACL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NodePath, Visitor } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { StaticConfigParsed, TamaguiInternalConfig } from '@tamagui/core'\nimport { mediaQueryConfig, postProcessStyles, pseudos } from '@tamagui/core-node'\nimport { stylePropsTransform } from '@tamagui/helpers'\nimport { difference, pick } from 'lodash'\n\nimport { FAILED_EVAL } from '../constants'\nimport { ExtractedAttr, ExtractedAttrAttr, ExtractorParseProps, Ternary } 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'\n\nconst UNTOUCHED_PROPS = {\n key: true,\n style: true,\n className: true,\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 disableExtraction,\n disableExtractInlineMedia,\n disableExtractVariables,\n disableDebugAttr,\n ...props\n }: ExtractorParseProps\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\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 }\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 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 if (disableExtraction) {\n if (!hasLogged) {\n console.log('\uD83E\uDD5A Tamagui disableExtraction set: no CSS or optimizations will be run')\n hasLogged = true\n }\n return\n }\n\n const { staticConfig } = component\n const isTextView = staticConfig.isText || false\n const validStyles = staticConfig?.validStyles ?? {}\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 deoptProps = new Set([\n ...(props.deoptProps ?? []),\n ...(staticConfig.deoptProps ?? []),\n ])\n const excludeProps = new Set(props.excludeProps ?? [])\n const isExcludedProp = (name: string) => {\n const res = excludeProps.has(name)\n if (res && shouldPrintDebug) console.log(` excluding ${name}`)\n return res\n }\n\n const isDeoptedProp = (name: string) => {\n const res = deoptProps.has(name)\n if (res && shouldPrintDebug) console.log(` deopting ${name}`)\n return res\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 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 (typeof 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 default props\n if (staticConfig.defaultProps) {\n for (const key in staticConfig.defaultProps) {\n if (key === 'StyleSheet') {\n // temp bugfix when wrapping styled(require('react-native-web').Input)\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 let inlinePropCount = 0\n let isFlattened = 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 function isStaticAttributeName(name: string) {\n return !!(\n !!validStyles[name] ||\n staticConfig.validPropsExtra?.[name] ||\n !!pseudos[name] ||\n staticConfig.variants?.[name] ||\n tamaguiConfig.shorthands[name] ||\n (name[0] === '$' ? !!mediaQueryConfig[name.slice(1)] : false)\n )\n }\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 (!isStaticAttributeName(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 <= { color: 'red', background: x ? 'red' : 'green' }\n // | => Ternary<test, { color: 'red' }, null>\n // | => Ternary<test && x, { background: 'red' }, null>\n // | => Ternary<test && !x, { background: '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 // 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 // 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 inlinePropCount++\n return attr\n }\n\n const name = attribute.name.name\n\n if (name.startsWith('data-')) {\n return attr\n }\n\n if (isExcludedProp(name)) {\n return null\n }\n\n // can still optimize the object... see hoverStyle on native\n if (isDeoptedProp(name)) {\n if (shouldPrintDebug) {\n console.log(' ! inlining, deopt prop', name)\n }\n inlinePropCount++\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 // 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 inlinePropCount++\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 inlinePropCount++\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 (!isStaticAttributeName(name)) {\n let keys = [name]\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 const out = staticConfig.propMapper(\n name,\n styleValue,\n defaultTheme,\n staticConfig.defaultProps\n )\n if (out) {\n keys = Object.keys(out)\n }\n }\n for (const key of keys) {\n if (!isStaticAttributeName(key)) {\n if (shouldPrintDebug) {\n console.log(' ! inlining, non-static', key)\n }\n inlinePropCount++\n }\n }\n if (inlinePropCount) {\n return attr\n }\n }\n\n // FAILED = dynamic or ternary, keep going\n if (styleValue !== FAILED_EVAL) {\n if (shouldPrintDebug) {\n console.log(` style: ${name} =`, styleValue)\n }\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\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 inlinePropCount++\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 (shouldPrintDebug) {\n console.log(' ! inline prop via no match', name, value.type)\n }\n // if we've made it this far, the prop stays inline\n inlinePropCount++\n\n if (shouldPrintDebug) {\n console.log(` inlining ${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 // now update to new values\n node.attributes = attrs.filter(isAttr).map((x) => x.value)\n\n if (couldntParse) {\n if (shouldPrintDebug) {\n console.log(` cancel:`, { 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 const hasOnlyStringChildren =\n !hasSpread &&\n (node.selfClosing ||\n (traversePath.node.children &&\n traversePath.node.children.every((x) => x.type === 'JSXText')))\n const shouldFlatten =\n !shouldDeopt &&\n inlinePropCount === 0 &&\n !hasSpread &&\n staticConfig.neverFlatten !== true &&\n (staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)\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 if (!shouldFlatten) {\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\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 acc.push({\n type: 'attr',\n value:\n cur.attr ||\n t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(t.nullLiteral())\n ),\n })\n }\n }\n }\n }\n acc.push(cur)\n return acc\n }, [])\n }\n\n if (shouldPrintDebug) {\n console.log(' - attrs (flattened): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // evaluate away purely style props\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n let key = Object.keys(cur.value)[0]\n let value = cur.value[key]\n const nonShortKey = tamaguiConfig.shorthands[key]\n // expand shorthand here\n if (nonShortKey) {\n cur.value = { [nonShortKey]: value }\n key = nonShortKey\n }\n\n if (!shouldFlatten) {\n if (\n // de-opt transform styles so it merges properly if not flattened\n stylePropsTransform[key] ||\n // de-opt if non-style\n (!validStyles[key] && !pseudos[key] && !key.startsWith('data-'))\n ) {\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 return acc\n }\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 (evaluated): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // combine styles, leave undefined values\n let prev: ExtractedAttr | null = null\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n if (prev?.type === 'style') {\n Object.assign(prev.value, cur.value)\n return acc\n }\n }\n acc.push(cur)\n prev = 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) => {\n if (!props) return\n if (!!excludeProps.size) {\n for (const key in props) {\n if (isExcludedProp(key)) delete props[key]\n }\n }\n if (shouldPrintDebug) {\n props['debug'] = true\n }\n const out = postProcessStyles(props, staticConfig, defaultTheme)\n if (shouldPrintDebug) {\n delete props['debug']\n }\n const next = out?.style ?? props\n if (shouldPrintDebug) {\n console.log(' -- viewProps:\\n', logLines(objToStr(out.viewProps)))\n console.log(' -- props:\\n', logLines(objToStr(props)))\n console.log(' -- next:\\n', logLines(objToStr(next)))\n }\n for (const key in next) {\n if (staticConfig.validStyles) {\n if (!staticConfig.validStyles[key] && !pseudos[key]) {\n delete next[key]\n }\n }\n }\n return next\n }\n\n // used to ensure we pass the entire prop bundle to getStyles\n const completeStylesProcessed = getStyles({\n ...staticConfig.defaultProps,\n ...completeStaticProps,\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\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(' completeStaticProps\\n', completeStaticProps)\n // prettier-ignore\n console.log(' completeStylesProcessed\\n', 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 switch (attr.type) {\n case 'ternary':\n const a = getStyles(attr.value.alternate)\n const c = getStyles(attr.value.consequent)\n attr.value.alternate = a\n attr.value.consequent = c\n if (shouldPrintDebug) console.log(' => tern ', attrStr(attr))\n continue\n case 'style':\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 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 isFlattened = true\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] inline props ', inlinePropCount, shouldDeopt ? ' deopted' : '', hasSpread ? ' spread' : '', '!flatten', staticConfig.neverFlatten)\n console.log(' - attrs (end):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n res.optimized++\n\n onExtractTag({\n attrs,\n node,\n lineNumbers,\n filePath,\n attemptEval,\n jsxPath: traversePath,\n originalNodeName,\n isFlattened,\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,sBAA4C;AAC5C,QAAmB;AAEnB,uBAA6D;AAC7D,qBAAoC;AACpC,oBAAiC;AAEjC,uBAA4B;AAE5B,6BAAqD;AACrD,6BAAgC;AAChC,4BAAiF;AACjF,iCAAoC;AACpC,uCAA0C;AAC1C,0BAA6B;AAC7B,yBAA4B;AAC5B,sBAAyB;AACzB,gCAAmC;AACnC,+BAAkC;AAElC,MAAM,kBAAkB;AAAA,EACtB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AAAA;AAGb,MAAM,SAAS,wBAAC,MAA6C,EAAE,SAAS,QAAzD;AAEf,MAAM,aAAa;AAAA,EACjB,UAAU;AAAA,EACV,UAAU;AAAA;AAKZ,MAAM,gBAAgB,wBAAC,MAAe,GAAhB;AAEf,2BAA2B;AAChC,QAAM,qBAEJ,CAAC,QAAQ,IAAI,iCACb,QAAQ,IAAI,mBAAmB,YAC/B,QAAQ,IAAI,kBAAkB,WAC7B,SAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,SAAS,QAAQ,IAAI;AAG9E,UAAQ,8BAA8B,SAAS;AAAA,IAC7C,QAAQ;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,mBAAmB,MAAM;AAC3B,cAAM,MAAM,MAAM,KAAK;AACvB,YAAI,kBAAkB;AACpB,kBAAQ,IAAI,4BAAqB,IAAI;AAAA;AAEvC,mBAAW,QAAQ,KAAK;AACtB,0DAAkB,MAAM;AAAA;AAAA;AAI5B,aAAO;AAAA;AAAA;AAAA;AAzqCG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -141,6 +141,9 @@ function extractToClassNames({
|
|
|
141
141
|
return [];
|
|
142
142
|
const styleWithPrev = ensureNeededPrevStyle(style);
|
|
143
143
|
const res2 = (0, import_core_node.getStylesAtomic)(styleWithPrev);
|
|
144
|
+
if (shouldPrintDebug) {
|
|
145
|
+
console.log("styleWithPrev", styleWithPrev, res2);
|
|
146
|
+
}
|
|
144
147
|
if (res2.length) {
|
|
145
148
|
finalStyles = [...finalStyles, ...res2];
|
|
146
149
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/extractToClassNames.ts"],
|
|
4
|
-
"sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { getRemainingRequest } from 'loader-utils'\nimport { ViewStyle } from 'react-native'\n\nimport { CONCAT_CLASSNAME_IMPORT } from '../constants'\nimport { ClassNameObject, StyleObject, TamaguiOptions } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { hoistClassNames } from './hoistClassNames'\nimport { logLines } from './logLines'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport function extractToClassNames({\n loader,\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n threaded,\n cssPath,\n}: {\n loader: any\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean\n cssPath: string\n threaded?: boolean\n}): null | {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n} {\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n // @ts-ignore\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n let hasFlattened = false\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n getFlattenedNode: ({ tag }) => {\n hasFlattened = true\n return tag\n },\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n }) => {\n let finalClassNames: ClassNameObject[] = []\n let finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n const viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n Object.assign(viewStyles, attr.value)\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null) => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style':\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n // prettier-ignore\n const existing = finalClassNames.find((x) => x.type == 'StringLiteral') as t.StringLiteral | null\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' classnames (after)\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n break\n case 'attr':\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n case 'ternary':\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (mediaExtraction) {\n lastMediaImportance++\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n if (!mediaExtraction.ternaryWithoutMedia) {\n continue\n }\n }\n const ternary = mediaExtraction?.ternaryWithoutMedia || attr.value\n const consInfo = addStyles(ternary.consequent)\n const altInfo = addStyles(ternary.alternate)\n const cCN = consInfo.map((x) => x.identifier).join(' ')\n const aCN = altInfo.map((x) => x.identifier).join(' ')\n if (consInfo.length && altInfo.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n break\n }\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n const names = buildClassName(finalClassNames)\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n if (!hasFlattened) {\n // not flat\n } else {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { className, rules } of finalStyles) {\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n if (styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = getRemainingRequest(loader)\n const importPath = `${cssPath}!=!tamagui-loader?${cssQuery}!${remReq}`\n ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)))\n }\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const timing = `${Date.now() - start}`.padStart(3)\n const path = basename(sourcePath).padStart(40)\n const numOptimized = `${res.optimized}`.padStart(4)\n const memory = memUsed > 10 ? `used ${memUsed}MB` : ''\n console.log(\n ` \uD83E\uDD5A ${path} ${timing}ms \u05C1\u00B7 ${numOptimized} optimized \u00B7 ${res.flattened} flattened ${memory}`\n )\n }\n\n return {\n ast,\n styles,\n js: result.code,\n map: result.map,\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AACtB,kBAAyB;AACzB,WAAsB;AAEtB,uBAAqB;AACrB,QAAmB;AACnB,uBAAgC;AAChC,qBAAgC;AAChC,uBAAsB;AACtB,0BAAoC;AAGpC,uBAAwC;AAExC,wBAA2B;AAC3B,4BAA+B;AAE/B,mCAAsC;AACtC,4BAA+B;AAC/B,+BAAkC;AAClC,6BAAgC;AAChC,sBAAyB;AAEzB,MAAM,mBAAmB;AAAA,EACvB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,cAAc;AAAA;AAGT,6BAA6B;AAAA,EAClC;AAAA,EACA;AAAA,E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BAAO;AACnB,cAAM,gBAAgB,sBAAsB;AAC5C,cAAM,OAAM,sCAAgB;AAC5B,YAAI,KAAI,QAAQ;AACd,wBAAc,CAAC,GAAG,aAAa,GAAG;AAAA;AAEpC,eAAO;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { getRemainingRequest } from 'loader-utils'\nimport { ViewStyle } from 'react-native'\n\nimport { CONCAT_CLASSNAME_IMPORT } from '../constants'\nimport { ClassNameObject, StyleObject, TamaguiOptions } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { hoistClassNames } from './hoistClassNames'\nimport { logLines } from './logLines'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport function extractToClassNames({\n loader,\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n threaded,\n cssPath,\n}: {\n loader: any\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean\n cssPath: string\n threaded?: boolean\n}): null | {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n} {\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n // @ts-ignore\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n let hasFlattened = false\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n getFlattenedNode: ({ tag }) => {\n hasFlattened = true\n return tag\n },\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n }) => {\n let finalClassNames: ClassNameObject[] = []\n let finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n const viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n Object.assign(viewStyles, attr.value)\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null) => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (shouldPrintDebug) {\n console.log('styleWithPrev', styleWithPrev, res)\n }\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style':\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n // prettier-ignore\n const existing = finalClassNames.find((x) => x.type == 'StringLiteral') as t.StringLiteral | null\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' classnames (after)\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n break\n case 'attr':\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n case 'ternary':\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (mediaExtraction) {\n lastMediaImportance++\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n if (!mediaExtraction.ternaryWithoutMedia) {\n continue\n }\n }\n const ternary = mediaExtraction?.ternaryWithoutMedia || attr.value\n const consInfo = addStyles(ternary.consequent)\n const altInfo = addStyles(ternary.alternate)\n const cCN = consInfo.map((x) => x.identifier).join(' ')\n const aCN = altInfo.map((x) => x.identifier).join(' ')\n if (consInfo.length && altInfo.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n break\n }\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n const names = buildClassName(finalClassNames)\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n if (!hasFlattened) {\n // not flat\n } else {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { className, rules } of finalStyles) {\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n if (styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = getRemainingRequest(loader)\n const importPath = `${cssPath}!=!tamagui-loader?${cssQuery}!${remReq}`\n ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)))\n }\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const timing = `${Date.now() - start}`.padStart(3)\n const path = basename(sourcePath).padStart(40)\n const numOptimized = `${res.optimized}`.padStart(4)\n const memory = memUsed > 10 ? `used ${memUsed}MB` : ''\n console.log(\n ` \uD83E\uDD5A ${path} ${timing}ms \u05C1\u00B7 ${numOptimized} optimized \u00B7 ${res.flattened} flattened ${memory}`\n )\n }\n\n return {\n ast,\n styles,\n js: result.code,\n map: result.map,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AACtB,kBAAyB;AACzB,WAAsB;AAEtB,uBAAqB;AACrB,QAAmB;AACnB,uBAAgC;AAChC,qBAAgC;AAChC,uBAAsB;AACtB,0BAAoC;AAGpC,uBAAwC;AAExC,wBAA2B;AAC3B,4BAA+B;AAE/B,mCAAsC;AACtC,4BAA+B;AAC/B,+BAAkC;AAClC,6BAAgC;AAChC,sBAAyB;AAEzB,MAAM,mBAAmB;AAAA,EACvB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,cAAc;AAAA;AAGT,6BAA6B;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAgBA;AACA,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI,MAAM;AAAA;AAElB,gCACE,OAAO,eAAe,YAAY,KAAK,WAAW,aAClD;AAGF,QAAM,kBAAkB,QAAQ,cAAc;AAC9C,QAAM,QAAQ,KAAK;AACnB,QAAM,MAAM,kBAAkB,QAAQ,gBAAgB;AAGtD,MAAI;AAEJ,MAAI;AAEF,UAAM,kCAAW;AAAA,WACV,KAAP;AACA,YAAQ,MAAM,sBAAsB;AACpC,UAAM;AAAA;AAGR,QAAM,SAAS,oBAAI;AACnB,QAAM,iBAAkD;AAExD,MAAI,eAAe;AA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388,10 +388,16 @@ function createExtractor() {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name !== "string") {
|
|
391
|
+
if (shouldPrintDebug) {
|
|
392
|
+
console.log(" ! inlining, spread attr");
|
|
393
|
+
}
|
|
391
394
|
inlinePropCount++;
|
|
392
395
|
return attr;
|
|
393
396
|
}
|
|
394
397
|
const name = attribute.name.name;
|
|
398
|
+
if (name.startsWith("data-")) {
|
|
399
|
+
return attr;
|
|
400
|
+
}
|
|
395
401
|
if (isExcludedProp(name)) {
|
|
396
402
|
return null;
|
|
397
403
|
}
|
|
@@ -452,7 +458,7 @@ function createExtractor() {
|
|
|
452
458
|
if (value) {
|
|
453
459
|
if (value.type === "StringLiteral" && value.value[0] === "$") {
|
|
454
460
|
if (shouldPrintDebug) {
|
|
455
|
-
console.log(`
|
|
461
|
+
console.log(` ! inlining, native disable extract: ${name} =`, value.value);
|
|
456
462
|
}
|
|
457
463
|
inlinePropCount++;
|
|
458
464
|
return attr;
|
|
@@ -470,6 +476,9 @@ function createExtractor() {
|
|
|
470
476
|
}
|
|
471
477
|
for (const key of keys) {
|
|
472
478
|
if (!isStaticAttributeName(key)) {
|
|
479
|
+
if (shouldPrintDebug) {
|
|
480
|
+
console.log(" ! inlining, non-static", key);
|
|
481
|
+
}
|
|
473
482
|
inlinePropCount++;
|
|
474
483
|
}
|
|
475
484
|
}
|
|
@@ -766,7 +775,13 @@ function createExtractor() {
|
|
|
766
775
|
delete props2[key];
|
|
767
776
|
}
|
|
768
777
|
}
|
|
778
|
+
if (shouldPrintDebug) {
|
|
779
|
+
props2["debug"] = true;
|
|
780
|
+
}
|
|
769
781
|
const out = postProcessStyles(props2, staticConfig, defaultTheme);
|
|
782
|
+
if (shouldPrintDebug) {
|
|
783
|
+
delete props2["debug"];
|
|
784
|
+
}
|
|
770
785
|
const next = (_a2 = out == null ? void 0 : out.style) != null ? _a2 : props2;
|
|
771
786
|
if (shouldPrintDebug) {
|
|
772
787
|
console.log(" -- viewProps:\n", logLines(objToStr(out.viewProps)));
|
|
@@ -800,8 +815,8 @@ function createExtractor() {
|
|
|
800
815
|
}
|
|
801
816
|
}
|
|
802
817
|
if (shouldPrintDebug) {
|
|
803
|
-
console.log(" completeStaticProps\n",
|
|
804
|
-
console.log(" completeStylesProcessed\n",
|
|
818
|
+
console.log(" completeStaticProps\n", completeStaticProps);
|
|
819
|
+
console.log(" completeStylesProcessed\n", completeStylesProcessed);
|
|
805
820
|
}
|
|
806
821
|
let getStyleError = null;
|
|
807
822
|
for (const attr of attrs) {
|
|
@@ -825,8 +840,6 @@ function createExtractor() {
|
|
|
825
840
|
return [keyIn, (_a2 = completeStylesProcessed[keyIn]) != null ? _a2 : attr.value[keyIn]];
|
|
826
841
|
}
|
|
827
842
|
})();
|
|
828
|
-
if (shouldPrintDebug)
|
|
829
|
-
console.log("style", { keyIn, key, value });
|
|
830
843
|
delete attr.value[keyIn];
|
|
831
844
|
attr.value[key] = value;
|
|
832
845
|
}
|
|
@@ -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 type { StaticConfigParsed, TamaguiInternalConfig } from '@tamagui/core'\nimport { mediaQueryConfig, postProcessStyles, pseudos } from '@tamagui/core-node'\nimport { stylePropsTransform } from '@tamagui/helpers'\nimport { difference, pick } from 'lodash'\n\nimport { FAILED_EVAL } from '../constants'\nimport { ExtractedAttr, ExtractedAttrAttr, ExtractorParseProps, Ternary } 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'\n\nconst UNTOUCHED_PROPS = {\n key: true,\n style: true,\n className: true,\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 disableExtraction,\n disableExtractInlineMedia,\n disableExtractVariables,\n disableDebugAttr,\n ...props\n }: ExtractorParseProps\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\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 }\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 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 if (disableExtraction) {\n if (!hasLogged) {\n console.log('\uD83E\uDD5A Tamagui disableExtraction set: no CSS or optimizations will be run')\n hasLogged = true\n }\n return\n }\n\n const { staticConfig } = component\n const isTextView = staticConfig.isText || false\n const validStyles = staticConfig?.validStyles ?? {}\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 deoptProps = new Set([\n ...(props.deoptProps ?? []),\n ...(staticConfig.deoptProps ?? []),\n ])\n const excludeProps = new Set(props.excludeProps ?? [])\n const isExcludedProp = (name: string) => {\n const res = excludeProps.has(name)\n if (res && shouldPrintDebug) console.log(` excluding ${name}`)\n return res\n }\n\n const isDeoptedProp = (name: string) => {\n const res = deoptProps.has(name)\n if (res && shouldPrintDebug) console.log(` deopting ${name}`)\n return res\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 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 (typeof 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 default props\n if (staticConfig.defaultProps) {\n for (const key in staticConfig.defaultProps) {\n if (key === 'StyleSheet') {\n // temp bugfix when wrapping styled(require('react-native-web').Input)\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 let inlinePropCount = 0\n let isFlattened = 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 function isStaticAttributeName(name: string) {\n return !!(\n !!validStyles[name] ||\n staticConfig.validPropsExtra?.[name] ||\n !!pseudos[name] ||\n staticConfig.variants?.[name] ||\n tamaguiConfig.shorthands[name] ||\n (name[0] === '$' ? !!mediaQueryConfig[name.slice(1)] : false)\n )\n }\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 (!isStaticAttributeName(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 <= { color: 'red', background: x ? 'red' : 'green' }\n // | => Ternary<test, { color: 'red' }, null>\n // | => Ternary<test && x, { background: 'red' }, null>\n // | => Ternary<test && !x, { background: '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 // 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 // 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 inlinePropCount++\n return attr\n }\n\n const name = attribute.name.name\n\n if (isExcludedProp(name)) {\n return null\n }\n\n // can still optimize the object... see hoverStyle on native\n if (isDeoptedProp(name)) {\n if (shouldPrintDebug) {\n console.log(' ! inlining, deopt prop', name)\n }\n inlinePropCount++\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 // 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 inlinePropCount++\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(` native, disable extract: ${name} =`, value.value)\n }\n inlinePropCount++\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 (!isStaticAttributeName(name)) {\n let keys = [name]\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 const out = staticConfig.propMapper(\n name,\n styleValue,\n defaultTheme,\n staticConfig.defaultProps\n )\n if (out) {\n keys = Object.keys(out)\n }\n }\n for (const key of keys) {\n if (!isStaticAttributeName(key)) {\n inlinePropCount++\n }\n }\n if (inlinePropCount) {\n return attr\n }\n }\n\n // FAILED = dynamic or ternary, keep going\n if (styleValue !== FAILED_EVAL) {\n if (shouldPrintDebug) {\n console.log(` style: ${name} =`, styleValue)\n }\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\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 inlinePropCount++\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 (shouldPrintDebug) {\n console.log(' ! inline prop via no match', name, value.type)\n }\n // if we've made it this far, the prop stays inline\n inlinePropCount++\n\n if (shouldPrintDebug) {\n console.log(` inlining ${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 // now update to new values\n node.attributes = attrs.filter(isAttr).map((x) => x.value)\n\n if (couldntParse) {\n if (shouldPrintDebug) {\n console.log(` cancel:`, { 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 const hasOnlyStringChildren =\n !hasSpread &&\n (node.selfClosing ||\n (traversePath.node.children &&\n traversePath.node.children.every((x) => x.type === 'JSXText')))\n const shouldFlatten =\n !shouldDeopt &&\n inlinePropCount === 0 &&\n !hasSpread &&\n staticConfig.neverFlatten !== true &&\n (staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)\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 if (!shouldFlatten) {\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\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 acc.push({\n type: 'attr',\n value:\n cur.attr ||\n t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(t.nullLiteral())\n ),\n })\n }\n }\n }\n }\n acc.push(cur)\n return acc\n }, [])\n }\n\n if (shouldPrintDebug) {\n console.log(' - attrs (flattened): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // evaluate away purely style props\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n let key = Object.keys(cur.value)[0]\n let value = cur.value[key]\n const nonShortKey = tamaguiConfig.shorthands[key]\n // expand shorthand here\n if (nonShortKey) {\n cur.value = { [nonShortKey]: value }\n key = nonShortKey\n }\n\n if (!shouldFlatten) {\n if (\n // de-opt transform styles so it merges properly if not flattened\n stylePropsTransform[key] ||\n // de-opt if non-style\n (!validStyles[key] && !pseudos[key] && !key.startsWith('data-'))\n ) {\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 return acc\n }\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 (evaluated): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // combine styles, leave undefined values\n let prev: ExtractedAttr | null = null\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n if (prev?.type === 'style') {\n Object.assign(prev.value, cur.value)\n return acc\n }\n }\n acc.push(cur)\n prev = 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) => {\n if (!props) return\n if (!!excludeProps.size) {\n for (const key in props) {\n if (isExcludedProp(key)) delete props[key]\n }\n }\n const out = postProcessStyles(props, staticConfig, defaultTheme)\n const next = out?.style ?? props\n if (shouldPrintDebug) {\n console.log(' -- viewProps:\\n', logLines(objToStr(out.viewProps)))\n console.log(' -- props:\\n', logLines(objToStr(props)))\n console.log(' -- next:\\n', logLines(objToStr(next)))\n }\n for (const key in next) {\n if (staticConfig.validStyles) {\n if (!staticConfig.validStyles[key] && !pseudos[key]) {\n delete next[key]\n }\n }\n }\n return next\n }\n\n // used to ensure we pass the entire prop bundle to getStyles\n const completeStylesProcessed = getStyles({\n ...staticConfig.defaultProps,\n ...completeStaticProps,\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\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(' 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 switch (attr.type) {\n case 'ternary':\n const a = getStyles(attr.value.alternate)\n const c = getStyles(attr.value.consequent)\n attr.value.alternate = a\n attr.value.consequent = c\n if (shouldPrintDebug) console.log(' => tern ', attrStr(attr))\n continue\n case 'style':\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 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 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 isFlattened = true\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] inline props ', inlinePropCount, shouldDeopt ? ' deopted' : '', hasSpread ? ' spread' : '', '!flatten', staticConfig.neverFlatten)\n console.log(' - attrs (end):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n res.optimized++\n\n onExtractTag({\n attrs,\n node,\n lineNumbers,\n filePath,\n attemptEval,\n jsxPath: traversePath,\n originalNodeName,\n isFlattened,\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;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,kBAAkB;AAAA,EACtB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AAAA;AAGb,MAAM,SAAS,wBAAC,MAA6C,EAAE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AA;AAQN,UAAI,mBAAmB,MAAM;AAC3B,cAAM,MAAM,MAAM,KAAK;AACvB,YAAI,kBAAkB;AACpB,kBAAQ,IAAI,4BAAqB,IAAI;AAAA;AAEvC,mBAAW,QAAQ,KAAK;AACtB,4BAAkB,MAAM;AAAA;AAAA;AAI5B,aAAO;AAAA;AAAA;AAAA;AAxpCG;",
|
|
4
|
+
"sourcesContent": ["import traverse, { NodePath, Visitor } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { StaticConfigParsed, TamaguiInternalConfig } from '@tamagui/core'\nimport { mediaQueryConfig, postProcessStyles, pseudos } from '@tamagui/core-node'\nimport { stylePropsTransform } from '@tamagui/helpers'\nimport { difference, pick } from 'lodash'\n\nimport { FAILED_EVAL } from '../constants'\nimport { ExtractedAttr, ExtractedAttrAttr, ExtractorParseProps, Ternary } 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'\n\nconst UNTOUCHED_PROPS = {\n key: true,\n style: true,\n className: true,\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 disableExtraction,\n disableExtractInlineMedia,\n disableExtractVariables,\n disableDebugAttr,\n ...props\n }: ExtractorParseProps\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\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 }\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 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 if (disableExtraction) {\n if (!hasLogged) {\n console.log('\uD83E\uDD5A Tamagui disableExtraction set: no CSS or optimizations will be run')\n hasLogged = true\n }\n return\n }\n\n const { staticConfig } = component\n const isTextView = staticConfig.isText || false\n const validStyles = staticConfig?.validStyles ?? {}\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 deoptProps = new Set([\n ...(props.deoptProps ?? []),\n ...(staticConfig.deoptProps ?? []),\n ])\n const excludeProps = new Set(props.excludeProps ?? [])\n const isExcludedProp = (name: string) => {\n const res = excludeProps.has(name)\n if (res && shouldPrintDebug) console.log(` excluding ${name}`)\n return res\n }\n\n const isDeoptedProp = (name: string) => {\n const res = deoptProps.has(name)\n if (res && shouldPrintDebug) console.log(` deopting ${name}`)\n return res\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 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 (typeof 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 default props\n if (staticConfig.defaultProps) {\n for (const key in staticConfig.defaultProps) {\n if (key === 'StyleSheet') {\n // temp bugfix when wrapping styled(require('react-native-web').Input)\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 let inlinePropCount = 0\n let isFlattened = 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 function isStaticAttributeName(name: string) {\n return !!(\n !!validStyles[name] ||\n staticConfig.validPropsExtra?.[name] ||\n !!pseudos[name] ||\n staticConfig.variants?.[name] ||\n tamaguiConfig.shorthands[name] ||\n (name[0] === '$' ? !!mediaQueryConfig[name.slice(1)] : false)\n )\n }\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 (!isStaticAttributeName(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 <= { color: 'red', background: x ? 'red' : 'green' }\n // | => Ternary<test, { color: 'red' }, null>\n // | => Ternary<test && x, { background: 'red' }, null>\n // | => Ternary<test && !x, { background: '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 // 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 // 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 inlinePropCount++\n return attr\n }\n\n const name = attribute.name.name\n\n if (name.startsWith('data-')) {\n return attr\n }\n\n if (isExcludedProp(name)) {\n return null\n }\n\n // can still optimize the object... see hoverStyle on native\n if (isDeoptedProp(name)) {\n if (shouldPrintDebug) {\n console.log(' ! inlining, deopt prop', name)\n }\n inlinePropCount++\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 // 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 inlinePropCount++\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 inlinePropCount++\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 (!isStaticAttributeName(name)) {\n let keys = [name]\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 const out = staticConfig.propMapper(\n name,\n styleValue,\n defaultTheme,\n staticConfig.defaultProps\n )\n if (out) {\n keys = Object.keys(out)\n }\n }\n for (const key of keys) {\n if (!isStaticAttributeName(key)) {\n if (shouldPrintDebug) {\n console.log(' ! inlining, non-static', key)\n }\n inlinePropCount++\n }\n }\n if (inlinePropCount) {\n return attr\n }\n }\n\n // FAILED = dynamic or ternary, keep going\n if (styleValue !== FAILED_EVAL) {\n if (shouldPrintDebug) {\n console.log(` style: ${name} =`, styleValue)\n }\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\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 inlinePropCount++\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 (shouldPrintDebug) {\n console.log(' ! inline prop via no match', name, value.type)\n }\n // if we've made it this far, the prop stays inline\n inlinePropCount++\n\n if (shouldPrintDebug) {\n console.log(` inlining ${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 // now update to new values\n node.attributes = attrs.filter(isAttr).map((x) => x.value)\n\n if (couldntParse) {\n if (shouldPrintDebug) {\n console.log(` cancel:`, { 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 const hasOnlyStringChildren =\n !hasSpread &&\n (node.selfClosing ||\n (traversePath.node.children &&\n traversePath.node.children.every((x) => x.type === 'JSXText')))\n const shouldFlatten =\n !shouldDeopt &&\n inlinePropCount === 0 &&\n !hasSpread &&\n staticConfig.neverFlatten !== true &&\n (staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)\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 if (!shouldFlatten) {\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\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 acc.push({\n type: 'attr',\n value:\n cur.attr ||\n t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(t.nullLiteral())\n ),\n })\n }\n }\n }\n }\n acc.push(cur)\n return acc\n }, [])\n }\n\n if (shouldPrintDebug) {\n console.log(' - attrs (flattened): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // evaluate away purely style props\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n let key = Object.keys(cur.value)[0]\n let value = cur.value[key]\n const nonShortKey = tamaguiConfig.shorthands[key]\n // expand shorthand here\n if (nonShortKey) {\n cur.value = { [nonShortKey]: value }\n key = nonShortKey\n }\n\n if (!shouldFlatten) {\n if (\n // de-opt transform styles so it merges properly if not flattened\n stylePropsTransform[key] ||\n // de-opt if non-style\n (!validStyles[key] && !pseudos[key] && !key.startsWith('data-'))\n ) {\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 return acc\n }\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 (evaluated): \\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n // combine styles, leave undefined values\n let prev: ExtractedAttr | null = null\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n if (prev?.type === 'style') {\n Object.assign(prev.value, cur.value)\n return acc\n }\n }\n acc.push(cur)\n prev = 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) => {\n if (!props) return\n if (!!excludeProps.size) {\n for (const key in props) {\n if (isExcludedProp(key)) delete props[key]\n }\n }\n if (shouldPrintDebug) {\n props['debug'] = true\n }\n const out = postProcessStyles(props, staticConfig, defaultTheme)\n if (shouldPrintDebug) {\n delete props['debug']\n }\n const next = out?.style ?? props\n if (shouldPrintDebug) {\n console.log(' -- viewProps:\\n', logLines(objToStr(out.viewProps)))\n console.log(' -- props:\\n', logLines(objToStr(props)))\n console.log(' -- next:\\n', logLines(objToStr(next)))\n }\n for (const key in next) {\n if (staticConfig.validStyles) {\n if (!staticConfig.validStyles[key] && !pseudos[key]) {\n delete next[key]\n }\n }\n }\n return next\n }\n\n // used to ensure we pass the entire prop bundle to getStyles\n const completeStylesProcessed = getStyles({\n ...staticConfig.defaultProps,\n ...completeStaticProps,\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\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(' completeStaticProps\\n', completeStaticProps)\n // prettier-ignore\n console.log(' completeStylesProcessed\\n', 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 switch (attr.type) {\n case 'ternary':\n const a = getStyles(attr.value.alternate)\n const c = getStyles(attr.value.consequent)\n attr.value.alternate = a\n attr.value.consequent = c\n if (shouldPrintDebug) console.log(' => tern ', attrStr(attr))\n continue\n case 'style':\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 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 isFlattened = true\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] inline props ', inlinePropCount, shouldDeopt ? ' deopted' : '', hasSpread ? ' spread' : '', '!flatten', staticConfig.neverFlatten)\n console.log(' - attrs (end):\\n', logLines(attrs.map(attrStr).join(', ')))\n }\n\n res.optimized++\n\n onExtractTag({\n attrs,\n node,\n lineNumbers,\n filePath,\n attemptEval,\n jsxPath: traversePath,\n originalNodeName,\n isFlattened,\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;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,kBAAkB;AAAA,EACtB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AAAA;AAGb,MAAM,SAAS,wBAAC,MAA6C,EAAE,SAAS,QAAzD;AAEf,MAAM,aAAa;AAAA,EACjB,UAAU;AAAA,EACV,UAAU;AAAA;AAKZ,MAAM,gBAAgB,wBAAC,MAAe,GAAhB;AAEf,2BAA2B;AAChC,QAAM,qBAEJ,CAAC,QAAQ,IAAI,iCACb,QAAQ,IAAI,mBAAmB,YAC/B,QAAQ,IAAI,kBAAkB,WAC7B,SAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,SAAS,QAAQ,IAAI;AAG9E,UAAQ,8BAA8B,SAAS;AAAA,IAC7C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AAM;AAAA;AAAA;AAI5B,aAAO;AAAA;AAAA;AAAA;AAzqCG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -96,6 +96,9 @@ function extractToClassNames({
|
|
|
96
96
|
return [];
|
|
97
97
|
const styleWithPrev = ensureNeededPrevStyle(style);
|
|
98
98
|
const res2 = getStylesAtomic(styleWithPrev);
|
|
99
|
+
if (shouldPrintDebug) {
|
|
100
|
+
console.log("styleWithPrev", styleWithPrev, res2);
|
|
101
|
+
}
|
|
99
102
|
if (res2.length) {
|
|
100
103
|
finalStyles = [...finalStyles, ...res2];
|
|
101
104
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/extractToClassNames.ts"],
|
|
4
|
-
"sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { getRemainingRequest } from 'loader-utils'\nimport { ViewStyle } from 'react-native'\n\nimport { CONCAT_CLASSNAME_IMPORT } from '../constants'\nimport { ClassNameObject, StyleObject, TamaguiOptions } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { hoistClassNames } from './hoistClassNames'\nimport { logLines } from './logLines'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport function extractToClassNames({\n loader,\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n threaded,\n cssPath,\n}: {\n loader: any\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean\n cssPath: string\n threaded?: boolean\n}): null | {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n} {\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n // @ts-ignore\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n let hasFlattened = false\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n getFlattenedNode: ({ tag }) => {\n hasFlattened = true\n return tag\n },\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n }) => {\n let finalClassNames: ClassNameObject[] = []\n let finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n const viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n Object.assign(viewStyles, attr.value)\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null) => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style':\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n // prettier-ignore\n const existing = finalClassNames.find((x) => x.type == 'StringLiteral') as t.StringLiteral | null\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' classnames (after)\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n break\n case 'attr':\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n case 'ternary':\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (mediaExtraction) {\n lastMediaImportance++\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n if (!mediaExtraction.ternaryWithoutMedia) {\n continue\n }\n }\n const ternary = mediaExtraction?.ternaryWithoutMedia || attr.value\n const consInfo = addStyles(ternary.consequent)\n const altInfo = addStyles(ternary.alternate)\n const cCN = consInfo.map((x) => x.identifier).join(' ')\n const aCN = altInfo.map((x) => x.identifier).join(' ')\n if (consInfo.length && altInfo.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n break\n }\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n const names = buildClassName(finalClassNames)\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n if (!hasFlattened) {\n // not flat\n } else {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { className, rules } of finalStyles) {\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n if (styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = getRemainingRequest(loader)\n const importPath = `${cssPath}!=!tamagui-loader?${cssQuery}!${remReq}`\n ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)))\n }\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const timing = `${Date.now() - start}`.padStart(3)\n const path = basename(sourcePath).padStart(40)\n const numOptimized = `${res.optimized}`.padStart(4)\n const memory = memUsed > 10 ? `used ${memUsed}MB` : ''\n console.log(\n ` \uD83E\uDD5A ${path} ${timing}ms \u05C1\u00B7 ${numOptimized} optimized \u00B7 ${res.flattened} flattened ${memory}`\n )\n }\n\n return {\n ast,\n styles,\n js: result.code,\n map: result.map,\n }\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA,MAAM,mBAAmB;AAAA,EACvB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,cAAc;AAAA;AAGT,6BAA6B;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAgBA;AAtDF;AAuDE,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI,MAAM;AAAA;AAElB,YACE,OAAO,eAAe,YAAY,KAAK,WAAW,aAClD;AAGF,QAAM,kBAAkB,cAAQ,eAAR,YAAsB;AAC9C,QAAM,QAAQ,KAAK;AACnB,QAAM,MAAM,kBAAkB,QAAQ,gBAAgB;AAGtD,MAAI;AAEJ,MAAI;AAEF,UAAM,WAAW;AAAA,WACV,KAAP;AACA,YAAQ,MAAM,sBAAsB;AACpC,UAAM;AAAA;AAGR,QAAM,SAAS,oBAAI;AACnB,QAAM,iBAAkD;AAExD,MAAI,eAAe;AAEnB,QAAM,MAAM,UAAU,MAAM,KAAK;AAAA,IAC/B;AAAA,IACA;AAAA,OACG;AAAA,IACH,kBAAkB,CAAC,EAAE,UAAU;AAC7B,qBAAe;AACf,aAAO;AAAA;AAAA,IAET,cAAc,CAAC;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,UACI;AACJ,UAAI,kBAAqC;AACzC,UAAI,aAAwD;AAC5D,UAAI,cAA6B;AAEjC,YAAM,aAAa;AACnB,iBAAW,QAAQ,OAAO;AACxB,YAAI,KAAK,SAAS,SAAS;AACzB,iBAAO,OAAO,YAAY,KAAK;AAAA;AAAA;AAInC,YAAM,wBAAwB,wBAAC,UAAqB;AAhH1D;AAkHQ,cAAM,OAAO,OAAO,KAAK;AACzB,YAAI,CAAC,KAAK,KAAK,CAAC,QAAQ,iBAAiB,OAAO;AAC9C,iBAAO;AAAA;AAET,mBAAW,KAAK,kBAAkB;AAChC,cAAI,KAAK,YAAY;AACnB,kBAAM,KAAK,aAAM,OAAN,aAAY,WAAW;AAAA;AAAA;AAGtC,eAAO;AAAA,SAXqB;AAc9B,YAAM,YAAY,wBAAC,UAA4B;AAC7C,YAAI,CAAC;AAAO,iBAAO;AACnB,cAAM,gBAAgB,sBAAsB;AAC5C,cAAM,OAAM,gBAAgB;AAC5B,YAAI,KAAI,QAAQ;AACd,wBAAc,CAAC,GAAG,aAAa,GAAG;AAAA;AAEpC,eAAO;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { getRemainingRequest } from 'loader-utils'\nimport { ViewStyle } from 'react-native'\n\nimport { CONCAT_CLASSNAME_IMPORT } from '../constants'\nimport { ClassNameObject, StyleObject, TamaguiOptions } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { hoistClassNames } from './hoistClassNames'\nimport { logLines } from './logLines'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport function extractToClassNames({\n loader,\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n threaded,\n cssPath,\n}: {\n loader: any\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean\n cssPath: string\n threaded?: boolean\n}): null | {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n} {\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n // @ts-ignore\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n let hasFlattened = false\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n getFlattenedNode: ({ tag }) => {\n hasFlattened = true\n return tag\n },\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n }) => {\n let finalClassNames: ClassNameObject[] = []\n let finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n const viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n Object.assign(viewStyles, attr.value)\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null) => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (shouldPrintDebug) {\n console.log('styleWithPrev', styleWithPrev, res)\n }\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style':\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n // prettier-ignore\n const existing = finalClassNames.find((x) => x.type == 'StringLiteral') as t.StringLiteral | null\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' classnames (after)\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n break\n case 'attr':\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n case 'ternary':\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (mediaExtraction) {\n lastMediaImportance++\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n if (!mediaExtraction.ternaryWithoutMedia) {\n continue\n }\n }\n const ternary = mediaExtraction?.ternaryWithoutMedia || attr.value\n const consInfo = addStyles(ternary.consequent)\n const altInfo = addStyles(ternary.alternate)\n const cCN = consInfo.map((x) => x.identifier).join(' ')\n const aCN = altInfo.map((x) => x.identifier).join(' ')\n if (consInfo.length && altInfo.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n break\n }\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n const names = buildClassName(finalClassNames)\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n if (!hasFlattened) {\n // not flat\n } else {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { className, rules } of finalStyles) {\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n if (styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = getRemainingRequest(loader)\n const importPath = `${cssPath}!=!tamagui-loader?${cssQuery}!${remReq}`\n ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)))\n }\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const timing = `${Date.now() - start}`.padStart(3)\n const path = basename(sourcePath).padStart(40)\n const numOptimized = `${res.optimized}`.padStart(4)\n const memory = memUsed > 10 ? `used ${memUsed}MB` : ''\n console.log(\n ` \uD83E\uDD5A ${path} ${timing}ms \u05C1\u00B7 ${numOptimized} optimized \u00B7 ${res.flattened} flattened ${memory}`\n )\n }\n\n return {\n ast,\n styles,\n js: result.code,\n map: result.map,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AAE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AACpB,YAAQ,IACN,wCACA,OAAO,KACJ,MAAM,MACN,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,OAC5B,KAAK;AAEV,YAAQ,IAAI,0CAA0C;AAAA;AAGxD,MAAI,iBAAiB;AACnB,UAAM,UAAU,MACZ,KAAK,MAAQ,SAAQ,cAAc,WAAW,IAAI,YAAY,OAAO,OAAQ,MAAM,KACnF;AACJ,UAAM,SAAS,GAAG,KAAK,QAAQ,QAAQ,SAAS;AAChD,UAAM,QAAO,SAAS,YAAY,SAAS;AAC3C,UAAM,eAAe,GAAG,IAAI,YAAY,SAAS;AACjD,UAAM,SAAS,UAAU,KAAK,QAAQ,cAAc;AACpD,YAAQ,IACN,eAAQ,SAAQ,uBAAe,+BAA4B,IAAI,uBAAuB;AAAA;AAI1F,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,OAAO;AAAA,IACX,KAAK,OAAO;AAAA;AAAA;AArTA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -388,10 +388,16 @@ function createExtractor() {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name !== "string") {
|
|
391
|
+
if (shouldPrintDebug) {
|
|
392
|
+
console.log(" ! inlining, spread attr");
|
|
393
|
+
}
|
|
391
394
|
inlinePropCount++;
|
|
392
395
|
return attr;
|
|
393
396
|
}
|
|
394
397
|
const name = attribute.name.name;
|
|
398
|
+
if (name.startsWith("data-")) {
|
|
399
|
+
return attr;
|
|
400
|
+
}
|
|
395
401
|
if (isExcludedProp(name)) {
|
|
396
402
|
return null;
|
|
397
403
|
}
|
|
@@ -452,7 +458,7 @@ function createExtractor() {
|
|
|
452
458
|
if (value) {
|
|
453
459
|
if (value.type === "StringLiteral" && value.value[0] === "$") {
|
|
454
460
|
if (shouldPrintDebug) {
|
|
455
|
-
console.log(`
|
|
461
|
+
console.log(` ! inlining, native disable extract: ${name} =`, value.value);
|
|
456
462
|
}
|
|
457
463
|
inlinePropCount++;
|
|
458
464
|
return attr;
|
|
@@ -470,6 +476,9 @@ function createExtractor() {
|
|
|
470
476
|
}
|
|
471
477
|
for (const key of keys) {
|
|
472
478
|
if (!isStaticAttributeName(key)) {
|
|
479
|
+
if (shouldPrintDebug) {
|
|
480
|
+
console.log(" ! inlining, non-static", key);
|
|
481
|
+
}
|
|
473
482
|
inlinePropCount++;
|
|
474
483
|
}
|
|
475
484
|
}
|
|
@@ -766,7 +775,13 @@ function createExtractor() {
|
|
|
766
775
|
delete props2[key];
|
|
767
776
|
}
|
|
768
777
|
}
|
|
778
|
+
if (shouldPrintDebug) {
|
|
779
|
+
props2["debug"] = true;
|
|
780
|
+
}
|
|
769
781
|
const out = postProcessStyles(props2, staticConfig, defaultTheme);
|
|
782
|
+
if (shouldPrintDebug) {
|
|
783
|
+
delete props2["debug"];
|
|
784
|
+
}
|
|
770
785
|
const next = (_a2 = out == null ? void 0 : out.style) != null ? _a2 : props2;
|
|
771
786
|
if (shouldPrintDebug) {
|
|
772
787
|
console.log(" -- viewProps:\n", logLines(objToStr(out.viewProps)));
|
|
@@ -800,8 +815,8 @@ function createExtractor() {
|
|
|
800
815
|
}
|
|
801
816
|
}
|
|
802
817
|
if (shouldPrintDebug) {
|
|
803
|
-
console.log(" completeStaticProps\n",
|
|
804
|
-
console.log(" completeStylesProcessed\n",
|
|
818
|
+
console.log(" completeStaticProps\n", completeStaticProps);
|
|
819
|
+
console.log(" completeStylesProcessed\n", completeStylesProcessed);
|
|
805
820
|
}
|
|
806
821
|
let getStyleError = null;
|
|
807
822
|
for (const attr of attrs) {
|
|
@@ -825,8 +840,6 @@ function createExtractor() {
|
|
|
825
840
|
return [keyIn, (_a2 = completeStylesProcessed[keyIn]) != null ? _a2 : attr.value[keyIn]];
|
|
826
841
|
}
|
|
827
842
|
})();
|
|
828
|
-
if (shouldPrintDebug)
|
|
829
|
-
console.log("style", { keyIn, key, value });
|
|
830
843
|
delete attr.value[keyIn];
|
|
831
844
|
attr.value[key] = value;
|
|
832
845
|
}
|
|
@@ -96,6 +96,9 @@ function extractToClassNames({
|
|
|
96
96
|
return [];
|
|
97
97
|
const styleWithPrev = ensureNeededPrevStyle(style);
|
|
98
98
|
const res2 = getStylesAtomic(styleWithPrev);
|
|
99
|
+
if (shouldPrintDebug) {
|
|
100
|
+
console.log("styleWithPrev", styleWithPrev, res2);
|
|
101
|
+
}
|
|
99
102
|
if (res2.length) {
|
|
100
103
|
finalStyles = [...finalStyles, ...res2];
|
|
101
104
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.62",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"typings": "types",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@dish/babel-preset": "^0.0.6",
|
|
61
61
|
"@expo/match-media": "^0.1.0",
|
|
62
62
|
"@tamagui/build": "^1.0.0-alpha.58",
|
|
63
|
-
"@tamagui/core": "^1.0.0-alpha.
|
|
63
|
+
"@tamagui/core": "^1.0.0-alpha.62",
|
|
64
64
|
"@tamagui/core-node": "^1.0.0-alpha.58",
|
|
65
65
|
"@tamagui/fake-react-native": "^1.0.0-alpha.17",
|
|
66
66
|
"@tamagui/helpers": "^1.0.0-alpha.58",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"invariant": "^2.2.4",
|
|
73
73
|
"loader-utils": "^2.0.0",
|
|
74
74
|
"lodash": "^4.17.21",
|
|
75
|
-
"tamagui": "^1.0.0-alpha.
|
|
75
|
+
"tamagui": "^1.0.0-alpha.62"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"react-native-web": "*"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "76f3b735226bdb7feffb53e3c8e3fd34392b6a10"
|
|
81
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,KAAK,EAAsB,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAM9E,OAAO,EAAoC,mBAAmB,EAAW,MAAM,UAAU,CAAA;AAyBzF,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;wBAsBb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,+MAcrC,mBAAmB;;;;;
|
|
1
|
+
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,KAAK,EAAsB,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAM9E,OAAO,EAAoC,mBAAmB,EAAW,MAAM,UAAU,CAAA;AAyBzF,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;wBAsBb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,+MAcrC,mBAAmB;;;;;EAwoC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractToClassNames.d.ts","sourceRoot":"","sources":["../../src/extractor/extractToClassNames.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAQjC,OAAO,EAAgC,cAAc,EAAE,MAAM,UAAU,CAAA;AAGvE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAc7C,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,OAAO,GACR,EAAE;IACD,MAAM,EAAE,GAAG,CAAA;IACX,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,IAAI,GAAG;IACT,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAA;IACX,GAAG,EAAE,GAAG,CAAA;CACT,
|
|
1
|
+
{"version":3,"file":"extractToClassNames.d.ts","sourceRoot":"","sources":["../../src/extractor/extractToClassNames.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAQjC,OAAO,EAAgC,cAAc,EAAE,MAAM,UAAU,CAAA;AAGvE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAc7C,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,OAAO,GACR,EAAE;IACD,MAAM,EAAE,GAAG,CAAA;IACX,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,IAAI,GAAG;IACT,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAA;IACX,GAAG,EAAE,GAAG,CAAA;CACT,CA+RA"}
|