@tenphi/tasty 0.0.0-snapshot.a8b4749 → 0.0.0-snapshot.a8da86e

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.
Files changed (125) hide show
  1. package/README.md +181 -136
  2. package/dist/babel-types-C_7kRP38.d.ts +18 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-Betc6IB6.js +60 -0
  6. package/dist/chunks/build-config-Betc6IB6.js.map +1 -0
  7. package/dist/{collector-C-keQH9m.js → chunks/collector-DqqisglQ.js} +68 -101
  8. package/dist/chunks/collector-DqqisglQ.js.map +1 -0
  9. package/dist/chunks/config-engine-BPeROwq2.js +272 -0
  10. package/dist/chunks/config-engine-BPeROwq2.js.map +1 -0
  11. package/dist/chunks/css-definitions-IeuyJTGk.js +899 -0
  12. package/dist/chunks/css-definitions-IeuyJTGk.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-P1E2jkj7.js +502 -0
  16. package/dist/chunks/debug-P1E2jkj7.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-XMBbGRes.js +582 -0
  22. package/dist/chunks/react-runtime-XMBbGRes.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CsIMtulO.js +2415 -0
  24. package/dist/chunks/runtime-engine-CsIMtulO.js.map +1 -0
  25. package/dist/chunks/runtime-state-CyKzDioI.js +141 -0
  26. package/dist/chunks/runtime-state-CyKzDioI.js.map +1 -0
  27. package/dist/{merge-styles-Cd2vBl9b.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-RbokDN6A.js +5427 -0
  30. package/dist/chunks/style-engine-RbokDN6A.js.map +1 -0
  31. package/dist/{css-writer-BWvwQzz0.js → chunks/zero-engine-DbtjMsfo.js} +81 -137
  32. package/dist/chunks/zero-engine-DbtjMsfo.js.map +1 -0
  33. package/dist/{collector-osfWTeRd.d.ts → collector-w4mBj5gd.d.ts} +64 -8
  34. package/dist/{config-BoZDUHW5.d.ts → config-CrZOfNJ5.d.ts} +489 -85
  35. package/dist/core/index.d.ts +5 -5
  36. package/dist/core/index.js +9 -6
  37. package/dist/{index-B_k47mc_.d.ts → index-CYJtAI9a.d.ts} +664 -399
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +11 -732
  40. package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-VXwJ0Frr.d.ts} +2 -3
  41. package/dist/ssr/astro-client.d.ts +1 -1
  42. package/dist/ssr/astro-client.js +1 -14
  43. package/dist/ssr/astro-client.js.map +1 -1
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  51. package/dist/ssr/astro-middleware-static.js +7 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +11 -8
  54. package/dist/ssr/astro-middleware.js +2 -14
  55. package/dist/ssr/astro-middleware.js.map +1 -1
  56. package/dist/ssr/astro.d.ts +40 -10
  57. package/dist/ssr/astro.js +163 -91
  58. package/dist/ssr/astro.js.map +1 -1
  59. package/dist/ssr/index.d.ts +10 -18
  60. package/dist/ssr/index.js +5 -5
  61. package/dist/ssr/index.js.map +1 -1
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +134 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +9 -9
  66. package/dist/ssr/next.js +29 -44
  67. package/dist/ssr/next.js.map +1 -1
  68. package/dist/static/index.d.ts +8 -9
  69. package/dist/static/index.js +4 -22
  70. package/dist/static/index.js.map +1 -1
  71. package/dist/static/inject.d.ts +1 -2
  72. package/dist/static/inject.js.map +1 -1
  73. package/dist/{index-tcHuMPFt.d.ts → types-JEY8PVYP.d.ts} +874 -593
  74. package/dist/zero/babel.d.ts +5 -19
  75. package/dist/zero/babel.js +74 -144
  76. package/dist/zero/babel.js.map +1 -1
  77. package/dist/zero/index.d.ts +57 -7
  78. package/dist/zero/index.js +24 -2
  79. package/dist/zero/index.js.map +1 -0
  80. package/dist/zero/next.d.ts +4 -5
  81. package/dist/zero/next.js +0 -31
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +17 -9
  84. package/docs/adoption.md +56 -31
  85. package/docs/ai-agents.md +250 -0
  86. package/docs/comparison.md +69 -40
  87. package/docs/configuration.md +487 -86
  88. package/docs/debug.md +26 -14
  89. package/docs/design-system.md +43 -24
  90. package/docs/dsl.md +558 -181
  91. package/docs/getting-started.md +64 -41
  92. package/docs/injector.md +120 -30
  93. package/docs/methodology.md +46 -40
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +87 -21
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +151 -42
  98. package/docs/runtime-benchmarks.md +388 -0
  99. package/docs/ssr.md +252 -86
  100. package/docs/styles.md +142 -25
  101. package/docs/tasty-static.md +174 -106
  102. package/package.json +127 -35
  103. package/tasty.config.ts +5 -0
  104. package/dist/async-storage-B7_o6FKt.js +0 -44
  105. package/dist/async-storage-B7_o6FKt.js.map +0 -1
  106. package/dist/collector-C-keQH9m.js.map +0 -1
  107. package/dist/config-BBiyxMCe.js +0 -10559
  108. package/dist/config-BBiyxMCe.js.map +0 -1
  109. package/dist/context-CkSg-kDT.js +0 -24
  110. package/dist/context-CkSg-kDT.js.map +0 -1
  111. package/dist/core-BO4319td.js +0 -1598
  112. package/dist/core-BO4319td.js.map +0 -1
  113. package/dist/css-writer-BWvwQzz0.js.map +0 -1
  114. package/dist/format-global-rules-Dbc_1tc3.js +0 -22
  115. package/dist/format-global-rules-Dbc_1tc3.js.map +0 -1
  116. package/dist/format-rules-BSjeH4Z7.js +0 -143
  117. package/dist/format-rules-BSjeH4Z7.js.map +0 -1
  118. package/dist/hydrate-CcvrP4qJ.js +0 -45
  119. package/dist/hydrate-CcvrP4qJ.js.map +0 -1
  120. package/dist/index.js.map +0 -1
  121. package/dist/keyframes-BUQhdOSJ.js +0 -588
  122. package/dist/keyframes-BUQhdOSJ.js.map +0 -1
  123. package/dist/merge-styles-Cd2vBl9b.js.map +0 -1
  124. package/dist/resolve-recipes-C1nrvnYh.js +0 -144
  125. package/dist/resolve-recipes-C1nrvnYh.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenphi/tasty",
3
- "version": "0.0.0-snapshot.a8b4749",
3
+ "version": "0.0.0-snapshot.a8da86e",
4
4
  "description": "A design-system-integrated styling system and DSL for concise, state-aware UI styling",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "import": "./dist/zero/index.js",
33
33
  "default": "./dist/zero/index.js"
34
34
  },
35
- "./next": {
35
+ "./zero/next": {
36
36
  "types": "./dist/zero/next.d.ts",
37
37
  "import": "./dist/zero/next.js",
38
38
  "default": "./dist/zero/next.js"
@@ -52,6 +52,11 @@
52
52
  "import": "./dist/ssr/next.js",
53
53
  "default": "./dist/ssr/next.js"
54
54
  },
55
+ "./ssr/next-config": {
56
+ "types": "./dist/ssr/next-config.d.ts",
57
+ "import": "./dist/ssr/next-config.js",
58
+ "default": "./dist/ssr/next-config.js"
59
+ },
55
60
  "./ssr/astro": {
56
61
  "types": "./dist/ssr/astro.d.ts",
57
62
  "import": "./dist/ssr/astro.js",
@@ -62,6 +67,26 @@
62
67
  "import": "./dist/ssr/astro-client.js",
63
68
  "default": "./dist/ssr/astro-client.js"
64
69
  },
70
+ "./ssr/astro-middleware": {
71
+ "types": "./dist/ssr/astro-middleware.d.ts",
72
+ "import": "./dist/ssr/astro-middleware.js",
73
+ "default": "./dist/ssr/astro-middleware.js"
74
+ },
75
+ "./ssr/astro-middleware-static": {
76
+ "types": "./dist/ssr/astro-middleware-static.d.ts",
77
+ "import": "./dist/ssr/astro-middleware-static.js",
78
+ "default": "./dist/ssr/astro-middleware-static.js"
79
+ },
80
+ "./ssr/astro-middleware-extract": {
81
+ "types": "./dist/ssr/astro-middleware-extract.d.ts",
82
+ "import": "./dist/ssr/astro-middleware-extract.js",
83
+ "default": "./dist/ssr/astro-middleware-extract.js"
84
+ },
85
+ "./ssr/astro-middleware-extract-static": {
86
+ "types": "./dist/ssr/astro-middleware-extract-static.d.ts",
87
+ "import": "./dist/ssr/astro-middleware-extract-static.js",
88
+ "default": "./dist/ssr/astro-middleware-extract-static.js"
89
+ },
65
90
  "./tasty.config": "./tasty.config.ts"
66
91
  },
67
92
  "files": [
@@ -73,7 +98,11 @@
73
98
  "./dist/ssr/index.js",
74
99
  "./dist/ssr/next.js",
75
100
  "./dist/ssr/astro.js",
76
- "./dist/ssr/astro-client.js"
101
+ "./dist/ssr/astro-client.js",
102
+ "./dist/ssr/astro-middleware.js",
103
+ "./dist/ssr/astro-middleware-static.js",
104
+ "./dist/ssr/astro-middleware-extract.js",
105
+ "./dist/ssr/astro-middleware-extract-static.js"
77
106
  ],
78
107
  "engines": {
79
108
  "node": ">=20"
@@ -81,6 +110,9 @@
81
110
  "scripts": {
82
111
  "build": "tsdown",
83
112
  "test": "vitest run",
113
+ "test:node": "vitest run --project node",
114
+ "test:browser": "vitest run --project browser",
115
+ "test:setup": "playwright install chromium",
84
116
  "test:watch": "vitest",
85
117
  "test:coverage": "vitest run --coverage",
86
118
  "typecheck": "tsc --noEmit",
@@ -89,11 +121,20 @@
89
121
  "format": "prettier --write \"src/**/*.{ts,tsx}\"",
90
122
  "format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
91
123
  "size": "size-limit",
92
- "bench": "vitest bench",
124
+ "bench": "vitest bench --project node",
125
+ "bench:browser": "vitest bench --project browser",
126
+ "bench:overhead": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-overhead.bench.tsx",
127
+ "bench:injection": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-injection.bench.ts",
128
+ "bench:interaction": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-interaction.bench.tsx",
129
+ "bench:cold-start": "node scripts/cold-start/index.mjs",
93
130
  "prepublishOnly": "pnpm run build",
94
131
  "changeset": "changeset",
95
132
  "version": "changeset version",
96
133
  "release": "changeset publish",
134
+ "knip": "knip",
135
+ "check:build": "node scripts/check-built-entries.mjs",
136
+ "check:react-compat": "node scripts/check-react-compat.mjs",
137
+ "check:test-only": "node scripts/check-test-only-code.mjs",
97
138
  "hygiene": "pnpm lint && pnpm format:check && pnpm typecheck",
98
139
  "hygiene:fix": "pnpm lint:fix && pnpm format && pnpm typecheck"
99
140
  },
@@ -123,6 +164,7 @@
123
164
  "@babel/helper-plugin-utils": "^7.24.0",
124
165
  "@babel/types": "^7.24.0",
125
166
  "jiti": "^2.6.1",
167
+ "next": ">=14.0.0",
126
168
  "react": "^18.0.0 || ^19.0.0"
127
169
  },
128
170
  "peerDependenciesMeta": {
@@ -140,61 +182,93 @@
140
182
  },
141
183
  "jiti": {
142
184
  "optional": true
185
+ },
186
+ "next": {
187
+ "optional": true
143
188
  }
144
189
  },
145
190
  "dependencies": {
146
191
  "csstype": "^3.1.0"
147
192
  },
148
193
  "devDependencies": {
149
- "@babel/core": "^7.24.0",
150
- "@changesets/changelog-github": "^0.7.0",
151
- "@changesets/cli": "^2.29.8",
194
+ "@astrojs/react": "^7.0.0",
195
+ "@babel/core": "^7.29.7",
196
+ "@babel/helper-plugin-utils": "^7.29.7",
197
+ "@babel/types": "^7.29.8",
198
+ "@changesets/changelog-github": "^1.0.1",
199
+ "@changesets/cli": "^3.0.3",
152
200
  "@eslint/js": "^10.0.1",
153
- "@size-limit/esbuild": "^12.0.0",
154
- "@size-limit/file": "^12.0.0",
155
- "@testing-library/jest-dom": "^6.9.1",
156
- "@testing-library/react": "^16.3.2",
201
+ "@size-limit/esbuild": "^14.0.0",
202
+ "@size-limit/file": "^14.0.0",
203
+ "@tenphi/eslint-plugin-tasty": "^1.1.0",
204
+ "@testing-library/jest-dom": "^7.0.1",
205
+ "@testing-library/react": "^16.3.3",
157
206
  "@types/babel__core": "^7.20.5",
158
207
  "@types/babel__helper-plugin-utils": "^7.10.3",
159
- "@types/node": "^25.3.2",
160
- "@types/react": "^19.0.0",
161
- "@vitest/runner": "^4.0.18",
162
- "eslint": "^10.0.0",
208
+ "@types/node": "^24.13.6",
209
+ "@types/react": "^19.3.0",
210
+ "@types/react-dom": "^19.3.0",
211
+ "@vitest/browser-playwright": "^4.1.11",
212
+ "astro": "^7.3.4",
213
+ "esbuild": "^0.28.2",
214
+ "eslint": "^10.11.0",
163
215
  "eslint-config-prettier": "^10.1.8",
164
- "happy-dom": "^20.9.0",
165
- "jsdom": "^29.0.2",
166
- "prettier": "^3.8.1",
167
- "react": "^19.0.0",
168
- "size-limit": "^12.0.0",
169
- "tsdown": "^0.22.0",
170
- "typescript": "^6.0.2",
171
- "typescript-eslint": "^8.56.0",
172
- "vitest": "^4.0.18"
173
- },
174
- "pnpm": {
175
- "onlyBuiltDependencies": [
176
- "esbuild"
177
- ]
216
+ "jiti": "^2.7.0",
217
+ "knip": "^6.38.0",
218
+ "next": "^16.3.6",
219
+ "playwright": "^1.63.0",
220
+ "prettier": "^3.9.9",
221
+ "react": "^19.3.0",
222
+ "react-dom": "^19.3.0",
223
+ "size-limit": "^14.0.0",
224
+ "tsdown": "^0.23.0",
225
+ "typescript": "^6.0.3",
226
+ "typescript-eslint": "^8.70.1",
227
+ "vitest": "^4.1.11"
178
228
  },
179
- "packageManager": "pnpm@11.0.8",
229
+ "packageManager": "pnpm@11.27.1",
180
230
  "size-limit": [
181
231
  {
182
232
  "name": "main (import *)",
183
233
  "path": "dist/index.js",
184
234
  "import": "*",
185
- "limit": "52 kB"
235
+ "limit": "58.54 kB"
236
+ },
237
+ {
238
+ "name": "main (tasty)",
239
+ "path": "dist/index.js",
240
+ "import": "{ tasty }",
241
+ "limit": "51.51 kB"
242
+ },
243
+ {
244
+ "name": "main (StyleParser)",
245
+ "path": "dist/index.js",
246
+ "import": "{ StyleParser }",
247
+ "limit": "6.94 kB"
248
+ },
249
+ {
250
+ "name": "main (parseColor)",
251
+ "path": "dist/index.js",
252
+ "import": "{ parseColor }",
253
+ "limit": "7.59 kB"
254
+ },
255
+ {
256
+ "name": "main (useRawCSS)",
257
+ "path": "dist/index.js",
258
+ "import": "{ useRawCSS }",
259
+ "limit": "31.2 kB"
186
260
  },
187
261
  {
188
262
  "name": "core (import *)",
189
263
  "path": "dist/core/index.js",
190
264
  "import": "*",
191
- "limit": "49.5 kB"
265
+ "limit": "55.23 kB"
192
266
  },
193
267
  {
194
268
  "name": "static",
195
269
  "path": "dist/static/index.js",
196
270
  "import": "*",
197
- "limit": "17 kB"
271
+ "limit": "1.08 kB"
198
272
  },
199
273
  {
200
274
  "name": "zero",
@@ -205,7 +279,7 @@
205
279
  "path",
206
280
  "crypto"
207
281
  ],
208
- "limit": "31 kB"
282
+ "limit": "37.98 kB"
209
283
  },
210
284
  {
211
285
  "name": "babel-plugin",
@@ -216,7 +290,25 @@
216
290
  "path",
217
291
  "crypto"
218
292
  ],
219
- "limit": "45.65 kB"
293
+ "limit": "42.44 kB"
294
+ },
295
+ {
296
+ "name": "astro client",
297
+ "path": "dist/ssr/astro-client.js",
298
+ "import": "*",
299
+ "limit": "0.5 kB"
300
+ },
301
+ {
302
+ "name": "Next.js config",
303
+ "path": "dist/ssr/next-config.js",
304
+ "import": "{ withTastyNext }",
305
+ "ignore": [
306
+ "node:crypto",
307
+ "node:fs",
308
+ "node:module",
309
+ "node:path"
310
+ ],
311
+ "limit": "39.13 kB"
220
312
  }
221
313
  ]
222
314
  }
package/tasty.config.ts CHANGED
@@ -12,4 +12,9 @@ export default {
12
12
  '$sharp-radius',
13
13
  '$bold-font-weight',
14
14
  ],
15
+ styles: ['viewTransitionName'],
16
+ // This repo imports its own API relatively, so the plugin's default
17
+ // `@tenphi/tasty` import tracking never matches. List the local entry points so
18
+ // `tasty({ styles })` call sites are actually linted.
19
+ importSources: ['@tenphi/tasty', './tasty', '../tasty', './src/tasty'],
15
20
  };
@@ -1,44 +0,0 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- //#region src/ssr/async-storage.ts
3
- /**
4
- * AsyncLocalStorage integration for SSR collector discovery.
5
- *
6
- * Used by Astro middleware and generic framework integrations where
7
- * the library cannot wrap the React tree with a context provider.
8
- * The middleware calls runWithCollector() around the render, and
9
- * useStyles() calls getSSRCollector() to find it.
10
- *
11
- * Uses globalThis to ensure the AsyncLocalStorage instance is shared
12
- * across module instances — frameworks like Astro may load middleware
13
- * and page components from separate module graphs.
14
- *
15
- * This module imports from 'node:async_hooks' — it must be excluded
16
- * from client bundles via the build configuration.
17
- */
18
- const ALS_KEY = "__tasty_ssr_als__";
19
- function getSharedStorage() {
20
- const g = globalThis;
21
- if (!g[ALS_KEY]) g[ALS_KEY] = new AsyncLocalStorage();
22
- return g[ALS_KEY];
23
- }
24
- /**
25
- * Run a function with a ServerStyleCollector bound to the current
26
- * async context. All useStyles() calls within `fn` (and any async
27
- * continuations) will find this collector via getSSRCollector().
28
- */
29
- function runWithCollector(collector, fn) {
30
- return getSharedStorage().run(collector, fn);
31
- }
32
- /**
33
- * Retrieve the ServerStyleCollector bound to the current async context.
34
- * Returns null when called outside of runWithCollector() or on the client.
35
- */
36
- function getSSRCollector() {
37
- const storage = getSharedStorage();
38
- if (typeof storage?.getStore !== "function") return null;
39
- return storage.getStore() ?? null;
40
- }
41
- //#endregion
42
- export { runWithCollector as n, getSSRCollector as t };
43
-
44
- //# sourceMappingURL=async-storage-B7_o6FKt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-storage-B7_o6FKt.js","names":[],"sources":["../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,UACL,EAAE,WAAW,IAAI,mBAAyC;CAE5D,OAAO,EAAE;;;;;;;AAQX,SAAgB,iBACd,WACA,IACG;CACH,OAAO,kBAAkB,CAAC,IAAI,WAAW,GAAG;;;;;;AAO9C,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,kBAAkB;CAClC,IAAI,OAAO,SAAS,aAAa,YAAY,OAAO;CACpD,OAAO,QAAQ,UAAU,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"collector-C-keQH9m.js","names":[],"sources":["../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = this.generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,+BAAuB,IAAI,KAAqB;CAChD,oCAA4B,IAAI,KAAa;CAC7C,yBAAiB,IAAI,KAAqB;CAC1C,iCAAyB,IAAI,KAAa;CAC1C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,oCAA4B,IAAI,KAAqB;CACrD,0CAAkC,IAAI,KAAa;C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