@tamagui/static 1.0.1-beta.195 → 1.0.1-beta.197
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/extractor/createExtractor.js +3 -4
- package/dist/extractor/createExtractor.js.map +2 -2
- package/dist/extractor/loadTamagui.js +4 -14
- package/dist/extractor/loadTamagui.js.map +2 -2
- package/dist/require.js +15 -26
- package/dist/require.js.map +2 -2
- package/package.json +13 -15
- package/src/extractor/createExtractor.ts +1 -3
- package/src/extractor/loadTamagui.ts +4 -16
- package/src/require.ts +18 -31
- package/types/extractor/loadTamagui.d.ts +0 -1
- package/types/require.d.ts +1 -1
|
@@ -31,7 +31,7 @@ var import_path = require("path");
|
|
|
31
31
|
var import_traverse = __toESM(require("@babel/traverse"));
|
|
32
32
|
var t = __toESM(require("@babel/types"));
|
|
33
33
|
var import_core_node = require("@tamagui/core-node");
|
|
34
|
-
var
|
|
34
|
+
var import_react_native_web_internals = require("react-native-web-internals");
|
|
35
35
|
var import_constants = require("../constants.js");
|
|
36
36
|
var import_createEvaluator = require("./createEvaluator.js");
|
|
37
37
|
var import_evaluateAstNode = require("./evaluateAstNode.js");
|
|
@@ -317,7 +317,6 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
|
317
317
|
}
|
|
318
318
|
const out2 = (0, import_loadTamagui.loadTamaguiSync)({
|
|
319
319
|
forceExports: true,
|
|
320
|
-
bubbleErrors: true,
|
|
321
320
|
components: [sourcePath]
|
|
322
321
|
});
|
|
323
322
|
if (!(out2 == null ? void 0 : out2.components)) {
|
|
@@ -666,7 +665,7 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
|
666
665
|
}
|
|
667
666
|
if (out) {
|
|
668
667
|
if (isTargetingHTML) {
|
|
669
|
-
out = (0,
|
|
668
|
+
out = (0, import_react_native_web_internals.createDOMProps)(isTextView ? "span" : "div", out);
|
|
670
669
|
delete out.className;
|
|
671
670
|
}
|
|
672
671
|
keys = Object.keys(out);
|
|
@@ -1342,7 +1341,7 @@ function createExtractor({ logger = console } = { logger: console }) {
|
|
|
1342
1341
|
);
|
|
1343
1342
|
if (out && isTargetingHTML) {
|
|
1344
1343
|
const cn = out.className;
|
|
1345
|
-
out = (0,
|
|
1344
|
+
out = (0, import_react_native_web_internals.createDOMProps)(isTextView ? "span" : "div", out);
|
|
1346
1345
|
out.className = cn;
|
|
1347
1346
|
}
|
|
1348
1347
|
if (shouldPrintDebug) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/extractor/createExtractor.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-console */\nimport { basename, join, relative } from 'path'\n\nimport traverse, { NodePath, TraverseOptions } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport {\n PseudoStyles,\n StaticConfigParsed,\n expandStyles,\n getSplitStyles,\n getStylesAtomic,\n mediaQueryConfig,\n proxyThemeVariables,\n pseudoDescriptors,\n} from '@tamagui/core-node'\nimport { createDOMProps } from '@tamagui/rnw'\nimport type { ViewStyle } from 'react-native'\n\nimport { FAILED_EVAL } from '../constants.js'\nimport type {\n ExtractedAttr,\n ExtractedAttrAttr,\n ExtractedAttrStyle,\n ExtractorOptions,\n ExtractorParseProps,\n TamaguiOptions,\n TamaguiOptionsWithFileInfo,\n Ternary,\n} from '../types.js'\nimport { createEvaluator, createSafeEvaluator } from './createEvaluator.js'\nimport { evaluateAstNode } from './evaluateAstNode.js'\nimport {\n attrStr,\n findComponentName,\n getValidComponent,\n getValidImport,\n isPresent,\n isValidImport,\n objToStr,\n} from './extractHelpers.js'\nimport { findTopmostFunction } from './findTopmostFunction.js'\nimport { getPrefixLogs } from './getPrefixLogs.js'\nimport { cleanupBeforeExit, getStaticBindingsForScope } from './getStaticBindingsForScope.js'\nimport { literalToAst } from './literalToAst.js'\nimport {\n LoadedComponents,\n TamaguiProjectInfo,\n loadTamagui,\n loadTamaguiSync,\n} from './loadTamagui.js'\nimport { logLines } from './logLines.js'\nimport { normalizeTernaries } from './normalizeTernaries.js'\nimport { removeUnusedHooks } from './removeUnusedHooks.js'\nimport { timer } from './timer.js'\nimport { validHTMLAttributes } from './validHTMLAttributes.js'\n\nconst UNTOUCHED_PROPS = {\n key: true,\n style: true,\n className: true,\n}\n\nconst INLINE_EXTRACTABLE = {\n ref: 'ref',\n key: 'key',\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n onPress: 'onClick',\n onHoverIn: 'onMouseEnter',\n onHoverOut: 'onMouseLeave',\n onPressIn: 'onMouseDown',\n onPressOut: 'onMouseUp',\n }),\n}\n\nconst validHooks = {\n useMedia: true,\n useTheme: true,\n}\n\nconst isAttr = (x: ExtractedAttr): x is ExtractedAttrAttr => x.type === 'attr'\nconst createTernary = (x: Ternary) => x\n\nexport type Extractor = ReturnType<typeof createExtractor>\n\ntype FileOrPath = NodePath<t.Program> | t.File\n\nlet hasLoggedBaseInfo = false\n\nexport function createExtractor({ logger = console }: ExtractorOptions = { logger: console }) {\n if (!process.env.TAMAGUI_TARGET) {\n console.log('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either \"web\" or \"native\"')\n process.exit(1)\n }\n\n const shouldAddDebugProp =\n // really basic disable this for next.js because it messes with ssr\n !process.env.npm_package_dependencies_next &&\n process.env.TAMAGUI_TARGET !== 'native' &&\n process.env.IDENTIFY_TAGS !== 'false' &&\n (process.env.NODE_ENV === 'development' || process.env.DEBUG || process.env.IDENTIFY_TAGS)\n\n let projectInfo: TamaguiProjectInfo | null = null\n\n // we load tamagui delayed 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\n function loadSync(props: TamaguiOptions) {\n return (projectInfo ||= loadTamaguiSync({\n config: props.config || 'tamagui.config.ts',\n components: props.components || ['tamagui'],\n }))\n }\n\n async function load(props: TamaguiOptions) {\n return (projectInfo ||= await loadTamagui({\n config: props.config || 'tamagui.config.ts',\n components: props.components || ['tamagui'],\n }))\n }\n\n return {\n options: {\n logger,\n },\n cleanupBeforeExit,\n loadTamagui: load,\n loadTamaguiSync: loadSync,\n getTamagui() {\n return projectInfo?.tamaguiConfig\n },\n parseSync: (f: FileOrPath, props: ExtractorParseProps) => {\n const projectInfo = loadSync(props)\n return parseWithConfig(projectInfo, f, props)\n },\n parse: async (f: FileOrPath, props: ExtractorParseProps) => {\n const projectInfo = await load(props)\n return parseWithConfig(projectInfo, f, props)\n },\n }\n\n function isValidStyleKey(name: string, staticConfig: StaticConfigParsed) {\n if (!projectInfo) {\n throw new Error(`Tamagui extractor not loaded yet`)\n }\n return !!(\n !!staticConfig.validStyles?.[name] ||\n !!pseudoDescriptors[name] ||\n // dont disable variants or else you lose many things flattening\n staticConfig.variants?.[name] ||\n projectInfo?.tamaguiConfig.shorthands[name] ||\n (name[0] === '$' ? !!mediaQueryConfig[name.slice(1)] : false)\n )\n }\n\n function parseWithConfig(\n { components, tamaguiConfig }: TamaguiProjectInfo,\n fileOrPath: FileOrPath,\n options: ExtractorParseProps\n ) {\n const {\n config = 'tamagui.config.ts',\n importsWhitelist = ['constants.js'],\n evaluateVars = true,\n sourcePath = '',\n onExtractTag,\n onStyleRule,\n getFlattenedNode,\n disable,\n disableExtraction,\n disableExtractInlineMedia,\n disableExtractVariables,\n disableDebugAttr,\n disableExtractFoundComponents,\n includeExtensions = ['.tsx', '.jsx'],\n extractStyledDefinitions = false,\n prefixLogs,\n excludeProps,\n target,\n ...restProps\n } = options\n\n let shouldPrintDebug = options.shouldPrintDebug || false\n\n if (disable === true || (Array.isArray(disable) && disable.includes(sourcePath))) {\n return null\n }\n if (sourcePath === '') {\n throw new Error(`Must provide a source file name`)\n }\n if (!components) {\n throw new Error(`Must provide components`)\n }\n if (includeExtensions && !includeExtensions.some((ext) => sourcePath.endsWith(ext))) {\n if (shouldPrintDebug) {\n logger.info(\n `Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(\n ', '\n )}`\n )\n }\n return null\n }\n\n /**\n * Step 1: Determine if importing any statically extractable components\n */\n\n const isTargetingHTML = target === 'html'\n const ogDebug = shouldPrintDebug\n const tm = timer()\n const propsWithFileInfo: TamaguiOptionsWithFileInfo = {\n ...options,\n sourcePath,\n allLoadedComponents: [...components],\n }\n\n if (!hasLoggedBaseInfo) {\n hasLoggedBaseInfo = true\n if (shouldPrintDebug) {\n logger.info(\n [\n 'loaded components:',\n propsWithFileInfo.allLoadedComponents\n .map((comp) => Object.keys(comp.nameToInfo).join(', '))\n .join(', '),\n ].join(' ')\n )\n }\n if (process.env.DEBUG?.startsWith('tamagui')) {\n const next = [...propsWithFileInfo.allLoadedComponents].map((info) => {\n const nameToInfo = { ...info.nameToInfo }\n for (const key in nameToInfo) {\n delete nameToInfo[key].staticConfig.validStyles\n }\n return { ...info, nameToInfo }\n })\n logger.info(['loaded:', JSON.stringify(next, null, 2)].join('\\n'))\n }\n }\n\n tm.mark('load-tamagui', !!shouldPrintDebug)\n\n const firstThemeName = Object.keys(tamaguiConfig.themes)[0]\n const firstTheme = tamaguiConfig.themes[firstThemeName]\n\n if (!firstTheme || typeof firstTheme !== 'object') {\n console.error(`Missing theme, an error occurred when importing your config`)\n console.log(`Got config:`, tamaguiConfig)\n console.log(`Looking for theme:`, firstThemeName)\n process.exit(0)\n }\n\n const proxiedTheme = proxyThemeVariables(firstTheme)\n type AccessListener = (key: string) => void\n const themeAccessListeners = new Set<AccessListener>()\n const defaultTheme = new Proxy(proxiedTheme, {\n get(target, key) {\n if (Reflect.has(target, key)) {\n themeAccessListeners.forEach((cb) => cb(String(key)))\n }\n return Reflect.get(target, key)\n },\n })\n\n // @ts-ignore\n const body = fileOrPath.type === 'Program' ? fileOrPath.get('body') : fileOrPath.program.body\n\n if (Object.keys(components).length === 0) {\n console.warn(`Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)`)\n if (process.env.DEBUG === 'tamagui') {\n console.log(`components`, Object.keys(components), components)\n }\n }\n\n if (shouldPrintDebug === 'verbose') {\n logger.info(\n `allLoadedComponent modules ${propsWithFileInfo.allLoadedComponents\n .map((k) => k.moduleName)\n .join(', ')}`\n )\n }\n\n let doesUseValidImport = false\n let hasImportedTheme = false\n\n const importDeclarations: t.ImportDeclaration[] = []\n\n for (const bodyPath of body) {\n if (bodyPath.type !== 'ImportDeclaration') continue\n const node = ('node' in bodyPath ? bodyPath.node : bodyPath) as t.ImportDeclaration\n const moduleName = node.source.value\n\n // if importing valid module\n const valid = isValidImport(propsWithFileInfo, moduleName)\n\n if (valid) {\n importDeclarations.push(node)\n }\n\n if (extractStyledDefinitions) {\n if (valid) {\n if (node.specifiers.some((specifier) => specifier.local.name === 'styled')) {\n doesUseValidImport = true\n break\n }\n }\n }\n\n if (valid) {\n const names = node.specifiers.map((specifier) => specifier.local.name)\n const isValidComponent = names.some((name) =>\n Boolean(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name])\n )\n if (shouldPrintDebug === 'verbose') {\n logger.info(\n `import ${names.join(', ')} from ${moduleName} isValidComponent ${isValidComponent}`\n )\n }\n if (isValidComponent) {\n doesUseValidImport = true\n break\n }\n }\n }\n\n if (shouldPrintDebug) {\n logger.info(`file: ${sourcePath} ${JSON.stringify({ doesUseValidImport, hasImportedTheme })}`)\n }\n\n if (!doesUseValidImport) {\n return null\n }\n\n function getValidImportedComponent(componentName: string) {\n const importDeclaration = importDeclarations.find((dec) =>\n dec.specifiers.some((spec) => spec.local.name === componentName)\n )\n if (!importDeclaration) {\n return null\n }\n return getValidImport(propsWithFileInfo, importDeclaration.source.value, componentName)\n }\n\n tm.mark('import-check', !!shouldPrintDebug)\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: TraverseOptions<any>) => {\n return fileOrPath.type === 'File' ? traverse(fileOrPath, a) : fileOrPath.traverse(a)\n }\n\n const shouldDisableExtraction =\n disableExtraction === true ||\n (Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath))\n\n /**\n * Step 2: Statically extract from JSX < /> nodes\n */\n let programPath: NodePath<t.Program> | null = null\n\n const res = {\n styled: 0,\n flattened: 0,\n optimized: 0,\n modified: 0,\n found: 0,\n }\n\n callTraverse({\n // @ts-ignore\n Program: {\n enter(path) {\n programPath = path\n },\n },\n\n // styled() calls\n CallExpression(path) {\n if (disable || shouldDisableExtraction || extractStyledDefinitions === false) {\n return\n }\n\n if (!t.isIdentifier(path.node.callee) || path.node.callee.name !== 'styled') {\n return\n }\n\n const name =\n t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id)\n ? path.parent.id.name\n : 'unknown'\n\n const definition = path.node.arguments[1]\n\n if (!name || !definition || !t.isObjectExpression(definition)) {\n return\n }\n\n let Component = getValidImportedComponent(name)\n\n if (!Component) {\n if (disableExtractFoundComponents === true) {\n return\n }\n if (\n Array.isArray(disableExtractFoundComponents) &&\n disableExtractFoundComponents.includes(name)\n ) {\n return\n }\n\n try {\n if (shouldPrintDebug) {\n logger.info(`Unknown component ${name}, attempting dynamic load: ${sourcePath}`)\n }\n\n const out = loadTamaguiSync({\n // TODO would extract more, is NO-OP for now..\n forceExports: true,\n bubbleErrors: true,\n components: [sourcePath],\n })\n\n if (!out?.components) {\n if (shouldPrintDebug) {\n logger.info(`Couldn't load, got ${out}`)\n }\n return\n }\n\n propsWithFileInfo.allLoadedComponents = [\n ...propsWithFileInfo.allLoadedComponents,\n ...out.components,\n ]\n\n Component = out.components.flatMap((x) => x.nameToInfo[name] ?? [])[0]\n\n if (shouldPrintDebug) {\n logger.info([`Tamagui Loaded`, JSON.stringify(out.components), !!Component].join(' '))\n }\n } catch (err: any) {\n if (shouldPrintDebug) {\n logger.info(\n `${getPrefixLogs(\n options\n )} skip optimize styled(${name}), unable to pre-process (DEBUG=tamagui for more)`\n )\n }\n if (process.env.DEBUG === 'tamagui') {\n logger.info(\n ` Disable this with \"disableExtractFoundComponents\" in your build-time configuration. \\n\\n ${err.message} ${err.stack}`\n )\n }\n }\n }\n\n if (!Component) {\n return\n }\n\n const componentSkipProps = new Set([\n ...(Component.staticConfig.inlineWhenUnflattened || []),\n ...(Component.staticConfig.inlineProps || []),\n ...(Component.staticConfig.deoptProps || []),\n // for now skip variants, will return to them\n 'variants',\n 'defaultVariants',\n // skip fontFamily its basically a \"variant\", important for theme use to be value always\n 'fontFamily',\n 'name',\n ])\n\n // for now dont parse variants, spreads, etc\n const skipped: (t.ObjectProperty | t.SpreadElement | t.ObjectMethod)[] = []\n const styles = {}\n\n // Generate scope object at this level\n const staticNamespace = getStaticBindingsForScope(\n path.scope,\n importsWhitelist,\n sourcePath,\n bindingCache,\n shouldPrintDebug\n )\n\n const attemptEval = !evaluateVars\n ? evaluateAstNode\n : createEvaluator({\n props: propsWithFileInfo,\n staticNamespace,\n sourcePath,\n shouldPrintDebug,\n })\n const attemptEvalSafe = createSafeEvaluator(attemptEval)\n\n for (const property of definition.properties) {\n if (\n !t.isObjectProperty(property) ||\n !t.isIdentifier(property.key) ||\n !isValidStyleKey(property.key.name, Component.staticConfig) ||\n // skip variants\n Component.staticConfig.variants?.[property.key.name] ||\n componentSkipProps.has(property.key.name)\n ) {\n skipped.push(property)\n continue\n }\n // attempt eval\n const out = attemptEvalSafe(property.value)\n if (out === FAILED_EVAL) {\n skipped.push(property)\n } else {\n styles[property.key.name] = out\n }\n }\n\n const out = getSplitStyles(styles, Component.staticConfig, defaultTheme, {\n focus: false,\n hover: false,\n mounted: false,\n press: false,\n pressIn: false,\n resolveVariablesAs: 'variable',\n })\n\n const classNames = {\n ...out.classNames,\n }\n\n // add in the style object as classnames\n const atomics = getStylesAtomic(out.style)\n\n for (const atomic of atomics) {\n out.rulesToInsert = out.rulesToInsert || []\n out.rulesToInsert.push(atomic)\n classNames[atomic.property] = atomic.identifier\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n logger.info([`Extracted styled(${name})\\n`, JSON.stringify(styles, null, 2), '\\n=>\\n', out.rulesToInsert.flatMap((rule) => rule.rules).join('\\n')].join(' '))\n }\n\n // leave only un-parsed props...\n definition.properties = skipped\n\n // ... + key: className\n for (const cn in classNames) {\n if (componentSkipProps.has(cn)) {\n continue\n }\n const val = classNames[cn]\n definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)))\n }\n\n if (out.rulesToInsert) {\n for (const { identifier, rules } of out.rulesToInsert) {\n onStyleRule?.(identifier, rules)\n }\n }\n\n res.styled++\n\n if (shouldPrintDebug) {\n logger.info(`Extracted styled(${name})`)\n }\n },\n\n JSXElement(traversePath) {\n if (shouldDisableExtraction) {\n return\n }\n\n tm.mark('jsx-element', !!shouldPrintDebug)\n\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 let modulePath = ''\n\n if (binding) {\n if (!t.isImportDeclaration(binding.path.parent)) {\n if (shouldPrintDebug) {\n logger.info(` - Binding not import declaration, skip`)\n }\n return\n }\n modulePath = binding.path.parent.source.value\n if (!isValidImport(propsWithFileInfo, modulePath, binding.identifier.name)) {\n if (shouldPrintDebug) {\n logger.info(` - Binding not internal import or from components ${modulePath}`)\n }\n return\n }\n }\n\n const component = getValidComponent(propsWithFileInfo, modulePath, node.name.name)\n if (!component || !component.staticConfig) {\n if (shouldPrintDebug) {\n logger.info(` - No Tamagui conf on this: ${node.name.name}`)\n }\n return\n }\n\n const originalNodeName = node.name.name\n\n // found a valid tag\n res.found++\n\n const filePath = `./${relative(process.cwd(), sourcePath)}`\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 const codePosition = `${filePath}:${lineNumbers}`\n\n // debug just one\n const debugPropValue = node.attributes\n .filter(\n (n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === 'debug'\n )\n // @ts-ignore\n .map((n: t.JSXAttribute) => {\n if (n.value === null) return true\n if (t.isStringLiteral(n.value)) return n.value.value as 'verbose'\n return false\n })[0] as boolean | 'verbose' | undefined\n\n if (debugPropValue) {\n shouldPrintDebug = debugPropValue\n }\n\n if (shouldPrintDebug) {\n logger.info('\\n')\n logger.info(\n `\\x1b[33m%s\\x1b[0m ` + `${componentName} | ${codePosition} -------------------`\n )\n // prettier-ignore\n logger.info(['\\x1b[1m', '\\x1b[32m', `<${originalNodeName} />`, disableDebugAttr ? '' : '\uD83D\uDC1B'].join(' '))\n }\n\n // add data-* debug attributes\n if (shouldAddDebugProp && !disableDebugAttr) {\n res.modified++\n node.attributes.unshift(\n t.jsxAttribute(t.jsxIdentifier('data-is'), t.stringLiteral(node.name.name))\n )\n if (componentName) {\n node.attributes.unshift(\n t.jsxAttribute(t.jsxIdentifier('data-in'), t.stringLiteral(componentName))\n )\n }\n\n node.attributes.unshift(\n t.jsxAttribute(\n t.jsxIdentifier('data-at'),\n t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)\n )\n )\n }\n\n // disable as it gets messy\n // const shouldLog = !hasLogged\n // if (shouldLog) {\n // logger.info(` 1\uFE0F\u20E3 Inline optimized 2\uFE0F\u20E3 Inline flattened 3\uFE0F\u20E3 styled() extracted`)\n // const prefix = ' |'\n // // prettier-ignore\n // logger.info([prefixLogs || prefix, ' total \u00B7 1\uFE0F\u20E3 \u00B7 2\uFE0F\u20E3 \u00B7 3\uFE0F\u20E3'].join(' '))\n // hasLogged = true\n // }\n\n if (disableExtraction) {\n return\n }\n\n try {\n const { staticConfig } = component\n const variants = staticConfig.variants || {}\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 inlineProps = new Set([\n ...(restProps.inlineProps || []),\n ...(staticConfig.inlineProps || []),\n ])\n\n const deoptProps = new Set([\n // always de-opt animation\n 'animation',\n ...(restProps.deoptProps || []),\n ...(staticConfig.deoptProps || []),\n ])\n\n const inlineWhenUnflattened = new Set([...(staticConfig.inlineWhenUnflattened || [])])\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 props: propsWithFileInfo,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n })\n const attemptEvalSafe = createSafeEvaluator(attemptEval)\n\n if (shouldPrintDebug) {\n logger.info(` 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 logger.info([' couldnt parse spread', e.message].join(' '))\n }\n flattenedAttrs.push(attr)\n return\n }\n if (arg !== undefined) {\n try {\n if (typeof arg !== 'object' || arg == null) {\n if (shouldPrintDebug) {\n logger.info([' non object or null arg', arg].join(' '))\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 logger.error(['Unhandled null prop', k, value, arg].join(' '))\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 logger.warn(`cant parse spread, caught err ${err}`)\n couldntParse = true\n }\n }\n })\n\n if (couldntParse) {\n return\n }\n\n tm.mark('jsx-element-flattened', !!shouldPrintDebug)\n\n // set flattened\n node.attributes = flattenedAttrs\n\n let attrs: ExtractedAttr[] = []\n let shouldDeopt = false\n const inlined = new Map<string, any>()\n const variantValues = new Map<string, any>()\n let hasSetOptimized = false\n const inlineWhenUnflattenedOGVals = {}\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 tm.mark('jsx-element-evaluate-attr', !!shouldPrintDebug)\n if (!res) {\n path.remove()\n }\n return res\n } catch (err: any) {\n if (shouldPrintDebug) {\n logger.info(\n [\n 'Recoverable error extracting attribute',\n err.message,\n shouldPrintDebug === 'verbose' ? err.stack : '',\n ].join(' ')\n )\n if (shouldPrintDebug === 'verbose') {\n logger.info(`node ${path.node?.type}`)\n }\n }\n // dont flatten if we run into error\n inlined.set(`${Math.random()}`, 'spread')\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 logger.info(\n [' - attrs (before):\\n', logLines(attrs.map(attrStr).join(', '))].join(' ')\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 && !isStaticObject(side))) {\n if (shouldPrintDebug) {\n logger.info(`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 logger.info(' ! inlining, spread attr')\n }\n inlined.set(`${Math.random()}`, 'spread')\n return attr\n }\n\n const name = attribute.name.name\n\n if (excludeProps?.has(name)) {\n if (shouldPrintDebug) {\n logger.info([' excluding prop', name].join(' '))\n }\n return null\n }\n\n if (inlineProps.has(name)) {\n inlined.set(name, name)\n if (shouldPrintDebug) {\n logger.info([' ! inlining, inline prop', name].join(' '))\n }\n return attr\n }\n\n // can still optimize the object... see hoverStyle on native\n if (deoptProps.has(name)) {\n shouldDeopt = true\n inlined.set(name, name)\n if (shouldPrintDebug) {\n logger.info([' ! inlining, deopted prop', name].join(' '))\n }\n return attr\n }\n\n // pass className, key, and style props through untouched\n if (UNTOUCHED_PROPS[name]) {\n return attr\n }\n\n if (INLINE_EXTRACTABLE[name]) {\n inlined.set(name, INLINE_EXTRACTABLE[name])\n return attr\n }\n\n if (name.startsWith('data-')) {\n return attr\n }\n\n // shorthand media queries\n if (name[0] === '$' && t.isJSXExpressionContainer(attribute?.value)) {\n // allow disabling this extraction\n if (disableExtractInlineMedia) {\n return attr\n }\n\n const shortname = name.slice(1)\n if (mediaQueryConfig[shortname]) {\n const expression = attribute.value.expression\n if (!t.isJSXEmptyExpression(expression)) {\n const ternaries = createTernariesFromObjectProperties(\n t.stringLiteral(shortname),\n expression,\n {\n inlineMediaQuery: shortname,\n }\n )\n if (ternaries) {\n return ternaries.map((value) => ({\n type: 'ternary',\n value,\n }))\n }\n }\n }\n }\n\n const [value, valuePath] = (() => {\n if (t.isJSXExpressionContainer(attribute?.value)) {\n return [attribute.value.expression!, path.get('value')!] as const\n } else {\n return [attribute.value!, path.get('value')!] as const\n }\n })()\n\n const remove = () => {\n Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove()\n }\n\n if (name === 'ref') {\n if (shouldPrintDebug) {\n logger.info([' ! inlining, ref', name].join(' '))\n }\n inlined.set('ref', 'ref')\n return attr\n }\n\n if (name === 'tag') {\n return {\n type: 'attr',\n value: path.node,\n }\n }\n\n // native shouldn't extract variables\n if (disableExtractVariables === true) {\n if (value) {\n if (value.type === 'StringLiteral' && value.value[0] === '$') {\n if (shouldPrintDebug) {\n logger.info(\n [` ! inlining, native disable extract: ${name} =`, value.value].join(' ')\n )\n }\n inlined.set(name, true)\n return attr\n }\n }\n }\n\n if (name === 'theme') {\n inlined.set('theme', attr.value)\n return attr\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 (!variants[name] && !isValidStyleKey(name, staticConfig)) {\n let keys = [name]\n let out: any = null\n\n // for now passing empty props {}, a bit odd, need to at least document\n // for now we don't expose custom components so just noting behavior\n out = staticConfig.propMapper(\n name,\n styleValue,\n defaultTheme,\n staticConfig.defaultProps,\n { resolveVariablesAs: 'auto' },\n undefined,\n undefined,\n shouldPrintDebug\n )\n\n if (out) {\n if (!Array.isArray(out)) {\n logger.warn(`Error expected array but got`, out)\n couldntParse = true\n shouldDeopt = true\n } else {\n out = Object.fromEntries(out)\n keys = Object.keys(out)\n }\n }\n if (out) {\n if (isTargetingHTML) {\n // translate to DOM-compat\n out = createDOMProps(isTextView ? 'span' : 'div', out)\n // remove className - we dont use rnw styling\n delete out.className\n }\n\n keys = Object.keys(out)\n }\n\n let didInline = false\n const attributes = keys.map((key) => {\n const val = out[key]\n if (isValidStyleKey(key, staticConfig)) {\n return {\n type: 'style',\n value: { [key]: styleValue },\n name: key,\n attr: path.node,\n } as const\n }\n if (\n validHTMLAttributes[key] ||\n key.startsWith('aria-') ||\n key.startsWith('data-') ||\n // this is debug stuff added by vite / new jsx transform\n key === '__source' ||\n key === '__self'\n ) {\n return attr\n }\n if (shouldPrintDebug) {\n logger.info(' ! inlining, non-static ' + key)\n }\n didInline = true\n inlined.set(key, val)\n return val\n })\n\n // weird logic whats going on here\n if (didInline) {\n if (shouldPrintDebug) {\n logger.info(` bailing flattening due to attributes ${attributes}`)\n }\n // bail\n return attr\n }\n\n // return evaluated attributes\n return attributes\n }\n\n // FAILED = dynamic or ternary, keep going\n if (styleValue !== FAILED_EVAL) {\n if (inlineWhenUnflattened.has(name)) {\n // preserve original value for restoration\n inlineWhenUnflattenedOGVals[name] = { styleValue, attr }\n }\n\n if (isValidStyleKey(name, staticConfig)) {\n if (shouldPrintDebug) {\n logger.info(` style: ${name} = ${styleValue}`)\n }\n if (!(name in staticConfig.defaultProps)) {\n if (!hasSetOptimized) {\n res.optimized++\n hasSetOptimized = true\n }\n }\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\n }\n } else {\n if (variants[name]) {\n variantValues.set(name, styleValue)\n }\n inlined.set(name, true)\n return attr\n }\n }\n\n // ternaries!\n\n // binary ternary, we can eventually make this smarter but step 1\n // basically for the common use case of:\n // opacity={(conditional ? 0 : 1) * scale}\n if (t.isBinaryExpression(value)) {\n if (shouldPrintDebug) {\n logger.info(` 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 logger.info(` 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 logger.info(` evalBinaryExpression cant extract`)\n }\n inlined.set(name, true)\n return attr\n }\n\n const staticConditional = getStaticConditional(value)\n if (staticConditional) {\n if (shouldPrintDebug === 'verbose') {\n logger.info(` static conditional ${name} ${value}`)\n }\n return { type: 'ternary', value: staticConditional }\n }\n\n const staticLogical = getStaticLogical(value)\n if (staticLogical) {\n if (shouldPrintDebug === 'verbose') {\n logger.info(` static ternary ${name} = ${value}`)\n }\n return { type: 'ternary', value: staticLogical }\n }\n\n // if we've made it this far, the prop stays inline\n inlined.set(name, true)\n if (shouldPrintDebug) {\n logger.info(` ! inline no match ${name} ${value}`)\n }\n\n //\n // RETURN ATTR\n //\n return attr\n\n // attr helpers:\n function addBinaryConditional(\n operator: any,\n staticExpr: any,\n cond: t.ConditionalExpression\n ): ExtractedAttr | null {\n if (getStaticConditional(cond)) {\n const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate))\n const cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent))\n if (shouldPrintDebug) {\n logger.info([' binaryConditional', cond.test, cons, alt].join(' '))\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 const aVal = attemptEval(value.alternate)\n const cVal = attemptEval(value.consequent)\n if (shouldPrintDebug) {\n const type = value.test.type\n logger.info([' static ternary', type, cVal, aVal].join(' '))\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 logger.info([' cant eval ternary', err.message].join(' '))\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 logger.info([' staticLogical', value.left, name, val].join(' '))\n }\n return {\n test: value.left,\n remove,\n consequent: { [name]: val },\n alternate: null,\n }\n } catch (err) {\n if (shouldPrintDebug) {\n logger.info([' cant static eval logical', err].join(' '))\n }\n }\n }\n }\n return null\n }\n } // END function evaluateAttribute\n\n function isStaticObject(obj: t.Node): obj is t.ObjectExpression {\n return (\n t.isObjectExpression(obj) &&\n obj.properties.every((prop) => {\n if (!t.isObjectProperty(prop)) {\n logger.info(['not object prop', prop].join(' '))\n return false\n }\n const propName = prop.key['name']\n if (!isValidStyleKey(propName, staticConfig) && propName !== 'tag') {\n if (shouldPrintDebug) {\n logger.info([' not a valid style prop!', propName].join(' '))\n }\n return false\n }\n return true\n })\n )\n }\n\n // side = {\n // color: 'red',\n // background: x ? 'red' : 'green',\n // $gtSm: { color: 'green' }\n // }\n // => Ternary<test, { color: 'red' }, null>\n // => Ternary<test && x, { background: 'red' }, null>\n // => Ternary<test && !x, { background: 'green' }, null>\n // => Ternary<test && '$gtSm', { color: 'green' }, null>\n function createTernariesFromObjectProperties(\n test: t.Expression,\n side: t.Expression | null,\n ternaryPartial: Partial<Ternary> = {}\n ): null | Ternary[] {\n if (!side) {\n return null\n }\n if (!isStaticObject(side)) {\n throw new Error('not extractable')\n }\n return side.properties.flatMap((property) => {\n if (!t.isObjectProperty(property)) {\n throw new Error('expected object property')\n }\n // handle media queries inside spread/conditional objects\n if (t.isIdentifier(property.key)) {\n const key = property.key.name\n const mediaQueryKey = key.slice(1)\n const isMediaQuery = key[0] === '$' && mediaQueryConfig[mediaQueryKey]\n if (isMediaQuery) {\n if (t.isExpression(property.value)) {\n const ternaries = createTernariesFromObjectProperties(\n t.stringLiteral(mediaQueryKey),\n property.value,\n {\n inlineMediaQuery: mediaQueryKey,\n }\n )\n if (ternaries) {\n return ternaries.map((value) => ({\n ...ternaryPartial,\n ...value,\n // ensure media query test stays on left side (see getMediaQueryTernary)\n test: t.logicalExpression('&&', value.test, test),\n }))\n } else {\n logger.info(['\u26A0\uFE0F no ternaries?', property].join(' '))\n }\n } else {\n logger.info(['\u26A0\uFE0F not expression', property].join(' '))\n }\n }\n }\n // this could be a recurse here if we want to get fancy\n if (t.isConditionalExpression(property.value)) {\n // merge up into the parent conditional, split into two\n const [truthy, falsy] = [\n t.objectExpression([t.objectProperty(property.key, property.value.consequent)]),\n t.objectExpression([t.objectProperty(property.key, property.value.alternate)]),\n ].map((x) => attemptEval(x))\n return [\n createTernary({\n remove() {},\n ...ternaryPartial,\n test: t.logicalExpression('&&', test, property.value.test),\n consequent: truthy,\n alternate: null,\n }),\n createTernary({\n ...ternaryPartial,\n test: t.logicalExpression(\n '&&',\n test,\n t.unaryExpression('!', property.value.test)\n ),\n consequent: falsy,\n alternate: null,\n remove() {},\n }),\n ]\n }\n const obj = t.objectExpression([t.objectProperty(property.key, property.value)])\n const consequent = attemptEval(obj)\n return createTernary({\n remove() {},\n ...ternaryPartial,\n test,\n consequent,\n alternate: null,\n })\n })\n }\n\n // now update to new values\n node.attributes = attrs.filter(isAttr).map((x) => x.value)\n\n if (couldntParse || shouldDeopt) {\n if (shouldPrintDebug) {\n logger.info([` avoid optimizing:`, { couldntParse, shouldDeopt }].join(' '))\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 logger.info(\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 // flatten logic!\n // fairly simple check to see if all children are text\n const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x))\n\n const hasOnlyStringChildren =\n !hasSpread &&\n (node.selfClosing ||\n (traversePath.node.children &&\n traversePath.node.children.every((x) => x.type === 'JSXText')))\n\n const themeVal = inlined.get('theme')\n\n // on native we can't flatten when theme prop is set\n if (target !== 'native') {\n inlined.delete('theme')\n }\n\n for (const [key] of [...inlined]) {\n const isStaticObjectVariant = staticConfig.variants?.[key] && variantValues.has(key)\n if (INLINE_EXTRACTABLE[key] || isStaticObjectVariant) {\n inlined.delete(key)\n }\n }\n\n const canFlattenProps = inlined.size === 0\n\n let shouldFlatten = Boolean(\n flatNode &&\n !shouldDeopt &&\n canFlattenProps &&\n !hasSpread &&\n staticConfig.neverFlatten !== true &&\n (staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)\n )\n\n const shouldWrapTheme = shouldFlatten && themeVal\n const usedThemeKeys = new Set<string>()\n\n if (disableExtractVariables) {\n // if it accesses any theme values during evaluation\n themeAccessListeners.add((key) => {\n shouldFlatten = false\n usedThemeKeys.add(key)\n if (shouldPrintDebug === 'verbose') {\n logger.info([' ! accessing theme key, avoid flatten', key].join(' '))\n }\n })\n }\n\n if (shouldPrintDebug) {\n try {\n // prettier-ignore\n logger.info([' - flatten?', objToStr({ hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapTheme, hasOnlyStringChildren }), 'inlined', [...inlined]].join(' '))\n } catch {\n // ok\n }\n }\n\n // wrap theme around children on flatten\n // TODO move this to bottom and re-check shouldFlatten\n // account for shouldFlatten could change w the above block \"if (disableExtractVariables)\"\n if (shouldFlatten && shouldWrapTheme) {\n if (!programPath) {\n console.warn(\n `No program path found, avoiding importing flattening / importing theme in ${sourcePath}`\n )\n } else {\n if (shouldPrintDebug) {\n logger.info([' - wrapping theme', themeVal].join(' '))\n }\n\n // remove theme attribute from flattened node\n attrs = attrs.filter((x) =>\n x.type === 'attr' && t.isJSXAttribute(x.value) && x.value.name.name === 'theme'\n ? false\n : true\n )\n\n // add import\n if (!hasImportedTheme) {\n hasImportedTheme = true\n programPath.node.body.push(\n t.importDeclaration(\n [t.importSpecifier(t.identifier('_TamaguiTheme'), t.identifier('Theme'))],\n t.stringLiteral('@tamagui/core')\n )\n )\n }\n\n traversePath.replaceWith(\n t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier('_TamaguiTheme'), [\n t.jsxAttribute(t.jsxIdentifier('name'), themeVal.value),\n ]),\n t.jsxClosingElement(t.jsxIdentifier('_TamaguiTheme')),\n [traversePath.node]\n )\n )\n }\n }\n\n // only if we flatten, ensure the default styles are there\n if (shouldFlatten) {\n const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {\n if (!isValidStyleKey(key, staticConfig)) {\n return []\n }\n const value = staticConfig.defaultProps[key]\n const name = tamaguiConfig.shorthands[key] || key\n if (value === undefined) {\n logger.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`)\n shouldDeopt = true\n return\n }\n const attr: ExtractedAttrStyle = {\n type: 'style',\n name,\n value: { [name]: value },\n }\n return attr\n }) as ExtractedAttr[]\n\n if (defaultStyleAttrs.length) {\n attrs = [...defaultStyleAttrs, ...attrs]\n }\n }\n\n if (shouldDeopt) {\n if (shouldPrintDebug) {\n logger.info(`Deopting`)\n }\n node.attributes = ogAttributes\n return\n }\n\n // insert overrides - this inserts null props for things that are set in classNames\n // only when not flattening, so the downstream component can skip applying those styles\n const ensureOverridden = {}\n if (!shouldFlatten) {\n for (const cur of attrs) {\n if (cur.type === 'style') {\n // TODO need to loop over initial props not just style props\n for (const key in cur.value) {\n const shouldEnsureOverridden = !!staticConfig.ensureOverriddenProp?.[key]\n const isSetInAttrsAlready = attrs.some(\n (x) =>\n x.type === 'attr' &&\n x.value.type === 'JSXAttribute' &&\n x.value.name.name === key\n )\n\n if (!isSetInAttrsAlready) {\n const isVariant = !!staticConfig.variants?.[cur.name || '']\n if (isVariant || shouldEnsureOverridden) {\n ensureOverridden[key] = true\n }\n }\n }\n }\n }\n }\n\n if (shouldPrintDebug) {\n logger.info(\n [' - attrs (flattened): \\n', logLines(attrs.map(attrStr).join(', '))].join(' ')\n )\n logger.info(\n [' - ensureOverriden:', Object.keys(ensureOverridden).join(', ')].join(' ')\n )\n }\n\n const state = {\n noClassNames: false,\n focus: false,\n hover: false,\n mounted: true, // TODO match logic in createComponent\n press: false,\n pressIn: false,\n }\n\n // evaluates all static attributes into a simple object\n let foundStaticProps = {}\n for (const key in attrs) {\n const cur = attrs[key]\n if (cur.type === 'style') {\n // remove variants because they are processed later, and can lead to invalid values here\n // see <Spacer flex /> where flex looks like a valid style, but is a variant\n foundStaticProps = {\n ...foundStaticProps,\n ...expandStylesWithoutVariants(cur.value),\n }\n continue\n }\n if (cur.type === 'attr') {\n if (t.isJSXSpreadAttribute(cur.value)) {\n continue\n }\n if (!t.isJSXIdentifier(cur.value.name)) {\n continue\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 foundStaticProps = {\n ...foundStaticProps,\n [key]: value,\n }\n }\n }\n }\n\n // must preserve exact order\n const completeProps = {}\n for (const key in staticConfig.defaultProps) {\n if (!(key in foundStaticProps)) {\n completeProps[key] = staticConfig.defaultProps[key]\n }\n }\n for (const key in foundStaticProps) {\n completeProps[key] = foundStaticProps[key]\n }\n\n // expand shorthands, de-opt variables\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (!cur) return acc\n if (cur.type === 'attr' && !t.isJSXSpreadAttribute(cur.value)) {\n if (shouldFlatten) {\n const name = cur.value.name.name\n if (typeof name === 'string') {\n if (name === 'tag') {\n // remove tag=\"\"\n return acc\n }\n\n // if flattening, expand variants\n if (variants[name] && variantValues.has(name)) {\n let out = Object.fromEntries(\n staticConfig.propMapper(\n name,\n variantValues.get(name),\n defaultTheme,\n completeProps,\n { ...state, resolveVariablesAs: 'auto' },\n undefined,\n undefined,\n shouldPrintDebug\n ) || []\n )\n if (out && isTargetingHTML) {\n const cn = out.className\n // translate to DOM-compat\n out = createDOMProps(isTextView ? 'span' : 'div', out)\n // remove rnw className use ours\n out.className = cn\n }\n if (shouldPrintDebug) {\n logger.info([' - expanded variant', name, out].join(' '))\n }\n for (const key in out) {\n const value = out[key]\n if (isValidStyleKey(key, staticConfig)) {\n acc.push({\n type: 'style',\n value: { [key]: value },\n name: key,\n attr: cur.value,\n } as const)\n } else {\n acc.push({\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(\n typeof value === 'string'\n ? t.stringLiteral(value)\n : literalToAst(value)\n )\n ),\n })\n }\n }\n }\n }\n }\n }\n\n if (cur.type !== 'style') {\n acc.push(cur)\n return acc\n }\n\n let key = Object.keys(cur.value)[0]\n const value = cur.value[key]\n const fullKey = tamaguiConfig.shorthands[key]\n // expand shorthands\n if (fullKey) {\n cur.value = { [fullKey]: value }\n key = fullKey\n }\n\n // finally we have all styles + expansions, lets see if we need to skip\n // any and keep them as attrs\n if (disableExtractVariables) {\n if (value[0] === '$' && (usedThemeKeys.has(key) || usedThemeKeys.has(fullKey))) {\n if (shouldPrintDebug) {\n logger.info([` keeping variable inline: ${key} =`, value].join(' '))\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 tm.mark('jsx-element-expanded', !!shouldPrintDebug)\n if (shouldPrintDebug) {\n logger.info(\n [' - attrs (expanded): \\n', logLines(attrs.map(attrStr).join(', '))].join(' ')\n )\n }\n\n // merge styles, leave undefined values\n let prev: ExtractedAttr | null = null\n\n function splitVariants(style: any) {\n const variants = {}\n const styles = {}\n for (const key in style) {\n if (staticConfig.variants?.[key]) {\n variants[key] = style[key]\n } else {\n styles[key] = style[key]\n }\n }\n return {\n variants,\n styles,\n }\n }\n\n function expandStylesWithoutVariants(style: any) {\n const { variants, styles } = splitVariants(style)\n return {\n ...expandStyles(styles),\n ...variants,\n }\n }\n\n function mergeStyles(prev: ViewStyle & PseudoStyles, nextIn: ViewStyle & PseudoStyles) {\n const next = expandStylesWithoutVariants(nextIn)\n for (const key in next) {\n // merge pseudos\n if (pseudoDescriptors[key]) {\n prev[key] = prev[key] || {}\n if (shouldPrintDebug) {\n if (!next[key] || !prev[key]) {\n logger.info(['warn: missing', key, prev, next].join(' '))\n }\n }\n Object.assign(prev[key], next[key])\n } else {\n prev[key] = next[key]\n }\n }\n }\n\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n const key = Object.keys(cur.value)[0]\n const value = cur.value[key]\n\n const shouldKeepOriginalAttr =\n // !isStyleAndAttr[key] &&\n !shouldFlatten &&\n // de-opt transform styles so it merges properly if not flattened\n // we handle this later on\n // (stylePropsTransform[key] ||\n // de-opt if non-style\n !validStyles[key] &&\n !pseudoDescriptors[key] &&\n !key.startsWith('data-')\n\n if (shouldKeepOriginalAttr) {\n if (shouldPrintDebug) {\n logger.info([' - keeping as non-style', key].join(' '))\n }\n prev = cur\n acc.push({\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(\n typeof value === 'string' ? t.stringLiteral(value) : literalToAst(value)\n )\n ),\n })\n acc.push(cur)\n return acc\n }\n\n if (ensureOverridden[key]) {\n acc.push({\n type: 'attr',\n value:\n cur.attr ||\n t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(t.nullLiteral())),\n })\n }\n\n if (prev?.type === 'style') {\n mergeStyles(prev.value, cur.value)\n return acc\n }\n }\n\n prev = cur\n acc.push(cur)\n return acc\n }, [])\n\n if (shouldPrintDebug) {\n logger.info(\n [' - attrs (combined \uD83D\uDD00): \\n', logLines(attrs.map(attrStr).join(', '))].join(' ')\n )\n logger.info(\n [' - defaultProps: \\n', logLines(objToStr(staticConfig.defaultProps))].join(' ')\n )\n // prettier-ignore\n logger.info([' - foundStaticProps: \\n', logLines(objToStr(foundStaticProps))].join(' '))\n logger.info([' - completeProps: \\n', logLines(objToStr(completeProps))].join(' '))\n }\n\n // post process\n const getStyles = (props: Object | null, debugName = '') => {\n if (!props || !Object.keys(props).length) {\n if (shouldPrintDebug) logger.info([' getStyles() no props'].join(' '))\n return {}\n }\n if (excludeProps && !!excludeProps.size) {\n for (const key in props) {\n if (excludeProps.has(key)) {\n if (shouldPrintDebug) logger.info([' delete excluded', key].join(' '))\n delete props[key]\n }\n }\n }\n try {\n const out = getSplitStyles(\n props,\n staticConfig,\n defaultTheme,\n {\n ...state,\n fallbackProps: completeProps,\n },\n undefined,\n undefined,\n undefined,\n debugPropValue\n )\n\n const outStyle = {\n ...out.style,\n ...out.pseudos,\n }\n // omitInvalidStyles(outStyle)\n // if (shouldPrintDebug) {\n // // prettier-ignore\n // logger.info(` getStyles ${debugName} (props):\\n`, logLines(objToStr(props)))\n // // prettier-ignore\n // logger.info(` getStyles ${debugName} (out.viewProps):\\n`, logLines(objToStr(out.viewProps)))\n // // prettier-ignore\n // logger.info(` getStyles ${debugName} (out.style):\\n`, logLines(objToStr(outStyle || {}), true))\n // }\n return outStyle\n } catch (err: any) {\n logger.info(['error', err.message, err.stack].join(' '))\n return {}\n }\n }\n\n // used to ensure we pass the entire prop bundle to getStyles\n const completeStyles = getStyles(completeProps, 'completeStyles')\n\n if (!completeStyles) {\n throw new Error(`Impossible, no styles`)\n }\n\n const isNativeNotFlat = !shouldFlatten && target === 'native'\n if (isNativeNotFlat) {\n if (shouldPrintDebug) {\n logger.info(`Disabled flattening except for simple cases on native for now`)\n node.attributes = ogAttributes\n return null\n }\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, 'ternary.alternate')\n const c = getStyles(attr.value.consequent, 'ternary.consequent')\n if (a) attr.value.alternate = a\n if (c) attr.value.consequent = c\n if (shouldPrintDebug) logger.info([' => tern ', attrStr(attr)].join(' '))\n continue\n }\n case 'style': {\n // expand variants and such\n const styles = getStyles(attr.value, 'style')\n if (styles) {\n attr.value = styles\n }\n // prettier-ignore\n if (shouldPrintDebug) logger.info([' * styles (in)', logLines(objToStr(attr.value))].join(' '))\n // prettier-ignore\n if (shouldPrintDebug) logger.info([' * styles (out)', logLines(objToStr(styles))].join(' '))\n continue\n }\n }\n } catch (err) {\n // any error de-opt\n getStyleError = err\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n logger.info([' - attrs (ternaries/combined):\\n', logLines(attrs.map(attrStr).join(', '))].join(' '))\n }\n\n tm.mark('jsx-element-styles', !!shouldPrintDebug)\n\n if (getStyleError) {\n logger.info([' \u26A0\uFE0F postprocessing error, deopt', getStyleError].join(' '))\n node.attributes = ogAttributes\n return null\n }\n\n // final lazy extra loop:\n const existingStyleKeys = new Set()\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attr = attrs[i]\n\n // if flattening map inline props to proper flattened names\n if (shouldFlatten) {\n if (attr.type === 'attr') {\n if (t.isJSXAttribute(attr.value)) {\n if (t.isJSXIdentifier(attr.value.name)) {\n const name = attr.value.name.name\n if (INLINE_EXTRACTABLE[name]) {\n // map to HTML only name\n attr.value.name.name = INLINE_EXTRACTABLE[name]\n }\n }\n }\n }\n }\n\n // remove duplicate styles\n // so if you have:\n // style({ color: 'red' }), ...someProps, style({ color: 'green' })\n // this will mutate:\n // style({}), ...someProps, style({ color: 'green' })\n if (attr.type === 'style') {\n for (const key in attr.value) {\n if (existingStyleKeys.has(key)) {\n if (shouldPrintDebug) {\n logger.info([` >> delete existing ${key}`].join(' '))\n }\n delete attr.value[key]\n } else {\n existingStyleKeys.add(key)\n }\n }\n }\n }\n\n // inlineWhenUnflattened\n if (!shouldFlatten) {\n if (inlineWhenUnflattened.size) {\n for (const [index, attr] of attrs.entries()) {\n if (attr.type === 'style') {\n for (const key in attr.value) {\n if (!inlineWhenUnflattened.has(key)) continue\n const val = inlineWhenUnflattenedOGVals[key]\n if (val) {\n // delete the style\n delete attr.value[key]\n\n // and insert it before\n attrs.splice(index - 1, 0, val.attr)\n } else {\n // just delete it, it was added during expansion but should be left inline\n delete attr.value[key]\n }\n }\n }\n }\n }\n }\n\n if (shouldFlatten) {\n // DO FLATTEN\n if (shouldPrintDebug) {\n logger.info([' [\u2705] flattening', originalNodeName, flatNode].join(' '))\n }\n // @ts-ignore\n node.name.name = flatNode\n res.flattened++\n if (closingElement) {\n // @ts-ignore\n closingElement.name.name = flatNode\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n logger.info([` \u274A\u274A inline props (${inlined.size}):`, shouldDeopt ? ' deopted' : '', hasSpread ? ' has spread' : '', staticConfig.neverFlatten ? 'neverFlatten' : ''].join(' '))\n logger.info(` - attrs (end):\\n ${logLines(attrs.map(attrStr).join(', '))}`)\n }\n\n onExtractTag({\n parserProps: propsWithFileInfo,\n attrs,\n node,\n lineNumbers,\n filePath,\n attemptEval,\n jsxPath: traversePath,\n originalNodeName,\n isFlattened: shouldFlatten,\n programPath: programPath!,\n completeProps,\n staticConfig,\n })\n } finally {\n if (debugPropValue) {\n shouldPrintDebug = ogDebug\n }\n }\n },\n })\n\n tm.mark('jsx-done', !!shouldPrintDebug)\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 logger.info(` [\uD83E\uDE9D] hook check ${all.length}`)\n }\n for (const comp of all) {\n removeUnusedHooks(comp, shouldPrintDebug)\n }\n }\n\n tm.done(shouldPrintDebug === 'verbose')\n\n return res\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAyC;AAEzC,sBAAoD;AACpD,QAAmB;AACnB,uBASO;AACP,iBAA+B;AAG/B,uBAA4B;AAW5B,6BAAqD;AACrD,6BAAgC;AAChC,4BAQO;AACP,iCAAoC;AACpC,2BAA8B;AAC9B,uCAA6D;AAC7D,0BAA6B;AAC7B,yBAKO;AACP,sBAAyB;AACzB,gCAAmC;AACnC,+BAAkC;AAClC,mBAAsB;AACtB,iCAAoC;AAEpC,MAAM,kBAAkB;AAAA,EACtB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AACb;AAEA,MAAM,qBAAqB;AAAA,EACzB,KAAK;AAAA,EACL,KAAK;AAAA,EACL,GAAI,QAAQ,IAAI,mBAAmB,SAAS;AAAA,IAC1C,SAAS;AAAA,IACT,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AACF;AAE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AC/C;AACA,iBAAW,QAAQ,KAAK;AACtB,wDAAkB,MAAM,gBAAgB;AAAA,MAC1C;AAAA,IACF;AAEA,OAAG,KAAK,qBAAqB,SAAS;AAEtC,WAAO;AAAA,EACT;AACF;",
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport { basename, join, relative } from 'path'\n\nimport traverse, { NodePath, TraverseOptions } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport {\n PseudoStyles,\n StaticConfigParsed,\n expandStyles,\n getSplitStyles,\n getStylesAtomic,\n mediaQueryConfig,\n proxyThemeVariables,\n pseudoDescriptors,\n} from '@tamagui/core-node'\nimport type { ViewStyle } from 'react-native'\nimport { createDOMProps } from 'react-native-web-internals'\n\nimport { FAILED_EVAL } from '../constants.js'\nimport type {\n ExtractedAttr,\n ExtractedAttrAttr,\n ExtractedAttrStyle,\n ExtractorOptions,\n ExtractorParseProps,\n TamaguiOptions,\n TamaguiOptionsWithFileInfo,\n Ternary,\n} from '../types.js'\nimport { createEvaluator, createSafeEvaluator } from './createEvaluator.js'\nimport { evaluateAstNode } from './evaluateAstNode.js'\nimport {\n attrStr,\n findComponentName,\n getValidComponent,\n getValidImport,\n isPresent,\n isValidImport,\n objToStr,\n} from './extractHelpers.js'\nimport { findTopmostFunction } from './findTopmostFunction.js'\nimport { getPrefixLogs } from './getPrefixLogs.js'\nimport { cleanupBeforeExit, getStaticBindingsForScope } from './getStaticBindingsForScope.js'\nimport { literalToAst } from './literalToAst.js'\nimport {\n LoadedComponents,\n TamaguiProjectInfo,\n loadTamagui,\n loadTamaguiSync,\n} from './loadTamagui.js'\nimport { logLines } from './logLines.js'\nimport { normalizeTernaries } from './normalizeTernaries.js'\nimport { removeUnusedHooks } from './removeUnusedHooks.js'\nimport { timer } from './timer.js'\nimport { validHTMLAttributes } from './validHTMLAttributes.js'\n\nconst UNTOUCHED_PROPS = {\n key: true,\n style: true,\n className: true,\n}\n\nconst INLINE_EXTRACTABLE = {\n ref: 'ref',\n key: 'key',\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n onPress: 'onClick',\n onHoverIn: 'onMouseEnter',\n onHoverOut: 'onMouseLeave',\n onPressIn: 'onMouseDown',\n onPressOut: 'onMouseUp',\n }),\n}\n\nconst validHooks = {\n useMedia: true,\n useTheme: true,\n}\n\nconst isAttr = (x: ExtractedAttr): x is ExtractedAttrAttr => x.type === 'attr'\nconst createTernary = (x: Ternary) => x\n\nexport type Extractor = ReturnType<typeof createExtractor>\n\ntype FileOrPath = NodePath<t.Program> | t.File\n\nlet hasLoggedBaseInfo = false\n\nexport function createExtractor({ logger = console }: ExtractorOptions = { logger: console }) {\n if (!process.env.TAMAGUI_TARGET) {\n console.log('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either \"web\" or \"native\"')\n process.exit(1)\n }\n\n const shouldAddDebugProp =\n // really basic disable this for next.js because it messes with ssr\n !process.env.npm_package_dependencies_next &&\n process.env.TAMAGUI_TARGET !== 'native' &&\n process.env.IDENTIFY_TAGS !== 'false' &&\n (process.env.NODE_ENV === 'development' || process.env.DEBUG || process.env.IDENTIFY_TAGS)\n\n let projectInfo: TamaguiProjectInfo | null = null\n\n // we load tamagui delayed 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\n function loadSync(props: TamaguiOptions) {\n return (projectInfo ||= loadTamaguiSync({\n config: props.config || 'tamagui.config.ts',\n components: props.components || ['tamagui'],\n }))\n }\n\n async function load(props: TamaguiOptions) {\n return (projectInfo ||= await loadTamagui({\n config: props.config || 'tamagui.config.ts',\n components: props.components || ['tamagui'],\n }))\n }\n\n return {\n options: {\n logger,\n },\n cleanupBeforeExit,\n loadTamagui: load,\n loadTamaguiSync: loadSync,\n getTamagui() {\n return projectInfo?.tamaguiConfig\n },\n parseSync: (f: FileOrPath, props: ExtractorParseProps) => {\n const projectInfo = loadSync(props)\n return parseWithConfig(projectInfo, f, props)\n },\n parse: async (f: FileOrPath, props: ExtractorParseProps) => {\n const projectInfo = await load(props)\n return parseWithConfig(projectInfo, f, props)\n },\n }\n\n function isValidStyleKey(name: string, staticConfig: StaticConfigParsed) {\n if (!projectInfo) {\n throw new Error(`Tamagui extractor not loaded yet`)\n }\n return !!(\n !!staticConfig.validStyles?.[name] ||\n !!pseudoDescriptors[name] ||\n // dont disable variants or else you lose many things flattening\n staticConfig.variants?.[name] ||\n projectInfo?.tamaguiConfig.shorthands[name] ||\n (name[0] === '$' ? !!mediaQueryConfig[name.slice(1)] : false)\n )\n }\n\n function parseWithConfig(\n { components, tamaguiConfig }: TamaguiProjectInfo,\n fileOrPath: FileOrPath,\n options: ExtractorParseProps\n ) {\n const {\n config = 'tamagui.config.ts',\n importsWhitelist = ['constants.js'],\n evaluateVars = true,\n sourcePath = '',\n onExtractTag,\n onStyleRule,\n getFlattenedNode,\n disable,\n disableExtraction,\n disableExtractInlineMedia,\n disableExtractVariables,\n disableDebugAttr,\n disableExtractFoundComponents,\n includeExtensions = ['.tsx', '.jsx'],\n extractStyledDefinitions = false,\n prefixLogs,\n excludeProps,\n target,\n ...restProps\n } = options\n\n let shouldPrintDebug = options.shouldPrintDebug || false\n\n if (disable === true || (Array.isArray(disable) && disable.includes(sourcePath))) {\n return null\n }\n if (sourcePath === '') {\n throw new Error(`Must provide a source file name`)\n }\n if (!components) {\n throw new Error(`Must provide components`)\n }\n if (includeExtensions && !includeExtensions.some((ext) => sourcePath.endsWith(ext))) {\n if (shouldPrintDebug) {\n logger.info(\n `Ignoring file due to includeExtensions: ${sourcePath}, includeExtensions: ${includeExtensions.join(\n ', '\n )}`\n )\n }\n return null\n }\n\n /**\n * Step 1: Determine if importing any statically extractable components\n */\n\n const isTargetingHTML = target === 'html'\n const ogDebug = shouldPrintDebug\n const tm = timer()\n const propsWithFileInfo: TamaguiOptionsWithFileInfo = {\n ...options,\n sourcePath,\n allLoadedComponents: [...components],\n }\n\n if (!hasLoggedBaseInfo) {\n hasLoggedBaseInfo = true\n if (shouldPrintDebug) {\n logger.info(\n [\n 'loaded components:',\n propsWithFileInfo.allLoadedComponents\n .map((comp) => Object.keys(comp.nameToInfo).join(', '))\n .join(', '),\n ].join(' ')\n )\n }\n if (process.env.DEBUG?.startsWith('tamagui')) {\n const next = [...propsWithFileInfo.allLoadedComponents].map((info) => {\n const nameToInfo = { ...info.nameToInfo }\n for (const key in nameToInfo) {\n delete nameToInfo[key].staticConfig.validStyles\n }\n return { ...info, nameToInfo }\n })\n logger.info(['loaded:', JSON.stringify(next, null, 2)].join('\\n'))\n }\n }\n\n tm.mark('load-tamagui', !!shouldPrintDebug)\n\n const firstThemeName = Object.keys(tamaguiConfig.themes)[0]\n const firstTheme = tamaguiConfig.themes[firstThemeName]\n\n if (!firstTheme || typeof firstTheme !== 'object') {\n console.error(`Missing theme, an error occurred when importing your config`)\n console.log(`Got config:`, tamaguiConfig)\n console.log(`Looking for theme:`, firstThemeName)\n process.exit(0)\n }\n\n const proxiedTheme = proxyThemeVariables(firstTheme)\n type AccessListener = (key: string) => void\n const themeAccessListeners = new Set<AccessListener>()\n const defaultTheme = new Proxy(proxiedTheme, {\n get(target, key) {\n if (Reflect.has(target, key)) {\n themeAccessListeners.forEach((cb) => cb(String(key)))\n }\n return Reflect.get(target, key)\n },\n })\n\n // @ts-ignore\n const body = fileOrPath.type === 'Program' ? fileOrPath.get('body') : fileOrPath.program.body\n\n if (Object.keys(components).length === 0) {\n console.warn(`Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)`)\n if (process.env.DEBUG === 'tamagui') {\n console.log(`components`, Object.keys(components), components)\n }\n }\n\n if (shouldPrintDebug === 'verbose') {\n logger.info(\n `allLoadedComponent modules ${propsWithFileInfo.allLoadedComponents\n .map((k) => k.moduleName)\n .join(', ')}`\n )\n }\n\n let doesUseValidImport = false\n let hasImportedTheme = false\n\n const importDeclarations: t.ImportDeclaration[] = []\n\n for (const bodyPath of body) {\n if (bodyPath.type !== 'ImportDeclaration') continue\n const node = ('node' in bodyPath ? bodyPath.node : bodyPath) as t.ImportDeclaration\n const moduleName = node.source.value\n\n // if importing valid module\n const valid = isValidImport(propsWithFileInfo, moduleName)\n\n if (valid) {\n importDeclarations.push(node)\n }\n\n if (extractStyledDefinitions) {\n if (valid) {\n if (node.specifiers.some((specifier) => specifier.local.name === 'styled')) {\n doesUseValidImport = true\n break\n }\n }\n }\n\n if (valid) {\n const names = node.specifiers.map((specifier) => specifier.local.name)\n const isValidComponent = names.some((name) =>\n Boolean(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name])\n )\n if (shouldPrintDebug === 'verbose') {\n logger.info(\n `import ${names.join(', ')} from ${moduleName} isValidComponent ${isValidComponent}`\n )\n }\n if (isValidComponent) {\n doesUseValidImport = true\n break\n }\n }\n }\n\n if (shouldPrintDebug) {\n logger.info(`file: ${sourcePath} ${JSON.stringify({ doesUseValidImport, hasImportedTheme })}`)\n }\n\n if (!doesUseValidImport) {\n return null\n }\n\n function getValidImportedComponent(componentName: string) {\n const importDeclaration = importDeclarations.find((dec) =>\n dec.specifiers.some((spec) => spec.local.name === componentName)\n )\n if (!importDeclaration) {\n return null\n }\n return getValidImport(propsWithFileInfo, importDeclaration.source.value, componentName)\n }\n\n tm.mark('import-check', !!shouldPrintDebug)\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: TraverseOptions<any>) => {\n return fileOrPath.type === 'File' ? traverse(fileOrPath, a) : fileOrPath.traverse(a)\n }\n\n const shouldDisableExtraction =\n disableExtraction === true ||\n (Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath))\n\n /**\n * Step 2: Statically extract from JSX < /> nodes\n */\n let programPath: NodePath<t.Program> | null = null\n\n const res = {\n styled: 0,\n flattened: 0,\n optimized: 0,\n modified: 0,\n found: 0,\n }\n\n callTraverse({\n // @ts-ignore\n Program: {\n enter(path) {\n programPath = path\n },\n },\n\n // styled() calls\n CallExpression(path) {\n if (disable || shouldDisableExtraction || extractStyledDefinitions === false) {\n return\n }\n\n if (!t.isIdentifier(path.node.callee) || path.node.callee.name !== 'styled') {\n return\n }\n\n const name =\n t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id)\n ? path.parent.id.name\n : 'unknown'\n\n const definition = path.node.arguments[1]\n\n if (!name || !definition || !t.isObjectExpression(definition)) {\n return\n }\n\n let Component = getValidImportedComponent(name)\n\n if (!Component) {\n if (disableExtractFoundComponents === true) {\n return\n }\n if (\n Array.isArray(disableExtractFoundComponents) &&\n disableExtractFoundComponents.includes(name)\n ) {\n return\n }\n\n try {\n if (shouldPrintDebug) {\n logger.info(`Unknown component ${name}, attempting dynamic load: ${sourcePath}`)\n }\n\n const out = loadTamaguiSync({\n forceExports: true,\n components: [sourcePath],\n })\n\n if (!out?.components) {\n if (shouldPrintDebug) {\n logger.info(`Couldn't load, got ${out}`)\n }\n return\n }\n\n propsWithFileInfo.allLoadedComponents = [\n ...propsWithFileInfo.allLoadedComponents,\n ...out.components,\n ]\n\n Component = out.components.flatMap((x) => x.nameToInfo[name] ?? [])[0]\n\n if (shouldPrintDebug) {\n logger.info([`Tamagui Loaded`, JSON.stringify(out.components), !!Component].join(' '))\n }\n } catch (err: any) {\n if (shouldPrintDebug) {\n logger.info(\n `${getPrefixLogs(\n options\n )} skip optimize styled(${name}), unable to pre-process (DEBUG=tamagui for more)`\n )\n }\n if (process.env.DEBUG === 'tamagui') {\n logger.info(\n ` Disable this with \"disableExtractFoundComponents\" in your build-time configuration. \\n\\n ${err.message} ${err.stack}`\n )\n }\n }\n }\n\n if (!Component) {\n return\n }\n\n const componentSkipProps = new Set([\n ...(Component.staticConfig.inlineWhenUnflattened || []),\n ...(Component.staticConfig.inlineProps || []),\n ...(Component.staticConfig.deoptProps || []),\n // for now skip variants, will return to them\n 'variants',\n 'defaultVariants',\n // skip fontFamily its basically a \"variant\", important for theme use to be value always\n 'fontFamily',\n 'name',\n ])\n\n // for now dont parse variants, spreads, etc\n const skipped: (t.ObjectProperty | t.SpreadElement | t.ObjectMethod)[] = []\n const styles = {}\n\n // Generate scope object at this level\n const staticNamespace = getStaticBindingsForScope(\n path.scope,\n importsWhitelist,\n sourcePath,\n bindingCache,\n shouldPrintDebug\n )\n\n const attemptEval = !evaluateVars\n ? evaluateAstNode\n : createEvaluator({\n props: propsWithFileInfo,\n staticNamespace,\n sourcePath,\n shouldPrintDebug,\n })\n const attemptEvalSafe = createSafeEvaluator(attemptEval)\n\n for (const property of definition.properties) {\n if (\n !t.isObjectProperty(property) ||\n !t.isIdentifier(property.key) ||\n !isValidStyleKey(property.key.name, Component.staticConfig) ||\n // skip variants\n Component.staticConfig.variants?.[property.key.name] ||\n componentSkipProps.has(property.key.name)\n ) {\n skipped.push(property)\n continue\n }\n // attempt eval\n const out = attemptEvalSafe(property.value)\n if (out === FAILED_EVAL) {\n skipped.push(property)\n } else {\n styles[property.key.name] = out\n }\n }\n\n const out = getSplitStyles(styles, Component.staticConfig, defaultTheme, {\n focus: false,\n hover: false,\n mounted: false,\n press: false,\n pressIn: false,\n resolveVariablesAs: 'variable',\n })\n\n const classNames = {\n ...out.classNames,\n }\n\n // add in the style object as classnames\n const atomics = getStylesAtomic(out.style)\n\n for (const atomic of atomics) {\n out.rulesToInsert = out.rulesToInsert || []\n out.rulesToInsert.push(atomic)\n classNames[atomic.property] = atomic.identifier\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n logger.info([`Extracted styled(${name})\\n`, JSON.stringify(styles, null, 2), '\\n=>\\n', out.rulesToInsert.flatMap((rule) => rule.rules).join('\\n')].join(' '))\n }\n\n // leave only un-parsed props...\n definition.properties = skipped\n\n // ... + key: className\n for (const cn in classNames) {\n if (componentSkipProps.has(cn)) {\n continue\n }\n const val = classNames[cn]\n definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)))\n }\n\n if (out.rulesToInsert) {\n for (const { identifier, rules } of out.rulesToInsert) {\n onStyleRule?.(identifier, rules)\n }\n }\n\n res.styled++\n\n if (shouldPrintDebug) {\n logger.info(`Extracted styled(${name})`)\n }\n },\n\n JSXElement(traversePath) {\n if (shouldDisableExtraction) {\n return\n }\n\n tm.mark('jsx-element', !!shouldPrintDebug)\n\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 let modulePath = ''\n\n if (binding) {\n if (!t.isImportDeclaration(binding.path.parent)) {\n if (shouldPrintDebug) {\n logger.info(` - Binding not import declaration, skip`)\n }\n return\n }\n modulePath = binding.path.parent.source.value\n if (!isValidImport(propsWithFileInfo, modulePath, binding.identifier.name)) {\n if (shouldPrintDebug) {\n logger.info(` - Binding not internal import or from components ${modulePath}`)\n }\n return\n }\n }\n\n const component = getValidComponent(propsWithFileInfo, modulePath, node.name.name)\n if (!component || !component.staticConfig) {\n if (shouldPrintDebug) {\n logger.info(` - No Tamagui conf on this: ${node.name.name}`)\n }\n return\n }\n\n const originalNodeName = node.name.name\n\n // found a valid tag\n res.found++\n\n const filePath = `./${relative(process.cwd(), sourcePath)}`\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 const codePosition = `${filePath}:${lineNumbers}`\n\n // debug just one\n const debugPropValue = node.attributes\n .filter(\n (n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === 'debug'\n )\n // @ts-ignore\n .map((n: t.JSXAttribute) => {\n if (n.value === null) return true\n if (t.isStringLiteral(n.value)) return n.value.value as 'verbose'\n return false\n })[0] as boolean | 'verbose' | undefined\n\n if (debugPropValue) {\n shouldPrintDebug = debugPropValue\n }\n\n if (shouldPrintDebug) {\n logger.info('\\n')\n logger.info(\n `\\x1b[33m%s\\x1b[0m ` + `${componentName} | ${codePosition} -------------------`\n )\n // prettier-ignore\n logger.info(['\\x1b[1m', '\\x1b[32m', `<${originalNodeName} />`, disableDebugAttr ? '' : '\uD83D\uDC1B'].join(' '))\n }\n\n // add data-* debug attributes\n if (shouldAddDebugProp && !disableDebugAttr) {\n res.modified++\n node.attributes.unshift(\n t.jsxAttribute(t.jsxIdentifier('data-is'), t.stringLiteral(node.name.name))\n )\n if (componentName) {\n node.attributes.unshift(\n t.jsxAttribute(t.jsxIdentifier('data-in'), t.stringLiteral(componentName))\n )\n }\n\n node.attributes.unshift(\n t.jsxAttribute(\n t.jsxIdentifier('data-at'),\n t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)\n )\n )\n }\n\n // disable as it gets messy\n // const shouldLog = !hasLogged\n // if (shouldLog) {\n // logger.info(` 1\uFE0F\u20E3 Inline optimized 2\uFE0F\u20E3 Inline flattened 3\uFE0F\u20E3 styled() extracted`)\n // const prefix = ' |'\n // // prettier-ignore\n // logger.info([prefixLogs || prefix, ' total \u00B7 1\uFE0F\u20E3 \u00B7 2\uFE0F\u20E3 \u00B7 3\uFE0F\u20E3'].join(' '))\n // hasLogged = true\n // }\n\n if (disableExtraction) {\n return\n }\n\n try {\n const { staticConfig } = component\n const variants = staticConfig.variants || {}\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 inlineProps = new Set([\n ...(restProps.inlineProps || []),\n ...(staticConfig.inlineProps || []),\n ])\n\n const deoptProps = new Set([\n // always de-opt animation\n 'animation',\n ...(restProps.deoptProps || []),\n ...(staticConfig.deoptProps || []),\n ])\n\n const inlineWhenUnflattened = new Set([...(staticConfig.inlineWhenUnflattened || [])])\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 props: propsWithFileInfo,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n })\n const attemptEvalSafe = createSafeEvaluator(attemptEval)\n\n if (shouldPrintDebug) {\n logger.info(` 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 logger.info([' couldnt parse spread', e.message].join(' '))\n }\n flattenedAttrs.push(attr)\n return\n }\n if (arg !== undefined) {\n try {\n if (typeof arg !== 'object' || arg == null) {\n if (shouldPrintDebug) {\n logger.info([' non object or null arg', arg].join(' '))\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 logger.error(['Unhandled null prop', k, value, arg].join(' '))\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 logger.warn(`cant parse spread, caught err ${err}`)\n couldntParse = true\n }\n }\n })\n\n if (couldntParse) {\n return\n }\n\n tm.mark('jsx-element-flattened', !!shouldPrintDebug)\n\n // set flattened\n node.attributes = flattenedAttrs\n\n let attrs: ExtractedAttr[] = []\n let shouldDeopt = false\n const inlined = new Map<string, any>()\n const variantValues = new Map<string, any>()\n let hasSetOptimized = false\n const inlineWhenUnflattenedOGVals = {}\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 tm.mark('jsx-element-evaluate-attr', !!shouldPrintDebug)\n if (!res) {\n path.remove()\n }\n return res\n } catch (err: any) {\n if (shouldPrintDebug) {\n logger.info(\n [\n 'Recoverable error extracting attribute',\n err.message,\n shouldPrintDebug === 'verbose' ? err.stack : '',\n ].join(' ')\n )\n if (shouldPrintDebug === 'verbose') {\n logger.info(`node ${path.node?.type}`)\n }\n }\n // dont flatten if we run into error\n inlined.set(`${Math.random()}`, 'spread')\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 logger.info(\n [' - attrs (before):\\n', logLines(attrs.map(attrStr).join(', '))].join(' ')\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 && !isStaticObject(side))) {\n if (shouldPrintDebug) {\n logger.info(`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 logger.info(' ! inlining, spread attr')\n }\n inlined.set(`${Math.random()}`, 'spread')\n return attr\n }\n\n const name = attribute.name.name\n\n if (excludeProps?.has(name)) {\n if (shouldPrintDebug) {\n logger.info([' excluding prop', name].join(' '))\n }\n return null\n }\n\n if (inlineProps.has(name)) {\n inlined.set(name, name)\n if (shouldPrintDebug) {\n logger.info([' ! inlining, inline prop', name].join(' '))\n }\n return attr\n }\n\n // can still optimize the object... see hoverStyle on native\n if (deoptProps.has(name)) {\n shouldDeopt = true\n inlined.set(name, name)\n if (shouldPrintDebug) {\n logger.info([' ! inlining, deopted prop', name].join(' '))\n }\n return attr\n }\n\n // pass className, key, and style props through untouched\n if (UNTOUCHED_PROPS[name]) {\n return attr\n }\n\n if (INLINE_EXTRACTABLE[name]) {\n inlined.set(name, INLINE_EXTRACTABLE[name])\n return attr\n }\n\n if (name.startsWith('data-')) {\n return attr\n }\n\n // shorthand media queries\n if (name[0] === '$' && t.isJSXExpressionContainer(attribute?.value)) {\n // allow disabling this extraction\n if (disableExtractInlineMedia) {\n return attr\n }\n\n const shortname = name.slice(1)\n if (mediaQueryConfig[shortname]) {\n const expression = attribute.value.expression\n if (!t.isJSXEmptyExpression(expression)) {\n const ternaries = createTernariesFromObjectProperties(\n t.stringLiteral(shortname),\n expression,\n {\n inlineMediaQuery: shortname,\n }\n )\n if (ternaries) {\n return ternaries.map((value) => ({\n type: 'ternary',\n value,\n }))\n }\n }\n }\n }\n\n const [value, valuePath] = (() => {\n if (t.isJSXExpressionContainer(attribute?.value)) {\n return [attribute.value.expression!, path.get('value')!] as const\n } else {\n return [attribute.value!, path.get('value')!] as const\n }\n })()\n\n const remove = () => {\n Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove()\n }\n\n if (name === 'ref') {\n if (shouldPrintDebug) {\n logger.info([' ! inlining, ref', name].join(' '))\n }\n inlined.set('ref', 'ref')\n return attr\n }\n\n if (name === 'tag') {\n return {\n type: 'attr',\n value: path.node,\n }\n }\n\n // native shouldn't extract variables\n if (disableExtractVariables === true) {\n if (value) {\n if (value.type === 'StringLiteral' && value.value[0] === '$') {\n if (shouldPrintDebug) {\n logger.info(\n [` ! inlining, native disable extract: ${name} =`, value.value].join(' ')\n )\n }\n inlined.set(name, true)\n return attr\n }\n }\n }\n\n if (name === 'theme') {\n inlined.set('theme', attr.value)\n return attr\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 (!variants[name] && !isValidStyleKey(name, staticConfig)) {\n let keys = [name]\n let out: any = null\n\n // for now passing empty props {}, a bit odd, need to at least document\n // for now we don't expose custom components so just noting behavior\n out = staticConfig.propMapper(\n name,\n styleValue,\n defaultTheme,\n staticConfig.defaultProps,\n { resolveVariablesAs: 'auto' },\n undefined,\n undefined,\n shouldPrintDebug\n )\n\n if (out) {\n if (!Array.isArray(out)) {\n logger.warn(`Error expected array but got`, out)\n couldntParse = true\n shouldDeopt = true\n } else {\n out = Object.fromEntries(out)\n keys = Object.keys(out)\n }\n }\n if (out) {\n if (isTargetingHTML) {\n // translate to DOM-compat\n out = createDOMProps(isTextView ? 'span' : 'div', out)\n // remove className - we dont use rnw styling\n delete out.className\n }\n\n keys = Object.keys(out)\n }\n\n let didInline = false\n const attributes = keys.map((key) => {\n const val = out[key]\n if (isValidStyleKey(key, staticConfig)) {\n return {\n type: 'style',\n value: { [key]: styleValue },\n name: key,\n attr: path.node,\n } as const\n }\n if (\n validHTMLAttributes[key] ||\n key.startsWith('aria-') ||\n key.startsWith('data-') ||\n // this is debug stuff added by vite / new jsx transform\n key === '__source' ||\n key === '__self'\n ) {\n return attr\n }\n if (shouldPrintDebug) {\n logger.info(' ! inlining, non-static ' + key)\n }\n didInline = true\n inlined.set(key, val)\n return val\n })\n\n // weird logic whats going on here\n if (didInline) {\n if (shouldPrintDebug) {\n logger.info(` bailing flattening due to attributes ${attributes}`)\n }\n // bail\n return attr\n }\n\n // return evaluated attributes\n return attributes\n }\n\n // FAILED = dynamic or ternary, keep going\n if (styleValue !== FAILED_EVAL) {\n if (inlineWhenUnflattened.has(name)) {\n // preserve original value for restoration\n inlineWhenUnflattenedOGVals[name] = { styleValue, attr }\n }\n\n if (isValidStyleKey(name, staticConfig)) {\n if (shouldPrintDebug) {\n logger.info(` style: ${name} = ${styleValue}`)\n }\n if (!(name in staticConfig.defaultProps)) {\n if (!hasSetOptimized) {\n res.optimized++\n hasSetOptimized = true\n }\n }\n return {\n type: 'style',\n value: { [name]: styleValue },\n name,\n attr: path.node,\n }\n } else {\n if (variants[name]) {\n variantValues.set(name, styleValue)\n }\n inlined.set(name, true)\n return attr\n }\n }\n\n // ternaries!\n\n // binary ternary, we can eventually make this smarter but step 1\n // basically for the common use case of:\n // opacity={(conditional ? 0 : 1) * scale}\n if (t.isBinaryExpression(value)) {\n if (shouldPrintDebug) {\n logger.info(` 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 logger.info(` 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 logger.info(` evalBinaryExpression cant extract`)\n }\n inlined.set(name, true)\n return attr\n }\n\n const staticConditional = getStaticConditional(value)\n if (staticConditional) {\n if (shouldPrintDebug === 'verbose') {\n logger.info(` static conditional ${name} ${value}`)\n }\n return { type: 'ternary', value: staticConditional }\n }\n\n const staticLogical = getStaticLogical(value)\n if (staticLogical) {\n if (shouldPrintDebug === 'verbose') {\n logger.info(` static ternary ${name} = ${value}`)\n }\n return { type: 'ternary', value: staticLogical }\n }\n\n // if we've made it this far, the prop stays inline\n inlined.set(name, true)\n if (shouldPrintDebug) {\n logger.info(` ! inline no match ${name} ${value}`)\n }\n\n //\n // RETURN ATTR\n //\n return attr\n\n // attr helpers:\n function addBinaryConditional(\n operator: any,\n staticExpr: any,\n cond: t.ConditionalExpression\n ): ExtractedAttr | null {\n if (getStaticConditional(cond)) {\n const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate))\n const cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent))\n if (shouldPrintDebug) {\n logger.info([' binaryConditional', cond.test, cons, alt].join(' '))\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 const aVal = attemptEval(value.alternate)\n const cVal = attemptEval(value.consequent)\n if (shouldPrintDebug) {\n const type = value.test.type\n logger.info([' static ternary', type, cVal, aVal].join(' '))\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 logger.info([' cant eval ternary', err.message].join(' '))\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 logger.info([' staticLogical', value.left, name, val].join(' '))\n }\n return {\n test: value.left,\n remove,\n consequent: { [name]: val },\n alternate: null,\n }\n } catch (err) {\n if (shouldPrintDebug) {\n logger.info([' cant static eval logical', err].join(' '))\n }\n }\n }\n }\n return null\n }\n } // END function evaluateAttribute\n\n function isStaticObject(obj: t.Node): obj is t.ObjectExpression {\n return (\n t.isObjectExpression(obj) &&\n obj.properties.every((prop) => {\n if (!t.isObjectProperty(prop)) {\n logger.info(['not object prop', prop].join(' '))\n return false\n }\n const propName = prop.key['name']\n if (!isValidStyleKey(propName, staticConfig) && propName !== 'tag') {\n if (shouldPrintDebug) {\n logger.info([' not a valid style prop!', propName].join(' '))\n }\n return false\n }\n return true\n })\n )\n }\n\n // side = {\n // color: 'red',\n // background: x ? 'red' : 'green',\n // $gtSm: { color: 'green' }\n // }\n // => Ternary<test, { color: 'red' }, null>\n // => Ternary<test && x, { background: 'red' }, null>\n // => Ternary<test && !x, { background: 'green' }, null>\n // => Ternary<test && '$gtSm', { color: 'green' }, null>\n function createTernariesFromObjectProperties(\n test: t.Expression,\n side: t.Expression | null,\n ternaryPartial: Partial<Ternary> = {}\n ): null | Ternary[] {\n if (!side) {\n return null\n }\n if (!isStaticObject(side)) {\n throw new Error('not extractable')\n }\n return side.properties.flatMap((property) => {\n if (!t.isObjectProperty(property)) {\n throw new Error('expected object property')\n }\n // handle media queries inside spread/conditional objects\n if (t.isIdentifier(property.key)) {\n const key = property.key.name\n const mediaQueryKey = key.slice(1)\n const isMediaQuery = key[0] === '$' && mediaQueryConfig[mediaQueryKey]\n if (isMediaQuery) {\n if (t.isExpression(property.value)) {\n const ternaries = createTernariesFromObjectProperties(\n t.stringLiteral(mediaQueryKey),\n property.value,\n {\n inlineMediaQuery: mediaQueryKey,\n }\n )\n if (ternaries) {\n return ternaries.map((value) => ({\n ...ternaryPartial,\n ...value,\n // ensure media query test stays on left side (see getMediaQueryTernary)\n test: t.logicalExpression('&&', value.test, test),\n }))\n } else {\n logger.info(['\u26A0\uFE0F no ternaries?', property].join(' '))\n }\n } else {\n logger.info(['\u26A0\uFE0F not expression', property].join(' '))\n }\n }\n }\n // this could be a recurse here if we want to get fancy\n if (t.isConditionalExpression(property.value)) {\n // merge up into the parent conditional, split into two\n const [truthy, falsy] = [\n t.objectExpression([t.objectProperty(property.key, property.value.consequent)]),\n t.objectExpression([t.objectProperty(property.key, property.value.alternate)]),\n ].map((x) => attemptEval(x))\n return [\n createTernary({\n remove() {},\n ...ternaryPartial,\n test: t.logicalExpression('&&', test, property.value.test),\n consequent: truthy,\n alternate: null,\n }),\n createTernary({\n ...ternaryPartial,\n test: t.logicalExpression(\n '&&',\n test,\n t.unaryExpression('!', property.value.test)\n ),\n consequent: falsy,\n alternate: null,\n remove() {},\n }),\n ]\n }\n const obj = t.objectExpression([t.objectProperty(property.key, property.value)])\n const consequent = attemptEval(obj)\n return createTernary({\n remove() {},\n ...ternaryPartial,\n test,\n consequent,\n alternate: null,\n })\n })\n }\n\n // now update to new values\n node.attributes = attrs.filter(isAttr).map((x) => x.value)\n\n if (couldntParse || shouldDeopt) {\n if (shouldPrintDebug) {\n logger.info([` avoid optimizing:`, { couldntParse, shouldDeopt }].join(' '))\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 logger.info(\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 // flatten logic!\n // fairly simple check to see if all children are text\n const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x))\n\n const hasOnlyStringChildren =\n !hasSpread &&\n (node.selfClosing ||\n (traversePath.node.children &&\n traversePath.node.children.every((x) => x.type === 'JSXText')))\n\n const themeVal = inlined.get('theme')\n\n // on native we can't flatten when theme prop is set\n if (target !== 'native') {\n inlined.delete('theme')\n }\n\n for (const [key] of [...inlined]) {\n const isStaticObjectVariant = staticConfig.variants?.[key] && variantValues.has(key)\n if (INLINE_EXTRACTABLE[key] || isStaticObjectVariant) {\n inlined.delete(key)\n }\n }\n\n const canFlattenProps = inlined.size === 0\n\n let shouldFlatten = Boolean(\n flatNode &&\n !shouldDeopt &&\n canFlattenProps &&\n !hasSpread &&\n staticConfig.neverFlatten !== true &&\n (staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)\n )\n\n const shouldWrapTheme = shouldFlatten && themeVal\n const usedThemeKeys = new Set<string>()\n\n if (disableExtractVariables) {\n // if it accesses any theme values during evaluation\n themeAccessListeners.add((key) => {\n shouldFlatten = false\n usedThemeKeys.add(key)\n if (shouldPrintDebug === 'verbose') {\n logger.info([' ! accessing theme key, avoid flatten', key].join(' '))\n }\n })\n }\n\n if (shouldPrintDebug) {\n try {\n // prettier-ignore\n logger.info([' - flatten?', objToStr({ hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapTheme, hasOnlyStringChildren }), 'inlined', [...inlined]].join(' '))\n } catch {\n // ok\n }\n }\n\n // wrap theme around children on flatten\n // TODO move this to bottom and re-check shouldFlatten\n // account for shouldFlatten could change w the above block \"if (disableExtractVariables)\"\n if (shouldFlatten && shouldWrapTheme) {\n if (!programPath) {\n console.warn(\n `No program path found, avoiding importing flattening / importing theme in ${sourcePath}`\n )\n } else {\n if (shouldPrintDebug) {\n logger.info([' - wrapping theme', themeVal].join(' '))\n }\n\n // remove theme attribute from flattened node\n attrs = attrs.filter((x) =>\n x.type === 'attr' && t.isJSXAttribute(x.value) && x.value.name.name === 'theme'\n ? false\n : true\n )\n\n // add import\n if (!hasImportedTheme) {\n hasImportedTheme = true\n programPath.node.body.push(\n t.importDeclaration(\n [t.importSpecifier(t.identifier('_TamaguiTheme'), t.identifier('Theme'))],\n t.stringLiteral('@tamagui/core')\n )\n )\n }\n\n traversePath.replaceWith(\n t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier('_TamaguiTheme'), [\n t.jsxAttribute(t.jsxIdentifier('name'), themeVal.value),\n ]),\n t.jsxClosingElement(t.jsxIdentifier('_TamaguiTheme')),\n [traversePath.node]\n )\n )\n }\n }\n\n // only if we flatten, ensure the default styles are there\n if (shouldFlatten) {\n const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {\n if (!isValidStyleKey(key, staticConfig)) {\n return []\n }\n const value = staticConfig.defaultProps[key]\n const name = tamaguiConfig.shorthands[key] || key\n if (value === undefined) {\n logger.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`)\n shouldDeopt = true\n return\n }\n const attr: ExtractedAttrStyle = {\n type: 'style',\n name,\n value: { [name]: value },\n }\n return attr\n }) as ExtractedAttr[]\n\n if (defaultStyleAttrs.length) {\n attrs = [...defaultStyleAttrs, ...attrs]\n }\n }\n\n if (shouldDeopt) {\n if (shouldPrintDebug) {\n logger.info(`Deopting`)\n }\n node.attributes = ogAttributes\n return\n }\n\n // insert overrides - this inserts null props for things that are set in classNames\n // only when not flattening, so the downstream component can skip applying those styles\n const ensureOverridden = {}\n if (!shouldFlatten) {\n for (const cur of attrs) {\n if (cur.type === 'style') {\n // TODO need to loop over initial props not just style props\n for (const key in cur.value) {\n const shouldEnsureOverridden = !!staticConfig.ensureOverriddenProp?.[key]\n const isSetInAttrsAlready = attrs.some(\n (x) =>\n x.type === 'attr' &&\n x.value.type === 'JSXAttribute' &&\n x.value.name.name === key\n )\n\n if (!isSetInAttrsAlready) {\n const isVariant = !!staticConfig.variants?.[cur.name || '']\n if (isVariant || shouldEnsureOverridden) {\n ensureOverridden[key] = true\n }\n }\n }\n }\n }\n }\n\n if (shouldPrintDebug) {\n logger.info(\n [' - attrs (flattened): \\n', logLines(attrs.map(attrStr).join(', '))].join(' ')\n )\n logger.info(\n [' - ensureOverriden:', Object.keys(ensureOverridden).join(', ')].join(' ')\n )\n }\n\n const state = {\n noClassNames: false,\n focus: false,\n hover: false,\n mounted: true, // TODO match logic in createComponent\n press: false,\n pressIn: false,\n }\n\n // evaluates all static attributes into a simple object\n let foundStaticProps = {}\n for (const key in attrs) {\n const cur = attrs[key]\n if (cur.type === 'style') {\n // remove variants because they are processed later, and can lead to invalid values here\n // see <Spacer flex /> where flex looks like a valid style, but is a variant\n foundStaticProps = {\n ...foundStaticProps,\n ...expandStylesWithoutVariants(cur.value),\n }\n continue\n }\n if (cur.type === 'attr') {\n if (t.isJSXSpreadAttribute(cur.value)) {\n continue\n }\n if (!t.isJSXIdentifier(cur.value.name)) {\n continue\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 foundStaticProps = {\n ...foundStaticProps,\n [key]: value,\n }\n }\n }\n }\n\n // must preserve exact order\n const completeProps = {}\n for (const key in staticConfig.defaultProps) {\n if (!(key in foundStaticProps)) {\n completeProps[key] = staticConfig.defaultProps[key]\n }\n }\n for (const key in foundStaticProps) {\n completeProps[key] = foundStaticProps[key]\n }\n\n // expand shorthands, de-opt variables\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (!cur) return acc\n if (cur.type === 'attr' && !t.isJSXSpreadAttribute(cur.value)) {\n if (shouldFlatten) {\n const name = cur.value.name.name\n if (typeof name === 'string') {\n if (name === 'tag') {\n // remove tag=\"\"\n return acc\n }\n\n // if flattening, expand variants\n if (variants[name] && variantValues.has(name)) {\n let out = Object.fromEntries(\n staticConfig.propMapper(\n name,\n variantValues.get(name),\n defaultTheme,\n completeProps,\n { ...state, resolveVariablesAs: 'auto' },\n undefined,\n undefined,\n shouldPrintDebug\n ) || []\n )\n if (out && isTargetingHTML) {\n const cn = out.className\n // translate to DOM-compat\n out = createDOMProps(isTextView ? 'span' : 'div', out)\n // remove rnw className use ours\n out.className = cn\n }\n if (shouldPrintDebug) {\n logger.info([' - expanded variant', name, out].join(' '))\n }\n for (const key in out) {\n const value = out[key]\n if (isValidStyleKey(key, staticConfig)) {\n acc.push({\n type: 'style',\n value: { [key]: value },\n name: key,\n attr: cur.value,\n } as const)\n } else {\n acc.push({\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(\n typeof value === 'string'\n ? t.stringLiteral(value)\n : literalToAst(value)\n )\n ),\n })\n }\n }\n }\n }\n }\n }\n\n if (cur.type !== 'style') {\n acc.push(cur)\n return acc\n }\n\n let key = Object.keys(cur.value)[0]\n const value = cur.value[key]\n const fullKey = tamaguiConfig.shorthands[key]\n // expand shorthands\n if (fullKey) {\n cur.value = { [fullKey]: value }\n key = fullKey\n }\n\n // finally we have all styles + expansions, lets see if we need to skip\n // any and keep them as attrs\n if (disableExtractVariables) {\n if (value[0] === '$' && (usedThemeKeys.has(key) || usedThemeKeys.has(fullKey))) {\n if (shouldPrintDebug) {\n logger.info([` keeping variable inline: ${key} =`, value].join(' '))\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 tm.mark('jsx-element-expanded', !!shouldPrintDebug)\n if (shouldPrintDebug) {\n logger.info(\n [' - attrs (expanded): \\n', logLines(attrs.map(attrStr).join(', '))].join(' ')\n )\n }\n\n // merge styles, leave undefined values\n let prev: ExtractedAttr | null = null\n\n function splitVariants(style: any) {\n const variants = {}\n const styles = {}\n for (const key in style) {\n if (staticConfig.variants?.[key]) {\n variants[key] = style[key]\n } else {\n styles[key] = style[key]\n }\n }\n return {\n variants,\n styles,\n }\n }\n\n function expandStylesWithoutVariants(style: any) {\n const { variants, styles } = splitVariants(style)\n return {\n ...expandStyles(styles),\n ...variants,\n }\n }\n\n function mergeStyles(prev: ViewStyle & PseudoStyles, nextIn: ViewStyle & PseudoStyles) {\n const next = expandStylesWithoutVariants(nextIn)\n for (const key in next) {\n // merge pseudos\n if (pseudoDescriptors[key]) {\n prev[key] = prev[key] || {}\n if (shouldPrintDebug) {\n if (!next[key] || !prev[key]) {\n logger.info(['warn: missing', key, prev, next].join(' '))\n }\n }\n Object.assign(prev[key], next[key])\n } else {\n prev[key] = next[key]\n }\n }\n }\n\n attrs = attrs.reduce<ExtractedAttr[]>((acc, cur) => {\n if (cur.type === 'style') {\n const key = Object.keys(cur.value)[0]\n const value = cur.value[key]\n\n const shouldKeepOriginalAttr =\n // !isStyleAndAttr[key] &&\n !shouldFlatten &&\n // de-opt transform styles so it merges properly if not flattened\n // we handle this later on\n // (stylePropsTransform[key] ||\n // de-opt if non-style\n !validStyles[key] &&\n !pseudoDescriptors[key] &&\n !key.startsWith('data-')\n\n if (shouldKeepOriginalAttr) {\n if (shouldPrintDebug) {\n logger.info([' - keeping as non-style', key].join(' '))\n }\n prev = cur\n acc.push({\n type: 'attr',\n value: t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(\n typeof value === 'string' ? t.stringLiteral(value) : literalToAst(value)\n )\n ),\n })\n acc.push(cur)\n return acc\n }\n\n if (ensureOverridden[key]) {\n acc.push({\n type: 'attr',\n value:\n cur.attr ||\n t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(t.nullLiteral())),\n })\n }\n\n if (prev?.type === 'style') {\n mergeStyles(prev.value, cur.value)\n return acc\n }\n }\n\n prev = cur\n acc.push(cur)\n return acc\n }, [])\n\n if (shouldPrintDebug) {\n logger.info(\n [' - attrs (combined \uD83D\uDD00): \\n', logLines(attrs.map(attrStr).join(', '))].join(' ')\n )\n logger.info(\n [' - defaultProps: \\n', logLines(objToStr(staticConfig.defaultProps))].join(' ')\n )\n // prettier-ignore\n logger.info([' - foundStaticProps: \\n', logLines(objToStr(foundStaticProps))].join(' '))\n logger.info([' - completeProps: \\n', logLines(objToStr(completeProps))].join(' '))\n }\n\n // post process\n const getStyles = (props: Object | null, debugName = '') => {\n if (!props || !Object.keys(props).length) {\n if (shouldPrintDebug) logger.info([' getStyles() no props'].join(' '))\n return {}\n }\n if (excludeProps && !!excludeProps.size) {\n for (const key in props) {\n if (excludeProps.has(key)) {\n if (shouldPrintDebug) logger.info([' delete excluded', key].join(' '))\n delete props[key]\n }\n }\n }\n try {\n const out = getSplitStyles(\n props,\n staticConfig,\n defaultTheme,\n {\n ...state,\n fallbackProps: completeProps,\n },\n undefined,\n undefined,\n undefined,\n debugPropValue\n )\n\n const outStyle = {\n ...out.style,\n ...out.pseudos,\n }\n // omitInvalidStyles(outStyle)\n // if (shouldPrintDebug) {\n // // prettier-ignore\n // logger.info(` getStyles ${debugName} (props):\\n`, logLines(objToStr(props)))\n // // prettier-ignore\n // logger.info(` getStyles ${debugName} (out.viewProps):\\n`, logLines(objToStr(out.viewProps)))\n // // prettier-ignore\n // logger.info(` getStyles ${debugName} (out.style):\\n`, logLines(objToStr(outStyle || {}), true))\n // }\n return outStyle\n } catch (err: any) {\n logger.info(['error', err.message, err.stack].join(' '))\n return {}\n }\n }\n\n // used to ensure we pass the entire prop bundle to getStyles\n const completeStyles = getStyles(completeProps, 'completeStyles')\n\n if (!completeStyles) {\n throw new Error(`Impossible, no styles`)\n }\n\n const isNativeNotFlat = !shouldFlatten && target === 'native'\n if (isNativeNotFlat) {\n if (shouldPrintDebug) {\n logger.info(`Disabled flattening except for simple cases on native for now`)\n node.attributes = ogAttributes\n return null\n }\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, 'ternary.alternate')\n const c = getStyles(attr.value.consequent, 'ternary.consequent')\n if (a) attr.value.alternate = a\n if (c) attr.value.consequent = c\n if (shouldPrintDebug) logger.info([' => tern ', attrStr(attr)].join(' '))\n continue\n }\n case 'style': {\n // expand variants and such\n const styles = getStyles(attr.value, 'style')\n if (styles) {\n attr.value = styles\n }\n // prettier-ignore\n if (shouldPrintDebug) logger.info([' * styles (in)', logLines(objToStr(attr.value))].join(' '))\n // prettier-ignore\n if (shouldPrintDebug) logger.info([' * styles (out)', logLines(objToStr(styles))].join(' '))\n continue\n }\n }\n } catch (err) {\n // any error de-opt\n getStyleError = err\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n logger.info([' - attrs (ternaries/combined):\\n', logLines(attrs.map(attrStr).join(', '))].join(' '))\n }\n\n tm.mark('jsx-element-styles', !!shouldPrintDebug)\n\n if (getStyleError) {\n logger.info([' \u26A0\uFE0F postprocessing error, deopt', getStyleError].join(' '))\n node.attributes = ogAttributes\n return null\n }\n\n // final lazy extra loop:\n const existingStyleKeys = new Set()\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attr = attrs[i]\n\n // if flattening map inline props to proper flattened names\n if (shouldFlatten) {\n if (attr.type === 'attr') {\n if (t.isJSXAttribute(attr.value)) {\n if (t.isJSXIdentifier(attr.value.name)) {\n const name = attr.value.name.name\n if (INLINE_EXTRACTABLE[name]) {\n // map to HTML only name\n attr.value.name.name = INLINE_EXTRACTABLE[name]\n }\n }\n }\n }\n }\n\n // remove duplicate styles\n // so if you have:\n // style({ color: 'red' }), ...someProps, style({ color: 'green' })\n // this will mutate:\n // style({}), ...someProps, style({ color: 'green' })\n if (attr.type === 'style') {\n for (const key in attr.value) {\n if (existingStyleKeys.has(key)) {\n if (shouldPrintDebug) {\n logger.info([` >> delete existing ${key}`].join(' '))\n }\n delete attr.value[key]\n } else {\n existingStyleKeys.add(key)\n }\n }\n }\n }\n\n // inlineWhenUnflattened\n if (!shouldFlatten) {\n if (inlineWhenUnflattened.size) {\n for (const [index, attr] of attrs.entries()) {\n if (attr.type === 'style') {\n for (const key in attr.value) {\n if (!inlineWhenUnflattened.has(key)) continue\n const val = inlineWhenUnflattenedOGVals[key]\n if (val) {\n // delete the style\n delete attr.value[key]\n\n // and insert it before\n attrs.splice(index - 1, 0, val.attr)\n } else {\n // just delete it, it was added during expansion but should be left inline\n delete attr.value[key]\n }\n }\n }\n }\n }\n }\n\n if (shouldFlatten) {\n // DO FLATTEN\n if (shouldPrintDebug) {\n logger.info([' [\u2705] flattening', originalNodeName, flatNode].join(' '))\n }\n // @ts-ignore\n node.name.name = flatNode\n res.flattened++\n if (closingElement) {\n // @ts-ignore\n closingElement.name.name = flatNode\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n logger.info([` \u274A\u274A inline props (${inlined.size}):`, shouldDeopt ? ' deopted' : '', hasSpread ? ' has spread' : '', staticConfig.neverFlatten ? 'neverFlatten' : ''].join(' '))\n logger.info(` - attrs (end):\\n ${logLines(attrs.map(attrStr).join(', '))}`)\n }\n\n onExtractTag({\n parserProps: propsWithFileInfo,\n attrs,\n node,\n lineNumbers,\n filePath,\n attemptEval,\n jsxPath: traversePath,\n originalNodeName,\n isFlattened: shouldFlatten,\n programPath: programPath!,\n completeProps,\n staticConfig,\n })\n } finally {\n if (debugPropValue) {\n shouldPrintDebug = ogDebug\n }\n }\n },\n })\n\n tm.mark('jsx-done', !!shouldPrintDebug)\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 logger.info(` [\uD83E\uDE9D] hook check ${all.length}`)\n }\n for (const comp of all) {\n removeUnusedHooks(comp, shouldPrintDebug)\n }\n }\n\n tm.done(shouldPrintDebug === 'verbose')\n\n return res\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAyC;AAEzC,sBAAoD;AACpD,QAAmB;AACnB,uBASO;AAEP,wCAA+B;AAE/B,uBAA4B;AAW5B,6BAAqD;AACrD,6BAAgC;AAChC,4BAQO;AACP,iCAAoC;AACpC,2BAA8B;AAC9B,uCAA6D;AAC7D,0BAA6B;AAC7B,yBAKO;AACP,sBAAyB;AACzB,gCAAmC;AACnC,+BAAkC;AAClC,mBAAsB;AACtB,iCAAoC;AAEpC,MAAM,kBAAkB;AAAA,EACtB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AACb;AAEA,MAAM,qBAAqB;AAAA,EACzB,KAAK;AAAA,EACL,KAAK;AAAA,EACL,GAAI,QAAQ,IAAI,mBAAmB,SAAS;AAAA,IAC1C,SAAS;AAAA,IACT,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AACF;AAEA,MAAM,aAAa;AAAA,EACjB,UAAU;AAAA,EACV,UAAU;AACZ;AAEA,MAAM,SAAS,CAAC,MAA6C,EAAE,SAAS;AACxE,MAAM,gBAAgB,CAAC,MAAe;AAMtC,IAAI,oBAAoB;AAEjB,SAAS,gBAAgB,EAAE,SAAS,QAAQ,IAAsB,EAAE,QAAQ,QAAQ,GAAG;AAC5F,MAAI,CAAC,QAAQ,IAAI,gBAAgB;AAC/B,YAA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AAEjB,gBAAI,kBAAkB;AACpB,qBAAO,KAAK,CAAC,yBAAoB,kBAAkB,QAAQ,EAAE,KAAK,GAAG,CAAC;AAAA,YACxE;AAEA,iBAAK,KAAK,OAAO;AACjB,gBAAI;AACJ,gBAAI,gBAAgB;AAElB,6BAAe,KAAK,OAAO;AAAA,YAC7B;AAAA,UACF;AAEA,cAAI,kBAAkB;AAEpB,mBAAO,KAAK,CAAC,+BAAqB,QAAQ,UAAU,cAAc,aAAa,IAAI,YAAY,gBAAgB,IAAI,aAAa,eAAe,iBAAiB,EAAE,EAAE,KAAK,GAAG,CAAC;AAC7K,mBAAO,KAAK;AAAA,OAAsB,0BAAS,MAAM,IAAI,6BAAO,EAAE,KAAK,IAAI,CAAC,GAAG;AAAA,UAC7E;AAEA,uBAAa;AAAA,YACX,aAAa;AAAA,YACb;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAS;AAAA,YACT;AAAA,YACA,aAAa;AAAA,YACb;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAAA,QACH,UAAE;AACA,cAAI,gBAAgB;AAClB,+BAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,OAAG,KAAK,YAAY,CAAC,CAAC,gBAAgB;AAKtC,QAAI,mBAAmB,MAAM;AAC3B,YAAM,MAAM,MAAM,KAAK,kBAAkB;AACzC,UAAI,kBAAkB;AACpB,eAAO,KAAK,4BAAqB,IAAI,QAAQ;AAAA,MAC/C;AACA,iBAAW,QAAQ,KAAK;AACtB,wDAAkB,MAAM,gBAAgB;AAAA,MAC1C;AAAA,IACF;AAEA,OAAG,KAAK,qBAAqB,SAAS;AAEtC,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["projectInfo", "target", "traverse", "_a", "out", "evaluateAttribute", "isStaticObject", "createTernariesFromObjectProperties", "ternaries", "value", "splitVariants", "variants", "expandStylesWithoutVariants", "mergeStyles", "prev", "res", "key"]
|
|
7
7
|
}
|
|
@@ -104,7 +104,7 @@ Tamagui built config and components:`
|
|
|
104
104
|
})
|
|
105
105
|
]);
|
|
106
106
|
try {
|
|
107
|
-
(0, import_require.registerRequire)(
|
|
107
|
+
(0, import_require.registerRequire)();
|
|
108
108
|
const out = require(configOutPath);
|
|
109
109
|
const config = out.default || out;
|
|
110
110
|
if (!config) {
|
|
@@ -171,8 +171,9 @@ function loadTamaguiSync(props) {
|
|
|
171
171
|
}
|
|
172
172
|
const { unregister } = require("esbuild-register/dist/node").register(esbuildOptions);
|
|
173
173
|
try {
|
|
174
|
-
(0, import_require.registerRequire)(
|
|
174
|
+
(0, import_require.registerRequire)();
|
|
175
175
|
process.env.IS_STATIC = "is_static";
|
|
176
|
+
const devValueOG = globalThis["__DEV__"];
|
|
176
177
|
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
177
178
|
try {
|
|
178
179
|
let tamaguiConfig = null;
|
|
@@ -195,7 +196,7 @@ function loadTamaguiSync(props) {
|
|
|
195
196
|
console.log(`components`, components);
|
|
196
197
|
}
|
|
197
198
|
process.env.IS_STATIC = void 0;
|
|
198
|
-
|
|
199
|
+
globalThis["__DEV__"] = devValueOG;
|
|
199
200
|
if (props.config && tamaguiConfig) {
|
|
200
201
|
(0, import_core_node.createTamagui)(tamaguiConfig);
|
|
201
202
|
}
|
|
@@ -205,9 +206,6 @@ function loadTamaguiSync(props) {
|
|
|
205
206
|
nameToPaths: (0, import_require.getNameToPaths)()
|
|
206
207
|
};
|
|
207
208
|
} catch (err) {
|
|
208
|
-
if (props.bubbleErrors) {
|
|
209
|
-
throw err;
|
|
210
|
-
}
|
|
211
209
|
if (err instanceof Error) {
|
|
212
210
|
console.warn(
|
|
213
211
|
`Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`
|
|
@@ -230,11 +228,6 @@ function loadTamaguiSync(props) {
|
|
|
230
228
|
};
|
|
231
229
|
}
|
|
232
230
|
return cache[key];
|
|
233
|
-
} catch (err) {
|
|
234
|
-
if (!props.bubbleErrors) {
|
|
235
|
-
console.log("Error loading Tamagui", err);
|
|
236
|
-
}
|
|
237
|
-
throw err;
|
|
238
231
|
} finally {
|
|
239
232
|
unregister();
|
|
240
233
|
(0, import_require.unregisterRequire)();
|
|
@@ -383,9 +376,6 @@ writeTmp: `,
|
|
|
383
376
|
cacheComponents[key] = info;
|
|
384
377
|
return info;
|
|
385
378
|
} catch (err) {
|
|
386
|
-
if (props.bubbleErrors) {
|
|
387
|
-
throw err;
|
|
388
|
-
}
|
|
389
379
|
console.log(`Tamagui error bundling components`, err.message, err.stack);
|
|
390
380
|
return null;
|
|
391
381
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/extractor/loadTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { readFileSync } from 'fs'\n/* eslint-disable no-console */\nimport { basename, dirname, extname, join, relative, sep } from 'path'\n\nimport generate from '@babel/generator'\nimport traverse from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { Color, colorLog } from '@tamagui/cli-color'\nimport { getDefaultTamaguiConfig } from '@tamagui/config-default-node'\nimport type { StaticConfigParsed, TamaguiInternalConfig } from '@tamagui/core-node'\nimport { createTamagui } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\nimport { ensureDir, existsSync, removeSync, writeFileSync } from 'fs-extra'\n\nimport { SHOULD_DEBUG } from '../constants.js'\nimport { getNameToPaths, registerRequire, unregisterRequire } from '../require.js'\nimport { babelParse } from './babelParse'\nimport { bundle } from './bundle'\n\ntype NameToPaths = {\n [key: string]: Set<string>\n}\n\nexport type LoadedComponents = {\n moduleName: string\n nameToInfo: Record<\n string,\n {\n staticConfig: StaticConfigParsed\n }\n >\n}\n\nexport type TamaguiProjectInfo = {\n components: LoadedComponents[]\n tamaguiConfig: TamaguiInternalConfig\n nameToPaths: NameToPaths\n}\n\ntype Props = {\n components: string[]\n config?: string\n forceExports?: boolean\n bubbleErrors?: boolean\n}\n\nconst cache = {}\n\n// TODO needs a plugin for webpack / vite to run this once at startup and not again until changed...\n\nexport async function loadTamagui(props: Props): Promise<TamaguiProjectInfo> {\n const key = JSON.stringify(props)\n if (cache[key]) {\n if (cache[key] instanceof Promise) {\n return await cache[key]\n }\n return cache[key]\n }\n\n let resolver: Function = () => {}\n cache[key] = new Promise((res) => {\n resolver = res\n })\n\n const tmpDir = join(process.cwd(), '.tamagui', 'tamagui-node')\n const configOutPath = join(tmpDir, `tamagui.config.js`)\n const baseComponents = props.components.filter((x) => x !== '@tamagui/core')\n const componentOutPaths = baseComponents.map((componentModule) =>\n join(\n tmpDir,\n `${componentModule\n .split(sep)\n .join('-')\n .replace(/[^a-z0-9]+/gi, '')}-components.config.js`\n )\n )\n\n const external = ['@tamagui/core', '@tamagui/core-node', 'react', 'react-dom', 'react-native-svg']\n const configEntry = props.config ? join(process.cwd(), props.config) : ''\n\n if (process.env.NODE_ENV === 'development' && process.env.DEBUG?.startsWith('tamagui')) {\n console.log(`Building config entry`, configEntry)\n }\n\n // build them to node-compat versions\n try {\n await ensureDir(tmpDir)\n } catch {\n //\n }\n\n colorLog(\n Color.FgYellow,\n `\nTamagui built config and components:`\n )\n colorLog(\n Color.Dim,\n `\n - Config: .${sep}${relative(process.cwd(), configOutPath)}\n - Components: .${sep}${relative(process.cwd(), componentOutPaths.join(', '))}\n`\n )\n\n await Promise.all([\n props.config\n ? bundle({\n entryPoints: [configEntry],\n external,\n outfile: configOutPath,\n })\n : null,\n ...baseComponents.map((componentModule, i) => {\n return bundle({\n entryPoints: [componentModule],\n resolvePlatformSpecificEntries: true,\n external,\n outfile: componentOutPaths[i],\n })\n }),\n ])\n\n try {\n registerRequire(props.bubbleErrors)\n const out = require(configOutPath)\n const config = out.default || out\n\n if (!config) {\n throw new Error(`No config: ${config}`)\n }\n\n let components = loadComponents({\n ...props,\n components: componentOutPaths,\n })\n\n if (!components) {\n throw new Error(`No components found: ${componentOutPaths.join(', ')}`)\n }\n\n // map from built back to original module names\n for (const component of components) {\n component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)]\n if (!component.moduleName) {\n throw new Error(`Tamagui internal err`)\n }\n }\n\n // always load core so we can optimize if directly importing\n const coreComponents = loadComponents({\n ...props,\n components: ['@tamagui/core-node'],\n })\n if (coreComponents) {\n coreComponents[0].moduleName = '@tamagui/core'\n components = [...components, ...coreComponents]\n }\n\n if (process.env.NODE_ENV === 'development' && process.env.DEBUG?.startsWith('tamagui')) {\n console.log('Loaded components', components)\n }\n\n cache[key] = {\n components,\n nameToPaths: {},\n tamaguiConfig: config,\n }\n\n // init core-node\n createTamagui(cache[key].tamaguiConfig)\n\n resolver(cache[key])\n\n return cache[key]\n } finally {\n unregisterRequire()\n }\n}\n\nexport function resolveWebOrNativeSpecificEntry(entry: string) {\n const resolved = require.resolve(entry)\n const ext = extname(resolved)\n const fileName = basename(resolved).replace(ext, '')\n const specificExt = process.env.TAMAGUI_TARGET === 'web' ? 'web' : 'native'\n const specificFile = join(dirname(resolved), fileName + '.' + specificExt + ext)\n if (existsSync(specificFile)) {\n return specificFile\n }\n return entry\n}\n\nconst esbuildOptions = {\n loader: 'tsx',\n target: 'es2018',\n format: 'cjs',\n jsx: 'transform',\n platform: 'node',\n} as const\n\n// loads in-process using esbuild-register\nexport function loadTamaguiSync(props: Props): TamaguiProjectInfo {\n const key = JSON.stringify(props)\n if (cache[key]) {\n return cache[key]\n }\n\n const { unregister } = require('esbuild-register/dist/node').register(esbuildOptions)\n\n try {\n registerRequire(props.bubbleErrors)\n\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n globalThis['__DEV__' as any] = process.env.NODE_ENV === 'development'\n\n try {\n // config\n let tamaguiConfig: TamaguiInternalConfig | null = null\n if (props.config) {\n const configPath = join(process.cwd(), props.config)\n const exp = require(configPath)\n tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n const confPath = require.resolve(configPath)\n throw new Error(`Can't find valid config in ${confPath}:\n \n Be sure you \"export default\" the config.`)\n }\n }\n\n // components\n const components = loadComponents(props)\n if (!components) {\n throw new Error(`No components loaded`)\n }\n if (process.env.DEBUG === 'tamagui') {\n console.log(`components`, components)\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n delete globalThis['__DEV__' as any]\n\n // set up core-node\n if (props.config && tamaguiConfig) {\n createTamagui(tamaguiConfig as any)\n }\n\n cache[key] = {\n components,\n tamaguiConfig,\n nameToPaths: getNameToPaths(),\n }\n } catch (err) {\n if (props.bubbleErrors) {\n throw err\n }\n\n if (err instanceof Error) {\n console.warn(\n `Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`\n )\n console.log(`\\n\\n ${err.message}\\n\\n`)\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n } else {\n console.error(`Error loading tamagui.config.ts`, err)\n }\n return {\n components: [],\n tamaguiConfig: getDefaultTamaguiConfig(),\n nameToPaths: {},\n }\n }\n\n return cache[key]\n } catch (err) {\n if (!props.bubbleErrors) {\n console.log('Error loading Tamagui', err)\n }\n throw err\n } finally {\n unregister()\n unregisterRequire()\n }\n}\n\nfunction interopDefaultExport(mod: any) {\n return mod?.default ?? mod\n}\n\nconst cacheComponents: Record<string, LoadedComponents[]> = {}\n\nfunction transformAddExports(ast: t.File) {\n const usedNames = new Set<string>()\n\n // avoid clobbering\n traverse(ast, {\n ExportNamedDeclaration(nodePath) {\n if (nodePath.node.specifiers) {\n for (const spec of nodePath.node.specifiers) {\n usedNames.add(t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value)\n }\n }\n },\n })\n\n traverse(ast, {\n VariableDeclaration(nodePath) {\n // top level only\n if (!t.isProgram(nodePath.parent)) return\n const decs = nodePath.node.declarations\n if (decs.length > 1) return\n const [dec] = decs\n if (!t.isIdentifier(dec.id)) return\n if (!dec.init) return\n if (usedNames.has(dec.id.name)) return\n usedNames.add(dec.id.name)\n nodePath.replaceWith(\n t.exportNamedDeclaration(t.variableDeclaration('let', [dec]), [\n t.exportSpecifier(t.identifier(dec.id.name), t.identifier(dec.id.name)),\n ])\n )\n },\n })\n\n return generate(ast as any, {\n concise: false,\n filename: 'test.tsx',\n retainLines: false,\n sourceMaps: false,\n }).code\n}\n\nfunction loadComponents(props: Props): null | LoadedComponents[] {\n const componentsModules = props.components\n const key = componentsModules.join('')\n if (cacheComponents[key]) {\n return cacheComponents[key]\n }\n try {\n const info: LoadedComponents[] = componentsModules.flatMap((name) => {\n const extension = extname(name)\n const isLocal = Boolean(extension)\n // during props.config pass we are passing in pre-bundled stuff\n const writeTmp = isLocal && !props.config\n const fileContents = writeTmp ? readFileSync(name, 'utf-8') : ''\n const loadModule = writeTmp\n ? join(dirname(name), `.tamagui-dynamic-eval-${basename(name)}.tsx`)\n : name\n let writtenContents = fileContents\n let didBabel = false\n\n const esbuildit = (src: string, target?: 'modern') =>\n esbuild.transformSync(src, {\n ...esbuildOptions,\n ...(target === 'modern' && {\n target: 'es2022',\n jsx: 'transform',\n loader: 'tsx',\n platform: 'neutral',\n format: 'esm',\n }),\n }).code\n\n function attemptLoad({ forceExports = false } = {}) {\n // need to write to tsx to enable reading it properly (:/ esbuild-register)\n if (writeTmp) {\n writtenContents = forceExports\n ? esbuildit(transformAddExports(babelParse(esbuildit(fileContents, 'modern'))))\n : esbuildit(fileContents)\n\n writeFileSync(loadModule, writtenContents)\n }\n return {\n moduleName: name,\n nameToInfo: getComponentStaticConfigByName(\n name,\n interopDefaultExport(require(loadModule))\n ),\n }\n }\n\n const dispose = () => {\n writeTmp && removeSync(loadModule)\n }\n\n try {\n const res = attemptLoad({\n forceExports: true,\n })\n didBabel = true\n return res\n } catch (err) {\n console.log('babel err', err, writtenContents)\n // ok\n writtenContents = fileContents\n if (process.env.DEBUG?.startsWith('tamagui')) {\n console.log(`Error parsing babel likely`, err)\n }\n } finally {\n dispose()\n }\n\n try {\n return attemptLoad({\n forceExports: false,\n })\n } catch (err) {\n if (!process.env.TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD) {\n console.log(`\n\nTamagui attempted but failed to dynamically load components in:\n ${name}\n\nThis will leave some styled() tags unoptimized.\nDisable this file (or dynamic loading altogether):\n\n disableExtractFoundComponents: ['${name}'] | true\n\nQuiet this warning with environment variable:\n \n TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD=1\n\n`)\n console.log(err)\n console.log(\n `At: ${loadModule}`,\n `\\ndidBabel: ${didBabel}`,\n `\\nIn:`,\n writtenContents,\n `\\nwriteTmp: `,\n writeTmp\n )\n }\n return []\n } finally {\n dispose()\n }\n })\n cacheComponents[key] = info\n return info\n } catch (err: any) {\n if (props.bubbleErrors) {\n throw err\n }\n console.log(`Tamagui error bundling components`, err.message, err.stack)\n return null\n }\n}\n\nfunction getComponentStaticConfigByName(name: string, exported: any) {\n if (!exported || typeof exported !== 'object' || Array.isArray(exported)) {\n throw new Error(`Invalid export from package ${name}: ${typeof exported}`)\n }\n const components: Record<string, { staticConfig: StaticConfigParsed }> = {}\n try {\n for (const key in exported) {\n const found = getTamaguiComponent(key, exported[key])\n if (found) {\n // remove non-stringifyable\n const { Component, reactNativeWebComponent, ...sc } = found.staticConfig\n components[key] = { staticConfig: sc }\n }\n }\n } catch (err) {\n console.error(`Tamagui failed getting components`)\n if (err instanceof Error) {\n console.error(err.message, err.stack)\n } else {\n console.error(err)\n }\n }\n return components\n}\n\nfunction getTamaguiComponent(\n name: string,\n Component: any\n): undefined | { staticConfig: StaticConfigParsed } {\n if (name[0].toUpperCase() !== name[0]) {\n return\n }\n const staticConfig = Component?.staticConfig as StaticConfigParsed | undefined\n if (staticConfig) {\n return Component\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA6B;AAE7B,kBAAgE;AAEhE,uBAAqB;AACrB,sBAAqB;AACrB,QAAmB;AACnB,uBAAgC;AAChC,iCAAwC;AAExC,uBAA8B;AAC9B,qBAAoB;AACpB,sBAAiE;AAEjE,uBAA6B;AAC7B,qBAAmE;AACnE,wBAA2B;AAC3B,oBAAuB;
|
|
4
|
+
"sourcesContent": ["import { readFileSync } from 'fs'\n/* eslint-disable no-console */\nimport { basename, dirname, extname, join, relative, sep } from 'path'\n\nimport generate from '@babel/generator'\nimport traverse from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { Color, colorLog } from '@tamagui/cli-color'\nimport { getDefaultTamaguiConfig } from '@tamagui/config-default-node'\nimport type { StaticConfigParsed, TamaguiInternalConfig } from '@tamagui/core-node'\nimport { createTamagui } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\nimport { ensureDir, existsSync, removeSync, writeFileSync } from 'fs-extra'\n\nimport { SHOULD_DEBUG } from '../constants.js'\nimport { getNameToPaths, registerRequire, unregisterRequire } from '../require.js'\nimport { babelParse } from './babelParse'\nimport { bundle } from './bundle'\n\ntype NameToPaths = {\n [key: string]: Set<string>\n}\n\nexport type LoadedComponents = {\n moduleName: string\n nameToInfo: Record<\n string,\n {\n staticConfig: StaticConfigParsed\n }\n >\n}\n\nexport type TamaguiProjectInfo = {\n components: LoadedComponents[]\n tamaguiConfig: TamaguiInternalConfig\n nameToPaths: NameToPaths\n}\n\ntype Props = {\n components: string[]\n config?: string\n forceExports?: boolean\n}\n\nconst cache = {}\n\n// TODO needs a plugin for webpack / vite to run this once at startup and not again until changed...\n\nexport async function loadTamagui(props: Props): Promise<TamaguiProjectInfo> {\n const key = JSON.stringify(props)\n if (cache[key]) {\n if (cache[key] instanceof Promise) {\n return await cache[key]\n }\n return cache[key]\n }\n\n let resolver: Function = () => {}\n cache[key] = new Promise((res) => {\n resolver = res\n })\n\n const tmpDir = join(process.cwd(), '.tamagui', 'tamagui-node')\n const configOutPath = join(tmpDir, `tamagui.config.js`)\n const baseComponents = props.components.filter((x) => x !== '@tamagui/core')\n const componentOutPaths = baseComponents.map((componentModule) =>\n join(\n tmpDir,\n `${componentModule\n .split(sep)\n .join('-')\n .replace(/[^a-z0-9]+/gi, '')}-components.config.js`\n )\n )\n\n const external = ['@tamagui/core', '@tamagui/core-node', 'react', 'react-dom', 'react-native-svg']\n const configEntry = props.config ? join(process.cwd(), props.config) : ''\n\n if (process.env.NODE_ENV === 'development' && process.env.DEBUG?.startsWith('tamagui')) {\n console.log(`Building config entry`, configEntry)\n }\n\n // build them to node-compat versions\n try {\n await ensureDir(tmpDir)\n } catch {\n //\n }\n\n colorLog(\n Color.FgYellow,\n `\nTamagui built config and components:`\n )\n colorLog(\n Color.Dim,\n `\n - Config: .${sep}${relative(process.cwd(), configOutPath)}\n - Components: .${sep}${relative(process.cwd(), componentOutPaths.join(', '))}\n`\n )\n\n await Promise.all([\n props.config\n ? bundle({\n entryPoints: [configEntry],\n external,\n outfile: configOutPath,\n })\n : null,\n ...baseComponents.map((componentModule, i) => {\n return bundle({\n entryPoints: [componentModule],\n resolvePlatformSpecificEntries: true,\n external,\n outfile: componentOutPaths[i],\n })\n }),\n ])\n\n try {\n registerRequire()\n const out = require(configOutPath)\n const config = out.default || out\n\n if (!config) {\n throw new Error(`No config: ${config}`)\n }\n\n let components = loadComponents({\n ...props,\n components: componentOutPaths,\n })\n\n if (!components) {\n throw new Error(`No components found: ${componentOutPaths.join(', ')}`)\n }\n\n // map from built back to original module names\n for (const component of components) {\n component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)]\n if (!component.moduleName) {\n throw new Error(`Tamagui internal err`)\n }\n }\n\n // always load core so we can optimize if directly importing\n const coreComponents = loadComponents({\n ...props,\n components: ['@tamagui/core-node'],\n })\n if (coreComponents) {\n coreComponents[0].moduleName = '@tamagui/core'\n components = [...components, ...coreComponents]\n }\n\n if (process.env.NODE_ENV === 'development' && process.env.DEBUG?.startsWith('tamagui')) {\n console.log('Loaded components', components)\n }\n\n cache[key] = {\n components,\n nameToPaths: {},\n tamaguiConfig: config,\n }\n\n // init core-node\n createTamagui(cache[key].tamaguiConfig)\n\n resolver(cache[key])\n\n return cache[key]\n } finally {\n unregisterRequire()\n }\n}\n\nexport function resolveWebOrNativeSpecificEntry(entry: string) {\n const resolved = require.resolve(entry)\n const ext = extname(resolved)\n const fileName = basename(resolved).replace(ext, '')\n const specificExt = process.env.TAMAGUI_TARGET === 'web' ? 'web' : 'native'\n const specificFile = join(dirname(resolved), fileName + '.' + specificExt + ext)\n if (existsSync(specificFile)) {\n return specificFile\n }\n return entry\n}\n\nconst esbuildOptions = {\n loader: 'tsx',\n target: 'es2018',\n format: 'cjs',\n jsx: 'transform',\n platform: 'node',\n} as const\n\n// loads in-process using esbuild-register\nexport function loadTamaguiSync(props: Props): TamaguiProjectInfo {\n const key = JSON.stringify(props)\n if (cache[key]) {\n return cache[key]\n }\n\n const { unregister } = require('esbuild-register/dist/node').register(esbuildOptions)\n\n try {\n registerRequire()\n\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n const devValueOG = globalThis['__DEV__' as any]\n globalThis['__DEV__' as any] = process.env.NODE_ENV === 'development'\n\n try {\n // config\n let tamaguiConfig: TamaguiInternalConfig | null = null\n if (props.config) {\n const configPath = join(process.cwd(), props.config)\n const exp = require(configPath)\n tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n const confPath = require.resolve(configPath)\n throw new Error(`Can't find valid config in ${confPath}:\n \n Be sure you \"export default\" the config.`)\n }\n }\n\n // components\n const components = loadComponents(props)\n if (!components) {\n throw new Error(`No components loaded`)\n }\n if (process.env.DEBUG === 'tamagui') {\n console.log(`components`, components)\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n globalThis['__DEV__' as any] = devValueOG\n\n // set up core-node\n if (props.config && tamaguiConfig) {\n createTamagui(tamaguiConfig as any)\n }\n\n cache[key] = {\n components,\n tamaguiConfig,\n nameToPaths: getNameToPaths(),\n }\n } catch (err) {\n if (err instanceof Error) {\n console.warn(\n `Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`\n )\n console.log(`\\n\\n ${err.message}\\n\\n`)\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n } else {\n console.error(`Error loading tamagui.config.ts`, err)\n }\n return {\n components: [],\n tamaguiConfig: getDefaultTamaguiConfig(),\n nameToPaths: {},\n }\n }\n\n return cache[key]\n } finally {\n unregister()\n unregisterRequire()\n }\n}\n\nfunction interopDefaultExport(mod: any) {\n return mod?.default ?? mod\n}\n\nconst cacheComponents: Record<string, LoadedComponents[]> = {}\n\nfunction transformAddExports(ast: t.File) {\n const usedNames = new Set<string>()\n\n // avoid clobbering\n traverse(ast, {\n ExportNamedDeclaration(nodePath) {\n if (nodePath.node.specifiers) {\n for (const spec of nodePath.node.specifiers) {\n usedNames.add(t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value)\n }\n }\n },\n })\n\n traverse(ast, {\n VariableDeclaration(nodePath) {\n // top level only\n if (!t.isProgram(nodePath.parent)) return\n const decs = nodePath.node.declarations\n if (decs.length > 1) return\n const [dec] = decs\n if (!t.isIdentifier(dec.id)) return\n if (!dec.init) return\n if (usedNames.has(dec.id.name)) return\n usedNames.add(dec.id.name)\n nodePath.replaceWith(\n t.exportNamedDeclaration(t.variableDeclaration('let', [dec]), [\n t.exportSpecifier(t.identifier(dec.id.name), t.identifier(dec.id.name)),\n ])\n )\n },\n })\n\n return generate(ast as any, {\n concise: false,\n filename: 'test.tsx',\n retainLines: false,\n sourceMaps: false,\n }).code\n}\n\nfunction loadComponents(props: Props): null | LoadedComponents[] {\n const componentsModules = props.components\n const key = componentsModules.join('')\n if (cacheComponents[key]) {\n return cacheComponents[key]\n }\n try {\n const info: LoadedComponents[] = componentsModules.flatMap((name) => {\n const extension = extname(name)\n const isLocal = Boolean(extension)\n // during props.config pass we are passing in pre-bundled stuff\n const writeTmp = isLocal && !props.config\n const fileContents = writeTmp ? readFileSync(name, 'utf-8') : ''\n const loadModule = writeTmp\n ? join(dirname(name), `.tamagui-dynamic-eval-${basename(name)}.tsx`)\n : name\n let writtenContents = fileContents\n let didBabel = false\n\n const esbuildit = (src: string, target?: 'modern') =>\n esbuild.transformSync(src, {\n ...esbuildOptions,\n ...(target === 'modern' && {\n target: 'es2022',\n jsx: 'transform',\n loader: 'tsx',\n platform: 'neutral',\n format: 'esm',\n }),\n }).code\n\n function attemptLoad({ forceExports = false } = {}) {\n // need to write to tsx to enable reading it properly (:/ esbuild-register)\n if (writeTmp) {\n writtenContents = forceExports\n ? esbuildit(transformAddExports(babelParse(esbuildit(fileContents, 'modern'))))\n : esbuildit(fileContents)\n\n writeFileSync(loadModule, writtenContents)\n }\n return {\n moduleName: name,\n nameToInfo: getComponentStaticConfigByName(\n name,\n interopDefaultExport(require(loadModule))\n ),\n }\n }\n\n const dispose = () => {\n writeTmp && removeSync(loadModule)\n }\n\n try {\n const res = attemptLoad({\n forceExports: true,\n })\n didBabel = true\n return res\n } catch (err) {\n console.log('babel err', err, writtenContents)\n // ok\n writtenContents = fileContents\n if (process.env.DEBUG?.startsWith('tamagui')) {\n console.log(`Error parsing babel likely`, err)\n }\n } finally {\n dispose()\n }\n\n try {\n return attemptLoad({\n forceExports: false,\n })\n } catch (err) {\n if (!process.env.TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD) {\n console.log(`\n\nTamagui attempted but failed to dynamically load components in:\n ${name}\n\nThis will leave some styled() tags unoptimized.\nDisable this file (or dynamic loading altogether):\n\n disableExtractFoundComponents: ['${name}'] | true\n\nQuiet this warning with environment variable:\n \n TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD=1\n\n`)\n console.log(err)\n console.log(\n `At: ${loadModule}`,\n `\\ndidBabel: ${didBabel}`,\n `\\nIn:`,\n writtenContents,\n `\\nwriteTmp: `,\n writeTmp\n )\n }\n return []\n } finally {\n dispose()\n }\n })\n cacheComponents[key] = info\n return info\n } catch (err: any) {\n console.log(`Tamagui error bundling components`, err.message, err.stack)\n return null\n }\n}\n\nfunction getComponentStaticConfigByName(name: string, exported: any) {\n if (!exported || typeof exported !== 'object' || Array.isArray(exported)) {\n throw new Error(`Invalid export from package ${name}: ${typeof exported}`)\n }\n const components: Record<string, { staticConfig: StaticConfigParsed }> = {}\n try {\n for (const key in exported) {\n const found = getTamaguiComponent(key, exported[key])\n if (found) {\n // remove non-stringifyable\n const { Component, reactNativeWebComponent, ...sc } = found.staticConfig\n components[key] = { staticConfig: sc }\n }\n }\n } catch (err) {\n console.error(`Tamagui failed getting components`)\n if (err instanceof Error) {\n console.error(err.message, err.stack)\n } else {\n console.error(err)\n }\n }\n return components\n}\n\nfunction getTamaguiComponent(\n name: string,\n Component: any\n): undefined | { staticConfig: StaticConfigParsed } {\n if (name[0].toUpperCase() !== name[0]) {\n return\n }\n const staticConfig = Component?.staticConfig as StaticConfigParsed | undefined\n if (staticConfig) {\n return Component\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA6B;AAE7B,kBAAgE;AAEhE,uBAAqB;AACrB,sBAAqB;AACrB,QAAmB;AACnB,uBAAgC;AAChC,iCAAwC;AAExC,uBAA8B;AAC9B,qBAAoB;AACpB,sBAAiE;AAEjE,uBAA6B;AAC7B,qBAAmE;AACnE,wBAA2B;AAC3B,oBAAuB;AA4BvB,MAAM,QAAQ,CAAC;AAIf,eAAsB,YAAY,OAA2C;AAjD7E;AAkDE,QAAM,MAAM,KAAK,UAAU,KAAK;AAChC,MAAI,MAAM,MAAM;AACd,QAAI,MAAM,gBAAgB,SAAS;AACjC,aAAO,MAAM,MAAM;AAAA,IACrB;AACA,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,WAAqB,MAAM;AAAA,EAAC;AAChC,QAAM,OAAO,IAAI,QAAQ,CAAC,QAAQ;AAChC,eAAW;AAAA,EACb,CAAC;AAED,QAAM,aAAS,kBA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AO,aAAa,YAAY,MAAM,QAAQ,QAAQ,GAAG;AACxE,UAAM,IAAI,MAAM,+BAA+B,SAAS,OAAO,UAAU;AAAA,EAC3E;AACA,QAAM,aAAmE,CAAC;AAC1E,MAAI;AACF,eAAW,OAAO,UAAU;AAC1B,YAAM,QAAQ,oBAAoB,KAAK,SAAS,IAAI;AACpD,UAAI,OAAO;AAET,cAAM,EAAE,WAAW,4BAA4B,GAAG,IAAI,MAAM;AAC5D,mBAAW,OAAO,EAAE,cAAc,GAAG;AAAA,MACvC;AAAA,IACF;AAAA,EACF,SAAS,KAAP;AACA,YAAQ,MAAM,mCAAmC;AACjD,QAAI,eAAe,OAAO;AACxB,cAAQ,MAAM,IAAI,SAAS,IAAI,KAAK;AAAA,IACtC,OAAO;AACL,cAAQ,MAAM,GAAG;AAAA,IACnB;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,oBACP,MACA,WACkD;AAClD,MAAI,KAAK,GAAG,YAAY,MAAM,KAAK,IAAI;AACrC;AAAA,EACF;AACA,QAAM,eAAe,uCAAW;AAChC,MAAI,cAAc;AAChB,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["traverse", "generate", "esbuild"]
|
|
7
7
|
}
|
package/dist/require.js
CHANGED
|
@@ -30,11 +30,7 @@ const Module = require("module");
|
|
|
30
30
|
const og = Module.prototype.require;
|
|
31
31
|
globalThis["ogRequire"] = og;
|
|
32
32
|
const getNameToPaths = () => nameToPaths;
|
|
33
|
-
|
|
34
|
-
setInterval(() => {
|
|
35
|
-
tries = 0;
|
|
36
|
-
}, 50);
|
|
37
|
-
function registerRequire(bubbleErrors) {
|
|
33
|
+
function registerRequire() {
|
|
38
34
|
if (Module.prototype.require !== globalThis["ogRequire"]) {
|
|
39
35
|
console.warn("didnt unregister before re-registering");
|
|
40
36
|
process.exit(1);
|
|
@@ -43,6 +39,7 @@ function registerRequire(bubbleErrors) {
|
|
|
43
39
|
const rnw = require("react-native-web");
|
|
44
40
|
const core = require("@tamagui/core-node");
|
|
45
41
|
Module.prototype.require = function(path) {
|
|
42
|
+
var _a;
|
|
46
43
|
if (import_constants.SHOULD_DEBUG) {
|
|
47
44
|
console.log("tamagui:require", path);
|
|
48
45
|
}
|
|
@@ -62,29 +59,21 @@ function registerRequire(bubbleErrors) {
|
|
|
62
59
|
const out = og.apply(this, arguments);
|
|
63
60
|
return out;
|
|
64
61
|
} catch (err) {
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`
|
|
79
|
-
);
|
|
80
|
-
const max = process.env.TAMAGUI_MAX_ERRORS ? +process.env.TAMAGUI_MAX_ERRORS : 50;
|
|
81
|
-
if (++tries > max) {
|
|
82
|
-
console.log(
|
|
83
|
-
`Too many errors loading design system, exiting (set TAMAGUI_MAX_ERRORS to override)..`
|
|
62
|
+
if ((_a = process.env.DEBUG) == null ? void 0 : _a.startsWith("tamagui")) {
|
|
63
|
+
console.error(
|
|
64
|
+
`Tamagui failed loading the pre-built tamagui.config.ts
|
|
65
|
+
|
|
66
|
+
${err.message}
|
|
67
|
+
${err.stack}
|
|
68
|
+
|
|
69
|
+
You can see if it loads in the node repl:
|
|
70
|
+
|
|
71
|
+
require("./${(0, import_path.relative)(process.cwd(), path)}").default
|
|
72
|
+
|
|
73
|
+
`
|
|
84
74
|
);
|
|
85
|
-
process.exit(1);
|
|
86
75
|
}
|
|
87
|
-
return
|
|
76
|
+
return proxyWorm;
|
|
88
77
|
}
|
|
89
78
|
};
|
|
90
79
|
return Module.prototype.require;
|
package/dist/require.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/require.ts"],
|
|
4
|
-
"sourcesContent": ["import { relative, sep } from 'path'\n\nimport { SHOULD_DEBUG } from './constants.js'\n\nconst nameToPaths = {}\nconst Module = require('module')\nconst og = Module.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA8B;AAE9B,uBAA6B;AAE7B,MAAM,cAAc,CAAC;AACrB,MAAM,SAAS,QAAQ,QAAQ;AAC/B,MAAM,KAAK,OAAO,UAAU;AAC5B,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;
|
|
4
|
+
"sourcesContent": ["import { relative, sep } from 'path'\n\nimport { SHOULD_DEBUG } from './constants.js'\n\nconst nameToPaths = {}\nconst Module = require('module')\nconst og = Module.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nexport function registerRequire() {\n if (Module.prototype.require !== globalThis['ogRequire']) {\n // eslint-disable-next-line no-console\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n // TODO can swap with react-native-web-lite\n const rnw = require('react-native-web')\n const core = require('@tamagui/core-node')\n\n Module.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n // eslint-disable-next-line no-console\n console.log('tamagui:require', path)\n }\n if (/\\.(gif|jpe?g|png|svg|ttf|otf|woff2?|bmp|webp)$/.test(path)) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient' ||\n path === '@expo/vector-icons'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports'.replace(/\\//g, sep))\n ) {\n return rnw\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\n // only for studio disable for now\n // if (!nameToPaths[path]) {\n // if (out && typeof out === 'object') {\n // for (const key in out) {\n // try {\n // const conf = out[key]?.staticConfig as StaticConfig\n // if (conf) {\n // if (conf.componentName) {\n // nameToPaths[conf.componentName] ??= new Set()\n // const fullName = path.startsWith('.')\n // ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n // : path\n // nameToPaths[conf.componentName].add(fullName)\n // } else {\n // // console.log('no name component', path)\n // }\n // }\n // } catch {\n // // ok\n // }\n // }\n // }\n // }\n return out\n } catch (err: any) {\n /**\n * Allow errors to happen, we're just reading config and components but sometimes external modules cause problems\n * We can't fix every problem, so just swap them out with proxyWorm which is a sort of generic object that can be read.\n */\n\n if (process.env.DEBUG?.startsWith('tamagui')) {\n // eslint-disable-next-line no-console\n console.error(\n `Tamagui failed loading the pre-built tamagui.config.ts\n \n ${err.message}\n ${err.stack}\n \n You can see if it loads in the node repl:\n \n require(\"./${relative(process.cwd(), path)}\").default\n \n `\n )\n }\n\n return proxyWorm\n }\n }\n\n return Module.prototype.require\n}\n\nexport function unregisterRequire() {\n Module.prototype.require = og\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA8B;AAE9B,uBAA6B;AAE7B,MAAM,cAAc,CAAC;AACrB,MAAM,SAAS,QAAQ,QAAQ;AAC/B,MAAM,KAAK,OAAO,UAAU;AAC5B,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAE7B,SAAS,kBAAkB;AAChC,MAAI,OAAO,UAAU,YAAY,WAAW,cAAc;AAExD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAE/C,QAAM,MAAM,QAAQ,kBAAkB;AACtC,QAAM,OAAO,QAAQ,oBAAoB;AAEzC,SAAO,UAAU,UAAU,SAAU,MAAc;AAvBrD;AAwBI,QAAI,+BAAc;AAEhB,cAAQ,IAAI,mBAAmB,IAAI;AAAA,IACrC;AACA,QAAI,iDAAiD,KAAK,IAAI,GAAG;AAC/D,aAAO,CAAC;AAAA,IACV;AACA,QACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,0BACT,SAAS,sBACT;AACA,aAAO;AAAA,IACT;AACA,QACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,oCAAoC,QAAQ,OAAO,eAAG,CAAC,GACxE;AACA,aAAO;AAAA,IACT;AACA,QAAI,SAAS,iBAAiB;AAC5B,aAAO;AAAA,IACT;AACA,QAAI;AACF,YAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AAwBpC,aAAO;AAAA,IACT,SAAS,KAAP;AAMA,WAAI,aAAQ,IAAI,UAAZ,mBAAmB,WAAW,YAAY;AAE5C,gBAAQ;AAAA,UACN;AAAA;AAAA,IAEN,IAAI;AAAA,IACJ,IAAI;AAAA;AAAA;AAAA;AAAA,qBAIS,sBAAS,QAAQ,IAAI,GAAG,IAAI;AAAA;AAAA;AAAA,QAGrC;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,OAAO,UAAU;AAC1B;AAEO,SAAS,oBAAoB;AAClC,SAAO,UAAU,UAAU;AAC7B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.197",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist",
|
|
@@ -36,17 +36,15 @@
|
|
|
36
36
|
"@babel/runtime": "^7.18.9",
|
|
37
37
|
"@babel/traverse": "^7.18.11",
|
|
38
38
|
"@expo/match-media": "^0.3.0",
|
|
39
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
40
|
-
"@tamagui/cli-color": "^1.0.1-beta.
|
|
41
|
-
"@tamagui/config-default-node": "^1.0.1-beta.
|
|
42
|
-
"@tamagui/core-node": "^1.0.1-beta.
|
|
43
|
-
"@tamagui/fake-react-native": "^1.0.1-beta.
|
|
44
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
45
|
-
"@tamagui/helpers-node": "^1.0.1-beta.
|
|
46
|
-
"@tamagui/proxy-worm": "^1.0.1-beta.
|
|
47
|
-
"@tamagui/
|
|
48
|
-
"@tamagui/rnw": "^1.0.1-beta.195",
|
|
49
|
-
"@tamagui/shorthands": "^1.0.1-beta.195",
|
|
39
|
+
"@tamagui/build": "^1.0.1-beta.197",
|
|
40
|
+
"@tamagui/cli-color": "^1.0.1-beta.197",
|
|
41
|
+
"@tamagui/config-default-node": "^1.0.1-beta.197",
|
|
42
|
+
"@tamagui/core-node": "^1.0.1-beta.197",
|
|
43
|
+
"@tamagui/fake-react-native": "^1.0.1-beta.197",
|
|
44
|
+
"@tamagui/helpers": "^1.0.1-beta.197",
|
|
45
|
+
"@tamagui/helpers-node": "^1.0.1-beta.197",
|
|
46
|
+
"@tamagui/proxy-worm": "^1.0.1-beta.197",
|
|
47
|
+
"@tamagui/shorthands": "^1.0.1-beta.197",
|
|
50
48
|
"babel-literal-to-ast": "^2.1.0",
|
|
51
49
|
"esbuild": "^0.15.11",
|
|
52
50
|
"esbuild-register": "^3.3.3",
|
|
@@ -55,14 +53,14 @@
|
|
|
55
53
|
"fs-extra": "^10.1.0",
|
|
56
54
|
"invariant": "^2.2.4",
|
|
57
55
|
"lodash": "^4.17.21",
|
|
58
|
-
"react-native-web-
|
|
59
|
-
"
|
|
56
|
+
"react-native-web-internals": "^1.0.1-beta.197",
|
|
57
|
+
"react-native-web-lite": "^1.0.1-beta.197"
|
|
60
58
|
},
|
|
61
59
|
"devDependencies": {
|
|
62
60
|
"@babel/plugin-syntax-typescript": "^7.18.6",
|
|
63
61
|
"@babel/types": "^7.19.4",
|
|
64
62
|
"@dish/babel-preset": "^0.0.6",
|
|
65
|
-
"@tamagui/test-design-system": "^1.0.1-beta.
|
|
63
|
+
"@tamagui/test-design-system": "^1.0.1-beta.197",
|
|
66
64
|
"@testing-library/react": "^13.3.0",
|
|
67
65
|
"@types/babel__generator": "^7.6.4",
|
|
68
66
|
"@types/babel__traverse": "^7.18.2",
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
proxyThemeVariables,
|
|
14
14
|
pseudoDescriptors,
|
|
15
15
|
} from '@tamagui/core-node'
|
|
16
|
-
import { createDOMProps } from '@tamagui/rnw'
|
|
17
16
|
import type { ViewStyle } from 'react-native'
|
|
17
|
+
import { createDOMProps } from 'react-native-web-internals'
|
|
18
18
|
|
|
19
19
|
import { FAILED_EVAL } from '../constants.js'
|
|
20
20
|
import type {
|
|
@@ -418,9 +418,7 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
const out = loadTamaguiSync({
|
|
421
|
-
// TODO would extract more, is NO-OP for now..
|
|
422
421
|
forceExports: true,
|
|
423
|
-
bubbleErrors: true,
|
|
424
422
|
components: [sourcePath],
|
|
425
423
|
})
|
|
426
424
|
|
|
@@ -41,7 +41,6 @@ type Props = {
|
|
|
41
41
|
components: string[]
|
|
42
42
|
config?: string
|
|
43
43
|
forceExports?: boolean
|
|
44
|
-
bubbleErrors?: boolean
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
const cache = {}
|
|
@@ -121,7 +120,7 @@ Tamagui built config and components:`
|
|
|
121
120
|
])
|
|
122
121
|
|
|
123
122
|
try {
|
|
124
|
-
registerRequire(
|
|
123
|
+
registerRequire()
|
|
125
124
|
const out = require(configOutPath)
|
|
126
125
|
const config = out.default || out
|
|
127
126
|
|
|
@@ -207,11 +206,12 @@ export function loadTamaguiSync(props: Props): TamaguiProjectInfo {
|
|
|
207
206
|
const { unregister } = require('esbuild-register/dist/node').register(esbuildOptions)
|
|
208
207
|
|
|
209
208
|
try {
|
|
210
|
-
registerRequire(
|
|
209
|
+
registerRequire()
|
|
211
210
|
|
|
212
211
|
// lets shim require and avoid importing react-native + react-native-web
|
|
213
212
|
// we just need to read the config around them
|
|
214
213
|
process.env.IS_STATIC = 'is_static'
|
|
214
|
+
const devValueOG = globalThis['__DEV__' as any]
|
|
215
215
|
globalThis['__DEV__' as any] = process.env.NODE_ENV === 'development'
|
|
216
216
|
|
|
217
217
|
try {
|
|
@@ -240,7 +240,7 @@ export function loadTamaguiSync(props: Props): TamaguiProjectInfo {
|
|
|
240
240
|
|
|
241
241
|
// undo shims
|
|
242
242
|
process.env.IS_STATIC = undefined
|
|
243
|
-
|
|
243
|
+
globalThis['__DEV__' as any] = devValueOG
|
|
244
244
|
|
|
245
245
|
// set up core-node
|
|
246
246
|
if (props.config && tamaguiConfig) {
|
|
@@ -253,10 +253,6 @@ export function loadTamaguiSync(props: Props): TamaguiProjectInfo {
|
|
|
253
253
|
nameToPaths: getNameToPaths(),
|
|
254
254
|
}
|
|
255
255
|
} catch (err) {
|
|
256
|
-
if (props.bubbleErrors) {
|
|
257
|
-
throw err
|
|
258
|
-
}
|
|
259
|
-
|
|
260
256
|
if (err instanceof Error) {
|
|
261
257
|
console.warn(
|
|
262
258
|
`Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`
|
|
@@ -276,11 +272,6 @@ export function loadTamaguiSync(props: Props): TamaguiProjectInfo {
|
|
|
276
272
|
}
|
|
277
273
|
|
|
278
274
|
return cache[key]
|
|
279
|
-
} catch (err) {
|
|
280
|
-
if (!props.bubbleErrors) {
|
|
281
|
-
console.log('Error loading Tamagui', err)
|
|
282
|
-
}
|
|
283
|
-
throw err
|
|
284
275
|
} finally {
|
|
285
276
|
unregister()
|
|
286
277
|
unregisterRequire()
|
|
@@ -443,9 +434,6 @@ Quiet this warning with environment variable:
|
|
|
443
434
|
cacheComponents[key] = info
|
|
444
435
|
return info
|
|
445
436
|
} catch (err: any) {
|
|
446
|
-
if (props.bubbleErrors) {
|
|
447
|
-
throw err
|
|
448
|
-
}
|
|
449
437
|
console.log(`Tamagui error bundling components`, err.message, err.stack)
|
|
450
438
|
return null
|
|
451
439
|
}
|
package/src/require.ts
CHANGED
|
@@ -9,13 +9,7 @@ globalThis['ogRequire'] = og
|
|
|
9
9
|
|
|
10
10
|
export const getNameToPaths = () => nameToPaths
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
let tries = 0
|
|
14
|
-
setInterval(() => {
|
|
15
|
-
tries = 0
|
|
16
|
-
}, 50)
|
|
17
|
-
|
|
18
|
-
export function registerRequire(bubbleErrors?: boolean) {
|
|
12
|
+
export function registerRequire() {
|
|
19
13
|
if (Module.prototype.require !== globalThis['ogRequire']) {
|
|
20
14
|
// eslint-disable-next-line no-console
|
|
21
15
|
console.warn('didnt unregister before re-registering')
|
|
@@ -80,35 +74,28 @@ export function registerRequire(bubbleErrors?: boolean) {
|
|
|
80
74
|
// }
|
|
81
75
|
return out
|
|
82
76
|
} catch (err: any) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// eslint-disable-next-line no-console
|
|
88
|
-
console.error(
|
|
89
|
-
`Tamagui failed loading the pre-built tamagui.config.ts
|
|
90
|
-
|
|
91
|
-
${err.message}
|
|
92
|
-
${err.stack}
|
|
77
|
+
/**
|
|
78
|
+
* Allow errors to happen, we're just reading config and components but sometimes external modules cause problems
|
|
79
|
+
* We can't fix every problem, so just swap them out with proxyWorm which is a sort of generic object that can be read.
|
|
80
|
+
*/
|
|
93
81
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
require("./${relative(process.cwd(), path)}").default
|
|
97
|
-
|
|
98
|
-
`
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
const max = process.env.TAMAGUI_MAX_ERRORS ? +process.env.TAMAGUI_MAX_ERRORS : 50
|
|
102
|
-
if (++tries > max) {
|
|
82
|
+
if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
103
83
|
// eslint-disable-next-line no-console
|
|
104
|
-
console.
|
|
105
|
-
`
|
|
84
|
+
console.error(
|
|
85
|
+
`Tamagui failed loading the pre-built tamagui.config.ts
|
|
86
|
+
|
|
87
|
+
${err.message}
|
|
88
|
+
${err.stack}
|
|
89
|
+
|
|
90
|
+
You can see if it loads in the node repl:
|
|
91
|
+
|
|
92
|
+
require("./${relative(process.cwd(), path)}").default
|
|
93
|
+
|
|
94
|
+
`
|
|
106
95
|
)
|
|
107
|
-
// avoid infinite loops
|
|
108
|
-
process.exit(1)
|
|
109
96
|
}
|
|
110
97
|
|
|
111
|
-
return
|
|
98
|
+
return proxyWorm
|
|
112
99
|
}
|
|
113
100
|
}
|
|
114
101
|
|
|
@@ -17,7 +17,6 @@ declare type Props = {
|
|
|
17
17
|
components: string[];
|
|
18
18
|
config?: string;
|
|
19
19
|
forceExports?: boolean;
|
|
20
|
-
bubbleErrors?: boolean;
|
|
21
20
|
};
|
|
22
21
|
export declare function loadTamagui(props: Props): Promise<TamaguiProjectInfo>;
|
|
23
22
|
export declare function resolveWebOrNativeSpecificEntry(entry: string): string;
|
package/types/require.d.ts
CHANGED