@tenphi/tasty 0.0.0-snapshot.da430e1 → 0.0.0-snapshot.db2ef70

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 (130) hide show
  1. package/README.md +408 -385
  2. package/dist/babel-types-Dc5zghyE.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-D9Iq8QQm.js +60 -0
  6. package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
  7. package/dist/{collector-BevHh16N.js → chunks/collector-Cb8ah2JF.js} +10 -127
  8. package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
  9. package/dist/chunks/config-engine-CMYFZYQh.js +272 -0
  10. package/dist/chunks/config-engine-CMYFZYQh.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-B4aWBkH3.js +910 -0
  14. package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-D2Pu7Xhy.js +502 -0
  18. package/dist/chunks/debug-D2Pu7Xhy.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DHiopXCu.js +691 -0
  24. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  25. package/dist/chunks/runtime-engine-NGCofNXy.js +2435 -0
  26. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  27. package/dist/chunks/runtime-state-lZjMbvwV.js +152 -0
  28. package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
  29. package/dist/{merge-styles-BKfagXfV.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-DnkV_4Jg.js +5602 -0
  32. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  33. package/dist/{css-writer-BDPmetHV.js → chunks/zero-engine-DcwaCvFs.js} +65 -145
  34. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  35. package/dist/{collector-CLVr5_p3.d.ts → collector-D2OT6I2G.d.ts} +6 -5
  36. package/dist/{config-YsxGv4tq.d.ts → config-C4ftFxgI.d.ts} +181 -77
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-CBK778ne.d.ts → index-DxQNRj50.d.ts} +308 -255
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -922
  43. package/dist/{merge-styles-CU7JbEwg.d.ts → merge-styles-D39qBtox.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +1 -2
  48. package/dist/ssr/astro-middleware-extract-static.js +1 -1
  49. package/dist/ssr/astro-middleware-extract.d.ts +1 -2
  50. package/dist/ssr/astro-middleware-extract.js +1 -1
  51. package/dist/ssr/astro-middleware-static.d.ts +1 -2
  52. package/dist/ssr/astro-middleware-static.js +1 -12
  53. package/dist/ssr/astro-middleware-static.js.map +1 -1
  54. package/dist/ssr/astro-middleware.d.ts +1 -2
  55. package/dist/ssr/astro-middleware.js +1 -13
  56. package/dist/ssr/astro-middleware.js.map +1 -1
  57. package/dist/ssr/astro.d.ts +17 -17
  58. package/dist/ssr/astro.js +220 -1
  59. package/dist/ssr/astro.js.map +1 -0
  60. package/dist/ssr/client.d.ts +2 -0
  61. package/dist/ssr/client.js +2 -0
  62. package/dist/ssr/index.d.ts +5 -25
  63. package/dist/ssr/index.js +5 -5
  64. package/dist/ssr/index.js.map +1 -1
  65. package/dist/ssr/next-config.d.ts +64 -0
  66. package/dist/ssr/next-config.js +123 -0
  67. package/dist/ssr/next-config.js.map +1 -0
  68. package/dist/ssr/next.d.ts +9 -8
  69. package/dist/ssr/next.js +29 -43
  70. package/dist/ssr/next.js.map +1 -1
  71. package/dist/static/index.d.ts +8 -9
  72. package/dist/static/index.js +4 -22
  73. package/dist/static/index.js.map +1 -1
  74. package/dist/static/inject.d.ts +1 -2
  75. package/dist/{index-Cd45t5NM.d.ts → types-CYQIhUg1.d.ts} +868 -820
  76. package/dist/zero/babel.d.ts +73 -2
  77. package/dist/zero/babel.js +81 -144
  78. package/dist/zero/babel.js.map +1 -1
  79. package/dist/zero/index.d.ts +63 -8
  80. package/dist/zero/index.js +25 -2
  81. package/dist/zero/index.js.map +1 -0
  82. package/dist/zero/next.d.ts +4 -5
  83. package/dist/zero/next.js +3 -38
  84. package/dist/zero/next.js.map +1 -1
  85. package/docs/README.md +4 -1
  86. package/docs/adoption.md +25 -17
  87. package/docs/ai-agents.md +68 -33
  88. package/docs/comparison.md +9 -8
  89. package/docs/configuration.md +204 -70
  90. package/docs/debug.md +21 -8
  91. package/docs/design-system.md +117 -15
  92. package/docs/dsl.md +307 -117
  93. package/docs/getting-started.md +81 -22
  94. package/docs/injector.md +105 -67
  95. package/docs/methodology.md +48 -23
  96. package/docs/migration-v3.md +3 -3
  97. package/docs/pipeline.md +54 -27
  98. package/docs/plugins.md +22 -42
  99. package/docs/react-api.md +76 -11
  100. package/docs/runtime-benchmarks.md +282 -110
  101. package/docs/ssr.md +226 -80
  102. package/docs/styles.md +169 -33
  103. package/docs/tasty-static.md +176 -58
  104. package/package.json +108 -44
  105. package/tasty.config.ts +1 -0
  106. package/dist/astro-C_by9qPq.js +0 -307
  107. package/dist/astro-C_by9qPq.js.map +0 -1
  108. package/dist/async-storage-DKK-wTD4.js +0 -44
  109. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  110. package/dist/babel-BUQGeOXA.d.ts +0 -83
  111. package/dist/collector-BevHh16N.js.map +0 -1
  112. package/dist/config-NcdqU9PC.js +0 -12269
  113. package/dist/config-NcdqU9PC.js.map +0 -1
  114. package/dist/context-CA8YKeMn.js +0 -24
  115. package/dist/context-CA8YKeMn.js.map +0 -1
  116. package/dist/core-D7s7u-k1.js +0 -1566
  117. package/dist/core-D7s7u-k1.js.map +0 -1
  118. package/dist/css-writer-BDPmetHV.js.map +0 -1
  119. package/dist/format-global-rules-DklyaXv-.js +0 -22
  120. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  121. package/dist/format-rules-BQCn7JZH.js +0 -130
  122. package/dist/format-rules-BQCn7JZH.js.map +0 -1
  123. package/dist/hydrate-C3cfqlaQ.js +0 -37
  124. package/dist/hydrate-C3cfqlaQ.js.map +0 -1
  125. package/dist/index.js.map +0 -1
  126. package/dist/keyframes-ByhOtsXB.js +0 -493
  127. package/dist/keyframes-ByhOtsXB.js.map +0 -1
  128. package/dist/merge-styles-BKfagXfV.js.map +0 -1
  129. package/dist/resolve-recipes-vvygrWLw.js +0 -144
  130. package/dist/resolve-recipes-vvygrWLw.js.map +0 -1
@@ -1,7 +1,6 @@
1
- import { b as Styles } from "./index-Cd45t5NM.js";
2
-
1
+ import { Y as Styles } from "./types-CYQIhUg1.js";
3
2
  //#region src/utils/merge-styles.d.ts
4
3
  declare function mergeStyles(...objects: (Styles | undefined | null)[]): Styles;
5
4
  //#endregion
6
5
  export { mergeStyles as t };
7
- //# sourceMappingURL=merge-styles-CU7JbEwg.d.ts.map
6
+ //# sourceMappingURL=merge-styles-D39qBtox.d.ts.map
@@ -1 +1 @@
1
- export { };
1
+ export {}
@@ -1,18 +1,5 @@
1
- import { t as hydrateTastyClasses } from "../hydrate-C3cfqlaQ.js";
1
+ import { t as hydrateTastyClasses } from "../chunks/hydration-TRcz5vnk.js";
2
2
  //#region src/ssr/astro-client.ts
3
- /**
4
- * Client-side cache hydration for Astro islands.
5
- *
6
- * Reads the class name list from `window.__TASTY__` (populated by
7
- * inline scripts emitted during SSR) and pre-populates the injector
8
- * so island hydration skips the style pipeline entirely.
9
- *
10
- * This module is browser-safe — it does NOT import node:async_hooks.
11
- *
12
- * Usage:
13
- * - Automatically injected by tastyIntegration() via injectScript('before-hydration')
14
- * - Can be imported manually: `import '@tenphi/tasty/ssr/astro-client'`
15
- */
16
3
  if (typeof window !== "undefined") hydrateTastyClasses();
17
4
  //#endregion
18
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"astro-client.js","names":[],"sources":["../../src/ssr/astro-client.ts"],"sourcesContent":["/**\n * Client-side cache hydration for Astro islands.\n *\n * Reads the class name list from `window.__TASTY__` (populated by\n * inline scripts emitted during SSR) and pre-populates the injector\n * so island hydration skips the style pipeline entirely.\n *\n * This module is browser-safe — it does NOT import node:async_hooks.\n *\n * Usage:\n * - Automatically injected by tastyIntegration() via injectScript('before-hydration')\n * - Can be imported manually: `import '@tenphi/tasty/ssr/astro-client'`\n */\n\nimport { hydrateTastyClasses } from './hydrate';\n\nif (typeof window !== 'undefined') {\n hydrateTastyClasses();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAI,OAAO,WAAW,aACpB,oBAAoB"}
1
+ {"version":3,"file":"astro-client.js","names":[],"sources":["../../src/ssr/astro-client.ts"],"sourcesContent":["/**\n * Client-side cache hydration for Astro islands.\n *\n * Reads the class name list from `window.__TASTY__` (populated by\n * inline scripts emitted during SSR) and pre-populates the injector\n * so island hydration skips the style pipeline entirely.\n *\n * This module is browser-safe — it does NOT import node:async_hooks.\n *\n * Usage:\n * - Automatically injected by tastyIntegration() via injectScript('before-hydration')\n * - Can be imported manually: `import '@tenphi/tasty/ssr/astro-client'`\n */\n\nimport { hydrateTastyClasses } from './hydrate';\n\nif (typeof window !== 'undefined') {\n hydrateTastyClasses();\n}\n"],"mappings":";;AAgBA,IAAI,OAAO,WAAW,aACpB,oBAAoB"}
@@ -3,9 +3,8 @@
3
3
  * Prerender-extraction middleware entrypoint for sites without islands.
4
4
  * Exported only so Astro can resolve it through the package exports map.
5
5
  */
6
- declare const onRequest: (context: {
6
+ export declare const onRequest: (context: {
7
7
  isPrerendered?: boolean;
8
8
  }, next: () => Promise<Response>) => Promise<Response>;
9
9
  //#endregion
10
- export { onRequest };
11
10
  //# sourceMappingURL=astro-middleware-extract-static.d.ts.map
@@ -1,4 +1,4 @@
1
- import { n as tastyMiddleware } from "../astro-C_by9qPq.js";
1
+ import { tastyMiddleware } from "./astro.js";
2
2
  const onRequest = tastyMiddleware({
3
3
  transferCache: false,
4
4
  extractionMetadata: true
@@ -3,9 +3,8 @@
3
3
  * Prerender-extraction middleware entrypoint with island cache transfer.
4
4
  * Exported only so Astro can resolve it through the package exports map.
5
5
  */
6
- declare const onRequest: (context: {
6
+ export declare const onRequest: (context: {
7
7
  isPrerendered?: boolean;
8
8
  }, next: () => Promise<Response>) => Promise<Response>;
9
9
  //#endregion
10
- export { onRequest };
11
10
  //# sourceMappingURL=astro-middleware-extract.d.ts.map
@@ -1,4 +1,4 @@
1
- import { n as tastyMiddleware } from "../astro-C_by9qPq.js";
1
+ import { tastyMiddleware } from "./astro.js";
2
2
  const onRequest = tastyMiddleware({
3
3
  transferCache: true,
4
4
  extractionMetadata: true
@@ -10,9 +10,8 @@
10
10
  * Identical to `./astro-middleware` except that no class-list `<script>` is
11
11
  * emitted, so a site without `client:*` islands ships zero client JavaScript.
12
12
  */
13
- declare const onRequest: (context: {
13
+ export declare const onRequest: (context: {
14
14
  isPrerendered?: boolean;
15
15
  }, next: () => Promise<Response>) => Promise<Response>;
16
16
  //#endregion
17
- export { onRequest };
18
17
  //# sourceMappingURL=astro-middleware-static.d.ts.map
@@ -1,16 +1,5 @@
1
- import { n as tastyMiddleware } from "../astro-C_by9qPq.js";
1
+ import { tastyMiddleware } from "./astro.js";
2
2
  //#region src/ssr/astro-middleware-static.ts
3
- /**
4
- * Astro middleware entrypoint for `tastyIntegration({ islands: false })`.
5
- *
6
- * Registered via `addMiddleware()` as
7
- * `@tenphi/tasty/ssr/astro-middleware-static`. Exposed as a package subpath
8
- * only so Astro can resolve it — use `tastyMiddleware({ transferCache: false })`
9
- * directly if you need manual middleware composition.
10
- *
11
- * Identical to `./astro-middleware` except that no class-list `<script>` is
12
- * emitted, so a site without `client:*` islands ships zero client JavaScript.
13
- */
14
3
  const onRequest = tastyMiddleware({ transferCache: false });
15
4
  //#endregion
16
5
  export { onRequest };
@@ -1 +1 @@
1
- {"version":3,"file":"astro-middleware-static.js","names":[],"sources":["../../src/ssr/astro-middleware-static.ts"],"sourcesContent":["/**\n * Astro middleware entrypoint for `tastyIntegration({ islands: false })`.\n *\n * Registered via `addMiddleware()` as\n * `@tenphi/tasty/ssr/astro-middleware-static`. Exposed as a package subpath\n * only so Astro can resolve it — use `tastyMiddleware({ transferCache: false })`\n * directly if you need manual middleware composition.\n *\n * Identical to `./astro-middleware` except that no class-list `<script>` is\n * emitted, so a site without `client:*` islands ships zero client JavaScript.\n */\n\nimport { tastyMiddleware } from './astro';\n\nexport const onRequest = tastyMiddleware({ transferCache: false });\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,YAAY,gBAAgB,EAAE,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"astro-middleware-static.js","names":[],"sources":["../../src/ssr/astro-middleware-static.ts"],"sourcesContent":["/**\n * Astro middleware entrypoint for `tastyIntegration({ islands: false })`.\n *\n * Registered via `addMiddleware()` as\n * `@tenphi/tasty/ssr/astro-middleware-static`. Exposed as a package subpath\n * only so Astro can resolve it — use `tastyMiddleware({ transferCache: false })`\n * directly if you need manual middleware composition.\n *\n * Identical to `./astro-middleware` except that no class-list `<script>` is\n * emitted, so a site without `client:*` islands ships zero client JavaScript.\n */\n\nimport { tastyMiddleware } from './astro';\n\nexport const onRequest = tastyMiddleware({ transferCache: false });\n"],"mappings":";;AAcA,MAAa,YAAY,gBAAgB,EAAE,eAAe,MAAM,CAAC"}
@@ -11,9 +11,8 @@
11
11
  * `./astro-middleware-static` for the variant used by
12
12
  * `tastyIntegration({ islands: false })`.
13
13
  */
14
- declare const onRequest: (context: {
14
+ export declare const onRequest: (context: {
15
15
  isPrerendered?: boolean;
16
16
  }, next: () => Promise<Response>) => Promise<Response>;
17
17
  //#endregion
18
- export { onRequest };
19
18
  //# sourceMappingURL=astro-middleware.d.ts.map
@@ -1,17 +1,5 @@
1
- import { n as tastyMiddleware } from "../astro-C_by9qPq.js";
1
+ import { tastyMiddleware } from "./astro.js";
2
2
  //#region src/ssr/astro-middleware.ts
3
- /**
4
- * Astro middleware entrypoint for `tastyIntegration()`.
5
- *
6
- * Registered via `addMiddleware()` as `@tenphi/tasty/ssr/astro-middleware`.
7
- * Exposed as a package subpath only so Astro can resolve it — use
8
- * `tastyMiddleware()` directly if you need manual middleware composition.
9
- *
10
- * This is the islands variant: the rendered class list is transferred to the
11
- * client so hydrating islands skip the style pipeline. See
12
- * `./astro-middleware-static` for the variant used by
13
- * `tastyIntegration({ islands: false })`.
14
- */
15
3
  const onRequest = tastyMiddleware({ transferCache: true });
16
4
  //#endregion
17
5
  export { onRequest };
@@ -1 +1 @@
1
- {"version":3,"file":"astro-middleware.js","names":[],"sources":["../../src/ssr/astro-middleware.ts"],"sourcesContent":["/**\n * Astro middleware entrypoint for `tastyIntegration()`.\n *\n * Registered via `addMiddleware()` as `@tenphi/tasty/ssr/astro-middleware`.\n * Exposed as a package subpath only so Astro can resolve it — use\n * `tastyMiddleware()` directly if you need manual middleware composition.\n *\n * This is the islands variant: the rendered class list is transferred to the\n * client so hydrating islands skip the style pipeline. See\n * `./astro-middleware-static` for the variant used by\n * `tastyIntegration({ islands: false })`.\n */\n\nimport { tastyMiddleware } from './astro';\n\nexport const onRequest = tastyMiddleware({ transferCache: true });\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,YAAY,gBAAgB,EAAE,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"astro-middleware.js","names":[],"sources":["../../src/ssr/astro-middleware.ts"],"sourcesContent":["/**\n * Astro middleware entrypoint for `tastyIntegration()`.\n *\n * Registered via `addMiddleware()` as `@tenphi/tasty/ssr/astro-middleware`.\n * Exposed as a package subpath only so Astro can resolve it — use\n * `tastyMiddleware()` directly if you need manual middleware composition.\n *\n * This is the islands variant: the rendered class list is transferred to the\n * client so hydrating islands skip the style pipeline. See\n * `./astro-middleware-static` for the variant used by\n * `tastyIntegration({ islands: false })`.\n */\n\nimport { tastyMiddleware } from './astro';\n\nexport const onRequest = tastyMiddleware({ transferCache: true });\n"],"mappings":";;AAeA,MAAa,YAAY,gBAAgB,EAAE,eAAe,KAAK,CAAC"}
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Import from '@tenphi/tasty/ssr/astro'.
10
10
  */
11
- interface TastyMiddlewareOptions {
11
+ export interface TastyMiddlewareOptions {
12
12
  /**
13
13
  * Whether to embed the class-list script for client hydration.
14
14
  * Set to false to skip class transfer (e.g. for CSP restrictions).
@@ -43,14 +43,20 @@ interface TastyMiddlewareOptions {
43
43
  * );
44
44
  * ```
45
45
  */
46
- declare function tastyMiddleware(options?: TastyMiddlewareOptions): (context: {
46
+ export declare function tastyMiddleware(options?: TastyMiddlewareOptions): (context: {
47
47
  isPrerendered?: boolean;
48
48
  }, next: () => Promise<Response>) => Promise<Response>;
49
- interface TastyIntegrationCSSOptions {
50
- /** CSS delivery mode. Extraction only applies to prerendered builds. */
49
+ export interface TastyIntegrationCSSOptions {
50
+ /**
51
+ * CSS delivery mode. Extraction only applies to prerendered builds.
52
+ * Extracted CSS preserves resource URLs verbatim, so use absolute URLs or
53
+ * data URLs. Root-relative URLs are also supported unless `assetsPrefix`
54
+ * sends CSS to an external origin. The build rejects resource URLs whose
55
+ * targets would change after extraction.
56
+ */
51
57
  mode?: 'inline' | 'extract';
52
58
  }
53
- interface TastyIntegrationOptions {
59
+ export interface TastyIntegrationOptions {
54
60
  /**
55
61
  * Enable island hydration support.
56
62
  *
@@ -92,36 +98,30 @@ interface TastyIntegrationOptions {
92
98
  * });
93
99
  * ```
94
100
  */
95
- declare function tastyIntegration(options?: TastyIntegrationOptions): {
101
+ export declare function tastyIntegration(options?: TastyIntegrationOptions): {
96
102
  name: string;
97
103
  hooks: {
98
- 'astro:config:setup': ({
99
- addMiddleware,
100
- injectScript
101
- }: {
104
+ 'astro:config:setup': ({ addMiddleware, injectScript }: {
102
105
  addMiddleware: (middleware: {
103
106
  entrypoint: string | URL;
104
107
  order: "pre" | "post";
105
108
  }) => void;
106
109
  injectScript: (stage: "head-inline" | "before-hydration" | "page" | "page-ssr", content: string) => void;
107
110
  }) => void;
108
- 'astro:config:done': ({
109
- config
110
- }: {
111
+ 'astro:config:done': ({ config }: {
111
112
  config: {
112
113
  base?: string;
114
+ site?: URL;
113
115
  build?: {
114
116
  assets?: string;
117
+ assetsPrefix?: string | Record<string, string>;
115
118
  };
116
119
  };
117
120
  }) => void;
118
- 'astro:build:done': ({
119
- dir
120
- }: {
121
+ 'astro:build:done': ({ dir }: {
121
122
  dir: URL;
122
123
  }) => Promise<void>;
123
124
  };
124
125
  };
125
126
  //#endregion
126
- export { TastyIntegrationCSSOptions, TastyIntegrationOptions, TastyMiddlewareOptions, tastyIntegration, tastyMiddleware };
127
127
  //# sourceMappingURL=astro.d.ts.map
package/dist/ssr/astro.js CHANGED
@@ -1,2 +1,221 @@
1
- import { n as tastyMiddleware, t as tastyIntegration } from "../astro-C_by9qPq.js";
1
+ import { f as getRuntimeConfigState, r as registerSSRCollectorGetterGlobal } from "../chunks/runtime-state-lZjMbvwV.js";
2
+ import { t as ServerStyleCollector } from "../chunks/collector-Cb8ah2JF.js";
3
+ import { r as runWithCollector, t as getSSRCollector } from "../chunks/async-storage-f9j9JRtq.js";
4
+ import { t as findUnsafeCSSResource } from "../chunks/css-resources-P7IBUUZs.js";
5
+ import { join } from "node:path";
6
+ import { createHash } from "node:crypto";
7
+ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
8
+ import { fileURLToPath } from "node:url";
9
+ //#region src/ssr/astro-extraction.ts
10
+ const METADATA_START = "<template data-tasty-extract>";
11
+ const METADATA_END = "</template>";
12
+ function createExtractionMetadata(artifacts) {
13
+ const encoded = Buffer.from(JSON.stringify(artifacts), "utf8").toString("base64");
14
+ return `${METADATA_START}${encoded}${METADATA_END}`;
15
+ }
16
+ function parseExtractablePage(path, html) {
17
+ const metadataStart = html.indexOf(METADATA_START);
18
+ if (metadataStart === -1) return null;
19
+ const metadataContentStart = metadataStart + 29;
20
+ const metadataEnd = html.indexOf(METADATA_END, metadataContentStart);
21
+ if (metadataEnd === -1) return null;
22
+ const encoded = html.slice(metadataContentStart, metadataEnd);
23
+ let artifacts;
24
+ try {
25
+ artifacts = JSON.parse(Buffer.from(encoded, "base64").toString("utf8"));
26
+ } catch {
27
+ return null;
28
+ }
29
+ const styleStart = html.lastIndexOf("<style data-tasty-ssr", metadataStart);
30
+ if (styleStart === -1) return null;
31
+ const styleOpenEnd = html.indexOf(">", styleStart);
32
+ const styleEnd = html.indexOf("</style>", styleOpenEnd + 1);
33
+ if (styleOpenEnd === -1 || styleEnd === -1 || styleEnd + 8 !== metadataStart) return null;
34
+ return {
35
+ path,
36
+ html,
37
+ artifacts,
38
+ styleStart,
39
+ replacementEnd: metadataEnd + 11,
40
+ styleOpen: html.slice(styleStart, styleOpenEnd + 1)
41
+ };
42
+ }
43
+ async function findHTMLFiles(dir) {
44
+ const paths = [];
45
+ const entries = await readdir(dir, { withFileTypes: true });
46
+ entries.sort((a, b) => a.name.localeCompare(b.name));
47
+ for (const entry of entries) {
48
+ const path = join(dir, entry.name);
49
+ if (entry.isDirectory()) paths.push(...await findHTMLFiles(path));
50
+ else if (entry.isFile() && entry.name.endsWith(".html")) paths.push(path);
51
+ }
52
+ return paths;
53
+ }
54
+ function crossOriginAssetsPrefix(assetsPrefix, site) {
55
+ if (!assetsPrefix) return null;
56
+ const prefix = typeof assetsPrefix === "string" ? assetsPrefix : assetsPrefix.css || assetsPrefix.fallback;
57
+ if (!/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(prefix)) return null;
58
+ if (!site) return prefix;
59
+ try {
60
+ return (prefix.startsWith("//") ? new URL(`${site.protocol}${prefix}`) : new URL(prefix)).origin === site.origin ? null : prefix;
61
+ } catch {
62
+ return prefix;
63
+ }
64
+ }
65
+ function validateExtractedURLs(pages, assetsPrefix, site) {
66
+ const externalPrefix = crossOriginAssetsPrefix(assetsPrefix, site);
67
+ for (const page of pages) for (const artifact of page.artifacts) {
68
+ const unsafe = findUnsafeCSSResource(artifact.css, externalPrefix !== null);
69
+ if (unsafe) {
70
+ const reason = unsafe.rootRelative ? `root-relative CSS URL "${unsafe.url}" would resolve against the external assetsPrefix "${externalPrefix}" instead of the page origin` : `page-relative CSS URL "${unsafe.url}" cannot preserve its target`;
71
+ throw new Error(`[Tasty] Astro CSS extraction cannot preserve ${reason} in ${page.path} (${artifact.kind} artifact ${artifact.id}). Use an absolute URL or a data URL${externalPrefix ? "" : ", or a root-relative URL such as url(/path/to/asset)"}.`);
72
+ }
73
+ }
74
+ }
75
+ function selectSharedArtifacts(pages) {
76
+ if (pages.length < 2) return [];
77
+ const source = pages[0].artifacts;
78
+ const otherIds = pages.slice(1).map((page) => new Set(page.artifacts.map(({ id }) => id)));
79
+ return source.filter(({ id }) => otherIds.every((ids) => ids.has(id)));
80
+ }
81
+ function stylesheetHref(base, assets, filename, assetsPrefix) {
82
+ const assetsPath = assets.replace(/^\/+|\/+$/g, "");
83
+ if (assetsPrefix) return `${(typeof assetsPrefix === "string" ? assetsPrefix : assetsPrefix.css || assetsPrefix.fallback).replace(/\/+$/g, "")}/${assetsPath}/${filename}`;
84
+ return `${base === "/" ? "" : `/${base.replace(/^\/+|\/+$/g, "")}`}/${assetsPath}/${filename}`;
85
+ }
86
+ function stylesheetLink(page, href) {
87
+ return `<link rel="stylesheet" href="${href}" data-tasty-ssr${page.styleOpen.match(/\snonce="[^"]*"/)?.[0] ?? ""}>`;
88
+ }
89
+ function transformPage(page, hrefs) {
90
+ const replacement = hrefs.map((href) => stylesheetLink(page, href)).join("");
91
+ return page.html.slice(0, page.styleStart) + replacement + page.html.slice(page.replacementEnd);
92
+ }
93
+ async function writeStylesheet(assetDir, scope, artifacts) {
94
+ if (artifacts.length === 0) return null;
95
+ const css = artifacts.map(({ css }) => css).join("\n");
96
+ const filename = `tasty.${scope}.${createHash("sha256").update(css).digest("hex").slice(0, 12)}.css`;
97
+ await writeFile(join(assetDir, filename), css);
98
+ return filename;
99
+ }
100
+ async function extractAstroCSS(options) {
101
+ const outputDir = fileURLToPath(options.dir);
102
+ const paths = await findHTMLFiles(outputDir);
103
+ const pages = (await Promise.all(paths.map(async (path) => parseExtractablePage(path, await readFile(path, "utf8"))))).filter((page) => page !== null);
104
+ if (pages.length === 0) return;
105
+ validateExtractedURLs(pages, options.assetsPrefix, options.site);
106
+ const shared = selectSharedArtifacts(pages);
107
+ const assetDir = join(outputDir, options.assets);
108
+ await mkdir(assetDir, { recursive: true });
109
+ const sharedFilename = await writeStylesheet(assetDir, "shared", shared);
110
+ const sharedHref = sharedFilename ? stylesheetHref(options.base, options.assets, sharedFilename, options.assetsPrefix) : null;
111
+ const sharedIds = new Set(shared.map(({ id }) => id));
112
+ for (const page of pages) {
113
+ const pageFilename = await writeStylesheet(assetDir, "page", page.artifacts.filter(({ id }) => !sharedIds.has(id)));
114
+ const hrefs = sharedHref ? [sharedHref] : [];
115
+ if (pageFilename) hrefs.push(stylesheetHref(options.base, options.assets, pageFilename, options.assetsPrefix));
116
+ await writeFile(page.path, transformPage(page, hrefs));
117
+ }
118
+ }
119
+ //#endregion
120
+ //#region src/ssr/astro.ts
121
+ registerSSRCollectorGetterGlobal(getSSRCollector);
122
+ function tastyMiddleware(options) {
123
+ const internalOptions = options;
124
+ return async (context, next) => {
125
+ const transferCache = options?.transferCache ?? true;
126
+ const extractionMetadata = internalOptions?.extractionMetadata === true && context.isPrerendered === true;
127
+ const collector = new ServerStyleCollector();
128
+ const rendered = await runWithCollector(collector, async () => {
129
+ const response = await next();
130
+ const body = response.body;
131
+ const contentType = response.headers.get("content-type") ?? "";
132
+ if (!body || !contentType.includes("text/html")) return { response };
133
+ const reader = body.pipeThrough(new TextDecoderStream()).getReader();
134
+ const parts = [];
135
+ for (;;) {
136
+ const { done, value } = await reader.read();
137
+ if (done) break;
138
+ parts.push(value);
139
+ }
140
+ return {
141
+ html: parts.join(""),
142
+ status: response.status,
143
+ headers: response.headers
144
+ };
145
+ });
146
+ if ("response" in rendered) return rendered.response;
147
+ if (!rendered.html) return new Response(null, {
148
+ status: rendered.status,
149
+ headers: rendered.headers
150
+ });
151
+ let { html } = rendered;
152
+ const css = collector.getCSS();
153
+ if (!css) return new Response(html, {
154
+ status: rendered.status,
155
+ headers: rendered.headers
156
+ });
157
+ const nonce = getRuntimeConfigState()?.nonce;
158
+ const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
159
+ const styleTag = `<style data-tasty-ssr${nonceAttr}>${css}</style>`;
160
+ const metadataTag = extractionMetadata ? createExtractionMetadata(collector.getArtifacts()) : "";
161
+ let cacheTag = "";
162
+ if (transferCache) {
163
+ const classNames = collector.getRenderedClassNames();
164
+ if (classNames.length > 0) cacheTag = `<script${nonceAttr}>(window.__TASTY__=window.__TASTY__||[]).push(${classNames.map((n) => `"${n}"`).join(",")})<\/script>`;
165
+ }
166
+ const injection = styleTag + metadataTag + cacheTag;
167
+ const idx = html.indexOf("</head>");
168
+ if (idx !== -1) html = html.slice(0, idx) + injection + html.slice(idx);
169
+ else html = injection + html;
170
+ const headers = new Headers(rendered.headers);
171
+ headers.delete("content-length");
172
+ return new Response(html, {
173
+ status: rendered.status,
174
+ headers
175
+ });
176
+ };
177
+ }
178
+ const MIDDLEWARE_ENTRYPOINT = "@tenphi/tasty/ssr/astro-middleware";
179
+ const MIDDLEWARE_ENTRYPOINT_STATIC = "@tenphi/tasty/ssr/astro-middleware-static";
180
+ const MIDDLEWARE_ENTRYPOINT_EXTRACT = "@tenphi/tasty/ssr/astro-middleware-extract";
181
+ const MIDDLEWARE_ENTRYPOINT_EXTRACT_STATIC = "@tenphi/tasty/ssr/astro-middleware-extract-static";
182
+ function tastyIntegration(options) {
183
+ const { islands = true } = options ?? {};
184
+ const cssMode = options?.css?.mode ?? "inline";
185
+ let base = "/";
186
+ let assets = "_astro";
187
+ let assetsPrefix;
188
+ let site;
189
+ return {
190
+ name: "@tenphi/tasty",
191
+ hooks: {
192
+ "astro:config:setup": ({ addMiddleware, injectScript }) => {
193
+ addMiddleware({
194
+ entrypoint: cssMode === "extract" ? islands ? MIDDLEWARE_ENTRYPOINT_EXTRACT : MIDDLEWARE_ENTRYPOINT_EXTRACT_STATIC : islands ? MIDDLEWARE_ENTRYPOINT : MIDDLEWARE_ENTRYPOINT_STATIC,
195
+ order: "pre"
196
+ });
197
+ if (islands) injectScript("before-hydration", `import "@tenphi/tasty/ssr/astro-client";`);
198
+ },
199
+ "astro:config:done": ({ config }) => {
200
+ base = config.base ?? "/";
201
+ assets = config.build?.assets ?? "_astro";
202
+ assetsPrefix = config.build?.assetsPrefix;
203
+ site = config.site;
204
+ },
205
+ "astro:build:done": async ({ dir }) => {
206
+ if (cssMode !== "extract") return;
207
+ await extractAstroCSS({
208
+ dir,
209
+ base,
210
+ assets,
211
+ assetsPrefix,
212
+ site
213
+ });
214
+ }
215
+ }
216
+ };
217
+ }
218
+ //#endregion
2
219
  export { tastyIntegration, tastyMiddleware };
220
+
221
+ //# sourceMappingURL=astro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astro.js","names":[],"sources":["../../src/ssr/astro-extraction.ts","../../src/ssr/astro.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { readdir, readFile, writeFile, mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { ServerStyleArtifact } from './collector';\nimport { findUnsafeCSSResource } from './css-resources';\n\nconst METADATA_START = '<template data-tasty-extract>';\nconst METADATA_END = '</template>';\n\ninterface ExtractablePage {\n path: string;\n html: string;\n artifacts: ServerStyleArtifact[];\n styleStart: number;\n replacementEnd: number;\n styleOpen: string;\n}\n\nexport function createExtractionMetadata(\n artifacts: ServerStyleArtifact[],\n): string {\n const encoded = Buffer.from(JSON.stringify(artifacts), 'utf8').toString(\n 'base64',\n );\n return `${METADATA_START}${encoded}${METADATA_END}`;\n}\n\nfunction parseExtractablePage(\n path: string,\n html: string,\n): ExtractablePage | null {\n const metadataStart = html.indexOf(METADATA_START);\n if (metadataStart === -1) return null;\n\n const metadataContentStart = metadataStart + METADATA_START.length;\n const metadataEnd = html.indexOf(METADATA_END, metadataContentStart);\n if (metadataEnd === -1) return null;\n\n const encoded = html.slice(metadataContentStart, metadataEnd);\n let artifacts: ServerStyleArtifact[];\n try {\n artifacts = JSON.parse(\n Buffer.from(encoded, 'base64').toString('utf8'),\n ) as ServerStyleArtifact[];\n } catch {\n return null;\n }\n\n const styleStart = html.lastIndexOf('<style data-tasty-ssr', metadataStart);\n if (styleStart === -1) return null;\n const styleOpenEnd = html.indexOf('>', styleStart);\n const styleEnd = html.indexOf('</style>', styleOpenEnd + 1);\n if (\n styleOpenEnd === -1 ||\n styleEnd === -1 ||\n styleEnd + '</style>'.length !== metadataStart\n ) {\n return null;\n }\n\n return {\n path,\n html,\n artifacts,\n styleStart,\n replacementEnd: metadataEnd + METADATA_END.length,\n styleOpen: html.slice(styleStart, styleOpenEnd + 1),\n };\n}\n\nasync function findHTMLFiles(dir: string): Promise<string[]> {\n const paths: string[] = [];\n const entries = await readdir(dir, { withFileTypes: true });\n entries.sort((a, b) => a.name.localeCompare(b.name));\n for (const entry of entries) {\n const path = join(dir, entry.name);\n if (entry.isDirectory()) {\n paths.push(...(await findHTMLFiles(path)));\n } else if (entry.isFile() && entry.name.endsWith('.html')) {\n paths.push(path);\n }\n }\n return paths;\n}\n\nfunction crossOriginAssetsPrefix(\n assetsPrefix?: string | Record<string, string>,\n site?: URL,\n): string | null {\n if (!assetsPrefix) return null;\n const prefix =\n typeof assetsPrefix === 'string'\n ? assetsPrefix\n : assetsPrefix.css || assetsPrefix.fallback;\n if (!/^(?:[a-z][a-z\\d+.-]*:|\\/\\/)/i.test(prefix)) return null;\n if (!site) return prefix;\n\n try {\n const prefixURL = prefix.startsWith('//')\n ? new URL(`${site.protocol}${prefix}`)\n : new URL(prefix);\n return prefixURL.origin === site.origin ? null : prefix;\n } catch {\n return prefix;\n }\n}\n\nfunction validateExtractedURLs(\n pages: ExtractablePage[],\n assetsPrefix?: string | Record<string, string>,\n site?: URL,\n): void {\n const externalPrefix = crossOriginAssetsPrefix(assetsPrefix, site);\n for (const page of pages) {\n for (const artifact of page.artifacts) {\n const unsafe = findUnsafeCSSResource(\n artifact.css,\n externalPrefix !== null,\n );\n if (unsafe) {\n const reason = unsafe.rootRelative\n ? `root-relative CSS URL \"${unsafe.url}\" would resolve against the external assetsPrefix \"${externalPrefix}\" instead of the page origin`\n : `page-relative CSS URL \"${unsafe.url}\" cannot preserve its target`;\n throw new Error(\n `[Tasty] Astro CSS extraction cannot preserve ${reason} in ${page.path} (${artifact.kind} artifact ${artifact.id}). Use an absolute URL or a data URL${externalPrefix ? '' : ', or a root-relative URL such as url(/path/to/asset)'}.`,\n );\n }\n }\n }\n}\n\n/** Find artifacts emitted by every styled page, in the first page's order. */\nfunction selectSharedArtifacts(\n pages: ExtractablePage[],\n): ServerStyleArtifact[] {\n if (pages.length < 2) return [];\n\n const source = pages[0].artifacts;\n const otherIds = pages\n .slice(1)\n .map((page) => new Set(page.artifacts.map(({ id }) => id)));\n\n return source.filter(({ id }) => otherIds.every((ids) => ids.has(id)));\n}\n\nfunction stylesheetHref(\n base: string,\n assets: string,\n filename: string,\n assetsPrefix?: string | Record<string, string>,\n): string {\n const assetsPath = assets.replace(/^\\/+|\\/+$/g, '');\n if (assetsPrefix) {\n const prefix =\n typeof assetsPrefix === 'string'\n ? assetsPrefix\n : assetsPrefix.css || assetsPrefix.fallback;\n return `${prefix.replace(/\\/+$/g, '')}/${assetsPath}/${filename}`;\n }\n\n const basePath = base === '/' ? '' : `/${base.replace(/^\\/+|\\/+$/g, '')}`;\n return `${basePath}/${assetsPath}/${filename}`;\n}\n\nfunction stylesheetLink(page: ExtractablePage, href: string): string {\n const nonceAttr = page.styleOpen.match(/\\snonce=\"[^\"]*\"/)?.[0] ?? '';\n return `<link rel=\"stylesheet\" href=\"${href}\" data-tasty-ssr${nonceAttr}>`;\n}\n\nfunction transformPage(page: ExtractablePage, hrefs: string[]): string {\n const replacement = hrefs.map((href) => stylesheetLink(page, href)).join('');\n\n return (\n page.html.slice(0, page.styleStart) +\n replacement +\n page.html.slice(page.replacementEnd)\n );\n}\n\nasync function writeStylesheet(\n assetDir: string,\n scope: 'shared' | 'page',\n artifacts: ServerStyleArtifact[],\n): Promise<string | null> {\n if (artifacts.length === 0) return null;\n\n const css = artifacts.map(({ css }) => css).join('\\n');\n const hash = createHash('sha256').update(css).digest('hex').slice(0, 12);\n const filename = `tasty.${scope}.${hash}.css`;\n await writeFile(join(assetDir, filename), css);\n return filename;\n}\n\nexport async function extractAstroCSS(options: {\n dir: URL;\n base: string;\n assets: string;\n assetsPrefix?: string | Record<string, string>;\n site?: URL;\n}): Promise<void> {\n const outputDir = fileURLToPath(options.dir);\n const paths = await findHTMLFiles(outputDir);\n const pages = (\n await Promise.all(\n paths.map(async (path) =>\n parseExtractablePage(path, await readFile(path, 'utf8')),\n ),\n )\n ).filter((page): page is ExtractablePage => page !== null);\n if (pages.length === 0) return;\n validateExtractedURLs(pages, options.assetsPrefix, options.site);\n\n const shared = selectSharedArtifacts(pages);\n const assetDir = join(outputDir, options.assets);\n await mkdir(assetDir, { recursive: true });\n const sharedFilename = await writeStylesheet(assetDir, 'shared', shared);\n const sharedHref = sharedFilename\n ? stylesheetHref(\n options.base,\n options.assets,\n sharedFilename,\n options.assetsPrefix,\n )\n : null;\n const sharedIds = new Set(shared.map(({ id }) => id));\n\n for (const page of pages) {\n const remainder = page.artifacts.filter(({ id }) => !sharedIds.has(id));\n const pageFilename = await writeStylesheet(assetDir, 'page', remainder);\n const hrefs = sharedHref ? [sharedHref] : [];\n if (pageFilename) {\n hrefs.push(\n stylesheetHref(\n options.base,\n options.assets,\n pageFilename,\n options.assetsPrefix,\n ),\n );\n }\n await writeFile(page.path, transformPage(page, hrefs));\n }\n}\n","/**\n * Astro integration for Tasty SSR.\n *\n * Provides:\n * - tastyIntegration() — Astro Integration API (recommended)\n * - tastyMiddleware() — manual middleware for advanced composition\n *\n * Import from '@tenphi/tasty/ssr/astro'.\n */\n\nimport { getRuntimeConfigState } from '../config-resources';\nimport { getSSRCollector, runWithCollector } from './async-storage';\nimport { createExtractionMetadata, extractAstroCSS } from './astro-extraction';\nimport { ServerStyleCollector } from './collector';\nimport { registerSSRCollectorGetterGlobal } from './ssr-collector-ref';\n\n// Wire up ALS-based collector discovery so computeStyles() can find\n// the collector set by tastyMiddleware's runWithCollector().\n// Uses globalThis so the getter is visible across Astro's separate\n// module graphs (middleware vs page components).\nregisterSSRCollectorGetterGlobal(getSSRCollector);\n\nexport interface TastyMiddlewareOptions {\n /**\n * Whether to embed the class-list script for client hydration.\n * Set to false to skip class transfer (e.g. for CSP restrictions).\n * Without it, client components may re-inject CSS that already exists\n * in server-rendered `<style>` tags. Default: true.\n */\n transferCache?: boolean;\n}\n\ninterface InternalTastyMiddlewareOptions extends TastyMiddlewareOptions {\n extractionMetadata?: boolean;\n}\n\n/**\n * Create an Astro middleware that collects Tasty styles during SSR.\n *\n * All React components rendered during the request will have their\n * computeStyles() calls captured by the collector via AsyncLocalStorage.\n * After rendering, the middleware injects the collected CSS into </head>.\n *\n * @example Manual middleware setup\n * ```ts\n * // src/middleware.ts\n * import { tastyMiddleware } from '@tenphi/tasty/ssr/astro';\n * export const onRequest = tastyMiddleware();\n * ```\n *\n * @example Composing with other middleware\n * ```ts\n * // src/middleware.ts\n * import { sequence } from 'astro:middleware';\n * import { tastyMiddleware } from '@tenphi/tasty/ssr/astro';\n *\n * export const onRequest = sequence(\n * tastyMiddleware(),\n * myOtherMiddleware,\n * );\n * ```\n */\nexport function tastyMiddleware(options?: TastyMiddlewareOptions) {\n const internalOptions = options as InternalTastyMiddlewareOptions | undefined;\n return async (\n context: { isPrerendered?: boolean },\n next: () => Promise<Response>,\n ): Promise<Response> => {\n const transferCache = options?.transferCache ?? true;\n const extractionMetadata =\n internalOptions?.extractionMetadata === true &&\n context.isPrerendered === true;\n const collector = new ServerStyleCollector();\n\n // Run the entire request — including body stream consumption — inside\n // the ALS context so that components rendering lazily during stream\n // reads can still find the collector via getSSRCollector().\n type Rendered =\n | { response: Response }\n | { html: string | null; status: number; headers: Headers };\n\n const rendered = await runWithCollector<Promise<Rendered>>(\n collector,\n async (): Promise<Rendered> => {\n const response = await next();\n const body = response.body;\n\n // Only process HTML responses. Reading a non-HTML body (e.g. an\n // image, font, or JSON endpoint) as UTF-8 text corrupts binary\n // payloads: every byte >= 0x80 is decoded to U+FFFD and re-encoded\n // as EF BF BD. Pass anything that isn't HTML straight through.\n const contentType = response.headers.get('content-type') ?? '';\n if (!body || !contentType.includes('text/html')) {\n return { response };\n }\n\n const reader = body.pipeThrough(new TextDecoderStream()).getReader();\n const parts: string[] = [];\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n parts.push(value);\n }\n return {\n html: parts.join(''),\n status: response.status,\n headers: response.headers,\n };\n },\n );\n\n // Non-HTML responses are returned untouched to avoid corrupting\n // binary payloads.\n if ('response' in rendered) {\n return rendered.response;\n }\n\n if (!rendered.html) {\n return new Response(null, {\n status: rendered.status,\n headers: rendered.headers,\n });\n }\n\n let { html } = rendered;\n\n const css = collector.getCSS();\n if (!css) {\n return new Response(html, {\n status: rendered.status,\n headers: rendered.headers,\n });\n }\n\n const nonce = getRuntimeConfigState()?.nonce;\n const nonceAttr = nonce ? ` nonce=\"${nonce}\"` : '';\n const styleTag = `<style data-tasty-ssr${nonceAttr}>${css}</style>`;\n const metadataTag = extractionMetadata\n ? createExtractionMetadata(collector.getArtifacts())\n : '';\n\n let cacheTag = '';\n if (transferCache) {\n const classNames = collector.getRenderedClassNames();\n if (classNames.length > 0) {\n const classListJSON = classNames.map((n) => `\"${n}\"`).join(',');\n cacheTag = `<script${nonceAttr}>(window.__TASTY__=window.__TASTY__||[]).push(${classListJSON})</script>`;\n }\n }\n\n const injection = styleTag + metadataTag + cacheTag;\n const idx = html.indexOf('</head>');\n if (idx !== -1) {\n html = html.slice(0, idx) + injection + html.slice(idx);\n } else {\n html = injection + html;\n }\n\n const headers = new Headers(rendered.headers);\n headers.delete('content-length');\n\n return new Response(html, {\n status: rendered.status,\n headers,\n });\n };\n}\n\n// ============================================================================\n// Astro Integration API\n// ============================================================================\n\n/**\n * Package subpaths of the middleware entrypoints registered by\n * `tastyIntegration()`.\n *\n * These must be bare specifiers rather than\n * `new URL('./astro-middleware.js', import.meta.url)`. The bundler is free to\n * hoist `tastyIntegration` into a shared chunk at a different directory depth\n * than `dist/ssr/`, which makes a relative URL resolve to a file that does not\n * exist and breaks the build for every consumer. A package subpath is resolved\n * by the consumer through our `exports` map, so it never depends on the\n * chunk layout.\n *\n * There are separate entrypoints instead of one parameterised entrypoint because\n * `addMiddleware()` cannot pass options: the integration runs when the Astro\n * config is loaded, while the middleware module is evaluated in the server\n * runtime — a different process for built output — so module-level state set\n * by the integration is not visible to the middleware.\n */\nconst MIDDLEWARE_ENTRYPOINT = '@tenphi/tasty/ssr/astro-middleware';\nconst MIDDLEWARE_ENTRYPOINT_STATIC =\n '@tenphi/tasty/ssr/astro-middleware-static';\nconst MIDDLEWARE_ENTRYPOINT_EXTRACT =\n '@tenphi/tasty/ssr/astro-middleware-extract';\nconst MIDDLEWARE_ENTRYPOINT_EXTRACT_STATIC =\n '@tenphi/tasty/ssr/astro-middleware-extract-static';\n\nexport interface TastyIntegrationCSSOptions {\n /**\n * CSS delivery mode. Extraction only applies to prerendered builds.\n * Extracted CSS preserves resource URLs verbatim, so use absolute URLs or\n * data URLs. Root-relative URLs are also supported unless `assetsPrefix`\n * sends CSS to an external origin. The build rejects resource URLs whose\n * targets would change after extraction.\n */\n mode?: 'inline' | 'extract';\n}\n\nexport interface TastyIntegrationOptions {\n /**\n * Enable island hydration support.\n *\n * When `true` (default): injects a client hydration script via\n * `injectScript('before-hydration')` and sets `transferCache: true`\n * on the middleware. Islands skip the style pipeline during hydration.\n *\n * When `false`: no client JS is shipped and `transferCache` is set\n * to `false`. Use this for fully static sites without `client:*`\n * directives.\n */\n islands?: boolean;\n /** Configure inline or build-wide extracted CSS delivery. */\n css?: TastyIntegrationCSSOptions;\n}\n\n/**\n * Astro integration that automatically sets up Tasty SSR.\n *\n * Registers middleware for cross-component CSS deduplication and\n * optionally injects a client hydration script for island support.\n *\n * @example Basic setup (with islands)\n * ```ts\n * // astro.config.mjs\n * import { tastyIntegration } from '@tenphi/tasty/ssr/astro';\n *\n * export default defineConfig({\n * integrations: [tastyIntegration()],\n * });\n * ```\n *\n * @example Static-only (no client JS)\n * ```ts\n * // astro.config.mjs\n * import { tastyIntegration } from '@tenphi/tasty/ssr/astro';\n *\n * export default defineConfig({\n * integrations: [tastyIntegration({ islands: false })],\n * });\n * ```\n */\nexport function tastyIntegration(options?: TastyIntegrationOptions) {\n const { islands = true } = options ?? {};\n const cssMode = options?.css?.mode ?? 'inline';\n let base = '/';\n let assets = '_astro';\n let assetsPrefix: string | Record<string, string> | undefined;\n let site: URL | undefined;\n\n return {\n name: '@tenphi/tasty',\n hooks: {\n 'astro:config:setup': ({\n addMiddleware,\n injectScript,\n }: {\n addMiddleware: (middleware: {\n entrypoint: string | URL;\n order: 'pre' | 'post';\n }) => void;\n injectScript: (\n stage: 'head-inline' | 'before-hydration' | 'page' | 'page-ssr',\n content: string,\n ) => void;\n }) => {\n addMiddleware({\n entrypoint:\n cssMode === 'extract'\n ? islands\n ? MIDDLEWARE_ENTRYPOINT_EXTRACT\n : MIDDLEWARE_ENTRYPOINT_EXTRACT_STATIC\n : islands\n ? MIDDLEWARE_ENTRYPOINT\n : MIDDLEWARE_ENTRYPOINT_STATIC,\n order: 'pre',\n });\n\n if (islands) {\n injectScript(\n 'before-hydration',\n `import \"@tenphi/tasty/ssr/astro-client\";`,\n );\n }\n },\n 'astro:config:done': ({\n config,\n }: {\n config: {\n base?: string;\n site?: URL;\n build?: {\n assets?: string;\n assetsPrefix?: string | Record<string, string>;\n };\n };\n }) => {\n base = config.base ?? '/';\n assets = config.build?.assets ?? '_astro';\n assetsPrefix = config.build?.assetsPrefix;\n site = config.site;\n },\n 'astro:build:done': async ({ dir }: { dir: URL }) => {\n if (cssMode !== 'extract') return;\n await extractAstroCSS({ dir, base, assets, assetsPrefix, site });\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,iBAAiB;AACvB,MAAM,eAAe;AAWrB,SAAgB,yBACd,WACQ;CACR,MAAM,UAAU,OAAO,KAAK,KAAK,UAAU,SAAS,GAAG,MAAM,CAAC,CAAC,SAC7D,QACF;CACA,OAAO,GAAG,iBAAiB,UAAU;AACvC;AAEA,SAAS,qBACP,MACA,MACwB;CACxB,MAAM,gBAAgB,KAAK,QAAQ,cAAc;CACjD,IAAI,kBAAkB,IAAI,OAAO;CAEjC,MAAM,uBAAuB,gBAAgB;CAC7C,MAAM,cAAc,KAAK,QAAQ,cAAc,oBAAoB;CACnE,IAAI,gBAAgB,IAAI,OAAO;CAE/B,MAAM,UAAU,KAAK,MAAM,sBAAsB,WAAW;CAC5D,IAAI;CACJ,IAAI;EACF,YAAY,KAAK,MACf,OAAO,KAAK,SAAS,QAAQ,CAAC,CAAC,SAAS,MAAM,CAChD;CACF,QAAQ;EACN,OAAO;CACT;CAEA,MAAM,aAAa,KAAK,YAAY,yBAAyB,aAAa;CAC1E,IAAI,eAAe,IAAI,OAAO;CAC9B,MAAM,eAAe,KAAK,QAAQ,KAAK,UAAU;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;KAAK;KAAM;KAAQ;KAAc;IAAK,CAAC;GACjE;EACF;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ import { t as hydrateTastyClasses } from "../hydrate-CRyjjAyl.js";
2
+ export { hydrateTastyClasses };
@@ -0,0 +1,2 @@
1
+ import { t as hydrateTastyClasses } from "../chunks/hydration-TRcz5vnk.js";
2
+ export { hydrateTastyClasses };
@@ -1,37 +1,17 @@
1
- import { i as createServerStyleCollector, n as ServerStyleArtifactKind, r as ServerStyleCollector, t as ServerStyleArtifact } from "../collector-CLVr5_p3.js";
2
-
1
+ import { i as ServerStyleArtifactKind, n as createServerStyleCollector, r as ServerStyleArtifact, t as ServerStyleCollector } from "../collector-D2OT6I2G.js";
2
+ import { t as hydrateTastyClasses } from "../hydrate-CRyjjAyl.js";
3
3
  //#region src/ssr/async-storage.d.ts
4
4
  /**
5
5
  * Run a function with a ServerStyleCollector bound to the current
6
6
  * async context. All useStyles() calls within `fn` (and any async
7
7
  * continuations) will find this collector via getSSRCollector().
8
8
  */
9
- declare function runWithCollector<T>(collector: ServerStyleCollector, fn: () => T): T;
9
+ export declare function runWithCollector<T>(collector: ServerStyleCollector, fn: () => T): T;
10
10
  /**
11
11
  * Retrieve the ServerStyleCollector bound to the current async context.
12
12
  * Returns null when called outside of runWithCollector() or on the client.
13
13
  */
14
- declare function getSSRCollector(): ServerStyleCollector | null;
14
+ export declare function getSSRCollector(): ServerStyleCollector | null;
15
15
  //#endregion
16
- //#region src/ssr/hydrate.d.ts
17
- /**
18
- * Client-side cache hydration for SSR/RSC.
19
- *
20
- * Pre-populates the client injector's rules map with class names
21
- * rendered on the server. With hash-based naming, the client derives
22
- * the same class name from the same cache key, so only the class name
23
- * list needs to cross the wire — no cache keys or counters.
24
- */
25
- /**
26
- * Pre-populate the client-side style registry from the server's class name list.
27
- *
28
- * Call this before ReactDOM.hydrateRoot() or ensure it runs before
29
- * any tasty() component renders on the client.
30
- *
31
- * When called without arguments, reads the class list from `window.__TASTY__`
32
- * (populated by inline scripts emitted during SSR/RSC streaming).
33
- */
34
- declare function hydrateTastyClasses(classes?: string[]): void;
35
- //#endregion
36
- export { type ServerStyleArtifact, type ServerStyleArtifactKind, ServerStyleCollector, createServerStyleCollector, getSSRCollector, hydrateTastyClasses, runWithCollector };
16
+ export { type ServerStyleArtifact, type ServerStyleArtifactKind, ServerStyleCollector, createServerStyleCollector, hydrateTastyClasses };
37
17
  //# sourceMappingURL=index.d.ts.map
package/dist/ssr/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { a as registerSSRCollectorGetterGlobal } from "../format-rules-BQCn7JZH.js";
2
- import { n as createServerStyleCollector, t as ServerStyleCollector } from "../collector-BevHh16N.js";
3
- import { n as runWithCollector, t as getSSRCollector } from "../async-storage-DKK-wTD4.js";
4
- import { t as hydrateTastyClasses } from "../hydrate-C3cfqlaQ.js";
1
+ import { r as registerSSRCollectorGetterGlobal } from "../chunks/runtime-state-lZjMbvwV.js";
2
+ import { n as createServerStyleCollector, t as ServerStyleCollector } from "../chunks/collector-Cb8ah2JF.js";
3
+ import { n as isAsyncStorageAvailable, r as runWithCollector, t as getSSRCollector } from "../chunks/async-storage-f9j9JRtq.js";
4
+ import { t as hydrateTastyClasses } from "../chunks/hydration-TRcz5vnk.js";
5
5
  //#region src/ssr/index.ts
6
- registerSSRCollectorGetterGlobal(getSSRCollector);
6
+ if (isAsyncStorageAvailable()) registerSSRCollectorGetterGlobal(getSSRCollector);
7
7
  //#endregion
8
8
  export { ServerStyleCollector, createServerStyleCollector, getSSRCollector, hydrateTastyClasses, runWithCollector };
9
9
 
@@ -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';\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"}
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.\n// A browser bundle that imports this entry has no storage to look in.\nimport { getSSRCollector, isAsyncStorageAvailable } from './async-storage';\nimport { registerSSRCollectorGetterGlobal } from './ssr-collector-ref';\n\nif (isAsyncStorageAvailable()) {\n registerSSRCollectorGetterGlobal(getSSRCollector);\n}\n"],"mappings":";;;;;AA0BA,IAAI,wBAAwB,GAC1B,iCAAiC,eAAe"}