@pyreon/styler 0.12.6 → 0.12.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/styler",
3
- "version": "0.12.6",
3
+ "version": "0.12.8",
4
4
  "description": "Lightweight CSS-in-JS engine for Pyreon",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,12 +40,12 @@
40
40
  "typecheck": "tsc --noEmit"
41
41
  },
42
42
  "devDependencies": {
43
- "@pyreon/typescript": "^0.12.6",
43
+ "@pyreon/typescript": "^0.12.8",
44
44
  "@vitus-labs/tools-rolldown": "^1.15.3"
45
45
  },
46
46
  "peerDependencies": {
47
- "@pyreon/core": "^0.12.6",
48
- "@pyreon/reactivity": "^0.12.6"
47
+ "@pyreon/core": "^0.12.8",
48
+ "@pyreon/reactivity": "^0.12.8"
49
49
  },
50
50
  "engines": {
51
51
  "node": ">= 22"
@@ -0,0 +1,58 @@
1
+ import type { VNode } from '@pyreon/core'
2
+ import { afterEach, describe, expect, it } from 'vitest'
3
+ import { sheet } from '../sheet'
4
+ import { styled } from '../styled'
5
+
6
+ // ─── Integration tests ───────────────────────────────────────────────────────
7
+
8
+ describe('Styler integration — styled + sheet', () => {
9
+ afterEach(() => {
10
+ sheet.reset()
11
+ })
12
+
13
+ it('styled("div") with CSS applies a pyr- class to element', () => {
14
+ const Box = styled('div')`
15
+ color: red;
16
+ display: flex;
17
+ `
18
+ const vnode = Box({}) as VNode
19
+ expect(vnode.type).toBe('div')
20
+ expect(vnode.props.class).toMatch(/^pyr-[0-9a-z]+$/)
21
+ })
22
+
23
+ it('dynamic styled with props-based interpolation produces different classes', () => {
24
+ const Box = styled('div')`
25
+ color: ${((props: Record<string, unknown>) => (props.color as string) || 'black') as any};
26
+ `
27
+ const vnode1 = Box({ color: 'red' }) as VNode
28
+ const vnode2 = Box({ color: 'blue' }) as VNode
29
+ // Dynamic interpolations produce different CSS, different hashes
30
+ expect(vnode1.props.class).toMatch(/^pyr-/)
31
+ expect(vnode2.props.class).toMatch(/^pyr-/)
32
+ expect(vnode1.props.class).not.toBe(vnode2.props.class)
33
+ })
34
+
35
+ it('multiple styled components get different classes from same sheet', () => {
36
+ const Red = styled('span')`
37
+ color: red;
38
+ `
39
+ const Blue = styled('span')`
40
+ color: blue;
41
+ `
42
+ const vnodeRed = Red({}) as VNode
43
+ const vnodeBlue = Blue({}) as VNode
44
+ expect(vnodeRed.props.class).toMatch(/^pyr-/)
45
+ expect(vnodeBlue.props.class).toMatch(/^pyr-/)
46
+ expect(vnodeRed.props.class).not.toBe(vnodeBlue.props.class)
47
+ })
48
+
49
+ it('@layer declarations exist in stylesheet (rocketstyle layer)', () => {
50
+ // The sheet mounts on construction and injects @layer base, rocketstyle;
51
+ // Verify the sheet has been mounted and can insert rules
52
+ const className = sheet.insert('display: grid;')
53
+ expect(className).toMatch(/^pyr-/)
54
+ // Same CSS returns same class (dedup works)
55
+ const className2 = sheet.insert('display: grid;')
56
+ expect(className2).toBe(className)
57
+ })
58
+ })