@tenphi/tasty 0.0.0-snapshot.cca2ea6 → 0.0.0-snapshot.cd6580c
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/dist/astro-r3wQ-RQn.js +307 -0
- package/dist/astro-r3wQ-RQn.js.map +1 -0
- package/dist/{babel-CHy3n_M7.d.ts → babel-Bu_bhevw.d.ts} +2 -2
- package/dist/{collector-0YO-P1vW.d.ts → collector-BTVXj2hS.d.ts} +20 -2
- package/dist/{collector-Eve9-4dP.js → collector-CudWaexa.js} +36 -13
- package/dist/collector-CudWaexa.js.map +1 -0
- package/dist/{config-Bwerr9rW.js → config-CHz_SFr_.js} +32 -24
- package/dist/config-CHz_SFr_.js.map +1 -0
- package/dist/{config-DRp9aYRG.d.ts → config-ClpSyptP.d.ts} +29 -11
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +6 -6
- package/dist/{core-C9nPCkW6.js → core-COC2UQ48.js} +150 -67
- package/dist/core-COC2UQ48.js.map +1 -0
- package/dist/{css-writer-7SOcy4BM.js → css-writer-Dji9t0wk.js} +3 -3
- package/dist/{css-writer-7SOcy4BM.js.map → css-writer-Dji9t0wk.js.map} +1 -1
- package/dist/{format-rules-Cb8LAho6.js → format-rules-U9Od0aqv.js} +2 -2
- package/dist/{format-rules-Cb8LAho6.js.map → format-rules-U9Od0aqv.js.map} +1 -1
- package/dist/{hydrate-DfL38fk5.js → hydrate-DA-ttBga.js} +2 -2
- package/dist/{hydrate-DfL38fk5.js.map → hydrate-DA-ttBga.js.map} +1 -1
- package/dist/{index-B1A0pcCf.d.ts → index-CV_fhEm0.d.ts} +18 -11
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/{keyframes-CygCEfJG.js → keyframes-KkxDZ9xu.js} +45 -3
- package/dist/keyframes-KkxDZ9xu.js.map +1 -0
- package/dist/{merge-styles-Bh_wsNk_.js → merge-styles-BGM4RJWC.js} +2 -2
- package/dist/{merge-styles-Bh_wsNk_.js.map → merge-styles-BGM4RJWC.js.map} +1 -1
- package/dist/{resolve-recipes-Da6piP7f.js → resolve-recipes-DbeVYQFr.js} +3 -3
- package/dist/{resolve-recipes-Da6piP7f.js.map → resolve-recipes-DbeVYQFr.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +11 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +3 -1
- package/dist/ssr/astro-middleware-static.js +1 -1
- package/dist/ssr/astro-middleware.d.ts +3 -1
- package/dist/ssr/astro-middleware.js +1 -1
- package/dist/ssr/astro.d.ts +37 -3
- package/dist/ssr/astro.js +1 -156
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/index.js +3 -3
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +4 -4
- package/dist/static/index.js +1 -1
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/index.js +1 -1
- package/dist/zero/next.d.ts +1 -1
- package/docs/ssr.md +48 -9
- package/package.json +18 -4
- package/dist/collector-Eve9-4dP.js.map +0 -1
- package/dist/config-Bwerr9rW.js.map +0 -1
- package/dist/core-C9nPCkW6.js.map +0 -1
- package/dist/keyframes-CygCEfJG.js.map +0 -1
- package/dist/ssr/astro.js.map +0 -1
package/dist/ssr/astro.d.ts
CHANGED
|
@@ -43,7 +43,13 @@ interface TastyMiddlewareOptions {
|
|
|
43
43
|
* );
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
declare function tastyMiddleware(options?: TastyMiddlewareOptions): (
|
|
46
|
+
declare function tastyMiddleware(options?: TastyMiddlewareOptions): (context: {
|
|
47
|
+
isPrerendered?: boolean;
|
|
48
|
+
}, next: () => Promise<Response>) => Promise<Response>;
|
|
49
|
+
interface TastyIntegrationCSSOptions {
|
|
50
|
+
/** CSS delivery mode. Extraction only applies to prerendered builds. */
|
|
51
|
+
mode?: 'inline' | 'extract';
|
|
52
|
+
}
|
|
47
53
|
interface TastyIntegrationOptions {
|
|
48
54
|
/**
|
|
49
55
|
* Enable island hydration support.
|
|
@@ -57,6 +63,8 @@ interface TastyIntegrationOptions {
|
|
|
57
63
|
* directives.
|
|
58
64
|
*/
|
|
59
65
|
islands?: boolean;
|
|
66
|
+
/** Configure inline or build-wide extracted CSS delivery. */
|
|
67
|
+
css?: TastyIntegrationCSSOptions;
|
|
60
68
|
}
|
|
61
69
|
/**
|
|
62
70
|
* Astro integration that automatically sets up Tasty SSR.
|
|
@@ -86,8 +94,34 @@ interface TastyIntegrationOptions {
|
|
|
86
94
|
*/
|
|
87
95
|
declare function tastyIntegration(options?: TastyIntegrationOptions): {
|
|
88
96
|
name: string;
|
|
89
|
-
hooks:
|
|
97
|
+
hooks: {
|
|
98
|
+
'astro:config:setup': ({
|
|
99
|
+
addMiddleware,
|
|
100
|
+
injectScript
|
|
101
|
+
}: {
|
|
102
|
+
addMiddleware: (middleware: {
|
|
103
|
+
entrypoint: string | URL;
|
|
104
|
+
order: "pre" | "post";
|
|
105
|
+
}) => void;
|
|
106
|
+
injectScript: (stage: "head-inline" | "before-hydration" | "page" | "page-ssr", content: string) => void;
|
|
107
|
+
}) => void;
|
|
108
|
+
'astro:config:done': ({
|
|
109
|
+
config
|
|
110
|
+
}: {
|
|
111
|
+
config: {
|
|
112
|
+
base?: string;
|
|
113
|
+
build?: {
|
|
114
|
+
assets?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}) => void;
|
|
118
|
+
'astro:build:done': ({
|
|
119
|
+
dir
|
|
120
|
+
}: {
|
|
121
|
+
dir: URL;
|
|
122
|
+
}) => Promise<void>;
|
|
123
|
+
};
|
|
90
124
|
};
|
|
91
125
|
//#endregion
|
|
92
|
-
export { TastyIntegrationOptions, TastyMiddlewareOptions, tastyIntegration, tastyMiddleware };
|
|
126
|
+
export { TastyIntegrationCSSOptions, TastyIntegrationOptions, TastyMiddlewareOptions, tastyIntegration, tastyMiddleware };
|
|
93
127
|
//# sourceMappingURL=astro.d.ts.map
|
package/dist/ssr/astro.js
CHANGED
|
@@ -1,157 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { a as registerSSRCollectorGetterGlobal } from "../format-rules-Cb8LAho6.js";
|
|
3
|
-
import { t as ServerStyleCollector } from "../collector-Eve9-4dP.js";
|
|
4
|
-
import { n as runWithCollector, t as getSSRCollector } from "../async-storage-DKK-wTD4.js";
|
|
5
|
-
//#region src/ssr/astro.ts
|
|
6
|
-
/**
|
|
7
|
-
* Astro integration for Tasty SSR.
|
|
8
|
-
*
|
|
9
|
-
* Provides:
|
|
10
|
-
* - tastyIntegration() — Astro Integration API (recommended)
|
|
11
|
-
* - tastyMiddleware() — manual middleware for advanced composition
|
|
12
|
-
*
|
|
13
|
-
* Import from '@tenphi/tasty/ssr/astro'.
|
|
14
|
-
*/
|
|
15
|
-
registerSSRCollectorGetterGlobal(getSSRCollector);
|
|
16
|
-
/**
|
|
17
|
-
* Create an Astro middleware that collects Tasty styles during SSR.
|
|
18
|
-
*
|
|
19
|
-
* All React components rendered during the request will have their
|
|
20
|
-
* computeStyles() calls captured by the collector via AsyncLocalStorage.
|
|
21
|
-
* After rendering, the middleware injects the collected CSS into </head>.
|
|
22
|
-
*
|
|
23
|
-
* @example Manual middleware setup
|
|
24
|
-
* ```ts
|
|
25
|
-
* // src/middleware.ts
|
|
26
|
-
* import { tastyMiddleware } from '@tenphi/tasty/ssr/astro';
|
|
27
|
-
* export const onRequest = tastyMiddleware();
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @example Composing with other middleware
|
|
31
|
-
* ```ts
|
|
32
|
-
* // src/middleware.ts
|
|
33
|
-
* import { sequence } from 'astro:middleware';
|
|
34
|
-
* import { tastyMiddleware } from '@tenphi/tasty/ssr/astro';
|
|
35
|
-
*
|
|
36
|
-
* export const onRequest = sequence(
|
|
37
|
-
* tastyMiddleware(),
|
|
38
|
-
* myOtherMiddleware,
|
|
39
|
-
* );
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
function tastyMiddleware(options) {
|
|
43
|
-
return async (_context, next) => {
|
|
44
|
-
const transferCache = options?.transferCache ?? true;
|
|
45
|
-
const collector = new ServerStyleCollector();
|
|
46
|
-
const rendered = await runWithCollector(collector, async () => {
|
|
47
|
-
const response = await next();
|
|
48
|
-
const body = response.body;
|
|
49
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
50
|
-
if (!body || !contentType.includes("text/html")) return { response };
|
|
51
|
-
const reader = body.pipeThrough(new TextDecoderStream()).getReader();
|
|
52
|
-
const parts = [];
|
|
53
|
-
for (;;) {
|
|
54
|
-
const { done, value } = await reader.read();
|
|
55
|
-
if (done) break;
|
|
56
|
-
parts.push(value);
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
html: parts.join(""),
|
|
60
|
-
status: response.status,
|
|
61
|
-
headers: response.headers
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
if ("response" in rendered) return rendered.response;
|
|
65
|
-
if (!rendered.html) return new Response(null, {
|
|
66
|
-
status: rendered.status,
|
|
67
|
-
headers: rendered.headers
|
|
68
|
-
});
|
|
69
|
-
let { html } = rendered;
|
|
70
|
-
const css = collector.getCSS();
|
|
71
|
-
if (!css) return new Response(html, {
|
|
72
|
-
status: rendered.status,
|
|
73
|
-
headers: rendered.headers
|
|
74
|
-
});
|
|
75
|
-
const nonce = getConfig().nonce;
|
|
76
|
-
const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
|
|
77
|
-
const styleTag = `<style data-tasty-ssr${nonceAttr}>${css}</style>`;
|
|
78
|
-
let cacheTag = "";
|
|
79
|
-
if (transferCache) {
|
|
80
|
-
const classNames = collector.getRenderedClassNames();
|
|
81
|
-
if (classNames.length > 0) cacheTag = `<script${nonceAttr}>(window.__TASTY__=window.__TASTY__||[]).push(${classNames.map((n) => `"${n}"`).join(",")})<\/script>`;
|
|
82
|
-
}
|
|
83
|
-
const injection = styleTag + cacheTag;
|
|
84
|
-
const idx = html.indexOf("</head>");
|
|
85
|
-
if (idx !== -1) html = html.slice(0, idx) + injection + html.slice(idx);
|
|
86
|
-
else html = injection + html;
|
|
87
|
-
const headers = new Headers(rendered.headers);
|
|
88
|
-
headers.delete("content-length");
|
|
89
|
-
return new Response(html, {
|
|
90
|
-
status: rendered.status,
|
|
91
|
-
headers
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Package subpaths of the middleware entrypoints registered by
|
|
97
|
-
* `tastyIntegration()`.
|
|
98
|
-
*
|
|
99
|
-
* These must be bare specifiers rather than
|
|
100
|
-
* `new URL('./astro-middleware.js', import.meta.url)`. The bundler is free to
|
|
101
|
-
* hoist `tastyIntegration` into a shared chunk at a different directory depth
|
|
102
|
-
* than `dist/ssr/`, which makes a relative URL resolve to a file that does not
|
|
103
|
-
* exist and breaks the build for every consumer. A package subpath is resolved
|
|
104
|
-
* by the consumer through our `exports` map, so it never depends on the
|
|
105
|
-
* chunk layout.
|
|
106
|
-
*
|
|
107
|
-
* There are two entrypoints instead of one parameterised entrypoint because
|
|
108
|
-
* `addMiddleware()` cannot pass options: the integration runs when the Astro
|
|
109
|
-
* config is loaded, while the middleware module is evaluated in the server
|
|
110
|
-
* runtime — a different process for built output — so module-level state set
|
|
111
|
-
* by the integration is not visible to the middleware.
|
|
112
|
-
*/
|
|
113
|
-
const MIDDLEWARE_ENTRYPOINT = "@tenphi/tasty/ssr/astro-middleware";
|
|
114
|
-
const MIDDLEWARE_ENTRYPOINT_STATIC = "@tenphi/tasty/ssr/astro-middleware-static";
|
|
115
|
-
/**
|
|
116
|
-
* Astro integration that automatically sets up Tasty SSR.
|
|
117
|
-
*
|
|
118
|
-
* Registers middleware for cross-component CSS deduplication and
|
|
119
|
-
* optionally injects a client hydration script for island support.
|
|
120
|
-
*
|
|
121
|
-
* @example Basic setup (with islands)
|
|
122
|
-
* ```ts
|
|
123
|
-
* // astro.config.mjs
|
|
124
|
-
* import { tastyIntegration } from '@tenphi/tasty/ssr/astro';
|
|
125
|
-
*
|
|
126
|
-
* export default defineConfig({
|
|
127
|
-
* integrations: [tastyIntegration()],
|
|
128
|
-
* });
|
|
129
|
-
* ```
|
|
130
|
-
*
|
|
131
|
-
* @example Static-only (no client JS)
|
|
132
|
-
* ```ts
|
|
133
|
-
* // astro.config.mjs
|
|
134
|
-
* import { tastyIntegration } from '@tenphi/tasty/ssr/astro';
|
|
135
|
-
*
|
|
136
|
-
* export default defineConfig({
|
|
137
|
-
* integrations: [tastyIntegration({ islands: false })],
|
|
138
|
-
* });
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
function tastyIntegration(options) {
|
|
142
|
-
const { islands = true } = options ?? {};
|
|
143
|
-
return {
|
|
144
|
-
name: "@tenphi/tasty",
|
|
145
|
-
hooks: { "astro:config:setup": ({ addMiddleware, injectScript }) => {
|
|
146
|
-
addMiddleware({
|
|
147
|
-
entrypoint: islands ? MIDDLEWARE_ENTRYPOINT : MIDDLEWARE_ENTRYPOINT_STATIC,
|
|
148
|
-
order: "pre"
|
|
149
|
-
});
|
|
150
|
-
if (islands) injectScript("before-hydration", `import "@tenphi/tasty/ssr/astro-client";`);
|
|
151
|
-
} }
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
//#endregion
|
|
1
|
+
import { n as tastyMiddleware, t as tastyIntegration } from "../astro-r3wQ-RQn.js";
|
|
155
2
|
export { tastyIntegration, tastyMiddleware };
|
|
156
|
-
|
|
157
|
-
//# sourceMappingURL=astro.js.map
|
package/dist/ssr/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as createServerStyleCollector, n as ServerStyleArtifactKind, r as ServerStyleCollector, t as ServerStyleArtifact } from "../collector-BTVXj2hS.js";
|
|
2
2
|
|
|
3
3
|
//#region src/ssr/async-storage.d.ts
|
|
4
4
|
/**
|
|
@@ -33,5 +33,5 @@ declare function getSSRCollector(): ServerStyleCollector | null;
|
|
|
33
33
|
*/
|
|
34
34
|
declare function hydrateTastyClasses(classes?: string[]): void;
|
|
35
35
|
//#endregion
|
|
36
|
-
export { ServerStyleCollector, createServerStyleCollector, getSSRCollector, hydrateTastyClasses, runWithCollector };
|
|
36
|
+
export { type ServerStyleArtifact, type ServerStyleArtifactKind, ServerStyleCollector, createServerStyleCollector, getSSRCollector, hydrateTastyClasses, runWithCollector };
|
|
37
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ssr/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as registerSSRCollectorGetterGlobal } from "../format-rules-
|
|
2
|
-
import { n as createServerStyleCollector, t as ServerStyleCollector } from "../collector-
|
|
1
|
+
import { a as registerSSRCollectorGetterGlobal } from "../format-rules-U9Od0aqv.js";
|
|
2
|
+
import { n as createServerStyleCollector, t as ServerStyleCollector } from "../collector-CudWaexa.js";
|
|
3
3
|
import { n as runWithCollector, t as getSSRCollector } from "../async-storage-DKK-wTD4.js";
|
|
4
|
-
import { t as hydrateTastyClasses } from "../hydrate-
|
|
4
|
+
import { t as hydrateTastyClasses } from "../hydrate-DA-ttBga.js";
|
|
5
5
|
//#region src/ssr/index.ts
|
|
6
6
|
registerSSRCollectorGetterGlobal(getSSRCollector);
|
|
7
7
|
//#endregion
|
package/dist/ssr/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/ssr/index.ts"],"sourcesContent":["/**\n * SSR entry point for @tenphi/tasty.\n *\n * Provides the core SSR infrastructure: ServerStyleCollector,\n * AsyncLocalStorage integration, and cache hydration.\n *\n * Import from '@tenphi/tasty/ssr'.\n */\n\n// Core collector\nexport { ServerStyleCollector, createServerStyleCollector } from './collector';\n\n// AsyncLocalStorage integration for Astro / generic frameworks\nexport { runWithCollector, getSSRCollector } from './async-storage';\n\n// Client-side cache hydration\nexport { hydrateTastyClasses } from './hydrate';\n\n// Register the ALS getter so hooks can find the collector\n// without importing 'node:async_hooks' in the browser bundle.\n// Uses globalThis so the getter is visible across separate module graphs.\nimport { getSSRCollector } from './async-storage';\nimport { registerSSRCollectorGetterGlobal } from './ssr-collector-ref';\n\nregisterSSRCollectorGetterGlobal(getSSRCollector);\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/ssr/index.ts"],"sourcesContent":["/**\n * SSR entry point for @tenphi/tasty.\n *\n * Provides the core SSR infrastructure: ServerStyleCollector,\n * AsyncLocalStorage integration, and cache hydration.\n *\n * Import from '@tenphi/tasty/ssr'.\n */\n\n// Core collector\nexport { ServerStyleCollector, createServerStyleCollector } from './collector';\nexport type { ServerStyleArtifact, ServerStyleArtifactKind } from './collector';\n\n// AsyncLocalStorage integration for Astro / generic frameworks\nexport { runWithCollector, getSSRCollector } from './async-storage';\n\n// Client-side cache hydration\nexport { hydrateTastyClasses } from './hydrate';\n\n// Register the ALS getter so hooks can find the collector\n// without importing 'node:async_hooks' in the browser bundle.\n// Uses globalThis so the getter is visible across separate module graphs.\nimport { getSSRCollector } from './async-storage';\nimport { registerSSRCollectorGetterGlobal } from './ssr-collector-ref';\n\nregisterSSRCollectorGetterGlobal(getSSRCollector);\n"],"mappings":";;;;;AAyBA,iCAAiC,eAAe"}
|
package/dist/ssr/next.d.ts
CHANGED
package/dist/ssr/next.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { n as getConfig } from "../config-
|
|
3
|
-
import { i as registerSSRCollectorGetter } from "../format-rules-
|
|
2
|
+
import { n as getConfig } from "../config-CHz_SFr_.js";
|
|
3
|
+
import { i as registerSSRCollectorGetter } from "../format-rules-U9Od0aqv.js";
|
|
4
4
|
import { t as getTastySSRContext } from "../context-CA8YKeMn.js";
|
|
5
|
-
import { t as ServerStyleCollector } from "../collector-
|
|
6
|
-
import { t as hydrateTastyClasses } from "../hydrate-
|
|
5
|
+
import { t as ServerStyleCollector } from "../collector-CudWaexa.js";
|
|
6
|
+
import { t as hydrateTastyClasses } from "../hydrate-DA-ttBga.js";
|
|
7
7
|
import { Fragment, createElement, useState } from "react";
|
|
8
8
|
import { useServerInsertedHTML } from "next/navigation";
|
|
9
9
|
//#region src/ssr/next.ts
|
package/dist/static/index.js
CHANGED
package/dist/zero/babel.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as _default, r as TastyZeroConfig, t as TastyZeroBabelOptions } from "../babel-
|
|
1
|
+
import { n as _default, r as TastyZeroConfig, t as TastyZeroBabelOptions } from "../babel-Bu_bhevw.js";
|
|
2
2
|
export { TastyZeroBabelOptions, type TastyZeroConfig, _default as default };
|
package/dist/zero/babel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as resetConfig, d as getGlobalStyles, i as getGlobalConfigTokens, s as getGlobalFunctions, t as configure } from "../config-
|
|
2
|
-
import { t as mergeStyles } from "../merge-styles-
|
|
3
|
-
import { t as resolveRecipes } from "../resolve-recipes-
|
|
4
|
-
import { a as extractFunctionsFromStyles, c as extractStylesForSelector, i as extractFontFaceFromStyles, l as extractStylesWithChunks, o as extractKeyframesFromStyles, r as extractCounterStyleFromStyles, s as extractPropertiesFromStyles, t as CSSWriter, u as setExtractorNamePrefix } from "../css-writer-
|
|
1
|
+
import { b as resetConfig, d as getGlobalStyles, i as getGlobalConfigTokens, s as getGlobalFunctions, t as configure } from "../config-CHz_SFr_.js";
|
|
2
|
+
import { t as mergeStyles } from "../merge-styles-BGM4RJWC.js";
|
|
3
|
+
import { t as resolveRecipes } from "../resolve-recipes-DbeVYQFr.js";
|
|
4
|
+
import { a as extractFunctionsFromStyles, c as extractStylesForSelector, i as extractFontFaceFromStyles, l as extractStylesWithChunks, o as extractKeyframesFromStyles, r as extractCounterStyleFromStyles, s as extractPropertiesFromStyles, t as CSSWriter, u as setExtractorNamePrefix } from "../css-writer-Dji9t0wk.js";
|
|
5
5
|
import * as fs from "fs";
|
|
6
6
|
import * as path from "path";
|
|
7
7
|
import { declare } from "@babel/helper-plugin-utils";
|
package/dist/zero/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as extractStylesForSelector, l as extractStylesWithChunks, n as createCSSWriter, t as CSSWriter } from "../css-writer-
|
|
1
|
+
import { c as extractStylesForSelector, l as extractStylesWithChunks, n as createCSSWriter, t as CSSWriter } from "../css-writer-Dji9t0wk.js";
|
|
2
2
|
export { CSSWriter, createCSSWriter, extractStylesForSelector, extractStylesWithChunks };
|
package/dist/zero/next.d.ts
CHANGED
package/docs/ssr.md
CHANGED
|
@@ -128,13 +128,15 @@ The nonce is automatically applied to all `<style>` and `<script>` tags injected
|
|
|
128
128
|
|
|
129
129
|
## Astro
|
|
130
130
|
|
|
131
|
-
Tasty offers
|
|
131
|
+
Tasty offers several levels of Astro integration. Choose the one that matches your needs:
|
|
132
132
|
|
|
133
|
-
| Setup
|
|
134
|
-
|
|
|
135
|
-
| Zero setup
|
|
136
|
-
| `tastyIntegration({ islands: false })`
|
|
137
|
-
| `tastyIntegration()`
|
|
133
|
+
| Setup | Config needed | Deduplication | Hooks work | Client JS |
|
|
134
|
+
| --------------------------------------------------------- | ------------- | ----------------------------- | ---------------------- | -------------- |
|
|
135
|
+
| Zero setup | None | Per render tree | Yes (within each tree) | None |
|
|
136
|
+
| `tastyIntegration({ islands: false })` | One line | Cross-tree | Yes | None |
|
|
137
|
+
| `tastyIntegration()` | One line | Cross-tree | Yes | Auto-hydration |
|
|
138
|
+
| `tastyIntegration({ css: { mode: 'extract' } })` | One line | Cross-tree and cross-page | Yes | Auto-hydration |
|
|
139
|
+
| `tastyIntegration({ islands: false, css: { mode: 'extract' } })` | One line | Cross-tree and cross-page | Yes | None |
|
|
138
140
|
|
|
139
141
|
### Zero setup (static pages)
|
|
140
142
|
|
|
@@ -231,6 +233,39 @@ export default defineConfig({
|
|
|
231
233
|
|
|
232
234
|
This gives the same middleware deduplication and hook support, but ships zero client-side JavaScript. No class-list `<script>` is emitted.
|
|
233
235
|
|
|
236
|
+
#### Build-wide CSS extraction
|
|
237
|
+
|
|
238
|
+
Static Astro builds can move repeated Tasty CSS into a content-hashed,
|
|
239
|
+
browser-cacheable asset:
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
export default defineConfig({
|
|
243
|
+
integrations: [
|
|
244
|
+
react(),
|
|
245
|
+
tastyIntegration({
|
|
246
|
+
islands: false,
|
|
247
|
+
css: {
|
|
248
|
+
mode: 'extract',
|
|
249
|
+
},
|
|
250
|
+
}),
|
|
251
|
+
],
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
`css.mode` defaults to `'inline'`, so existing projects keep their current
|
|
256
|
+
output. Extraction requires Astro 5 or newer and only applies to prerendered
|
|
257
|
+
production pages. Development, preview-time SSR, and on-demand routes continue
|
|
258
|
+
to receive the normal inline `<style data-tasty-ssr>` output.
|
|
259
|
+
|
|
260
|
+
Extraction moves the largest common block whose position can be preserved on
|
|
261
|
+
every generated page into one stylesheet. Page-only component, global, and raw
|
|
262
|
+
CSS stays inline, so unvisited routes do not receive unrelated styles.
|
|
263
|
+
|
|
264
|
+
The asset is written under Astro's configured `build.assets` directory (for
|
|
265
|
+
example, `/_astro/tasty.a1b2c3.css`). Links include the configured Astro
|
|
266
|
+
`base`, so nested routes do not need relative-path handling. The content hash
|
|
267
|
+
and output are deterministic for identical builds.
|
|
268
|
+
|
|
234
269
|
### Manual middleware (advanced)
|
|
235
270
|
|
|
236
271
|
If you need to compose Tasty's middleware with other middleware (e.g., via `sequence()`), use `tastyMiddleware()` directly:
|
|
@@ -263,10 +298,14 @@ Astro's `@astrojs/react` renderer calls `renderToString()` for each React compon
|
|
|
263
298
|
- **Static components** (no `client:*`): Styles are collected during `renderToString` and injected into `</head>` as a single `<style>` tag. No JavaScript is shipped.
|
|
264
299
|
- **Islands** (`client:load`, `client:visible`, etc.): Styles are collected during SSR the same way. On the client, the hydration script (auto-injected by `tastyIntegration()` or manually via `@tenphi/tasty/ssr/astro-client`) reads the class list from `window.__TASTY__` and pre-populates the injector's rules map. The island's `computeStyles()` calls see the class names as already registered and skip the pipeline during hydration.
|
|
265
300
|
- The middleware reads the full response body, then injects the collected CSS into `</head>` before sending the final HTML.
|
|
301
|
+
- In extraction mode, prerendered responses also carry temporary structured
|
|
302
|
+
artifact metadata. `astro:build:done` uses those collector-provided
|
|
303
|
+
boundaries to write the shared asset and rewrite generated HTML, then removes
|
|
304
|
+
the metadata. CSS is never split on newlines or parsed heuristically.
|
|
266
305
|
|
|
267
306
|
### CSP nonce
|
|
268
307
|
|
|
269
|
-
Call `configure({ nonce: '...' })` before any rendering happens. The middleware reads the nonce and applies it to injected `<style>` and `<script>` tags.
|
|
308
|
+
Call `configure({ nonce: '...' })` before any rendering happens. The middleware reads the nonce and applies it to injected `<style>` and `<script>` tags. In extraction mode, page-local inline style tags and the external stylesheet link retain the nonce.
|
|
270
309
|
|
|
271
310
|
---
|
|
272
311
|
|
|
@@ -355,7 +394,7 @@ const stream = await runWithCollector(collector, () =>
|
|
|
355
394
|
| `@tenphi/tasty/ssr/next` | Next.js App Router: `TastyRegistry` component |
|
|
356
395
|
| `@tenphi/tasty/ssr/astro` | Astro: `tastyIntegration`, `tastyMiddleware` |
|
|
357
396
|
| `@tenphi/tasty/ssr/astro-client` | Astro: client-side cache hydration (auto-injected by integration, or import manually) |
|
|
358
|
-
| `@tenphi/tasty/ssr/astro-middleware`<br>`@tenphi/tasty/ssr/astro-middleware-static` | Astro: the middleware entrypoints `tastyIntegration()` registers via `addMiddleware()`. Exported so Astro can resolve them by specifier; you should not import them. For manual setups use `tastyMiddleware()`. |
|
|
397
|
+
| `@tenphi/tasty/ssr/astro-middleware`<br>`@tenphi/tasty/ssr/astro-middleware-static`<br>`@tenphi/tasty/ssr/astro-middleware-extract`<br>`@tenphi/tasty/ssr/astro-middleware-extract-static` | Astro: the middleware entrypoints `tastyIntegration()` registers via `addMiddleware()`. Exported so Astro can resolve them by specifier; you should not import them. For manual setups use `tastyMiddleware()`. |
|
|
359
398
|
|
|
360
399
|
### `ServerStyleCollector`
|
|
361
400
|
|
|
@@ -429,7 +468,7 @@ Class names are also derived from the _resolved_ styles, so the server and the c
|
|
|
429
468
|
|
|
430
469
|
### Styles duplicated after hydration
|
|
431
470
|
|
|
432
|
-
**Global CSS** (`:root` tokens, `@property`, `globalStyles`, `@font-face`, `@counter-style`) configured via `configure()` is automatically deduplicated. When Tasty detects
|
|
471
|
+
**Global CSS** (`:root` tokens, `@property`, `globalStyles`, `@font-face`, `@counter-style`, `@function`) configured via `configure()` is automatically deduplicated. When Tasty detects an inline or extracted `[data-tasty-ssr]` stylesheet in the document, it skips client-side injection of globals that were already rendered by the SSR collector. This means `configure()` can be called with the full config on both server and client — no `typeof window === 'undefined'` guard is needed.
|
|
433
472
|
|
|
434
473
|
**Component CSS**: SSR `<style data-tasty-ssr>` tags remain in the DOM. The client injector creates separate `<style>` elements for any new styles. SSR styles are never modified or removed by the client. If this is a concern for very large apps, you can remove the SSR style tags and hydration scripts manually after hydration:
|
|
435
474
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenphi/tasty",
|
|
3
|
-
"version": "0.0.0-snapshot.
|
|
3
|
+
"version": "0.0.0-snapshot.cd6580c",
|
|
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",
|
|
@@ -72,6 +72,16 @@
|
|
|
72
72
|
"import": "./dist/ssr/astro-middleware-static.js",
|
|
73
73
|
"default": "./dist/ssr/astro-middleware-static.js"
|
|
74
74
|
},
|
|
75
|
+
"./ssr/astro-middleware-extract": {
|
|
76
|
+
"types": "./dist/ssr/astro-middleware-extract.d.ts",
|
|
77
|
+
"import": "./dist/ssr/astro-middleware-extract.js",
|
|
78
|
+
"default": "./dist/ssr/astro-middleware-extract.js"
|
|
79
|
+
},
|
|
80
|
+
"./ssr/astro-middleware-extract-static": {
|
|
81
|
+
"types": "./dist/ssr/astro-middleware-extract-static.d.ts",
|
|
82
|
+
"import": "./dist/ssr/astro-middleware-extract-static.js",
|
|
83
|
+
"default": "./dist/ssr/astro-middleware-extract-static.js"
|
|
84
|
+
},
|
|
75
85
|
"./tasty.config": "./tasty.config.ts"
|
|
76
86
|
},
|
|
77
87
|
"files": [
|
|
@@ -85,7 +95,9 @@
|
|
|
85
95
|
"./dist/ssr/astro.js",
|
|
86
96
|
"./dist/ssr/astro-client.js",
|
|
87
97
|
"./dist/ssr/astro-middleware.js",
|
|
88
|
-
"./dist/ssr/astro-middleware-static.js"
|
|
98
|
+
"./dist/ssr/astro-middleware-static.js",
|
|
99
|
+
"./dist/ssr/astro-middleware-extract.js",
|
|
100
|
+
"./dist/ssr/astro-middleware-extract-static.js"
|
|
89
101
|
],
|
|
90
102
|
"engines": {
|
|
91
103
|
"node": ">=20"
|
|
@@ -170,6 +182,7 @@
|
|
|
170
182
|
"csstype": "^3.1.0"
|
|
171
183
|
},
|
|
172
184
|
"devDependencies": {
|
|
185
|
+
"@astrojs/react": "^4.4.2",
|
|
173
186
|
"@babel/core": "^7.24.0",
|
|
174
187
|
"@babel/helper-plugin-utils": "^7.24.0",
|
|
175
188
|
"@babel/types": "^7.24.0",
|
|
@@ -187,6 +200,7 @@
|
|
|
187
200
|
"@types/react": "^19.0.0",
|
|
188
201
|
"@types/react-dom": "^19.0.0",
|
|
189
202
|
"@vitest/browser-playwright": "^4.1.10",
|
|
203
|
+
"astro": "^5.18.2",
|
|
190
204
|
"eslint": "^10.0.0",
|
|
191
205
|
"eslint-config-prettier": "^10.1.8",
|
|
192
206
|
"jiti": "^2.6.1",
|
|
@@ -208,13 +222,13 @@
|
|
|
208
222
|
"name": "main (import *)",
|
|
209
223
|
"path": "dist/index.js",
|
|
210
224
|
"import": "*",
|
|
211
|
-
"limit": "
|
|
225
|
+
"limit": "57.2 kB"
|
|
212
226
|
},
|
|
213
227
|
{
|
|
214
228
|
"name": "core (import *)",
|
|
215
229
|
"path": "dist/core/index.js",
|
|
216
230
|
"import": "*",
|
|
217
|
-
"limit": "
|
|
231
|
+
"limit": "54.2 kB"
|
|
218
232
|
},
|
|
219
233
|
{
|
|
220
234
|
"name": "static",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collector-Eve9-4dP.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 getGlobalCounterStyles,\n getGlobalFontFaces,\n getGlobalFunctions,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { formatFunctionRule, parseFunctionName } from '../functions';\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 functionRules = new Map<string, string>();\n private flushedFunctionKeys = 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 = getGlobalFontFaces();\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 = getGlobalCounterStyles();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css, { weak: true });\n }\n }\n\n const globalFn = getGlobalFunctions();\n if (globalFn) {\n for (const [name, definition] of Object.entries(globalFn)) {\n const css = formatFunctionRule(name, definition);\n this.collectFunction(parseFunctionName(name), css, { weak: true });\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 and overrides an\n * existing rule by default. Pass `weak: true` for global `configure()`\n * definitions, which never clobber an existing rule.\n */\n collectCounterStyle(\n name: string,\n css: string,\n options?: { weak?: boolean },\n ): void {\n const existing = this.counterStyleRules.get(name);\n if (existing === undefined) {\n this.counterStyleRules.set(name, css);\n return;\n }\n if (options?.weak || existing === css) return;\n this.counterStyleRules.set(name, css);\n // If a rule with this name was already flushed (streaming), allow the\n // overriding rule to be flushed again so it wins by source order.\n this.flushedCounterStyleKeys.delete(name);\n }\n\n /**\n * Record a @function rule. Deduplicated by CSS function name and overrides an\n * existing rule by default. Pass `weak: true` for global `configure()`\n * definitions, which never clobber an existing rule.\n */\n collectFunction(\n name: string,\n css: string,\n options?: { weak?: boolean },\n ): void {\n const existing = this.functionRules.get(name);\n if (existing === undefined) {\n this.functionRules.set(name, css);\n return;\n }\n if (options?.weak || existing === css) return;\n this.functionRules.set(name, css);\n // If a rule with this name was already flushed (streaming), allow the\n // overriding rule to be flushed again so it wins by source order.\n this.flushedFunctionKeys.delete(name);\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 * Pass `replace` for slot-keyed entries (an explicit `id`), where the last\n * write must win to match the client's update-tracking behavior.\n */\n collectGlobalStyles(key: string, css: string, replace?: boolean): void {\n if (replace || !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 * Pass `replace` for slot-keyed entries (an explicit `id`), where the last\n * write must win to match the client's update-tracking behavior.\n */\n collectRawCSS(key: string, css: string, replace?: boolean): void {\n if (replace || !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.functionRules.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.functionRules) {\n if (!this.flushedFunctionKeys.has(key)) {\n parts.push(css);\n this.flushedFunctionKeys.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\n/**\n * Factory for creating a {@link ServerStyleCollector} instance.\n *\n * Canonical functional entry point; the `ServerStyleCollector` class remains\n * exported for advanced/internal use.\n *\n * @param namePrefix - Optional override for the configured class-name prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n *\n * @example\n * ```ts\n * import { createServerStyleCollector } from '@tenphi/tasty/ssr';\n *\n * const collector = createServerStyleCollector();\n * ```\n */\nexport function createServerStyleCollector(\n namePrefix?: string,\n): ServerStyleCollector {\n return new ServerStyleCollector(namePrefix);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,IAAoB;CACzC,sCAA8B,IAAI,IAAoB;CACtD,8BAAsB,IAAI,IAAY;CACtC,gCAAwB,IAAI,IAAoB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