@tamagui/cli 2.7.7 → 3.0.0-beta.1093.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/add.cjs +76 -87
- package/dist/build.cjs +425 -278
- package/dist/cli.cjs +342 -340
- package/dist/generate-prompt.cjs +339 -359
- package/dist/generate.cjs +45 -54
- package/dist/index.cjs +1 -1
- package/dist/migrate.cjs +427 -0
- package/dist/setup-prompt.cjs +157 -0
- package/dist/to-tailwind-default-config.cjs +789 -0
- package/dist/to-tailwind.cjs +213 -0
- package/dist/update-template.cjs +43 -52
- package/dist/update.cjs +14 -18
- package/dist/upgrade.cjs +406 -398
- package/dist/utils.cjs +84 -101
- package/metro.cjs +1 -0
- package/metro.d.ts +1 -0
- package/metro.mjs +1 -0
- package/package.json +43 -13
- package/src/build.ts +594 -362
- package/src/cli.ts +96 -12
- package/src/generate-prompt.ts +16 -30
- package/src/migrate.ts +412 -0
- package/src/setup-prompt.ts +139 -0
- package/src/to-tailwind-default-config.ts +767 -0
- package/src/to-tailwind.ts +313 -0
- package/src/utils.ts +11 -9
- package/types/add.d.ts +1 -1
- package/types/add.d.ts.map +1 -1
- package/types/build.d.ts +2 -1
- package/types/build.d.ts.map +1 -1
- package/types/migrate.d.ts +7 -0
- package/types/migrate.d.ts.map +1 -0
- package/types/setup-prompt.d.ts +3 -0
- package/types/setup-prompt.d.ts.map +1 -0
- package/types/to-tailwind-default-config.d.ts +53 -0
- package/types/to-tailwind-default-config.d.ts.map +1 -0
- package/types/to-tailwind.d.ts +16 -0
- package/types/to-tailwind.d.ts.map +1 -0
- package/types/utils.d.ts.map +1 -1
- package/vite.cjs +1 -0
- package/vite.d.ts +1 -0
- package/vite.mjs +1 -0
package/src/cli.ts
CHANGED
|
@@ -3,30 +3,45 @@ import chalk from 'chalk'
|
|
|
3
3
|
|
|
4
4
|
import { disposeAll, getOptions } from './utils'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
;['exit', 'SIGINT'].forEach((_) => {
|
|
8
|
-
process.on(_, () => {
|
|
9
|
-
disposeAll()
|
|
10
|
-
process.exit()
|
|
11
|
-
})
|
|
12
|
-
})
|
|
6
|
+
process.on('exit', disposeAll)
|
|
13
7
|
|
|
14
8
|
const COMMAND_MAP = {
|
|
15
9
|
check: {
|
|
16
|
-
description: `Checks
|
|
10
|
+
description: `Checks flat style values, inconsistent versions, duplicate installs, lockfile issues, and missing config.`,
|
|
17
11
|
shorthands: [],
|
|
18
12
|
flags: {
|
|
19
13
|
'--help': Boolean,
|
|
20
14
|
'--debug': Boolean,
|
|
21
15
|
'--verbose': Boolean,
|
|
16
|
+
'--styles-only': Boolean,
|
|
17
|
+
'--deps-only': Boolean,
|
|
22
18
|
},
|
|
23
19
|
async run() {
|
|
24
20
|
const { _, ...flags } = arg(this.flags)
|
|
25
21
|
const options = await getOptions({
|
|
26
22
|
debug: flags['--debug'] ? (flags['--verbose'] ? 'verbose' : true) : false,
|
|
27
23
|
})
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
if (!flags['--styles-only']) {
|
|
25
|
+
const { checkDeps } = require('@tamagui/static/checkDeps')
|
|
26
|
+
await checkDeps(options.paths.root)
|
|
27
|
+
}
|
|
28
|
+
if (flags['--deps-only']) return
|
|
29
|
+
const { checkStyleFiles, formatCheckResults, MissingConfigArtifactError } =
|
|
30
|
+
require('@tamagui/language-service/check') as typeof import('@tamagui/language-service/check')
|
|
31
|
+
try {
|
|
32
|
+
const result = checkStyleFiles({
|
|
33
|
+
root: options.paths.root,
|
|
34
|
+
configPath: options.paths.conf,
|
|
35
|
+
})
|
|
36
|
+
console.info(formatCheckResults(result))
|
|
37
|
+
if (result.diagnosticCount > 0) process.exitCode = 1
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error instanceof MissingConfigArtifactError) {
|
|
40
|
+
console.warn(chalk.yellow(`skipping flat value check: ${error.message}`))
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
throw error
|
|
44
|
+
}
|
|
30
45
|
},
|
|
31
46
|
},
|
|
32
47
|
|
|
@@ -227,6 +242,68 @@ const COMMAND_MAP = {
|
|
|
227
242
|
},
|
|
228
243
|
},
|
|
229
244
|
|
|
245
|
+
setup: {
|
|
246
|
+
shorthands: [],
|
|
247
|
+
description: `Print an AI-agent prompt for adding Tamagui to a project for the first time`,
|
|
248
|
+
usage: `$ tamagui setup`,
|
|
249
|
+
flags: {
|
|
250
|
+
'--help': Boolean,
|
|
251
|
+
},
|
|
252
|
+
async run() {
|
|
253
|
+
const { printSetupPrompt } = require('./setup-prompt')
|
|
254
|
+
printSetupPrompt()
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
migrate: {
|
|
259
|
+
shorthands: [],
|
|
260
|
+
description: `Print an AI-agent prompt for migrating a Tamagui app to v3`,
|
|
261
|
+
usage: `$ tamagui migrate --from v2
|
|
262
|
+
$ tamagui migrate --from v1`,
|
|
263
|
+
flags: {
|
|
264
|
+
'--help': Boolean,
|
|
265
|
+
'--from': String,
|
|
266
|
+
},
|
|
267
|
+
async run() {
|
|
268
|
+
const { _, ...flags } = arg(this.flags)
|
|
269
|
+
const [_cmd, fromArg] = _
|
|
270
|
+
const { printMigrationPrompt } = require('./migrate')
|
|
271
|
+
|
|
272
|
+
printMigrationPrompt({
|
|
273
|
+
from: flags['--from'] || fromArg,
|
|
274
|
+
})
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
'to-tailwind': {
|
|
279
|
+
shorthands: [],
|
|
280
|
+
description: `Convert Tamagui JSX props in files or globs to Tailwind className syntax`,
|
|
281
|
+
flags: {
|
|
282
|
+
'--help': Boolean,
|
|
283
|
+
'--write': Boolean,
|
|
284
|
+
// path to the app's tamagui config so token/media/shorthand resolution uses the app's
|
|
285
|
+
// ACTUAL scales, not the bundled default fallback.
|
|
286
|
+
'--config': String,
|
|
287
|
+
// acknowledge use of the bundled default scales (required for --write without --config).
|
|
288
|
+
'--use-default-config': Boolean,
|
|
289
|
+
// opt in to DOM renaming (View→div). default: preserve Tamagui components (RN-safe).
|
|
290
|
+
'--rename-dom': Boolean,
|
|
291
|
+
},
|
|
292
|
+
async run() {
|
|
293
|
+
const { _, ...flags } = arg(this.flags)
|
|
294
|
+
const { toTailwind } = require('./to-tailwind')
|
|
295
|
+
const [_cmd, ...patterns] = _
|
|
296
|
+
|
|
297
|
+
await toTailwind({
|
|
298
|
+
patterns,
|
|
299
|
+
write: flags['--write'],
|
|
300
|
+
configPath: flags['--config'],
|
|
301
|
+
useDefaultConfig: flags['--use-default-config'],
|
|
302
|
+
renameDom: flags['--rename-dom'],
|
|
303
|
+
})
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
|
|
230
307
|
'update-template': {
|
|
231
308
|
shorthands: ['ut'],
|
|
232
309
|
description: `Used to update your git repo with the source template. (e.g. Takeout)`,
|
|
@@ -332,8 +409,13 @@ main()
|
|
|
332
409
|
async function main() {
|
|
333
410
|
if (flags['--help']) {
|
|
334
411
|
console.info(`\n$ tamagui ${command}: ${definition.description}\n`)
|
|
412
|
+
if ('usage' in definition && definition.usage) {
|
|
413
|
+
console.info(`Usage:\n${definition.usage}\n`)
|
|
414
|
+
}
|
|
335
415
|
console.info(
|
|
336
|
-
`Flags
|
|
416
|
+
`Flags:\n${Object.entries(definition.flags)
|
|
417
|
+
.map(([k, v]) => ` ${k} (${v.name})`)
|
|
418
|
+
.join('\n')}`
|
|
337
419
|
)
|
|
338
420
|
process.exit(0)
|
|
339
421
|
}
|
|
@@ -354,7 +436,9 @@ async function main() {
|
|
|
354
436
|
await definition.run()
|
|
355
437
|
} catch (err: any) {
|
|
356
438
|
console.error(`Error running command: ${err.message}`)
|
|
439
|
+
process.exit(1) // a thrown command error must be a NON-ZERO exit (safety: --write aborts)
|
|
357
440
|
}
|
|
358
441
|
|
|
359
|
-
|
|
442
|
+
// `check` sets exitCode when it finds problems; a literal 0 would erase it
|
|
443
|
+
process.exit(process.exitCode ?? 0)
|
|
360
444
|
}
|
package/src/generate-prompt.ts
CHANGED
|
@@ -83,8 +83,8 @@ function generateMarkdown(config: any): string {
|
|
|
83
83
|
if (settings.onlyAllowShorthands) {
|
|
84
84
|
sections.push('**You MUST use shorthand properties in this project.**\n\n')
|
|
85
85
|
sections.push('Full property names are not allowed. For example:\n')
|
|
86
|
-
sections.push('- ✅ `<View w="
|
|
87
|
-
sections.push('- ❌ `<View width="
|
|
86
|
+
sections.push('- ✅ `<View w="10" />` (correct)\n')
|
|
87
|
+
sections.push('- ❌ `<View width="10" />` (will error)\n\n')
|
|
88
88
|
sections.push(
|
|
89
89
|
'See the Shorthand Properties section below for all available shorthands.\n\n'
|
|
90
90
|
)
|
|
@@ -93,11 +93,9 @@ function generateMarkdown(config: any): string {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
if (settings.
|
|
97
|
-
sections.push(
|
|
98
|
-
|
|
99
|
-
)
|
|
100
|
-
if (settings.themeClassNameOnRoot) {
|
|
96
|
+
if (settings.addThemeClassName !== undefined) {
|
|
97
|
+
sections.push(`### Theme Class Name: \`${settings.addThemeClassName}\`\n\n`)
|
|
98
|
+
if (settings.addThemeClassName === 'html') {
|
|
101
99
|
sections.push('Theme classes are applied to the root HTML element.\n\n')
|
|
102
100
|
}
|
|
103
101
|
}
|
|
@@ -114,12 +112,6 @@ function generateMarkdown(config: any): string {
|
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
|
|
117
|
-
// Check for web-specific optimizations
|
|
118
|
-
if (settings.webContainerType) {
|
|
119
|
-
sections.push(`### Web Container Type: \`${settings.webContainerType}\`\n\n`)
|
|
120
|
-
sections.push('Enables web-specific container query optimizations.\n\n')
|
|
121
|
-
}
|
|
122
|
-
|
|
123
115
|
// Check for strictness settings (common patterns)
|
|
124
116
|
const configString = JSON.stringify(config.tamaguiConfig)
|
|
125
117
|
if (configString.includes('semi-strict-web')) {
|
|
@@ -347,22 +339,20 @@ function generateMarkdown(config: any): string {
|
|
|
347
339
|
sections.push('```\n\n')
|
|
348
340
|
|
|
349
341
|
sections.push('**Accessing theme values:**\n\n')
|
|
350
|
-
sections.push('Components
|
|
342
|
+
sections.push('Components access theme values by their bare names:\n\n')
|
|
351
343
|
sections.push('```tsx\n')
|
|
352
344
|
sections.push(
|
|
353
|
-
`<View ${getPropName('backgroundColor')}="
|
|
345
|
+
`<View ${getPropName('backgroundColor')}="background" ${getPropName('color')}="color" />\n`
|
|
354
346
|
)
|
|
355
347
|
sections.push('```\n\n')
|
|
356
348
|
|
|
357
349
|
sections.push('**Special props:**\n\n')
|
|
358
|
-
sections.push('- `inverse`:
|
|
350
|
+
sections.push('- `theme="inverse"`: Uses the opposite light or dark sub-theme\n')
|
|
359
351
|
sections.push('- `reset`: Reverts to grandparent theme\n\n')
|
|
360
352
|
|
|
361
353
|
// Tokens
|
|
362
354
|
sections.push('## Tokens\n\n')
|
|
363
|
-
sections.push(
|
|
364
|
-
'Tokens are design system values that can be referenced using the `$` prefix.\n\n'
|
|
365
|
-
)
|
|
355
|
+
sections.push('Tokens are design system values referenced by their bare names.\n\n')
|
|
366
356
|
|
|
367
357
|
const tokens = config.tamaguiConfig?.tokens || {}
|
|
368
358
|
|
|
@@ -459,22 +449,20 @@ function generateMarkdown(config: any): string {
|
|
|
459
449
|
|
|
460
450
|
// Token usage examples
|
|
461
451
|
sections.push('### Token Usage\n\n')
|
|
462
|
-
sections.push('Tokens can be used in component props
|
|
452
|
+
sections.push('Tokens can be used in component props by their bare names:\n\n')
|
|
463
453
|
sections.push('```tsx\n')
|
|
464
454
|
sections.push('// Space tokens - for margin, padding, gap\n')
|
|
465
455
|
sections.push(
|
|
466
|
-
`<View ${getPropName('padding')}="
|
|
456
|
+
`<View ${getPropName('padding')}="4" ${getPropName('gap')}="2" ${getPropName('margin')}="3" />\n\n`
|
|
467
457
|
)
|
|
468
458
|
sections.push('// Size tokens - for width, height, dimensions\n')
|
|
469
|
-
sections.push(
|
|
470
|
-
`<View ${getPropName('width')}="$10" ${getPropName('height')}="$6" />\n\n`
|
|
471
|
-
)
|
|
459
|
+
sections.push(`<View ${getPropName('width')}="10" ${getPropName('height')}="6" />\n\n`)
|
|
472
460
|
sections.push('// Color tokens - for colors and backgrounds\n')
|
|
473
461
|
sections.push(
|
|
474
|
-
`<View ${getPropName('backgroundColor')}="
|
|
462
|
+
`<View ${getPropName('backgroundColor')}="blue5" ${getPropName('color')}="gray12" />\n\n`
|
|
475
463
|
)
|
|
476
464
|
sections.push('// Radius tokens - for border-radius\n')
|
|
477
|
-
sections.push(`<View ${getPropName('borderRadius')}="
|
|
465
|
+
sections.push(`<View ${getPropName('borderRadius')}="4" />\n`)
|
|
478
466
|
sections.push('```\n\n')
|
|
479
467
|
|
|
480
468
|
// Media queries
|
|
@@ -495,14 +483,12 @@ function generateMarkdown(config: any): string {
|
|
|
495
483
|
'Media queries can be used as style props or with the `useMedia` hook:\n\n'
|
|
496
484
|
)
|
|
497
485
|
sections.push('```tsx\n')
|
|
498
|
-
sections.push('// As
|
|
486
|
+
sections.push('// As a clause in the same style value\n')
|
|
499
487
|
|
|
500
488
|
// Get first media query name as example
|
|
501
489
|
const firstMediaName = mediaEntries[0]?.[0]
|
|
502
490
|
if (firstMediaName) {
|
|
503
|
-
sections.push(
|
|
504
|
-
`<View ${getPropName('width')}="100%" $${firstMediaName}={{ ${getPropName('width')}: "50%" }} />\n\n`
|
|
505
|
-
)
|
|
491
|
+
sections.push(`<View ${getPropName('width')}="100% ${firstMediaName}:50%" />\n\n`)
|
|
506
492
|
}
|
|
507
493
|
|
|
508
494
|
sections.push('// Using the useMedia hook\n')
|
package/src/migrate.ts
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
type MigrationFrom = 'v1' | 'v2'
|
|
2
|
+
|
|
3
|
+
export function printMigrationPrompt({ from }: { from?: string }) {
|
|
4
|
+
process.stdout.write(getMigrationPrompt({ from }))
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getMigrationPrompt({ from }: { from?: string } = {}) {
|
|
8
|
+
const source = normalizeFrom(from)
|
|
9
|
+
|
|
10
|
+
if (source === 'v1') {
|
|
11
|
+
return `${promptHeader('v1', 'v3')}
|
|
12
|
+
|
|
13
|
+
${v1ToV2Prompt}
|
|
14
|
+
|
|
15
|
+
After the v1 to v2 pass is complete, apply the v2 to v3 pass below.
|
|
16
|
+
|
|
17
|
+
${v2ToV3Prompt}
|
|
18
|
+
`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return `${promptHeader('v2', 'v3')}
|
|
22
|
+
|
|
23
|
+
${v2ToV3Prompt}
|
|
24
|
+
`
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeFrom(from: string | undefined): MigrationFrom {
|
|
28
|
+
const value = (from || 'v2').toLowerCase().replace(/^from-?/, '')
|
|
29
|
+
|
|
30
|
+
if (value === '1' || value === 'v1') return 'v1'
|
|
31
|
+
if (value === '2' || value === 'v2') return 'v2'
|
|
32
|
+
|
|
33
|
+
throw new Error('Usage: tamagui migrate --from v2 | --from v1')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function promptHeader(from: string, to: string) {
|
|
37
|
+
return `You are migrating a Tamagui app from ${from} to ${to}.
|
|
38
|
+
|
|
39
|
+
Work like a careful coding agent:
|
|
40
|
+
|
|
41
|
+
- Read the app's Tamagui config, package manager, bundler, and component usage before editing.
|
|
42
|
+
- Keep changes scoped to the migration.
|
|
43
|
+
- Run the codemods listed below, then review the diff by hand.
|
|
44
|
+
- Do not publish packages, rotate secrets, or change production infrastructure.
|
|
45
|
+
- Validate with typecheck/build and at least one real app run or browser/native smoke test.
|
|
46
|
+
- Report any behavior that cannot be migrated mechanically.`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const v2ToV3Prompt = `## v2 -> v3 migration prompt
|
|
50
|
+
|
|
51
|
+
### 0. Choose the intermediate checkpoint before editing
|
|
52
|
+
|
|
53
|
+
The Tamagui package version and the config version are separate. Tamagui V3
|
|
54
|
+
supports Config v5; upgrading the runtime does not require Config v6.
|
|
55
|
+
|
|
56
|
+
- Coming from V2: first reach V3 packages and APIs with the app's existing token, theme, font, media, and animation values. Keep custom config values. If an old config entry is no longer exported, preserve its resolved values in an app-owned config; do not substitute v6 defaults.
|
|
57
|
+
- Coming from Config v5 or v5-subtle: keep that config during the V3 API upgrade. Keep the 12-step adaptive colors, spacing, radii, font scales, and breakpoint meanings. Do not remap them to the v6 scale.
|
|
58
|
+
- Already running V3 with Config v5: this intermediate checkpoint is valid. Inventory remaining V2 APIs before applying codemods; do not repeat completed work or treat Config v5 as an upgrade failure.
|
|
59
|
+
- Do not combine this pass with wholesale \`html.*\` adoption, Tailwind conversion, new skins, or a theme redesign unless separately requested.
|
|
60
|
+
|
|
61
|
+
Record the starting package/config versions and representative light/dark,
|
|
62
|
+
responsive, and native screenshots. Name the intended checkpoint in the plan:
|
|
63
|
+
"V3 API, existing design values." Visual changes during this pass need an
|
|
64
|
+
explanation or a fix, not automatic screenshot acceptance.
|
|
65
|
+
|
|
66
|
+
The checkpoint is complete when the required API migration, report review,
|
|
67
|
+
typecheck/build, and real app checks in step 15 pass. Leave Config v6 and other
|
|
68
|
+
optional design changes in a separate follow-up; do not start them just because
|
|
69
|
+
the V3 API work is finished.
|
|
70
|
+
|
|
71
|
+
### 1. Update dependencies
|
|
72
|
+
|
|
73
|
+
- Bump every \`tamagui\` and \`@tamagui/*\` package together to v3.
|
|
74
|
+
- Keep \`@tamagui/core\`, \`@tamagui/web\`, and \`tamagui\` deduped in the lockfile.
|
|
75
|
+
- Run:
|
|
76
|
+
|
|
77
|
+
\`\`\`bash
|
|
78
|
+
npx tamagui check
|
|
79
|
+
\`\`\`
|
|
80
|
+
|
|
81
|
+
### 2. Migrate tokens and conditional styles
|
|
82
|
+
|
|
83
|
+
V3 accepts bare token/theme names and flat clauses only. Run the transactional
|
|
84
|
+
flat-values codemod from your project root, dry run first:
|
|
85
|
+
|
|
86
|
+
\`\`\`bash
|
|
87
|
+
npx @tamagui/codemod-flat-values --report flat-values-report.md ./src
|
|
88
|
+
npx @tamagui/codemod-flat-values --write \\
|
|
89
|
+
--report flat-values-report.md \\
|
|
90
|
+
--json flat-values-report.json \\
|
|
91
|
+
./src
|
|
92
|
+
\`\`\`
|
|
93
|
+
|
|
94
|
+
For example, this V2 input:
|
|
95
|
+
|
|
96
|
+
\`\`\`tsx
|
|
97
|
+
<View bg="$background" hoverStyle={{ bg: '$backgroundHover' }} $sm={{ p: '$6' }} p="$4" />
|
|
98
|
+
\`\`\`
|
|
99
|
+
|
|
100
|
+
becomes:
|
|
101
|
+
|
|
102
|
+
\`\`\`tsx
|
|
103
|
+
<View bg="background hover:background-hover" p="4 sm:6" />
|
|
104
|
+
\`\`\`
|
|
105
|
+
|
|
106
|
+
Resolve every report row and rerun until the app has no V2 authoring. Do not
|
|
107
|
+
add a compatibility setting or restore condition-object parsing.
|
|
108
|
+
|
|
109
|
+
### 3. Preserve config values while migrating required APIs
|
|
110
|
+
|
|
111
|
+
- Existing Config v5 applications should keep \`@tamagui/config/v5\` or \`/v5-subtle\` while migrating incrementally. These are frozen static compatibility packs, so they preserve the V5 token and theme values but will not receive new theme-builder features.
|
|
112
|
+
- Import animations from \`@tamagui/config/animations-css\`, \`animations-rn\`, \`animations-reanimated\`, or \`animations-motion\`.
|
|
113
|
+
- Apps using Sheet or animated-number hooks with the CSS driver must import \`createAnimations\` from \`@tamagui/animations-css/extras\`. The root entry omits those hooks.
|
|
114
|
+
- Remove \`@tamagui/theme-builder\` and V5 builder imports from packages that no longer export them. Static \`@tamagui/themes/v5\`, \`/v5-subtle\`, and \`/v5-tokens\` imports remain supported.
|
|
115
|
+
- An app that GENERATES its v5 themes (\`createV5Theme\`, \`subtleChildrenThemes\`, \`createPalettes\`) has two ways to stay on v5 for this migration: run the builder once and serialize the result to a static literal, or import the same builders from \`@tamagui/config-v5\` (and \`@tamagui/config-v5/builder\`), the opt-in package that carries them. Take one of those when the themes are built from values the app only knows at runtime; the optional v6 recipe move in the appendix is a separate migration.
|
|
116
|
+
- Component names no longer select uppercase theme segments automatically. Replace component themes with explicit normal theme or \`level2\` boundaries in component skins.
|
|
117
|
+
|
|
118
|
+
Do not apply the v6 color remap or recipe conversion in the optional appendix
|
|
119
|
+
while keeping Config v5. Reserved API/theme-key spelling changes still apply;
|
|
120
|
+
preserve the resolved values behind the renamed keys.
|
|
121
|
+
|
|
122
|
+
### 4. Migrate Sheet anatomy
|
|
123
|
+
|
|
124
|
+
The flat-values codemod from step 2 rewrites every provable \`Sheet.Frame\` to
|
|
125
|
+
\`Sheet.Container\` with a \`Sheet.Background\` first child carrying the surface
|
|
126
|
+
props, and reports spreads and \`styled(Sheet.Frame, …)\` targets for review.
|
|
127
|
+
Check each rewritten callsite against these rules:
|
|
128
|
+
|
|
129
|
+
- Replace \`Sheet.Frame\` with \`Sheet.Container\` plus \`Sheet.Background\`.
|
|
130
|
+
- Keep layout props such as \`padding\`, \`gap\`, \`height\`, \`maxHeight\`, and flex props on \`Sheet.Container\`.
|
|
131
|
+
- Move visual surface props such as \`bg\`, \`borderRadius\`, \`elevation\`, and \`shadow*\` to \`Sheet.Background\`.
|
|
132
|
+
- Keep \`Sheet.Overlay\` as a direct child of \`Sheet\`.
|
|
133
|
+
- Add explicit clipping if old \`Sheet.Frame\` overflow clipping mattered.
|
|
134
|
+
- \`disableHideBottomOverflow\` belongs on \`Sheet.Background\`.
|
|
135
|
+
|
|
136
|
+
Before:
|
|
137
|
+
|
|
138
|
+
\`\`\`tsx
|
|
139
|
+
<Sheet>
|
|
140
|
+
<Sheet.Overlay />
|
|
141
|
+
<Sheet.Frame padding="$4" bg="$background" borderTopRadius="$6">
|
|
142
|
+
<Sheet.ScrollView>{children}</Sheet.ScrollView>
|
|
143
|
+
</Sheet.Frame>
|
|
144
|
+
</Sheet>
|
|
145
|
+
\`\`\`
|
|
146
|
+
|
|
147
|
+
After:
|
|
148
|
+
|
|
149
|
+
\`\`\`tsx
|
|
150
|
+
<Sheet>
|
|
151
|
+
<Sheet.Overlay />
|
|
152
|
+
<Sheet.Container padding="4">
|
|
153
|
+
<Sheet.Background bg="background" borderTopRadius="6" />
|
|
154
|
+
<Sheet.ScrollView>{children}</Sheet.ScrollView>
|
|
155
|
+
</Sheet.Container>
|
|
156
|
+
</Sheet>
|
|
157
|
+
\`\`\`
|
|
158
|
+
|
|
159
|
+
### 5. Remove deprecated v2 APIs
|
|
160
|
+
|
|
161
|
+
Search:
|
|
162
|
+
|
|
163
|
+
\`\`\`bash
|
|
164
|
+
rg "focusable|fullscreen|themeInverse|<Theme inverse|Sheet\\.Frame|styleable\\(|inlineWhenUnflattened|\\$true|getTokenRelative|stepTokenUpOrDown|forceRemoveScrollEnabled|sizeAdjust|getExpandedShorthands|usePropsAndStyle|useProps|useStyle"
|
|
165
|
+
\`\`\`
|
|
166
|
+
|
|
167
|
+
Replace:
|
|
168
|
+
|
|
169
|
+
- \`focusable\` -> \`tabIndex\`.
|
|
170
|
+
- \`fullscreen\` -> explicit \`position\` and \`inset\` props.
|
|
171
|
+
- \`themeInverse\` -> \`theme="inverse"\`.
|
|
172
|
+
- \`<Theme inverse>\` -> \`<Theme name="inverse">\`.
|
|
173
|
+
- \`Sheet.Frame\` -> \`Sheet.Container\` plus \`Sheet.Background\`.
|
|
174
|
+
- \`Component.styleable(fn)\` -> \`createStyledHOC(Component, fn)\` (same behavior, standalone function).
|
|
175
|
+
- forwardRef wrapper statics -> direct refs and normal composition.
|
|
176
|
+
- \`inlineWhenUnflattened\` -> remove it.
|
|
177
|
+
- deprecated UI kit aliases -> current component names.
|
|
178
|
+
- old platform style keys -> flat \`web:\`, \`native:\`, \`ios:\`, and \`android:\` clauses.
|
|
179
|
+
- \`forceRemoveScrollEnabled\` -> \`disableRemoveScroll\` with inverted intent.
|
|
180
|
+
- \`createCheckbox\` \`sizeAdjust\` -> explicit sizing math or component styles.
|
|
181
|
+
- \`getExpandedShorthands\` -> \`getExpandedShorthand(key, props)\` when behavior code needs one authored prop and must accept its configured shorthand.
|
|
182
|
+
- \`useProps\`, \`useStyle\`, and \`usePropsAndStyle\` -> keep conditional values on styled Tamagui components; use \`splitStyleProps\` only when a wrapper must partition authored props.
|
|
183
|
+
|
|
184
|
+
V2 could spread one style across its base prop, pseudo-style objects, media
|
|
185
|
+
objects, and platform objects. The removed hooks gathered those separate
|
|
186
|
+
objects into resolved props and styles. V3 keeps every base and conditional
|
|
187
|
+
clause for a style on that style's single property, for example
|
|
188
|
+
\`opacity="1 hover:0.7 sm:0.8"\`. The styled component interprets that value,
|
|
189
|
+
so a wrapper should pass it through instead of flattening the component's
|
|
190
|
+
styles in JavaScript.
|
|
191
|
+
|
|
192
|
+
\`splitStyleProps(props)\` returns \`[styleProps, regularProps]\` in one pass.
|
|
193
|
+
Pass \`{ expandShorthands: true }\` to canonicalize selected keys. Its optional
|
|
194
|
+
filter map selects only those canonical keys, leaving rejected style props in
|
|
195
|
+
the second object. The filter may instead be a callback receiving
|
|
196
|
+
\`(key, value, originalKey, isStyleProp)\`.
|
|
197
|
+
|
|
198
|
+
\`getExpandedShorthand(key, props)\` only chooses the longhand or configured
|
|
199
|
+
shorthand for one property. It does not resolve tokens or select the active
|
|
200
|
+
clause. Neither does \`splitStyleProps\`. Use \`useMedia()\` or \`useTheme()\`
|
|
201
|
+
when behavior itself needs active responsive or theme state.
|
|
202
|
+
|
|
203
|
+
### 6. Replace true tokens
|
|
204
|
+
|
|
205
|
+
- Default v3 configs no longer export the legacy \`$true\` token key.
|
|
206
|
+
- The codemod writes \`$true\` on style props as \`4\` and reports a \`legacy-true-token\` warning; confirm the app's config aliased it there.
|
|
207
|
+
- On \`size\`, \`elevation\`, and \`iconSize\` it writes the boolean \`true\`, which resolves to the component default size.
|
|
208
|
+
- Token definitions and custom variants are not edited; search them for the alias by hand.
|
|
209
|
+
- Do not change unrelated boolean props or boolean variant values.
|
|
210
|
+
|
|
211
|
+
### 7. Replace token stepping
|
|
212
|
+
|
|
213
|
+
Removed from \`@tamagui/get-token\`:
|
|
214
|
+
|
|
215
|
+
- \`stepTokenUpOrDown\`
|
|
216
|
+
- \`getTokenRelative\`
|
|
217
|
+
- the second options argument to \`getSize\`, \`getSpace\`, and \`getRadius\`
|
|
218
|
+
- \`shift\`, \`bounds\`, and \`excludeHalfSteps\`
|
|
219
|
+
|
|
220
|
+
Before:
|
|
221
|
+
|
|
222
|
+
\`\`\`tsx
|
|
223
|
+
const padding = getSize(size, { shift: -2 })
|
|
224
|
+
\`\`\`
|
|
225
|
+
|
|
226
|
+
After:
|
|
227
|
+
|
|
228
|
+
\`\`\`tsx
|
|
229
|
+
const padding = getVariableValue(getSize(size)) * 0.6
|
|
230
|
+
\`\`\`
|
|
231
|
+
|
|
232
|
+
Use explicit token keys when you need a named smaller or larger token. Use numeric multiplication when proportional sizing is intended.
|
|
233
|
+
|
|
234
|
+
### 8. Audit font size values
|
|
235
|
+
|
|
236
|
+
- \`fontSize={17}\` is a raw numeric platform value and keeps platform-default line-height behavior.
|
|
237
|
+
- \`fontSize="17px"\` is an exact pixel value.
|
|
238
|
+
- Configured font \`size\` and \`lineHeight\` tokens should use px strings when exact web pixels are intended.
|
|
239
|
+
- Convert custom config font tokens to px strings if exact pixels were intended.
|
|
240
|
+
|
|
241
|
+
### 9. Update FocusScope
|
|
242
|
+
|
|
243
|
+
- Function-as-children is removed. Pass JSX children directly.
|
|
244
|
+
- FocusScope renders a \`display: contents\` wrapper.
|
|
245
|
+
- Use \`noFocus\` for zero-focus mode when focus should be rejected entirely.
|
|
246
|
+
|
|
247
|
+
Before:
|
|
248
|
+
|
|
249
|
+
\`\`\`tsx
|
|
250
|
+
<FocusScope loop>
|
|
251
|
+
{({ ref, onKeyDown, tabIndex }) => (
|
|
252
|
+
<View ref={ref} onKeyDown={onKeyDown} tabIndex={tabIndex} />
|
|
253
|
+
)}
|
|
254
|
+
</FocusScope>
|
|
255
|
+
\`\`\`
|
|
256
|
+
|
|
257
|
+
After:
|
|
258
|
+
|
|
259
|
+
\`\`\`tsx
|
|
260
|
+
<FocusScope loop>
|
|
261
|
+
<View />
|
|
262
|
+
</FocusScope>
|
|
263
|
+
\`\`\`
|
|
264
|
+
|
|
265
|
+
### 10. Update Dialog, Popover, Select, and Adapt flows
|
|
266
|
+
|
|
267
|
+
- Dialog, Popover, and Select use one Adapt handoff model.
|
|
268
|
+
- Adapted Sheet content stays mounted through the sheet slide-out.
|
|
269
|
+
- Parts own their presence animation lifecycles.
|
|
270
|
+
- The \`onDidAnimate\` prop is replaced by the typed \`onTransition\` lifecycle: \`onTransition={(e) => e.phase === 'end' && e.cause === 'enter' && done()}\`.
|
|
271
|
+
- \`Popover.Content forceMount\` now matches Dialog semantics.
|
|
272
|
+
- \`Dialog.Content\` no longer accepts the old no-op \`size\` variant.
|
|
273
|
+
- Non-modal Dialog content no longer enables RemoveScroll while open.
|
|
274
|
+
- Remove internal imports such as \`useShowPopoverSheet\`, \`PopoverAdaptHiddenContext\`, or \`useSelectBreakpointActive\` if the app used them.
|
|
275
|
+
|
|
276
|
+
### 11. Update Select
|
|
277
|
+
|
|
278
|
+
- Keep \`name\` when Select participates in a form. Remove the unsupported \`autoComplete\` prop.
|
|
279
|
+
- Use \`Select.Separator\` for visual grouping.
|
|
280
|
+
- \`Select.Content\` accepts \`onEscapeKeyDown\` and \`onInteractOutside\`.
|
|
281
|
+
- \`Select.Trigger\` and web \`Select.Viewport\` expose \`data-state="open" | "closed"\`.
|
|
282
|
+
|
|
283
|
+
### 12. Update themed icons
|
|
284
|
+
|
|
285
|
+
- \`<Icon size="4" />\` now resolves through the current font's \`font.size['4']\` scale.
|
|
286
|
+
- Raw numeric icon sizes are unchanged.
|
|
287
|
+
- Themed icons no longer accept Tamagui media or pseudo props directly.
|
|
288
|
+
- Wrap icons in a styled \`View\` for media and state clauses.
|
|
289
|
+
|
|
290
|
+
### 13. Check ScrollView web usage
|
|
291
|
+
|
|
292
|
+
\`@tamagui/scroll-view\` now has its own web implementation. It supports \`scrollTo\`, \`scrollToEnd\`, \`getScrollableNode\`, RN-shaped \`onScroll\`, \`contentContainerStyle\`, \`horizontal\`, and indicator props.
|
|
293
|
+
|
|
294
|
+
Replace unsupported old web/lite usage such as momentum events, \`snapTo*\`, and \`keyboardDismissMode\`.
|
|
295
|
+
|
|
296
|
+
### 14. Optional Tailwind frontend
|
|
297
|
+
|
|
298
|
+
Skip this in the intermediate V3 API checkpoint unless Tailwind adoption was
|
|
299
|
+
separately requested. It does not require changing the whole app to Config v6.
|
|
300
|
+
|
|
301
|
+
Tailwind authoring is selected by the component package, with no global config:
|
|
302
|
+
|
|
303
|
+
\`\`\`tsx
|
|
304
|
+
import { View, Text, styled } from '@tamagui/tailwind'
|
|
305
|
+
\`\`\`
|
|
306
|
+
|
|
307
|
+
Keep importing regular Tamagui components from \`tamagui\` or
|
|
308
|
+
\`@tamagui/core\`. Do not mix utility classes and Tamagui style props on the
|
|
309
|
+
same component; choose the import whose styling language that component uses.
|
|
310
|
+
|
|
311
|
+
### 15. Verification
|
|
312
|
+
|
|
313
|
+
- Run \`npx tamagui check\`.
|
|
314
|
+
- Run typecheck and build.
|
|
315
|
+
- Start the app and manually test screens using Sheet, Dialog, Popover, Select, FocusScope, icons, and ScrollView.
|
|
316
|
+
- Test Adapt breakpoints where popovers/selects/dialogs become sheets.
|
|
317
|
+
- Verify keyboard focus, Escape, outside click, scroll locking, and close animations.
|
|
318
|
+
- Inspect icon alignment next to text at each app size token.
|
|
319
|
+
- If the Tailwind frontend is used, compare web and native output for the classes used.
|
|
320
|
+
- Compare the same screens and resolved control dimensions with the baseline. Keeping Config v5 preserves the scales, but does not prove that changed component APIs preserve every layout.
|
|
321
|
+
- Report the final package version, retained config, manual fixes, runtime evidence, and deferred optional work. A validated V3 app on Config v5 is a completed migration.
|
|
322
|
+
|
|
323
|
+
### Optional follow-up: Config v6, only when separately requested
|
|
324
|
+
|
|
325
|
+
This appendix is not part of the intermediate V3 API checkpoint. Start a new
|
|
326
|
+
reviewable change after that checkpoint is validated. Record new visual
|
|
327
|
+
acceptance criteria before changing design values.
|
|
328
|
+
|
|
329
|
+
- New apps can start with \`defaultConfig\` from \`@tamagui/config/v6\`.
|
|
330
|
+
- For an existing app, inventory and compare resolved spacing, size, radius, font, icon, and media values. Map by resolved value when preserving appearance; the same token name can mean a different number in v6.
|
|
331
|
+
- Preserve breakpoint meaning: changing a max-width key to a min-width key can invert responsive behavior.
|
|
332
|
+
|
|
333
|
+
- Use \`createThemes\`, \`levels\`, scales, and the other recipe helpers from \`@tamagui/themes/builder\`.
|
|
334
|
+
- Remove \`componentThemes\`, \`templates\`, \`masks\`, \`childrenThemes\`, and \`grandChildrenThemes\`. Express hierarchy in the recipe tree, semantic values in scales, and exact one-theme overrides in \`values\`.
|
|
335
|
+
|
|
336
|
+
Rename the adaptive 12-step ramp approximately:
|
|
337
|
+
|
|
338
|
+
- \`color1\` -> \`color1\`
|
|
339
|
+
- \`color2\` -> \`color2\`
|
|
340
|
+
- \`color3\` -> \`color3\`
|
|
341
|
+
- \`color4\` -> \`color4\`
|
|
342
|
+
- \`color5\` -> \`color5\`
|
|
343
|
+
- \`color6\` and \`color7\` -> \`color6\`
|
|
344
|
+
- \`color8\` -> \`color7\`
|
|
345
|
+
- \`color9\` -> \`color8\`
|
|
346
|
+
- \`color10\` -> \`color9\`
|
|
347
|
+
- \`color11\` -> \`color10\`
|
|
348
|
+
- \`color12\` -> \`color11\`
|
|
349
|
+
|
|
350
|
+
The endpoints are exact; inspect contrast in the compressed middle. Replace
|
|
351
|
+
\`surface1\` with \`level2\`, \`surface2\` with \`level3\`, and \`surface3\`
|
|
352
|
+
or \`surface4\` with \`level4\`. Levels are relative and preserve a surrounding
|
|
353
|
+
color theme when nested.
|
|
354
|
+
|
|
355
|
+
Search the config and application together:
|
|
356
|
+
|
|
357
|
+
\`\`\`bash
|
|
358
|
+
rg "@tamagui/theme-builder|v5-builder|createV5Theme|componentThemes|grandChildrenThemes|surface[1-4]|color12"
|
|
359
|
+
\`\`\`
|
|
360
|
+
|
|
361
|
+
Validate the config change separately with light/dark screenshots, responsive
|
|
362
|
+
layouts, text and icon alignment, and every platform the app ships. Do not
|
|
363
|
+
accept visual drift merely because the codemod and typecheck are green.`
|
|
364
|
+
|
|
365
|
+
const v1ToV2Prompt = `## v1 -> v2 migration pass
|
|
366
|
+
|
|
367
|
+
Bring the app to the v2 baseline before applying v3 changes.
|
|
368
|
+
|
|
369
|
+
### Requirements
|
|
370
|
+
|
|
371
|
+
- React 19+
|
|
372
|
+
- React Native 0.81+ with New Architecture support
|
|
373
|
+
- TypeScript 5+
|
|
374
|
+
|
|
375
|
+
### Config
|
|
376
|
+
|
|
377
|
+
- Preserve the app's existing token, theme, font, and breakpoint values while reaching the v2 API baseline. Keep supported Config v5 imports or serialize the old generated config into app-owned values when an entry is no longer exported. Config v6 is a separate optional migration after the v3 checkpoint below.
|
|
378
|
+
- Import animations separately from \`@tamagui/config/animations-css\`, \`animations-rn\`, \`animations-reanimated\`, or \`animations-motion\`.
|
|
379
|
+
- Move root \`createTamagui\` settings into \`settings\`.
|
|
380
|
+
- Account for the defaults \`flexBasis: 0\` and \`position: static\`. Use \`styleCompat: 'legacy'\` or explicit props if needed.
|
|
381
|
+
- Rename media queries: \`$2xl\` -> \`$xxl\`, \`$2xs\` -> \`$xxs\`, and max queries to kebab-case such as \`$max-md\`.
|
|
382
|
+
- Preserve resolved colors and themes; defer v6 recipe conversion to the optional follow-up below.
|
|
383
|
+
|
|
384
|
+
### v1 prop and API changes
|
|
385
|
+
|
|
386
|
+
- \`animation\` -> \`transition\`.
|
|
387
|
+
- \`AnimationProp\` -> \`TransitionProp\`.
|
|
388
|
+
- \`tag\` -> \`render\`.
|
|
389
|
+
- \`Stack\` -> \`View\`.
|
|
390
|
+
- \`StackProps\` -> \`ViewProps\`.
|
|
391
|
+
- \`space\` and \`spaceDirection\` -> \`gap\`.
|
|
392
|
+
- \`themeInverse\` and \`<Theme inverse>\` -> \`theme="inverse"\` and \`<Theme name="inverse">\`.
|
|
393
|
+
- \`onHoverIn\` / \`onHoverOut\` -> \`onPointerEnter\` / \`onPointerLeave\` or mouse events.
|
|
394
|
+
- \`ellipse\` -> \`numberOfLines={1}\`.
|
|
395
|
+
- React Native accessibility props -> ARIA/web equivalents where applicable.
|
|
396
|
+
- React Native shadow props -> \`boxShadow\`.
|
|
397
|
+
|
|
398
|
+
### v1 component changes
|
|
399
|
+
|
|
400
|
+
- Input and Image prefer web-standard props such as \`type\`, \`inputMode\`, \`src\`, \`alt\`, and \`objectFit\`.
|
|
401
|
+
- Button and ListItem no longer take direct text style props. Style text through child components.
|
|
402
|
+
- Tabs uses \`Tabs.Tab\` instead of \`Tabs.Trigger\`; \`activationMode\` defaults to \`manual\`.
|
|
403
|
+
- Group requires \`Group.Item\`; remove old separator/space/scrollable auto-cloning props.
|
|
404
|
+
- Replace old \`Popover.Sheet\` subcomponents with standalone \`Sheet\` inside \`Adapt\`.
|
|
405
|
+
- Add native setup imports where needed: \`@tamagui/native/setup-teleport\`, \`setup-gesture-handler\`, \`setup-expo-ui-menu\` or \`setup-zeego\`, \`setup-burnt\`, and linear-gradient setup.
|
|
406
|
+
|
|
407
|
+
### v1 -> v2 verification
|
|
408
|
+
|
|
409
|
+
- Run the app before starting v3 changes.
|
|
410
|
+
- Verify layout affected by flex/position defaults.
|
|
411
|
+
- Verify forms, tabs, groups, portals, native sheets, and Input/Image behavior.
|
|
412
|
+
- Commit the v1 -> v2 migration separately if possible.`
|