@tamagui/static 1.0.1-beta.129 → 1.0.1-beta.132

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.
Files changed (33) hide show
  1. package/dist/cjs/extractor/createExtractor.js +8 -2
  2. package/dist/cjs/extractor/createExtractor.js.map +2 -2
  3. package/dist/cjs/extractor/extractToClassNames.js +18 -6
  4. package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
  5. package/dist/cjs/extractor/getStaticBindingsForScope.js +0 -3
  6. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +2 -2
  7. package/dist/cjs/require.js +6 -5
  8. package/dist/cjs/require.js.map +2 -2
  9. package/dist/cjs/types.js.map +1 -1
  10. package/dist/esm/extractor/createExtractor.js +8 -2
  11. package/dist/esm/extractor/createExtractor.js.map +2 -2
  12. package/dist/esm/extractor/extractToClassNames.js +18 -6
  13. package/dist/esm/extractor/extractToClassNames.js.map +2 -2
  14. package/dist/esm/extractor/getStaticBindingsForScope.js +0 -3
  15. package/dist/esm/extractor/getStaticBindingsForScope.js.map +2 -2
  16. package/dist/esm/require.js +6 -5
  17. package/dist/esm/require.js.map +2 -2
  18. package/dist/jsx/extractor/createExtractor.js +8 -2
  19. package/dist/jsx/extractor/createExtractor.js.map +2 -2
  20. package/dist/jsx/extractor/extractToClassNames.js +18 -6
  21. package/dist/jsx/extractor/extractToClassNames.js.map +2 -2
  22. package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -3
  23. package/dist/jsx/extractor/getStaticBindingsForScope.js.map +2 -2
  24. package/dist/jsx/require.js +6 -5
  25. package/dist/jsx/require.js.map +2 -2
  26. package/package.json +12 -20
  27. package/src/extractor/createExtractor.ts +9 -3
  28. package/src/extractor/extractToClassNames.ts +17 -5
  29. package/src/extractor/getStaticBindingsForScope.ts +0 -3
  30. package/src/require.ts +7 -5
  31. package/src/types.ts +3 -1
  32. package/types/require.d.ts +1 -1
  33. package/types/types.d.ts +3 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/extractor/extractToClassNames.ts"],
4
- "sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { ViewStyle } from 'react-native'\n\nimport { CONCAT_CLASSNAME_IMPORT } from '../constants'\nimport { ClassNameObject, StyleObject, TamaguiOptions, Ternary } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { getPrefixLogs } from './getPrefixLogs'\nimport { hoistClassNames } from './hoistClassNames'\nimport { logLines } from './logLines'\nimport { timer } from './timer'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport type ExtractedResponse = {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n}\n\nexport function extractToClassNames({\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n}: {\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean | 'verbose'\n}): ExtractedResponse | null {\n const tm = timer()\n\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n tm.mark(`babel-parse`, shouldPrintDebug === 'verbose')\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n let hasFlattened = false\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n target: 'html',\n extractStyledDefinitions: true,\n onStyleRule(identifier, rules) {\n cssMap.set(`.${identifier}`, { css: rules.join(';'), commentTexts: [] })\n },\n getFlattenedNode: ({ tag }) => {\n hasFlattened = true\n return tag\n },\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n isFlattened,\n }) => {\n // reset hasFlattened\n const didFlattenThisTag = hasFlattened\n hasFlattened = false\n\n let finalClassNames: ClassNameObject[] = []\n let finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n let viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n viewStyles = {\n ...viewStyles,\n ...attr.value,\n }\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null): StyleObject[] => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style':\n if (!isFlattened) {\n const styles = getStylesAtomic(attr.value)\n\n finalStyles = [...finalStyles, ...styles]\n\n for (const style of styles) {\n // leave them as attributes\n const prop = style.pseudo ? `${style.property}-${style.pseudo}` : style.property\n finalAttrs.push(\n t.jsxAttribute(t.jsxIdentifier(prop), t.stringLiteral(style.identifier))\n )\n }\n } else {\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n const existing = finalClassNames.find(\n (x) => x.type == 'StringLiteral'\n ) as t.StringLiteral | null\n\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n }\n\n break\n case 'attr':\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n case 'ternary':\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (shouldPrintDebug) {\n if (mediaExtraction) {\n // prettier-ignore\n console.log('ternary (mediaStyles)', mediaExtraction.ternaryWithoutMedia?.inlineMediaQuery ?? '', mediaExtraction.mediaStyles.map((x) => x.identifier).join('.'))\n }\n }\n if (!mediaExtraction) {\n addTernaryStyle(\n attr.value,\n addStyles(attr.value.consequent),\n addStyles(attr.value.alternate)\n )\n continue\n }\n lastMediaImportance++\n if (mediaExtraction.mediaStyles) {\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n }\n if (mediaExtraction.ternaryWithoutMedia) {\n addTernaryStyle(mediaExtraction.ternaryWithoutMedia, mediaExtraction.mediaStyles, [])\n } else {\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n }\n break\n }\n }\n\n function addTernaryStyle(ternary: Ternary, a: any, b: any) {\n const cCN = a.map((x) => x.identifier).join(' ')\n const aCN = b.map((x) => x.identifier).join(' ')\n if (a.length && b.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' finalClassNames\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n let names = buildClassName(finalClassNames)\n if (t.isStringLiteral(names)) {\n names.value = concatClassName(names.value)\n }\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n if (!didFlattenThisTag) {\n // not flat\n } else {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { identifier, rules } of finalStyles) {\n const className = `.${identifier}`\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened && !res.styled)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n // this makes the debug output terrible, and i think sourcemap works already\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const path = basename(sourcePath)\n .replace(/\\.[jt]sx?$/, '')\n .slice(0, 22)\n .trim()\n .padStart(24)\n\n const numStyled = `${res.styled}`.padStart(3)\n const numOptimized = `${res.optimized}`.padStart(3)\n const numFound = `${res.found}`.padStart(3)\n const numFlattened = `${res.flattened}`.padStart(3)\n const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : ''\n const timing = Date.now() - start\n const timingWarning = timing > 150 ? '\u26A0\uFE0F' : timing > 150 ? '\u2622\uFE0F' : ''\n const timingStr = `${timing}ms ${timingWarning}`.padStart(6)\n const pre = getPrefixLogs(options)\n const memStr = memory ? `(${memory})` : ''\n console.log(\n `${pre} ${path} ${numFound} \u00B7 ${numOptimized} \u00B7 ${numFlattened} \u00B7 ${numStyled} ${timingStr} ${memStr}`\n )\n }\n\n return {\n ast,\n styles,\n js: result.code,\n map: result.map,\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AACtB,kBAAyB;AACzB,WAAsB;AAEtB,uBAAqB;AACrB,QAAmB;AACnB,uBAAgC;AAChC,qBAAgC;AAChC,uBAAsB;AAGtB,uBAA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,MAAM,wCAAc,OAAO;AACjC,UAAM,SAAS,SAAS,IAAI,YAAY;AACxC,YAAQ,IACN,GAAG,OAAO,UAAS,iBAAc,qBAAkB,qBAAkB,cAAc,aAAa,QAClG;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,OAAO;AAAA,IACX,KAAK,OAAO;AAAA,EACd;AACF;",
4
+ "sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { ViewStyle } from 'react-native'\n\nimport { CONCAT_CLASSNAME_IMPORT } from '../constants'\nimport { ClassNameObject, StyleObject, TamaguiOptions, Ternary } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { getPrefixLogs } from './getPrefixLogs'\nimport { hoistClassNames } from './hoistClassNames'\nimport { logLines } from './logLines'\nimport { timer } from './timer'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport type ExtractedResponse = {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n}\n\nexport function extractToClassNames({\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n}: {\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean | 'verbose'\n}): ExtractedResponse | null {\n const tm = timer()\n\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n tm.mark(`babel-parse`, shouldPrintDebug === 'verbose')\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n let hasFlattened = false\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n target: 'html',\n extractStyledDefinitions: true,\n onStyleRule(identifier, rules) {\n cssMap.set(`.${identifier}`, { css: rules.join(';'), commentTexts: [] })\n },\n getFlattenedNode: ({ tag }) => {\n hasFlattened = true\n return tag\n },\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n isFlattened,\n completeProps,\n staticConfig,\n }) => {\n // reset hasFlattened\n const didFlattenThisTag = hasFlattened\n hasFlattened = false\n\n let finalClassNames: ClassNameObject[] = []\n const finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n let viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n viewStyles = {\n ...viewStyles,\n ...attr.value,\n }\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null): StyleObject[] => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style': {\n if (!isFlattened) {\n const styles = getStylesAtomic(attr.value)\n\n finalStyles = [...finalStyles, ...styles]\n\n for (const style of styles) {\n // leave them as attributes\n const prop = style.pseudo ? `${style.property}-${style.pseudo}` : style.property\n finalAttrs.push(\n t.jsxAttribute(t.jsxIdentifier(prop), t.stringLiteral(style.identifier))\n )\n }\n } else {\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n const existing = finalClassNames.find(\n (x) => x.type == 'StringLiteral'\n ) as t.StringLiteral | null\n\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n }\n\n break\n }\n case 'attr': {\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n }\n case 'ternary': {\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (shouldPrintDebug) {\n if (mediaExtraction) {\n // prettier-ignore\n console.log('ternary (mediaStyles)', mediaExtraction.ternaryWithoutMedia?.inlineMediaQuery ?? '', mediaExtraction.mediaStyles.map((x) => x.identifier).join('.'))\n }\n }\n if (!mediaExtraction) {\n addTernaryStyle(\n attr.value,\n addStyles(attr.value.consequent),\n addStyles(attr.value.alternate)\n )\n continue\n }\n lastMediaImportance++\n if (mediaExtraction.mediaStyles) {\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n }\n if (mediaExtraction.ternaryWithoutMedia) {\n addTernaryStyle(mediaExtraction.ternaryWithoutMedia, mediaExtraction.mediaStyles, [])\n } else {\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n }\n break\n }\n }\n }\n\n function addTernaryStyle(ternary: Ternary, a: any, b: any) {\n const cCN = a.map((x) => x.identifier).join(' ')\n const aCN = b.map((x) => x.identifier).join(' ')\n if (a.length && b.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' finalClassNames\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n const names = buildClassName(finalClassNames)\n if (t.isStringLiteral(names)) {\n names.value = concatClassName(names.value)\n if (staticConfig.isText) {\n let family = completeProps.fontFamily\n if (family[0] === '$') {\n family = family.slice(1)\n }\n names.value = `font_${family} ${names.value}`\n }\n }\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n if (!didFlattenThisTag) {\n // not flat\n } else {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { identifier, rules } of finalStyles) {\n const className = `.${identifier}`\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened && !res.styled)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n // this makes the debug output terrible, and i think sourcemap works already\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const path = basename(sourcePath)\n .replace(/\\.[jt]sx?$/, '')\n .slice(0, 22)\n .trim()\n .padStart(24)\n\n const numStyled = `${res.styled}`.padStart(3)\n const numOptimized = `${res.optimized}`.padStart(3)\n const numFound = `${res.found}`.padStart(3)\n const numFlattened = `${res.flattened}`.padStart(3)\n const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : ''\n const timing = Date.now() - start\n const timingWarning = timing > 150 ? '\u26A0\uFE0F' : timing > 150 ? '\u2622\uFE0F' : ''\n const timingStr = `${timing}ms ${timingWarning}`.padStart(6)\n const pre = getPrefixLogs(options)\n const memStr = memory ? `(${memory})` : ''\n console.log(\n `${pre} ${path} ${numFound} \u00B7 ${numOptimized} \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AAQ,EAAE,IAAI,KACnF;AACJ,UAAM,QAAO,0BAAS,UAAU,EAC7B,QAAQ,cAAc,EAAE,EACxB,MAAM,GAAG,EAAE,EACX,KAAK,EACL,SAAS,EAAE;AAEd,UAAM,YAAY,GAAG,IAAI,SAAS,SAAS,CAAC;AAC5C,UAAM,eAAe,GAAG,IAAI,YAAY,SAAS,CAAC;AAClD,UAAM,WAAW,GAAG,IAAI,QAAQ,SAAS,CAAC;AAC1C,UAAM,eAAe,GAAG,IAAI,YAAY,SAAS,CAAC;AAClD,UAAM,SAAS,QAAQ,IAAI,SAAS,UAAU,KAAK,IAAI,cAAc;AACrE,UAAM,SAAS,KAAK,IAAI,IAAI;AAC5B,UAAM,gBAAgB,SAAS,MAAM,iBAAO,SAAS,MAAM,iBAAO;AAClE,UAAM,YAAY,GAAG,YAAY,gBAAgB,SAAS,CAAC;AAC3D,UAAM,MAAM,wCAAc,OAAO;AACjC,UAAM,SAAS,SAAS,IAAI,YAAY;AACxC,YAAQ,IACN,GAAG,OAAO,UAAS,iBAAc,qBAAkB,qBAAkB,cAAc,aAAa,QAClG;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,OAAO;AAAA,IACX,KAAK,OAAO;AAAA,EACd;AACF;",
6
6
  "names": []
7
7
  }
@@ -111,9 +111,6 @@ async function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bind
111
111
  }
112
112
  }
113
113
  } catch (err) {
114
- if (moduleName.includes("@tamagui/select")) {
115
- continue;
116
- }
117
114
  console.warn(`\u26A0\uFE0F Failed evaluating module, continuing: ${moduleName}`);
118
115
  }
119
116
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/extractor/getStaticBindingsForScope.ts"],
4
- "sourcesContent": ["import { fork, spawn } from 'child_process'\nimport { dirname, extname, join, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport esbuild from 'esbuild'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nconst cache = new Map()\nconst pending = new Map<string, Promise<any>>()\nsetInterval(() => {\n if (cache.size) {\n cache.clear()\n }\n}, 10)\n\nconst loadCmd = `${join(__dirname, 'loadFile.js')}`\nconst child = fork(loadCmd, [], {\n execArgv: ['-r', 'esbuild-register'],\n})\n\nfunction importModule(path: string) {\n if (pending.has(path)) {\n return pending.get(path)\n }\n const promise = new Promise((res, rej) => {\n if (cache.has(path)) {\n return cache.get(path)\n }\n const listener = (msg: any) => {\n if (!msg) return\n if (typeof msg !== 'string') return\n if (msg[0] === '-') {\n rej(new Error(msg.slice(1)))\n return\n }\n child.removeListener('message', listener)\n const val = JSON.parse(msg)\n cache.set(path, val)\n res(val)\n }\n child.once('message', listener)\n child.send(`${path.replace('.js', '')}`)\n })\n pending.set(path, promise)\n return promise\n}\n\nexport async function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Promise<Record<string, any>> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n try {\n const src = await importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n } catch (err) {\n if (moduleName.includes('@tamagui/select')) {\n continue\n }\n console.warn(`\u26A0\uFE0F Failed evaluating module, continuing: ${moduleName}`)\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n ret[k] = src\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch {\n // skip\n }\n }\n\n return ret\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA4B;AAC5B,kBAAgD;AAGhD,QAAmB;AAInB,6BAAgC;AAChC,6BAAgC;AAEhC,MAAM,gBAAgB,CAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG;AAEnF,2BAA2B,YAAoB,MAAc;AAC3D,QAAM,YAAY,yBAAQ,UAAU;AACpC,MAAI,cAAc,IAAI,GAAG;AACvB,QAAI,yBAAQ,IAAI,MAAM,IAAI;AACxB,cAAQ;AAAA,IACV;AACA,WAAO,yBAAQ,WAAW,IAAI;AAAA,EAChC;AACA,SAAO;AACT;AAEA,MAAM,QAAQ,oBAAI,IAAI;AACtB,MAAM,UAAU,oBAAI,IAA0B;AAC9C,YAAY,MAAM;AAChB,MAAI,MAAM,MAAM;AACd,UAAM,MAAM;AAAA,EACd;AACF,GAAG,EAAE;AAEL,MAAM,UAAU,GAAG,sBAAK,WAAW,aAAa;AAChD,MAAM,QAAQ,+BAAK,SAAS,CAAC,GAAG;AAAA,EAC9B,UAAU,CAAC,MAAM,kBAAkB;AACrC,CAAC;AAED,sBAAsB,MAAc;AAClC,MAAI,QAAQ,IAAI,IAAI,GAAG;AACrB,WAAO,QAAQ,IAAI,IAAI;AAAA,EACzB;AACA,QAAM,UAAU,IAAI,QAAQ,CAAC,KAAK,QAAQ;AACxC,QAAI,MAAM,IA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AAI,CAAC,OAAO,CAAC,IAAI,MAAM;AACrB;AAAA,IACF;AAGA,QAAI,OAAO,IAAI,GAAG,UAAU,YAAY,OAAO,IAAI,GAAG,QAAQ,UAAU;AACtE,cAAQ,MAAM,kCAAkC;AAChD;AAAA,IACF;AAEA,QAAI,CAAC,EAAE,aAAa,IAAI,EAAE,GAAG;AAC3B,cAAQ,MAAM,0BAA0B;AACxC;AAAA,IACF;AAEA,UAAM,WAAW,GAAG,IAAI,GAAG,QAAQ,IAAI,GAAG,SAAS,IAAI,GAAG;AAG1D,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAEA,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAGA,QAAI;AACF,UAAI,KAAK,4CAAgB,IAAI,MAAM,QAAW,gBAAgB;AAC9D,mBAAa,YAAY,IAAI;AAC7B;AAAA,IACF,QAAE;AAAA,IAEF;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { fork, spawn } from 'child_process'\nimport { dirname, extname, join, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport esbuild from 'esbuild'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nconst cache = new Map()\nconst pending = new Map<string, Promise<any>>()\nsetInterval(() => {\n if (cache.size) {\n cache.clear()\n }\n}, 10)\n\nconst loadCmd = `${join(__dirname, 'loadFile.js')}`\nconst child = fork(loadCmd, [], {\n execArgv: ['-r', 'esbuild-register'],\n})\n\nfunction importModule(path: string) {\n if (pending.has(path)) {\n return pending.get(path)\n }\n const promise = new Promise((res, rej) => {\n if (cache.has(path)) {\n return cache.get(path)\n }\n const listener = (msg: any) => {\n if (!msg) return\n if (typeof msg !== 'string') return\n if (msg[0] === '-') {\n rej(new Error(msg.slice(1)))\n return\n }\n child.removeListener('message', listener)\n const val = JSON.parse(msg)\n cache.set(path, val)\n res(val)\n }\n child.once('message', listener)\n child.send(`${path.replace('.js', '')}`)\n })\n pending.set(path, promise)\n return promise\n}\n\nexport async function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Promise<Record<string, any>> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n try {\n const src = await importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n } catch (err) {\n console.warn(`\u26A0\uFE0F Failed evaluating module, continuing: ${moduleName}`)\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n ret[k] = src\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch {\n // skip\n }\n }\n\n return ret\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA4B;AAC5B,kBAAgD;AAGhD,QAAmB;AAInB,6BAAgC;AAChC,6BAAgC;AAEhC,M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,QAAW,gBAAgB;AAC9D,mBAAa,YAAY,IAAI;AAC7B;AAAA,IACF,QAAE;AAAA,IAEF;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -26,8 +26,8 @@ module.exports = __toCommonJS(require_exports);
26
26
  var import_path = require("path");
27
27
  var import_constants = require("./constants");
28
28
  const nameToPaths = {};
29
- const Mod = require("module");
30
- const og = Mod.prototype.require;
29
+ const Module = require("module");
30
+ const og = Module.prototype.require;
31
31
  globalThis["ogRequire"] = og;
32
32
  const getNameToPaths = () => nameToPaths;
33
33
  let tries = 0;
@@ -35,14 +35,14 @@ setInterval(() => {
35
35
  tries = 0;
36
36
  }, 50);
37
37
  function registerRequire() {
38
- if (Mod.prototype.require !== globalThis["ogRequire"]) {
38
+ if (Module.prototype.require !== globalThis["ogRequire"]) {
39
39
  console.warn("didnt unregister before re-registering");
40
40
  process.exit(1);
41
41
  }
42
42
  const proxyWorm = require("@tamagui/proxy-worm");
43
43
  const rnw = require("react-native-web");
44
44
  const core = require("@tamagui/core-node");
45
- Mod.prototype.require = function(path) {
45
+ Module.prototype.require = function(path) {
46
46
  var _a, _b;
47
47
  if (import_constants.SHOULD_DEBUG) {
48
48
  console.log("tamagui require", path);
@@ -93,9 +93,10 @@ function registerRequire() {
93
93
  return proxyWorm;
94
94
  }
95
95
  };
96
+ return Module.prototype.require;
96
97
  }
97
98
  function unregisterRequire() {
98
- Mod.prototype.require = og;
99
+ Module.prototype.require = og;
99
100
  }
100
101
  // Annotate the CommonJS export names for ESM import in node:
101
102
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/require.ts"],
4
- "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\n// just for catching egregious amounts of errors in a tight loop\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 50)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const core = require('@tamagui/core-node')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css') || path.endsWith('.json') || path.endsWith('.ttf')) {\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')\n ) {\n return rnw\n // return og('react-native-web')\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\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 if (SHOULD_DEBUG) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring\\n`,\n err.message,\n err.stack\n )\n }\n const max = process.env.TAMAGUI_MAX_ERRORS ? +process.env.TAMAGUI_MAX_ERRORS : 200\n if (++tries > max) {\n console.log(\n `Too many errors loading design system, exiting (set TAMAGUI_MAX_ERRORS to override)..`\n )\n // avoid infinite loops\n process.exit(1)\n }\n // return proxyWorm by default\n return proxyWorm\n }\n }\n}\n\n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BAAI,MAAM;AACR,oBAAI,KAAK,eAAe;AACtB,mCAAY,KAAK,kBAAjB,mBAAoC,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,sBAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,UAAI,+BAAc;AAChB,gBAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,SACJ,IAAI,KACN;AAAA,MACF;AACA,YAAM,MAAM,QAAQ,IAAI,qBAAqB,CAAC,QAAQ,IAAI,qBAAqB;AAC/E,UAAI,EAAE,QAAQ,KAAK;AACjB,gBAAQ,IACN,uFACF;AAEA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,6BAA6B;AAClC,MAAI,UAAU,UAAU;AAC1B;",
4
+ "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Module = require('module')\nconst og = Module.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\n// just for catching egregious amounts of errors in a tight loop\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 50)\n\nexport function registerRequire() {\n if (Module.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\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 console.log('tamagui require', path)\n }\n if (path.endsWith('.css') || path.endsWith('.json') || path.endsWith('.ttf')) {\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')\n ) {\n return rnw\n // return og('react-native-web')\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\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 if (SHOULD_DEBUG) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring\\n`,\n err.message,\n err.stack\n )\n }\n const max = process.env.TAMAGUI_MAX_ERRORS ? +process.env.TAMAGUI_MAX_ERRORS : 200\n if (++tries > max) {\n console.log(\n `Too many errors loading design system, exiting (set TAMAGUI_MAX_ERRORS to override)..`\n )\n // avoid infinite loops\n process.exit(1)\n }\n // return proxyWorm by default\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,kBAAqB;AAIrB,uBAA6B;AAE7B,MAAM,cAAc,CAAC;AACrB,MAAM,SAAS,QAAQ,QAAQ;AAC/B,MAAM,KAAK,OAAO,UAAU;AAC5B,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAGpC,IAAI,QAAQ;AACZ,YAAY,MAAM;A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AAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,UAAI,+BAAc;AAChB,gBAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,SACJ,IAAI,KACN;AAAA,MACF;AACA,YAAM,MAAM,QAAQ,IAAI,qBAAqB,CAAC,QAAQ,IAAI,qBAAqB;AAC/E,UAAI,EAAE,QAAQ,KAAK;AACjB,gBAAQ,IACN,uFACF;AAEA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,OAAO,UAAU;AAC1B;AAEO,6BAA6B;AAClC,SAAO,UAAU,UAAU;AAC7B;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts"],
4
- "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { PseudoStyles, StyleObject } from '@tamagui/core-node'\nimport { ViewStyle } from 'react-native'\n\nexport type { StyleObject } from '@tamagui/helpers'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface TamaguiOptions {\n // module paths you want to compile with tamagui (for example ['tamagui'])\n components: string[]\n // your tamagui.config.ts\n config?: string\n evaluateVars?: boolean\n importsWhitelist?: string[]\n disable?: boolean\n disableExtraction?: boolean\n disableDebugAttr?: boolean\n disableExtractInlineMedia?: boolean\n disableExtractVariables?: boolean\n excludeReactNativeWebExports?: string[]\n exclude?: RegExp\n logTimings?: boolean\n prefixLogs?: string\n\n // probably non user options\n cssPath?: string\n cssData?: any\n deoptProps?: Set<string>\n excludeProps?: Set<string>\n inlineProps?: Set<string>\n forceExtractStyleDefinitions?: boolean\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: ViewStyle & PseudoStyles\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n}\n\nexport type ExtractorParseProps = TamaguiOptions & {\n target: 'native' | 'html'\n sourcePath?: string\n shouldPrintDebug?: boolean | 'verbose'\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string\n extractStyledDefinitions?: boolean\n // identifer, rule\n onStyleRule?: (identifier: string, rules: string[]) => void\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
4
+ "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { PseudoStyles, StaticConfig, StyleObject } from '@tamagui/core-node'\nimport { ViewStyle } from 'react-native'\n\nexport type { StyleObject } from '@tamagui/helpers'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface TamaguiOptions {\n // module paths you want to compile with tamagui (for example ['tamagui'])\n components: string[]\n // your tamagui.config.ts\n config?: string\n evaluateVars?: boolean\n importsWhitelist?: string[]\n disable?: boolean\n disableExtraction?: boolean\n disableDebugAttr?: boolean\n disableExtractInlineMedia?: boolean\n disableExtractVariables?: boolean\n excludeReactNativeWebExports?: string[]\n exclude?: RegExp\n logTimings?: boolean\n prefixLogs?: string\n\n // probably non user options\n cssPath?: string\n cssData?: any\n deoptProps?: Set<string>\n excludeProps?: Set<string>\n inlineProps?: Set<string>\n forceExtractStyleDefinitions?: boolean\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: ViewStyle & PseudoStyles\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n completeProps: Record<string, any>\n staticConfig: StaticConfig\n}\n\nexport type ExtractorParseProps = TamaguiOptions & {\n target: 'native' | 'html'\n sourcePath?: string\n shouldPrintDebug?: boolean | 'verbose'\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string\n extractStyledDefinitions?: boolean\n // identifer, rule\n onStyleRule?: (identifier: string, rules: string[]) => void\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1244,14 +1244,18 @@ function createExtractor() {
1244
1244
  }
1245
1245
  }
1246
1246
  if (!shouldFlatten) {
1247
- if (Object.keys(inlineWhenUnflattenedOGVals).length) {
1247
+ if (inlineWhenUnflattened.size) {
1248
1248
  for (const [index, attr] of attrs.entries()) {
1249
1249
  if (attr.type === "style") {
1250
1250
  for (const key in attr.value) {
1251
+ if (!inlineWhenUnflattened.has(key))
1252
+ continue;
1251
1253
  const val = inlineWhenUnflattenedOGVals[key];
1252
1254
  if (val) {
1253
1255
  delete attr.value[key];
1254
1256
  attrs.splice(index - 1, 0, val.attr);
1257
+ } else {
1258
+ delete attr.value[key];
1255
1259
  }
1256
1260
  }
1257
1261
  }
@@ -1281,7 +1285,9 @@ function createExtractor() {
1281
1285
  jsxPath: traversePath,
1282
1286
  originalNodeName,
1283
1287
  isFlattened: shouldFlatten,
1284
- programPath
1288
+ programPath,
1289
+ completeProps,
1290
+ staticConfig
1285
1291
  });
1286
1292
  } finally {
1287
1293
  if (debugPropValue) {