@tamagui/static 2.7.7 → 3.0.0-beta.643.1
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/check-dep-versions.cjs +355 -0
- package/dist/cjs/checkDeps.cjs +302 -0
- package/dist/cjs/compiler.cjs +286 -0
- package/dist/cjs/compilerHost.cjs +1695 -0
- package/dist/cjs/constants.cjs +33 -0
- package/dist/cjs/domStructuralPass.cjs +112 -0
- package/dist/cjs/exports.cjs +42 -0
- package/dist/cjs/extractor/addLocalExports.cjs +64 -0
- package/dist/cjs/extractor/bundle.cjs +203 -0
- package/dist/cjs/extractor/bundleConfig.cjs +747 -0
- package/dist/cjs/extractor/concatClassName.cjs +117 -0
- package/dist/cjs/extractor/detectModuleFormat.cjs +54 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.cjs +47 -0
- package/dist/cjs/extractor/esbuildTsconfigPaths.cjs +92 -0
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +38 -0
- package/dist/cjs/extractor/loadTamagui.cjs +344 -0
- package/dist/cjs/extractor/regenerateConfig.cjs +161 -0
- package/dist/cjs/extractor/watchTamaguiConfig.cjs +64 -0
- package/dist/cjs/getPragmaOptions.cjs +67 -0
- package/dist/cjs/helpers/memoize.cjs +42 -0
- package/dist/cjs/helpers/requireTamaguiCore.cjs +40 -0
- package/dist/cjs/index.cjs +34 -0
- package/dist/cjs/registerRequire.cjs +220 -0
- package/dist/cjs/server.cjs +66 -0
- package/dist/cjs/staticEvaluationIgnoredModules.cjs +86 -0
- package/dist/cjs/types.cjs +17 -0
- package/dist/cjs/zero/artifact.cjs +145 -0
- package/dist/cjs/zero/graph.cjs +209 -0
- package/dist/cjs/zero/identity.cjs +61 -0
- package/dist/cjs/zero/index.cjs +26 -0
- package/dist/cjs/zero/islands.cjs +232 -0
- package/dist/cjs/zero/options.cjs +163 -0
- package/dist/cjs/zero/ownership.cjs +79 -0
- package/dist/cjs/zero/theme.cjs +328 -0
- package/dist/cjs/zero/transform.cjs +203 -0
- package/dist/esm/check-dep-versions.mjs +329 -0
- package/dist/esm/check-dep-versions.mjs.map +1 -0
- package/dist/esm/checkDeps.mjs +279 -0
- package/dist/esm/checkDeps.mjs.map +1 -0
- package/dist/esm/compiler.mjs +255 -0
- package/dist/esm/compiler.mjs.map +1 -0
- package/dist/esm/compilerHost.mjs +1675 -0
- package/dist/esm/compilerHost.mjs.map +1 -0
- package/dist/esm/constants.mjs +7 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +92 -0
- package/dist/esm/domStructuralPass.mjs.map +1 -0
- package/dist/esm/exports.mjs +26 -0
- package/dist/esm/extractor/addLocalExports.mjs +44 -0
- package/dist/esm/extractor/addLocalExports.mjs.map +1 -0
- package/dist/esm/extractor/bundle.mjs +173 -0
- package/dist/esm/extractor/bundle.mjs.map +1 -0
- package/dist/esm/extractor/bundleConfig.mjs +706 -0
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -0
- package/dist/esm/extractor/concatClassName.mjs +96 -0
- package/dist/esm/extractor/concatClassName.mjs.map +1 -0
- package/dist/esm/extractor/detectModuleFormat.mjs +31 -0
- package/dist/esm/extractor/detectModuleFormat.mjs.map +1 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs +26 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs.map +1 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs +63 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs.map +1 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs +18 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs.map +1 -0
- package/dist/esm/extractor/loadTamagui.mjs +306 -0
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -0
- package/dist/esm/extractor/regenerateConfig.mjs +131 -0
- package/dist/esm/extractor/regenerateConfig.mjs.map +1 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs +43 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs.map +1 -0
- package/dist/esm/getPragmaOptions.mjs +46 -0
- package/dist/esm/getPragmaOptions.mjs.map +1 -0
- package/dist/esm/helpers/memoize.mjs +21 -0
- package/dist/esm/helpers/memoize.mjs.map +1 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs +19 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs.map +1 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/registerRequire.mjs +195 -0
- package/dist/esm/registerRequire.mjs.map +1 -0
- package/dist/esm/server.mjs +40 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/setup.mjs +0 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs +61 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/zero/artifact.mjs +119 -0
- package/dist/esm/zero/artifact.mjs.map +1 -0
- package/dist/esm/zero/graph.mjs +170 -0
- package/dist/esm/zero/graph.mjs.map +1 -0
- package/dist/esm/zero/identity.mjs +36 -0
- package/dist/esm/zero/identity.mjs.map +1 -0
- package/dist/esm/zero/index.mjs +15 -0
- package/dist/esm/zero/islands.mjs +197 -0
- package/dist/esm/zero/islands.mjs.map +1 -0
- package/dist/esm/zero/options.mjs +129 -0
- package/dist/esm/zero/options.mjs.map +1 -0
- package/dist/esm/zero/ownership.mjs +48 -0
- package/dist/esm/zero/ownership.mjs.map +1 -0
- package/dist/esm/zero/theme.mjs +303 -0
- package/dist/esm/zero/theme.mjs.map +1 -0
- package/dist/esm/zero/transform.mjs +177 -0
- package/dist/esm/zero/transform.mjs.map +1 -0
- package/package.json +33 -43
- package/src/check-dep-versions.ts +2 -2
- package/src/checkDeps.ts +3 -2
- package/src/compiler.ts +425 -0
- package/src/compilerHost.ts +3125 -0
- package/src/constants.ts +0 -5
- package/src/domStructuralPass.ts +170 -0
- package/src/exports.ts +3 -6
- package/src/extractor/addLocalExports.ts +49 -0
- package/src/extractor/bundle.ts +20 -35
- package/src/extractor/bundleConfig.ts +334 -187
- package/src/extractor/concatClassName.ts +13 -20
- package/src/extractor/getTamaguiConfigPathFromOptionsConfig.ts +5 -4
- package/src/extractor/loadTamagui.ts +196 -143
- package/src/extractor/regenerateConfig.ts +65 -13
- package/src/extractor/watchTamaguiConfig.ts +6 -1
- package/src/helpers/requireTamaguiCore.ts +6 -1
- package/src/registerRequire.ts +94 -132
- package/src/staticEvaluationIgnoredModules.ts +74 -0
- package/src/types.ts +2 -107
- package/src/zero/artifact.ts +142 -0
- package/src/zero/graph.ts +359 -0
- package/src/zero/identity.ts +73 -0
- package/src/zero/index.ts +8 -0
- package/src/zero/islands.ts +262 -0
- package/src/zero/options.ts +239 -0
- package/src/zero/ownership.ts +113 -0
- package/src/zero/theme.ts +478 -0
- package/src/zero/transform.ts +320 -0
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/compiler.d.ts +117 -0
- package/types/compiler.d.ts.map +1 -0
- package/types/compilerHost.d.ts +25 -0
- package/types/compilerHost.d.ts.map +1 -0
- package/types/constants.d.ts +0 -1
- package/types/constants.d.ts.map +1 -1
- package/types/domStructuralPass.d.ts +3 -0
- package/types/domStructuralPass.d.ts.map +1 -0
- package/types/exports.d.ts +3 -6
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/addLocalExports.d.ts +3 -0
- package/types/extractor/addLocalExports.d.ts.map +1 -0
- package/types/extractor/bundle.d.ts +66 -65
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +19 -4
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +26 -3
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchTamaguiConfig.d.ts.map +1 -1
- package/types/getPragmaOptions.d.ts +1 -1
- package/types/helpers/memoize.d.ts +1 -1
- package/types/helpers/memoize.d.ts.map +1 -1
- package/types/helpers/requireTamaguiCore.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/registerRequire.d.ts +2 -2
- package/types/registerRequire.d.ts.map +1 -1
- package/types/staticEvaluationIgnoredModules.d.ts +9 -0
- package/types/staticEvaluationIgnoredModules.d.ts.map +1 -0
- package/types/types.d.ts +2 -90
- package/types/types.d.ts.map +1 -1
- package/types/zero/artifact.d.ts +44 -0
- package/types/zero/artifact.d.ts.map +1 -0
- package/types/zero/graph.d.ts +139 -0
- package/types/zero/graph.d.ts.map +1 -0
- package/types/zero/identity.d.ts +33 -0
- package/types/zero/identity.d.ts.map +1 -0
- package/types/zero/index.d.ts +9 -0
- package/types/zero/index.d.ts.map +1 -0
- package/types/zero/islands.d.ts +56 -0
- package/types/zero/islands.d.ts.map +1 -0
- package/types/zero/options.d.ts +58 -0
- package/types/zero/options.d.ts.map +1 -0
- package/types/zero/ownership.d.ts +51 -0
- package/types/zero/ownership.d.ts.map +1 -0
- package/types/zero/theme.d.ts +83 -0
- package/types/zero/theme.d.ts.map +1 -0
- package/types/zero/transform.d.ts +53 -0
- package/types/zero/transform.d.ts.map +1 -0
- package/dist/check-dep-versions.cjs +0 -372
- package/dist/checkDeps.cjs +0 -271
- package/dist/constants.cjs +0 -51
- package/dist/exports.cjs +0 -48
- package/dist/extractor/accessSafe.cjs +0 -48
- package/dist/extractor/babelParse.cjs +0 -56
- package/dist/extractor/buildClassName.cjs +0 -86
- package/dist/extractor/bundle.cjs +0 -234
- package/dist/extractor/bundleConfig.cjs +0 -729
- package/dist/extractor/concatClassName.cjs +0 -129
- package/dist/extractor/createEvaluator.cjs +0 -88
- package/dist/extractor/createExtractor.cjs +0 -1968
- package/dist/extractor/createLogger.cjs +0 -50
- package/dist/extractor/detectModuleFormat.cjs +0 -55
- package/dist/extractor/ensureImportingConcat.cjs +0 -54
- package/dist/extractor/errors.cjs +0 -28
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -56
- package/dist/extractor/esbuildTsconfigPaths.cjs +0 -108
- package/dist/extractor/evaluateAstNode.cjs +0 -128
- package/dist/extractor/extractHelpers.cjs +0 -182
- package/dist/extractor/extractMediaStyle.cjs +0 -169
- package/dist/extractor/extractToClassNames.cjs +0 -475
- package/dist/extractor/extractToNative.cjs +0 -369
- package/dist/extractor/findTopmostFunction.cjs +0 -43
- package/dist/extractor/generatedUid.cjs +0 -58
- package/dist/extractor/getPrefixLogs.cjs +0 -31
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -85
- package/dist/extractor/getSourceModule.cjs +0 -100
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -213
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +0 -41
- package/dist/extractor/hasTopLevelAwait.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs +0 -76
- package/dist/extractor/literalToAst.cjs +0 -109
- package/dist/extractor/loadFile.cjs +0 -17
- package/dist/extractor/loadTamagui.cjs +0 -373
- package/dist/extractor/logLines.cjs +0 -43
- package/dist/extractor/normalizeTernaries.cjs +0 -100
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -42
- package/dist/extractor/regenerateConfig.cjs +0 -178
- package/dist/extractor/removeUnusedHooks.cjs +0 -108
- package/dist/extractor/timer.cjs +0 -52
- package/dist/extractor/validHTMLAttributes.cjs +0 -79
- package/dist/extractor/watchTamaguiConfig.cjs +0 -70
- package/dist/getPragmaOptions.cjs +0 -73
- package/dist/helpers/memoize.cjs +0 -45
- package/dist/helpers/requireTamaguiCore.cjs +0 -40
- package/dist/index.cjs +0 -42
- package/dist/registerRequire.cjs +0 -209
- package/dist/server.cjs +0 -82
- package/dist/types.cjs +0 -18
- package/dist/worker.cjs +0 -111
- package/src/extractor/accessSafe.ts +0 -22
- package/src/extractor/babelParse.ts +0 -38
- package/src/extractor/buildClassName.ts +0 -76
- package/src/extractor/createEvaluator.ts +0 -82
- package/src/extractor/createExtractor.ts +0 -2970
- package/src/extractor/createLogger.ts +0 -41
- package/src/extractor/ensureImportingConcat.ts +0 -36
- package/src/extractor/errors.ts +0 -1
- package/src/extractor/evaluateAstNode.ts +0 -136
- package/src/extractor/extractHelpers.ts +0 -211
- package/src/extractor/extractMediaStyle.ts +0 -194
- package/src/extractor/extractToClassNames.ts +0 -733
- package/src/extractor/extractToNative.ts +0 -506
- package/src/extractor/findTopmostFunction.ts +0 -24
- package/src/extractor/generatedUid.ts +0 -41
- package/src/extractor/getPrefixLogs.ts +0 -9
- package/src/extractor/getPropValueFromAttributes.ts +0 -95
- package/src/extractor/getSourceModule.ts +0 -96
- package/src/extractor/getStaticBindingsForScope.ts +0 -237
- package/src/extractor/hasTopLevelAwait.ts +0 -28
- package/src/extractor/hoistClassNames.ts +0 -52
- package/src/extractor/literalToAst.ts +0 -85
- package/src/extractor/loadFile.ts +0 -17
- package/src/extractor/logLines.ts +0 -16
- package/src/extractor/normalizeTernaries.ts +0 -89
- package/src/extractor/propsToFontFamilyCache.ts +0 -18
- package/src/extractor/removeUnusedHooks.ts +0 -83
- package/src/extractor/timer.ts +0 -25
- package/src/extractor/validHTMLAttributes.ts +0 -52
- package/src/worker.ts +0 -142
- package/types/extractor/accessSafe.d.ts +0 -3
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts +0 -5
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/buildClassName.d.ts +0 -7
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts +0 -12
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts +0 -32
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/createLogger.d.ts +0 -3
- package/types/extractor/createLogger.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts +0 -4
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/errors.d.ts +0 -3
- package/types/extractor/errors.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts +0 -3
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts +0 -28
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts +0 -11
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts +0 -25
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/extractToNative.d.ts +0 -13
- package/types/extractor/extractToNative.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -4
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts +0 -5
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPrefixLogs.d.ts +0 -3
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -19
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts +0 -16
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -5
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hasTopLevelAwait.d.ts +0 -2
- package/types/extractor/hasTopLevelAwait.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts +0 -6
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts +0 -4
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/loadFile.d.ts +0 -1
- package/types/extractor/loadFile.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts +0 -2
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts +0 -5
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/propsToFontFamilyCache.d.ts +0 -4
- package/types/extractor/propsToFontFamilyCache.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts +0 -3
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts +0 -5
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts +0 -52
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
- package/types/worker.d.ts +0 -46
- package/types/worker.d.ts.map +0 -1
- /package/dist/{setup.cjs → cjs/setup.cjs} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { dirname, join } from 'node:path'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
2
3
|
|
|
3
4
|
import { generateThemes, writeGeneratedThemes } from '@tamagui/generate-themes'
|
|
5
|
+
import { stylePropsAll } from '@tamagui/helpers'
|
|
6
|
+
import { grammarEntries } from '@tamagui/style-grammar'
|
|
4
7
|
import type { TamaguiOptions } from '@tamagui/types'
|
|
5
|
-
import
|
|
8
|
+
import FS from 'fs-extra'
|
|
6
9
|
|
|
7
10
|
import { requireTamaguiCore } from '../helpers/requireTamaguiCore'
|
|
8
11
|
import type { TamaguiPlatform } from '../types'
|
|
9
12
|
import type { BundledConfig } from './bundleConfig'
|
|
10
13
|
import { getBundledConfig } from './bundleConfig'
|
|
11
14
|
|
|
12
|
-
const tamaguiDir = join(process.cwd(), '.tamagui')
|
|
13
|
-
const confFile = join(tamaguiDir, 'tamagui.config.json')
|
|
14
|
-
|
|
15
15
|
/**
|
|
16
16
|
* Sort of a super-set of bundleConfig(), this code needs some refactoring ideally
|
|
17
17
|
*/
|
|
@@ -27,6 +27,7 @@ export async function regenerateConfig(
|
|
|
27
27
|
const config = configIn ?? (await getBundledConfig(tamaguiOptions, rebuild))
|
|
28
28
|
if (!config) return
|
|
29
29
|
const out = transformConfig(config, tamaguiOptions.platform || 'web')
|
|
30
|
+
const confFile = getConfigFile(tamaguiOptions)
|
|
30
31
|
|
|
31
32
|
await FS.ensureDir(dirname(confFile))
|
|
32
33
|
await FS.writeJSON(confFile, out, {
|
|
@@ -41,14 +42,15 @@ export async function regenerateConfig(
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export function regenerateConfigSync(
|
|
44
|
-
|
|
45
|
+
tamaguiOptions: TamaguiOptions,
|
|
45
46
|
config: BundledConfig
|
|
46
47
|
) {
|
|
47
48
|
try {
|
|
49
|
+
const confFile = getConfigFile(tamaguiOptions)
|
|
48
50
|
FS.ensureDirSync(dirname(confFile))
|
|
49
51
|
FS.writeJSONSync(
|
|
50
52
|
confFile,
|
|
51
|
-
transformConfig(config,
|
|
53
|
+
transformConfig(config, tamaguiOptions.platform || 'web'),
|
|
52
54
|
{
|
|
53
55
|
spaces: 2,
|
|
54
56
|
}
|
|
@@ -70,8 +72,11 @@ export async function generateTamaguiThemes(
|
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
const { input, output } = tamaguiOptions.themeBuilder
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
+
const root = tamaguiOptions.root || process.cwd()
|
|
76
|
+
const tamaguiDir = join(root, '.tamagui')
|
|
77
|
+
const projectRequire = createRequire(join(root, 'package.json'))
|
|
78
|
+
const inPath = resolveRelativePath(input, root, projectRequire)
|
|
79
|
+
const outPath = resolveRelativePath(output, root, projectRequire)
|
|
75
80
|
const generatedOutput = await generateThemes(inPath)
|
|
76
81
|
|
|
77
82
|
// because this runs in parallel (its cheap) lets avoid logging a bunch, so check to see if changed:
|
|
@@ -96,8 +101,15 @@ export async function generateTamaguiThemes(
|
|
|
96
101
|
return hasChanged
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
const
|
|
100
|
-
|
|
104
|
+
const getConfigFile = (options: TamaguiOptions) =>
|
|
105
|
+
join(options.root || process.cwd(), '.tamagui', 'tamagui.config.json')
|
|
106
|
+
|
|
107
|
+
const resolveRelativePath = (
|
|
108
|
+
inputPath: string,
|
|
109
|
+
root: string,
|
|
110
|
+
projectRequire: NodeRequire
|
|
111
|
+
) =>
|
|
112
|
+
inputPath.startsWith('.') ? join(root, inputPath) : projectRequire.resolve(inputPath)
|
|
101
113
|
|
|
102
114
|
function cloneDeepSafe(x: any, excludeKeys = {}) {
|
|
103
115
|
if (!x) return x
|
|
@@ -110,6 +122,40 @@ function cloneDeepSafe(x: any, excludeKeys = {}) {
|
|
|
110
122
|
)
|
|
111
123
|
}
|
|
112
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Which token category each style prop draws its values from, emitted so the
|
|
127
|
+
* language server can offer `bg=""` colors and `p=""` spaces instead of every
|
|
128
|
+
* token in the config.
|
|
129
|
+
*
|
|
130
|
+
* Derived from the style-grammar registry rather than restated here: that
|
|
131
|
+
* registry is already the contract the runtime resolver is pinned to
|
|
132
|
+
* (see core-test/tokenCategoryParity.web.test.tsx), so a second table would be
|
|
133
|
+
* a second thing to keep true.
|
|
134
|
+
*
|
|
135
|
+
* A prefix shared by props of different categories (`border` is both
|
|
136
|
+
* borderWidth/space and borderColor/color) is left out rather than guessed at;
|
|
137
|
+
* an unmapped prop offers the whole vocabulary, which is the honest answer.
|
|
138
|
+
*/
|
|
139
|
+
function buildPropCategories(): Record<string, string> {
|
|
140
|
+
const out: Record<string, string> = {}
|
|
141
|
+
const byPrefix: Record<string, Set<string | undefined>> = {}
|
|
142
|
+
|
|
143
|
+
for (const entry of grammarEntries) {
|
|
144
|
+
if (entry.tokenCategory) out[entry.prop] = entry.tokenCategory
|
|
145
|
+
if (entry.prefix) (byPrefix[entry.prefix] ||= new Set()).add(entry.tokenCategory)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
for (const [prefix, categories] of Object.entries(byPrefix)) {
|
|
149
|
+
// `out[prefix]` may already be set when a prop is its own prefix (`gap`,
|
|
150
|
+
// `color`); the registry agrees with itself there, so this is a no-op
|
|
151
|
+
if (categories.size !== 1) continue
|
|
152
|
+
const [only] = categories
|
|
153
|
+
if (only) out[prefix] = only
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return out
|
|
157
|
+
}
|
|
158
|
+
|
|
113
159
|
function transformConfig(config: BundledConfig, platform: TamaguiPlatform) {
|
|
114
160
|
if (!config) {
|
|
115
161
|
return null
|
|
@@ -127,11 +173,9 @@ function transformConfig(config: BundledConfig, platform: TamaguiPlatform) {
|
|
|
127
173
|
|
|
128
174
|
// reduce down to usable, smaller json
|
|
129
175
|
|
|
130
|
-
// slim themes
|
|
176
|
+
// slim themes
|
|
131
177
|
for (const key in themes) {
|
|
132
178
|
const theme = themes[key]
|
|
133
|
-
// @ts-ignore
|
|
134
|
-
theme.id = key
|
|
135
179
|
for (const tkey in theme) {
|
|
136
180
|
theme[tkey] = getVariableValue(theme[tkey])
|
|
137
181
|
}
|
|
@@ -177,10 +221,18 @@ function transformConfig(config: BundledConfig, platform: TamaguiPlatform) {
|
|
|
177
221
|
return {
|
|
178
222
|
components,
|
|
179
223
|
nameToPaths,
|
|
224
|
+
tamaguiConfigMetadata: {
|
|
225
|
+
themeFields: 'values-only',
|
|
226
|
+
},
|
|
180
227
|
tamaguiConfig: {
|
|
181
228
|
...cleanedConfig,
|
|
182
229
|
// Output userShorthands as shorthands (excludes built-ins)
|
|
183
230
|
shorthands: userShorthands,
|
|
231
|
+
propCategories: buildPropCategories(),
|
|
232
|
+
// every prop that can carry a style value. the shorthand tables alone
|
|
233
|
+
// miss any long-form prop with no shorthand (`gap`, `backgroundColor`),
|
|
234
|
+
// and the language server was silent inside exactly those.
|
|
235
|
+
styleProps: Object.keys(stylePropsAll),
|
|
184
236
|
},
|
|
185
237
|
}
|
|
186
238
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { TamaguiOptions } from '@tamagui/types'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
2
3
|
import { esbuildWatchFiles, generateThemesAndLog, getOptions } from './loadTamagui'
|
|
3
4
|
import { regenerateConfig } from './regenerateConfig'
|
|
4
5
|
|
|
6
|
+
const nodeRequire = createRequire(
|
|
7
|
+
typeof __filename === 'string' ? __filename : import.meta.url
|
|
8
|
+
)
|
|
9
|
+
|
|
5
10
|
let isWatching = false
|
|
6
11
|
|
|
7
12
|
export async function watchTamaguiConfig(tamaguiOptions: TamaguiOptions) {
|
|
@@ -43,7 +48,7 @@ export async function watchTamaguiConfig(tamaguiOptions: TamaguiOptions) {
|
|
|
43
48
|
if (themeBuilderInput) {
|
|
44
49
|
let inputPath = themeBuilderInput
|
|
45
50
|
try {
|
|
46
|
-
inputPath =
|
|
51
|
+
inputPath = nodeRequire.resolve(themeBuilderInput)
|
|
47
52
|
} catch {
|
|
48
53
|
// ok
|
|
49
54
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// this allows us to swap between core native and web in the same process:
|
|
2
2
|
|
|
3
3
|
import type { TamaguiPlatform } from '../types'
|
|
4
|
+
import { createRequire } from 'node:module'
|
|
5
|
+
|
|
6
|
+
const nodeRequire = createRequire(
|
|
7
|
+
typeof __filename === 'string' ? __filename : import.meta.url
|
|
8
|
+
)
|
|
4
9
|
|
|
5
10
|
export function requireTamaguiCore(
|
|
6
11
|
platform: TamaguiPlatform,
|
|
7
|
-
ogRequire: Function =
|
|
12
|
+
ogRequire: Function = nodeRequire
|
|
8
13
|
): typeof import('@tamagui/core') {
|
|
9
14
|
if (!platform) {
|
|
10
15
|
throw new Error(`No platform given to requireTamaguiCore`)
|
package/src/registerRequire.ts
CHANGED
|
@@ -1,21 +1,43 @@
|
|
|
1
|
+
import { dirname } from 'node:path'
|
|
2
|
+
import { buildSync } from 'esbuild'
|
|
1
3
|
import { register } from 'esbuild-register/dist/node'
|
|
4
|
+
import { createRequire } from 'node:module'
|
|
2
5
|
|
|
3
6
|
import { esbuildIgnoreFilesRegex } from './extractor/bundle'
|
|
4
7
|
import { requireTamaguiCore } from './helpers/requireTamaguiCore'
|
|
8
|
+
import {
|
|
9
|
+
getStaticEvaluationModuleReplacement,
|
|
10
|
+
isIgnoredStaticEvaluationModule,
|
|
11
|
+
} from './staticEvaluationIgnoredModules'
|
|
5
12
|
import type { TamaguiPlatform } from './types'
|
|
6
13
|
|
|
7
14
|
const nameToPaths = {}
|
|
15
|
+
const nodeRequire = createRequire(
|
|
16
|
+
typeof __filename === 'string' ? __filename : import.meta.url
|
|
17
|
+
)
|
|
8
18
|
|
|
9
19
|
export const getNameToPaths = () => nameToPaths
|
|
10
20
|
|
|
11
|
-
const Module =
|
|
12
|
-
const proxyWorm = require('@tamagui/proxy-worm')
|
|
21
|
+
const Module = nodeRequire('node:module')
|
|
13
22
|
|
|
14
23
|
let isRegistered = false
|
|
15
24
|
let og: any
|
|
16
25
|
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
class StaticEvaluationError extends Error {
|
|
27
|
+
code = 'TAMAGUI_STATIC_EVALUATION_ERROR' as const
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
readonly moduleName: string,
|
|
31
|
+
readonly importer: string,
|
|
32
|
+
readonly failedModule: string,
|
|
33
|
+
readonly reason: string,
|
|
34
|
+
options: ErrorOptions
|
|
35
|
+
) {
|
|
36
|
+
super(
|
|
37
|
+
`[tamagui] Failed to evaluate module "${failedModule}" imported from "${importer}" while loading the Tamagui config and configured components.\nReason: ${reason}\nFix the module so it can run in Node during the build. If it is runtime-only and none of its exports create your Tamagui config or components, add "${moduleName}" to dangerouslyIgnoreStaticEvaluationModules in tamagui.build.ts.`,
|
|
38
|
+
options
|
|
39
|
+
)
|
|
40
|
+
}
|
|
19
41
|
}
|
|
20
42
|
|
|
21
43
|
const compiled = {}
|
|
@@ -48,6 +70,35 @@ function getStaticExtractionStub(path: string) {
|
|
|
48
70
|
fetchUpdateAsync: async () => ({ isNew: false }),
|
|
49
71
|
reloadAsync: async () => {},
|
|
50
72
|
}
|
|
73
|
+
case 'react-native-reanimated': {
|
|
74
|
+
const identity = <T>(value: T) => value
|
|
75
|
+
const sharedValue = <T>(value: T) => ({
|
|
76
|
+
value,
|
|
77
|
+
get: () => value,
|
|
78
|
+
set: (next: T | ((current: T) => T)) => {
|
|
79
|
+
value = typeof next === 'function' ? (next as (current: T) => T)(value) : next
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
const Animated = {
|
|
83
|
+
createAnimatedComponent: identity,
|
|
84
|
+
View: () => null,
|
|
85
|
+
Text: () => null,
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
__esModule: true,
|
|
89
|
+
default: Animated,
|
|
90
|
+
cancelAnimation: () => {},
|
|
91
|
+
runOnJS: identity,
|
|
92
|
+
runOnUI: identity,
|
|
93
|
+
useAnimatedReaction: () => {},
|
|
94
|
+
useAnimatedStyle: (callback: () => unknown) => callback(),
|
|
95
|
+
useDerivedValue: (callback: () => unknown) => sharedValue(callback()),
|
|
96
|
+
useSharedValue: sharedValue,
|
|
97
|
+
withDelay: (_delay: number, animation: unknown) => animation,
|
|
98
|
+
withSpring: identity,
|
|
99
|
+
withTiming: identity,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
51
102
|
default:
|
|
52
103
|
return null
|
|
53
104
|
}
|
|
@@ -55,14 +106,14 @@ function getStaticExtractionStub(path: string) {
|
|
|
55
106
|
|
|
56
107
|
export function registerRequire(
|
|
57
108
|
platform: TamaguiPlatform,
|
|
58
|
-
{
|
|
59
|
-
|
|
109
|
+
{ ignoredModules = [] }: { ignoredModules?: string[] } = {
|
|
110
|
+
ignoredModules: [],
|
|
60
111
|
}
|
|
61
112
|
) {
|
|
62
113
|
// already registered
|
|
63
114
|
if (isRegistered) {
|
|
64
115
|
return {
|
|
65
|
-
tamaguiRequire:
|
|
116
|
+
tamaguiRequire: nodeRequire,
|
|
66
117
|
unregister: () => {},
|
|
67
118
|
}
|
|
68
119
|
}
|
|
@@ -122,12 +173,35 @@ export function registerRequire(
|
|
|
122
173
|
})
|
|
123
174
|
}
|
|
124
175
|
|
|
176
|
+
const staticEvaluationReplacement = getStaticEvaluationModuleReplacement(path)
|
|
177
|
+
if (staticEvaluationReplacement) {
|
|
178
|
+
if (!(path in compiled)) {
|
|
179
|
+
const replacementPath = nodeRequire.resolve(staticEvaluationReplacement)
|
|
180
|
+
const output = buildSync({
|
|
181
|
+
entryPoints: [replacementPath],
|
|
182
|
+
bundle: true,
|
|
183
|
+
format: 'cjs',
|
|
184
|
+
platform: 'node',
|
|
185
|
+
write: false,
|
|
186
|
+
}).outputFiles[0].text
|
|
187
|
+
const replacementModule = new Module(replacementPath, this)
|
|
188
|
+
replacementModule.filename = replacementPath
|
|
189
|
+
replacementModule.paths = Module._nodeModulePaths(dirname(replacementPath))
|
|
190
|
+
replacementModule._compile(output, replacementPath)
|
|
191
|
+
compiled[path] = replacementModule.exports
|
|
192
|
+
}
|
|
193
|
+
return compiled[path]
|
|
194
|
+
}
|
|
195
|
+
|
|
125
196
|
if (
|
|
126
|
-
|
|
127
|
-
path
|
|
128
|
-
esbuildIgnoreFilesRegex.test(path)
|
|
197
|
+
staticEvaluationReplacement === null ||
|
|
198
|
+
isIgnoredStaticEvaluationModule(path, ignoredModules)
|
|
129
199
|
) {
|
|
130
|
-
return
|
|
200
|
+
return {}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (esbuildIgnoreFilesRegex.test(path)) {
|
|
204
|
+
return {}
|
|
131
205
|
}
|
|
132
206
|
|
|
133
207
|
if (path in compiled) {
|
|
@@ -156,141 +230,29 @@ export function registerRequire(
|
|
|
156
230
|
}
|
|
157
231
|
}
|
|
158
232
|
|
|
159
|
-
if (!whitelisted[path]) {
|
|
160
|
-
if (proxyWormImports && !path.includes('.tamagui-dynamic-eval')) {
|
|
161
|
-
// allow tamagui and its sub-packages through - they re-export components
|
|
162
|
-
// with staticConfig needed for dynamic eval optimization.
|
|
163
|
-
// also allow requires FROM within tamagui packages (relative imports like ./Separator.cjs)
|
|
164
|
-
const callerFile = this?.filename || this?.id || ''
|
|
165
|
-
const isFromTamaguiPkg =
|
|
166
|
-
callerFile.includes('@tamagui') ||
|
|
167
|
-
callerFile.includes('node_modules/tamagui/') ||
|
|
168
|
-
/\/tamagui\/code\/(core|ui|packages)\//.test(callerFile)
|
|
169
|
-
const isFromStaticLoader =
|
|
170
|
-
!callerFile ||
|
|
171
|
-
callerFile === '.' ||
|
|
172
|
-
callerFile === '[eval]' ||
|
|
173
|
-
callerFile.endsWith('/[eval]') ||
|
|
174
|
-
callerFile.includes('/code/compiler/static/') ||
|
|
175
|
-
callerFile.includes('/.tamagui/')
|
|
176
|
-
// relative requires from within a whitelisted package's own files
|
|
177
|
-
// (e.g. react/index.js does require('./cjs/react.development.js')).
|
|
178
|
-
// proxy-worming these breaks the package's own internals.
|
|
179
|
-
const isRelativeFromWhitelisted =
|
|
180
|
-
path.startsWith('.') &&
|
|
181
|
-
Object.keys(whitelisted).some((pkg) =>
|
|
182
|
-
callerFile.includes(`/node_modules/${pkg}/`)
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
if (
|
|
186
|
-
path === 'tamagui' ||
|
|
187
|
-
path.startsWith('@tamagui/') ||
|
|
188
|
-
isRelativeFromWhitelisted ||
|
|
189
|
-
isFromTamaguiPkg ||
|
|
190
|
-
isFromStaticLoader
|
|
191
|
-
) {
|
|
192
|
-
return og.apply(this, [path])
|
|
193
|
-
}
|
|
194
|
-
return proxyWorm
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
233
|
try {
|
|
199
234
|
const out = og.apply(this, arguments)
|
|
200
|
-
// only for studio disable for now
|
|
201
|
-
// if (!nameToPaths[path]) {
|
|
202
|
-
// if (out && typeof out === 'object') {
|
|
203
|
-
// for (const key in out) {
|
|
204
|
-
// try {
|
|
205
|
-
// const conf = out[key]?.staticConfig as StaticConfig
|
|
206
|
-
// if (conf) {
|
|
207
|
-
// if (conf.componentName) {
|
|
208
|
-
// nameToPaths[conf.componentName] ??= new Set()
|
|
209
|
-
// const fullName = path.startsWith('.')
|
|
210
|
-
// ? join(`${this.path.replace(/dist(\/cjs)?/, 'src')}`, path)
|
|
211
|
-
// : path
|
|
212
|
-
// nameToPaths[conf.componentName].add(fullName)
|
|
213
|
-
// } else {
|
|
214
|
-
// // console.log('no name component', path)
|
|
215
|
-
// }
|
|
216
|
-
// }
|
|
217
|
-
// } catch {
|
|
218
|
-
// // ok
|
|
219
|
-
// }
|
|
220
|
-
// }
|
|
221
|
-
// }
|
|
222
|
-
// }
|
|
223
235
|
return out
|
|
224
236
|
} catch (err: any) {
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
path.includes('tamagui-dynamic-eval')
|
|
228
|
-
) {
|
|
229
|
-
// ok, dynamic eval fails
|
|
230
|
-
return
|
|
237
|
+
if (err?.code === 'TAMAGUI_STATIC_EVALUATION_ERROR') {
|
|
238
|
+
throw err
|
|
231
239
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
/**
|
|
242
|
-
* Allow errors to happen, we're just reading config and components but sometimes external modules cause problems
|
|
243
|
-
* We can't fix every problem, so just swap them out with proxyWorm which is a sort of generic object that can be read.
|
|
244
|
-
*/
|
|
245
|
-
|
|
246
|
-
console.warn(
|
|
247
|
-
` [tamagui] skipped "${path}" (set TAMAGUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`
|
|
248
|
-
)
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return proxyWorm
|
|
240
|
+
const importer = this?.filename || this?.id || '<unknown module>'
|
|
241
|
+
const reason = err instanceof Error ? err.message : String(err)
|
|
242
|
+
const failedModule =
|
|
243
|
+
reason.match(/Cannot find native module ['"]([^'"]+)['"]/)?.[1] || path
|
|
244
|
+
throw new StaticEvaluationError(path, importer, failedModule, reason, {
|
|
245
|
+
cause: err,
|
|
246
|
+
})
|
|
252
247
|
}
|
|
253
248
|
}
|
|
254
249
|
|
|
255
250
|
return {
|
|
256
251
|
tamaguiRequire,
|
|
257
252
|
unregister: () => {
|
|
258
|
-
if (hasWarnedForModules.size) {
|
|
259
|
-
console.info(
|
|
260
|
-
` [tamagui] skipped loading ${hasWarnedForModules.size} module, see: https://tamagui.dev/docs/intro/errors#warning-001`
|
|
261
|
-
)
|
|
262
|
-
hasWarnedForModules.clear()
|
|
263
|
-
}
|
|
264
|
-
|
|
265
253
|
unregister()
|
|
266
254
|
isRegistered = false
|
|
267
255
|
Module.prototype.require = og
|
|
268
256
|
},
|
|
269
257
|
}
|
|
270
258
|
}
|
|
271
|
-
|
|
272
|
-
const IGNORES = process.env.TAMAGUI_IGNORE_BUNDLE_ERRORS
|
|
273
|
-
const extraIgnores =
|
|
274
|
-
IGNORES === 'true' ? [] : process.env.TAMAGUI_IGNORE_BUNDLE_ERRORS?.split(',')
|
|
275
|
-
|
|
276
|
-
const knownIgnorableModules = {
|
|
277
|
-
'@gorhom/bottom-sheet': true,
|
|
278
|
-
'expo-modules': true,
|
|
279
|
-
solito: true,
|
|
280
|
-
'expo-linear-gradient': true,
|
|
281
|
-
'@expo/vector-icons': true,
|
|
282
|
-
'tamagui/linear-gradient': true,
|
|
283
|
-
// animation libraries not needed for static extraction
|
|
284
|
-
'@emotion/is-prop-valid': true,
|
|
285
|
-
'framer-motion': true,
|
|
286
|
-
motion: true,
|
|
287
|
-
...Object.fromEntries(extraIgnores?.map((k) => [k, true]) || []),
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const hasWarnedForModules = new Set<string>()
|
|
291
|
-
|
|
292
|
-
const allowedIgnores = {
|
|
293
|
-
'expo-constants': true,
|
|
294
|
-
'./ExpoHaptics': true,
|
|
295
|
-
'./js/MaskedView': true,
|
|
296
|
-
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises'
|
|
2
|
+
import { dirname } from 'node:path'
|
|
3
|
+
import type { Plugin } from 'esbuild'
|
|
4
|
+
|
|
5
|
+
export const tamaguiStaticEvaluationModules = Object.freeze({
|
|
6
|
+
// react-native-safe-area-context evaluates its native codegen spec in Node and
|
|
7
|
+
// calls codegenNativeComponent, which is unavailable during static evaluation.
|
|
8
|
+
'react-native-safe-area-context': null,
|
|
9
|
+
// react-native-worklets initializes native JSI in Node, so static evaluation
|
|
10
|
+
// inlines the package's own mock while preserving the authored animation config.
|
|
11
|
+
// the vendor mock mutates _WORKLET, __RUNTIME_KIND, _log,
|
|
12
|
+
// _getAnimationTimestamp, and requestAnimationFrame in the compiler process.
|
|
13
|
+
'react-native-worklets': 'react-native-worklets/lib/module/mock.js',
|
|
14
|
+
} as const)
|
|
15
|
+
|
|
16
|
+
export function getStaticEvaluationModuleReplacement(moduleName: string) {
|
|
17
|
+
return Object.hasOwn(tamaguiStaticEvaluationModules, moduleName)
|
|
18
|
+
? tamaguiStaticEvaluationModules[
|
|
19
|
+
moduleName as keyof typeof tamaguiStaticEvaluationModules
|
|
20
|
+
]
|
|
21
|
+
: undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function isIgnoredStaticEvaluationModule(
|
|
25
|
+
moduleName: string,
|
|
26
|
+
userIgnoredModules: readonly string[] = []
|
|
27
|
+
) {
|
|
28
|
+
return (
|
|
29
|
+
getStaticEvaluationModuleReplacement(moduleName) !== undefined ||
|
|
30
|
+
userIgnoredModules.includes(moduleName)
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function staticEvaluationIgnorePlugin(
|
|
35
|
+
userIgnoredModules: readonly string[] = []
|
|
36
|
+
): Plugin {
|
|
37
|
+
return {
|
|
38
|
+
name: 'tamagui-static-evaluation-ignore',
|
|
39
|
+
setup(build) {
|
|
40
|
+
build.onResolve({ filter: /.*/ }, (args) => {
|
|
41
|
+
if (isIgnoredStaticEvaluationModule(args.path, userIgnoredModules)) {
|
|
42
|
+
return { path: args.path, namespace: 'tamagui-static-evaluation-ignore' }
|
|
43
|
+
}
|
|
44
|
+
return null
|
|
45
|
+
})
|
|
46
|
+
build.onLoad(
|
|
47
|
+
{ filter: /.*/, namespace: 'tamagui-static-evaluation-ignore' },
|
|
48
|
+
async (args) => {
|
|
49
|
+
const replacement = getStaticEvaluationModuleReplacement(args.path)
|
|
50
|
+
if (replacement) {
|
|
51
|
+
const resolved = await build.resolve(replacement, {
|
|
52
|
+
kind: 'require-call',
|
|
53
|
+
resolveDir: build.initialOptions.absWorkingDir || process.cwd(),
|
|
54
|
+
})
|
|
55
|
+
if (resolved.errors.length) {
|
|
56
|
+
return { errors: resolved.errors, warnings: resolved.warnings }
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
contents: await readFile(resolved.path, 'utf8'),
|
|
60
|
+
loader: 'js',
|
|
61
|
+
resolveDir: dirname(resolved.path),
|
|
62
|
+
warnings: resolved.warnings,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
contents: 'module.exports = {}',
|
|
67
|
+
loader: 'js',
|
|
68
|
+
resolveDir: build.initialOptions.absWorkingDir || process.cwd(),
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,109 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type * as t from '@babel/types'
|
|
3
|
-
import type { PseudoStyles, StaticConfig, TamaguiConfig } from '@tamagui/core'
|
|
4
|
-
import type { StyleObject } from '@tamagui/helpers'
|
|
5
|
-
import type { TamaguiOptions } from '@tamagui/types'
|
|
6
|
-
import type { ViewStyle } from 'react-native'
|
|
7
|
-
|
|
8
|
-
import type { LoadedComponents } from './extractor/bundleConfig'
|
|
9
|
-
|
|
10
|
-
export type TamaguiPlatform = 'native' | 'web'
|
|
11
|
-
|
|
12
|
-
export type { TamaguiOptions, TamaguiBuildOptions } from '@tamagui/types'
|
|
13
|
-
|
|
1
|
+
export type { TamaguiBuildOptions, TamaguiOptions } from '@tamagui/types'
|
|
14
2
|
export type { StyleObject } from '@tamagui/helpers'
|
|
15
3
|
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
export interface CacheObject {
|
|
19
|
-
[key: string]: any
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface LogOptions {
|
|
23
|
-
clear?: boolean
|
|
24
|
-
timestamp?: boolean
|
|
25
|
-
error?: Error | null
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface Logger {
|
|
29
|
-
info(msg: string, options?: LogOptions): void
|
|
30
|
-
warn(msg: string, options?: LogOptions): void
|
|
31
|
-
error(msg: string, options?: LogOptions): void
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type ExtractorOptions = {
|
|
35
|
-
logger?: Logger
|
|
36
|
-
platform?: TamaguiPlatform
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type ExtractedAttrAttr = {
|
|
40
|
-
type: 'attr'
|
|
41
|
-
value: t.JSXAttribute | t.JSXSpreadAttribute
|
|
42
|
-
extraClassNames?: string
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type ExtractedAttrStyle = {
|
|
46
|
-
type: 'style'
|
|
47
|
-
value: ViewStyle & PseudoStyles
|
|
48
|
-
attr?: t.JSXAttribute | t.JSXSpreadAttribute
|
|
49
|
-
name?: string
|
|
50
|
-
extraClassNames?: string
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type ExtractedTernaryAttr = {
|
|
54
|
-
type: 'ternary'
|
|
55
|
-
value: Ternary
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type ExtractedAttr = ExtractedAttrAttr | ExtractedTernaryAttr | ExtractedAttrStyle
|
|
59
|
-
|
|
60
|
-
export type ExtractTagProps = {
|
|
61
|
-
parserProps: TamaguiOptionsWithFileInfo
|
|
62
|
-
attrs: ExtractedAttr[]
|
|
63
|
-
node: t.JSXOpeningElement
|
|
64
|
-
attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any
|
|
65
|
-
flatNodeName?: string
|
|
66
|
-
jsxPath: NodePath<t.JSXElement>
|
|
67
|
-
programPath: NodePath<t.Program>
|
|
68
|
-
originalNodeName: string
|
|
69
|
-
lineNumbers: string
|
|
70
|
-
filePath: string
|
|
71
|
-
completeProps: Record<string, any>
|
|
72
|
-
staticConfig: StaticConfig
|
|
73
|
-
config: TamaguiConfig
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export type TamaguiOptionsWithFileInfo = TamaguiOptions & {
|
|
77
|
-
sourcePath?: string
|
|
78
|
-
allLoadedComponents: LoadedComponents[]
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type ExtractorParseProps = Omit<
|
|
82
|
-
TamaguiOptionsWithFileInfo,
|
|
83
|
-
'allLoadedComponents'
|
|
84
|
-
> & {
|
|
85
|
-
platform: TamaguiPlatform
|
|
86
|
-
shouldPrintDebug?: boolean | 'verbose'
|
|
87
|
-
onExtractTag: (props: ExtractTagProps) => void
|
|
88
|
-
getFlattenedNode?: (props: { isTextView: boolean; tag: string }) => string
|
|
89
|
-
extractStyledDefinitions?: boolean
|
|
90
|
-
// identifer, rule
|
|
91
|
-
onStyledDefinitionRule?: (identifier: string, rules: string[]) => void
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface Ternary {
|
|
95
|
-
test: t.Expression
|
|
96
|
-
remove: Function
|
|
97
|
-
consequent: object | null
|
|
98
|
-
alternate: object | null
|
|
99
|
-
fontFamily?: string
|
|
100
|
-
inlineMediaQuery?: string
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export type ClassNameToStyleObj = {
|
|
104
|
-
[key: string]: StyleObject
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface PluginContext {
|
|
108
|
-
write: (path: string, rules: { [key: string]: string }) => any
|
|
109
|
-
}
|
|
4
|
+
export type TamaguiPlatform = 'native' | 'web'
|