@tamagui/codemod-flat-values 0.0.0-bootstrap.0 → 3.0.0-beta.1093.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +234 -1
  2. package/dist/builtInNames.mjs +14 -0
  3. package/dist/builtInNames.mjs.map +1 -0
  4. package/dist/containers.mjs +141 -0
  5. package/dist/containers.mjs.map +1 -0
  6. package/dist/convert.mjs +1233 -0
  7. package/dist/convert.mjs.map +1 -0
  8. package/dist/expressions.mjs +188 -0
  9. package/dist/expressions.mjs.map +1 -0
  10. package/dist/functionalVariants.mjs +469 -0
  11. package/dist/functionalVariants.mjs.map +1 -0
  12. package/dist/grammar.mjs +73 -0
  13. package/dist/grammar.mjs.map +1 -0
  14. package/dist/index.mjs +374 -0
  15. package/dist/index.mjs.map +1 -0
  16. package/dist/legacyConditions.mjs +293 -0
  17. package/dist/legacyConditions.mjs.map +1 -0
  18. package/dist/legacyNames.mjs +130 -0
  19. package/dist/legacyNames.mjs.map +1 -0
  20. package/dist/provenance.mjs +137 -0
  21. package/dist/provenance.mjs.map +1 -0
  22. package/dist/report.mjs +188 -0
  23. package/dist/report.mjs.map +1 -0
  24. package/dist/sheetAnatomy.mjs +200 -0
  25. package/dist/sheetAnatomy.mjs.map +1 -0
  26. package/dist/structuredNative.mjs +275 -0
  27. package/dist/structuredNative.mjs.map +1 -0
  28. package/dist/transition.mjs +257 -0
  29. package/dist/transition.mjs.map +1 -0
  30. package/package.json +35 -7
  31. package/src/builtInNames.ts +23 -0
  32. package/src/containers.ts +227 -0
  33. package/src/convert.ts +1977 -0
  34. package/src/expressions.ts +220 -0
  35. package/src/functionalVariants.ts +642 -0
  36. package/src/grammar.ts +190 -0
  37. package/src/index.ts +589 -0
  38. package/src/legacyConditions.ts +357 -0
  39. package/src/legacyNames.ts +160 -0
  40. package/src/provenance.ts +210 -0
  41. package/src/report.ts +362 -0
  42. package/src/sheetAnatomy.ts +277 -0
  43. package/src/structuredNative.ts +459 -0
  44. package/src/transition.ts +415 -0
@@ -0,0 +1,188 @@
1
+ function countCodes(flags) {
2
+ const counts = /* @__PURE__ */ new Map();
3
+ for (const flag of flags) counts.set(flag.code, (counts.get(flag.code) ?? 0) + 1);
4
+ return [...counts].sort(([leftCode, leftCount], [rightCode, rightCount]) => rightCount - leftCount || leftCode.localeCompare(rightCode));
5
+ }
6
+ function renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, write = false) {
7
+ const sites = files.flatMap((file) => file.sites);
8
+ const functionalVariants = files.flatMap((file) => file.functionalVariants);
9
+ const sheetFrames = files.flatMap((file) => file.sheetFrames);
10
+ const flaggedSheetFrames = sheetFrames.filter((site) => site.flags.length > 0);
11
+ const transitions = files.flatMap((file) => file.transitions);
12
+ const flaggedTransitions = transitions.filter((site) => site.flags.length > 0);
13
+ const convertedFunctionalVariants = functionalVariants.filter((site) => site.converted);
14
+ const flaggedFunctionalVariants = functionalVariants.filter((site) => !site.converted);
15
+ const clean = sites.filter((site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === "clean");
16
+ const flagged = sites.filter((site) => site.flags.length > 0);
17
+ const warnings = sites.filter((site) => site.warnings.length > 0);
18
+ const needsRelocation = sites.filter((site) => site.assessmentVerdict === "needs-relocation");
19
+ const unknownHost = sites.filter((site) => site.assessmentVerdict === "unknown-host");
20
+ const ineligible = sites.filter((site) => site.assessmentVerdict === "ineligible");
21
+ const waiting = clean.filter((site) => site.programs.length === 0);
22
+ const jsx = sites.filter((site) => site.kind === "jsx");
23
+ const styled = sites.filter((site) => site.kind === "styled");
24
+ const cleanJsx = jsx.filter((site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === "clean").length;
25
+ const cleanStyled = styled.filter((site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === "clean").length;
26
+ const touched = (file) => file.sites.length > 0 || file.functionalVariants.length > 0 || file.sheetFrames.length > 0 || file.transitions.length > 0;
27
+ const blocked = (file) => file.sites.some((site) => site.legacyLeft > 0) || file.functionalVariants.some((site) => !site.converted) || file.sheetFrames.some((site) => site.flags.length > 0) || file.transitions.some((site) => site.flags.length > 0);
28
+ const readyFiles = files.filter((file) => touched(file) && !blocked(file));
29
+ const filesWithSites = files.filter(touched).length;
30
+ const blockedFiles = files.filter(blocked).map((file) => file.file);
31
+ const functionalFlagCounts = countCodes(flaggedFunctionalVariants.flatMap((site) => [...new Map(site.flags.map((flag) => [flag.code, flag])).values()]));
32
+ const lines = [
33
+ "# Flat-values codemod dry-run",
34
+ "",
35
+ `Corpus: ${corpus.map((entry) => `\`${entry}\``).join(", ")}.`,
36
+ "",
37
+ 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.",
38
+ "",
39
+ "## Summary",
40
+ "",
41
+ `- ${sites.length} conversion sites found`,
42
+ `- ${clean.length - waiting.length} converted with no open questions`,
43
+ `- ${needsRelocation.length} need relocation because the authored target or host cannot evaluate the conversion`,
44
+ `- ${unknownHost.length} have an unverified host type`,
45
+ `- ${ineligible.length} use properties that cannot carry flat clauses`,
46
+ `- ${waiting.length} have nothing to convert until the runtime catches up (see below)`,
47
+ `- ${flagged.length} have syntax or ordering flags for manual work`,
48
+ `- ${warnings.length} have configuration warnings for manual review`,
49
+ `- ${ignoredFiles} source files skipped by \`.tamagui-flat-values-ignore\` markers`,
50
+ `- ${jsx.length} JSX sites: ${cleanJsx} clean, ${jsx.length - cleanJsx} need review`,
51
+ `- ${styled.length} styled config sites: ${cleanStyled} clean, ${styled.length - cleanStyled} need review`,
52
+ `- ${functionalVariants.length} functional variant sites found`,
53
+ `- ${convertedFunctionalVariants.length} functional variants have automatic styled.dynamic rewrites`,
54
+ `- ${flaggedFunctionalVariants.length} functional variants need manual migration`,
55
+ `- ${sheetFrames.length} Sheet.Frame sites rewritten to Sheet.Container plus Sheet.Background`,
56
+ `- ${flaggedSheetFrames.length} Sheet.Frame sites need a human to place a spread or a styled target`,
57
+ `- ${transitions.length} v2 transition values rewritten to the v3 spelling`,
58
+ `- ${flaggedTransitions.length} v2 transition values need a hand migration`,
59
+ "",
60
+ "### Functional variant flag reasons",
61
+ "",
62
+ ...functionalFlagCounts.length ? functionalFlagCounts.map(([code, count]) => `- ${code}: ${count}`) : ["- none"],
63
+ "",
64
+ "### Remaining manual migration",
65
+ "",
66
+ `${readyFiles.length} of ${filesWithSites} files have no legacy condition object, flagged functional variant, or flagged Sheet.Frame left after`,
67
+ "conversion. V3 has no compatibility setting; finish the remaining files directly:",
68
+ blockedFiles.length ? blockedFiles.map((file) => `\`${file}\``).join(", ") : "every file in this corpus is fully migrated.",
69
+ "",
70
+ "### Flag reasons",
71
+ ""
72
+ ];
73
+ const flagCounts = countCodes(flagged.flatMap((site) => site.flags));
74
+ lines.push(...flagCounts.length ? flagCounts.map(([code, count]) => `- ${code}: ${count}`) : ["- none"]);
75
+ const warningCounts = countCodes(warnings.flatMap((site) => site.warnings));
76
+ lines.push("", "### Configuration warning reasons", "", ...warningCounts.length ? warningCounts.map(([code, count]) => `- ${code}: ${count}`) : ["- none"]);
77
+ const inventoryCounts = countCodes(sites.flatMap((site) => site.inventory));
78
+ if (inventoryCounts.length) {
79
+ lines.push("", "### Values left authored for another migration", "", "These are not flat-value migration work. The conversion keeps them exactly as", "authored and records them so their follow-up migrations have a corpus inventory.", "", ...inventoryCounts.map(([code, count]) => `- ${code}: ${count}`));
80
+ }
81
+ const pendingCounts = countCodes(sites.flatMap((site) => site.pending));
82
+ if (pendingCounts.length) {
83
+ lines.push("", "### Waiting on runtime support", "", "The conversion is known but not offered, because the runtime cannot read it yet.", "Each pending reason below names the exact host or merge contract that must land", "before the suggested source is safe to apply.", "", ...pendingCounts.map(([code, count]) => `- ${code}: ${count}`));
84
+ }
85
+ if (registryDiagnostics.length) {
86
+ lines.push("", "### Modifier registry diagnostics", "");
87
+ for (const diagnostic of registryDiagnostics) lines.push(`- ${diagnostic}`);
88
+ }
89
+ for (const file of files) {
90
+ if (!touched(file)) continue;
91
+ lines.push("", `## \`${file.file}\``, "");
92
+ for (const site of file.transitions) {
93
+ lines.push(`### ${site.label} at line ${site.line} (${site.flags.length ? "review" : "automatic"})`, "", "Before:", "", "```tsx", site.before, "```", "", "Automatic rewrite:", "", "```tsx", site.after, "```");
94
+ if (site.flags.length) {
95
+ lines.push("", "Flags:", "");
96
+ for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);
97
+ }
98
+ }
99
+ for (const site of file.sheetFrames) {
100
+ lines.push(`### ${site.label} at line ${site.line} (${site.flags.length ? "review" : "automatic"})`, "", "Before:", "", "```tsx", site.before, "```", "", "Automatic rewrite:", "", "```tsx", site.after, "```");
101
+ if (site.flags.length) {
102
+ lines.push("", "Flags:", "");
103
+ for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);
104
+ }
105
+ lines.push("");
106
+ }
107
+ for (const site of file.functionalVariants) {
108
+ lines.push(`### ${site.label} functional variant at line ${site.line} (${site.converted ? "automatic" : "manual"})`, "", "Before:", "", "```tsx", site.before, "```", "", site.converted ? "Automatic rewrite:" : "Left authored:", "", "```tsx", site.after, "```");
109
+ if (site.flags.length) {
110
+ lines.push("", "Flags:", "");
111
+ for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);
112
+ }
113
+ if (site.draft) {
114
+ lines.push("", "Generated `.resolve` draft:", "", "```tsx", site.draft, "```");
115
+ }
116
+ if (site.notes.length) {
117
+ lines.push("", "Notes:", "");
118
+ for (const note of site.notes) lines.push(`- ${note}`);
119
+ }
120
+ lines.push("");
121
+ }
122
+ for (const site of file.sites) {
123
+ const status = [
124
+ site.assessmentVerdict === "clean" ? null : site.assessmentVerdict,
125
+ site.flags.length ? "syntax-blocked" : null,
126
+ site.warnings.length ? "configuration-warning" : null
127
+ ].filter(Boolean).join(", ");
128
+ lines.push(`### ${site.label} at line ${site.line} (${status || "clean"})`, "", "Before:", "", "```tsx", site.before, "```", "", "After:", "", "```tsx", site.after, "```");
129
+ if (site.flags.length) {
130
+ lines.push("", "Flags:", "");
131
+ for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);
132
+ }
133
+ if (site.warnings.length) {
134
+ lines.push("", "Configuration warnings:", "");
135
+ for (const warning of site.warnings) {
136
+ lines.push(`- **${warning.code}**: ${warning.detail}`);
137
+ }
138
+ }
139
+ if (site.assessments.length) {
140
+ lines.push("", "Conversion assessment:", "");
141
+ for (const assessment of site.assessments) {
142
+ for (const reason of assessment.reasons) {
143
+ lines.push(`- **${assessment.verdict}: ${assessment.property}**: ${reason.message}. Remedy: ${reason.remedy}.`);
144
+ }
145
+ }
146
+ }
147
+ if (site.inventory.length) {
148
+ lines.push("", "Left authored:", "");
149
+ for (const flag of site.inventory) lines.push(`- **${flag.code}**: ${flag.detail}`);
150
+ }
151
+ if (site.pending.length) {
152
+ lines.push("", "Waiting on runtime support:", "");
153
+ for (const flag of site.pending) lines.push(`- **${flag.code}**: ${flag.detail}`);
154
+ }
155
+ if (site.notes.length) {
156
+ lines.push("", "Notes:", "");
157
+ for (const note of site.notes) lines.push(`- ${note}`);
158
+ }
159
+ lines.push("");
160
+ }
161
+ }
162
+ return {
163
+ text: `${lines.join("\n")}
164
+ `,
165
+ summary: {
166
+ sites: sites.length,
167
+ clean: clean.length,
168
+ needsRelocation: needsRelocation.length,
169
+ unknownHost: unknownHost.length,
170
+ ineligible: ineligible.length,
171
+ flagged: flagged.length,
172
+ warnings: warnings.length,
173
+ waiting: waiting.length,
174
+ ignoredFiles,
175
+ functionalVariantSites: functionalVariants.length,
176
+ functionalVariantConverted: convertedFunctionalVariants.length,
177
+ functionalVariantFlagged: flaggedFunctionalVariants.length,
178
+ functionalVariantFlags: Object.fromEntries(functionalFlagCounts),
179
+ sheetFrames: sheetFrames.length,
180
+ sheetFramesFlagged: flaggedSheetFrames.length,
181
+ transitions: transitions.length,
182
+ transitionsFlagged: flaggedTransitions.length
183
+ }
184
+ };
185
+ }
186
+
187
+ export { renderReport };
188
+ //# sourceMappingURL=report.mjs.map
@@ -0,0 +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 sheetFrames = files.flatMap((file) => file.sheetFrames);\n const flaggedSheetFrames = sheetFrames.filter((site) => site.flags.length > 0);\n const transitions = files.flatMap((file) => file.transitions);\n const flaggedTransitions = transitions.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 || file.transitions.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) || file.transitions.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 `- ${transitions.length} v2 transition values rewritten to the v3 spelling`,\n `- ${flaggedTransitions.length} v2 transition values need a hand 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, 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.transitions) {\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 }\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 transitions: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BAAgB;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;GACvC,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,IAA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