@tamagui/codemod-flat-values 3.0.0-beta.807.1 → 3.0.0-beta.831.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/README.md CHANGED
@@ -77,7 +77,7 @@ helper, a `react-native` component, and an intrinsic tag are all left alone —
77
77
  literals is rewritten in place (`active ? '$red10' : '$blue10'`), and an expression
78
78
  whose type the checker can prove interpolates into the program
79
79
  (`` backgroundColor={`${GREEN} disabled:${GREY}`} ``).
80
- - Variant and compound-variant branches convert as their own style objects, so a
80
+ - Variant branches convert as their own style objects, so a
81
81
  branch contributes at its own position in the forward pass. No base is invented for
82
82
  a condition-only branch: with clause-level merge (decision 21)
83
83
  `exitStyle={{ x: 10 }}` is exactly `x="exit:10px"`, which keeps whatever base the
package/dist/index.mjs CHANGED
@@ -163,22 +163,6 @@ function variantSites(config, label, registry, containers, targets, host, write2
163
163
  }
164
164
  }
165
165
  }
166
- const compound = config.getProperty("compoundVariants");
167
- if (Node.isPropertyAssignment(compound)) {
168
- const array = unwrapExpression(compound.getInitializerOrThrow());
169
- if (Node.isArrayLiteralExpression(array)) {
170
- for (const [index, element] of array.getElements().entries()) {
171
- const entry = unwrapExpression(element);
172
- if (!Node.isObjectLiteralExpression(entry)) continue;
173
- const style = entry.getProperty("style");
174
- if (!Node.isPropertyAssignment(style)) continue;
175
- for (const object of variantStyleObjects(style.getInitializerOrThrow())) {
176
- const site = convertStyleObject(object, "styled", `${label} compoundVariants[${index}]`, registry, containers, targets, host, write2);
177
- if (site) sites.push(site);
178
- }
179
- }
180
- }
181
- }
182
166
  return sites;
183
167
  }
184
168
  function conversionTargets(filePath) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["index.js"],"sourcesContent":["#!/usr/bin/env node\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, relative, resolve } from \"node:path\";\nimport { resolveTamaguiHost } from \"@tamagui/language-service/host\";\nimport { stylePropsTextOnly } from \"@tamagui/helpers\";\nimport {\n ModuleKind,\n ModuleResolutionKind,\n Node,\n Project,\n ScriptTarget,\n SyntaxKind,\n ts\n} from \"ts-morph\";\nimport { planContainers } from \"./containers\";\nimport { convertJsxSite, convertStyleObject } from \"./convert\";\nimport { compact, unwrapExpression } from \"./expressions\";\nimport {\n codemodMediaNames,\n createModifierRegistry,\n grammarPlatformNames\n} from \"./grammar\";\nimport { createProvenance } from \"./provenance\";\nimport { renderReport } from \"./report\";\nconst projectRoot = process.cwd();\nconst defaultReportPath = resolve(projectRoot, \"tamagui-flat-values-report.md\");\nconst ignoreMarker = \".tamagui-flat-values-ignore\";\nconst ignoredDirectories = /* @__PURE__ */ new Map();\nfunction isIgnored(filePath) {\n let directory = dirname(filePath);\n const visited = [];\n while (directory === projectRoot || !relative(projectRoot, directory).startsWith(\"..\")) {\n const cached = ignoredDirectories.get(directory);\n if (cached !== void 0) {\n for (const seen of visited) ignoredDirectories.set(seen, cached);\n return cached;\n }\n visited.push(directory);\n if (existsSync(resolve(directory, ignoreMarker))) {\n for (const seen of visited) ignoredDirectories.set(seen, true);\n return true;\n }\n if (directory === projectRoot) break;\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n for (const seen of visited) ignoredDirectories.set(seen, false);\n return false;\n}\nfunction collectFiles(inputs2) {\n const tsConfigFilePath = resolve(projectRoot, \"tsconfig.json\");\n if (!existsSync(tsConfigFilePath)) {\n console.error(\n `no tsconfig.json in ${projectRoot}; run the codemod from your project root`\n );\n process.exit(2);\n }\n const project = new Project({\n tsConfigFilePath,\n skipAddingFilesFromTsConfig: true,\n compilerOptions: {\n allowJs: false,\n jsx: 4,\n target: ScriptTarget.ES2020,\n module: ModuleKind.ESNext,\n moduleResolution: ModuleResolutionKind.NodeJs,\n skipLibCheck: true,\n strictNullChecks: true,\n baseUrl: projectRoot\n }\n });\n const files2 = /* @__PURE__ */ new Map();\n const ignored = /* @__PURE__ */ new Set();\n const missing = [];\n for (const input of inputs2) {\n const path = resolve(projectRoot, input);\n if (!existsSync(path)) {\n missing.push(input);\n continue;\n }\n const pattern = /\\.[cm]?[jt]sx?$/.test(path) ? path : `${path}/**/*.{ts,tsx}`;\n const matched = project.addSourceFilesAtPaths(pattern);\n if (!matched.length) missing.push(input);\n for (const file of matched) {\n const filePath = file.getFilePath();\n if (isIgnored(filePath)) ignored.add(filePath);\n else files2.set(filePath, file);\n }\n }\n if (missing.length) {\n console.error(\n `no source file matched ${missing.map((input) => `\"${input}\"`).join(\", \")}`\n );\n process.exit(2);\n }\n if (files2.size === 0 && ignored.size > 0) {\n console.error(\n `all ${ignored.size} matched source ${ignored.size === 1 ? \"file was\" : \"files were\"} skipped by ${ignoreMarker}; no migration report was written`\n );\n process.exit(2);\n }\n return {\n sourceFiles: [...files2.values()].sort(\n (left, right) => left.getFilePath().localeCompare(right.getFilePath())\n ),\n ignoredFiles: ignored.size\n };\n}\nfunction themeNames(sourceFiles2) {\n const names = /* @__PURE__ */ new Set([\"light\", \"dark\"]);\n for (const sourceFile of sourceFiles2) {\n for (const name of conditionNames(sourceFile)) {\n if (name.startsWith(\"$theme-\")) names.add(name.slice(\"$theme-\".length));\n }\n }\n return names;\n}\nfunction mediaNames(sourceFiles2) {\n const names = new Set(codemodMediaNames);\n for (const sourceFile of sourceFiles2) {\n for (const name of conditionNames(sourceFile)) {\n if (!name.startsWith(\"$\")) continue;\n if (name.startsWith(\"$theme-\") || name.startsWith(\"$platform-\") || name.startsWith(\"$group-\") || grammarPlatformNames.has(name.slice(1))) {\n continue;\n }\n names.add(name.slice(1));\n }\n }\n return names;\n}\nfunction conditionNames(sourceFile) {\n const names = [];\n for (const attribute of sourceFile.getDescendantsOfKind(SyntaxKind.JsxAttribute)) {\n const name = attribute.getNameNode();\n if (Node.isIdentifier(name)) names.push(name.getText());\n }\n for (const property of sourceFile.getDescendantsOfKind(SyntaxKind.PropertyAssignment)) {\n const name = property.getNameNode();\n if (Node.isComputedPropertyName(name)) continue;\n names.push(name.getText().replace(/^['\"]|['\"]$/g, \"\"));\n }\n return names;\n}\nfunction variantStyleObjects(value) {\n const current = unwrapExpression(value);\n if (Node.isObjectLiteralExpression(current)) return [current];\n if (Node.isConditionalExpression(current)) {\n return [\n ...variantStyleObjects(current.getWhenTrue()),\n ...variantStyleObjects(current.getWhenFalse())\n ];\n }\n if (Node.isArrowFunction(current) || Node.isFunctionExpression(current)) {\n const body = current.getBody();\n if (Node.isBlock(body)) {\n return body.getDescendantsOfKind(SyntaxKind.ReturnStatement).flatMap((statement) => {\n const returned = statement.getExpression();\n return returned ? variantStyleObjects(returned) : [];\n });\n }\n return variantStyleObjects(body);\n }\n return [];\n}\nfunction variantSites(config, label, registry, containers, targets, host, write2) {\n const sites = [];\n const variants = config.getProperty(\"variants\");\n if (Node.isPropertyAssignment(variants)) {\n const object = unwrapExpression(variants.getInitializerOrThrow());\n if (Node.isObjectLiteralExpression(object)) {\n for (const variant of object.getProperties()) {\n if (!Node.isPropertyAssignment(variant)) continue;\n const variantName = compact(variant.getNameNode().getText());\n const branches = unwrapExpression(variant.getInitializerOrThrow());\n if (!Node.isObjectLiteralExpression(branches)) continue;\n for (const branch of branches.getProperties()) {\n if (!Node.isPropertyAssignment(branch)) continue;\n const branchName = compact(branch.getNameNode().getText());\n for (const style of variantStyleObjects(branch.getInitializerOrThrow())) {\n const site = convertStyleObject(\n style,\n \"styled\",\n `${label} variants.${variantName}.${branchName}`,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n }\n }\n }\n }\n const compound = config.getProperty(\"compoundVariants\");\n if (Node.isPropertyAssignment(compound)) {\n const array = unwrapExpression(compound.getInitializerOrThrow());\n if (Node.isArrayLiteralExpression(array)) {\n for (const [index, element] of array.getElements().entries()) {\n const entry = unwrapExpression(element);\n if (!Node.isObjectLiteralExpression(entry)) continue;\n const style = entry.getProperty(\"style\");\n if (!Node.isPropertyAssignment(style)) continue;\n for (const object of variantStyleObjects(style.getInitializerOrThrow())) {\n const site = convertStyleObject(\n object,\n \"styled\",\n `${label} compoundVariants[${index}]`,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n }\n }\n }\n return sites;\n}\nfunction conversionTargets(filePath) {\n if (/\\.web\\.[cm]?[jt]sx?$/.test(filePath)) return \"web\";\n if (/\\.native\\.[cm]?[jt]sx?$/.test(filePath)) return \"native\";\n return \"shared\";\n}\nfunction typeAwareHost(node) {\n const checker = node.getProject().getTypeChecker().compilerObject;\n const host = resolveTamaguiHost(\n checker,\n node.compilerNode\n );\n if (!host || node.getText() !== \"View\") return host;\n return {\n ...host,\n accepts: (property) => !(property in stylePropsTextOnly) && host.accepts(property)\n };\n}\nfunction inspectFile(sourceFile, registry, provenance2, write2) {\n const containers = planContainers(sourceFile, registry);\n const targets = conversionTargets(sourceFile.getFilePath());\n const sites = [];\n const styledCalls = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).filter((call) => provenance2.isTamaguiStyledCall(call)).sort((left, right) => right.getStart() - left.getStart());\n const jsxOpenings = [\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n ].filter((opening) => provenance2.isTamaguiElement(opening)).sort((left, right) => right.getStart() - left.getStart());\n for (const opening of jsxOpenings) {\n const site = convertJsxSite(\n opening,\n registry,\n containers,\n targets,\n typeAwareHost(opening.getTagNameNode()),\n write2\n );\n if (site) sites.push(site);\n }\n for (const call of styledCalls) {\n const component = call.getArguments()[0];\n const host = component ? typeAwareHost(component) : void 0;\n const config = unwrapExpression(\n call.getArguments()[1] ?? call\n );\n if (!Node.isObjectLiteralExpression(config)) continue;\n const label = `styled(${compact(call.getArguments()[0]?.getText() ?? \"unknown\")}, \\u2026)`;\n sites.push(...variantSites(config, label, registry, containers, targets, host, write2));\n const site = convertStyleObject(\n config,\n \"styled\",\n label,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n sites.sort(\n (left, right) => left.line - right.line || left.label.localeCompare(right.label)\n );\n return { file: relative(projectRoot, sourceFile.getFilePath()), sites };\n}\nconst usage = `Converts Tamagui style syntax to V3 flat property values and reports what it cannot convert.\n\n npx @tamagui/codemod-flat-values [options] <files or directories...>\n\n --report <path> where to write the Markdown report (default: ${relative(\n projectRoot,\n defaultReportPath\n)})\n --json <path> also write the machine-readable report\n --write rewrite every statically safe conversion in place\n --help print this\n\nRun it from your project root, which is where paths and the tsconfig resolve from.\nSource files are only written with --write.`;\nfunction parseArguments(argv) {\n const inputs2 = [];\n let reportPath2 = defaultReportPath;\n let jsonPath2 = null;\n let write2 = false;\n for (let index = 0; index < argv.length; index++) {\n const argument = argv[index];\n if (argument === \"--help\" || argument === \"-h\") {\n console.log(usage);\n process.exit(0);\n }\n if (argument === \"--write\") {\n write2 = true;\n continue;\n }\n if (argument === \"--report\" || argument === \"--json\") {\n const next = argv[index + 1];\n if (!next) {\n console.error(`${argument} requires a path\n\n${usage}`);\n process.exit(2);\n }\n if (argument === \"--report\") reportPath2 = resolve(next);\n else jsonPath2 = resolve(next);\n index++;\n continue;\n }\n if (argument.startsWith(\"-\")) {\n console.error(`unknown option \"${argument}\"\n\n${usage}`);\n process.exit(2);\n }\n inputs2.push(argument);\n }\n if (!inputs2.length) {\n console.error(`no files or directories given\n\n${usage}`);\n process.exit(2);\n }\n return { reportPath: reportPath2, jsonPath: jsonPath2, inputs: inputs2, write: write2 };\n}\nconst { reportPath, jsonPath, inputs, write } = parseArguments(process.argv.slice(2));\nconst { sourceFiles, ignoredFiles } = collectFiles(inputs);\nfor (const sourceFile of sourceFiles) {\n const diagnostics = sourceFile.compilerNode.parseDiagnostics;\n if (diagnostics?.length) {\n console.error(\n `${relative(projectRoot, sourceFile.getFilePath())}: source has parse errors; no files were written`\n );\n process.exit(2);\n }\n}\nconst originals = new Map(\n sourceFiles.map((sourceFile) => [sourceFile.getFilePath(), sourceFile.getFullText()])\n);\nconst modifierRegistry = createModifierRegistry({\n mediaNames: mediaNames(sourceFiles),\n themeNames: themeNames(sourceFiles)\n});\nconst provenance = createProvenance();\nconst files = sourceFiles.map(\n (sourceFile) => inspectFile(sourceFile, modifierRegistry.registry, provenance, write)\n);\nif (write) {\n for (const sourceFile of sourceFiles) {\n const filePath = sourceFile.getFilePath();\n const parsed = ts.createSourceFile(\n filePath,\n sourceFile.getFullText(),\n ScriptTarget.Latest,\n true,\n filePath.endsWith(\"x\") ? ts.ScriptKind.TSX : ts.ScriptKind.TS\n );\n if (parsed.parseDiagnostics?.length) {\n const details = parsed.parseDiagnostics.map((diagnostic) => {\n const start = diagnostic.start ?? 0;\n const position = parsed.getLineAndCharacterOfPosition(start);\n const line = parsed.text.split(/\\r?\\n/)[position.line] ?? \"\";\n return `${position.line + 1}:${position.character + 1} ${ts.flattenDiagnosticMessageText(\n diagnostic.messageText,\n \"\\n\"\n )}\n ${line.trim()}`;\n }).join(\"\\n\");\n console.error(\n `${relative(projectRoot, filePath)}: rewrite produced parse errors; no files were written\n${details}`\n );\n process.exit(2);\n }\n }\n}\nconst { text, summary } = renderReport(\n files,\n inputs.map((input) => relative(projectRoot, resolve(projectRoot, input))),\n modifierRegistry.diagnostics,\n ignoredFiles,\n write\n);\nmkdirSync(dirname(reportPath), { recursive: true });\nwriteFileSync(reportPath, text);\nif (jsonPath !== null) {\n mkdirSync(dirname(jsonPath), { recursive: true });\n writeFileSync(jsonPath, `${JSON.stringify({ files, summary }, null, 2)}\n`);\n}\nlet written = 0;\nif (write) {\n for (const sourceFile of sourceFiles) {\n const next = sourceFile.getFullText();\n if (next === originals.get(sourceFile.getFilePath())) continue;\n writeFileSync(sourceFile.getFilePath(), next);\n written++;\n }\n}\nconsole.log(`wrote ${reportPath}`);\nif (write) console.log(`rewrote ${written} source files`);\nconsole.log(\n `${summary.sites} sites: ${summary.clean - summary.waiting} clean, ${summary.needsRelocation} need relocation, ${summary.unknownHost} unknown host, ${summary.ineligible} ineligible, ${summary.waiting} waiting on runtime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MAAM,OAAO,WAAW,YAAY;EACpC,IAAI,SAAS,UAAU,IAAI,WAAW,YAAY,CAAC,GAAG;EACtD,cAAc,WAAW,YAAY,GAAG,IAAI;EAC5C;CACF;AACF;AACA,QAAQ,IAAI,SAAS,YAAY;AACjC,IAAI,OAAO,QAAQ,IAAI,WAAW,QAAQ,cAAc;AACxD,QAAQ,IACN,GAAG,QAAQ,MAAM,UAAU,QAAQ,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,gBAAgB,oBAAoB,QAAQ,YAAY,iBAAiB,QAAQ,WAAW,eAAe,QAAQ,QAAQ,+BAA+B,QAAQ,QAAQ,mBAAmB,QAAQ,aAAa,sBACjS"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["index.js"],"sourcesContent":["#!/usr/bin/env node\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, relative, resolve } from \"node:path\";\nimport { resolveTamaguiHost } from \"@tamagui/language-service/host\";\nimport { stylePropsTextOnly } from \"@tamagui/helpers\";\nimport {\n ModuleKind,\n ModuleResolutionKind,\n Node,\n Project,\n ScriptTarget,\n SyntaxKind,\n ts\n} from \"ts-morph\";\nimport { planContainers } from \"./containers\";\nimport { convertJsxSite, convertStyleObject } from \"./convert\";\nimport { compact, unwrapExpression } from \"./expressions\";\nimport {\n codemodMediaNames,\n createModifierRegistry,\n grammarPlatformNames\n} from \"./grammar\";\nimport { createProvenance } from \"./provenance\";\nimport { renderReport } from \"./report\";\nconst projectRoot = process.cwd();\nconst defaultReportPath = resolve(projectRoot, \"tamagui-flat-values-report.md\");\nconst ignoreMarker = \".tamagui-flat-values-ignore\";\nconst ignoredDirectories = /* @__PURE__ */ new Map();\nfunction isIgnored(filePath) {\n let directory = dirname(filePath);\n const visited = [];\n while (directory === projectRoot || !relative(projectRoot, directory).startsWith(\"..\")) {\n const cached = ignoredDirectories.get(directory);\n if (cached !== void 0) {\n for (const seen of visited) ignoredDirectories.set(seen, cached);\n return cached;\n }\n visited.push(directory);\n if (existsSync(resolve(directory, ignoreMarker))) {\n for (const seen of visited) ignoredDirectories.set(seen, true);\n return true;\n }\n if (directory === projectRoot) break;\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n for (const seen of visited) ignoredDirectories.set(seen, false);\n return false;\n}\nfunction collectFiles(inputs2) {\n const tsConfigFilePath = resolve(projectRoot, \"tsconfig.json\");\n if (!existsSync(tsConfigFilePath)) {\n console.error(\n `no tsconfig.json in ${projectRoot}; run the codemod from your project root`\n );\n process.exit(2);\n }\n const project = new Project({\n tsConfigFilePath,\n skipAddingFilesFromTsConfig: true,\n compilerOptions: {\n allowJs: false,\n jsx: 4,\n target: ScriptTarget.ES2020,\n module: ModuleKind.ESNext,\n moduleResolution: ModuleResolutionKind.NodeJs,\n skipLibCheck: true,\n strictNullChecks: true,\n baseUrl: projectRoot\n }\n });\n const files2 = /* @__PURE__ */ new Map();\n const ignored = /* @__PURE__ */ new Set();\n const missing = [];\n for (const input of inputs2) {\n const path = resolve(projectRoot, input);\n if (!existsSync(path)) {\n missing.push(input);\n continue;\n }\n const pattern = /\\.[cm]?[jt]sx?$/.test(path) ? path : `${path}/**/*.{ts,tsx}`;\n const matched = project.addSourceFilesAtPaths(pattern);\n if (!matched.length) missing.push(input);\n for (const file of matched) {\n const filePath = file.getFilePath();\n if (isIgnored(filePath)) ignored.add(filePath);\n else files2.set(filePath, file);\n }\n }\n if (missing.length) {\n console.error(\n `no source file matched ${missing.map((input) => `\"${input}\"`).join(\", \")}`\n );\n process.exit(2);\n }\n if (files2.size === 0 && ignored.size > 0) {\n console.error(\n `all ${ignored.size} matched source ${ignored.size === 1 ? \"file was\" : \"files were\"} skipped by ${ignoreMarker}; no migration report was written`\n );\n process.exit(2);\n }\n return {\n sourceFiles: [...files2.values()].sort(\n (left, right) => left.getFilePath().localeCompare(right.getFilePath())\n ),\n ignoredFiles: ignored.size\n };\n}\nfunction themeNames(sourceFiles2) {\n const names = /* @__PURE__ */ new Set([\"light\", \"dark\"]);\n for (const sourceFile of sourceFiles2) {\n for (const name of conditionNames(sourceFile)) {\n if (name.startsWith(\"$theme-\")) names.add(name.slice(\"$theme-\".length));\n }\n }\n return names;\n}\nfunction mediaNames(sourceFiles2) {\n const names = new Set(codemodMediaNames);\n for (const sourceFile of sourceFiles2) {\n for (const name of conditionNames(sourceFile)) {\n if (!name.startsWith(\"$\")) continue;\n if (name.startsWith(\"$theme-\") || name.startsWith(\"$platform-\") || name.startsWith(\"$group-\") || grammarPlatformNames.has(name.slice(1))) {\n continue;\n }\n names.add(name.slice(1));\n }\n }\n return names;\n}\nfunction conditionNames(sourceFile) {\n const names = [];\n for (const attribute of sourceFile.getDescendantsOfKind(SyntaxKind.JsxAttribute)) {\n const name = attribute.getNameNode();\n if (Node.isIdentifier(name)) names.push(name.getText());\n }\n for (const property of sourceFile.getDescendantsOfKind(SyntaxKind.PropertyAssignment)) {\n const name = property.getNameNode();\n if (Node.isComputedPropertyName(name)) continue;\n names.push(name.getText().replace(/^['\"]|['\"]$/g, \"\"));\n }\n return names;\n}\nfunction variantStyleObjects(value) {\n const current = unwrapExpression(value);\n if (Node.isObjectLiteralExpression(current)) return [current];\n if (Node.isConditionalExpression(current)) {\n return [\n ...variantStyleObjects(current.getWhenTrue()),\n ...variantStyleObjects(current.getWhenFalse())\n ];\n }\n if (Node.isArrowFunction(current) || Node.isFunctionExpression(current)) {\n const body = current.getBody();\n if (Node.isBlock(body)) {\n return body.getDescendantsOfKind(SyntaxKind.ReturnStatement).flatMap((statement) => {\n const returned = statement.getExpression();\n return returned ? variantStyleObjects(returned) : [];\n });\n }\n return variantStyleObjects(body);\n }\n return [];\n}\nfunction variantSites(config, label, registry, containers, targets, host, write2) {\n const sites = [];\n const variants = config.getProperty(\"variants\");\n if (Node.isPropertyAssignment(variants)) {\n const object = unwrapExpression(variants.getInitializerOrThrow());\n if (Node.isObjectLiteralExpression(object)) {\n for (const variant of object.getProperties()) {\n if (!Node.isPropertyAssignment(variant)) continue;\n const variantName = compact(variant.getNameNode().getText());\n const branches = unwrapExpression(variant.getInitializerOrThrow());\n if (!Node.isObjectLiteralExpression(branches)) continue;\n for (const branch of branches.getProperties()) {\n if (!Node.isPropertyAssignment(branch)) continue;\n const branchName = compact(branch.getNameNode().getText());\n for (const style of variantStyleObjects(branch.getInitializerOrThrow())) {\n const site = convertStyleObject(\n style,\n \"styled\",\n `${label} variants.${variantName}.${branchName}`,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n }\n }\n }\n }\n return sites;\n}\nfunction conversionTargets(filePath) {\n if (/\\.web\\.[cm]?[jt]sx?$/.test(filePath)) return \"web\";\n if (/\\.native\\.[cm]?[jt]sx?$/.test(filePath)) return \"native\";\n return \"shared\";\n}\nfunction typeAwareHost(node) {\n const checker = node.getProject().getTypeChecker().compilerObject;\n const host = resolveTamaguiHost(\n checker,\n node.compilerNode\n );\n if (!host || node.getText() !== \"View\") return host;\n return {\n ...host,\n accepts: (property) => !(property in stylePropsTextOnly) && host.accepts(property)\n };\n}\nfunction inspectFile(sourceFile, registry, provenance2, write2) {\n const containers = planContainers(sourceFile, registry);\n const targets = conversionTargets(sourceFile.getFilePath());\n const sites = [];\n const styledCalls = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).filter((call) => provenance2.isTamaguiStyledCall(call)).sort((left, right) => right.getStart() - left.getStart());\n const jsxOpenings = [\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n ].filter((opening) => provenance2.isTamaguiElement(opening)).sort((left, right) => right.getStart() - left.getStart());\n for (const opening of jsxOpenings) {\n const site = convertJsxSite(\n opening,\n registry,\n containers,\n targets,\n typeAwareHost(opening.getTagNameNode()),\n write2\n );\n if (site) sites.push(site);\n }\n for (const call of styledCalls) {\n const component = call.getArguments()[0];\n const host = component ? typeAwareHost(component) : void 0;\n const config = unwrapExpression(\n call.getArguments()[1] ?? call\n );\n if (!Node.isObjectLiteralExpression(config)) continue;\n const label = `styled(${compact(call.getArguments()[0]?.getText() ?? \"unknown\")}, \\u2026)`;\n sites.push(...variantSites(config, label, registry, containers, targets, host, write2));\n const site = convertStyleObject(\n config,\n \"styled\",\n label,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n sites.sort(\n (left, right) => left.line - right.line || left.label.localeCompare(right.label)\n );\n return { file: relative(projectRoot, sourceFile.getFilePath()), sites };\n}\nconst usage = `Converts Tamagui style syntax to V3 flat property values and reports what it cannot convert.\n\n npx @tamagui/codemod-flat-values [options] <files or directories...>\n\n --report <path> where to write the Markdown report (default: ${relative(\n projectRoot,\n defaultReportPath\n)})\n --json <path> also write the machine-readable report\n --write rewrite every statically safe conversion in place\n --help print this\n\nRun it from your project root, which is where paths and the tsconfig resolve from.\nSource files are only written with --write.`;\nfunction parseArguments(argv) {\n const inputs2 = [];\n let reportPath2 = defaultReportPath;\n let jsonPath2 = null;\n let write2 = false;\n for (let index = 0; index < argv.length; index++) {\n const argument = argv[index];\n if (argument === \"--help\" || argument === \"-h\") {\n console.log(usage);\n process.exit(0);\n }\n if (argument === \"--write\") {\n write2 = true;\n continue;\n }\n if (argument === \"--report\" || argument === \"--json\") {\n const next = argv[index + 1];\n if (!next) {\n console.error(`${argument} requires a path\n\n${usage}`);\n process.exit(2);\n }\n if (argument === \"--report\") reportPath2 = resolve(next);\n else jsonPath2 = resolve(next);\n index++;\n continue;\n }\n if (argument.startsWith(\"-\")) {\n console.error(`unknown option \"${argument}\"\n\n${usage}`);\n process.exit(2);\n }\n inputs2.push(argument);\n }\n if (!inputs2.length) {\n console.error(`no files or directories given\n\n${usage}`);\n process.exit(2);\n }\n return { reportPath: reportPath2, jsonPath: jsonPath2, inputs: inputs2, write: write2 };\n}\nconst { reportPath, jsonPath, inputs, write } = parseArguments(process.argv.slice(2));\nconst { sourceFiles, ignoredFiles } = collectFiles(inputs);\nfor (const sourceFile of sourceFiles) {\n const diagnostics = sourceFile.compilerNode.parseDiagnostics;\n if (diagnostics?.length) {\n console.error(\n `${relative(projectRoot, sourceFile.getFilePath())}: source has parse errors; no files were written`\n );\n process.exit(2);\n }\n}\nconst originals = new Map(\n sourceFiles.map((sourceFile) => [sourceFile.getFilePath(), sourceFile.getFullText()])\n);\nconst modifierRegistry = createModifierRegistry({\n mediaNames: mediaNames(sourceFiles),\n themeNames: themeNames(sourceFiles)\n});\nconst provenance = createProvenance();\nconst files = sourceFiles.map(\n (sourceFile) => inspectFile(sourceFile, modifierRegistry.registry, provenance, write)\n);\nif (write) {\n for (const sourceFile of sourceFiles) {\n const filePath = sourceFile.getFilePath();\n const parsed = ts.createSourceFile(\n filePath,\n sourceFile.getFullText(),\n ScriptTarget.Latest,\n true,\n filePath.endsWith(\"x\") ? ts.ScriptKind.TSX : ts.ScriptKind.TS\n );\n if (parsed.parseDiagnostics?.length) {\n const details = parsed.parseDiagnostics.map((diagnostic) => {\n const start = diagnostic.start ?? 0;\n const position = parsed.getLineAndCharacterOfPosition(start);\n const line = parsed.text.split(/\\r?\\n/)[position.line] ?? \"\";\n return `${position.line + 1}:${position.character + 1} ${ts.flattenDiagnosticMessageText(\n diagnostic.messageText,\n \"\\n\"\n )}\n ${line.trim()}`;\n }).join(\"\\n\");\n console.error(\n `${relative(projectRoot, filePath)}: rewrite produced parse errors; no files were written\n${details}`\n );\n process.exit(2);\n }\n }\n}\nconst { text, summary } = renderReport(\n files,\n inputs.map((input) => relative(projectRoot, resolve(projectRoot, input))),\n modifierRegistry.diagnostics,\n ignoredFiles,\n write\n);\nmkdirSync(dirname(reportPath), { recursive: true });\nwriteFileSync(reportPath, text);\nif (jsonPath !== null) {\n mkdirSync(dirname(jsonPath), { recursive: true });\n writeFileSync(jsonPath, `${JSON.stringify({ files, summary }, null, 2)}\n`);\n}\nlet written = 0;\nif (write) {\n for (const sourceFile of sourceFiles) {\n const next = sourceFile.getFullText();\n if (next === originals.get(sourceFile.getFilePath())) continue;\n writeFileSync(sourceFile.getFilePath(), next);\n written++;\n }\n}\nconsole.log(`wrote ${reportPath}`);\nif (write) console.log(`rewrote ${written} source files`);\nconsole.log(\n `${summary.sites} sites: ${summary.clean - summary.waiting} clean, ${summary.needsRelocation} need relocation, ${summary.unknownHost} unknown host, ${summary.ineligible} ineligible, ${summary.waiting} waiting on runtime support, ${summary.flagged} syntax-flagged; ${summary.ignoredFiles} source files ignored`\n);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,cAAc,QAAQ,IAAI;AAChC,MAAM,oBAAoB,QAAQ,aAAa,+BAA+B;AAC9E,MAAM,eAAe;AACrB,MAAM,qCAAqC,IAAI,IAAI;AACnD,SAAS,UAAU,UAAU;CAC3B,IAAI,YAAY,QAAQ,QAAQ;CAChC,MAAM,UAAU,CAAC;CACjB,OAAO,cAAc,eAAe,CAAC,SAAS,aAAa,SAAS,CAAC,CAAC,WAAW,IAAI,GAAG;EACtF,MAAM,SAAS,mBAAmB,IAAI,SAAS;EAC/C,IAAI,WAAW,KAAK,GAAG;GACrB,KAAK,MAAM,QAAQ,SAAS,mBAAmB,IAAI,MAAM,MAAM;GAC/D,OAAO;EACT;EACA,QAAQ,KAAK,SAAS;EACtB,IAAI,WAAW,QAAQ,WAAW,YAAY,CAAC,GAAG;GAChD,KAAK,MAAM,QAAQ,SAAS,mBAAmB,IAAI,MAAM,IAAI;GAC7D,OAAO;EACT;EACA,IAAI,cAAc,aAAa;EAC/B,MAAM,SAAS,QAAQ,SAAS;EAChC,IAAI,WAAW,WAAW;EAC1B,YAAY;CACd;CACA,KAAK,MAAM,QAAQ,SAAS,mBAAmB,IAAI,MAAM,KAAK;CAC9D,OAAO;AACT;AACA,SAAS,aAAa,SAAS;CAC7B,MAAM,mBAAmB,QAAQ,aAAa,eAAe;CAC7D,IAAI,CAAC,WAAW,gBAAgB,GAAG;EACjC,QAAQ,MACN,uBAAuB,YAAY,yCACrC;EACA,QAAQ,KAAK,CAAC;C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AAmB,QAAQ,aAAa,sBACjS"}
@@ -249,7 +249,6 @@ function convertLegacyConditionProp(propName, value, options) {
249
249
  const modifiers = root.modifiers.slice();
250
250
  const visit = (object, objectPath) => {
251
251
  for (const childProp in object) {
252
- if (!Object.prototype.hasOwnProperty.call(object, childProp)) continue;
253
252
  const childValue = object[childProp];
254
253
  const childPath = `${objectPath}.${childProp}`;
255
254
  const condition = resolveLegacyCondition(childProp, options.registry);
@@ -1 +1 @@
1
- {"version":3,"file":"legacyConditions.js","names":[],"sources":["legacyConditions.js"],"sourcesContent":["import {\n transformFamilyProps,\n unitlessNumberProperties\n} from \"@tamagui/style-grammar/tooling\";\nconst pseudoToModifier = Object.freeze({\n hoverStyle: \"hover\",\n pressStyle: \"press\",\n focusStyle: \"focus\",\n focusVisibleStyle: \"focus-visible\",\n focusWithinStyle: \"focus-within\",\n disabledStyle: \"disabled\",\n enterStyle: \"enter\",\n exitStyle: \"exit\"\n});\nconst transformPartProperties = /* @__PURE__ */ new Set([\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"rotate\",\n \"rotateX\",\n \"rotateY\",\n \"rotateZ\",\n \"x\",\n \"y\",\n \"skewX\",\n \"skewY\",\n \"perspective\"\n]);\nfunction resolveLegacyCondition(propName, registry) {\n const pseudoModifier = pseudoToModifier[propName];\n if (pseudoModifier !== void 0) {\n return registry.get(pseudoModifier) === \"state\" ? { recognized: true, modifiers: [pseudoModifier] } : {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy condition \"${propName}\" maps to unregistered state modifier \"${pseudoModifier}\"`\n }\n };\n }\n if (propName.startsWith(\"$theme-\")) {\n const modifier = propName.slice(\"$theme-\".length);\n return modifier && registry.get(modifier) === \"theme\" ? { recognized: true, modifiers: [modifier] } : {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy theme condition \"${propName}\" does not name a registered theme`\n }\n };\n }\n if (propName.startsWith(\"$platform-\")) {\n const modifier = propName.slice(\"$platform-\".length);\n return modifier && registry.get(modifier) === \"platform\" ? { recognized: true, modifiers: [modifier] } : {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy platform condition \"${propName}\" does not name a registered platform`\n }\n };\n }\n if (propName.startsWith(\"$group-\")) {\n const remainder = propName.slice(\"$group-\".length);\n const candidates = [];\n let start = 0;\n while (start < remainder.length) {\n const state2 = remainder.slice(start);\n if (registry.get(state2) === \"state\") candidates.push(state2);\n const dash = remainder.indexOf(\"-\", start);\n if (dash === -1) break;\n start = dash + 1;\n }\n const longestLength = candidates.reduce(\n (length, state2) => Math.max(length, state2.length),\n 0\n );\n const longest = candidates.filter((state2) => state2.length === longestLength);\n if (longest.length > 1) {\n return {\n recognized: true,\n error: {\n code: \"ambiguous-legacy-group\",\n message: `legacy group condition \"${propName}\" has more than one equally specific state suffix`\n }\n };\n }\n const state = longest.length === 1 ? longest[0] : null;\n let namePart = state === null ? remainder : state.length === remainder.length ? \"\" : remainder.slice(0, -(state.length + 1));\n let media = null;\n if (namePart) {\n let scanStart = 0;\n while (scanStart < namePart.length) {\n const suffix2 = namePart.slice(scanStart);\n if (registry.get(`@${suffix2}`) === \"container\") {\n media = suffix2;\n break;\n }\n const dash = namePart.indexOf(\"-\", scanStart);\n if (dash === -1) break;\n scanStart = dash + 1;\n }\n if (media !== null) {\n namePart = media.length === namePart.length ? \"\" : namePart.slice(0, -(media.length + 1));\n } else if (state === null) {\n return {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy group condition \"${propName}\" has no registered state or container-size suffix`\n }\n };\n }\n } else if (state === null) {\n return {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy group condition \"${propName}\" has no registered state suffix`\n }\n };\n }\n const suffix = namePart ? `/${namePart}` : \"\";\n const modifiers = [];\n if (media !== null) modifiers.push(`@${media}${suffix}`);\n if (state !== null) modifiers.push(`group-${state}${suffix}`);\n return { recognized: true, modifiers };\n }\n if (propName[0] === \"$\") {\n const modifier = propName.slice(1);\n const kind = registry.get(modifier);\n if (kind === \"media\" || kind === \"container\") {\n return { recognized: true, modifiers: [modifier] };\n }\n }\n return { recognized: false };\n}\nfunction isConditionObject(value) {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\nfunction convertStyleValue(prop, value, path, errors) {\n if (transformPartProperties.has(prop) && !transformFamilyProps.has(prop)) {\n errors.push({\n code: \"legacy-transform-part\",\n path,\n message: `legacy transform part \"${prop}\" has no flat spelling; author it inside a flat \\`transform\\` value (only x, y, scale, scaleX, scaleY, and rotate are first-class)`\n });\n return null;\n }\n if (typeof value === \"number\" && Number.isFinite(value) && transformFamilyProps.has(prop)) {\n if (prop === \"rotate\") return value === 0 ? \"0deg\" : `${value}deg`;\n if (prop === \"x\" || prop === \"y\") return value === 0 ? \"0\" : `${value}px`;\n return String(value);\n }\n if (typeof value === \"string\") {\n const text = value.replace(/\\$(-?\\d+)\\.(\\d+)\\b/g, \"$$$1-$2\");\n if (!text.length) {\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: \"an empty string cannot become a condition clause payload\"\n });\n return null;\n }\n if (text.indexOf(\"$\") === -1) return text;\n if (text.includes('\"') || text.includes(\"'\") || text.includes(\"url(\")) {\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: `\"${text}\" mixes \"$\" with quoted or url() content; migrate the token spelling by hand`\n });\n return null;\n }\n if (/\\$[\\w-]*\\./.test(text)) {\n errors.push({\n code: \"legacy-token-dot-path\",\n path,\n message: `legacy token in \"${text}\" uses dot-path naming; rename it to one configured flat token name before conversion`\n });\n return null;\n }\n if (/\\$-?\\d/.test(text) && !/^\\$-?[\\w-]+$/.test(text)) {\n errors.push({\n code: \"legacy-numeric-composite-token\",\n path,\n message: `numeric token in \"${text}\" is embedded in a composite value; replace it with its resolved CSS value before conversion`\n });\n return null;\n }\n if (/\\$(?![\\w-])/.test(text)) {\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: `\"$\" in \"${text}\" is not followed by a token name`\n });\n return null;\n }\n return text.replace(/\\$([\\w-]+)/g, \"$1\");\n }\n if (typeof value === \"number\") {\n if (Number.isFinite(value)) {\n return unitlessNumberProperties.has(prop) ? String(value) : `${value}px`;\n }\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: `non-finite number ${String(value)} cannot become a CSS payload`\n });\n return null;\n }\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: `legacy condition value for \"${prop}\" must be a string or finite number`\n });\n return null;\n}\nfunction convertLegacyConditionProp(propName, value, options) {\n const root = resolveLegacyCondition(propName, options.registry);\n if (!root.recognized) return null;\n const result = { contributions: [], errors: [] };\n if (\"error\" in root) {\n result.errors.push({ ...root.error, path: propName });\n return result;\n }\n if (!isConditionObject(value)) {\n result.errors.push({\n code: \"legacy-condition-object\",\n path: propName,\n message: `legacy condition \"${propName}\" must contain a style object`\n });\n return result;\n }\n const modifiers = root.modifiers.slice();\n const visit = (object, objectPath) => {\n for (const childProp in object) {\n if (!Object.prototype.hasOwnProperty.call(object, childProp)) continue;\n const childValue = object[childProp];\n const childPath = `${objectPath}.${childProp}`;\n const condition = resolveLegacyCondition(childProp, options.registry);\n if (condition.recognized) {\n if (\"error\" in condition) {\n result.errors.push({ ...condition.error, path: childPath });\n continue;\n }\n if (!isConditionObject(childValue)) {\n result.errors.push({\n code: \"legacy-condition-object\",\n path: childPath,\n message: `legacy condition \"${childProp}\" must contain a style object`\n });\n continue;\n }\n modifiers.push(...condition.modifiers);\n visit(childValue, childPath);\n modifiers.length -= condition.modifiers.length;\n continue;\n }\n const payload = convertStyleValue(childProp, childValue, childPath, result.errors);\n if (payload !== null) {\n result.contributions.push({\n prop: childProp,\n clause: { modifiers: modifiers.slice(), payload }\n });\n }\n }\n };\n visit(value, propName);\n return result;\n}\nexport {\n convertLegacyConditionProp,\n pseudoToModifier\n};\n//# sourceMappingURL=legacyConditions.js.map\n"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AAE,GAAG,KAAK;GAAO,MAAM;EAAS,CAAC;EACpD,OAAO;CACT;CACA,IAAI,CAAC,kBAAkB,KAAK,GAAG;EAC7B,OAAO,OAAO,KAAK;GACjB,MAAM;GACN,MAAM;GACN,SAAS,qBAAqB,SAAS;EACzC,CAAC;EACD,OAAO;CACT;CACA,MAAM,YAAY,KAAK,UAAU,MAAM;CACvC,MAAM,SAAS,QAAQ,eAAe;EACpC,KAAK,MAAM,aAAa,QAAQ;GAC9B,IAAI,CAAC,OAAO,UAAU,eAAe,KAAK,QAAQ,SAAS,GAAG;GAC9D,MAAM,aAAa,OAAO;GAC1B,MAAM,YAAY,GAAG,WAAW,GAAG;GACnC,MAAM,YAAY,uBAAuB,WAAW,QAAQ,QAAQ;GACpE,IAAI,UAAU,YAAY;IACxB,IAAI,WAAW,WAAW;KACxB,OAAO,OAAO,KAAK;MAAE,GAAG,UAAU;MAAO,MAAM;KAAU,CAAC;KAC1D;IACF;IACA,IAAI,CAAC,kBAAkB,UAAU,GAAG;KAClC,OAAO,OAAO,KAAK;MACjB,MAAM;MACN,MAAM;MACN,SAAS,qBAAqB,UAAU;KAC1C,CAAC;KACD;IACF;IACA,UAAU,KAAK,GAAG,UAAU,SAAS;IACrC,MAAM,YAAY,SAAS;IAC3B,UAAU,UAAU,UAAU,UAAU;IACxC;GACF;GACA,MAAM,UAAU,kBAAkB,WAAW,YAAY,WAAW,OAAO,MAAM;GACjF,IAAI,YAAY,MAAM;IACpB,OAAO,cAAc,KAAK;KACxB,MAAM;KACN,QAAQ;MAAE,WAAW,UAAU,MAAM;MAAG;KAAQ;IAClD,CAAC;GACH;EACF;CACF;CACA,MAAM,OAAO,QAAQ;CACrB,OAAO;AACT"}
1
+ {"version":3,"file":"legacyConditions.js","names":[],"sources":["legacyConditions.js"],"sourcesContent":["import {\n transformFamilyProps,\n unitlessNumberProperties\n} from \"@tamagui/style-grammar/tooling\";\nconst pseudoToModifier = Object.freeze({\n hoverStyle: \"hover\",\n pressStyle: \"press\",\n focusStyle: \"focus\",\n focusVisibleStyle: \"focus-visible\",\n focusWithinStyle: \"focus-within\",\n disabledStyle: \"disabled\",\n enterStyle: \"enter\",\n exitStyle: \"exit\"\n});\nconst transformPartProperties = /* @__PURE__ */ new Set([\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"rotate\",\n \"rotateX\",\n \"rotateY\",\n \"rotateZ\",\n \"x\",\n \"y\",\n \"skewX\",\n \"skewY\",\n \"perspective\"\n]);\nfunction resolveLegacyCondition(propName, registry) {\n const pseudoModifier = pseudoToModifier[propName];\n if (pseudoModifier !== void 0) {\n return registry.get(pseudoModifier) === \"state\" ? { recognized: true, modifiers: [pseudoModifier] } : {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy condition \"${propName}\" maps to unregistered state modifier \"${pseudoModifier}\"`\n }\n };\n }\n if (propName.startsWith(\"$theme-\")) {\n const modifier = propName.slice(\"$theme-\".length);\n return modifier && registry.get(modifier) === \"theme\" ? { recognized: true, modifiers: [modifier] } : {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy theme condition \"${propName}\" does not name a registered theme`\n }\n };\n }\n if (propName.startsWith(\"$platform-\")) {\n const modifier = propName.slice(\"$platform-\".length);\n return modifier && registry.get(modifier) === \"platform\" ? { recognized: true, modifiers: [modifier] } : {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy platform condition \"${propName}\" does not name a registered platform`\n }\n };\n }\n if (propName.startsWith(\"$group-\")) {\n const remainder = propName.slice(\"$group-\".length);\n const candidates = [];\n let start = 0;\n while (start < remainder.length) {\n const state2 = remainder.slice(start);\n if (registry.get(state2) === \"state\") candidates.push(state2);\n const dash = remainder.indexOf(\"-\", start);\n if (dash === -1) break;\n start = dash + 1;\n }\n const longestLength = candidates.reduce(\n (length, state2) => Math.max(length, state2.length),\n 0\n );\n const longest = candidates.filter((state2) => state2.length === longestLength);\n if (longest.length > 1) {\n return {\n recognized: true,\n error: {\n code: \"ambiguous-legacy-group\",\n message: `legacy group condition \"${propName}\" has more than one equally specific state suffix`\n }\n };\n }\n const state = longest.length === 1 ? longest[0] : null;\n let namePart = state === null ? remainder : state.length === remainder.length ? \"\" : remainder.slice(0, -(state.length + 1));\n let media = null;\n if (namePart) {\n let scanStart = 0;\n while (scanStart < namePart.length) {\n const suffix2 = namePart.slice(scanStart);\n if (registry.get(`@${suffix2}`) === \"container\") {\n media = suffix2;\n break;\n }\n const dash = namePart.indexOf(\"-\", scanStart);\n if (dash === -1) break;\n scanStart = dash + 1;\n }\n if (media !== null) {\n namePart = media.length === namePart.length ? \"\" : namePart.slice(0, -(media.length + 1));\n } else if (state === null) {\n return {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy group condition \"${propName}\" has no registered state or container-size suffix`\n }\n };\n }\n } else if (state === null) {\n return {\n recognized: true,\n error: {\n code: \"unregistered-legacy-condition\",\n message: `legacy group condition \"${propName}\" has no registered state suffix`\n }\n };\n }\n const suffix = namePart ? `/${namePart}` : \"\";\n const modifiers = [];\n if (media !== null) modifiers.push(`@${media}${suffix}`);\n if (state !== null) modifiers.push(`group-${state}${suffix}`);\n return { recognized: true, modifiers };\n }\n if (propName[0] === \"$\") {\n const modifier = propName.slice(1);\n const kind = registry.get(modifier);\n if (kind === \"media\" || kind === \"container\") {\n return { recognized: true, modifiers: [modifier] };\n }\n }\n return { recognized: false };\n}\nfunction isConditionObject(value) {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\nfunction convertStyleValue(prop, value, path, errors) {\n if (transformPartProperties.has(prop) && !transformFamilyProps.has(prop)) {\n errors.push({\n code: \"legacy-transform-part\",\n path,\n message: `legacy transform part \"${prop}\" has no flat spelling; author it inside a flat \\`transform\\` value (only x, y, scale, scaleX, scaleY, and rotate are first-class)`\n });\n return null;\n }\n if (typeof value === \"number\" && Number.isFinite(value) && transformFamilyProps.has(prop)) {\n if (prop === \"rotate\") return value === 0 ? \"0deg\" : `${value}deg`;\n if (prop === \"x\" || prop === \"y\") return value === 0 ? \"0\" : `${value}px`;\n return String(value);\n }\n if (typeof value === \"string\") {\n const text = value.replace(/\\$(-?\\d+)\\.(\\d+)\\b/g, \"$$$1-$2\");\n if (!text.length) {\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: \"an empty string cannot become a condition clause payload\"\n });\n return null;\n }\n if (text.indexOf(\"$\") === -1) return text;\n if (text.includes('\"') || text.includes(\"'\") || text.includes(\"url(\")) {\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: `\"${text}\" mixes \"$\" with quoted or url() content; migrate the token spelling by hand`\n });\n return null;\n }\n if (/\\$[\\w-]*\\./.test(text)) {\n errors.push({\n code: \"legacy-token-dot-path\",\n path,\n message: `legacy token in \"${text}\" uses dot-path naming; rename it to one configured flat token name before conversion`\n });\n return null;\n }\n if (/\\$-?\\d/.test(text) && !/^\\$-?[\\w-]+$/.test(text)) {\n errors.push({\n code: \"legacy-numeric-composite-token\",\n path,\n message: `numeric token in \"${text}\" is embedded in a composite value; replace it with its resolved CSS value before conversion`\n });\n return null;\n }\n if (/\\$(?![\\w-])/.test(text)) {\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: `\"$\" in \"${text}\" is not followed by a token name`\n });\n return null;\n }\n return text.replace(/\\$([\\w-]+)/g, \"$1\");\n }\n if (typeof value === \"number\") {\n if (Number.isFinite(value)) {\n return unitlessNumberProperties.has(prop) ? String(value) : `${value}px`;\n }\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: `non-finite number ${String(value)} cannot become a CSS payload`\n });\n return null;\n }\n errors.push({\n code: \"unsupported-legacy-value\",\n path,\n message: `legacy condition value for \"${prop}\" must be a string or finite number`\n });\n return null;\n}\nfunction convertLegacyConditionProp(propName, value, options) {\n const root = resolveLegacyCondition(propName, options.registry);\n if (!root.recognized) return null;\n const result = { contributions: [], errors: [] };\n if (\"error\" in root) {\n result.errors.push({ ...root.error, path: propName });\n return result;\n }\n if (!isConditionObject(value)) {\n result.errors.push({\n code: \"legacy-condition-object\",\n path: propName,\n message: `legacy condition \"${propName}\" must contain a style object`\n });\n return result;\n }\n const modifiers = root.modifiers.slice();\n const visit = (object, objectPath) => {\n for (const childProp in object) {\n const childValue = object[childProp];\n const childPath = `${objectPath}.${childProp}`;\n const condition = resolveLegacyCondition(childProp, options.registry);\n if (condition.recognized) {\n if (\"error\" in condition) {\n result.errors.push({ ...condition.error, path: childPath });\n continue;\n }\n if (!isConditionObject(childValue)) {\n result.errors.push({\n code: \"legacy-condition-object\",\n path: childPath,\n message: `legacy condition \"${childProp}\" must contain a style object`\n });\n continue;\n }\n modifiers.push(...condition.modifiers);\n visit(childValue, childPath);\n modifiers.length -= condition.modifiers.length;\n continue;\n }\n const payload = convertStyleValue(childProp, childValue, childPath, result.errors);\n if (payload !== null) {\n result.contributions.push({\n prop: childProp,\n clause: { modifiers: modifiers.slice(), payload }\n });\n }\n }\n };\n visit(value, propName);\n return result;\n}\nexport {\n convertLegacyConditionProp,\n pseudoToModifier\n};\n//# sourceMappingURL=legacyConditions.js.map\n"],"mappings":";;;AAIA,MAAM,mBAAmB,OAAO,OAAO;CACrC,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,mBAAmB;CACnB,kBAAkB;CAClB,eAAe;CACf,YAAY;CACZ,WAAW;AACb,CAAC;AACD,MAAM,0CAA0C,IAAI,IAAI;CACtD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,SAAS,uBAAuB,UAAU,UAAU;CAClD,MAAM,iBAAiB,iBAAiB;CACxC,IAAI,mBAAmB,KAAK,GAAG;EAC7B,OAAO,SAAS,IAAI,cAAc,MAAM,UAAU;GAAE,YAAY;GAAM,WAAW,CAAC,cAAc;EAAE,IAAI;GACpG,YAAY;GACZ,OAAO;IACL,MAAM;IACN,SAAS,qBAAqB,SAAS,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MAAM;KAAU,CAAC;KAC1D;IACF;IACA,IAAI,CAAC,kBAAkB,UAAU,GAAG;KAClC,OAAO,OAAO,KAAK;MACjB,MAAM;MACN,MAAM;MACN,SAAS,qBAAqB,UAAU;KAC1C,CAAC;KACD;IACF;IACA,UAAU,KAAK,GAAG,UAAU,SAAS;IACrC,MAAM,YAAY,SAAS;IAC3B,UAAU,UAAU,UAAU,UAAU;IACxC;GACF;GACA,MAAM,UAAU,kBAAkB,WAAW,YAAY,WAAW,OAAO,MAAM;GACjF,IAAI,YAAY,MAAM;IACpB,OAAO,cAAc,KAAK;KACxB,MAAM;KACN,QAAQ;MAAE,WAAW,UAAU,MAAM;MAAG;KAAQ;IAClD,CAAC;GACH;EACF;CACF;CACA,MAAM,OAAO,QAAQ;CACrB,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/codemod-flat-values",
3
- "version": "3.0.0-beta.807.1",
3
+ "version": "3.0.0-beta.831.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,14 +26,14 @@
26
26
  "typecheck": "tsc --noEmit"
27
27
  },
28
28
  "dependencies": {
29
- "@tamagui/helpers": "3.0.0-beta.807.1",
30
- "@tamagui/language-service": "3.0.0-beta.807.1",
31
- "@tamagui/shorthands": "3.0.0-beta.807.1",
32
- "@tamagui/style-grammar": "3.0.0-beta.807.1",
29
+ "@tamagui/helpers": "3.0.0-beta.831.1",
30
+ "@tamagui/language-service": "3.0.0-beta.831.1",
31
+ "@tamagui/shorthands": "3.0.0-beta.831.1",
32
+ "@tamagui/style-grammar": "3.0.0-beta.831.1",
33
33
  "ts-morph": "^28.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@tamagui/build": "3.0.0-beta.807.1",
36
+ "@tamagui/build": "3.0.0-beta.831.1",
37
37
  "typescript": "~6.0.3"
38
38
  },
39
39
  "repository": {
package/src/index.ts CHANGED
@@ -250,32 +250,6 @@ function variantSites(
250
250
  }
251
251
  }
252
252
 
253
- const compound = config.getProperty('compoundVariants')
254
- if (Node.isPropertyAssignment(compound)) {
255
- const array = unwrapExpression(compound.getInitializerOrThrow())
256
- if (Node.isArrayLiteralExpression(array)) {
257
- for (const [index, element] of array.getElements().entries()) {
258
- const entry = unwrapExpression(element)
259
- if (!Node.isObjectLiteralExpression(entry)) continue
260
- const style = entry.getProperty('style')
261
- if (!Node.isPropertyAssignment(style)) continue
262
- for (const object of variantStyleObjects(style.getInitializerOrThrow())) {
263
- const site = convertStyleObject(
264
- object,
265
- 'styled',
266
- `${label} compoundVariants[${index}]`,
267
- registry,
268
- containers,
269
- targets,
270
- host,
271
- write
272
- )
273
- if (site) sites.push(site)
274
- }
275
- }
276
- }
277
- }
278
-
279
253
  return sites
280
254
  }
281
255
 
@@ -319,7 +319,6 @@ export function convertLegacyConditionProp(
319
319
  const modifiers = root.modifiers.slice()
320
320
  const visit = (object: Record<string, unknown>, objectPath: string): void => {
321
321
  for (const childProp in object) {
322
- if (!Object.prototype.hasOwnProperty.call(object, childProp)) continue
323
322
  const childValue = object[childProp]
324
323
  const childPath = `${objectPath}.${childProp}`
325
324
  const condition = resolveLegacyCondition(childProp, options.registry)