@pyreon/styler 0.11.6 → 0.11.7
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 +14 -12
- package/package.json +4 -4
- package/src/styled.tsx +24 -12
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, h, provide, useContext } from "@pyreon/core";
|
|
2
|
-
import { effect } from "@pyreon/reactivity";
|
|
2
|
+
import { effect, runUntracked } from "@pyreon/reactivity";
|
|
3
3
|
|
|
4
4
|
//#region src/resolve.ts
|
|
5
5
|
/**
|
|
@@ -827,17 +827,19 @@ const createStyledComponent = (tag, strings, values, options) => {
|
|
|
827
827
|
}, initialClassName, isDOM, customFilter);
|
|
828
828
|
if (isReactiveRS) effect(() => {
|
|
829
829
|
const newRS = $rs();
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
if (currentClassName)
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
830
|
+
runUntracked(() => {
|
|
831
|
+
const newCss = normalizeCSS(resolve(strings, values, {
|
|
832
|
+
...rawProps,
|
|
833
|
+
$rocketstyle: newRS,
|
|
834
|
+
theme
|
|
835
|
+
}));
|
|
836
|
+
const newClass = newCss.length > 0 ? sheet.insert(newCss, boost) : "";
|
|
837
|
+
if (el && newClass !== currentClassName) {
|
|
838
|
+
if (currentClassName) el.classList.remove(currentClassName);
|
|
839
|
+
if (newClass) el.classList.add(newClass);
|
|
840
|
+
currentClassName = newClass;
|
|
841
|
+
}
|
|
842
|
+
});
|
|
841
843
|
});
|
|
842
844
|
return h(finalTag, finalProps, ...Array.isArray(rawProps.children) ? rawProps.children : rawProps.children != null ? [rawProps.children] : []);
|
|
843
845
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/styler",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
4
4
|
"description": "Lightweight CSS-in-JS engine for Pyreon",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"typecheck": "tsc --noEmit"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@pyreon/typescript": "^0.11.
|
|
44
|
+
"@pyreon/typescript": "^0.11.7",
|
|
45
45
|
"@vitus-labs/tools-rolldown": "^1.15.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@pyreon/core": "^0.11.
|
|
49
|
-
"@pyreon/reactivity": "^0.11.
|
|
48
|
+
"@pyreon/core": "^0.11.7",
|
|
49
|
+
"@pyreon/reactivity": "^0.11.7"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">= 22"
|
package/src/styled.tsx
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type { ComponentFn, VNode } from '@pyreon/core'
|
|
19
19
|
import { h } from '@pyreon/core'
|
|
20
|
-
import { effect } from '@pyreon/reactivity'
|
|
20
|
+
import { effect, runUntracked } from '@pyreon/reactivity'
|
|
21
21
|
import { buildProps } from './forward'
|
|
22
22
|
import { type Interpolation, normalizeCSS, resolve } from './resolve'
|
|
23
23
|
import { isDynamic } from './shared'
|
|
@@ -163,19 +163,31 @@ const createStyledComponent = (
|
|
|
163
163
|
customFilter,
|
|
164
164
|
)
|
|
165
165
|
|
|
166
|
-
// Set up reactive class swap when $rocketstyle is a function accessor
|
|
166
|
+
// Set up reactive class swap when $rocketstyle is a function accessor.
|
|
167
|
+
// CRITICAL: only $rs() is tracked. resolve() and DOM mutations run
|
|
168
|
+
// inside runUntracked() to prevent subscribing to signals read by
|
|
169
|
+
// interpolation functions (theme properties, context getters, etc.).
|
|
170
|
+
// Without this, every styled component's effect subscribes to every
|
|
171
|
+
// signal touched during CSS resolution — causing an exponential
|
|
172
|
+
// cascade across 50+ components on any signal change.
|
|
167
173
|
if (isReactiveRS) {
|
|
168
174
|
effect(() => {
|
|
169
|
-
const newRS = $rs() //
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
const newRS = $rs() // TRACKED: subscribes to mode signal only
|
|
176
|
+
|
|
177
|
+
runUntracked(() => {
|
|
178
|
+
// UNTRACKED: resolve + DOM mutation — no additional subscriptions
|
|
179
|
+
const newResolvedProps = { ...rawProps, $rocketstyle: newRS }
|
|
180
|
+
const newCss = normalizeCSS(
|
|
181
|
+
resolve(strings, values, { ...newResolvedProps, theme }),
|
|
182
|
+
)
|
|
183
|
+
const newClass = newCss.length > 0 ? sheet.insert(newCss, boost) : ''
|
|
184
|
+
|
|
185
|
+
if (el && newClass !== currentClassName) {
|
|
186
|
+
if (currentClassName) el.classList.remove(currentClassName)
|
|
187
|
+
if (newClass) el.classList.add(newClass)
|
|
188
|
+
currentClassName = newClass
|
|
189
|
+
}
|
|
190
|
+
})
|
|
179
191
|
})
|
|
180
192
|
}
|
|
181
193
|
|