@tamagui/codemod-flat-values 3.0.0-beta.889.1 → 3.0.0-beta.891.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.
@@ -1 +1 @@
1
- {"version":3,"file":"report.js","names":[],"sources":["report.js"],"sourcesContent":["function countCodes(flags) {\n const counts = /* @__PURE__ */ new Map();\n for (const flag of flags) counts.set(flag.code, (counts.get(flag.code) ?? 0) + 1);\n return [...counts].sort(\n ([leftCode, leftCount], [rightCode, rightCount]) => rightCount - leftCount || leftCode.localeCompare(rightCode)\n );\n}\nfunction renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, write = false) {\n const sites = files.flatMap((file) => file.sites);\n const functionalVariants = files.flatMap((file) => file.functionalVariants);\n const convertedFunctionalVariants = functionalVariants.filter((site) => site.converted);\n const flaggedFunctionalVariants = functionalVariants.filter((site) => !site.converted);\n const clean = sites.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n );\n const flagged = sites.filter((site) => site.flags.length > 0);\n const warnings = sites.filter((site) => site.warnings.length > 0);\n const needsRelocation = sites.filter(\n (site) => site.assessmentVerdict === \"needs-relocation\"\n );\n const unknownHost = sites.filter((site) => site.assessmentVerdict === \"unknown-host\");\n const ineligible = sites.filter((site) => site.assessmentVerdict === \"ineligible\");\n const waiting = clean.filter((site) => site.programs.length === 0);\n const jsx = sites.filter((site) => site.kind === \"jsx\");\n const styled = sites.filter((site) => site.kind === \"styled\");\n const cleanJsx = jsx.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n ).length;\n const cleanStyled = styled.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n ).length;\n const readyFiles = files.filter(\n (file) => (file.sites.length > 0 || file.functionalVariants.length > 0) && file.sites.every((site) => site.legacyLeft === 0) && file.functionalVariants.every((site) => site.converted)\n );\n const filesWithSites = files.filter(\n (file) => file.sites.length > 0 || file.functionalVariants.length > 0\n ).length;\n const blockedFiles = files.filter(\n (file) => file.sites.some((site) => site.legacyLeft > 0) || file.functionalVariants.some((site) => !site.converted)\n ).map((file) => file.file);\n const functionalFlagCounts = countCodes(\n flaggedFunctionalVariants.flatMap((site) => [\n ...new Map(site.flags.map((flag) => [flag.code, flag])).values()\n ])\n );\n const lines = [\n \"# Flat-values codemod dry-run\",\n \"\",\n `Corpus: ${corpus.map((entry) => `\\`${entry}\\``).join(\", \")}.`,\n \"\",\n write ? \"Statically safe conversions were written in place. Flagged legacy syntax remains for manual migration.\" : \"Dry run only: no source files were written. Pass `--write` to apply statically safe conversions.\",\n \"\",\n \"## Summary\",\n \"\",\n `- ${sites.length} conversion sites found`,\n `- ${clean.length - waiting.length} converted with no open questions`,\n `- ${needsRelocation.length} need relocation because the authored target or host cannot evaluate the conversion`,\n `- ${unknownHost.length} have an unverified host type`,\n `- ${ineligible.length} use properties that cannot carry flat clauses`,\n `- ${waiting.length} have nothing to convert until the runtime catches up (see below)`,\n `- ${flagged.length} have syntax or ordering flags for manual work`,\n `- ${warnings.length} have configuration warnings for manual review`,\n `- ${ignoredFiles} source files skipped by \\`.tamagui-flat-values-ignore\\` markers`,\n `- ${jsx.length} JSX sites: ${cleanJsx} clean, ${jsx.length - cleanJsx} need review`,\n `- ${styled.length} styled config sites: ${cleanStyled} clean, ${styled.length - cleanStyled} need review`,\n `- ${functionalVariants.length} functional variant sites found`,\n `- ${convertedFunctionalVariants.length} functional variants have automatic styled.dynamic rewrites`,\n `- ${flaggedFunctionalVariants.length} functional variants need manual migration`,\n \"\",\n \"### Functional variant flag reasons\",\n \"\",\n ...functionalFlagCounts.length ? functionalFlagCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"],\n \"\",\n \"### Remaining manual migration\",\n \"\",\n `${readyFiles.length} of ${filesWithSites} files have no legacy condition object or flagged functional variant left after`,\n \"conversion. V3 has no compatibility setting; finish the remaining files directly:\",\n blockedFiles.length ? blockedFiles.map((file) => `\\`${file}\\``).join(\", \") : \"every file in this corpus is fully migrated.\",\n \"\",\n \"### Flag reasons\",\n \"\"\n ];\n const flagCounts = countCodes(flagged.flatMap((site) => site.flags));\n lines.push(\n ...flagCounts.length ? flagCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"]\n );\n const warningCounts = countCodes(warnings.flatMap((site) => site.warnings));\n lines.push(\n \"\",\n \"### Configuration warning reasons\",\n \"\",\n ...warningCounts.length ? warningCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"]\n );\n const inventoryCounts = countCodes(sites.flatMap((site) => site.inventory));\n if (inventoryCounts.length) {\n lines.push(\n \"\",\n \"### Values left authored for another migration\",\n \"\",\n \"These are not flat-value migration work. The conversion keeps them exactly as\",\n \"authored and records them so their follow-up migrations have a corpus inventory.\",\n \"\",\n ...inventoryCounts.map(([code, count]) => `- ${code}: ${count}`)\n );\n }\n const pendingCounts = countCodes(sites.flatMap((site) => site.pending));\n if (pendingCounts.length) {\n lines.push(\n \"\",\n \"### Waiting on runtime support\",\n \"\",\n \"The conversion is known but not offered, because the runtime cannot read it yet.\",\n \"Each pending reason below names the exact host or merge contract that must land\",\n \"before the suggested source is safe to apply.\",\n \"\",\n ...pendingCounts.map(([code, count]) => `- ${code}: ${count}`)\n );\n }\n if (registryDiagnostics.length) {\n lines.push(\"\", \"### Modifier registry diagnostics\", \"\");\n for (const diagnostic of registryDiagnostics) lines.push(`- ${diagnostic}`);\n }\n for (const file of files) {\n if (!file.sites.length && !file.functionalVariants.length) continue;\n lines.push(\"\", `## \\`${file.file}\\``, \"\");\n for (const site of file.functionalVariants) {\n lines.push(\n `### ${site.label} functional variant at line ${site.line} (${site.converted ? \"automatic\" : \"manual\"})`,\n \"\",\n \"Before:\",\n \"\",\n \"```tsx\",\n site.before,\n \"```\",\n \"\",\n site.converted ? \"Automatic rewrite:\" : \"Left authored:\",\n \"\",\n \"```tsx\",\n site.after,\n \"```\"\n );\n if (site.flags.length) {\n lines.push(\"\", \"Flags:\", \"\");\n for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.draft) {\n lines.push(\"\", \"Generated `.resolve` draft:\", \"\", \"```tsx\", site.draft, \"```\");\n }\n if (site.notes.length) {\n lines.push(\"\", \"Notes:\", \"\");\n for (const note of site.notes) lines.push(`- ${note}`);\n }\n lines.push(\"\");\n }\n for (const site of file.sites) {\n const status = [\n site.assessmentVerdict === \"clean\" ? null : site.assessmentVerdict,\n site.flags.length ? \"syntax-blocked\" : null,\n site.warnings.length ? \"configuration-warning\" : null\n ].filter(Boolean).join(\", \");\n lines.push(\n `### ${site.label} at line ${site.line} (${status || \"clean\"})`,\n \"\",\n \"Before:\",\n \"\",\n \"```tsx\",\n site.before,\n \"```\",\n \"\",\n \"After:\",\n \"\",\n \"```tsx\",\n site.after,\n \"```\"\n );\n if (site.flags.length) {\n lines.push(\"\", \"Flags:\", \"\");\n for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.warnings.length) {\n lines.push(\"\", \"Configuration warnings:\", \"\");\n for (const warning of site.warnings) {\n lines.push(`- **${warning.code}**: ${warning.detail}`);\n }\n }\n if (site.assessments.length) {\n lines.push(\"\", \"Conversion assessment:\", \"\");\n for (const assessment of site.assessments) {\n for (const reason of assessment.reasons) {\n lines.push(\n `- **${assessment.verdict}: ${assessment.property}**: ${reason.message}. Remedy: ${reason.remedy}.`\n );\n }\n }\n }\n if (site.inventory.length) {\n lines.push(\"\", \"Left authored:\", \"\");\n for (const flag of site.inventory)\n lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.pending.length) {\n lines.push(\"\", \"Waiting on runtime support:\", \"\");\n for (const flag of site.pending) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.notes.length) {\n lines.push(\"\", \"Notes:\", \"\");\n for (const note of site.notes) lines.push(`- ${note}`);\n }\n lines.push(\"\");\n }\n }\n return {\n text: `${lines.join(\"\\n\")}\n`,\n summary: {\n sites: sites.length,\n clean: clean.length,\n needsRelocation: needsRelocation.length,\n unknownHost: unknownHost.length,\n ineligible: ineligible.length,\n flagged: flagged.length,\n warnings: warnings.length,\n waiting: waiting.length,\n ignoredFiles,\n functionalVariantSites: functionalVariants.length,\n functionalVariantConverted: convertedFunctionalVariants.length,\n functionalVariantFlagged: flaggedFunctionalVariants.length,\n functionalVariantFlags: Object.fromEntries(functionalFlagCounts)\n }\n };\n}\nexport {\n renderReport\n};\n//# sourceMappingURL=report.js.map\n"],"mappings":";AAAA,SAAS,WAAW,OAAO;CACzB,MAAM,yBAAyB,IAAI,IAAI;CACvC,KAAK,MAAM,QAAQ,OAAO,OAAO,IAAI,KAAK,OAAO,OAAO,IAAI,KAAK,IAAI,KAAK,KAAK,CAAC;CAChF,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,MAChB,CAAC,UAAU,YAAY,CAAC,WAAW,gBAAgB,aAAa,aAAa,SAAS,cAAc,SAAS,CAChH;AACF;AACA,SAAS,aAAa,OAAO,QAAQ,qBAAqB,eAAe,GAAG,QAAQ,OAAO;CACzF,MAAM,QAAQ,MAAM,SAAS,SAAS,KAAK,KAAK;CAChD,MAAM,qBAAqB,MAAM,SAAS,SAAS,KAAK,kBAAkB;CAC1E,MAAM,8BAA8B,mBAAmB,QAAQ,SAAS,KAAK,SAAS;CACtF,MAAM,4BAA4B,mBAAmB,QAAQ,SAAS,CAAC,KAAK,SAAS;CACrF,MAAM,QAAQ,MAAM,QACjB,SAAS,KAAK,MAAM,WAAW,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,sBAAsB,OAChG;CACA,MAAM,UAAU,MAAM,QAAQ,SAAS,KAAK,MAAM,SAAS,CAAC;CAC5D,MAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,SAAS,SAAS,CAAC;CAChE,MAAM,kBAAkB,MAAM,QAC3B,SAAS,KAAK,sBAAsB,kBACvC;CACA,MAAM,cAAc,MAAM,QAAQ,SAA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O,KAAK,KAAK,MAAM,KAAK,QAAQ;GAClF;GACA,IAAI,KAAK,MAAM,QAAQ;IACrB,MAAM,KAAK,IAAI,UAAU,EAAE;IAC3B,KAAK,MAAM,QAAQ,KAAK,OAAO,MAAM,KAAK,KAAK,MAAM;GACvD;GACA,MAAM,KAAK,EAAE;EACf;CACF;CACA,OAAO;EACL,MAAM,GAAG,MAAM,KAAK,IAAI,EAAE;;EAE1B,SAAS;GACP,OAAO,MAAM;GACb,OAAO,MAAM;GACb,iBAAiB,gBAAgB;GACjC,aAAa,YAAY;GACzB,YAAY,WAAW;GACvB,SAAS,QAAQ;GACjB,UAAU,SAAS;GACnB,SAAS,QAAQ;GACjB;GACA,wBAAwB,mBAAmB;GAC3C,4BAA4B,4BAA4B;GACxD,0BAA0B,0BAA0B;GACpD,wBAAwB,OAAO,YAAY,oBAAoB;EACjE;CACF;AACF"}
1
+ {"version":3,"file":"report.js","names":[],"sources":["report.js"],"sourcesContent":["function countCodes(flags) {\n const counts = /* @__PURE__ */ new Map();\n for (const flag of flags) counts.set(flag.code, (counts.get(flag.code) ?? 0) + 1);\n return [...counts].sort(\n ([leftCode, leftCount], [rightCode, rightCount]) => rightCount - leftCount || leftCode.localeCompare(rightCode)\n );\n}\nfunction renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, write = false) {\n const sites = files.flatMap((file) => file.sites);\n const functionalVariants = files.flatMap((file) => file.functionalVariants);\n const sheetFrames = files.flatMap((file) => file.sheetFrames);\n const flaggedSheetFrames = sheetFrames.filter((site) => site.flags.length > 0);\n const convertedFunctionalVariants = functionalVariants.filter((site) => site.converted);\n const flaggedFunctionalVariants = functionalVariants.filter((site) => !site.converted);\n const clean = sites.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n );\n const flagged = sites.filter((site) => site.flags.length > 0);\n const warnings = sites.filter((site) => site.warnings.length > 0);\n const needsRelocation = sites.filter(\n (site) => site.assessmentVerdict === \"needs-relocation\"\n );\n const unknownHost = sites.filter((site) => site.assessmentVerdict === \"unknown-host\");\n const ineligible = sites.filter((site) => site.assessmentVerdict === \"ineligible\");\n const waiting = clean.filter((site) => site.programs.length === 0);\n const jsx = sites.filter((site) => site.kind === \"jsx\");\n const styled = sites.filter((site) => site.kind === \"styled\");\n const cleanJsx = jsx.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n ).length;\n const cleanStyled = styled.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n ).length;\n const touched = (file) => file.sites.length > 0 || file.functionalVariants.length > 0 || file.sheetFrames.length > 0;\n const blocked = (file) => file.sites.some((site) => site.legacyLeft > 0) || file.functionalVariants.some((site) => !site.converted) || file.sheetFrames.some((site) => site.flags.length > 0);\n const readyFiles = files.filter((file) => touched(file) && !blocked(file));\n const filesWithSites = files.filter(touched).length;\n const blockedFiles = files.filter(blocked).map((file) => file.file);\n const functionalFlagCounts = countCodes(\n flaggedFunctionalVariants.flatMap((site) => [\n ...new Map(site.flags.map((flag) => [flag.code, flag])).values()\n ])\n );\n const lines = [\n \"# Flat-values codemod dry-run\",\n \"\",\n `Corpus: ${corpus.map((entry) => `\\`${entry}\\``).join(\", \")}.`,\n \"\",\n write ? \"Statically safe conversions were written in place. Flagged legacy syntax remains for manual migration.\" : \"Dry run only: no source files were written. Pass `--write` to apply statically safe conversions.\",\n \"\",\n \"## Summary\",\n \"\",\n `- ${sites.length} conversion sites found`,\n `- ${clean.length - waiting.length} converted with no open questions`,\n `- ${needsRelocation.length} need relocation because the authored target or host cannot evaluate the conversion`,\n `- ${unknownHost.length} have an unverified host type`,\n `- ${ineligible.length} use properties that cannot carry flat clauses`,\n `- ${waiting.length} have nothing to convert until the runtime catches up (see below)`,\n `- ${flagged.length} have syntax or ordering flags for manual work`,\n `- ${warnings.length} have configuration warnings for manual review`,\n `- ${ignoredFiles} source files skipped by \\`.tamagui-flat-values-ignore\\` markers`,\n `- ${jsx.length} JSX sites: ${cleanJsx} clean, ${jsx.length - cleanJsx} need review`,\n `- ${styled.length} styled config sites: ${cleanStyled} clean, ${styled.length - cleanStyled} need review`,\n `- ${functionalVariants.length} functional variant sites found`,\n `- ${convertedFunctionalVariants.length} functional variants have automatic styled.dynamic rewrites`,\n `- ${flaggedFunctionalVariants.length} functional variants need manual migration`,\n `- ${sheetFrames.length} Sheet.Frame sites rewritten to Sheet.Container plus Sheet.Background`,\n `- ${flaggedSheetFrames.length} Sheet.Frame sites need a human to place a spread or a styled target`,\n \"\",\n \"### Functional variant flag reasons\",\n \"\",\n ...functionalFlagCounts.length ? functionalFlagCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"],\n \"\",\n \"### Remaining manual migration\",\n \"\",\n `${readyFiles.length} of ${filesWithSites} files have no legacy condition object, flagged functional variant, or flagged Sheet.Frame left after`,\n \"conversion. V3 has no compatibility setting; finish the remaining files directly:\",\n blockedFiles.length ? blockedFiles.map((file) => `\\`${file}\\``).join(\", \") : \"every file in this corpus is fully migrated.\",\n \"\",\n \"### Flag reasons\",\n \"\"\n ];\n const flagCounts = countCodes(flagged.flatMap((site) => site.flags));\n lines.push(\n ...flagCounts.length ? flagCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"]\n );\n const warningCounts = countCodes(warnings.flatMap((site) => site.warnings));\n lines.push(\n \"\",\n \"### Configuration warning reasons\",\n \"\",\n ...warningCounts.length ? warningCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"]\n );\n const inventoryCounts = countCodes(sites.flatMap((site) => site.inventory));\n if (inventoryCounts.length) {\n lines.push(\n \"\",\n \"### Values left authored for another migration\",\n \"\",\n \"These are not flat-value migration work. The conversion keeps them exactly as\",\n \"authored and records them so their follow-up migrations have a corpus inventory.\",\n \"\",\n ...inventoryCounts.map(([code, count]) => `- ${code}: ${count}`)\n );\n }\n const pendingCounts = countCodes(sites.flatMap((site) => site.pending));\n if (pendingCounts.length) {\n lines.push(\n \"\",\n \"### Waiting on runtime support\",\n \"\",\n \"The conversion is known but not offered, because the runtime cannot read it yet.\",\n \"Each pending reason below names the exact host or merge contract that must land\",\n \"before the suggested source is safe to apply.\",\n \"\",\n ...pendingCounts.map(([code, count]) => `- ${code}: ${count}`)\n );\n }\n if (registryDiagnostics.length) {\n lines.push(\"\", \"### Modifier registry diagnostics\", \"\");\n for (const diagnostic of registryDiagnostics) lines.push(`- ${diagnostic}`);\n }\n for (const file of files) {\n if (!touched(file)) continue;\n lines.push(\"\", `## \\`${file.file}\\``, \"\");\n for (const site of file.sheetFrames) {\n lines.push(\n `### ${site.label} at line ${site.line} (${site.flags.length ? \"review\" : \"automatic\"})`,\n \"\",\n \"Before:\",\n \"\",\n \"```tsx\",\n site.before,\n \"```\",\n \"\",\n \"Automatic rewrite:\",\n \"\",\n \"```tsx\",\n site.after,\n \"```\"\n );\n if (site.flags.length) {\n lines.push(\"\", \"Flags:\", \"\");\n for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n lines.push(\"\");\n }\n for (const site of file.functionalVariants) {\n lines.push(\n `### ${site.label} functional variant at line ${site.line} (${site.converted ? \"automatic\" : \"manual\"})`,\n \"\",\n \"Before:\",\n \"\",\n \"```tsx\",\n site.before,\n \"```\",\n \"\",\n site.converted ? \"Automatic rewrite:\" : \"Left authored:\",\n \"\",\n \"```tsx\",\n site.after,\n \"```\"\n );\n if (site.flags.length) {\n lines.push(\"\", \"Flags:\", \"\");\n for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.draft) {\n lines.push(\"\", \"Generated `.resolve` draft:\", \"\", \"```tsx\", site.draft, \"```\");\n }\n if (site.notes.length) {\n lines.push(\"\", \"Notes:\", \"\");\n for (const note of site.notes) lines.push(`- ${note}`);\n }\n lines.push(\"\");\n }\n for (const site of file.sites) {\n const status = [\n site.assessmentVerdict === \"clean\" ? null : site.assessmentVerdict,\n site.flags.length ? \"syntax-blocked\" : null,\n site.warnings.length ? \"configuration-warning\" : null\n ].filter(Boolean).join(\", \");\n lines.push(\n `### ${site.label} at line ${site.line} (${status || \"clean\"})`,\n \"\",\n \"Before:\",\n \"\",\n \"```tsx\",\n site.before,\n \"```\",\n \"\",\n \"After:\",\n \"\",\n \"```tsx\",\n site.after,\n \"```\"\n );\n if (site.flags.length) {\n lines.push(\"\", \"Flags:\", \"\");\n for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.warnings.length) {\n lines.push(\"\", \"Configuration warnings:\", \"\");\n for (const warning of site.warnings) {\n lines.push(`- **${warning.code}**: ${warning.detail}`);\n }\n }\n if (site.assessments.length) {\n lines.push(\"\", \"Conversion assessment:\", \"\");\n for (const assessment of site.assessments) {\n for (const reason of assessment.reasons) {\n lines.push(\n `- **${assessment.verdict}: ${assessment.property}**: ${reason.message}. Remedy: ${reason.remedy}.`\n );\n }\n }\n }\n if (site.inventory.length) {\n lines.push(\"\", \"Left authored:\", \"\");\n for (const flag of site.inventory)\n lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.pending.length) {\n lines.push(\"\", \"Waiting on runtime support:\", \"\");\n for (const flag of site.pending) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.notes.length) {\n lines.push(\"\", \"Notes:\", \"\");\n for (const note of site.notes) lines.push(`- ${note}`);\n }\n lines.push(\"\");\n }\n }\n return {\n text: `${lines.join(\"\\n\")}\n`,\n summary: {\n sites: sites.length,\n clean: clean.length,\n needsRelocation: needsRelocation.length,\n unknownHost: unknownHost.length,\n ineligible: ineligible.length,\n flagged: flagged.length,\n warnings: warnings.length,\n waiting: waiting.length,\n ignoredFiles,\n functionalVariantSites: functionalVariants.length,\n functionalVariantConverted: convertedFunctionalVariants.length,\n functionalVariantFlagged: flaggedFunctionalVariants.length,\n functionalVariantFlags: Object.fromEntries(functionalFlagCounts),\n sheetFrames: sheetFrames.length,\n sheetFramesFlagged: flaggedSheetFrames.length\n }\n };\n}\n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ACzB,MAAM,KAAK,IAAI,kBAAkB,EAAE;IACnC,KAAK,MAAM,QAAQ,KAAK,WACtB,MAAM,KAAK,OAAO,KAAK,KAAK,MAAM,KAAK,QAAQ;GACnD;GACA,IAAI,KAAK,QAAQ,QAAQ;IACvB,MAAM,KAAK,IAAI,+BAA+B,EAAE;IAChD,KAAK,MAAM,QAAQ,KAAK,SAAS,MAAM,KAAK,OAAO,KAAK,KAAK,MAAM,KAAK,QAAQ;GAClF;GACA,IAAI,KAAK,MAAM,QAAQ;IACrB,MAAM,KAAK,IAAI,UAAU,EAAE;IAC3B,KAAK,MAAM,QAAQ,KAAK,OAAO,MAAM,KAAK,KAAK,MAAM;GACvD;GACA,MAAM,KAAK,EAAE;EACf;CACF;CACA,OAAO;EACL,MAAM,GAAG,MAAM,KAAK,IAAI,EAAE;;EAE1B,SAAS;GACP,OAAO,MAAM;GACb,OAAO,MAAM;GACb,iBAAiB,gBAAgB;GACjC,aAAa,YAAY;GACzB,YAAY,WAAW;GACvB,SAAS,QAAQ;GACjB,UAAU,SAAS;GACnB,SAAS,QAAQ;GACjB;GACA,wBAAwB,mBAAmB;GAC3C,4BAA4B,4BAA4B;GACxD,0BAA0B,0BAA0B;GACpD,wBAAwB,OAAO,YAAY,oBAAoB;GAC/D,aAAa,YAAY;GACzB,oBAAoB,mBAAmB;EACzC;CACF;AACF"}
@@ -0,0 +1,200 @@
1
+ import { Node, SyntaxKind } from "ts-morph";
2
+
3
+ const surfaceProps = /* @__PURE__ */ new Set([
4
+ "bg",
5
+ "background",
6
+ "backgroundColor",
7
+ "backgroundImage",
8
+ "borderColor",
9
+ "borderRadius",
10
+ "borderStyle",
11
+ "borderWidth",
12
+ "boxShadow",
13
+ "disableHideBottomOverflow",
14
+ "elevate",
15
+ "elevation",
16
+ "elevationAndroid",
17
+ "outlineColor",
18
+ "outlineOffset",
19
+ "outlineStyle",
20
+ "outlineWidth"
21
+ ]);
22
+ function isSurfaceProp(name) {
23
+ return surfaceProps.has(name) || /^border[A-Z].*(Color|Radius|Style|Width)$/.test(name) || /^shadow[A-Z]/.test(name);
24
+ }
25
+ function applyEdits(source, base, edits) {
26
+ let text = source;
27
+ for (const edit of [...edits].sort((left, right) => right.start - left.start)) {
28
+ text = `${text.slice(0, edit.start - base)}${edit.text}${text.slice(edit.end - base)}`;
29
+ }
30
+ return text;
31
+ }
32
+ function sheetPart(node) {
33
+ if (!Node.isPropertyAccessExpression(node)) return null;
34
+ const owner = node.getExpression();
35
+ const ownerName = Node.isPropertyAccessExpression(owner) ? owner.getName() : Node.isIdentifier(owner) ? owner.getText() : null;
36
+ if (ownerName !== "Sheet") return null;
37
+ return {
38
+ sheet: owner.getText(),
39
+ part: node.getNameNode(),
40
+ partName: node.getName()
41
+ };
42
+ }
43
+ function frameOpening(opening, provenance) {
44
+ const found = sheetPart(opening.getTagNameNode());
45
+ if (!found || found.partName !== "Frame") return null;
46
+ if (!provenance.isTamaguiElement(opening)) return null;
47
+ return found;
48
+ }
49
+ function attributeName(attribute) {
50
+ const name = attribute.getNameNode();
51
+ return Node.isIdentifier(name) ? name.getText() : null;
52
+ }
53
+ function rewriteFrame(opening, sheet, part) {
54
+ const element = Node.isJsxOpeningElement(opening) ? opening.getParentIfKindOrThrow(SyntaxKind.JsxElement) : opening;
55
+ const start = element.getStart();
56
+ const end = element.getEnd();
57
+ const source = element.getText();
58
+ const edits = [{
59
+ start: part.getStart(),
60
+ end: part.getEnd(),
61
+ text: "Container"
62
+ }];
63
+ const flags = [];
64
+ const moved = [];
65
+ let previousEnd = opening.getTagNameNode().getEnd();
66
+ for (const attribute of opening.getAttributes()) {
67
+ if (Node.isJsxSpreadAttribute(attribute)) {
68
+ flags.push({
69
+ code: "sheet-frame-spread",
70
+ detail: `${attribute.getText()} stays on ${sheet}.Container; move any surface props it carries onto ${sheet}.Background by hand`
71
+ });
72
+ } else {
73
+ const name = attributeName(attribute);
74
+ if (name !== null && isSurfaceProp(name)) {
75
+ moved.push(attribute.getText());
76
+ edits.push({
77
+ start: previousEnd,
78
+ end: attribute.getEnd(),
79
+ text: ""
80
+ });
81
+ }
82
+ }
83
+ previousEnd = attribute.getEnd();
84
+ }
85
+ const background = `<${sheet}.Background${moved.length ? ` ${moved.join(" ")}` : ""} />`;
86
+ if (Node.isJsxSelfClosingElement(element)) {
87
+ edits.push({
88
+ start: element.getEnd() - 2,
89
+ end: element.getEnd(),
90
+ text: `>${background}</${sheet}.Container>`
91
+ });
92
+ const beforeClose = source.slice(0, -2);
93
+ if (/\s$/.test(beforeClose)) {
94
+ edits.push({
95
+ start: element.getEnd() - 2 - (beforeClose.length - beforeClose.trimEnd().length),
96
+ end: element.getEnd() - 2,
97
+ text: ""
98
+ });
99
+ }
100
+ return {
101
+ after: applyEdits(source, start, edits),
102
+ start,
103
+ end,
104
+ flags
105
+ };
106
+ }
107
+ const closingPart = sheetPart(element.getClosingElement().getTagNameNode());
108
+ if (closingPart) {
109
+ edits.push({
110
+ start: closingPart.part.getStart(),
111
+ end: closingPart.part.getEnd(),
112
+ text: "Container"
113
+ });
114
+ }
115
+ const firstChild = element.getJsxChildren().find((child) => !Node.isJsxText(child) || child.getText().trim() !== "");
116
+ const existing = firstChild && (Node.isJsxElement(firstChild) || Node.isJsxSelfClosingElement(firstChild)) ? sheetPart((Node.isJsxElement(firstChild) ? firstChild.getOpeningElement() : firstChild).getTagNameNode()) : null;
117
+ if (existing?.partName === "Background") {
118
+ if (moved.length) {
119
+ const existingOpening = Node.isJsxElement(firstChild) ? firstChild.getOpeningElement() : firstChild;
120
+ const attributes = existingOpening.getAttributes();
121
+ const anchor = attributes.length ? attributes[attributes.length - 1].getEnd() : existingOpening.getTagNameNode().getEnd();
122
+ edits.push({
123
+ start: anchor,
124
+ end: anchor,
125
+ text: ` ${moved.join(" ")}`
126
+ });
127
+ }
128
+ return {
129
+ after: applyEdits(source, start, edits),
130
+ start,
131
+ end,
132
+ flags
133
+ };
134
+ }
135
+ const afterOpening = source.slice(opening.getEnd() - start);
136
+ const childLine = /^(\r?\n[ \t]*)/.exec(afterOpening);
137
+ edits.push({
138
+ start: opening.getEnd(),
139
+ end: opening.getEnd(),
140
+ text: childLine ? `${childLine[1]}${background}` : background
141
+ });
142
+ return {
143
+ after: applyEdits(source, start, edits),
144
+ start,
145
+ end,
146
+ flags
147
+ };
148
+ }
149
+ function convertSheetFrames(sourceFile, provenance, write) {
150
+ const reports = [];
151
+ const openings = () => [...sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement), ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)].sort((left, right) => left.getStart() - right.getStart()).flatMap((opening) => {
152
+ const found = frameOpening(opening, provenance);
153
+ return found ? [{
154
+ opening,
155
+ ...found
156
+ }] : [];
157
+ });
158
+ const record = (opening, sheet, part) => {
159
+ const element = Node.isJsxOpeningElement(opening) ? opening.getParentIfKindOrThrow(SyntaxKind.JsxElement) : opening;
160
+ const before = element.getText();
161
+ const rewritten = rewriteFrame(opening, sheet, part);
162
+ reports.push({
163
+ label: `<${sheet}.Frame>`,
164
+ line: opening.getStartLineNumber(),
165
+ before,
166
+ after: rewritten.after,
167
+ flags: rewritten.flags
168
+ });
169
+ return rewritten;
170
+ };
171
+ if (write) {
172
+ for (let next = openings()[0]; next; next = openings()[0]) {
173
+ const rewritten = record(next.opening, next.sheet, next.part);
174
+ sourceFile.replaceText([rewritten.start, rewritten.end], rewritten.after);
175
+ }
176
+ } else {
177
+ for (const next of openings()) record(next.opening, next.sheet, next.part);
178
+ }
179
+ for (const call of sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).filter((call2) => provenance.isTamaguiStyledCall(call2)).sort((left, right) => right.getStart() - left.getStart())) {
180
+ const target = call.getArguments()[0];
181
+ const found = target ? sheetPart(target) : null;
182
+ if (!found || found.partName !== "Frame") continue;
183
+ const before = target.getText();
184
+ reports.push({
185
+ label: `styled(${before}, \u2026)`,
186
+ line: call.getStartLineNumber(),
187
+ before,
188
+ after: `${found.sheet}.Container`,
189
+ flags: [{
190
+ code: "sheet-frame-styled",
191
+ detail: `${before} is split into ${found.sheet}.Container and ${found.sheet}.Background; the styled target is now the Container, so move any surface styles in this config to a styled ${found.sheet}.Background`
192
+ }]
193
+ });
194
+ if (write) found.part.replaceWithText("Container");
195
+ }
196
+ return reports.sort((left, right) => left.line - right.line);
197
+ }
198
+
199
+ export { convertSheetFrames };
200
+ //# sourceMappingURL=sheetAnatomy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheetAnatomy.js","names":[],"sources":["sheetAnatomy.js"],"sourcesContent":["import {\n Node,\n SyntaxKind\n} from \"ts-morph\";\nconst surfaceProps = /* @__PURE__ */ new Set([\n \"bg\",\n \"background\",\n \"backgroundColor\",\n \"backgroundImage\",\n \"borderColor\",\n \"borderRadius\",\n \"borderStyle\",\n \"borderWidth\",\n \"boxShadow\",\n \"disableHideBottomOverflow\",\n \"elevate\",\n \"elevation\",\n \"elevationAndroid\",\n \"outlineColor\",\n \"outlineOffset\",\n \"outlineStyle\",\n \"outlineWidth\"\n]);\nfunction isSurfaceProp(name) {\n return surfaceProps.has(name) || /^border[A-Z].*(Color|Radius|Style|Width)$/.test(name) || /^shadow[A-Z]/.test(name);\n}\nfunction applyEdits(source, base, edits) {\n let text = source;\n for (const edit of [...edits].sort((left, right) => right.start - left.start)) {\n text = `${text.slice(0, edit.start - base)}${edit.text}${text.slice(edit.end - base)}`;\n }\n return text;\n}\nfunction sheetPart(node) {\n if (!Node.isPropertyAccessExpression(node)) return null;\n const owner = node.getExpression();\n const ownerName = Node.isPropertyAccessExpression(owner) ? owner.getName() : Node.isIdentifier(owner) ? owner.getText() : null;\n if (ownerName !== \"Sheet\") return null;\n return { sheet: owner.getText(), part: node.getNameNode(), partName: node.getName() };\n}\nfunction frameOpening(opening, provenance) {\n const found = sheetPart(opening.getTagNameNode());\n if (!found || found.partName !== \"Frame\") return null;\n if (!provenance.isTamaguiElement(opening)) return null;\n return found;\n}\nfunction attributeName(attribute) {\n const name = attribute.getNameNode();\n return Node.isIdentifier(name) ? name.getText() : null;\n}\nfunction rewriteFrame(opening, sheet, part) {\n const element = Node.isJsxOpeningElement(opening) ? opening.getParentIfKindOrThrow(SyntaxKind.JsxElement) : opening;\n const start = element.getStart();\n const end = element.getEnd();\n const source = element.getText();\n const edits = [\n { start: part.getStart(), end: part.getEnd(), text: \"Container\" }\n ];\n const flags = [];\n const moved = [];\n let previousEnd = opening.getTagNameNode().getEnd();\n for (const attribute of opening.getAttributes()) {\n if (Node.isJsxSpreadAttribute(attribute)) {\n flags.push({\n code: \"sheet-frame-spread\",\n detail: `${attribute.getText()} stays on ${sheet}.Container; move any surface props it carries onto ${sheet}.Background by hand`\n });\n } else {\n const name = attributeName(attribute);\n if (name !== null && isSurfaceProp(name)) {\n moved.push(attribute.getText());\n edits.push({ start: previousEnd, end: attribute.getEnd(), text: \"\" });\n }\n }\n previousEnd = attribute.getEnd();\n }\n const background = `<${sheet}.Background${moved.length ? ` ${moved.join(\" \")}` : \"\"} />`;\n if (Node.isJsxSelfClosingElement(element)) {\n edits.push({\n start: element.getEnd() - 2,\n end: element.getEnd(),\n text: `>${background}</${sheet}.Container>`\n });\n const beforeClose = source.slice(0, -2);\n if (/\\s$/.test(beforeClose)) {\n edits.push({\n start: element.getEnd() - 2 - (beforeClose.length - beforeClose.trimEnd().length),\n end: element.getEnd() - 2,\n text: \"\"\n });\n }\n return { after: applyEdits(source, start, edits), start, end, flags };\n }\n const closingPart = sheetPart(element.getClosingElement().getTagNameNode());\n if (closingPart) {\n edits.push({\n start: closingPart.part.getStart(),\n end: closingPart.part.getEnd(),\n text: \"Container\"\n });\n }\n const firstChild = element.getJsxChildren().find((child) => !Node.isJsxText(child) || child.getText().trim() !== \"\");\n const existing = firstChild && (Node.isJsxElement(firstChild) || Node.isJsxSelfClosingElement(firstChild)) ? sheetPart(\n (Node.isJsxElement(firstChild) ? firstChild.getOpeningElement() : firstChild).getTagNameNode()\n ) : null;\n if (existing?.partName === \"Background\") {\n if (moved.length) {\n const existingOpening = Node.isJsxElement(firstChild) ? firstChild.getOpeningElement() : firstChild;\n const attributes = existingOpening.getAttributes();\n const anchor = attributes.length ? attributes[attributes.length - 1].getEnd() : existingOpening.getTagNameNode().getEnd();\n edits.push({ start: anchor, end: anchor, text: ` ${moved.join(\" \")}` });\n }\n return { after: applyEdits(source, start, edits), start, end, flags };\n }\n const afterOpening = source.slice(opening.getEnd() - start);\n const childLine = /^(\\r?\\n[ \\t]*)/.exec(afterOpening);\n edits.push({\n start: opening.getEnd(),\n end: opening.getEnd(),\n text: childLine ? `${childLine[1]}${background}` : background\n });\n return { after: applyEdits(source, start, edits), start, end, flags };\n}\nfunction convertSheetFrames(sourceFile, provenance, write) {\n const reports = [];\n const openings = () => [\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n ].sort((left, right) => left.getStart() - right.getStart()).flatMap((opening) => {\n const found = frameOpening(opening, provenance);\n return found ? [{ opening, ...found }] : [];\n });\n const record = (opening, sheet, part) => {\n const element = Node.isJsxOpeningElement(opening) ? opening.getParentIfKindOrThrow(SyntaxKind.JsxElement) : opening;\n const before = element.getText();\n const rewritten = rewriteFrame(opening, sheet, part);\n reports.push({\n label: `<${sheet}.Frame>`,\n line: opening.getStartLineNumber(),\n before,\n after: rewritten.after,\n flags: rewritten.flags\n });\n return rewritten;\n };\n if (write) {\n for (let next = openings()[0]; next; next = openings()[0]) {\n const rewritten = record(next.opening, next.sheet, next.part);\n sourceFile.replaceText([rewritten.start, rewritten.end], rewritten.after);\n }\n } else {\n for (const next of openings()) record(next.opening, next.sheet, next.part);\n }\n for (const call of sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).filter((call2) => provenance.isTamaguiStyledCall(call2)).sort((left, right) => right.getStart() - left.getStart())) {\n const target = call.getArguments()[0];\n const found = target ? sheetPart(target) : null;\n if (!found || found.partName !== \"Frame\") continue;\n const before = target.getText();\n reports.push({\n label: `styled(${before}, \\u2026)`,\n line: call.getStartLineNumber(),\n before,\n after: `${found.sheet}.Container`,\n flags: [\n {\n code: \"sheet-frame-styled\",\n detail: `${before} is split into ${found.sheet}.Container and ${found.sheet}.Background; the styled target is now the Container, so move any surface styles in this config to a styled ${found.sheet}.Background`\n }\n ]\n });\n if (write) found.part.replaceWithText(\"Container\");\n }\n return reports.sort((left, right) => left.line - right.line);\n}\nexport {\n convertSheetFrames\n};\n//# sourceMappingURL=sheetAnatomy.js.map\n"],"mappings":";;;AAIA,MAAM,+BAA+B,IAAI,IAAI;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,SAAS,cAAc,MAAM;CAC3B,OAAO,aAAa,IAAI,IAAI,KAAK,4CAA4C,KAAK,IAAI,KAAK,eAAe,KAAK,IAAI;AACrH;AACA,SAAS,WAAW,QAAQ,MAAM,OAAO;CACvC,IAAI,OAAO;CACX,KAAK,MAAM,QAAQ,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,MAAM,UAAU,MAAM,QAAQ,KAAK,KAAK,GAAG;EAC7E,OAAO,GAAG,KAAK,MAAM,GAAG,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,KAAK,MAAM,KAAK,MAAM,IAAI;CACrF;CACA,OAAO;AACT;AACA,SAAS,UAAU,MAAM;CACvB,IAAI,CAAC,KAAK,2BAA2B,IAAI,GAAG,OAAO;CACnD,MAAM,QAAQ,KAAK,cAAc;CACjC,MAAM,YAAY,KAAK,2BAA2B,KAAK,IAAI,MAAM,QAAQ,IAAI,KAAK,aAAa,KAAK,IAAI,MAAM,QAAQ,IAAI;CAC1H,IAAI,cAAc,SAAS,OAAO;CAClC,OAAO;EAAE,OAAO,MAAM,QAAQ;EAAG,MAAM,KAAK,YAAY;EAAG,UAAU,KAAK,QAAQ;CAAE;AACtF;AACA,SAAS,aAAa,SAAS,YAAY;CACzC,MAAM,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,SAAS,KAAK,OAAO,KAAK,IAAI;GAC5D,WAAW,YAAY,CAAC,UAAU,OAAO,UAAU,GAAG,GAAG,UAAU,KAAK;EAC1E;CACF,OAAO;EACL,KAAK,MAAM,QAAQ,SAAS,GAAG,OAAO,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI;CAC3E;CACA,KAAK,MAAM,QAAQ,WAAW,qBAAqB,WAAW,cAAc,CAAC,CAAC,QAAQ,UAAU,WAAW,oBAAoB,KAAK,CAAC,CAAC,CAAC,MAAM,MAAM,UAAU,MAAM,SAAS,IAAI,KAAK,SAAS,CAAC,GAAG;EAChM,MAAM,SAAS,KAAK,aAAa,CAAC,CAAC;EACnC,MAAM,QAAQ,SAAS,UAAU,MAAM,IAAI;EAC3C,IAAI,CAAC,SAAS,MAAM,aAAa,SAAS;EAC1C,MAAM,SAAS,OAAO,QAAQ;EAC9B,QAAQ,KAAK;GACX,OAAO,UAAU,OAAO;GACxB,MAAM,KAAK,mBAAmB;GAC9B;GACA,OAAO,GAAG,MAAM,MAAM;GACtB,OAAO,CACL;IACE,MAAM;IACN,QAAQ,GAAG,OAAO,iBAAiB,MAAM,MAAM,iBAAiB,MAAM,MAAM,6GAA6G,MAAM,MAAM;GACvM,CACF;EACF,CAAC;EACD,IAAI,OAAO,MAAM,KAAK,gBAAgB,WAAW;CACnD;CACA,OAAO,QAAQ,MAAM,MAAM,UAAU,KAAK,OAAO,MAAM,IAAI;AAC7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/codemod-flat-values",
3
- "version": "3.0.0-beta.889.1",
3
+ "version": "3.0.0-beta.891.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.889.1",
30
- "@tamagui/language-service": "3.0.0-beta.889.1",
31
- "@tamagui/shorthands": "3.0.0-beta.889.1",
32
- "@tamagui/style-grammar": "3.0.0-beta.889.1",
29
+ "@tamagui/helpers": "3.0.0-beta.891.1",
30
+ "@tamagui/language-service": "3.0.0-beta.891.1",
31
+ "@tamagui/shorthands": "3.0.0-beta.891.1",
32
+ "@tamagui/style-grammar": "3.0.0-beta.891.1",
33
33
  "ts-morph": "^28.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@tamagui/build": "3.0.0-beta.889.1",
36
+ "@tamagui/build": "3.0.0-beta.891.1",
37
37
  "typescript": "~6.0.3"
38
38
  },
39
39
  "repository": {
package/src/convert.ts CHANGED
@@ -1429,16 +1429,19 @@ function rewriteJsxSite(
1429
1429
  // impossible to review.
1430
1430
  //
1431
1431
  // The authored indentation is dropped from the prefix and the closing suffix
1432
- // so every emitted line is indented by replaceWithText alone. Keeping it would
1433
- // add to what ts-morph supplies and stagger the attributes, and taking control
1434
- // of the whitespace directly is not an option: SourceFile.replaceText forgets
1435
- // every node in the file and the rest of the pass then reads freed nodes.
1432
+ // so every emitted line is indented by replaceWithText alone: ts-morph puts
1433
+ // each new line at the element's own indentation, so an attribute line
1434
+ // carries one relative step and the closing `>` none. Keeping the authored
1435
+ // whitespace would add to what ts-morph supplies and stagger the attributes,
1436
+ // and taking control of the whitespace directly is not an option:
1437
+ // SourceFile.replaceText forgets every node in the file and the rest of the
1438
+ // pass then reads freed nodes.
1436
1439
  const authoredMultiline =
1437
1440
  prefix.includes('\n') ||
1438
1441
  source.slice(first.getStart() - start, last.getEnd() - start).includes('\n')
1439
1442
  opening.replaceWithText(
1440
1443
  authoredMultiline
1441
- ? `${prefix.replace(/[ \t]+$/, '')}${rendered.join('\n')}${suffix.replace(/\n[ \t]+/, '\n')}`
1444
+ ? `${prefix.replace(/[ \t]+$/, '')}${rendered.map((text) => ` ${text}`).join('\n')}${suffix.replace(/\n[ \t]+/, '\n')}`
1442
1445
  : `${prefix}${rendered.join(' ')}${suffix}`
1443
1446
  )
1444
1447
  }
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ import { dirname, relative, resolve } from 'node:path'
4
4
  import { resolveTamaguiHost } from '@tamagui/language-service/host'
5
5
  import { stylePropsTextOnly } from '@tamagui/helpers'
6
6
  import {
7
+ IndentationText,
7
8
  ModuleKind,
8
9
  ModuleResolutionKind,
9
10
  Node,
@@ -34,6 +35,7 @@ import {
34
35
  } from './grammar'
35
36
  import { createProvenance } from './provenance'
36
37
  import { renderReport, type FileReport } from './report'
38
+ import { convertSheetFrames } from './sheetAnatomy'
37
39
 
38
40
  type Provenance = ReturnType<typeof createProvenance>
39
41
 
@@ -86,6 +88,11 @@ function collectFiles(inputs: readonly string[]): {
86
88
  const project = new Project({
87
89
  tsConfigFilePath,
88
90
  skipAddingFilesFromTsConfig: true,
91
+ // ts-morph re-indents every multi-line replacement from the indentation it
92
+ // computes for the node with this unit. The default four-space unit puts a
93
+ // JSX child two columns past where two-space source authored it, and every
94
+ // attribute line of a rewritten element staggered with it
95
+ manipulationSettings: { indentationText: IndentationText.TwoSpaces },
89
96
  compilerOptions: {
90
97
  allowJs: false,
91
98
  jsx: 4,
@@ -311,6 +318,9 @@ function inspectFile(
311
318
  provenance: Provenance,
312
319
  write: boolean
313
320
  ): FileReport {
321
+ // the anatomy rewrite runs first so the Background it adds, and the surface
322
+ // props it moves there, go through the flat-value conversion below
323
+ const sheetFrames = convertSheetFrames(sourceFile, provenance, write)
314
324
  const containers = planContainers(sourceFile, registry)
315
325
  const targets = conversionTargets(sourceFile.getFilePath())
316
326
  const sites: SiteReport[] = []
@@ -375,6 +385,7 @@ function inspectFile(
375
385
  file: relative(projectRoot, sourceFile.getFilePath()),
376
386
  sites,
377
387
  functionalVariants,
388
+ sheetFrames,
378
389
  }
379
390
  }
380
391
 
@@ -528,5 +539,5 @@ if (write) {
528
539
  console.log(`wrote ${reportPath}`)
529
540
  if (write) console.log(`rewrote ${written} source files`)
530
541
  console.log(
531
- `${summary.sites} style 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.functionalVariantSites} functional variants: ${summary.functionalVariantConverted} automatic, ${summary.functionalVariantFlagged} flagged; ${summary.ignoredFiles} source files ignored`
542
+ `${summary.sites} style 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.functionalVariantSites} functional variants: ${summary.functionalVariantConverted} automatic, ${summary.functionalVariantFlagged} flagged; ${summary.sheetFrames} Sheet.Frame sites: ${summary.sheetFramesFlagged} need review; ${summary.ignoredFiles} source files ignored`
532
543
  )
package/src/report.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import type { Flag, SiteReport } from './convert'
2
2
  import type { FunctionalVariantReport } from './functionalVariants'
3
+ import type { SheetFrameReport } from './sheetAnatomy'
3
4
 
4
5
  export interface FileReport {
5
6
  file: string
6
7
  sites: SiteReport[]
7
8
  functionalVariants: FunctionalVariantReport[]
9
+ sheetFrames: SheetFrameReport[]
8
10
  }
9
11
 
10
12
  function countCodes(flags: Iterable<Flag>): Array<[string, number]> {
@@ -31,6 +33,9 @@ export interface ReportSummary {
31
33
  functionalVariantConverted: number
32
34
  functionalVariantFlagged: number
33
35
  functionalVariantFlags: Record<string, number>
36
+ sheetFrames: number
37
+ /** rewritten, but with a spread or a styled target a human has to place */
38
+ sheetFramesFlagged: number
34
39
  }
35
40
 
36
41
  export function renderReport(
@@ -42,6 +47,8 @@ export function renderReport(
42
47
  ): { text: string; summary: ReportSummary } {
43
48
  const sites = files.flatMap((file) => file.sites)
44
49
  const functionalVariants = files.flatMap((file) => file.functionalVariants)
50
+ const sheetFrames = files.flatMap((file) => file.sheetFrames)
51
+ const flaggedSheetFrames = sheetFrames.filter((site) => site.flags.length > 0)
45
52
  const convertedFunctionalVariants = functionalVariants.filter((site) => site.converted)
46
53
  const flaggedFunctionalVariants = functionalVariants.filter((site) => !site.converted)
47
54
  const clean = sites.filter(
@@ -72,22 +79,17 @@ export function renderReport(
72
79
  site.warnings.length === 0 &&
73
80
  site.assessmentVerdict === 'clean'
74
81
  ).length
75
- const readyFiles = files.filter(
76
- (file) =>
77
- (file.sites.length > 0 || file.functionalVariants.length > 0) &&
78
- file.sites.every((site) => site.legacyLeft === 0) &&
79
- file.functionalVariants.every((site) => site.converted)
80
- )
81
- const filesWithSites = files.filter(
82
- (file) => file.sites.length > 0 || file.functionalVariants.length > 0
83
- ).length
84
- const blockedFiles = files
85
- .filter(
86
- (file) =>
87
- file.sites.some((site) => site.legacyLeft > 0) ||
88
- file.functionalVariants.some((site) => !site.converted)
89
- )
90
- .map((file) => file.file)
82
+ const touched = (file: FileReport) =>
83
+ file.sites.length > 0 ||
84
+ file.functionalVariants.length > 0 ||
85
+ file.sheetFrames.length > 0
86
+ const blocked = (file: FileReport) =>
87
+ file.sites.some((site) => site.legacyLeft > 0) ||
88
+ file.functionalVariants.some((site) => !site.converted) ||
89
+ file.sheetFrames.some((site) => site.flags.length > 0)
90
+ const readyFiles = files.filter((file) => touched(file) && !blocked(file))
91
+ const filesWithSites = files.filter(touched).length
92
+ const blockedFiles = files.filter(blocked).map((file) => file.file)
91
93
  const functionalFlagCounts = countCodes(
92
94
  flaggedFunctionalVariants.flatMap((site) => [
93
95
  ...new Map(site.flags.map((flag) => [flag.code, flag])).values(),
@@ -119,6 +121,8 @@ export function renderReport(
119
121
  `- ${functionalVariants.length} functional variant sites found`,
120
122
  `- ${convertedFunctionalVariants.length} functional variants have automatic styled.dynamic rewrites`,
121
123
  `- ${flaggedFunctionalVariants.length} functional variants need manual migration`,
124
+ `- ${sheetFrames.length} Sheet.Frame sites rewritten to Sheet.Container plus Sheet.Background`,
125
+ `- ${flaggedSheetFrames.length} Sheet.Frame sites need a human to place a spread or a styled target`,
122
126
  '',
123
127
  '### Functional variant flag reasons',
124
128
  '',
@@ -128,7 +132,7 @@ export function renderReport(
128
132
  '',
129
133
  '### Remaining manual migration',
130
134
  '',
131
- `${readyFiles.length} of ${filesWithSites} files have no legacy condition object or flagged functional variant left after`,
135
+ `${readyFiles.length} of ${filesWithSites} files have no legacy condition object, flagged functional variant, or flagged Sheet.Frame left after`,
132
136
  'conversion. V3 has no compatibility setting; finish the remaining files directly:',
133
137
  blockedFiles.length
134
138
  ? blockedFiles.map((file) => `\`${file}\``).join(', ')
@@ -188,8 +192,30 @@ export function renderReport(
188
192
  }
189
193
 
190
194
  for (const file of files) {
191
- if (!file.sites.length && !file.functionalVariants.length) continue
195
+ if (!touched(file)) continue
192
196
  lines.push('', `## \`${file.file}\``, '')
197
+ for (const site of file.sheetFrames) {
198
+ lines.push(
199
+ `### ${site.label} at line ${site.line} (${site.flags.length ? 'review' : 'automatic'})`,
200
+ '',
201
+ 'Before:',
202
+ '',
203
+ '```tsx',
204
+ site.before,
205
+ '```',
206
+ '',
207
+ 'Automatic rewrite:',
208
+ '',
209
+ '```tsx',
210
+ site.after,
211
+ '```'
212
+ )
213
+ if (site.flags.length) {
214
+ lines.push('', 'Flags:', '')
215
+ for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`)
216
+ }
217
+ lines.push('')
218
+ }
193
219
  for (const site of file.functionalVariants) {
194
220
  lines.push(
195
221
  `### ${site.label} functional variant at line ${site.line} (${site.converted ? 'automatic' : 'manual'})`,
@@ -295,6 +321,8 @@ export function renderReport(
295
321
  functionalVariantConverted: convertedFunctionalVariants.length,
296
322
  functionalVariantFlagged: flaggedFunctionalVariants.length,
297
323
  functionalVariantFlags: Object.fromEntries(functionalFlagCounts),
324
+ sheetFrames: sheetFrames.length,
325
+ sheetFramesFlagged: flaggedSheetFrames.length,
298
326
  },
299
327
  }
300
328
  }