@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,293 @@
1
+ import { transformFamilyProps, unitlessNumberProperties } from "@tamagui/style-grammar/tooling";
2
+
3
+ const pseudoToModifier = Object.freeze({
4
+ hoverStyle: "hover",
5
+ pressStyle: "press",
6
+ focusStyle: "focus",
7
+ focusVisibleStyle: "focus-visible",
8
+ focusWithinStyle: "focus-within",
9
+ disabledStyle: "disabled",
10
+ enterStyle: "enter",
11
+ exitStyle: "exit"
12
+ });
13
+ const transformPartProperties = /* @__PURE__ */ new Set([
14
+ "scale",
15
+ "scaleX",
16
+ "scaleY",
17
+ "rotate",
18
+ "rotateX",
19
+ "rotateY",
20
+ "rotateZ",
21
+ "x",
22
+ "y",
23
+ "skewX",
24
+ "skewY",
25
+ "perspective"
26
+ ]);
27
+ function resolveLegacyCondition(propName, registry) {
28
+ const pseudoModifier = pseudoToModifier[propName];
29
+ if (pseudoModifier !== void 0) {
30
+ return registry.get(pseudoModifier) === "state" ? {
31
+ recognized: true,
32
+ modifiers: [pseudoModifier]
33
+ } : {
34
+ recognized: true,
35
+ error: {
36
+ code: "unregistered-legacy-condition",
37
+ message: `legacy condition "${propName}" maps to unregistered state modifier "${pseudoModifier}"`
38
+ }
39
+ };
40
+ }
41
+ if (propName.startsWith("$theme-")) {
42
+ const modifier = propName.slice("$theme-".length);
43
+ return modifier && registry.get(modifier) === "theme" ? {
44
+ recognized: true,
45
+ modifiers: [modifier]
46
+ } : {
47
+ recognized: true,
48
+ error: {
49
+ code: "unregistered-legacy-condition",
50
+ message: `legacy theme condition "${propName}" does not name a registered theme`
51
+ }
52
+ };
53
+ }
54
+ if (propName.startsWith("$platform-")) {
55
+ const modifier = propName.slice("$platform-".length);
56
+ return modifier && registry.get(modifier) === "platform" ? {
57
+ recognized: true,
58
+ modifiers: [modifier]
59
+ } : {
60
+ recognized: true,
61
+ error: {
62
+ code: "unregistered-legacy-condition",
63
+ message: `legacy platform condition "${propName}" does not name a registered platform`
64
+ }
65
+ };
66
+ }
67
+ if (propName.startsWith("$group-")) {
68
+ const remainder = propName.slice("$group-".length);
69
+ const candidates = [];
70
+ let start = 0;
71
+ while (start < remainder.length) {
72
+ const state2 = remainder.slice(start);
73
+ if (registry.get(state2) === "state") candidates.push(state2);
74
+ const dash = remainder.indexOf("-", start);
75
+ if (dash === -1) break;
76
+ start = dash + 1;
77
+ }
78
+ const longestLength = candidates.reduce((length, state2) => Math.max(length, state2.length), 0);
79
+ const longest = candidates.filter((state2) => state2.length === longestLength);
80
+ if (longest.length > 1) {
81
+ return {
82
+ recognized: true,
83
+ error: {
84
+ code: "ambiguous-legacy-group",
85
+ message: `legacy group condition "${propName}" has more than one equally specific state suffix`
86
+ }
87
+ };
88
+ }
89
+ const state = longest.length === 1 ? longest[0] : null;
90
+ let namePart = state === null ? remainder : state.length === remainder.length ? "" : remainder.slice(0, -(state.length + 1));
91
+ let media = null;
92
+ if (namePart) {
93
+ let scanStart = 0;
94
+ while (scanStart < namePart.length) {
95
+ const suffix2 = namePart.slice(scanStart);
96
+ if (registry.get(`@${suffix2}`) === "container") {
97
+ media = suffix2;
98
+ break;
99
+ }
100
+ const dash = namePart.indexOf("-", scanStart);
101
+ if (dash === -1) break;
102
+ scanStart = dash + 1;
103
+ }
104
+ if (media !== null) {
105
+ namePart = media.length === namePart.length ? "" : namePart.slice(0, -(media.length + 1));
106
+ } else if (state === null) {
107
+ return {
108
+ recognized: true,
109
+ error: {
110
+ code: "unregistered-legacy-condition",
111
+ message: `legacy group condition "${propName}" has no registered state or container-size suffix`
112
+ }
113
+ };
114
+ }
115
+ } else if (state === null) {
116
+ return {
117
+ recognized: true,
118
+ error: {
119
+ code: "unregistered-legacy-condition",
120
+ message: `legacy group condition "${propName}" has no registered state suffix`
121
+ }
122
+ };
123
+ }
124
+ const suffix = namePart ? `/${namePart}` : "";
125
+ const modifiers = [];
126
+ if (media !== null) modifiers.push(`@${media}${suffix}`);
127
+ if (state !== null) modifiers.push(`group-${state}${suffix}`);
128
+ return {
129
+ recognized: true,
130
+ modifiers
131
+ };
132
+ }
133
+ if (propName[0] === "$") {
134
+ const modifier = propName.slice(1);
135
+ const kind = registry.get(modifier);
136
+ if (kind === "media" || kind === "container") {
137
+ return {
138
+ recognized: true,
139
+ modifiers: [modifier]
140
+ };
141
+ }
142
+ }
143
+ return { recognized: false };
144
+ }
145
+ function isConditionObject(value) {
146
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
147
+ const prototype = Object.getPrototypeOf(value);
148
+ return prototype === Object.prototype || prototype === null;
149
+ }
150
+ function convertStyleValue(prop, value, path, errors) {
151
+ if (transformPartProperties.has(prop) && !transformFamilyProps.has(prop)) {
152
+ errors.push({
153
+ code: "legacy-transform-part",
154
+ path,
155
+ 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)`
156
+ });
157
+ return null;
158
+ }
159
+ if (typeof value === "number" && Number.isFinite(value) && transformFamilyProps.has(prop)) {
160
+ if (prop === "rotate") return value === 0 ? "0deg" : `${value}deg`;
161
+ if (prop === "x" || prop === "y") return value === 0 ? "0" : `${value}px`;
162
+ return String(value);
163
+ }
164
+ if (typeof value === "string") {
165
+ const text = value.replace(/\$(-?\d+)\.(\d+)\b/g, "$$$1-$2");
166
+ if (!text.length) {
167
+ errors.push({
168
+ code: "unsupported-legacy-value",
169
+ path,
170
+ message: "an empty string cannot become a condition clause payload"
171
+ });
172
+ return null;
173
+ }
174
+ if (text.indexOf("$") === -1) return text;
175
+ if (text.includes("\"") || text.includes("'") || text.includes("url(")) {
176
+ errors.push({
177
+ code: "unsupported-legacy-value",
178
+ path,
179
+ message: `"${text}" mixes "$" with quoted or url() content; migrate the token spelling by hand`
180
+ });
181
+ return null;
182
+ }
183
+ if (/\$[\w-]*\./.test(text)) {
184
+ errors.push({
185
+ code: "legacy-token-dot-path",
186
+ path,
187
+ message: `legacy token in "${text}" uses dot-path naming; rename it to one configured flat token name before conversion`
188
+ });
189
+ return null;
190
+ }
191
+ if (/\$-?\d/.test(text) && !/^\$-?[\w-]+$/.test(text)) {
192
+ errors.push({
193
+ code: "legacy-numeric-composite-token",
194
+ path,
195
+ message: `numeric token in "${text}" is embedded in a composite value; replace it with its resolved CSS value before conversion`
196
+ });
197
+ return null;
198
+ }
199
+ if (/\$(?![\w-])/.test(text)) {
200
+ errors.push({
201
+ code: "unsupported-legacy-value",
202
+ path,
203
+ message: `"$" in "${text}" is not followed by a token name`
204
+ });
205
+ return null;
206
+ }
207
+ return text.replace(/\$([\w-]+)/g, "$1");
208
+ }
209
+ if (typeof value === "number") {
210
+ if (Number.isFinite(value)) {
211
+ return unitlessNumberProperties.has(prop) ? String(value) : `${value}px`;
212
+ }
213
+ errors.push({
214
+ code: "unsupported-legacy-value",
215
+ path,
216
+ message: `non-finite number ${String(value)} cannot become a CSS payload`
217
+ });
218
+ return null;
219
+ }
220
+ errors.push({
221
+ code: "unsupported-legacy-value",
222
+ path,
223
+ message: `legacy condition value for "${prop}" must be a string or finite number`
224
+ });
225
+ return null;
226
+ }
227
+ function convertLegacyConditionProp(propName, value, options) {
228
+ const root = resolveLegacyCondition(propName, options.registry);
229
+ if (!root.recognized) return null;
230
+ const result = {
231
+ contributions: [],
232
+ errors: []
233
+ };
234
+ if ("error" in root) {
235
+ result.errors.push({
236
+ ...root.error,
237
+ path: propName
238
+ });
239
+ return result;
240
+ }
241
+ if (!isConditionObject(value)) {
242
+ result.errors.push({
243
+ code: "legacy-condition-object",
244
+ path: propName,
245
+ message: `legacy condition "${propName}" must contain a style object`
246
+ });
247
+ return result;
248
+ }
249
+ const modifiers = root.modifiers.slice();
250
+ const visit = (object, objectPath) => {
251
+ for (const childProp in object) {
252
+ const childValue = object[childProp];
253
+ const childPath = `${objectPath}.${childProp}`;
254
+ const condition = resolveLegacyCondition(childProp, options.registry);
255
+ if (condition.recognized) {
256
+ if ("error" in condition) {
257
+ result.errors.push({
258
+ ...condition.error,
259
+ path: childPath
260
+ });
261
+ continue;
262
+ }
263
+ if (!isConditionObject(childValue)) {
264
+ result.errors.push({
265
+ code: "legacy-condition-object",
266
+ path: childPath,
267
+ message: `legacy condition "${childProp}" must contain a style object`
268
+ });
269
+ continue;
270
+ }
271
+ modifiers.push(...condition.modifiers);
272
+ visit(childValue, childPath);
273
+ modifiers.length -= condition.modifiers.length;
274
+ continue;
275
+ }
276
+ const payload = convertStyleValue(childProp, childValue, childPath, result.errors);
277
+ if (payload !== null) {
278
+ result.contributions.push({
279
+ prop: childProp,
280
+ clause: {
281
+ modifiers: modifiers.slice(),
282
+ payload
283
+ }
284
+ });
285
+ }
286
+ }
287
+ };
288
+ visit(value, propName);
289
+ return result;
290
+ }
291
+
292
+ export { convertLegacyConditionProp, pseudoToModifier };
293
+ //# sourceMappingURL=legacyConditions.mjs.map
@@ -0,0 +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 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,yCAAyC,eAAe;GACjG;EACF;CACF;CACA,IAAI,SAAS,WAAW,SAAS,GAAG;EAClC,MAAM,WAAW,SAAS,MAAM,UAAU,MAAM;EAChD,OAAO,YAAY,SAAS,IAAI,QAAQ,MAAM,UAAU;GAAE,YAAY;GAAM,WAAW,CAAC,QAAQ;EAAE,IAAI;GACpG,YAAY;GACZ,OAAO;IACL,MAAM;IACN,SAAS,2BAA2B,SAAS;GAC/C;EACF;CACF;CACA,IAAI,SAAS,WAAW,YAAY,GAAG;EACrC,MAAM,WAAW,SAAS,MAAM,aAAa,MAAM;EACnD,OAAO,YAAY,SAAS,IAAI,QAAQ,MAAM,aAAa;GAAE,YAAY;GAAM,WAAW,CAAC,QAAQ;EAAE,IAAI;GACvG,YAAY;GACZ,OAAO;IACL,MAAM;IACN,SAAS,8BAA8B,SAAS;GAClD;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grammarPlatformNames, pseudoToModifier } from "./grammar.mjs";
2
+
3
+ function isLegacyConditionName(name) {
4
+ return name.startsWith("$") || pseudoToModifier[name] !== void 0;
5
+ }
6
+ function kebab(name) {
7
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
8
+ }
9
+ function mediaName(name, registry) {
10
+ if (registry.get(name) === "media") return name;
11
+ const kebabbed = kebab(name);
12
+ return registry.get(kebabbed) === "media" ? kebabbed : null;
13
+ }
14
+ function longestSuffix(parts, resolve) {
15
+ for (let start = 0; start < parts.length; start++) {
16
+ const resolved = resolve(parts.slice(start).join("-"));
17
+ if (resolved !== null) return {
18
+ value: resolved,
19
+ rest: parts.slice(0, start)
20
+ };
21
+ }
22
+ return null;
23
+ }
24
+ function resolveGroupName(name, registry) {
25
+ const parts = name.slice("$group-".length).split("-");
26
+ const state = longestSuffix(parts, (candidate) => registry.get(candidate) === "state" ? candidate : null);
27
+ const beforeState = state ? state.rest : parts;
28
+ const size = longestSuffix(beforeState, (candidate) => mediaName(candidate, registry));
29
+ const group = (size ? size.rest : beforeState).join("-") || null;
30
+ const suffix = group === null ? "" : `/${group}`;
31
+ if (!state && !size) {
32
+ return {
33
+ ok: false,
34
+ code: "legacy-group-presence",
35
+ message: `"${name}" styles every descendant of the group unconditionally; V3 has no group-presence condition, so move the value to the base program or add a state`
36
+ };
37
+ }
38
+ if (!size) {
39
+ return {
40
+ ok: true,
41
+ resolved: {
42
+ canonical: name,
43
+ replaceRoot: null,
44
+ container: null
45
+ }
46
+ };
47
+ }
48
+ const modifiers = [`@${size.value}${suffix}`];
49
+ if (state) modifiers.push(`group-${state.value}${suffix}`);
50
+ for (const modifier of modifiers) {
51
+ if (registry.get(modifier) === void 0) {
52
+ return {
53
+ ok: false,
54
+ code: "unregistered-legacy-condition",
55
+ message: `"${name}" needs modifier "${modifier}", which is not registered`
56
+ };
57
+ }
58
+ }
59
+ return {
60
+ ok: true,
61
+ resolved: {
62
+ canonical: state ? `$group-${group === null ? "" : `${group}-`}${state.value}` : `$${size.value}`,
63
+ replaceRoot: modifiers,
64
+ container: {
65
+ size: size.value,
66
+ group
67
+ }
68
+ }
69
+ };
70
+ }
71
+ function resolveLegacyName(name, registry) {
72
+ if (pseudoToModifier[name] !== void 0 || name.startsWith("$theme-")) {
73
+ return {
74
+ ok: true,
75
+ resolved: {
76
+ canonical: name,
77
+ replaceRoot: null,
78
+ container: null
79
+ }
80
+ };
81
+ }
82
+ if (name.startsWith("$platform-")) {
83
+ return {
84
+ ok: true,
85
+ resolved: {
86
+ canonical: name,
87
+ replaceRoot: null,
88
+ container: null
89
+ }
90
+ };
91
+ }
92
+ if (name.startsWith("$group-")) return resolveGroupName(name, registry);
93
+ if (name.startsWith("$")) {
94
+ const bare = name.slice(1);
95
+ if (grammarPlatformNames.has(bare)) {
96
+ return {
97
+ ok: true,
98
+ resolved: {
99
+ canonical: `$platform-${bare}`,
100
+ replaceRoot: null,
101
+ container: null
102
+ }
103
+ };
104
+ }
105
+ const media = mediaName(bare, registry);
106
+ if (media !== null) {
107
+ return {
108
+ ok: true,
109
+ resolved: {
110
+ canonical: `$${media}`,
111
+ replaceRoot: null,
112
+ container: null
113
+ }
114
+ };
115
+ }
116
+ return {
117
+ ok: false,
118
+ code: "unknown-legacy-condition",
119
+ message: `"${name}" is not a registered legacy condition spelling`
120
+ };
121
+ }
122
+ return {
123
+ ok: false,
124
+ code: "unknown-legacy-condition",
125
+ message: `"${name}" is not a registered legacy condition spelling`
126
+ };
127
+ }
128
+
129
+ export { isLegacyConditionName, resolveLegacyName };
130
+ //# sourceMappingURL=legacyNames.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacyNames.js","names":[],"sources":["legacyNames.js"],"sourcesContent":["import {\n grammarPlatformNames,\n pseudoToModifier\n} from \"./grammar\";\nfunction isLegacyConditionName(name) {\n return name.startsWith(\"$\") || pseudoToModifier[name] !== void 0;\n}\nfunction kebab(name) {\n return name.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\nfunction mediaName(name, registry) {\n if (registry.get(name) === \"media\") return name;\n const kebabbed = kebab(name);\n return registry.get(kebabbed) === \"media\" ? kebabbed : null;\n}\nfunction longestSuffix(parts, resolve) {\n for (let start = 0; start < parts.length; start++) {\n const resolved = resolve(parts.slice(start).join(\"-\"));\n if (resolved !== null) return { value: resolved, rest: parts.slice(0, start) };\n }\n return null;\n}\nfunction resolveGroupName(name, registry) {\n const parts = name.slice(\"$group-\".length).split(\"-\");\n const state = longestSuffix(\n parts,\n (candidate) => registry.get(candidate) === \"state\" ? candidate : null\n );\n const beforeState = state ? state.rest : parts;\n const size = longestSuffix(beforeState, (candidate) => mediaName(candidate, registry));\n const group = (size ? size.rest : beforeState).join(\"-\") || null;\n const suffix = group === null ? \"\" : `/${group}`;\n if (!state && !size) {\n return {\n ok: false,\n code: \"legacy-group-presence\",\n message: `\"${name}\" styles every descendant of the group unconditionally; V3 has no group-presence condition, so move the value to the base program or add a state`\n };\n }\n if (!size) {\n return { ok: true, resolved: { canonical: name, replaceRoot: null, container: null } };\n }\n const modifiers = [`@${size.value}${suffix}`];\n if (state) modifiers.push(`group-${state.value}${suffix}`);\n for (const modifier of modifiers) {\n if (registry.get(modifier) === void 0) {\n return {\n ok: false,\n code: \"unregistered-legacy-condition\",\n message: `\"${name}\" needs modifier \"${modifier}\", which is not registered`\n };\n }\n }\n return {\n ok: true,\n resolved: {\n // any registered root works: `replaceRoot` substitutes the whole chain\n canonical: state ? `$group-${group === null ? \"\" : `${group}-`}${state.value}` : `$${size.value}`,\n replaceRoot: modifiers,\n container: { size: size.value, group }\n }\n };\n}\nfunction resolveLegacyName(name, registry) {\n if (pseudoToModifier[name] !== void 0 || name.startsWith(\"$theme-\")) {\n return { ok: true, resolved: { canonical: name, replaceRoot: null, container: null } };\n }\n if (name.startsWith(\"$platform-\")) {\n return { ok: true, resolved: { canonical: name, replaceRoot: null, container: null } };\n }\n if (name.startsWith(\"$group-\")) return resolveGroupName(name, registry);\n if (name.startsWith(\"$\")) {\n const bare = name.slice(1);\n if (grammarPlatformNames.has(bare)) {\n return {\n ok: true,\n resolved: {\n canonical: `$platform-${bare}`,\n replaceRoot: null,\n container: null\n }\n };\n }\n const media = mediaName(bare, registry);\n if (media !== null) {\n return {\n ok: true,\n resolved: { canonical: `$${media}`, replaceRoot: null, container: null }\n };\n }\n return {\n ok: false,\n code: \"unknown-legacy-condition\",\n message: `\"${name}\" is not a registered legacy condition spelling`\n };\n }\n return {\n ok: false,\n code: \"unknown-legacy-condition\",\n message: `\"${name}\" is not a registered legacy condition spelling`\n };\n}\nexport {\n isLegacyConditionName,\n resolveLegacyName\n};\n//# sourceMappingURL=legacyNames.js.map\n"],"mappings":";;;AAIA,SAAS,sBAAsB,MAAM;CACnC,OAAO,KAAK,WAAW,GAAG,KAAK,iBAAiB,UAAU,KAAK;AACjE;AACA,SAAS,MAAM,MAAM;CACnB,OAAO,KAAK,QAAQ,sBAAsB,OAAO,CAAC,CAAC,YAAY;AACjE;AACA,SAAS,UAAU,MAAM,UAAU;CACjC,IAAI,SAAS,IAAI,IAAI,MAAM,SAAS,OAAO;CAC3C,MAAM,WAAW,MAAM,IAAI;CAC3B,OAAO,SAAS,IAAI,QAAQ,MAAM,UAAU,WAAW;AACzD;AACA,SAAS,cAAc,OAAO,SAAS;CACrC,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,WAAW,QAAQ,MAAM,MAAM,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC;EACrD,IAAI,aAAa,MAAM,OAAO;GAAE,OAAO;GAAU,MAAM,MAAM,MAAM,GAAG,KAAK;EAAE;CAC/E;CACA,OAAO;AACT;AACA,SAAS,iBAAiB,MAAM,UAAU;CACxC,MAAM,QAAQ,KAAK,MAAM,UAAU,MAAM,CAAC,CAAC,MAAM,GAAG;CACpD,MAAM,QAAQ,cACZ,QACC,cAAc,SAAS,IAAI,SAAS,MAAM,UAAU,YAAY,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AG,OAAO,iBAAiB,MAAM,QAAQ;CACtE,IAAI,KAAK,WAAW,GAAG,GAAG;EACxB,MAAM,OAAO,KAAK,MAAM,CAAC;EACzB,IAAI,qBAAqB,IAAI,IAAI,GAAG;GAClC,OAAO;IACL,IAAI;IACJ,UAAU;KACR,WAAW,aAAa;KACxB,aAAa;KACb,WAAW;IACb;GACF;EACF;EACA,MAAM,QAAQ,UAAU,MAAM,QAAQ;EACtC,IAAI,UAAU,MAAM;GAClB,OAAO;IACL,IAAI;IACJ,UAAU;KAAE,WAAW,IAAI;KAAS,aAAa;KAAM,WAAW;IAAK;GACzE;EACF;EACA,OAAO;GACL,IAAI;GACJ,MAAM;GACN,SAAS,IAAI,KAAK;EACpB;CACF;CACA,OAAO;EACL,IAAI;EACJ,MAAM;EACN,SAAS,IAAI,KAAK;CACpB;AACF"}
@@ -0,0 +1,137 @@
1
+ import { Node, SyntaxKind } from "ts-morph";
2
+
3
+ const tamaguiModule = /^(tamagui|@tamagui\/)/;
4
+ function rootIdentifier(node) {
5
+ let current = node;
6
+ while (Node.isPropertyAccessExpression(current)) current = current.getExpression();
7
+ return Node.isIdentifier(current) ? current : null;
8
+ }
9
+ function createProvenance() {
10
+ const resolved = /* @__PURE__ */ new Map();
11
+ const active = /* @__PURE__ */ new Set();
12
+ const fromDeclaration = (declaration) => {
13
+ const cached = resolved.get(declaration);
14
+ if (cached !== void 0) return cached;
15
+ if (active.has(declaration)) return false;
16
+ active.add(declaration);
17
+ const answer = computeDeclaration(declaration);
18
+ active.delete(declaration);
19
+ resolved.set(declaration, answer);
20
+ return answer;
21
+ };
22
+ const fromModule = (specifier, source, name) => {
23
+ if (tamaguiModule.test(specifier)) return true;
24
+ if (source === void 0) return false;
25
+ return exportedBinding(source, name);
26
+ };
27
+ const bindings = /* @__PURE__ */ new Map();
28
+ const openBindings = /* @__PURE__ */ new Set();
29
+ const exportedBinding = (source, name) => {
30
+ const key = `${source.getFilePath()}#${name}`;
31
+ const cached = bindings.get(key);
32
+ if (cached !== void 0) return cached;
33
+ if (openBindings.has(key)) return false;
34
+ openBindings.add(key);
35
+ const answer = computeBinding(source, name);
36
+ openBindings.delete(key);
37
+ bindings.set(key, answer);
38
+ return answer;
39
+ };
40
+ const computeBinding = (source, name) => {
41
+ for (const declaration of source.getExportDeclarations()) {
42
+ const specifier = declaration.getModuleSpecifierValue();
43
+ const named = declaration.getNamedExports();
44
+ if (specifier === void 0) {
45
+ for (const element of named) {
46
+ if ((element.getAliasNode() ?? element.getNameNode()).getText() !== name) {
47
+ continue;
48
+ }
49
+ if (fromDeclaration(element)) return true;
50
+ }
51
+ continue;
52
+ }
53
+ if (!named.length && !declaration.getNamespaceExport()) {
54
+ if (fromModule(specifier, declaration.getModuleSpecifierSourceFile(), name)) {
55
+ return true;
56
+ }
57
+ continue;
58
+ }
59
+ for (const element of named) {
60
+ if ((element.getAliasNode() ?? element.getNameNode()).getText() !== name) continue;
61
+ if (fromModule(specifier, declaration.getModuleSpecifierSourceFile(), element.getName())) {
62
+ return true;
63
+ }
64
+ }
65
+ }
66
+ for (const [exportName, declarations] of source.getExportedDeclarations()) {
67
+ if (exportName !== name) continue;
68
+ for (const declaration of declarations) {
69
+ if (fromDeclaration(declaration)) return true;
70
+ }
71
+ }
72
+ return false;
73
+ };
74
+ const computeDeclaration = (declaration) => {
75
+ if (Node.isImportSpecifier(declaration)) {
76
+ const importDeclaration = declaration.getImportDeclaration();
77
+ return fromModule(importDeclaration.getModuleSpecifierValue(), importDeclaration.getModuleSpecifierSourceFile(), declaration.getName());
78
+ }
79
+ if (Node.isImportClause(declaration) || Node.isNamespaceImport(declaration)) {
80
+ const importDeclaration = declaration.getFirstAncestorByKindOrThrow(SyntaxKind.ImportDeclaration);
81
+ return tamaguiModule.test(importDeclaration.getModuleSpecifierValue());
82
+ }
83
+ if (Node.isExportSpecifier(declaration)) {
84
+ const exportDeclaration = declaration.getExportDeclaration();
85
+ const specifier = exportDeclaration.getModuleSpecifierValue();
86
+ if (specifier !== void 0) {
87
+ return fromModule(specifier, exportDeclaration.getModuleSpecifierSourceFile(), declaration.getName());
88
+ }
89
+ for (const local of declaration.getLocalTargetDeclarations()) {
90
+ if (fromDeclaration(local)) return true;
91
+ }
92
+ return false;
93
+ }
94
+ if (Node.isVariableDeclaration(declaration)) {
95
+ const initializer = declaration.getInitializer();
96
+ return initializer !== void 0 && isTamaguiValue(initializer);
97
+ }
98
+ return false;
99
+ };
100
+ const fromIdentifier = (identifier) => {
101
+ const symbol = identifier.getSymbol();
102
+ if (symbol === void 0) return false;
103
+ for (const declaration of symbol.getDeclarations()) {
104
+ if (fromDeclaration(declaration)) return true;
105
+ }
106
+ const aliased = symbol.getAliasedSymbol();
107
+ if (aliased === void 0) return false;
108
+ for (const declaration of aliased.getDeclarations()) {
109
+ if (fromDeclaration(declaration)) return true;
110
+ }
111
+ return false;
112
+ };
113
+ const isTamaguiStyledCall = (call) => {
114
+ const callee = rootIdentifier(call.getExpression());
115
+ if (callee === null || callee.getText() !== "styled") return false;
116
+ return fromIdentifier(callee);
117
+ };
118
+ function isTamaguiValue(expression) {
119
+ let current = expression;
120
+ while (Node.isParenthesizedExpression(current) || Node.isAsExpression(current) || Node.isNonNullExpression(current)) {
121
+ current = current.getExpression();
122
+ }
123
+ const identifier = rootIdentifier(Node.isCallExpression(current) ? current.getExpression() : current);
124
+ return identifier !== null && fromIdentifier(identifier);
125
+ }
126
+ return {
127
+ isTamaguiElement: (opening) => {
128
+ const tag = rootIdentifier(opening.getTagNameNode());
129
+ if (tag === null || !/^[A-Z_$]/.test(tag.getText())) return false;
130
+ return fromIdentifier(tag);
131
+ },
132
+ isTamaguiStyledCall
133
+ };
134
+ }
135
+
136
+ export { createProvenance };
137
+ //# sourceMappingURL=provenance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance.js","names":[],"sources":["provenance.js"],"sourcesContent":["import {\n Node,\n SyntaxKind\n} from \"ts-morph\";\nconst tamaguiModule = /^(tamagui|@tamagui\\/)/;\nfunction rootIdentifier(node) {\n let current = node;\n while (Node.isPropertyAccessExpression(current)) current = current.getExpression();\n return Node.isIdentifier(current) ? current : null;\n}\nfunction createProvenance() {\n const resolved = /* @__PURE__ */ new Map();\n const active = /* @__PURE__ */ new Set();\n const fromDeclaration = (declaration) => {\n const cached = resolved.get(declaration);\n if (cached !== void 0) return cached;\n if (active.has(declaration)) return false;\n active.add(declaration);\n const answer = computeDeclaration(declaration);\n active.delete(declaration);\n resolved.set(declaration, answer);\n return answer;\n };\n const fromModule = (specifier, source, name) => {\n if (tamaguiModule.test(specifier)) return true;\n if (source === void 0) return false;\n return exportedBinding(source, name);\n };\n const bindings = /* @__PURE__ */ new Map();\n const openBindings = /* @__PURE__ */ new Set();\n const exportedBinding = (source, name) => {\n const key = `${source.getFilePath()}#${name}`;\n const cached = bindings.get(key);\n if (cached !== void 0) return cached;\n if (openBindings.has(key)) return false;\n openBindings.add(key);\n const answer = computeBinding(source, name);\n openBindings.delete(key);\n bindings.set(key, answer);\n return answer;\n };\n const computeBinding = (source, name) => {\n for (const declaration of source.getExportDeclarations()) {\n const specifier = declaration.getModuleSpecifierValue();\n const named = declaration.getNamedExports();\n if (specifier === void 0) {\n for (const element of named) {\n if ((element.getAliasNode() ?? element.getNameNode()).getText() !== name) {\n continue;\n }\n if (fromDeclaration(element)) return true;\n }\n continue;\n }\n if (!named.length && !declaration.getNamespaceExport()) {\n if (fromModule(specifier, declaration.getModuleSpecifierSourceFile(), name)) {\n return true;\n }\n continue;\n }\n for (const element of named) {\n if ((element.getAliasNode() ?? element.getNameNode()).getText() !== name) continue;\n if (fromModule(\n specifier,\n declaration.getModuleSpecifierSourceFile(),\n element.getName()\n )) {\n return true;\n }\n }\n }\n for (const [exportName, declarations] of source.getExportedDeclarations()) {\n if (exportName !== name) continue;\n for (const declaration of declarations) {\n if (fromDeclaration(declaration)) return true;\n }\n }\n return false;\n };\n const computeDeclaration = (declaration) => {\n if (Node.isImportSpecifier(declaration)) {\n const importDeclaration = declaration.getImportDeclaration();\n return fromModule(\n importDeclaration.getModuleSpecifierValue(),\n importDeclaration.getModuleSpecifierSourceFile(),\n declaration.getName()\n );\n }\n if (Node.isImportClause(declaration) || Node.isNamespaceImport(declaration)) {\n const importDeclaration = declaration.getFirstAncestorByKindOrThrow(\n SyntaxKind.ImportDeclaration\n );\n return tamaguiModule.test(importDeclaration.getModuleSpecifierValue());\n }\n if (Node.isExportSpecifier(declaration)) {\n const exportDeclaration = declaration.getExportDeclaration();\n const specifier = exportDeclaration.getModuleSpecifierValue();\n if (specifier !== void 0) {\n return fromModule(\n specifier,\n exportDeclaration.getModuleSpecifierSourceFile(),\n declaration.getName()\n );\n }\n for (const local of declaration.getLocalTargetDeclarations()) {\n if (fromDeclaration(local)) return true;\n }\n return false;\n }\n if (Node.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n return initializer !== void 0 && isTamaguiValue(initializer);\n }\n return false;\n };\n const fromIdentifier = (identifier) => {\n const symbol = identifier.getSymbol();\n if (symbol === void 0) return false;\n for (const declaration of symbol.getDeclarations()) {\n if (fromDeclaration(declaration)) return true;\n }\n const aliased = symbol.getAliasedSymbol();\n if (aliased === void 0) return false;\n for (const declaration of aliased.getDeclarations()) {\n if (fromDeclaration(declaration)) return true;\n }\n return false;\n };\n const isTamaguiStyledCall = (call) => {\n const callee = rootIdentifier(call.getExpression());\n if (callee === null || callee.getText() !== \"styled\") return false;\n return fromIdentifier(callee);\n };\n function isTamaguiValue(expression) {\n let current = expression;\n while (Node.isParenthesizedExpression(current) || Node.isAsExpression(current) || Node.isNonNullExpression(current)) {\n current = current.getExpression();\n }\n const identifier = rootIdentifier(\n Node.isCallExpression(current) ? current.getExpression() : current\n );\n return identifier !== null && fromIdentifier(identifier);\n }\n return {\n isTamaguiElement: (opening) => {\n const tag = rootIdentifier(opening.getTagNameNode());\n if (tag === null || !/^[A-Z_$]/.test(tag.getText())) return false;\n return fromIdentifier(tag);\n },\n isTamaguiStyledCall\n };\n}\nexport {\n create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