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