@vitus-labs/unistyle 1.4.3-alpha.1 → 1.4.3-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js
CHANGED
|
@@ -154,9 +154,7 @@ const transformTheme = ({ theme, breakpoints }) => {
|
|
|
154
154
|
* breakpoint-per-property), optimizes (deduplicates identical breakpoints),
|
|
155
155
|
* and wraps each breakpoint's styles in the appropriate `@media` query.
|
|
156
156
|
*/
|
|
157
|
-
|
|
158
|
-
let lastBreakpointsRef = null;
|
|
159
|
-
let lastOptimized = null;
|
|
157
|
+
const themeCache = /* @__PURE__ */ new WeakMap();
|
|
160
158
|
const makeItResponsive = ({ theme: customTheme, key = "", css, styles, normalize = true }) => ({ theme = {}, ...props }) => {
|
|
161
159
|
const internalTheme = customTheme || props[key];
|
|
162
160
|
if (isEmpty(internalTheme)) return "";
|
|
@@ -172,7 +170,8 @@ const makeItResponsive = ({ theme: customTheme, key = "", css, styles, normalize
|
|
|
172
170
|
`;
|
|
173
171
|
const { media, sortedBreakpoints } = __VITUS_LABS__;
|
|
174
172
|
let optimizedTheme;
|
|
175
|
-
|
|
173
|
+
const cached = themeCache.get(internalTheme);
|
|
174
|
+
if (cached && cached.breakpoints === sortedBreakpoints) optimizedTheme = cached.optimized;
|
|
176
175
|
else {
|
|
177
176
|
let helperTheme = internalTheme;
|
|
178
177
|
if (normalize) helperTheme = normalizeTheme({
|
|
@@ -186,9 +185,10 @@ const makeItResponsive = ({ theme: customTheme, key = "", css, styles, normalize
|
|
|
186
185
|
}),
|
|
187
186
|
breakpoints: sortedBreakpoints
|
|
188
187
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
themeCache.set(internalTheme, {
|
|
189
|
+
breakpoints: sortedBreakpoints,
|
|
190
|
+
optimized: optimizedTheme
|
|
191
|
+
});
|
|
192
192
|
}
|
|
193
193
|
return sortedBreakpoints.map((item) => {
|
|
194
194
|
const breakpointTheme = optimizedTheme[item];
|
|
@@ -154,9 +154,7 @@ const transformTheme = ({ theme, breakpoints }) => {
|
|
|
154
154
|
* breakpoint-per-property), optimizes (deduplicates identical breakpoints),
|
|
155
155
|
* and wraps each breakpoint's styles in the appropriate `@media` query.
|
|
156
156
|
*/
|
|
157
|
-
|
|
158
|
-
let lastBreakpointsRef = null;
|
|
159
|
-
let lastOptimized = null;
|
|
157
|
+
const themeCache = /* @__PURE__ */ new WeakMap();
|
|
160
158
|
const makeItResponsive = ({ theme: customTheme, key = "", css, styles, normalize = true }) => ({ theme = {}, ...props }) => {
|
|
161
159
|
const internalTheme = customTheme || props[key];
|
|
162
160
|
if (isEmpty(internalTheme)) return "";
|
|
@@ -172,7 +170,8 @@ const makeItResponsive = ({ theme: customTheme, key = "", css, styles, normalize
|
|
|
172
170
|
`;
|
|
173
171
|
const { media, sortedBreakpoints } = __VITUS_LABS__;
|
|
174
172
|
let optimizedTheme;
|
|
175
|
-
|
|
173
|
+
const cached = themeCache.get(internalTheme);
|
|
174
|
+
if (cached && cached.breakpoints === sortedBreakpoints) optimizedTheme = cached.optimized;
|
|
176
175
|
else {
|
|
177
176
|
let helperTheme = internalTheme;
|
|
178
177
|
if (normalize) helperTheme = normalizeTheme({
|
|
@@ -186,9 +185,10 @@ const makeItResponsive = ({ theme: customTheme, key = "", css, styles, normalize
|
|
|
186
185
|
}),
|
|
187
186
|
breakpoints: sortedBreakpoints
|
|
188
187
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
themeCache.set(internalTheme, {
|
|
189
|
+
breakpoints: sortedBreakpoints,
|
|
190
|
+
optimized: optimizedTheme
|
|
191
|
+
});
|
|
192
192
|
}
|
|
193
193
|
return sortedBreakpoints.map((item) => {
|
|
194
194
|
const breakpointTheme = optimizedTheme[item];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/unistyle",
|
|
3
|
-
"version": "1.4.3-alpha.
|
|
3
|
+
"version": "1.4.3-alpha.4+4f526f8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"react": ">= 19"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@vitus-labs/core": "1.4.3-alpha.
|
|
55
|
+
"@vitus-labs/core": "1.4.3-alpha.4+4f526f8",
|
|
56
56
|
"@vitus-labs/tools-rolldown": "^1.6.0",
|
|
57
57
|
"@vitus-labs/tools-typescript": "^1.6.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "4f526f89193039b02d6232d42fa487b6fd2a5970"
|
|
60
60
|
}
|