@tenphi/tasty 0.0.0-snapshot.ee431f7 → 0.0.0-snapshot.eef6937

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 (318) hide show
  1. package/README.md +387 -186
  2. package/dist/astro-Bql0oF64.js +321 -0
  3. package/dist/astro-Bql0oF64.js.map +1 -0
  4. package/dist/async-storage-DKK-wTD4.js +44 -0
  5. package/dist/async-storage-DKK-wTD4.js.map +1 -0
  6. package/dist/babel-DWCsafYw.d.ts +83 -0
  7. package/dist/collector-BTVXj2hS.d.ts +163 -0
  8. package/dist/collector-C6TtL8HJ.js +327 -0
  9. package/dist/collector-C6TtL8HJ.js.map +1 -0
  10. package/dist/config-B3gPdCqd.js +12421 -0
  11. package/dist/config-B3gPdCqd.js.map +1 -0
  12. package/dist/config-LfIDmVHx.d.ts +1363 -0
  13. package/dist/context-CA8YKeMn.js +24 -0
  14. package/dist/context-CA8YKeMn.js.map +1 -0
  15. package/dist/core/index.d.ts +5 -33
  16. package/dist/core/index.js +6 -26
  17. package/dist/core-Bq7w2kti.js +1686 -0
  18. package/dist/core-Bq7w2kti.js.map +1 -0
  19. package/dist/css-writer-Bgowobbx.js +390 -0
  20. package/dist/css-writer-Bgowobbx.js.map +1 -0
  21. package/dist/format-global-rules-DklyaXv-.js +22 -0
  22. package/dist/format-global-rules-DklyaXv-.js.map +1 -0
  23. package/dist/format-rules-rCZ37rqY.js +130 -0
  24. package/dist/format-rules-rCZ37rqY.js.map +1 -0
  25. package/dist/hydrate-CNOmZprz.js +37 -0
  26. package/dist/hydrate-CNOmZprz.js.map +1 -0
  27. package/dist/index-Bm9ltvdH.d.ts +1933 -0
  28. package/dist/index-BmogEzTo.d.ts +1575 -0
  29. package/dist/index.d.ts +5 -48
  30. package/dist/index.js +921 -32
  31. package/dist/index.js.map +1 -0
  32. package/dist/keyframes-DE-OE76F.js +535 -0
  33. package/dist/keyframes-DE-OE76F.js.map +1 -0
  34. package/dist/{utils/merge-styles.d.ts → merge-styles-BcLl1u_d.d.ts} +3 -3
  35. package/dist/{utils/merge-styles.js → merge-styles-DuoZEsm9.js} +4 -6
  36. package/dist/merge-styles-DuoZEsm9.js.map +1 -0
  37. package/dist/{utils/resolve-recipes.js → resolve-recipes-H9NqOQuP.js} +5 -8
  38. package/dist/resolve-recipes-H9NqOQuP.js.map +1 -0
  39. package/dist/ssr/astro-client.d.ts +1 -0
  40. package/dist/ssr/astro-client.js +19 -0
  41. package/dist/ssr/astro-client.js.map +1 -0
  42. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  43. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  44. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  45. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  46. package/dist/ssr/astro-middleware-extract.js +9 -0
  47. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  48. package/dist/ssr/astro-middleware-static.d.ts +18 -0
  49. package/dist/ssr/astro-middleware-static.js +18 -0
  50. package/dist/ssr/astro-middleware-static.js.map +1 -0
  51. package/dist/ssr/astro-middleware.d.ts +19 -0
  52. package/dist/ssr/astro-middleware.js +19 -0
  53. package/dist/ssr/astro-middleware.js.map +1 -0
  54. package/dist/ssr/astro.d.ts +132 -0
  55. package/dist/ssr/astro.js +2 -0
  56. package/dist/ssr/index.d.ts +37 -0
  57. package/dist/ssr/index.js +10 -0
  58. package/dist/ssr/index.js.map +1 -0
  59. package/dist/ssr/next.d.ts +45 -0
  60. package/dist/ssr/next.js +74 -0
  61. package/dist/ssr/next.js.map +1 -0
  62. package/dist/static/index.d.ts +91 -5
  63. package/dist/static/index.js +49 -4
  64. package/dist/static/index.js.map +1 -0
  65. package/dist/static/inject.d.ts +5 -0
  66. package/dist/static/inject.js +17 -0
  67. package/dist/static/inject.js.map +1 -0
  68. package/dist/zero/babel.d.ts +2 -108
  69. package/dist/zero/babel.js +235 -39
  70. package/dist/zero/babel.js.map +1 -1
  71. package/dist/zero/index.d.ts +81 -3
  72. package/dist/zero/index.js +2 -4
  73. package/dist/zero/next.d.ts +56 -30
  74. package/dist/zero/next.js +106 -41
  75. package/dist/zero/next.js.map +1 -1
  76. package/docs/README.md +39 -0
  77. package/docs/adoption.md +323 -0
  78. package/docs/ai-agents.md +224 -0
  79. package/docs/comparison.md +448 -0
  80. package/docs/configuration.md +823 -0
  81. package/docs/debug.md +322 -0
  82. package/docs/design-system.md +455 -0
  83. package/docs/dsl.md +1021 -0
  84. package/docs/getting-started.md +238 -0
  85. package/docs/injector.md +634 -0
  86. package/docs/methodology.md +648 -0
  87. package/docs/migration-v3.md +285 -0
  88. package/docs/pipeline.md +741 -0
  89. package/docs/plugins.md +353 -0
  90. package/docs/react-api.md +681 -0
  91. package/docs/runtime-benchmarks.md +178 -0
  92. package/docs/ssr.md +508 -0
  93. package/docs/styles.md +645 -0
  94. package/docs/tasty-static.md +582 -0
  95. package/package.json +120 -47
  96. package/tasty.config.ts +6 -0
  97. package/dist/_virtual/_rolldown/runtime.js +0 -8
  98. package/dist/chunks/cacheKey.js +0 -70
  99. package/dist/chunks/cacheKey.js.map +0 -1
  100. package/dist/chunks/definitions.d.ts +0 -37
  101. package/dist/chunks/definitions.js +0 -260
  102. package/dist/chunks/definitions.js.map +0 -1
  103. package/dist/chunks/renderChunk.js +0 -61
  104. package/dist/chunks/renderChunk.js.map +0 -1
  105. package/dist/config.d.ts +0 -280
  106. package/dist/config.js +0 -403
  107. package/dist/config.js.map +0 -1
  108. package/dist/debug.d.ts +0 -204
  109. package/dist/debug.js +0 -733
  110. package/dist/debug.js.map +0 -1
  111. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  112. package/dist/hooks/useGlobalStyles.js +0 -56
  113. package/dist/hooks/useGlobalStyles.js.map +0 -1
  114. package/dist/hooks/useKeyframes.d.ts +0 -56
  115. package/dist/hooks/useKeyframes.js +0 -54
  116. package/dist/hooks/useKeyframes.js.map +0 -1
  117. package/dist/hooks/useProperty.d.ts +0 -79
  118. package/dist/hooks/useProperty.js +0 -91
  119. package/dist/hooks/useProperty.js.map +0 -1
  120. package/dist/hooks/useRawCSS.d.ts +0 -53
  121. package/dist/hooks/useRawCSS.js +0 -28
  122. package/dist/hooks/useRawCSS.js.map +0 -1
  123. package/dist/hooks/useStyles.d.ts +0 -40
  124. package/dist/hooks/useStyles.js +0 -169
  125. package/dist/hooks/useStyles.js.map +0 -1
  126. package/dist/injector/index.d.ts +0 -157
  127. package/dist/injector/index.js +0 -154
  128. package/dist/injector/index.js.map +0 -1
  129. package/dist/injector/injector.d.ts +0 -139
  130. package/dist/injector/injector.js +0 -404
  131. package/dist/injector/injector.js.map +0 -1
  132. package/dist/injector/sheet-manager.d.ts +0 -127
  133. package/dist/injector/sheet-manager.js +0 -714
  134. package/dist/injector/sheet-manager.js.map +0 -1
  135. package/dist/injector/types.d.ts +0 -135
  136. package/dist/keyframes/index.js +0 -206
  137. package/dist/keyframes/index.js.map +0 -1
  138. package/dist/parser/classify.js +0 -319
  139. package/dist/parser/classify.js.map +0 -1
  140. package/dist/parser/const.js +0 -33
  141. package/dist/parser/const.js.map +0 -1
  142. package/dist/parser/lru.js +0 -109
  143. package/dist/parser/lru.js.map +0 -1
  144. package/dist/parser/parser.d.ts +0 -25
  145. package/dist/parser/parser.js +0 -116
  146. package/dist/parser/parser.js.map +0 -1
  147. package/dist/parser/tokenizer.js +0 -69
  148. package/dist/parser/tokenizer.js.map +0 -1
  149. package/dist/parser/types.d.ts +0 -51
  150. package/dist/parser/types.js +0 -46
  151. package/dist/parser/types.js.map +0 -1
  152. package/dist/pipeline/conditions.d.ts +0 -134
  153. package/dist/pipeline/conditions.js +0 -406
  154. package/dist/pipeline/conditions.js.map +0 -1
  155. package/dist/pipeline/exclusive.js +0 -231
  156. package/dist/pipeline/exclusive.js.map +0 -1
  157. package/dist/pipeline/index.d.ts +0 -53
  158. package/dist/pipeline/index.js +0 -660
  159. package/dist/pipeline/index.js.map +0 -1
  160. package/dist/pipeline/materialize.js +0 -844
  161. package/dist/pipeline/materialize.js.map +0 -1
  162. package/dist/pipeline/parseStateKey.d.ts +0 -15
  163. package/dist/pipeline/parseStateKey.js +0 -438
  164. package/dist/pipeline/parseStateKey.js.map +0 -1
  165. package/dist/pipeline/simplify.js +0 -516
  166. package/dist/pipeline/simplify.js.map +0 -1
  167. package/dist/pipeline/warnings.js +0 -18
  168. package/dist/pipeline/warnings.js.map +0 -1
  169. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  170. package/dist/plugins/okhsl-plugin.js +0 -371
  171. package/dist/plugins/okhsl-plugin.js.map +0 -1
  172. package/dist/plugins/types.d.ts +0 -69
  173. package/dist/properties/index.js +0 -158
  174. package/dist/properties/index.js.map +0 -1
  175. package/dist/states/index.d.ts +0 -49
  176. package/dist/states/index.js +0 -416
  177. package/dist/states/index.js.map +0 -1
  178. package/dist/static/tastyStatic.d.ts +0 -46
  179. package/dist/static/tastyStatic.js +0 -31
  180. package/dist/static/tastyStatic.js.map +0 -1
  181. package/dist/static/types.d.ts +0 -49
  182. package/dist/static/types.js +0 -24
  183. package/dist/static/types.js.map +0 -1
  184. package/dist/styles/align.d.ts +0 -15
  185. package/dist/styles/align.js +0 -14
  186. package/dist/styles/align.js.map +0 -1
  187. package/dist/styles/border.d.ts +0 -25
  188. package/dist/styles/border.js +0 -114
  189. package/dist/styles/border.js.map +0 -1
  190. package/dist/styles/color.d.ts +0 -14
  191. package/dist/styles/color.js +0 -23
  192. package/dist/styles/color.js.map +0 -1
  193. package/dist/styles/createStyle.js +0 -77
  194. package/dist/styles/createStyle.js.map +0 -1
  195. package/dist/styles/dimension.js +0 -97
  196. package/dist/styles/dimension.js.map +0 -1
  197. package/dist/styles/display.d.ts +0 -37
  198. package/dist/styles/display.js +0 -67
  199. package/dist/styles/display.js.map +0 -1
  200. package/dist/styles/fade.d.ts +0 -15
  201. package/dist/styles/fade.js +0 -58
  202. package/dist/styles/fade.js.map +0 -1
  203. package/dist/styles/fill.d.ts +0 -42
  204. package/dist/styles/fill.js +0 -51
  205. package/dist/styles/fill.js.map +0 -1
  206. package/dist/styles/flow.d.ts +0 -16
  207. package/dist/styles/flow.js +0 -12
  208. package/dist/styles/flow.js.map +0 -1
  209. package/dist/styles/gap.d.ts +0 -31
  210. package/dist/styles/gap.js +0 -37
  211. package/dist/styles/gap.js.map +0 -1
  212. package/dist/styles/height.d.ts +0 -17
  213. package/dist/styles/height.js +0 -20
  214. package/dist/styles/height.js.map +0 -1
  215. package/dist/styles/index.d.ts +0 -2
  216. package/dist/styles/index.js +0 -9
  217. package/dist/styles/index.js.map +0 -1
  218. package/dist/styles/inset.d.ts +0 -52
  219. package/dist/styles/inset.js +0 -150
  220. package/dist/styles/inset.js.map +0 -1
  221. package/dist/styles/justify.d.ts +0 -15
  222. package/dist/styles/justify.js +0 -14
  223. package/dist/styles/justify.js.map +0 -1
  224. package/dist/styles/list.d.ts +0 -16
  225. package/dist/styles/list.js +0 -98
  226. package/dist/styles/list.js.map +0 -1
  227. package/dist/styles/margin.d.ts +0 -24
  228. package/dist/styles/margin.js +0 -104
  229. package/dist/styles/margin.js.map +0 -1
  230. package/dist/styles/outline.d.ts +0 -29
  231. package/dist/styles/outline.js +0 -65
  232. package/dist/styles/outline.js.map +0 -1
  233. package/dist/styles/padding.d.ts +0 -24
  234. package/dist/styles/padding.js +0 -104
  235. package/dist/styles/padding.js.map +0 -1
  236. package/dist/styles/predefined.d.ts +0 -73
  237. package/dist/styles/predefined.js +0 -241
  238. package/dist/styles/predefined.js.map +0 -1
  239. package/dist/styles/preset.d.ts +0 -47
  240. package/dist/styles/preset.js +0 -126
  241. package/dist/styles/preset.js.map +0 -1
  242. package/dist/styles/radius.d.ts +0 -14
  243. package/dist/styles/radius.js +0 -51
  244. package/dist/styles/radius.js.map +0 -1
  245. package/dist/styles/scrollbar.d.ts +0 -21
  246. package/dist/styles/scrollbar.js +0 -112
  247. package/dist/styles/scrollbar.js.map +0 -1
  248. package/dist/styles/shadow.d.ts +0 -14
  249. package/dist/styles/shadow.js +0 -24
  250. package/dist/styles/shadow.js.map +0 -1
  251. package/dist/styles/styledScrollbar.d.ts +0 -47
  252. package/dist/styles/styledScrollbar.js +0 -38
  253. package/dist/styles/styledScrollbar.js.map +0 -1
  254. package/dist/styles/transition.d.ts +0 -14
  255. package/dist/styles/transition.js +0 -158
  256. package/dist/styles/transition.js.map +0 -1
  257. package/dist/styles/types.d.ts +0 -498
  258. package/dist/styles/width.d.ts +0 -17
  259. package/dist/styles/width.js +0 -20
  260. package/dist/styles/width.js.map +0 -1
  261. package/dist/tasty.d.ts +0 -982
  262. package/dist/tasty.js +0 -191
  263. package/dist/tasty.js.map +0 -1
  264. package/dist/tokens/typography.d.ts +0 -19
  265. package/dist/tokens/typography.js +0 -237
  266. package/dist/tokens/typography.js.map +0 -1
  267. package/dist/types.d.ts +0 -184
  268. package/dist/utils/cache-wrapper.js +0 -26
  269. package/dist/utils/cache-wrapper.js.map +0 -1
  270. package/dist/utils/case-converter.js +0 -8
  271. package/dist/utils/case-converter.js.map +0 -1
  272. package/dist/utils/colors.d.ts +0 -5
  273. package/dist/utils/colors.js +0 -9
  274. package/dist/utils/colors.js.map +0 -1
  275. package/dist/utils/css-types.d.ts +0 -7
  276. package/dist/utils/dotize.d.ts +0 -26
  277. package/dist/utils/dotize.js +0 -122
  278. package/dist/utils/dotize.js.map +0 -1
  279. package/dist/utils/filter-base-props.d.ts +0 -15
  280. package/dist/utils/filter-base-props.js +0 -45
  281. package/dist/utils/filter-base-props.js.map +0 -1
  282. package/dist/utils/get-display-name.d.ts +0 -7
  283. package/dist/utils/get-display-name.js +0 -10
  284. package/dist/utils/get-display-name.js.map +0 -1
  285. package/dist/utils/hsl-to-rgb.js +0 -38
  286. package/dist/utils/hsl-to-rgb.js.map +0 -1
  287. package/dist/utils/is-dev-env.js +0 -19
  288. package/dist/utils/is-dev-env.js.map +0 -1
  289. package/dist/utils/is-valid-element-type.js +0 -15
  290. package/dist/utils/is-valid-element-type.js.map +0 -1
  291. package/dist/utils/merge-styles.js.map +0 -1
  292. package/dist/utils/mod-attrs.d.ts +0 -8
  293. package/dist/utils/mod-attrs.js +0 -21
  294. package/dist/utils/mod-attrs.js.map +0 -1
  295. package/dist/utils/okhsl-to-rgb.js +0 -296
  296. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  297. package/dist/utils/process-tokens.d.ts +0 -31
  298. package/dist/utils/process-tokens.js +0 -171
  299. package/dist/utils/process-tokens.js.map +0 -1
  300. package/dist/utils/resolve-recipes.d.ts +0 -17
  301. package/dist/utils/resolve-recipes.js.map +0 -1
  302. package/dist/utils/string.js +0 -8
  303. package/dist/utils/string.js.map +0 -1
  304. package/dist/utils/styles.d.ts +0 -178
  305. package/dist/utils/styles.js +0 -590
  306. package/dist/utils/styles.js.map +0 -1
  307. package/dist/utils/typography.d.ts +0 -36
  308. package/dist/utils/typography.js +0 -53
  309. package/dist/utils/typography.js.map +0 -1
  310. package/dist/utils/warnings.d.ts +0 -16
  311. package/dist/utils/warnings.js +0 -16
  312. package/dist/utils/warnings.js.map +0 -1
  313. package/dist/zero/css-writer.d.ts +0 -45
  314. package/dist/zero/css-writer.js +0 -74
  315. package/dist/zero/css-writer.js.map +0 -1
  316. package/dist/zero/extractor.d.ts +0 -24
  317. package/dist/zero/extractor.js +0 -150
  318. package/dist/zero/extractor.js.map +0 -1
@@ -0,0 +1,321 @@
1
+ import { n as getConfig } from "./config-B3gPdCqd.js";
2
+ import { a as registerSSRCollectorGetterGlobal } from "./format-rules-rCZ37rqY.js";
3
+ import { t as ServerStyleCollector } from "./collector-C6TtL8HJ.js";
4
+ import { n as runWithCollector, t as getSSRCollector } from "./async-storage-DKK-wTD4.js";
5
+ import { createHash } from "node:crypto";
6
+ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
7
+ import { join } from "node:path";
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
+ return `${METADATA_START}${Buffer.from(JSON.stringify(artifacts), "utf8").toString("base64")}${METADATA_END}`;
14
+ }
15
+ function parseExtractablePage(path, html) {
16
+ const metadataStart = html.indexOf(METADATA_START);
17
+ if (metadataStart === -1) return null;
18
+ const metadataContentStart = metadataStart + 29;
19
+ const metadataEnd = html.indexOf(METADATA_END, metadataContentStart);
20
+ if (metadataEnd === -1) return null;
21
+ const encoded = html.slice(metadataContentStart, metadataEnd);
22
+ let artifacts;
23
+ try {
24
+ artifacts = JSON.parse(Buffer.from(encoded, "base64").toString("utf8"));
25
+ } catch {
26
+ return null;
27
+ }
28
+ const styleStart = html.lastIndexOf("<style data-tasty-ssr", metadataStart);
29
+ if (styleStart === -1) return null;
30
+ const styleOpenEnd = html.indexOf(">", styleStart);
31
+ const styleEnd = html.indexOf("</style>", styleOpenEnd + 1);
32
+ if (styleOpenEnd === -1 || styleEnd === -1 || styleEnd + 8 !== metadataStart) return null;
33
+ return {
34
+ path,
35
+ html,
36
+ artifacts,
37
+ styleStart,
38
+ replacementEnd: metadataEnd + 11,
39
+ styleOpen: html.slice(styleStart, styleOpenEnd + 1)
40
+ };
41
+ }
42
+ async function findHTMLFiles(dir) {
43
+ const paths = [];
44
+ const entries = await readdir(dir, { withFileTypes: true });
45
+ entries.sort((a, b) => a.name.localeCompare(b.name));
46
+ for (const entry of entries) {
47
+ const path = join(dir, entry.name);
48
+ if (entry.isDirectory()) paths.push(...await findHTMLFiles(path));
49
+ else if (entry.isFile() && entry.name.endsWith(".html")) paths.push(path);
50
+ }
51
+ return paths;
52
+ }
53
+ function skipCSSString(css, start, quote) {
54
+ for (let index = start + 1; index < css.length; index++) if (css[index] === "\\") index++;
55
+ else if (css[index] === quote) return index + 1;
56
+ return css.length;
57
+ }
58
+ function findPageRelativeURL(css) {
59
+ for (let index = 0; index < css.length; index++) {
60
+ if (css[index] === "/" && css[index + 1] === "*") {
61
+ const commentEnd = css.indexOf("*/", index + 2);
62
+ index = commentEnd === -1 ? css.length : commentEnd + 1;
63
+ continue;
64
+ }
65
+ if (css[index] === "\"" || css[index] === "'") {
66
+ index = skipCSSString(css, index, css[index]) - 1;
67
+ continue;
68
+ }
69
+ if (css.slice(index, index + 4).toLowerCase() !== "url(" || index > 0 && /[\w-]/.test(css[index - 1])) continue;
70
+ let valueStart = index + 4;
71
+ while (/\s/.test(css[valueStart] ?? "")) valueStart++;
72
+ let valueEnd;
73
+ const quote = css[valueStart];
74
+ const quoted = quote === "\"" || quote === "'";
75
+ if (quoted) {
76
+ valueEnd = skipCSSString(css, valueStart, quote) - 1;
77
+ index = css.indexOf(")", valueEnd + 1);
78
+ } else {
79
+ valueEnd = valueStart;
80
+ while (valueEnd < css.length && css[valueEnd] !== ")") {
81
+ if (css[valueEnd] === "\\") valueEnd++;
82
+ valueEnd++;
83
+ }
84
+ index = valueEnd;
85
+ }
86
+ if (index === -1) return null;
87
+ const url = css.slice(valueStart + (quoted ? 1 : 0), valueEnd).trim();
88
+ if (url && !url.startsWith("/") && !/^[a-z][a-z\d+.-]*:/i.test(url)) return url;
89
+ }
90
+ return null;
91
+ }
92
+ function validateExtractedURLs(pages) {
93
+ for (const page of pages) for (const artifact of page.artifacts) {
94
+ const url = findPageRelativeURL(artifact.css);
95
+ if (url) throw new Error(`[Tasty] Astro CSS extraction cannot preserve page-relative CSS URL "${url}" in ${page.path} (${artifact.kind} artifact ${artifact.id}). Use a root-relative URL such as url(/path/to/asset), an absolute URL, or a data URL.`);
96
+ }
97
+ }
98
+ /** Find artifacts emitted by every styled page, in the first page's order. */
99
+ function selectSharedArtifacts(pages) {
100
+ if (pages.length < 2) return [];
101
+ const source = pages[0].artifacts;
102
+ const otherIds = pages.slice(1).map((page) => new Set(page.artifacts.map(({ id }) => id)));
103
+ return source.filter(({ id }) => otherIds.every((ids) => ids.has(id)));
104
+ }
105
+ function stylesheetHref(base, assets, filename, assetsPrefix) {
106
+ const assetsPath = assets.replace(/^\/+|\/+$/g, "");
107
+ if (assetsPrefix) return `${(typeof assetsPrefix === "string" ? assetsPrefix : assetsPrefix.css || assetsPrefix.fallback).replace(/\/+$/g, "")}/${assetsPath}/${filename}`;
108
+ return `${base === "/" ? "" : `/${base.replace(/^\/+|\/+$/g, "")}`}/${assetsPath}/${filename}`;
109
+ }
110
+ function stylesheetLink(page, href) {
111
+ return `<link rel="stylesheet" href="${href}" data-tasty-ssr${page.styleOpen.match(/\snonce="[^"]*"/)?.[0] ?? ""}>`;
112
+ }
113
+ function transformPage(page, hrefs) {
114
+ const replacement = hrefs.map((href) => stylesheetLink(page, href)).join("");
115
+ return page.html.slice(0, page.styleStart) + replacement + page.html.slice(page.replacementEnd);
116
+ }
117
+ async function writeStylesheet(assetDir, scope, artifacts) {
118
+ if (artifacts.length === 0) return null;
119
+ const css = artifacts.map(({ css }) => css).join("\n");
120
+ const filename = `tasty.${scope}.${createHash("sha256").update(css).digest("hex").slice(0, 12)}.css`;
121
+ await writeFile(join(assetDir, filename), css);
122
+ return filename;
123
+ }
124
+ async function extractAstroCSS(options) {
125
+ const outputDir = fileURLToPath(options.dir);
126
+ const paths = await findHTMLFiles(outputDir);
127
+ const pages = (await Promise.all(paths.map(async (path) => parseExtractablePage(path, await readFile(path, "utf8"))))).filter((page) => page !== null);
128
+ if (pages.length === 0) return;
129
+ validateExtractedURLs(pages);
130
+ const shared = selectSharedArtifacts(pages);
131
+ const assetDir = join(outputDir, options.assets);
132
+ await mkdir(assetDir, { recursive: true });
133
+ const sharedFilename = await writeStylesheet(assetDir, "shared", shared);
134
+ const sharedHref = sharedFilename ? stylesheetHref(options.base, options.assets, sharedFilename, options.assetsPrefix) : null;
135
+ const sharedIds = new Set(shared.map(({ id }) => id));
136
+ for (const page of pages) {
137
+ const pageFilename = await writeStylesheet(assetDir, "page", page.artifacts.filter(({ id }) => !sharedIds.has(id)));
138
+ const hrefs = sharedHref ? [sharedHref] : [];
139
+ if (pageFilename) hrefs.push(stylesheetHref(options.base, options.assets, pageFilename, options.assetsPrefix));
140
+ await writeFile(page.path, transformPage(page, hrefs));
141
+ }
142
+ }
143
+ //#endregion
144
+ //#region src/ssr/astro.ts
145
+ /**
146
+ * Astro integration for Tasty SSR.
147
+ *
148
+ * Provides:
149
+ * - tastyIntegration() — Astro Integration API (recommended)
150
+ * - tastyMiddleware() — manual middleware for advanced composition
151
+ *
152
+ * Import from '@tenphi/tasty/ssr/astro'.
153
+ */
154
+ registerSSRCollectorGetterGlobal(getSSRCollector);
155
+ /**
156
+ * Create an Astro middleware that collects Tasty styles during SSR.
157
+ *
158
+ * All React components rendered during the request will have their
159
+ * computeStyles() calls captured by the collector via AsyncLocalStorage.
160
+ * After rendering, the middleware injects the collected CSS into </head>.
161
+ *
162
+ * @example Manual middleware setup
163
+ * ```ts
164
+ * // src/middleware.ts
165
+ * import { tastyMiddleware } from '@tenphi/tasty/ssr/astro';
166
+ * export const onRequest = tastyMiddleware();
167
+ * ```
168
+ *
169
+ * @example Composing with other middleware
170
+ * ```ts
171
+ * // src/middleware.ts
172
+ * import { sequence } from 'astro:middleware';
173
+ * import { tastyMiddleware } from '@tenphi/tasty/ssr/astro';
174
+ *
175
+ * export const onRequest = sequence(
176
+ * tastyMiddleware(),
177
+ * myOtherMiddleware,
178
+ * );
179
+ * ```
180
+ */
181
+ function tastyMiddleware(options) {
182
+ const internalOptions = options;
183
+ return async (context, next) => {
184
+ const transferCache = options?.transferCache ?? true;
185
+ const extractionMetadata = internalOptions?.extractionMetadata === true && context.isPrerendered === true;
186
+ const collector = new ServerStyleCollector();
187
+ const rendered = await runWithCollector(collector, async () => {
188
+ const response = await next();
189
+ const body = response.body;
190
+ const contentType = response.headers.get("content-type") ?? "";
191
+ if (!body || !contentType.includes("text/html")) return { response };
192
+ const reader = body.pipeThrough(new TextDecoderStream()).getReader();
193
+ const parts = [];
194
+ for (;;) {
195
+ const { done, value } = await reader.read();
196
+ if (done) break;
197
+ parts.push(value);
198
+ }
199
+ return {
200
+ html: parts.join(""),
201
+ status: response.status,
202
+ headers: response.headers
203
+ };
204
+ });
205
+ if ("response" in rendered) return rendered.response;
206
+ if (!rendered.html) return new Response(null, {
207
+ status: rendered.status,
208
+ headers: rendered.headers
209
+ });
210
+ let { html } = rendered;
211
+ const css = collector.getCSS();
212
+ if (!css) return new Response(html, {
213
+ status: rendered.status,
214
+ headers: rendered.headers
215
+ });
216
+ const nonce = getConfig().nonce;
217
+ const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
218
+ const styleTag = `<style data-tasty-ssr${nonceAttr}>${css}</style>`;
219
+ const metadataTag = extractionMetadata ? createExtractionMetadata(collector.getArtifacts()) : "";
220
+ let cacheTag = "";
221
+ if (transferCache) {
222
+ const classNames = collector.getRenderedClassNames();
223
+ if (classNames.length > 0) cacheTag = `<script${nonceAttr}>(window.__TASTY__=window.__TASTY__||[]).push(${classNames.map((n) => `"${n}"`).join(",")})<\/script>`;
224
+ }
225
+ const injection = styleTag + metadataTag + cacheTag;
226
+ const idx = html.indexOf("</head>");
227
+ if (idx !== -1) html = html.slice(0, idx) + injection + html.slice(idx);
228
+ else html = injection + html;
229
+ const headers = new Headers(rendered.headers);
230
+ headers.delete("content-length");
231
+ return new Response(html, {
232
+ status: rendered.status,
233
+ headers
234
+ });
235
+ };
236
+ }
237
+ /**
238
+ * Package subpaths of the middleware entrypoints registered by
239
+ * `tastyIntegration()`.
240
+ *
241
+ * These must be bare specifiers rather than
242
+ * `new URL('./astro-middleware.js', import.meta.url)`. The bundler is free to
243
+ * hoist `tastyIntegration` into a shared chunk at a different directory depth
244
+ * than `dist/ssr/`, which makes a relative URL resolve to a file that does not
245
+ * exist and breaks the build for every consumer. A package subpath is resolved
246
+ * by the consumer through our `exports` map, so it never depends on the
247
+ * chunk layout.
248
+ *
249
+ * There are separate entrypoints instead of one parameterised entrypoint because
250
+ * `addMiddleware()` cannot pass options: the integration runs when the Astro
251
+ * config is loaded, while the middleware module is evaluated in the server
252
+ * runtime — a different process for built output — so module-level state set
253
+ * by the integration is not visible to the middleware.
254
+ */
255
+ const MIDDLEWARE_ENTRYPOINT = "@tenphi/tasty/ssr/astro-middleware";
256
+ const MIDDLEWARE_ENTRYPOINT_STATIC = "@tenphi/tasty/ssr/astro-middleware-static";
257
+ const MIDDLEWARE_ENTRYPOINT_EXTRACT = "@tenphi/tasty/ssr/astro-middleware-extract";
258
+ const MIDDLEWARE_ENTRYPOINT_EXTRACT_STATIC = "@tenphi/tasty/ssr/astro-middleware-extract-static";
259
+ /**
260
+ * Astro integration that automatically sets up Tasty SSR.
261
+ *
262
+ * Registers middleware for cross-component CSS deduplication and
263
+ * optionally injects a client hydration script for island support.
264
+ *
265
+ * @example Basic setup (with islands)
266
+ * ```ts
267
+ * // astro.config.mjs
268
+ * import { tastyIntegration } from '@tenphi/tasty/ssr/astro';
269
+ *
270
+ * export default defineConfig({
271
+ * integrations: [tastyIntegration()],
272
+ * });
273
+ * ```
274
+ *
275
+ * @example Static-only (no client JS)
276
+ * ```ts
277
+ * // astro.config.mjs
278
+ * import { tastyIntegration } from '@tenphi/tasty/ssr/astro';
279
+ *
280
+ * export default defineConfig({
281
+ * integrations: [tastyIntegration({ islands: false })],
282
+ * });
283
+ * ```
284
+ */
285
+ function tastyIntegration(options) {
286
+ const { islands = true } = options ?? {};
287
+ const cssMode = options?.css?.mode ?? "inline";
288
+ let base = "/";
289
+ let assets = "_astro";
290
+ let assetsPrefix;
291
+ return {
292
+ name: "@tenphi/tasty",
293
+ hooks: {
294
+ "astro:config:setup": ({ addMiddleware, injectScript }) => {
295
+ addMiddleware({
296
+ entrypoint: cssMode === "extract" ? islands ? MIDDLEWARE_ENTRYPOINT_EXTRACT : MIDDLEWARE_ENTRYPOINT_EXTRACT_STATIC : islands ? MIDDLEWARE_ENTRYPOINT : MIDDLEWARE_ENTRYPOINT_STATIC,
297
+ order: "pre"
298
+ });
299
+ if (islands) injectScript("before-hydration", `import "@tenphi/tasty/ssr/astro-client";`);
300
+ },
301
+ "astro:config:done": ({ config }) => {
302
+ base = config.base ?? "/";
303
+ assets = config.build?.assets ?? "_astro";
304
+ assetsPrefix = config.build?.assetsPrefix;
305
+ },
306
+ "astro:build:done": async ({ dir }) => {
307
+ if (cssMode !== "extract") return;
308
+ await extractAstroCSS({
309
+ dir,
310
+ base,
311
+ assets,
312
+ assetsPrefix
313
+ });
314
+ }
315
+ }
316
+ };
317
+ }
318
+ //#endregion
319
+ export { tastyMiddleware as n, tastyIntegration as t };
320
+
321
+ //# sourceMappingURL=astro-Bql0oF64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astro-Bql0oF64.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';\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 skipCSSString(css: string, start: number, quote: string): number {\n for (let index = start + 1; index < css.length; index++) {\n if (css[index] === '\\\\') {\n index++;\n } else if (css[index] === quote) {\n return index + 1;\n }\n }\n return css.length;\n}\n\nfunction findPageRelativeURL(css: string): string | null {\n for (let index = 0; index < css.length; index++) {\n if (css[index] === '/' && css[index + 1] === '*') {\n const commentEnd = css.indexOf('*/', index + 2);\n index = commentEnd === -1 ? css.length : commentEnd + 1;\n continue;\n }\n\n if (css[index] === '\"' || css[index] === \"'\") {\n index = skipCSSString(css, index, css[index]) - 1;\n continue;\n }\n\n if (\n css.slice(index, index + 4).toLowerCase() !== 'url(' ||\n (index > 0 && /[\\w-]/.test(css[index - 1]))\n ) {\n continue;\n }\n\n let valueStart = index + 4;\n while (/\\s/.test(css[valueStart] ?? '')) valueStart++;\n\n let valueEnd: number;\n const quote = css[valueStart];\n const quoted = quote === '\"' || quote === \"'\";\n if (quoted) {\n valueEnd = skipCSSString(css, valueStart, quote) - 1;\n index = css.indexOf(')', valueEnd + 1);\n } else {\n valueEnd = valueStart;\n while (valueEnd < css.length && css[valueEnd] !== ')') {\n if (css[valueEnd] === '\\\\') valueEnd++;\n valueEnd++;\n }\n index = valueEnd;\n }\n\n if (index === -1) return null;\n const url = css.slice(valueStart + (quoted ? 1 : 0), valueEnd).trim();\n if (url && !url.startsWith('/') && !/^[a-z][a-z\\d+.-]*:/i.test(url)) {\n return url;\n }\n }\n\n return null;\n}\n\nfunction validateExtractedURLs(pages: ExtractablePage[]): void {\n for (const page of pages) {\n for (const artifact of page.artifacts) {\n const url = findPageRelativeURL(artifact.css);\n if (url) {\n throw new Error(\n `[Tasty] Astro CSS extraction cannot preserve page-relative CSS URL \"${url}\" in ${page.path} (${artifact.kind} artifact ${artifact.id}). Use a root-relative URL such as url(/path/to/asset), an absolute URL, or a data URL.`,\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}): 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);\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 { getConfig } from '../config';\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 = getConfig().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 `url()` values verbatim, so use root-relative or\n * absolute URLs. The build rejects URLs relative to the rendered page.\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\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 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 },\n 'astro:build:done': async ({ dir }: { dir: URL }) => {\n if (cssMode !== 'extract') return;\n await extractAstroCSS({ dir, base, assets, assetsPrefix });\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,iBAAiB;AACvB,MAAM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ACJ,OAAO,OAAO,QAAQ;IACtB,SAAS,OAAO,OAAO,UAAU;IACjC,eAAe,OAAO,OAAO;GAC/B;GACA,oBAAoB,OAAO,EAAE,UAAwB;IACnD,IAAI,YAAY,WAAW;IAC3B,MAAM,gBAAgB;KAAE;KAAK;KAAM;KAAQ;IAAa,CAAC;GAC3D;EACF;CACF;AACF"}
@@ -0,0 +1,44 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ //#region src/ssr/async-storage.ts
3
+ /**
4
+ * AsyncLocalStorage integration for SSR collector discovery.
5
+ *
6
+ * Used by Astro middleware and generic framework integrations where
7
+ * the library cannot wrap the React tree with a context provider.
8
+ * The middleware calls runWithCollector() around the render, and
9
+ * useStyles() calls getSSRCollector() to find it.
10
+ *
11
+ * Uses globalThis to ensure the AsyncLocalStorage instance is shared
12
+ * across module instances — frameworks like Astro may load middleware
13
+ * and page components from separate module graphs.
14
+ *
15
+ * This module imports from 'node:async_hooks' — it must be excluded
16
+ * from client bundles via the build configuration.
17
+ */
18
+ const ALS_KEY = "__tasty_ssr_als__";
19
+ function getSharedStorage() {
20
+ const g = globalThis;
21
+ if (!g[ALS_KEY]) g[ALS_KEY] = new AsyncLocalStorage();
22
+ return g[ALS_KEY];
23
+ }
24
+ /**
25
+ * Run a function with a ServerStyleCollector bound to the current
26
+ * async context. All useStyles() calls within `fn` (and any async
27
+ * continuations) will find this collector via getSSRCollector().
28
+ */
29
+ function runWithCollector(collector, fn) {
30
+ return getSharedStorage().run(collector, fn);
31
+ }
32
+ /**
33
+ * Retrieve the ServerStyleCollector bound to the current async context.
34
+ * Returns null when called outside of runWithCollector() or on the client.
35
+ */
36
+ function getSSRCollector() {
37
+ const storage = getSharedStorage();
38
+ if (typeof storage?.getStore !== "function") return null;
39
+ return storage.getStore() ?? null;
40
+ }
41
+ //#endregion
42
+ export { runWithCollector as n, getSSRCollector as t };
43
+
44
+ //# sourceMappingURL=async-storage-DKK-wTD4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-storage-DKK-wTD4.js","names":[],"sources":["../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,UACL,EAAE,WAAW,IAAI,kBAAwC;CAE3D,OAAO,EAAE;AACX;;;;;;AAOA,SAAgB,iBACd,WACA,IACG;CACH,OAAO,iBAAiB,CAAC,CAAC,IAAI,WAAW,EAAE;AAC7C;;;;;AAMA,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,iBAAiB;CACjC,IAAI,OAAO,SAAS,aAAa,YAAY,OAAO;CACpD,OAAO,QAAQ,SAAS,KAAK;AAC/B"}
@@ -0,0 +1,83 @@
1
+ import { t as TastyConfig } from "./config-LfIDmVHx.js";
2
+ import { PluginPass } from "@babel/core";
3
+
4
+ //#region src/zero/babel-types.d.ts
5
+ /**
6
+ * Build-time configuration for zero-runtime mode.
7
+ * Subset of TastyConfig excluding runtime-only DOM options
8
+ * (`nonce`, `maxRulesPerSheet`, `forceTextInjection`, `gc`)
9
+ * and overriding `devMode` default to `false`.
10
+ */
11
+ type TastyZeroConfig = Omit<TastyConfig, 'nonce' | 'maxRulesPerSheet' | 'forceTextInjection' | 'gc' | 'devMode'> & {
12
+ /**
13
+ * Enable development mode features: source comments in generated CSS.
14
+ * @default false
15
+ */
16
+ devMode?: boolean;
17
+ };
18
+ //#endregion
19
+ //#region src/zero/babel.d.ts
20
+ /**
21
+ * Options for the `@tenphi/tasty/babel-plugin` Babel plugin.
22
+ */
23
+ interface TastyZeroBabelOptions {
24
+ /** Output path for generated CSS (default: 'tasty.css') */
25
+ output?: string;
26
+ /**
27
+ * Tasty configuration for build-time processing.
28
+ * Can be a static object or a factory function that returns fresh config.
29
+ * A factory is called on each plugin invocation, enabling hot reload
30
+ * of config values that depend on external files (e.g. theme tokens).
31
+ */
32
+ config?: TastyZeroConfig | (() => TastyZeroConfig);
33
+ /**
34
+ * Absolute path to a TypeScript/JavaScript module that default-exports
35
+ * a `TastyZeroConfig` object. The module is loaded via jiti on each
36
+ * plugin invocation, enabling hot reload when the file changes.
37
+ *
38
+ * This option is JSON-serializable and is the primary way Turbopack
39
+ * passes config to the Babel plugin (since Turbopack loader options
40
+ * must be plain primitives/objects/arrays).
41
+ *
42
+ * When both `config` and `configFile` are set, `config` takes precedence.
43
+ *
44
+ * @example '/absolute/path/to/tasty-zero.config.ts'
45
+ */
46
+ configFile?: string;
47
+ /**
48
+ * Absolute file paths whose content affects the generated CSS.
49
+ * When any of these files change, babel-loader invalidates its cache
50
+ * and re-runs the plugin with fresh config values.
51
+ *
52
+ * Typically includes theme files that define Glaze palettes or token values.
53
+ * Paths must be absolute (resolved by the Next.js wrapper).
54
+ */
55
+ configDeps?: string[];
56
+ /**
57
+ * Automatically replace `@tenphi/tasty/static` imports with an import
58
+ * of the generated CSS file. This eliminates the need for users to
59
+ * manually import the CSS in their app entry point.
60
+ *
61
+ * @default true
62
+ */
63
+ injectImport?: boolean;
64
+ /**
65
+ * Output mode for extracted CSS.
66
+ *
67
+ * - `'file'` (default): CSS is written to a single output file and
68
+ * the `@tenphi/tasty/static` import is rewritten to import that file.
69
+ * - `'inject'`: CSS is embedded inline in the JS output and injected
70
+ * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.
71
+ * No CSS file is written. Each `tastyStatic` call becomes
72
+ * self-contained. Best for reusable components and extensions.
73
+ *
74
+ * When `mode` is `'inject'`, `output` and `injectImport` are ignored.
75
+ *
76
+ * @default 'file'
77
+ */
78
+ mode?: 'file' | 'inject';
79
+ }
80
+ declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => import("@babel/core").PluginObj<PluginPass>;
81
+ //#endregion
82
+ export { _default as n, TastyZeroConfig as r, TastyZeroBabelOptions as t };
83
+ //# sourceMappingURL=babel-DWCsafYw.d.ts.map