Skip to content

Commit 8e6ff82

Browse files
committed
chore(mobile): upgrade Uniwind to 1.13.0
- Update platform variant fixtures and expectations for the new metadata format
1 parent b874ff6 commit 8e6ff82

5 files changed

Lines changed: 45 additions & 35 deletions

File tree

‎apps/mobile/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"shiki": "4.2.0",
144144
"tailwind-merge": "^3.5.0",
145145
"unified": "catalog:",
146-
"uniwind": "1.12.1"
146+
"uniwind": "1.13.0"
147147
},
148148
"devDependencies": {
149149
"@babel/core": "^7.29.7",

‎apps/mobile/src/lib/uniwind-platform-variants.fixture.cjs‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,27 @@ async function main() {
9999
const compiled = addMetaToStylesTemplate(processor, platform);
100100
const payload = compileNativeCSS(bundlerConfig, tailwindCSS);
101101
const styles = {};
102+
// Compiled entries keep only their generated `matches` predicate; the
103+
// conditions they were built from live on the processor's style metadata.
102104
for (const [className, entries] of Object.entries(compiled)) {
103-
styles[className] = entries.map(
104-
({ native, minWidth, maxWidth, active, focus, disabled, dataAttributes }) => ({
105-
native,
106-
minWidth,
107-
maxWidth,
108-
active: active ?? null,
109-
focus: focus ?? null,
110-
disabled: disabled ?? null,
111-
dataAttributes: dataAttributes ?? null,
112-
}),
113-
);
105+
styles[className] = entries.map(({ index }) => {
106+
const {
107+
platform: guard,
108+
conditions,
109+
active,
110+
focus,
111+
disabled,
112+
dataAttributes,
113+
} = processor.stylesheets[className][index].meta;
114+
return {
115+
platform: guard,
116+
responsive: conditions.some((condition) => condition.includes("rt.screen.width")),
117+
active,
118+
focus,
119+
disabled,
120+
dataAttributes,
121+
};
122+
});
114123
}
115124
platforms[platform] = {
116125
styles,

‎apps/mobile/src/lib/uniwind-platform-variants.test.ts‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import * as NodeURL from "node:url";
66
import { beforeAll, describe, expect, it } from "vite-plus/test";
77

88
interface CompiledStyle {
9-
native: boolean;
10-
minWidth: number;
11-
maxWidth: number;
9+
platform: string | null;
10+
responsive: boolean;
1211
active: boolean | null;
1312
focus: boolean | null;
1413
disabled: boolean | null;
@@ -101,7 +100,9 @@ describe("uniwind platform variants compile per platform", () => {
101100
`android has ${className}`,
102101
).toBeUndefined();
103102
expect(output.platforms.ios?.styles[className], `ios lacks ${className}`).toBeDefined();
104-
expect(output.platforms.ios?.styles[className]?.every((style) => style.native)).toBe(true);
103+
expect(
104+
output.platforms.ios?.styles[className]?.every((style) => style.platform === "ios"),
105+
).toBe(true);
105106
}
106107
});
107108

@@ -112,9 +113,9 @@ describe("uniwind platform variants compile per platform", () => {
112113
output.platforms.android?.styles[className],
113114
`android lacks ${className}`,
114115
).toBeDefined();
115-
expect(output.platforms.android?.styles[className]?.every((style) => style.native)).toBe(
116-
true,
117-
);
116+
expect(
117+
output.platforms.android?.styles[className]?.every((style) => style.platform === "android"),
118+
).toBe(true);
118119
}
119120
});
120121

@@ -123,13 +124,13 @@ describe("uniwind platform variants compile per platform", () => {
123124
for (const platform of ["ios", "android"]) {
124125
const styles = output.platforms[platform]?.styles[className];
125126
expect(styles, `${platform} lacks ${className}`).toBeDefined();
126-
expect(styles?.every((style) => !style.native)).toBe(true);
127+
expect(styles?.every((style) => style.platform === null)).toBe(true);
127128
}
128129
}
129130
for (const platform of ["ios", "android"]) {
130131
for (const className of RESPONSIVE_CLASSES) {
131132
const style = output.platforms[platform]?.styles[className]?.at(-1);
132-
expect(style?.minWidth, `${className} lost its breakpoint`).toBeGreaterThan(0);
133+
expect(style?.responsive, `${className} lost its breakpoint`).toBe(true);
133134
}
134135
}
135136
});
@@ -174,19 +175,19 @@ describe("uniwind keeps media rules nested inside class rules attached to the cl
174175
for (const platform of ["ios", "android"]) {
175176
const entries = nested.platforms[platform]?.styles["container-x"];
176177
expect(entries, `${platform} lacks container-x`).toBeDefined();
177-
expect(entries?.some((style) => !style.native && style.minWidth === 0)).toBe(true);
178-
expect(entries?.some((style) => !style.native && style.minWidth > 0)).toBe(true);
178+
expect(entries?.some((style) => style.platform === null && !style.responsive)).toBe(true);
179+
expect(entries?.some((style) => style.platform === null && style.responsive)).toBe(true);
179180
}
180181
});
181182

182183
it("keeps @variant declarations inside @utility on their platform", () => {
183184
const iosEntries = nested.platforms.ios?.styles["foo-x"];
184-
expect(iosEntries?.some((style) => !style.native)).toBe(true);
185-
expect(iosEntries?.some((style) => style.native)).toBe(true);
185+
expect(iosEntries?.some((style) => style.platform === null)).toBe(true);
186+
expect(iosEntries?.some((style) => style.platform === "ios")).toBe(true);
186187

187188
const androidEntries = nested.platforms.android?.styles["foo-x"];
188-
expect(androidEntries?.some((style) => !style.native)).toBe(true);
189-
expect(androidEntries?.some((style) => style.native)).toBe(false);
189+
expect(androidEntries?.some((style) => style.platform === null)).toBe(true);
190+
expect(androidEntries?.some((style) => style.platform !== null)).toBe(false);
190191
});
191192
});
192193

‎pnpm-lock.yaml‎

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ minimumReleaseAgeExclude:
165165
- "@distilled.cloud/[email protected]"
166166
- "@shadcn/[email protected]"
167167
168-
- uniwind@1.12.1
168+
- uniwind@1.13.0
169169
170170
171171

0 commit comments

Comments
 (0)