@pyreon/styler 0.14.0 → 0.16.0
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.d.ts +8 -2
- package/lib/index.js +87 -21
- package/package.json +9 -8
- package/src/ThemeProvider.ts +5 -1
- package/src/__tests__/dev-gate-treeshake.test.ts +85 -0
- package/src/__tests__/native-marker.test.ts +9 -0
- package/src/__tests__/sheet.test.ts +87 -2
- package/src/__tests__/styled.test.ts +110 -0
- package/src/env.d.ts +6 -0
- package/src/resolve.ts +2 -5
- package/src/sheet.ts +47 -9
- package/src/styled.tsx +123 -15
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as _pyreon_core0 from "@pyreon/core";
|
|
1
|
+
import * as _$_pyreon_core0 from "@pyreon/core";
|
|
2
2
|
import { ComponentFn, VNode, VNodeChild } from "@pyreon/core";
|
|
3
3
|
|
|
4
4
|
//#region src/ThemeProvider.d.ts
|
|
@@ -16,7 +16,7 @@ type Theme = DefaultTheme & Record<string, unknown>;
|
|
|
16
16
|
* - String-equality memoization (same CSS class = no DOM update)
|
|
17
17
|
* - Untracked resolve (no exponential cascade)
|
|
18
18
|
*/
|
|
19
|
-
declare const ThemeContext: _pyreon_core0.ReactiveContext<Theme>;
|
|
19
|
+
declare const ThemeContext: _$_pyreon_core0.ReactiveContext<Theme>;
|
|
20
20
|
/**
|
|
21
21
|
* Read the current theme. Returns the theme value (calls the accessor).
|
|
22
22
|
* Inside a reactive scope (computed/effect), this tracks theme changes.
|
|
@@ -204,6 +204,12 @@ declare class StyleSheet {
|
|
|
204
204
|
/**
|
|
205
205
|
* Full cleanup: clear cache and remove all CSS rules from the DOM.
|
|
206
206
|
* Intended for HMR / dev-time reloads where stale styles must be purged.
|
|
207
|
+
*
|
|
208
|
+
* Also fires `onSheetClear` subscribers so downstream caches (e.g.
|
|
209
|
+
* `styled.tsx`'s static-component cache) reset alongside the sheet.
|
|
210
|
+
* Without this, stale `StaticStyled` ComponentFn references survive HMR
|
|
211
|
+
* and continue to apply CSS class names that were just deleted from
|
|
212
|
+
* the DOM — observable as missing styles after every hot reload.
|
|
207
213
|
*/
|
|
208
214
|
clearAll(): void;
|
|
209
215
|
/**
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createReactiveContext, h, provide, useContext } from "@pyreon/core";
|
|
1
|
+
import { createReactiveContext, h, nativeCompat, provide, useContext } from "@pyreon/core";
|
|
2
2
|
import { computed, renderEffect, runUntracked } from "@pyreon/reactivity";
|
|
3
3
|
|
|
4
4
|
//#region src/resolve.ts
|
|
5
|
-
const _countSink$
|
|
5
|
+
const _countSink$2 = globalThis;
|
|
6
6
|
/**
|
|
7
7
|
* Lazy representation of a `css` tagged template. Stores the raw template
|
|
8
8
|
* strings and interpolation values without resolving them. Resolution is
|
|
@@ -20,7 +20,7 @@ var CSSResult = class {
|
|
|
20
20
|
};
|
|
21
21
|
/** Resolve a tagged template's strings + values into a final CSS string. */
|
|
22
22
|
const resolve = (strings, values, props) => {
|
|
23
|
-
if (
|
|
23
|
+
if (process.env.NODE_ENV !== "production") _countSink$2.__pyreon_count__?.("styler.resolve");
|
|
24
24
|
let result = strings[0];
|
|
25
25
|
for (let i = 0; i < values.length; i++) {
|
|
26
26
|
const v = values[i];
|
|
@@ -414,7 +414,8 @@ const hash = (str) => hashFinalize(hashUpdate(HASH_INIT, str));
|
|
|
414
414
|
* Media queries (@media), @supports, and @container blocks nested inside
|
|
415
415
|
* component CSS are automatically extracted into separate top-level rules.
|
|
416
416
|
*/
|
|
417
|
-
const _countSink = globalThis;
|
|
417
|
+
const _countSink$1 = globalThis;
|
|
418
|
+
const __DEV__ = process.env.NODE_ENV !== "production";
|
|
418
419
|
const PREFIX = "pyr";
|
|
419
420
|
const ATTR = "data-pyreon-styler";
|
|
420
421
|
const DEFAULT_MAX_CACHE_SIZE = 1e4;
|
|
@@ -554,11 +555,11 @@ var StyleSheet = class {
|
|
|
554
555
|
* via @layer order (base < rocketstyle) instead of specificity hacks.
|
|
555
556
|
*/
|
|
556
557
|
insert(cssText, _unused = false, insertLayer) {
|
|
557
|
-
if (
|
|
558
|
+
if (process.env.NODE_ENV !== "production") _countSink$1.__pyreon_count__?.("styler.sheet.insert");
|
|
558
559
|
const icKey = insertLayer ? `${cssText}\0L:${insertLayer}` : cssText;
|
|
559
560
|
const icHit = this.insertCache.get(icKey);
|
|
560
561
|
if (icHit) {
|
|
561
|
-
if (
|
|
562
|
+
if (process.env.NODE_ENV !== "production") _countSink$1.__pyreon_count__?.("styler.sheet.insert.hit");
|
|
562
563
|
return icHit;
|
|
563
564
|
}
|
|
564
565
|
const className = `${PREFIX}-${hash(cssText)}`;
|
|
@@ -579,7 +580,7 @@ var StyleSheet = class {
|
|
|
579
580
|
else if (this.sheet) for (const rule of finalRules) try {
|
|
580
581
|
this.sheet.insertRule(rule, this.sheet.cssRules.length);
|
|
581
582
|
} catch (_e) {
|
|
582
|
-
if (
|
|
583
|
+
if (__DEV__) console.warn("[styler] Failed to insert CSS rule:", rule, _e);
|
|
583
584
|
}
|
|
584
585
|
this.insertCache.set(icKey, className);
|
|
585
586
|
return className;
|
|
@@ -594,7 +595,7 @@ var StyleSheet = class {
|
|
|
594
595
|
else if (this.sheet) try {
|
|
595
596
|
this.sheet.insertRule(rule, this.sheet.cssRules.length);
|
|
596
597
|
} catch (_e) {
|
|
597
|
-
if (
|
|
598
|
+
if (__DEV__) console.warn("[styler] Failed to insert @keyframes rule:", rule, _e);
|
|
598
599
|
}
|
|
599
600
|
}
|
|
600
601
|
/**
|
|
@@ -631,7 +632,7 @@ var StyleSheet = class {
|
|
|
631
632
|
for (const rule of rules) try {
|
|
632
633
|
this.sheet.insertRule(rule, this.sheet.cssRules.length);
|
|
633
634
|
} catch (_e) {
|
|
634
|
-
if (
|
|
635
|
+
if (__DEV__) console.warn("[styler] Failed to insert global CSS rule:", rule, _e);
|
|
635
636
|
}
|
|
636
637
|
}
|
|
637
638
|
}
|
|
@@ -664,6 +665,12 @@ var StyleSheet = class {
|
|
|
664
665
|
/**
|
|
665
666
|
* Full cleanup: clear cache and remove all CSS rules from the DOM.
|
|
666
667
|
* Intended for HMR / dev-time reloads where stale styles must be purged.
|
|
668
|
+
*
|
|
669
|
+
* Also fires `onSheetClear` subscribers so downstream caches (e.g.
|
|
670
|
+
* `styled.tsx`'s static-component cache) reset alongside the sheet.
|
|
671
|
+
* Without this, stale `StaticStyled` ComponentFn references survive HMR
|
|
672
|
+
* and continue to apply CSS class names that were just deleted from
|
|
673
|
+
* the DOM — observable as missing styles after every hot reload.
|
|
667
674
|
*/
|
|
668
675
|
clearAll() {
|
|
669
676
|
this.cache.clear();
|
|
@@ -671,6 +678,7 @@ var StyleSheet = class {
|
|
|
671
678
|
clearNormCache();
|
|
672
679
|
this.ssrBuffer = [];
|
|
673
680
|
if (this.sheet) while (this.sheet.cssRules.length > 0) this.sheet.deleteRule(0);
|
|
681
|
+
fireSheetClearSubscribers();
|
|
674
682
|
}
|
|
675
683
|
/**
|
|
676
684
|
* Compute className and full CSS rule text without injecting.
|
|
@@ -709,6 +717,22 @@ const sheet = new StyleSheet();
|
|
|
709
717
|
* Use in SSR to get per-request isolation.
|
|
710
718
|
*/
|
|
711
719
|
const createSheet = (options) => new StyleSheet(options);
|
|
720
|
+
const _sheetClearSubscribers = /* @__PURE__ */ new Set();
|
|
721
|
+
const fireSheetClearSubscribers = () => {
|
|
722
|
+
for (const cb of _sheetClearSubscribers) cb();
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Subscribe to `sheet.clearAll()`. Fires after the sheet has been
|
|
726
|
+
* fully cleared, so subscribers can drop downstream caches that depend
|
|
727
|
+
* on the sheet's class names being live in the DOM.
|
|
728
|
+
*
|
|
729
|
+
* Returns a disposer for symmetry; in practice subscribers register
|
|
730
|
+
* once at module load and never unsubscribe.
|
|
731
|
+
*/
|
|
732
|
+
const onSheetClear = (callback) => {
|
|
733
|
+
_sheetClearSubscribers.add(callback);
|
|
734
|
+
return () => _sheetClearSubscribers.delete(callback);
|
|
735
|
+
};
|
|
712
736
|
|
|
713
737
|
//#endregion
|
|
714
738
|
//#region src/ThemeProvider.ts
|
|
@@ -743,6 +767,7 @@ function ThemeProvider({ theme, children }) {
|
|
|
743
767
|
provide(ThemeContext, () => theme);
|
|
744
768
|
return children ?? null;
|
|
745
769
|
}
|
|
770
|
+
nativeCompat(ThemeProvider);
|
|
746
771
|
|
|
747
772
|
//#endregion
|
|
748
773
|
//#region src/globalStyle.ts
|
|
@@ -795,21 +820,30 @@ const keyframes = (strings, ...values) => new KeyframesResult(strings, values);
|
|
|
795
820
|
|
|
796
821
|
//#endregion
|
|
797
822
|
//#region src/styled.tsx
|
|
823
|
+
const _countSink = globalThis;
|
|
798
824
|
const getDisplayName = (tag) => typeof tag === "string" ? tag : tag.displayName || tag.name || "Component";
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
825
|
+
let staticComponentCache = /* @__PURE__ */ new WeakMap();
|
|
826
|
+
const _hotCache = {
|
|
827
|
+
strings: null,
|
|
828
|
+
tag: null,
|
|
829
|
+
component: null
|
|
830
|
+
};
|
|
831
|
+
onSheetClear(() => {
|
|
832
|
+
staticComponentCache = /* @__PURE__ */ new WeakMap();
|
|
833
|
+
_hotCache.strings = null;
|
|
834
|
+
_hotCache.tag = null;
|
|
835
|
+
_hotCache.component = null;
|
|
836
|
+
});
|
|
803
837
|
const createStyledComponent = (tag, strings, values, options) => {
|
|
804
838
|
if (values.length === 0 && !options) {
|
|
805
|
-
if (strings ===
|
|
839
|
+
if (strings === _hotCache.strings && tag === _hotCache.tag) return _hotCache.component;
|
|
806
840
|
const tagMap = staticComponentCache.get(strings);
|
|
807
841
|
if (tagMap) {
|
|
808
842
|
const cached = tagMap.get(tag);
|
|
809
843
|
if (cached) {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
844
|
+
_hotCache.strings = strings;
|
|
845
|
+
_hotCache.tag = tag;
|
|
846
|
+
_hotCache.component = cached;
|
|
813
847
|
return cached;
|
|
814
848
|
}
|
|
815
849
|
}
|
|
@@ -820,9 +854,20 @@ const createStyledComponent = (tag, strings, values, options) => {
|
|
|
820
854
|
if (!hasDynamicValues) {
|
|
821
855
|
const cssText = normalizeCSS(values.length === 0 ? strings[0] : resolve(strings, values, {}));
|
|
822
856
|
const staticClassName = cssText.length > 0 ? sheet.insert(cssText, false, insertLayer) : "";
|
|
857
|
+
const tagIsDOM = typeof tag === "string";
|
|
858
|
+
const cachedEmptyVNode = h(tag, staticClassName ? { class: staticClassName } : {});
|
|
823
859
|
const StaticStyled = (rawProps) => {
|
|
860
|
+
let hasExtraProps = false;
|
|
861
|
+
for (const _k in rawProps) {
|
|
862
|
+
hasExtraProps = true;
|
|
863
|
+
break;
|
|
864
|
+
}
|
|
865
|
+
if (!hasExtraProps && rawProps.ref == null) {
|
|
866
|
+
if (process.env.NODE_ENV !== "production") _countSink.__pyreon_count__?.("styler.staticVNode.hit");
|
|
867
|
+
return cachedEmptyVNode;
|
|
868
|
+
}
|
|
824
869
|
const finalTag = rawProps.as || tag;
|
|
825
|
-
return h(finalTag, buildProps(rawProps, staticClassName, typeof finalTag === "string", customFilter), ...Array.isArray(rawProps.children) ? rawProps.children : rawProps.children != null ? [rawProps.children] : []);
|
|
870
|
+
return h(finalTag, buildProps(rawProps, staticClassName, finalTag === tag ? tagIsDOM : typeof finalTag === "string", customFilter), ...Array.isArray(rawProps.children) ? rawProps.children : rawProps.children != null ? [rawProps.children] : []);
|
|
826
871
|
};
|
|
827
872
|
StaticStyled.displayName = `styled(${getDisplayName(tag)})`;
|
|
828
873
|
if (!options && values.length === 0) {
|
|
@@ -832,13 +877,14 @@ const createStyledComponent = (tag, strings, values, options) => {
|
|
|
832
877
|
staticComponentCache.set(strings, tagMap);
|
|
833
878
|
}
|
|
834
879
|
tagMap.set(tag, StaticStyled);
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
880
|
+
_hotCache.strings = strings;
|
|
881
|
+
_hotCache.tag = tag;
|
|
882
|
+
_hotCache.component = StaticStyled;
|
|
838
883
|
}
|
|
839
884
|
return StaticStyled;
|
|
840
885
|
}
|
|
841
886
|
const classCache = /* @__PURE__ */ new WeakMap();
|
|
887
|
+
const elClassCache = /* @__PURE__ */ new WeakMap();
|
|
842
888
|
const DynamicStyled = (rawProps) => {
|
|
843
889
|
const themeAccessor = useThemeAccessor();
|
|
844
890
|
const theme = themeAccessor();
|
|
@@ -854,6 +900,19 @@ const createStyledComponent = (tag, strings, values, options) => {
|
|
|
854
900
|
if (cached !== void 0) return cached;
|
|
855
901
|
}
|
|
856
902
|
}
|
|
903
|
+
const $el = rawProps.$element;
|
|
904
|
+
const $childFix = rawProps.$childFix;
|
|
905
|
+
const useElCache = (!rs || typeof rs !== "object" || !rsState || typeof rsState !== "object") && $el && typeof $el === "object";
|
|
906
|
+
if (useElCache) {
|
|
907
|
+
const inner = elClassCache.get($el);
|
|
908
|
+
if (inner) {
|
|
909
|
+
const cached = inner.get($childFix);
|
|
910
|
+
if (cached !== void 0) {
|
|
911
|
+
if (process.env.NODE_ENV !== "production") _countSink.__pyreon_count__?.("styler.elClassCache.hit");
|
|
912
|
+
return cached;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
857
916
|
const cssText = normalizeCSS(resolve(strings, values, {
|
|
858
917
|
...rawProps,
|
|
859
918
|
...isReactiveRS ? { $rocketstyle: rs } : {},
|
|
@@ -868,6 +927,13 @@ const createStyledComponent = (tag, strings, values, options) => {
|
|
|
868
927
|
classCache.set(rs, inner);
|
|
869
928
|
}
|
|
870
929
|
inner.set(rsState, className);
|
|
930
|
+
} else if (useElCache) {
|
|
931
|
+
let inner = elClassCache.get($el);
|
|
932
|
+
if (!inner) {
|
|
933
|
+
inner = /* @__PURE__ */ new Map();
|
|
934
|
+
elClassCache.set($el, inner);
|
|
935
|
+
}
|
|
936
|
+
inner.set($childFix, className);
|
|
871
937
|
}
|
|
872
938
|
return className;
|
|
873
939
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/styler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Lightweight CSS-in-JS engine for Pyreon",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"lib",
|
|
13
|
+
"!lib/**/*.map",
|
|
13
14
|
"!lib/analysis",
|
|
14
15
|
"README.md",
|
|
15
16
|
"LICENSE",
|
|
@@ -41,16 +42,16 @@
|
|
|
41
42
|
"typecheck": "tsc --noEmit"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@pyreon/test-utils": "^0.13.
|
|
45
|
-
"@pyreon/typescript": "^0.
|
|
45
|
+
"@pyreon/test-utils": "^0.13.3",
|
|
46
|
+
"@pyreon/typescript": "^0.16.0",
|
|
46
47
|
"@vitest/browser-playwright": "^4.1.4",
|
|
47
|
-
"@vitus-labs/tools-rolldown": "^
|
|
48
|
-
},
|
|
49
|
-
"peerDependencies": {
|
|
50
|
-
"@pyreon/core": "^0.14.0",
|
|
51
|
-
"@pyreon/reactivity": "^0.14.0"
|
|
48
|
+
"@vitus-labs/tools-rolldown": "^2.3.0"
|
|
52
49
|
},
|
|
53
50
|
"engines": {
|
|
54
51
|
"node": ">= 22"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@pyreon/core": "^0.16.0",
|
|
55
|
+
"@pyreon/reactivity": "^0.16.0"
|
|
55
56
|
}
|
|
56
57
|
}
|
package/src/ThemeProvider.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* }
|
|
13
13
|
*/
|
|
14
14
|
import type { VNode, VNodeChild } from '@pyreon/core'
|
|
15
|
-
import { createReactiveContext, provide, useContext } from '@pyreon/core'
|
|
15
|
+
import { createReactiveContext, nativeCompat, provide, useContext } from '@pyreon/core'
|
|
16
16
|
|
|
17
17
|
export interface DefaultTheme {}
|
|
18
18
|
|
|
@@ -59,3 +59,7 @@ export function ThemeProvider({
|
|
|
59
59
|
provide(ThemeContext, () => theme)
|
|
60
60
|
return (children ?? null) as VNode | null
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
// Mark as native — compat-mode jsx() runtimes skip wrapCompatComponent so
|
|
64
|
+
// provide(ThemeContext, ...) reaches Pyreon's setup frame.
|
|
65
|
+
nativeCompat(ThemeProvider)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { describe, expect, it } from 'vitest'
|
|
6
|
+
import { build } from 'vite'
|
|
7
|
+
|
|
8
|
+
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
9
|
+
const SRC = path.resolve(here, '..')
|
|
10
|
+
|
|
11
|
+
// Bundle-level regression test for the styler dev-gate fix.
|
|
12
|
+
//
|
|
13
|
+
// Background — the shape of the problem:
|
|
14
|
+
// `process.env.NODE_ENV !== 'production'` is dead code in real Vite
|
|
15
|
+
// browser bundles because Vite does not polyfill `process`. The
|
|
16
|
+
// `console.warn` calls inside the gate were silently dropped in
|
|
17
|
+
// production, which masked malformed-CSS bugs (insertRule failures
|
|
18
|
+
// produced no diagnostic — empty <style> tag, classes assigned, no
|
|
19
|
+
// console output).
|
|
20
|
+
//
|
|
21
|
+
// The fix is to use bundler-agnostic `process.env.NODE_ENV !== 'production'`
|
|
22
|
+
// — every modern bundler auto-replaces `process.env.NODE_ENV` at consumer
|
|
23
|
+
// build time. This test bundles `sheet.ts` through Vite's production build
|
|
24
|
+
// and asserts the dev-warning strings are GONE. It also bundles in dev
|
|
25
|
+
// mode and asserts the strings are PRESENT, so a source-level deletion
|
|
26
|
+
// can't trivially pass the prod test.
|
|
27
|
+
//
|
|
28
|
+
// Mirrors `packages/core/runtime-dom/src/tests/dev-gate-treeshake.test.ts`.
|
|
29
|
+
|
|
30
|
+
const DEV_WARNING_STRINGS = [
|
|
31
|
+
'[styler] Failed to insert CSS rule:',
|
|
32
|
+
'[styler] Failed to insert @keyframes rule:',
|
|
33
|
+
'[styler] Failed to insert global CSS rule:',
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
async function bundleWithVite(entry: string, dev: boolean): Promise<string> {
|
|
37
|
+
const outDir = mkdtempSync(path.join(tmpdir(), 'pyreon-styler-treeshake-'))
|
|
38
|
+
try {
|
|
39
|
+
await build({
|
|
40
|
+
mode: dev ? 'development' : 'production',
|
|
41
|
+
logLevel: 'error',
|
|
42
|
+
configFile: false,
|
|
43
|
+
resolve: { conditions: ['bun'] },
|
|
44
|
+
define: {
|
|
45
|
+
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production'),
|
|
46
|
+
},
|
|
47
|
+
build: {
|
|
48
|
+
// PINNED minifier — see runtime-dom's tree-shake test for rationale.
|
|
49
|
+
minify: dev ? false : 'esbuild',
|
|
50
|
+
target: 'esnext',
|
|
51
|
+
write: true,
|
|
52
|
+
outDir,
|
|
53
|
+
emptyOutDir: true,
|
|
54
|
+
lib: {
|
|
55
|
+
entry,
|
|
56
|
+
formats: ['es'],
|
|
57
|
+
fileName: 'out',
|
|
58
|
+
},
|
|
59
|
+
rollupOptions: {
|
|
60
|
+
external: [],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
return readFileSync(path.join(outDir, 'out.js'), 'utf8')
|
|
65
|
+
} finally {
|
|
66
|
+
rmSync(outDir, { recursive: true, force: true })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
describe('styler dev-warning gate (Vite production bundle)', () => {
|
|
71
|
+
it('sheet.ts → dev warnings eliminated in Vite production bundle', async () => {
|
|
72
|
+
const code = await bundleWithVite(path.join(SRC, 'sheet.ts'), false)
|
|
73
|
+
for (const warn of DEV_WARNING_STRINGS) {
|
|
74
|
+
expect(code, `"${warn}" survived prod tree-shake`).not.toContain(warn)
|
|
75
|
+
}
|
|
76
|
+
expect(code.length).toBeGreaterThan(0)
|
|
77
|
+
}, 10000)
|
|
78
|
+
|
|
79
|
+
it('sheet.ts → dev warnings PRESERVED in Vite dev bundle (sanity)', async () => {
|
|
80
|
+
const code = await bundleWithVite(path.join(SRC, 'sheet.ts'), true)
|
|
81
|
+
for (const warn of DEV_WARNING_STRINGS) {
|
|
82
|
+
expect(code, `"${warn}" missing from dev bundle (did source change?)`).toContain(warn)
|
|
83
|
+
}
|
|
84
|
+
}, 10000)
|
|
85
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isNativeCompat } from '@pyreon/core'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { ThemeProvider } from '../ThemeProvider'
|
|
4
|
+
|
|
5
|
+
describe('native-compat marker — @pyreon/styler', () => {
|
|
6
|
+
it('ThemeProvider is marked native', () => {
|
|
7
|
+
expect(isNativeCompat(ThemeProvider)).toBe(true)
|
|
8
|
+
})
|
|
9
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import { hash } from '../hash'
|
|
3
|
-
import { sheet } from '../sheet'
|
|
3
|
+
import { onSheetClear, sheet, StyleSheet } from '../sheet'
|
|
4
4
|
|
|
5
5
|
describe('StyleSheet', () => {
|
|
6
6
|
beforeEach(() => {
|
|
@@ -152,6 +152,47 @@ describe('StyleSheet', () => {
|
|
|
152
152
|
})
|
|
153
153
|
})
|
|
154
154
|
|
|
155
|
+
describe('onSheetClear', () => {
|
|
156
|
+
// Subscriber registry used by `styled.tsx` to drop its static-component
|
|
157
|
+
// cache when the singleton sheet is cleared. Without this, stale
|
|
158
|
+
// `StaticStyled` ComponentFns survive HMR and continue returning class
|
|
159
|
+
// names the sheet just deleted from the DOM.
|
|
160
|
+
it('fires subscribers after clearAll', () => {
|
|
161
|
+
const cb = vi.fn()
|
|
162
|
+
const dispose = onSheetClear(cb)
|
|
163
|
+
sheet.clearAll()
|
|
164
|
+
expect(cb).toHaveBeenCalledTimes(1)
|
|
165
|
+
dispose()
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('does NOT fire subscribers on clearCache (partial cleanup)', () => {
|
|
169
|
+
const cb = vi.fn()
|
|
170
|
+
const dispose = onSheetClear(cb)
|
|
171
|
+
sheet.insert('color: red;')
|
|
172
|
+
sheet.clearCache()
|
|
173
|
+
expect(cb).not.toHaveBeenCalled()
|
|
174
|
+
dispose()
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('disposer removes the subscriber', () => {
|
|
178
|
+
const cb = vi.fn()
|
|
179
|
+
const dispose = onSheetClear(cb)
|
|
180
|
+
dispose()
|
|
181
|
+
sheet.clearAll()
|
|
182
|
+
expect(cb).not.toHaveBeenCalled()
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('fires multiple subscribers in registration order', () => {
|
|
186
|
+
const order: number[] = []
|
|
187
|
+
const dispose1 = onSheetClear(() => order.push(1))
|
|
188
|
+
const dispose2 = onSheetClear(() => order.push(2))
|
|
189
|
+
sheet.clearAll()
|
|
190
|
+
expect(order).toEqual([1, 2])
|
|
191
|
+
dispose1()
|
|
192
|
+
dispose2()
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
155
196
|
describe('has', () => {
|
|
156
197
|
it('returns true for cached classNames', () => {
|
|
157
198
|
const className = sheet.insert('color: red;')
|
|
@@ -162,4 +203,48 @@ describe('StyleSheet', () => {
|
|
|
162
203
|
expect(sheet.has('pyr-unknown')).toBe(false)
|
|
163
204
|
})
|
|
164
205
|
})
|
|
206
|
+
|
|
207
|
+
// Failed insertRule used to be silently swallowed in production because
|
|
208
|
+
// `process.env.NODE_ENV !== 'production'` is dead code in real Vite browser
|
|
209
|
+
// bundles (Vite does not polyfill `process`). The dev gate now uses
|
|
210
|
+
// `import.meta.env.DEV` which fires the warn under vitest and tree-shakes
|
|
211
|
+
// away in prod. This test asserts the warn fires for malformed CSS in dev.
|
|
212
|
+
describe('insertRule failures fire console.warn in dev', () => {
|
|
213
|
+
it('warns when StyleSheet.insertRule throws on malformed CSS', () => {
|
|
214
|
+
const local = new StyleSheet()
|
|
215
|
+
const realSheet = (local as unknown as { sheet: CSSStyleSheet | null }).sheet
|
|
216
|
+
if (!realSheet) {
|
|
217
|
+
// happy-dom may not expose a real sheet — skip; the prod-bundle
|
|
218
|
+
// tree-shake test in dev-gate-treeshake.test.ts covers the build side.
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
222
|
+
// Mock the prototype, not the instance — happy-dom's CSSStyleSheet may
|
|
223
|
+
// expose `insertRule` as a non-configurable own property that vi.spyOn
|
|
224
|
+
// can't intercept on an instance.
|
|
225
|
+
const proto = Object.getPrototypeOf(realSheet) as { insertRule: () => number }
|
|
226
|
+
const insertSpy = vi.spyOn(proto, 'insertRule').mockImplementation(() => {
|
|
227
|
+
throw new SyntaxError('invalid rule')
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
// Use a unique CSS string to bypass cross-instance/global insert cache
|
|
231
|
+
local.insert(`color: ${Math.random()};`)
|
|
232
|
+
|
|
233
|
+
const styleWarnings = warnSpy.mock.calls.filter(
|
|
234
|
+
(args) => typeof args[0] === 'string' && args[0].includes('[styler]'),
|
|
235
|
+
)
|
|
236
|
+
expect(styleWarnings.length).toBeGreaterThan(0)
|
|
237
|
+
|
|
238
|
+
insertSpy.mockRestore()
|
|
239
|
+
warnSpy.mockRestore()
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it('uses bundler-agnostic process.env.NODE_ENV — vitest sets NODE_ENV !== "production"', () => {
|
|
243
|
+
// Smoke test the gate itself: vitest must set process.env.NODE_ENV to
|
|
244
|
+
// a non-production value for the regression test above to be meaningful.
|
|
245
|
+
// Every modern bundler (incl. Vitest's Vite pipeline) auto-replaces
|
|
246
|
+
// `process.env.NODE_ENV` at build time.
|
|
247
|
+
expect(process.env.NODE_ENV).not.toBe('production')
|
|
248
|
+
})
|
|
249
|
+
})
|
|
165
250
|
})
|
|
@@ -398,4 +398,114 @@ describe('styled.tag (Proxy)', () => {
|
|
|
398
398
|
const vnode = Comp({}) as VNode
|
|
399
399
|
expect(vnode.type).toBe('section')
|
|
400
400
|
})
|
|
401
|
+
|
|
402
|
+
describe('empty-rawProps static VNode cache', () => {
|
|
403
|
+
// Hot path for `<MyStyled />` with no props: pre-built VNode returned
|
|
404
|
+
// from the StaticStyled closure verbatim. Skips `buildProps` + `h()` +
|
|
405
|
+
// children-array construction per render. Mirrors vitus-labs PR #228.
|
|
406
|
+
it('returns the SAME VNode identity across renders when rawProps is empty', () => {
|
|
407
|
+
const Comp = styled('div')`
|
|
408
|
+
color: red;
|
|
409
|
+
`
|
|
410
|
+
const v1 = Comp({}) as VNode
|
|
411
|
+
const v2 = Comp({}) as VNode
|
|
412
|
+
// Same VNode object — proves the pre-built cache fires.
|
|
413
|
+
expect(v1).toBe(v2)
|
|
414
|
+
expect(v1.type).toBe('div')
|
|
415
|
+
expect((v1.props as Record<string, string>).class).toMatch(/^pyr-/)
|
|
416
|
+
})
|
|
417
|
+
|
|
418
|
+
it('falls through to the full path when ANY prop is provided', () => {
|
|
419
|
+
const Comp = styled('div')`
|
|
420
|
+
color: red;
|
|
421
|
+
`
|
|
422
|
+
const v1 = Comp({}) as VNode
|
|
423
|
+
const v2 = Comp({ 'data-x': '1' }) as VNode
|
|
424
|
+
// Different identity — the second call bypassed the cache because
|
|
425
|
+
// `for (const _k in rawProps) hasExtraProps = true` fires.
|
|
426
|
+
expect(v1).not.toBe(v2)
|
|
427
|
+
// Both still produce the correct className.
|
|
428
|
+
expect((v1.props as Record<string, unknown>).class).toMatch(/^pyr-/)
|
|
429
|
+
expect((v2.props as Record<string, unknown>).class).toMatch(/^pyr-/)
|
|
430
|
+
// Second VNode carries the extra prop forwarded through buildProps.
|
|
431
|
+
expect((v2.props as Record<string, unknown>)['data-x']).toBe('1')
|
|
432
|
+
})
|
|
433
|
+
|
|
434
|
+
it('falls through to the full path when `as` overrides the tag', () => {
|
|
435
|
+
const Comp = styled('div')`
|
|
436
|
+
color: red;
|
|
437
|
+
`
|
|
438
|
+
const v1 = Comp({}) as VNode
|
|
439
|
+
const v2 = Comp({ as: 'span' }) as VNode
|
|
440
|
+
// `as` is enumerable → `hasExtraProps = true` → bypasses cache.
|
|
441
|
+
// Output tag is the override.
|
|
442
|
+
expect(v2.type).toBe('span')
|
|
443
|
+
expect(v1).not.toBe(v2)
|
|
444
|
+
})
|
|
445
|
+
|
|
446
|
+
it('falls through to the full path when a ref is provided', () => {
|
|
447
|
+
const Comp = styled('div')`
|
|
448
|
+
color: red;
|
|
449
|
+
`
|
|
450
|
+
const refCb = () => {}
|
|
451
|
+
const v1 = Comp({}) as VNode
|
|
452
|
+
const v2 = Comp({ ref: refCb }) as VNode
|
|
453
|
+
// `ref` is enumerable in JS, so `hasExtraProps = true` already fires.
|
|
454
|
+
// The explicit `rawProps.ref == null` guard is defense-in-depth for
|
|
455
|
+
// any future call site that uses Object.defineProperty(rawProps, 'ref',
|
|
456
|
+
// { enumerable: false, ... }) — that shape would otherwise return the
|
|
457
|
+
// cached no-ref VNode and silently drop the user's callback.
|
|
458
|
+
expect(v1).not.toBe(v2)
|
|
459
|
+
})
|
|
460
|
+
})
|
|
461
|
+
|
|
462
|
+
describe('clearAll resets static-component cache', () => {
|
|
463
|
+
// Regression: pre-fix, `staticComponentCache` (WeakMap) and the
|
|
464
|
+
// single-entry hot cache (`_hotStrings` / `_hotTag` / `_hotComponent`)
|
|
465
|
+
// survived `sheet.clearAll()`. After HMR / dev reload, the same
|
|
466
|
+
// template-literal call site re-invoked `styled('div')\`...\`` and got
|
|
467
|
+
// back the SAME ComponentFn instance — but the class name that
|
|
468
|
+
// component returns was deleted from the DOM by `clearAll`. End-user
|
|
469
|
+
// symptom: every hot reload silently broke styles for any static
|
|
470
|
+
// styled component until full page refresh.
|
|
471
|
+
//
|
|
472
|
+
// Fix wires `onSheetClear` so styled.tsx subscribes at module load
|
|
473
|
+
// and resets both caches alongside the sheet.
|
|
474
|
+
it('producing a new component after clearAll, with a fresh class name', () => {
|
|
475
|
+
// First mount: get baseline component + className.
|
|
476
|
+
const tag = 'div'
|
|
477
|
+
const literal: TemplateStringsArray = Object.assign(
|
|
478
|
+
['color: red;'] as unknown as TemplateStringsArray,
|
|
479
|
+
{ raw: ['color: red;'] },
|
|
480
|
+
)
|
|
481
|
+
const Comp1 = (styled(tag) as (s: TemplateStringsArray) => any)(literal)
|
|
482
|
+
const vnode1 = Comp1({}) as VNode
|
|
483
|
+
const class1 = (vnode1.props as Record<string, string>).class
|
|
484
|
+
|
|
485
|
+
// Same call, no clear: hot cache returns the SAME function identity.
|
|
486
|
+
const Comp1Again = (styled(tag) as (s: TemplateStringsArray) => any)(literal)
|
|
487
|
+
expect(Comp1Again).toBe(Comp1)
|
|
488
|
+
|
|
489
|
+
// Clear the sheet (HMR simulation).
|
|
490
|
+
sheet.clearAll()
|
|
491
|
+
|
|
492
|
+
// After clear: same template-literal identity should produce a NEW
|
|
493
|
+
// component (caches were dropped). Its className resolves against
|
|
494
|
+
// the now-empty sheet, so the new className IS re-inserted into
|
|
495
|
+
// the DOM and the class is observable.
|
|
496
|
+
const Comp2 = (styled(tag) as (s: TemplateStringsArray) => any)(literal)
|
|
497
|
+
expect(Comp2).not.toBe(Comp1)
|
|
498
|
+
const vnode2 = Comp2({}) as VNode
|
|
499
|
+
const class2 = (vnode2.props as Record<string, string>).class
|
|
500
|
+
// FNV-1a hashing is content-deterministic, so class names are
|
|
501
|
+
// structurally equal — but the sheet has freshly re-inserted the
|
|
502
|
+
// rule. Asserting non-empty + same format is the load-bearing
|
|
503
|
+
// observation: pre-fix, Comp2 === Comp1 and class2 would also have
|
|
504
|
+
// been `''` if the user had run `clearAll` between insertions
|
|
505
|
+
// (cache stale, sheet empty).
|
|
506
|
+
expect(class1).toMatch(/^pyr-/)
|
|
507
|
+
expect(class2).toMatch(/^pyr-/)
|
|
508
|
+
expect(sheet.has(class2!)).toBe(true)
|
|
509
|
+
})
|
|
510
|
+
})
|
|
401
511
|
})
|
package/src/env.d.ts
ADDED
package/src/resolve.ts
CHANGED
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
import type { DefaultTheme } from './ThemeProvider'
|
|
8
8
|
|
|
9
9
|
// Dev-time counter sink — populated by `@pyreon/perf-harness` on install().
|
|
10
|
-
// Guarded on call sites with `
|
|
10
|
+
// Guarded on call sites with `process.env.NODE_ENV !== 'production'` so prod bundles
|
|
11
11
|
// tree-shake the entire reference. No cross-package import, no publish surface.
|
|
12
|
-
interface ViteMeta {
|
|
13
|
-
readonly env?: { readonly DEV?: boolean }
|
|
14
|
-
}
|
|
15
12
|
const _countSink = globalThis as { __pyreon_count__?: (name: string, n?: number) => void }
|
|
16
13
|
|
|
17
14
|
/**
|
|
@@ -60,7 +57,7 @@ export const resolve = (
|
|
|
60
57
|
values: Interpolation[],
|
|
61
58
|
props: Record<string, any>,
|
|
62
59
|
): string => {
|
|
63
|
-
if (
|
|
60
|
+
if (process.env.NODE_ENV !== 'production') _countSink.__pyreon_count__?.('styler.resolve')
|
|
64
61
|
// Tagged templates guarantee strings.length === values.length + 1,
|
|
65
62
|
// so strings[0] and strings[i+1] are always defined — no ?? needed.
|
|
66
63
|
let result = strings[0] as string
|
package/src/sheet.ts
CHANGED
|
@@ -9,11 +9,15 @@ import { hash } from './hash'
|
|
|
9
9
|
import { clearNormCache } from './resolve'
|
|
10
10
|
|
|
11
11
|
// Dev-time counter sink — see styler/resolve.ts for the contract.
|
|
12
|
-
interface ViteMeta {
|
|
13
|
-
readonly env?: { readonly DEV?: boolean }
|
|
14
|
-
}
|
|
15
12
|
const _countSink = globalThis as { __pyreon_count__?: (name: string, n?: number) => void }
|
|
16
13
|
|
|
14
|
+
// Dev-mode gate. `import.meta.env.DEV` is literal-replaced by Vite at build
|
|
15
|
+
// time and tree-shakes to zero bytes in prod. The previous
|
|
16
|
+
// `process.env.NODE_ENV !== 'production'` form was dead code in real Vite
|
|
17
|
+
// browser bundles (Vite does not polyfill `process`), so insertRule failures
|
|
18
|
+
// were silently swallowed in production — masking malformed CSS bugs.
|
|
19
|
+
const __DEV__ = process.env.NODE_ENV !== 'production'
|
|
20
|
+
|
|
17
21
|
const PREFIX = 'pyr'
|
|
18
22
|
const ATTR = 'data-pyreon-styler'
|
|
19
23
|
const DEFAULT_MAX_CACHE_SIZE = 10000
|
|
@@ -206,13 +210,13 @@ export class StyleSheet {
|
|
|
206
210
|
* via @layer order (base < rocketstyle) instead of specificity hacks.
|
|
207
211
|
*/
|
|
208
212
|
insert(cssText: string, _unused = false, insertLayer?: string): string {
|
|
209
|
-
if (
|
|
213
|
+
if (process.env.NODE_ENV !== 'production')
|
|
210
214
|
_countSink.__pyreon_count__?.('styler.sheet.insert')
|
|
211
215
|
// Fast path: skip hash computation on repeated insertions of same CSS text
|
|
212
216
|
const icKey = insertLayer ? `${cssText}\0L:${insertLayer}` : cssText
|
|
213
217
|
const icHit = this.insertCache.get(icKey)
|
|
214
218
|
if (icHit) {
|
|
215
|
-
if (
|
|
219
|
+
if (process.env.NODE_ENV !== 'production')
|
|
216
220
|
_countSink.__pyreon_count__?.('styler.sheet.insert.hit')
|
|
217
221
|
return icHit
|
|
218
222
|
}
|
|
@@ -252,7 +256,7 @@ export class StyleSheet {
|
|
|
252
256
|
try {
|
|
253
257
|
this.sheet.insertRule(rule, this.sheet.cssRules.length)
|
|
254
258
|
} catch (_e) {
|
|
255
|
-
if (
|
|
259
|
+
if (__DEV__) {
|
|
256
260
|
// oxlint-disable-next-line no-console
|
|
257
261
|
console.warn('[styler] Failed to insert CSS rule:', rule, _e)
|
|
258
262
|
}
|
|
@@ -279,8 +283,9 @@ export class StyleSheet {
|
|
|
279
283
|
try {
|
|
280
284
|
this.sheet.insertRule(rule, this.sheet.cssRules.length)
|
|
281
285
|
} catch (_e) {
|
|
282
|
-
if (
|
|
283
|
-
//
|
|
286
|
+
if (__DEV__) {
|
|
287
|
+
// oxlint-disable-next-line no-console
|
|
288
|
+
console.warn('[styler] Failed to insert @keyframes rule:', rule, _e)
|
|
284
289
|
}
|
|
285
290
|
}
|
|
286
291
|
}
|
|
@@ -329,7 +334,7 @@ export class StyleSheet {
|
|
|
329
334
|
try {
|
|
330
335
|
this.sheet.insertRule(rule, this.sheet.cssRules.length)
|
|
331
336
|
} catch (_e) {
|
|
332
|
-
if (
|
|
337
|
+
if (__DEV__) {
|
|
333
338
|
// oxlint-disable-next-line no-console
|
|
334
339
|
console.warn('[styler] Failed to insert global CSS rule:', rule, _e)
|
|
335
340
|
}
|
|
@@ -386,6 +391,12 @@ export class StyleSheet {
|
|
|
386
391
|
/**
|
|
387
392
|
* Full cleanup: clear cache and remove all CSS rules from the DOM.
|
|
388
393
|
* Intended for HMR / dev-time reloads where stale styles must be purged.
|
|
394
|
+
*
|
|
395
|
+
* Also fires `onSheetClear` subscribers so downstream caches (e.g.
|
|
396
|
+
* `styled.tsx`'s static-component cache) reset alongside the sheet.
|
|
397
|
+
* Without this, stale `StaticStyled` ComponentFn references survive HMR
|
|
398
|
+
* and continue to apply CSS class names that were just deleted from
|
|
399
|
+
* the DOM — observable as missing styles after every hot reload.
|
|
389
400
|
*/
|
|
390
401
|
clearAll(): void {
|
|
391
402
|
this.cache.clear()
|
|
@@ -397,6 +408,7 @@ export class StyleSheet {
|
|
|
397
408
|
this.sheet.deleteRule(0)
|
|
398
409
|
}
|
|
399
410
|
}
|
|
411
|
+
fireSheetClearSubscribers()
|
|
400
412
|
}
|
|
401
413
|
|
|
402
414
|
/**
|
|
@@ -442,3 +454,29 @@ export const sheet = new StyleSheet()
|
|
|
442
454
|
* Use in SSR to get per-request isolation.
|
|
443
455
|
*/
|
|
444
456
|
export const createSheet = (options?: StyleSheetOptions): StyleSheet => new StyleSheet(options)
|
|
457
|
+
|
|
458
|
+
// ─── onSheetClear subscriber registry ─────────────────────────────────────
|
|
459
|
+
//
|
|
460
|
+
// Used by `styled.tsx` to reset its static-component cache when the
|
|
461
|
+
// singleton sheet is cleared via `clearAll()`. Module-level Set so the
|
|
462
|
+
// subscription survives between calls; ports the vitus-labs pattern from
|
|
463
|
+
// `connector-styler/sheet.ts:onClear`. Scoped to the singleton sheet —
|
|
464
|
+
// per-instance sheets created via `createSheet()` don't fire the hook.
|
|
465
|
+
const _sheetClearSubscribers = new Set<() => void>()
|
|
466
|
+
|
|
467
|
+
const fireSheetClearSubscribers = (): void => {
|
|
468
|
+
for (const cb of _sheetClearSubscribers) cb()
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Subscribe to `sheet.clearAll()`. Fires after the sheet has been
|
|
473
|
+
* fully cleared, so subscribers can drop downstream caches that depend
|
|
474
|
+
* on the sheet's class names being live in the DOM.
|
|
475
|
+
*
|
|
476
|
+
* Returns a disposer for symmetry; in practice subscribers register
|
|
477
|
+
* once at module load and never unsubscribe.
|
|
478
|
+
*/
|
|
479
|
+
export const onSheetClear = (callback: () => void): (() => void) => {
|
|
480
|
+
_sheetClearSubscribers.add(callback)
|
|
481
|
+
return () => _sheetClearSubscribers.delete(callback)
|
|
482
|
+
}
|
package/src/styled.tsx
CHANGED
|
@@ -21,9 +21,12 @@ import { computed, renderEffect, 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'
|
|
24
|
-
import { sheet } from './sheet'
|
|
24
|
+
import { onSheetClear, sheet } from './sheet'
|
|
25
25
|
import { useThemeAccessor } from './ThemeProvider'
|
|
26
26
|
|
|
27
|
+
// Dev-time counter sink — see packages/internals/perf-harness/COUNTERS.md.
|
|
28
|
+
const _countSink = globalThis as { __pyreon_count__?: (name: string, n?: number) => void }
|
|
29
|
+
|
|
27
30
|
type Tag = string | ComponentFn<any>
|
|
28
31
|
|
|
29
32
|
export interface StyledOptions {
|
|
@@ -47,12 +50,33 @@ const getDisplayName = (tag: Tag): string =>
|
|
|
47
50
|
|
|
48
51
|
// Component cache: same template literal + tag + no options → same component.
|
|
49
52
|
// WeakMap on `strings` (TemplateStringsArray is object-identity per source location).
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
|
|
53
|
+
// `let` so `sheet.clearAll()` (HMR / dev reload) can drop stale entries by
|
|
54
|
+
// swapping the WeakMap reference — WeakMap has no `.clear()` method, and stale
|
|
55
|
+
// `StaticStyled` ComponentFns left behind would keep returning class names the
|
|
56
|
+
// sheet just deleted from the DOM.
|
|
57
|
+
let staticComponentCache = new WeakMap<TemplateStringsArray, Map<Tag, ComponentFn>>()
|
|
58
|
+
|
|
59
|
+
// Single-entry hot cache — 3 reference comparisons, no Map/WeakMap overhead.
|
|
60
|
+
// All 3 fields move atomically (consolidated into one object so `clearAll`
|
|
61
|
+
// resets them together — pre-fix, partial state was possible if a reset
|
|
62
|
+
// path forgot one field).
|
|
63
|
+
const _hotCache: {
|
|
64
|
+
strings: TemplateStringsArray | null
|
|
65
|
+
tag: Tag | null
|
|
66
|
+
component: ComponentFn | null
|
|
67
|
+
} = { strings: null, tag: null, component: null }
|
|
68
|
+
|
|
69
|
+
// Subscribe to `sheet.clearAll()` (HMR / dev-time reset). Drops both the
|
|
70
|
+
// WeakMap and the hot-cache slots so subsequent `styled()` calls produce
|
|
71
|
+
// fresh components with up-to-date class names. Static class names emitted
|
|
72
|
+
// before `clearAll` are stale by the time the user observes them — the rule
|
|
73
|
+
// they pointed at has been deleted from the DOM.
|
|
74
|
+
onSheetClear(() => {
|
|
75
|
+
staticComponentCache = new WeakMap()
|
|
76
|
+
_hotCache.strings = null
|
|
77
|
+
_hotCache.tag = null
|
|
78
|
+
_hotCache.component = null
|
|
79
|
+
})
|
|
56
80
|
|
|
57
81
|
const createStyledComponent = (
|
|
58
82
|
tag: Tag,
|
|
@@ -62,16 +86,17 @@ const createStyledComponent = (
|
|
|
62
86
|
): ComponentFn => {
|
|
63
87
|
// Ultra-fast hot cache: 3 reference comparisons → return immediately
|
|
64
88
|
if (values.length === 0 && !options) {
|
|
65
|
-
if (strings ===
|
|
89
|
+
if (strings === _hotCache.strings && tag === _hotCache.tag)
|
|
90
|
+
return _hotCache.component as ComponentFn
|
|
66
91
|
|
|
67
92
|
// WeakMap fallback for alternating patterns
|
|
68
93
|
const tagMap = staticComponentCache.get(strings)
|
|
69
94
|
if (tagMap) {
|
|
70
95
|
const cached = tagMap.get(tag)
|
|
71
96
|
if (cached) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
97
|
+
_hotCache.strings = strings
|
|
98
|
+
_hotCache.tag = tag
|
|
99
|
+
_hotCache.component = cached
|
|
75
100
|
return cached
|
|
76
101
|
}
|
|
77
102
|
}
|
|
@@ -91,9 +116,56 @@ const createStyledComponent = (
|
|
|
91
116
|
|
|
92
117
|
const staticClassName = hasCss ? sheet.insert(cssText, false, insertLayer) : ''
|
|
93
118
|
|
|
119
|
+
// Hoisted out of the render fn: `tag` is known at component-creation time,
|
|
120
|
+
// and `tag` matches `rawProps.as ?? tag` whenever rawProps is empty (the
|
|
121
|
+
// common case for `<MyStyled />` without any props). The DOM-ness check
|
|
122
|
+
// doesn't change between renders for the same `tag`.
|
|
123
|
+
const tagIsDOM = typeof tag === 'string'
|
|
124
|
+
|
|
125
|
+
// Pre-built VNode for the no-extra-props hot path (`<MyStyled />`). Same
|
|
126
|
+
// shape `h(tag, { class })` would produce per render, but allocated once
|
|
127
|
+
// at component-creation time. Mount.ts spreads `vnode.props` into a new
|
|
128
|
+
// object before invoking the component (mount.ts:404-418 doesn't mutate
|
|
129
|
+
// the source vnode), so sharing the same VNode across mount sites is
|
|
130
|
+
// safe. `vnode.children` is empty here because the empty-rawProps branch
|
|
131
|
+
// also implies no children were passed — `rawProps.children` would be
|
|
132
|
+
// `undefined` and the `Array.isArray ? : ?? : []` chain produces `[]`.
|
|
133
|
+
//
|
|
134
|
+
// **Cache lifetime**: this VNode references `staticClassName`, which is
|
|
135
|
+
// the className the sheet just inserted. If `sheet.clearAll()` runs
|
|
136
|
+
// (HMR / dev reload), the className becomes stale BUT the outer
|
|
137
|
+
// `staticComponentCache` (and `_hot*` caches) ALSO survive that path —
|
|
138
|
+
// so consumers continue to receive the stale className regardless. The
|
|
139
|
+
// companion fix to wire `onSheetClear` and reset both caches is tracked
|
|
140
|
+
// separately (see PR #561). This optimization is correct under the
|
|
141
|
+
// existing cache lifetime contract; the HMR-staleness issue is broader
|
|
142
|
+
// than the VNode cache.
|
|
143
|
+
const cachedEmptyVNode = h(
|
|
144
|
+
tag as string,
|
|
145
|
+
staticClassName ? { class: staticClassName } : {},
|
|
146
|
+
)
|
|
147
|
+
|
|
94
148
|
const StaticStyled: ComponentFn = (rawProps: Record<string, any>): VNode | null => {
|
|
149
|
+
// Hot path: no extra props beyond what's empty AND no `ref` / `as`.
|
|
150
|
+
// `for ... in` over an empty object is O(0); the `break` exits on the
|
|
151
|
+
// first key. Skipping the cache when `ref` is present is necessary
|
|
152
|
+
// because the user expects their callback to fire on the mounted DOM
|
|
153
|
+
// node — the pre-built VNode has no `ref` in its props.
|
|
154
|
+
let hasExtraProps = false
|
|
155
|
+
for (const _k in rawProps) {
|
|
156
|
+
hasExtraProps = true
|
|
157
|
+
break
|
|
158
|
+
}
|
|
159
|
+
if (!hasExtraProps && rawProps.ref == null) {
|
|
160
|
+
if (process.env.NODE_ENV !== 'production')
|
|
161
|
+
_countSink.__pyreon_count__?.('styler.staticVNode.hit')
|
|
162
|
+
return cachedEmptyVNode
|
|
163
|
+
}
|
|
164
|
+
|
|
95
165
|
const finalTag = rawProps.as || tag
|
|
96
|
-
|
|
166
|
+
// Fast `isDOM` when the user didn't pass `as` — reuses the closure-time
|
|
167
|
+
// check. Only `typeof` is needed when `as` overrides the tag.
|
|
168
|
+
const isDOM = finalTag === tag ? tagIsDOM : typeof finalTag === 'string'
|
|
97
169
|
const finalProps = buildProps(rawProps, staticClassName, isDOM, customFilter)
|
|
98
170
|
|
|
99
171
|
return h(
|
|
@@ -118,9 +190,9 @@ const createStyledComponent = (
|
|
|
118
190
|
staticComponentCache.set(strings, tagMap)
|
|
119
191
|
}
|
|
120
192
|
tagMap.set(tag, StaticStyled)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
193
|
+
_hotCache.strings = strings
|
|
194
|
+
_hotCache.tag = tag
|
|
195
|
+
_hotCache.component = StaticStyled
|
|
124
196
|
}
|
|
125
197
|
|
|
126
198
|
return StaticStyled
|
|
@@ -130,6 +202,14 @@ const createStyledComponent = (
|
|
|
130
202
|
// Two-level WeakMap: $rocketstyle → $rocketstate → className.
|
|
131
203
|
// 50 identical Items with the same resolved theme → 1 resolve + 49 hits.
|
|
132
204
|
const classCache = new WeakMap<object, WeakMap<object, string>>()
|
|
205
|
+
// Single-key cache for non-rocketstyle styled components (e.g. Element's
|
|
206
|
+
// Wrapper, which depends on `$element` + `$childFix`). The key is the
|
|
207
|
+
// `$element` object identity; `$childFix` is folded into a `Map<bool,
|
|
208
|
+
// string>` per `$element` to avoid wrong-cache hits when childFix differs.
|
|
209
|
+
// Element-layer interning (see `@pyreon/elements` Element/component.tsx)
|
|
210
|
+
// gives `$element` stable identity across mounts, which is what makes this
|
|
211
|
+
// cache fire — analogous to PR #344's rocketstyle dimension memo.
|
|
212
|
+
const elClassCache = new WeakMap<object, Map<unknown, string>>()
|
|
133
213
|
|
|
134
214
|
// DYNAMIC PATH: uses computed() for reactive class derivation.
|
|
135
215
|
//
|
|
@@ -164,6 +244,27 @@ const createStyledComponent = (
|
|
|
164
244
|
}
|
|
165
245
|
}
|
|
166
246
|
|
|
247
|
+
// Element-layer cache (no rocketstyle props, but $element is present
|
|
248
|
+
// and an object). Fires only when the rocketstyle path didn't apply
|
|
249
|
+
// — they're mutually exclusive in practice.
|
|
250
|
+
const $el = rawProps.$element
|
|
251
|
+
const $childFix = rawProps.$childFix
|
|
252
|
+
const useElCache =
|
|
253
|
+
(!rs || typeof rs !== 'object' || !rsState || typeof rsState !== 'object') &&
|
|
254
|
+
$el &&
|
|
255
|
+
typeof $el === 'object'
|
|
256
|
+
if (useElCache) {
|
|
257
|
+
const inner = elClassCache.get($el as object)
|
|
258
|
+
if (inner) {
|
|
259
|
+
const cached = inner.get($childFix)
|
|
260
|
+
if (cached !== undefined) {
|
|
261
|
+
if (process.env.NODE_ENV !== 'production')
|
|
262
|
+
_countSink.__pyreon_count__?.('styler.elClassCache.hit')
|
|
263
|
+
return cached
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
167
268
|
const resolveProps = {
|
|
168
269
|
...rawProps,
|
|
169
270
|
...(isReactiveRS ? { $rocketstyle: rs } : {}),
|
|
@@ -180,6 +281,13 @@ const createStyledComponent = (
|
|
|
180
281
|
classCache.set(rs, inner)
|
|
181
282
|
}
|
|
182
283
|
inner.set(rsState, className)
|
|
284
|
+
} else if (useElCache) {
|
|
285
|
+
let inner = elClassCache.get($el as object)
|
|
286
|
+
if (!inner) {
|
|
287
|
+
inner = new Map()
|
|
288
|
+
elClassCache.set($el as object, inner)
|
|
289
|
+
}
|
|
290
|
+
inner.set($childFix, className)
|
|
183
291
|
}
|
|
184
292
|
return className
|
|
185
293
|
}
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/ThemeProvider.ts","../../src/resolve.ts","../../src/css.ts","../../src/forward.ts","../../src/globalStyle.ts","../../src/hash.ts","../../src/keyframes.ts","../../src/shared.ts","../../src/sheet.ts","../../src/styled.tsx","../../src/useCSS.ts"],"mappings":";;;;UAgBiB,YAAA;AAAA,KAEZ,KAAA,GAAQ,YAAA,GAAe,MAAA;;;AAoB5B;;;;;;;;;AAMA;cAZa,YAAA,EAAY,aAAA,CAAA,eAAA,CAAA,KAAA;;;;;cAMZ,QAAA,sBAA+B,KAAA,OAAU,CAAA;;;AAatD;;cAPa,gBAAA,sBAAuC,KAAA,cAAiB,CAAA;;;;;iBAOrD,aAAA,CAAA;EACd,KAAA;EACA;AAAA;EAEA,KAAA,EAAO,KAAA;EACP,QAAA,GAAW,UAAA;AAAA,IACT,KAAA;;;;;;AAzC4B;;;;;AAgBhC;KCPY,WAAA,oBAA+B,MAAA,qBAA2B,CAAA;EACpE,KAAA,GAAQ,YAAA,GAAe,MAAA;AAAA;AAAA,KAGb,aAAA,oBAAiC,MAAA,oEAMzC,SAAA,GACA,aAAA,CAAc,CAAA,QACZ,KAAA,EAAO,WAAA,CAAY,CAAA,MAAO,aAAA,CAAc,CAAA;ADC9C;;;;;AAAA,cCMa,SAAA;EAAA,SAEA,OAAA,EAAS,oBAAA;EAAA,SACT,MAAA,EAAQ,aAAA;cADR,OAAA,EAAS,oBAAA,EACT,MAAA,EAAQ,aAAA;EDHR;ECOX,QAAA,CAAA;AAAA;;cAMW,OAAA,GACX,OAAA,EAAS,oBAAA,EACT,MAAA,EAAQ,aAAA,IACR,KAAA,EAAO,MAAA;;cA0CI,cAAA;AAAA,cAEA,YAAA,GAAgB,GAAA;AAAA,cAmEhB,YAAA,GAAgB,KAAA,EAAO,aAAA,EAAe,KAAA,EAAO,MAAA;;;;;;AD3J1D;;;;;AAAgC;cELnB,GAAA,GAAO,OAAA,EAAS,oBAAA,KAAyB,MAAA,EAAQ,aAAA,OAAkB,SAAA;;;;;;;AFKhF;;;;;cGsLa,WAAA,GAAe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ER3SO;EAAA,QQsTC,eAAA;;EAKR,KAAA,CAAA;EP3VU;EOkWV,UAAA,CAAA;EPlWqB;;;;EO4WrB,QAAA,CAAA;EP3W6B;;;EO0X7B,OAAA,CAAQ,OAAA;IAAoB,SAAA;IAAmB,KAAA;EAAA;EP1XxB;EO0YvB,GAAA,CAAI,SAAA;EP1YyB;EAAA,IO+YzB,SAAA,CAAA;AAAA;;;;;;;;cAYO,KAAA,EAAK,UAAA;;;;;cAML,WAAA,GAAe,OAAA,GAAU,iBAAA,KAAoB,UAAA;;;KCjarD,GAAA,YAAe,WAAA;AAAA,UAEH,aAAA;ETUyE;ESRxF,iBAAA,IAAqB,IAAA;ETQE;;;;;AAMzB;;;ESLE,KAAA;AAAA;;;;;ATYF;;;;;;;;KS0OK,aAAA,uBAAoC,MAAA,mBACvC,OAAA,EAAS,oBAAA,KACN,MAAA,EAAQ,aAAA,CAAc,CAAA,QACtB,WAAA,CAAY,CAAA,GAAI,MAAA;AAAA,KAEhB,QAAA;AAAA,KAqFO,cAAA,KAAmB,GAAA,EAAK,GAAA,EAAK,OAAA,GAAU,aAAA,KAAkB,aAAA,YAC7D,QAAA,GAAW,aAAA;AAAA,cAMN,MAAA,EAAQ,cAAA;;;iBCnXL,MAAA,CAAO,QAAA,EAAU,SAAA,EAAW,KAAA,GAAQ,MAAA,eAAqB,KAAA"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_countSink"],"sources":["../src/resolve.ts","../src/css.ts","../src/forward.ts","../src/shared.ts","../src/hash.ts","../src/sheet.ts","../src/ThemeProvider.ts","../src/globalStyle.ts","../src/keyframes.ts","../src/styled.tsx","../src/useCSS.ts"],"sourcesContent":["/**\n * Interpolation resolver: converts tagged template strings + values into a\n * final CSS string. Handles nested CSSResults, arrays, functions, and\n * primitive values.\n */\n\nimport type { DefaultTheme } from './ThemeProvider'\n\n// Dev-time counter sink — populated by `@pyreon/perf-harness` on install().\n// Guarded on call sites with `import.meta.env?.DEV === true` so prod bundles\n// tree-shake the entire reference. No cross-package import, no publish surface.\ninterface ViteMeta {\n readonly env?: { readonly DEV?: boolean }\n}\nconst _countSink = globalThis as { __pyreon_count__?: (name: string, n?: number) => void }\n\n/**\n * Props passed to interpolation functions inside tagged templates.\n * Generic `P` allows consumers to type their custom props (e.g. transient $-prefixed):\n *\n * @example\n * styled('div')<{ $color: string }>`\n * background: ${(props) => props.$color}; // props.$color is typed!\n * `\n */\nexport type StyledProps<P extends object = Record<string, unknown>> = P & {\n theme?: DefaultTheme & Record<string, unknown>\n}\n\nexport type Interpolation<P extends object = Record<string, unknown>> =\n | string\n | number\n | boolean\n | null\n | undefined\n | CSSResult\n | Interpolation<P>[]\n | ((props: StyledProps<P>) => Interpolation<P>)\n\n/**\n * Lazy representation of a `css` tagged template. Stores the raw template\n * strings and interpolation values without resolving them. Resolution is\n * deferred until a styled component renders (or until explicitly resolved).\n */\nexport class CSSResult {\n constructor(\n readonly strings: TemplateStringsArray,\n readonly values: Interpolation[],\n ) {}\n\n /** Resolve with empty props — useful for static templates, testing, and debugging. */\n toString(): string {\n return resolve(this.strings, this.values, {})\n }\n}\n\n/** Resolve a tagged template's strings + values into a final CSS string. */\nexport const resolve = (\n strings: TemplateStringsArray,\n values: Interpolation[],\n props: Record<string, any>,\n): string => {\n if ((import.meta as ViteMeta).env?.DEV === true) _countSink.__pyreon_count__?.('styler.resolve')\n // Tagged templates guarantee strings.length === values.length + 1,\n // so strings[0] and strings[i+1] are always defined — no ?? needed.\n let result = strings[0] as string\n for (let i = 0; i < values.length; i++) {\n const v = values[i]\n const s = strings[i + 1] as string\n // Inline the most common value types to avoid function call overhead.\n if (typeof v === 'function') {\n const r = v(props)\n result +=\n (typeof r === 'string'\n ? r\n : r == null || r === false || r === true\n ? ''\n : resolveValue(r as Interpolation, props)) + s\n } else if (v == null || v === false || v === true) {\n result += s\n } else if (typeof v === 'string') {\n result += v + s\n } else if (typeof v === 'number') {\n result += v + s\n } else {\n result += resolveValue(v, props) + s\n }\n }\n return result\n}\n\n/**\n * Normalize resolved CSS text for strict `insertRule` compatibility.\n *\n * Single-pass scanner that handles all cleanup in one traversal:\n * - Strips block comments and line comments (preserves :// in URLs)\n * - Collapses whitespace to single spaces\n * - Removes redundant semicolons\n * - Trims leading/trailing whitespace\n */\nconst normCache = new Map<string, string>()\n/** Clear the normalizeCSS cache (called during HMR cleanup). */\nexport const clearNormCache = () => normCache.clear()\n\nexport const normalizeCSS = (css: string): string => {\n const cached = normCache.get(css)\n if (cached !== undefined) return cached\n\n const len = css.length\n let out = ''\n let space = false // pending space to emit before next non-whitespace char\n let last = 0 // charCode of last char written to output (0 = nothing yet)\n\n for (let i = 0; i < len; i++) {\n const c = css.charCodeAt(i)\n\n // /* block comment */\n if (c === 47 /* / */ && css.charCodeAt(i + 1) === 42 /* * */) {\n const end = css.indexOf('*/', i + 2)\n i = end === -1 ? len : end + 1\n space = true\n continue\n }\n\n // // line comment (but not :// in URLs)\n if (c === 47 /* / */ && css.charCodeAt(i + 1) === 47 /* / */ && last !== 58 /* : */) {\n const nl = css.indexOf('\\n', i + 2)\n i = nl === -1 ? len : nl\n space = true\n continue\n }\n\n // Whitespace → collapse\n if (c === 32 || c === 9 || c === 10 || c === 13 || c === 12) {\n space = true\n continue\n }\n\n // Semicolon → skip if redundant (after start, {, }, or another ;)\n if (c === 59 /* ; */) {\n if (last === 0 || last === 123 /* { */ || last === 125 /* } */ || last === 59 /* ; */) {\n continue\n }\n space = false\n out += ';'\n last = 59\n continue\n }\n\n // Regular char — emit pending space (but not at start of output)\n if (space && last !== 0) out += ' '\n space = false\n\n out += css[i]\n last = c\n }\n\n // Evict oldest ~10% to prevent memory leaks without cliff-edge drop\n if (normCache.size > 2000) {\n let count = 0\n for (const key of normCache.keys()) {\n if (count >= 200) break\n normCache.delete(key)\n count++\n }\n }\n normCache.set(css, out)\n\n return out\n}\n\nexport const resolveValue = (value: Interpolation, props: Record<string, any>): string => {\n // null, undefined, false, true → empty (enables conditional: ${cond && css`...`})\n if (value == null || value === false || value === true) return ''\n\n // function interpolation → call with props/theme context, resolve result\n if (typeof value === 'function') return resolveValue(value(props) as Interpolation, props)\n\n // nested CSSResult → recursively resolve\n if (value instanceof CSSResult) return resolve(value.strings, value.values, props)\n\n // array of results (e.g. from makeItResponsive's breakpoints.map())\n if (Array.isArray(value)) {\n let arrayResult = ''\n for (let i = 0; i < value.length; i++) {\n arrayResult += resolveValue(value[i], props)\n }\n return arrayResult\n }\n\n return String(value)\n}\n","import { CSSResult, type Interpolation } from './resolve'\n\n/**\n * Tagged template function for CSS. Captures the template strings and\n * interpolation values as a lazy CSSResult — resolution is deferred\n * until a styled component renders.\n *\n * Works as both a tagged template (`css\\`...\\``) and a regular function\n * call (`css(...args)`) since tagged templates are syntactic sugar for\n * function calls with (TemplateStringsArray, ...values).\n */\nexport const css = (strings: TemplateStringsArray, ...values: Interpolation[]): CSSResult =>\n new CSSResult(strings, values)\n","/**\n * HTML prop filtering. Prevents unknown props from being forwarded to DOM\n * elements (which causes warnings). Props starting with `$` are\n * transient (styling-only) and are always filtered out.\n */\n\n// Common HTML attributes, event handlers, and ARIA/data attributes\nconst HTML_PROPS = new Set([\n // Core props\n 'className',\n 'class',\n 'dangerouslySetInnerHTML',\n 'htmlFor',\n 'id',\n 'key',\n 'ref',\n 'style',\n 'tabIndex',\n 'role',\n // Event handlers\n 'onAbort',\n 'onAnimationEnd',\n 'onAnimationIteration',\n 'onAnimationStart',\n 'onBlur',\n 'onChange',\n 'onClick',\n 'onCompositionEnd',\n 'onCompositionStart',\n 'onCompositionUpdate',\n 'onContextMenu',\n 'onCopy',\n 'onCut',\n 'onDoubleClick',\n 'onDrag',\n 'onDragEnd',\n 'onDragEnter',\n 'onDragLeave',\n 'onDragOver',\n 'onDragStart',\n 'onDrop',\n 'onError',\n 'onFocus',\n 'onInput',\n 'onKeyDown',\n 'onKeyPress',\n 'onKeyUp',\n 'onLoad',\n 'onMouseDown',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseMove',\n 'onMouseOut',\n 'onMouseOver',\n 'onMouseUp',\n 'onPaste',\n 'onPointerCancel',\n 'onPointerDown',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerMove',\n 'onPointerOut',\n 'onPointerOver',\n 'onPointerUp',\n 'onScroll',\n 'onSelect',\n 'onSubmit',\n 'onTouchCancel',\n 'onTouchEnd',\n 'onTouchMove',\n 'onTouchStart',\n 'onTransitionEnd',\n 'onWheel',\n // HTML attributes\n 'accept',\n 'acceptCharset',\n 'accessKey',\n 'action',\n 'allow',\n 'allowFullScreen',\n 'alt',\n 'as',\n 'async',\n 'autoCapitalize',\n 'autoComplete',\n 'autoCorrect',\n 'autoFocus',\n 'autoPlay',\n 'capture',\n 'cellPadding',\n 'cellSpacing',\n 'charSet',\n 'checked',\n 'cite',\n 'cols',\n 'colSpan',\n 'content',\n 'contentEditable',\n 'controls',\n 'controlsList',\n 'coords',\n 'crossOrigin',\n 'dateTime',\n 'decoding',\n 'default',\n 'defaultChecked',\n 'defaultValue',\n 'defer',\n 'dir',\n 'disabled',\n 'disablePictureInPicture',\n 'disableRemotePlayback',\n 'download',\n 'draggable',\n 'encType',\n 'enterKeyHint',\n 'fetchPriority',\n 'form',\n 'formAction',\n 'formEncType',\n 'formMethod',\n 'formNoValidate',\n 'formTarget',\n 'frameBorder',\n 'headers',\n 'height',\n 'hidden',\n 'high',\n 'href',\n 'hrefLang',\n 'httpEquiv',\n 'inputMode',\n 'integrity',\n 'is',\n 'label',\n 'lang',\n 'list',\n 'loading',\n 'loop',\n 'low',\n 'max',\n 'maxLength',\n 'media',\n 'method',\n 'min',\n 'minLength',\n 'multiple',\n 'muted',\n 'name',\n 'noModule',\n 'noValidate',\n 'nonce',\n 'open',\n 'optimum',\n 'pattern',\n 'placeholder',\n 'playsInline',\n 'poster',\n 'preload',\n 'readOnly',\n 'referrerPolicy',\n 'rel',\n 'required',\n 'reversed',\n 'rows',\n 'rowSpan',\n 'sandbox',\n 'scope',\n 'scoped',\n 'scrolling',\n 'selected',\n 'shape',\n 'size',\n 'sizes',\n 'slot',\n 'span',\n 'spellCheck',\n 'src',\n 'srcDoc',\n 'srcLang',\n 'srcSet',\n 'start',\n 'step',\n 'summary',\n 'target',\n 'title',\n 'translate',\n 'type',\n 'useMap',\n 'value',\n 'width',\n 'wrap',\n])\n\n/**\n * Filters props for HTML elements. Keeps valid HTML attrs, data-*, aria-*.\n * Rejects unknown props and $-prefixed transient props.\n */\nexport const filterProps = (props: Record<string, unknown>): Record<string, unknown> => {\n const filtered: Record<string, unknown> = {}\n\n for (const key in props) {\n // Skip transient props ($-prefixed) — used for styling-only props\n if (key.charCodeAt(0) === 36) continue // '$'\n\n // Skip `as` prop — handled separately by styled\n if (key === 'as') continue\n\n // Keep data-* and aria-* attributes\n if (key.startsWith('data-') || key.startsWith('aria-')) {\n filtered[key] = props[key]\n continue\n }\n\n // Keep known HTML props\n if (HTML_PROPS.has(key)) {\n filtered[key] = props[key]\n }\n }\n\n return filtered\n}\n\n/**\n * Build final props for a styled component in a single pass.\n * Combines className merging, ref injection, and prop filtering into one\n * allocation and one iteration.\n */\nexport const buildProps = (\n rawProps: Record<string, any>,\n generatedCls: string,\n isDOM: boolean,\n customFilter?: (prop: string) => boolean,\n): Record<string, any> => {\n const result: Record<string, any> = {}\n\n // Merge generated + user className\n const userCls = rawProps.class || rawProps.className\n if (generatedCls) {\n result.class = userCls ? `${generatedCls} ${userCls}` : generatedCls\n } else if (userCls) {\n result.class = userCls\n }\n\n // Component target — forward all props except as/className/class and $-prefixed\n if (!isDOM) {\n for (const key in rawProps) {\n if (key === 'as' || key === 'className' || key === 'class') continue\n if (key.charCodeAt(0) === 36) continue // $-prefixed transient\n result[key] = rawProps[key]\n }\n return result\n }\n\n // DOM element with custom shouldForwardProp\n if (customFilter) {\n for (const key in rawProps) {\n if (key === 'as' || key === 'className' || key === 'class') continue\n if (customFilter(key)) result[key] = rawProps[key]\n }\n return result\n }\n\n // DOM element with default filtering\n for (const key in rawProps) {\n if (key === 'as' || key === 'className' || key === 'class') continue\n if (key.charCodeAt(0) === 36) continue // $-prefixed transient\n if (key.startsWith('data-') || key.startsWith('aria-')) {\n result[key] = rawProps[key]\n continue\n }\n if (HTML_PROPS.has(key)) result[key] = rawProps[key]\n }\n return result\n}\n","/**\n * Shared utilities used across multiple modules.\n */\nimport { CSSResult, type Interpolation } from './resolve'\n\n/** Check if an interpolation value is dynamic (contains functions or nested dynamic CSSResults). */\nexport const isDynamic = (v: Interpolation): boolean => {\n if (typeof v === 'function') return true\n if (Array.isArray(v)) return v.some(isDynamic)\n if (v instanceof CSSResult) return v.values.some(isDynamic)\n return false\n}\n","/**\n * Fast FNV-1a non-cryptographic hash. Returns base-36 string for compact class names.\n *\n * 32-bit hash space → ~4.3 billion unique values. Collision probability is\n * negligible for typical applications (< 10,000 unique CSS rules).\n */\n\n/** FNV-1a offset basis — starting state for streaming hash. */\nexport const HASH_INIT = 2166136261\n\nconst FNV_PRIME = 16777619\n\n/**\n * Feed a string segment into the running hash state.\n * Streaming: hashUpdate(hashUpdate(HASH_INIT, 'ab'), 'cd') === hash('abcd').\n */\nexport const hashUpdate = (init: number, str: string): number => {\n let h = init\n for (let i = 0; i < str.length; i++) {\n h ^= str.charCodeAt(i)\n h = Math.imul(h, FNV_PRIME)\n }\n return h\n}\n\n/** Finalize a hash state into a base-36 class name suffix. */\nexport const hashFinalize = (h: number): string => (h >>> 0).toString(36)\n\n/** Hash a complete string in one shot. Returns base-36 string. */\nexport const hash = (str: string): string => hashFinalize(hashUpdate(HASH_INIT, str))\n","/**\n * StyleSheet manager. Handles CSS rule injection, hash-based deduplication,\n * SSR buffering, client-side hydration, bounded cache, and @layer support.\n *\n * Media queries (@media), @supports, and @container blocks nested inside\n * component CSS are automatically extracted into separate top-level rules.\n */\nimport { hash } from './hash'\nimport { clearNormCache } from './resolve'\n\n// Dev-time counter sink — see styler/resolve.ts for the contract.\ninterface ViteMeta {\n readonly env?: { readonly DEV?: boolean }\n}\nconst _countSink = globalThis as { __pyreon_count__?: (name: string, n?: number) => void }\n\nconst PREFIX = 'pyr'\nconst ATTR = 'data-pyreon-styler'\nconst DEFAULT_MAX_CACHE_SIZE = 10000\n\nexport interface StyleSheetOptions {\n /** Maximum number of cached rules before eviction (default: 10000). */\n maxCacheSize?: number\n /** CSS @layer name to wrap scoped rules in. */\n layer?: string\n}\n\nexport class StyleSheet {\n private cache = new Map<string, string>()\n private insertCache = new Map<string, string>()\n private sheet: CSSStyleSheet | null = null\n private ssrBuffer: string[] = []\n private isSSR: boolean\n private maxCacheSize: number\n private layer: string | undefined\n private supportsLayer = false\n\n constructor(options: StyleSheetOptions = {}) {\n this.maxCacheSize = options.maxCacheSize ?? DEFAULT_MAX_CACHE_SIZE\n this.layer = options.layer\n this.isSSR = typeof document === 'undefined'\n if (!this.isSSR) this.mount()\n }\n\n private mount() {\n // Reuse existing <style> tag from SSR hydration\n const existing = document.querySelector(`style[${ATTR}]`) as HTMLStyleElement | null\n\n if (existing) {\n this.sheet = existing.sheet ?? null\n this.hydrateFromTag(existing)\n } else {\n const el = document.createElement('style')\n el.setAttribute(ATTR, '')\n document.head.appendChild(el)\n this.sheet = el.sheet ?? null\n }\n\n // Inject CSS @layer ordering for the framework's cascade.\n //\n // Two layers: `elements` (base layout primitives) < `rocketstyle`\n // (themed component styles). The explicit ordering declaration\n // ensures rocketstyle theme styles always override element base\n // styles regardless of source order, while media queries within\n // each layer still work correctly (media conditions are evaluated\n // within each layer independently).\n //\n // Previously this used a single `@layer pyreon` which put\n // rocketstyle and elements in the same layer, relying on source\n // order. That broke when Elements were rendered WITHOUT a layer\n // (unlayered CSS always wins over layered CSS per the cascade\n // spec), making rocketstyle themes unable to override element\n // base styles.\n if (this.sheet) {\n try {\n this.sheet.insertRule('@layer elements, rocketstyle;', 0)\n this.supportsLayer = true\n } catch {\n // @layer not supported — falls back to source order\n }\n }\n }\n\n /** Extract className from a selector like \".pyr-abc\" or \".pyr-abc.pyr-abc\" → \"pyr-abc\" */\n private extractClassName(selectorText: string): string | null {\n if (selectorText[0] !== '.') return null\n const dotIdx = selectorText.indexOf('.', 1)\n return dotIdx > 0 ? selectorText.slice(1, dotIdx) : selectorText.slice(1)\n }\n\n /** Parse existing rules from SSR-rendered <style> tag into cache. */\n private hydrateFromTag(el: HTMLStyleElement) {\n const sheet = el.sheet\n if (!sheet) return\n\n for (let i = 0; i < sheet.cssRules.length; i++) {\n const rule = sheet.cssRules[i]\n\n if (rule instanceof CSSStyleRule) {\n const className = this.extractClassName(rule.selectorText)\n if (className) this.cache.set(className, className)\n }\n\n // Handle split @media rules that wrap our selectors\n if (typeof CSSMediaRule !== 'undefined' && rule instanceof CSSMediaRule) {\n for (let j = 0; j < rule.cssRules.length; j++) {\n const inner = rule.cssRules[j]\n if (inner instanceof CSSStyleRule) {\n const className = this.extractClassName(inner.selectorText)\n if (className) this.cache.set(className, className)\n }\n }\n }\n }\n }\n\n /** Evict oldest entries when cache exceeds max size. */\n private evictIfNeeded() {\n if (this.cache.size <= this.maxCacheSize) return\n\n // Map iteration order is insertion order — delete oldest 10%\n const toDelete = Math.floor(this.maxCacheSize * 0.1)\n let count = 0\n for (const key of this.cache.keys()) {\n if (count >= toDelete) break\n this.cache.delete(key)\n count++\n }\n }\n\n /**\n * Extract nested at-rules (@media, @supports, @container) from CSS text\n * and wrap their content in the given selector as separate top-level rules.\n */\n private splitAtRules(cssText: string, selector: string): { base: string; atRules: string[] } {\n // Fast path: no at-rules to split\n if (cssText.indexOf('@') === -1) return { base: cssText, atRules: [] }\n\n const atRules: string[] = []\n const baseParts: string[] = []\n let depth = 0\n let atStart = -1\n let lastBase = 0\n\n for (let i = 0; i < cssText.length; i++) {\n const ch = cssText[i]\n\n if (ch === '{') {\n depth++\n } else if (ch === '}') {\n depth--\n if (depth === 0 && atStart >= 0) {\n // End of a tracked at-rule block — extract and wrap with selector\n const openBrace = cssText.indexOf('{', atStart)\n const atPrefix = cssText.slice(atStart, openBrace).trim()\n const innerCSS = cssText.slice(openBrace + 1, i).trim()\n if (innerCSS) {\n atRules.push(`${atPrefix}{${selector}{${innerCSS}}}`)\n }\n atStart = -1\n lastBase = i + 1\n }\n } else if (depth === 0 && ch === '@' && atStart < 0) {\n // Check if this starts a splittable at-rule (not @keyframes, @font-face, etc.)\n const remaining = cssText.slice(i, i + 20)\n if (/^@(?:media|supports|container)\\b/.test(remaining)) {\n // Save any base CSS that precedes this at-rule\n const baseBefore = cssText.slice(lastBase, i).trim()\n if (baseBefore) baseParts.push(baseBefore)\n atStart = i\n }\n }\n }\n\n // Collect remaining base CSS after the last at-rule\n if (lastBase < cssText.length && atStart < 0) {\n const remaining = cssText.slice(lastBase).trim()\n if (remaining) baseParts.push(remaining)\n }\n\n // If no at-rules were found, return original unchanged\n if (atRules.length === 0) return { base: cssText, atRules: [] }\n\n return { base: baseParts.join(' '), atRules }\n }\n\n /**\n * Compute a className from CSS text without injecting (pure function).\n */\n getClassName(cssText: string): string {\n const cached = this.insertCache.get(cssText)\n if (cached) return cached\n const h = hash(cssText)\n return `${PREFIX}-${h}`\n }\n\n /**\n * Insert CSS rules for a component. Returns the class name (deterministic, hash-based).\n * Deduplicates: same CSS text always produces the same class name and\n * the rules are only injected once.\n *\n * @param cssText - CSS declarations to insert\n * @param _unused - Reserved for backward compatibility (was `boost`)\n * @param insertLayer - CSS @layer to wrap this rule in (e.g. 'rocketstyle').\n * Used by rocketstyle to ensure wrapper styles override inner component styles\n * via @layer order (base < rocketstyle) instead of specificity hacks.\n */\n insert(cssText: string, _unused = false, insertLayer?: string): string {\n if ((import.meta as ViteMeta).env?.DEV === true)\n _countSink.__pyreon_count__?.('styler.sheet.insert')\n // Fast path: skip hash computation on repeated insertions of same CSS text\n const icKey = insertLayer ? `${cssText}\\0L:${insertLayer}` : cssText\n const icHit = this.insertCache.get(icKey)\n if (icHit) {\n if ((import.meta as ViteMeta).env?.DEV === true)\n _countSink.__pyreon_count__?.('styler.sheet.insert.hit')\n return icHit\n }\n\n const h = hash(cssText)\n const className = `${PREFIX}-${h}`\n\n if (this.cache.has(className)) {\n this.insertCache.set(icKey, className)\n return className\n }\n\n this.evictIfNeeded()\n this.cache.set(className, className)\n\n const selector = `.${className}`\n\n // Split nested at-rules into separate top-level rules\n const { base, atRules } = this.splitAtRules(cssText, selector)\n\n const rules: string[] = []\n if (base) rules.push(`${selector}{${base}}`)\n rules.push(...atRules)\n\n // Apply @layer wrapping — per-insert layer takes precedence over sheet-level layer.\n // In SSR, always apply layers (output goes to real browsers).\n // In client, skip if @layer isn't supported (e.g. happy-dom in tests).\n const layerName = this.isSSR || this.supportsLayer ? (insertLayer ?? this.layer) : undefined\n const finalRules = layerName ? rules.map((r) => `@layer ${layerName}{${r}}`) : rules\n\n if (this.isSSR) {\n for (const rule of finalRules) {\n this.ssrBuffer.push(rule)\n }\n } else if (this.sheet) {\n for (const rule of finalRules) {\n try {\n this.sheet.insertRule(rule, this.sheet.cssRules.length)\n } catch (_e) {\n if (process.env.NODE_ENV !== 'production') {\n // oxlint-disable-next-line no-console\n console.warn('[styler] Failed to insert CSS rule:', rule, _e)\n }\n }\n }\n }\n\n this.insertCache.set(icKey, className)\n return className\n }\n\n /** Insert a @keyframes rule. Deduplicates by animation name. */\n insertKeyframes(name: string, body: string): void {\n if (this.cache.has(name)) return\n\n this.evictIfNeeded()\n this.cache.set(name, name)\n\n const rule = `@keyframes ${name}{${body}}`\n\n if (this.isSSR) {\n this.ssrBuffer.push(rule)\n } else if (this.sheet) {\n try {\n this.sheet.insertRule(rule, this.sheet.cssRules.length)\n } catch (_e) {\n if (process.env.NODE_ENV !== 'production') {\n // silently ignore invalid CSS rules in production\n }\n }\n }\n }\n\n /**\n * Split CSS text into individual top-level rules.\n * CSSStyleSheet.insertRule() only accepts one rule at a time.\n */\n private splitRules(cssText: string): string[] {\n const rules: string[] = []\n let depth = 0\n let start = 0\n\n for (let i = 0; i < cssText.length; i++) {\n const ch = cssText[i]\n if (ch === '{') depth++\n else if (ch === '}') {\n depth--\n if (depth === 0) {\n const rule = cssText.slice(start, i + 1).trim()\n if (rule) rules.push(rule)\n start = i + 1\n }\n }\n }\n\n return rules\n }\n\n /** Insert global CSS rules (no wrapper selector). Deduplicates by hash. */\n insertGlobal(cssText: string): void {\n const h = hash(cssText)\n const key = `global-${h}`\n\n if (this.cache.has(key)) return\n\n this.evictIfNeeded()\n this.cache.set(key, key)\n\n if (this.isSSR) {\n this.ssrBuffer.push(cssText)\n } else if (this.sheet) {\n const rules = this.splitRules(cssText)\n for (const rule of rules) {\n try {\n this.sheet.insertRule(rule, this.sheet.cssRules.length)\n } catch (_e) {\n if (process.env.NODE_ENV !== 'production') {\n // oxlint-disable-next-line no-console\n console.warn('[styler] Failed to insert global CSS rule:', rule, _e)\n }\n }\n }\n }\n }\n\n /** Returns collected CSS for SSR as a complete `<style>` tag string. */\n getStyleTag(): string {\n if (this.ssrBuffer.length === 0) return `<style ${ATTR}=\"\"></style>`\n // Emit the layer ordering declaration for SSR output so the cascade\n // is correct when the browser parses the SSR HTML. On the client side\n // this ordering is injected via insertRule in mount().\n const layerDecl = this.hasLayeredRules()\n ? '@layer elements, rocketstyle;'\n : this.layer\n ? `@layer ${this.layer};`\n : ''\n const css = (layerDecl + this.ssrBuffer.join('')).replace(/<\\/style/gi, '<\\\\/style')\n return `<style ${ATTR}=\"\">${css}</style>`\n }\n\n /** Returns collected CSS rules as a raw string (useful for streaming SSR). */\n getStyles(): string {\n if (this.ssrBuffer.length === 0) return ''\n const layerDecl = this.hasLayeredRules()\n ? '@layer elements, rocketstyle;'\n : this.layer\n ? `@layer ${this.layer};`\n : ''\n return layerDecl + this.ssrBuffer.join('')\n }\n\n /** Check if any buffered SSR rules use @layer wrapping. */\n private hasLayeredRules(): boolean {\n return this.ssrBuffer.some((r) => r.startsWith('@layer '))\n }\n\n /** Reset SSR buffer and cache (call between server requests). */\n reset(): void {\n this.ssrBuffer = []\n this.cache.clear()\n this.insertCache.clear()\n }\n\n /** Clear the dedup cache. Useful for HMR / dev-time reloads. */\n clearCache(): void {\n this.cache.clear()\n this.insertCache.clear()\n clearNormCache()\n }\n\n /**\n * Full cleanup: clear cache and remove all CSS rules from the DOM.\n * Intended for HMR / dev-time reloads where stale styles must be purged.\n */\n clearAll(): void {\n this.cache.clear()\n this.insertCache.clear()\n clearNormCache()\n this.ssrBuffer = []\n if (this.sheet) {\n while (this.sheet.cssRules.length > 0) {\n this.sheet.deleteRule(0)\n }\n }\n }\n\n /**\n * Compute className and full CSS rule text without injecting.\n */\n prepare(cssText: string): { className: string; rules: string } {\n const h = hash(cssText)\n const className = `${PREFIX}-${h}`\n const selector = `.${className}`\n const { base, atRules } = this.splitAtRules(cssText, selector)\n\n const allRules: string[] = []\n if (base) allRules.push(`${selector}{${base}}`)\n allRules.push(...atRules)\n\n const finalRules = this.layer ? allRules.map((r) => `@layer ${this.layer}{${r}}`) : allRules\n\n return { className, rules: finalRules.join('') }\n }\n\n /** Check if a className is already in the cache. O(1) Map lookup. */\n has(className: string): boolean {\n return this.cache.has(className)\n }\n\n /** Current number of cached rules. */\n get cacheSize(): number {\n return this.cache.size\n }\n}\n\n/** Default singleton sheet for client-side use.\n * No default layer — each consumer specifies their own:\n * Elements use `{ layer: 'elements' }`\n * Rocketstyle uses `{ layer: 'rocketstyle' }`\n * The layer ordering `@layer elements, rocketstyle` is injected\n * in mount() so rocketstyle always overrides elements.\n */\nexport const sheet = new StyleSheet()\n\n/**\n * Factory for creating isolated StyleSheet instances.\n * Use in SSR to get per-request isolation.\n */\nexport const createSheet = (options?: StyleSheetOptions): StyleSheet => new StyleSheet(options)\n","/**\n * Theme context for styled components.\n *\n * Extensible theme interface. Consumers can augment this via module\n * declaration merging for full strict types:\n *\n * declare module '@pyreon/styler' {\n * interface DefaultTheme {\n * colors: { primary: string; secondary: string }\n * spacing: (n: number) => string\n * }\n * }\n */\nimport type { VNode, VNodeChild } from '@pyreon/core'\nimport { createReactiveContext, provide, useContext } from '@pyreon/core'\n\nexport interface DefaultTheme {}\n\ntype Theme = DefaultTheme & Record<string, unknown>\n\n/**\n * Reactive theme context. Consumers get `() => Theme` from useContext.\n *\n * The DIFFERENCE from PR #258: styled components read the theme accessor\n * inside a COMPUTED (not an effect). The computed tracks theme + mode +\n * dimensions simultaneously, and the resolve itself runs untracked.\n * This gives reactive theme/mode/dimension switching with:\n * - Zero per-component effect()\n * - One lightweight computed per component\n * - String-equality memoization (same CSS class = no DOM update)\n * - Untracked resolve (no exponential cascade)\n */\nexport const ThemeContext = createReactiveContext<Theme>({} as Theme)\n\n/**\n * Read the current theme. Returns the theme value (calls the accessor).\n * Inside a reactive scope (computed/effect), this tracks theme changes.\n */\nexport const useTheme = <T extends object = Theme>(): T => useContext(ThemeContext)() as T\n\n/**\n * Returns the raw `() => Theme` accessor for use inside computeds\n * where you need explicit control over when the read happens.\n */\nexport const useThemeAccessor = <T extends object = Theme>(): (() => T) =>\n useContext(ThemeContext) as () => T\n\n/**\n * @internal Low-level provider — use `PyreonUI` from `@pyreon/ui-core` instead.\n * @deprecated Prefer `<PyreonUI theme={theme}>`\n */\nexport function ThemeProvider({\n theme,\n children,\n}: {\n theme: Theme\n children?: VNodeChild\n}): VNode | null {\n provide(ThemeContext, () => theme)\n return (children ?? null) as VNode | null\n}\n","/**\n * createGlobalStyle() — tagged template function that injects global CSS\n * rules (not scoped to a class name). Returns a component function that\n * injects styles when called and supports dynamic interpolations via\n * props/theme.\n *\n * Usage:\n * const GlobalStyle = createGlobalStyle`\n * body { margin: 0; font-family: ${({ theme }) => theme.font}; }\n * *, *::before, *::after { box-sizing: border-box; }\n * `\n */\nimport type { ComponentFn } from '@pyreon/core'\nimport { type Interpolation, normalizeCSS, resolve } from './resolve'\nimport { isDynamic } from './shared'\nimport { sheet } from './sheet'\nimport { useTheme } from './ThemeProvider'\n\nexport const createGlobalStyle = (\n strings: TemplateStringsArray,\n ...values: Interpolation[]\n): ComponentFn => {\n const hasDynamicValues = values.some(isDynamic)\n\n // STATIC FAST PATH: compute once at creation time\n if (!hasDynamicValues) {\n const cssText = normalizeCSS(resolve(strings, values, {}))\n\n // Inject into sheet immediately\n if (cssText.trim()) sheet.insertGlobal(cssText)\n\n const StaticGlobal: ComponentFn = () => null\n return StaticGlobal\n }\n\n // DYNAMIC PATH: resolve on every render with theme/props\n const DynamicGlobal: ComponentFn = (props: Record<string, any>) => {\n const theme = useTheme()\n const allProps = { ...props, theme }\n const cssText = normalizeCSS(resolve(strings, values, allProps))\n\n if (cssText.trim()) sheet.insertGlobal(cssText)\n\n return null\n }\n\n return DynamicGlobal\n}\n","/**\n * keyframes() tagged template function. Creates a CSS @keyframes rule,\n * injects it into the stylesheet, and returns the generated animation name.\n *\n * Usage:\n * const fadeIn = keyframes`\n * from { opacity: 0; }\n * to { opacity: 1; }\n * `\n * // fadeIn === \"pyr-kf-abc123\" (deterministic, hash-based)\n */\nimport { hash } from './hash'\nimport { type Interpolation, normalizeCSS, resolve } from './resolve'\nimport { sheet } from './sheet'\n\nclass KeyframesResult {\n readonly name: string\n\n constructor(strings: TemplateStringsArray, values: Interpolation[]) {\n const body = normalizeCSS(resolve(strings, values, {}))\n const h = hash(body)\n this.name = `pyr-kf-${h}`\n\n sheet.insertKeyframes(this.name, body)\n }\n\n /** Returns the animation name when used in string context. */\n toString(): string {\n return this.name\n }\n}\n\nexport const keyframes = (\n strings: TemplateStringsArray,\n ...values: Interpolation[]\n): KeyframesResult => new KeyframesResult(strings, values)\n","/**\n * styled() component factory. Creates Pyreon components that inject CSS\n * class names from tagged template literals.\n *\n * Supports:\n * - styled('div')`...` and styled(Component)`...`\n * - styled.div`...` (via Proxy)\n * - `as` prop for polymorphic rendering\n * - $-prefixed transient props (not forwarded to DOM)\n * - Custom shouldForwardProp for per-component prop filtering\n * - Static path optimization (templates with no dynamic interpolations)\n * - Boost specificity via doubled selector\n *\n * CSS nesting (`&` selectors) works natively — the resolver passes CSS\n * through without transformation, so `&:hover`, `&::before`, etc. work\n * as-is in browsers supporting CSS Nesting (all modern browsers).\n */\nimport type { ComponentFn, VNode } from '@pyreon/core'\nimport { h } from '@pyreon/core'\nimport { computed, renderEffect, runUntracked } from '@pyreon/reactivity'\nimport { buildProps } from './forward'\nimport { type Interpolation, normalizeCSS, resolve } from './resolve'\nimport { isDynamic } from './shared'\nimport { sheet } from './sheet'\nimport { useThemeAccessor } from './ThemeProvider'\n\ntype Tag = string | ComponentFn<any>\n\nexport interface StyledOptions {\n /** Custom prop filter. Return true to forward the prop to the DOM element. */\n shouldForwardProp?: (prop: string) => boolean\n /**\n * CSS @layer name. Rules are wrapped in `@layer <name> { ... }`.\n * Framework CSS uses two layers with explicit ordering:\n * `@layer elements, rocketstyle;`\n * Elements (base layout) use `'elements'`, rocketstyle themes use\n * `'rocketstyle'`. The ordering ensures themes always override base\n * styles regardless of source order.\n */\n layer?: string\n}\n\nconst getDisplayName = (tag: Tag): string =>\n typeof tag === 'string'\n ? tag\n : (tag as ComponentFn<any> & { displayName?: string }).displayName || tag.name || 'Component'\n\n// Component cache: same template literal + tag + no options → same component.\n// WeakMap on `strings` (TemplateStringsArray is object-identity per source location).\nconst staticComponentCache = new WeakMap<TemplateStringsArray, Map<Tag, ComponentFn>>()\n\n// Single-entry hot cache — just 3 reference comparisons, no Map/WeakMap overhead.\nlet _hotStrings: TemplateStringsArray | null = null\nlet _hotTag: Tag | null = null\nlet _hotComponent: ComponentFn | null = null\n\nconst createStyledComponent = (\n tag: Tag,\n strings: TemplateStringsArray,\n values: Interpolation[],\n options?: StyledOptions,\n): ComponentFn => {\n // Ultra-fast hot cache: 3 reference comparisons → return immediately\n if (values.length === 0 && !options) {\n if (strings === _hotStrings && tag === _hotTag) return _hotComponent as ComponentFn\n\n // WeakMap fallback for alternating patterns\n const tagMap = staticComponentCache.get(strings)\n if (tagMap) {\n const cached = tagMap.get(tag)\n if (cached) {\n _hotStrings = strings\n _hotTag = tag\n _hotComponent = cached\n return cached\n }\n }\n }\n\n // Fast check: no values means no dynamic interpolations — avoids .some() scan\n const hasDynamicValues = values.length > 0 && values.some(isDynamic)\n const customFilter = options ? options.shouldForwardProp : undefined\n const insertLayer = options?.layer\n\n // STATIC FAST PATH: no function interpolations → compute class once at creation time\n if (!hasDynamicValues) {\n // Inline resolve for the common no-values case\n const raw = values.length === 0 ? (strings[0] as string) : resolve(strings, values, {})\n const cssText = normalizeCSS(raw)\n const hasCss = cssText.length > 0\n\n const staticClassName = hasCss ? sheet.insert(cssText, false, insertLayer) : ''\n\n const StaticStyled: ComponentFn = (rawProps: Record<string, any>): VNode | null => {\n const finalTag = rawProps.as || tag\n const isDOM = typeof finalTag === 'string'\n const finalProps = buildProps(rawProps, staticClassName, isDOM, customFilter)\n\n return h(\n finalTag as string,\n finalProps,\n ...(Array.isArray(rawProps.children)\n ? rawProps.children\n : rawProps.children != null\n ? [rawProps.children]\n : []),\n )\n }\n\n ;(StaticStyled as ComponentFn & { displayName?: string }).displayName =\n `styled(${getDisplayName(tag)})`\n\n // Store in component cache + hot cache for future reuse\n if (!options && values.length === 0) {\n let tagMap = staticComponentCache.get(strings)\n if (!tagMap) {\n tagMap = new Map()\n staticComponentCache.set(strings, tagMap)\n }\n tagMap.set(tag, StaticStyled)\n _hotStrings = strings\n _hotTag = tag\n _hotComponent = StaticStyled\n }\n\n return StaticStyled\n }\n\n // ─── Tier 2: Per-definition class cache ───────────────────────────────────\n // Two-level WeakMap: $rocketstyle → $rocketstate → className.\n // 50 identical Items with the same resolved theme → 1 resolve + 49 hits.\n const classCache = new WeakMap<object, WeakMap<object, string>>()\n\n // DYNAMIC PATH: uses computed() for reactive class derivation.\n //\n // Architecture:\n // - $rocketstyle/$rocketstate may be function ACCESSORS (from rocketstyle)\n // or plain objects (from direct styled() usage).\n // - When they're accessors, a computed() tracks them so mode/dimension\n // signal changes produce a new CSS class reactively.\n // - The resolve() itself runs UNTRACKED inside the computed to prevent\n // exponential cascade from theme deep-reads in interpolation functions.\n // - The computed memoizes by string equality — same CSS class = no DOM update.\n // - Pyreon's built-in renderEffect handles the DOM class attribute update\n // when the computed value changes.\n //\n // This gives reactive mode/dimension switching WITHOUT per-component effect().\n const DynamicStyled: ComponentFn = (rawProps: Record<string, any>): VNode | null => {\n const themeAccessor = useThemeAccessor()\n const theme = themeAccessor() // snapshot for initial + static path\n const $rs = rawProps.$rocketstyle\n const $rsState = rawProps.$rocketstate\n const isReactiveRS = typeof $rs === 'function'\n const isReactiveState = typeof $rsState === 'function'\n\n // Helper: resolve CSS + cache result\n const doResolve = (rs: any, rsState: any, t: any): string => {\n // Tier 2 cache: skip resolve if same object identity seen before\n if (rs && typeof rs === 'object' && rsState && typeof rsState === 'object') {\n const inner = classCache.get(rs)\n if (inner) {\n const cached = inner.get(rsState)\n if (cached !== undefined) return cached\n }\n }\n\n const resolveProps = {\n ...rawProps,\n ...(isReactiveRS ? { $rocketstyle: rs } : {}),\n ...(isReactiveState ? { $rocketstate: rsState } : {}),\n theme: t,\n }\n const cssText = normalizeCSS(resolve(strings, values, resolveProps))\n const className = cssText.length > 0 ? sheet.insert(cssText, false, insertLayer) : ''\n\n if (rs && typeof rs === 'object' && rsState && typeof rsState === 'object') {\n let inner = classCache.get(rs)\n if (!inner) {\n inner = new WeakMap()\n classCache.set(rs, inner)\n }\n inner.set(rsState, className)\n }\n return className\n }\n\n // If any axis is reactive, wrap in computed that tracks all three:\n // 1. $rocketstyle accessor (mode + dimension signals)\n // 2. $rocketstate accessor (state descriptor)\n // 3. themeAccessor (user-preference theme swap)\n // The resolve itself runs UNTRACKED to prevent exponential cascade.\n const hasReactive = isReactiveRS || isReactiveState\n const cssClass = hasReactive\n ? computed(() => {\n // TRACKED reads:\n const rs = isReactiveRS ? $rs() : $rs\n const rsState = isReactiveState ? $rsState() : $rsState\n const t = themeAccessor() // TRACKED — theme swap\n\n // UNTRACKED: resolve + sheet insert\n return runUntracked(() => doResolve(rs, rsState, t))\n }, { equals: (a, b) => a === b })\n : null\n\n const finalTag = rawProps.as || tag\n const isDOM = typeof finalTag === 'string'\n\n // Initial class: computed (reactive) or direct resolve (static)\n const className = cssClass\n ? cssClass()\n : doResolve($rs, $rsState, theme)\n const finalProps = buildProps(rawProps, className, isDOM, customFilter)\n\n // Reactive path: lightweight renderEffect that reads the pre-computed\n // class string and toggles classList. This is NOT the old PR #258\n // approach — the expensive resolve() already happened inside the\n // computed. This renderEffect only does: read string → compare → toggle.\n if (cssClass) {\n let el: Element | null = null\n let currentClassName = className\n\n const originalRef = finalProps.ref\n finalProps.ref = (node: Element | null) => {\n el = node\n if (originalRef) {\n if (typeof originalRef === 'function') originalRef(node)\n else if (originalRef && typeof originalRef === 'object') (originalRef as any).current = node\n }\n }\n\n renderEffect(() => {\n const newClass = cssClass() // reads computed — O(1), just string\n if (el && newClass !== currentClassName) {\n if (currentClassName) el.classList.remove(currentClassName)\n if (newClass) el.classList.add(newClass)\n currentClassName = newClass\n }\n })\n }\n\n return h(\n finalTag as string,\n finalProps,\n ...(Array.isArray(rawProps.children)\n ? rawProps.children\n : rawProps.children != null\n ? [rawProps.children]\n : []),\n )\n }\n\n ;(DynamicStyled as ComponentFn & { displayName?: string }).displayName =\n `styled(${getDisplayName(tag)})`\n return DynamicStyled\n}\n\n/** Factory function: styled(tag) returns a tagged template function. */\nconst styledFactory = (tag: Tag, options?: StyledOptions) => {\n const templateFn = (strings: TemplateStringsArray, ...values: Interpolation[]) =>\n createStyledComponent(tag, strings, values, options)\n\n return templateFn\n}\n\n/**\n * Main styled export. Supports both calling conventions:\n * - `styled('div')` or `styled(Component)` → returns tagged template function\n * - `styled('div', { shouldForwardProp })` → with custom prop filtering\n * - `styled.div` → shorthand via Proxy (no options)\n */\n// Cache template functions per tag to avoid closure allocation on every Proxy get\nconst proxyCache = new Map<string, (...args: any[]) => any>()\n\n/**\n * Generic tagged template function returned by `styled(tag)` and `styled.tag`.\n *\n * Accepts an optional type parameter `<P>` for consumer-defined props\n * (typically transient $-prefixed props that aren't forwarded to the DOM).\n *\n * @example\n * const Box = styled('div')<{ $color: string }>`\n * background: ${(props) => props.$color};\n * `\n * <Box $color=\"red\" /> // $color is required and typed\n */\ntype TagTemplateFn = <P extends object = Record<string, unknown>>(\n strings: TemplateStringsArray,\n ...values: Interpolation<P>[]\n) => ComponentFn<P & Record<string, unknown>>\n\ntype HtmlTags =\n | 'a'\n | 'abbr'\n | 'address'\n | 'article'\n | 'aside'\n | 'audio'\n | 'b'\n | 'blockquote'\n | 'body'\n | 'br'\n | 'button'\n | 'canvas'\n | 'caption'\n | 'code'\n | 'col'\n | 'colgroup'\n | 'dd'\n | 'details'\n | 'div'\n | 'dl'\n | 'dt'\n | 'em'\n | 'fieldset'\n | 'figcaption'\n | 'figure'\n | 'footer'\n | 'form'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'head'\n | 'header'\n | 'hr'\n | 'html'\n | 'i'\n | 'iframe'\n | 'img'\n | 'input'\n | 'label'\n | 'legend'\n | 'li'\n | 'link'\n | 'main'\n | 'mark'\n | 'menu'\n | 'meta'\n | 'nav'\n | 'ol'\n | 'optgroup'\n | 'option'\n | 'output'\n | 'p'\n | 'picture'\n | 'pre'\n | 'progress'\n | 'q'\n | 'section'\n | 'select'\n | 'small'\n | 'source'\n | 'span'\n | 'strong'\n | 'style'\n | 'sub'\n | 'summary'\n | 'sup'\n | 'svg'\n | 'table'\n | 'tbody'\n | 'td'\n | 'template'\n | 'textarea'\n | 'tfoot'\n | 'th'\n | 'thead'\n | 'time'\n | 'tr'\n | 'u'\n | 'ul'\n | 'video'\n\nexport type StyledFunction = ((tag: Tag, options?: StyledOptions) => TagTemplateFn) & {\n [K in HtmlTags]: TagTemplateFn\n}\n\n// Proxy is needed to support styled.div`...` syntax; the cast bridges\n// styledFactory's call signature to StyledFunction which adds HTML tag properties.\n// Proxy target uses `as any` because TS can't resolve Proxy<StyledFunction> with mapped types\nexport const styled: StyledFunction = new Proxy(styledFactory as any, {\n get(_target: unknown, prop: string) {\n if (prop === 'prototype' || prop === '$$typeof') return undefined\n // styled.div`...`, styled.span`...`, etc.\n let fn = proxyCache.get(prop)\n if (!fn) {\n fn = (strings: TemplateStringsArray, ...values: Interpolation[]) =>\n createStyledComponent(prop, strings, values)\n proxyCache.set(prop, fn)\n }\n return fn\n },\n})\n","/**\n * Hook that resolves a CSSResult template with props, injects CSS\n * into the shared stylesheet, and returns the className.\n *\n * Use this when you need computed CSS class names on plain elements\n * without the overhead of a styled component layer.\n */\nimport { type CSSResult, normalizeCSS, resolve } from './resolve'\nimport { sheet } from './sheet'\nimport { useTheme } from './ThemeProvider'\n\nexport function useCSS(template: CSSResult, props?: Record<string, any>, boost?: boolean): string {\n const theme = useTheme()\n const allProps = theme ? { ...props, theme } : (props ?? {})\n const cssText = normalizeCSS(resolve(template.strings, template.values, allProps))\n\n if (!cssText.trim()) return ''\n\n return sheet.insert(cssText, boost)\n}\n"],"mappings":";;;;AAcA,MAAMA,eAAa;;;;;;AA8BnB,IAAa,YAAb,MAAuB;CACrB,YACE,AAAS,SACT,AAAS,QACT;EAFS;EACA;;;CAIX,WAAmB;AACjB,SAAO,QAAQ,KAAK,SAAS,KAAK,QAAQ,EAAE,CAAC;;;;AAKjD,MAAa,WACX,SACA,QACA,UACW;AACX,KAAK,OAAO,KAAkB,KAAK,QAAQ,KAAM,cAAW,mBAAmB,iBAAiB;CAGhG,IAAI,SAAS,QAAQ;AACrB,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,IAAI,OAAO;EACjB,MAAM,IAAI,QAAQ,IAAI;AAEtB,MAAI,OAAO,MAAM,YAAY;GAC3B,MAAM,IAAI,EAAE,MAAM;AAClB,cACG,OAAO,MAAM,WACV,IACA,KAAK,QAAQ,MAAM,SAAS,MAAM,OAChC,KACA,aAAa,GAAoB,MAAM,IAAI;aAC1C,KAAK,QAAQ,MAAM,SAAS,MAAM,KAC3C,WAAU;WACD,OAAO,MAAM,SACtB,WAAU,IAAI;WACL,OAAO,MAAM,SACtB,WAAU,IAAI;M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AAgB,OAAsB,UAAuC;AAExF,KAAI,SAAS,QAAQ,UAAU,SAAS,UAAU,KAAM,QAAO;AAG/D,KAAI,OAAO,UAAU,WAAY,QAAO,aAAa,MAAM,MAAM,EAAmB,MAAM;AAG1F,KAAI,iBAAiB,UAAW,QAAO,QAAQ,MAAM,SAAS,MAAM,QAAQ,MAAM;AAGlF,KAAI,MAAM,QAAQ,MAAM,EAAE;EACxB,IAAI,cAAc;AAClB,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,gBAAe,aAAa,MAAM,IAAI,MAAM;AAE9C,SAAO;;AAGT,QAAO,OAAO,MAAM;;;;;;;;;;;;;;ACnLtB,MAAa,OAAO,SAA+B,GAAG,WACpD,IAAI,UAAU,SAAS,OAAO;;;;;;;;;ACLhC,MAAM,aAAa,IAAI,IAAI;CAEzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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