acrylblends 0.6.3 → 0.7.0

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 (285) hide show
  1. package/README.md +4 -3
  2. package/docs/framework/README.md +2 -2
  3. package/docs/framework/UPSTREAM.md +1 -1
  4. package/docs/framework/guides/jsx.md +51 -1
  5. package/docs/framework/helpers/ssg.md +3 -6
  6. package/docs/framework/middleware/builtin/jsx-renderer.md +0 -3
  7. package/docs/framework/upstream.json +2 -2
  8. package/lib/accepts.d.ts +1 -1
  9. package/lib/acryl-base.d.ts +1 -1
  10. package/lib/adapter.d.ts +1 -1
  11. package/lib/{app-wFwpg-bt.d.ts → app-D8riatvv.d.ts} +1 -1
  12. package/lib/{base-ddiVmiE7.js → base-NSN_SNv-.js} +1 -0
  13. package/lib/basic-auth.d.ts +1 -1
  14. package/lib/bearer-auth.d.ts +1 -1
  15. package/lib/body-limit.d.ts +1 -1
  16. package/lib/cache.d.ts +1 -1
  17. package/lib/cache.js +4 -4
  18. package/lib/{client-BHTr318g.js → client-DDLXwhBo.js} +2 -125
  19. package/lib/client.d.ts +2 -2
  20. package/lib/client.js +2 -1
  21. package/lib/combine.d.ts +1 -1
  22. package/lib/{components-DYZdxJIJ.js → components-JXVm45kK.js} +1 -1
  23. package/lib/{components-Ce5FRyHU.js → components-cEW3ovK0.js} +3 -3
  24. package/lib/compress.d.ts +1 -1
  25. package/lib/conninfo.d.ts +2 -2
  26. package/lib/{context-DVQBjuns.d.ts → context-DS3fYyG-.d.ts} +1 -1
  27. package/lib/context-storage.d.ts +1 -1
  28. package/lib/cookie.d.ts +1 -1
  29. package/lib/cors.d.ts +1 -1
  30. package/lib/csrf.d.ts +1 -1
  31. package/lib/dev.d.ts +2 -2
  32. package/lib/etag.d.ts +1 -1
  33. package/lib/factory.d.ts +2 -2
  34. package/lib/{hooks-Bq5q9IMl.js → hooks-w72iLeFR.js} +6 -6
  35. package/lib/{index-CUTfU69R.d.ts → index-Bb7YJKCq.d.ts} +2 -2
  36. package/lib/{index-CsvB-F9j.d.ts → index-BvFh1Gfx.d.ts} +1 -1
  37. package/lib/{index-Cqcdluyn.d.ts → index-CTy4N7ng.d.ts} +2 -2
  38. package/lib/index.d.ts +4 -4
  39. package/lib/ip-restriction.d.ts +2 -2
  40. package/lib/jsx/dom/client.js +1 -1
  41. package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
  42. package/lib/jsx/dom/jsx-runtime.js +1 -1
  43. package/lib/jsx/dom/server.js +2 -2
  44. package/lib/jsx/dom.js +4 -4
  45. package/lib/jsx/jsx-dev-runtime.js +1 -1
  46. package/lib/jsx/jsx-runtime.js +1 -1
  47. package/lib/jsx/streaming.js +1 -1
  48. package/lib/{jsx-dev-runtime-kAhR_4C7.js → jsx-dev-runtime-CWLRA2F3.js} +2 -2
  49. package/lib/jsx-renderer.d.ts +75 -0
  50. package/lib/jsx-renderer.js +99 -0
  51. package/lib/jsx.js +4 -4
  52. package/lib/jwk.d.ts +1 -1
  53. package/lib/jwt.d.ts +1 -1
  54. package/lib/language.d.ts +1 -1
  55. package/lib/logger.d.ts +1 -1
  56. package/lib/loopback-only.d.ts +1 -1
  57. package/lib/method-not-allowed.d.ts +2 -2
  58. package/lib/method-override.d.ts +2 -2
  59. package/lib/mount.d.ts +1 -1
  60. package/lib/node-server/conninfo.d.ts +1 -1
  61. package/lib/node-server/register.d.ts +1 -0
  62. package/lib/node-server/register.js +73 -0
  63. package/lib/node-server/serve-static.d.ts +1 -1
  64. package/lib/node-server/serve-static.js +1 -1
  65. package/lib/node-server.d.ts +1 -1
  66. package/lib/node-server.js +1 -1
  67. package/lib/powered-by.d.ts +1 -1
  68. package/lib/pretty-json.d.ts +1 -1
  69. package/lib/quick.d.ts +1 -1
  70. package/lib/request-id.d.ts +1 -1
  71. package/lib/request.d.ts +1 -1
  72. package/lib/route.d.ts +1 -1
  73. package/lib/schema-validator.d.ts +1 -1
  74. package/lib/secure-headers.d.ts +1 -1
  75. package/lib/{serve-static-Cw23shXv.js → serve-static-B14MF1Va.js} +1 -0
  76. package/lib/serve-static.d.ts +1 -1
  77. package/lib/ssg-BwjcA-Ge.js +389 -0
  78. package/lib/ssg.d.ts +156 -0
  79. package/lib/ssg.js +2 -0
  80. package/lib/streaming.d.ts +1 -1
  81. package/lib/testing.d.ts +3 -3
  82. package/lib/testing.js +1 -1
  83. package/lib/timeout.d.ts +1 -1
  84. package/lib/timing.d.ts +1 -1
  85. package/lib/tiny.d.ts +1 -1
  86. package/lib/trailing-slash.d.ts +1 -1
  87. package/lib/{types-nEL8VPDC.d.ts → types-Dv_nV2cv.d.ts} +1 -1
  88. package/lib/{types-CQiGmsWW.d.ts → types-zNxyEpG2.d.ts} +2 -2
  89. package/lib/types.d.ts +1 -1
  90. package/lib/utils/body.d.ts +1 -1
  91. package/lib/utils/ipaddr.d.ts +1 -1
  92. package/lib/utils-Cx61GFMC.js +125 -0
  93. package/lib/validator.d.ts +1 -1
  94. package/lib/ws.d.ts +1 -1
  95. package/package.json +13 -1
  96. package/plugins/acryl-inspect/upstream.json +1 -1
  97. package/plugins/acryl-node-server/src/register.ts +86 -0
  98. package/plugins/acryl-node-server/upstream.json +5 -3
  99. package/plugins/acryl-router/src/core/helper/ssg/index.ts +14 -0
  100. package/plugins/acryl-router/src/core/helper/ssg/middleware.ts +83 -0
  101. package/plugins/acryl-router/src/core/helper/ssg/plugins.ts +72 -0
  102. package/plugins/acryl-router/src/core/helper/ssg/ssg.ts +471 -0
  103. package/plugins/acryl-router/src/core/helper/ssg/utils.ts +118 -0
  104. package/plugins/acryl-router/src/core/jsx/dom/render.ts +6 -6
  105. package/plugins/acryl-router/src/core/middleware/cache/index.ts +4 -4
  106. package/plugins/acryl-router/src/core/middleware/jsx-renderer/index.ts +162 -0
  107. package/plugins/acryl-router/src/helpers/index.ts +1 -0
  108. package/plugins/acryl-router/src/middleware/index.ts +1 -0
  109. package/plugins/acryl-router/upstream.json +2 -2
  110. package/plugins/acryl-router-http/upstream.json +1 -1
  111. package/plugins/acryl-state/upstream.json +1 -1
  112. package/plugins/desktop/main.ts +4 -1
  113. package/plugins/desktop/upstream.json +1 -1
  114. package/plugins/desktop-web/main.ts +3 -1
  115. package/plugins/desktop-web/upstream.json +1 -1
  116. package/plugins/extensions/resolve.ts +4 -0
  117. package/shared/AGENTS.core.md +3 -0
  118. package/templates/agent/package.json +7 -3
  119. package/templates/agent/tsconfig.json +10 -2
  120. package/templates/blank/package.json +7 -3
  121. package/templates/blank/src/about.tsx +14 -0
  122. package/templates/blank/src/routes.ts +2 -0
  123. package/templates/blank/test/app.test.ts +15 -0
  124. package/templates/blank/tsconfig.json +3 -1
  125. package/templates/todo/package.json +7 -3
  126. package/templates/todo/tsconfig.json +3 -1
  127. package/templates/todo/upstream.json +1 -1
  128. package/plugins/acryl-inspect/tests/report.spec.ts +0 -69
  129. package/plugins/acryl-inspect/tests/service.spec.ts +0 -121
  130. package/plugins/acryl-node-server/tests/adapter/app.ts +0 -76
  131. package/plugins/acryl-node-server/tests/adapter/assets/.static/plain.txt +0 -1
  132. package/plugins/acryl-node-server/tests/adapter/assets/favicon.ico +0 -0
  133. package/plugins/acryl-node-server/tests/adapter/assets/secret.txt +0 -1
  134. package/plugins/acryl-node-server/tests/adapter/assets/static/acryl.html +0 -1
  135. package/plugins/acryl-node-server/tests/adapter/assets/static/admin/secret.txt +0 -1
  136. package/plugins/acryl-node-server/tests/adapter/assets/static/data.json +0 -5
  137. package/plugins/acryl-node-server/tests/adapter/assets/static/extensionless +0 -1
  138. package/plugins/acryl-node-server/tests/adapter/assets/static/foo..bar.txt +0 -0
  139. package/plugins/acryl-node-server/tests/adapter/assets/static/index.html +0 -1
  140. package/plugins/acryl-node-server/tests/adapter/assets/static/plain.txt +0 -1
  141. package/plugins/acryl-node-server/tests/adapter/assets/static-with-context-path/plain.txt +0 -1
  142. package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin +0 -1
  143. package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin.br +0 -1
  144. package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt +0 -1
  145. package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.br +0 -1
  146. package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.zst +0 -1
  147. package/plugins/acryl-node-server/tests/adapter/conninfo.test.ts +0 -34
  148. package/plugins/acryl-node-server/tests/adapter/content-length.test.ts +0 -248
  149. package/plugins/acryl-node-server/tests/adapter/early-hints.test.ts +0 -457
  150. package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-cert.pem +0 -23
  151. package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-key.pem +0 -27
  152. package/plugins/acryl-node-server/tests/adapter/headers.test.ts +0 -252
  153. package/plugins/acryl-node-server/tests/adapter/helpers/request.ts +0 -190
  154. package/plugins/acryl-node-server/tests/adapter/listener.test.ts +0 -727
  155. package/plugins/acryl-node-server/tests/adapter/request-client-disconnect.test.ts +0 -189
  156. package/plugins/acryl-node-server/tests/adapter/request.test.ts +0 -1230
  157. package/plugins/acryl-node-server/tests/adapter/response.test.ts +0 -285
  158. package/plugins/acryl-node-server/tests/adapter/serve-static.test.ts +0 -849
  159. package/plugins/acryl-node-server/tests/adapter/server-socket.test.ts +0 -790
  160. package/plugins/acryl-node-server/tests/adapter/server.test.ts +0 -1312
  161. package/plugins/acryl-node-server/tests/adapter/setup.ts +0 -16
  162. package/plugins/acryl-node-server/tests/adapter/url.test.ts +0 -76
  163. package/plugins/acryl-node-server/tests/adapter/utils/response.test.ts +0 -23
  164. package/plugins/acryl-node-server/tests/adapter/utils/stream.test.ts +0 -75
  165. package/plugins/acryl-node-server/tests/adapter/utils.test.ts +0 -235
  166. package/plugins/acryl-node-server/tests/adapter/websocket.test.ts +0 -260
  167. package/plugins/acryl-node-server/tests/server.spec.ts +0 -141
  168. package/plugins/acryl-router/src/core/app.test.ts +0 -3833
  169. package/plugins/acryl-router/src/core/client/client.test.ts +0 -2313
  170. package/plugins/acryl-router/src/core/client/types.test.ts +0 -149
  171. package/plugins/acryl-router/src/core/client/utils.test.ts +0 -405
  172. package/plugins/acryl-router/src/core/compose.test.ts +0 -751
  173. package/plugins/acryl-router/src/core/context.test.ts +0 -629
  174. package/plugins/acryl-router/src/core/helper/accepts/accepts.test.ts +0 -344
  175. package/plugins/acryl-router/src/core/helper/adapter/index.test.ts +0 -55
  176. package/plugins/acryl-router/src/core/helper/cookie/index.test.ts +0 -510
  177. package/plugins/acryl-router/src/core/helper/css/common.case.test.tsx +0 -506
  178. package/plugins/acryl-router/src/core/helper/css/index.test.tsx +0 -678
  179. package/plugins/acryl-router/src/core/helper/dev/index.test.ts +0 -181
  180. package/plugins/acryl-router/src/core/helper/factory/index.test.ts +0 -434
  181. package/plugins/acryl-router/src/core/helper/html/index.test.ts +0 -78
  182. package/plugins/acryl-router/src/core/helper/proxy/index.test.ts +0 -356
  183. package/plugins/acryl-router/src/core/helper/route/index.test.ts +0 -259
  184. package/plugins/acryl-router/src/core/helper/streaming/sse.test.tsx +0 -557
  185. package/plugins/acryl-router/src/core/helper/streaming/stream.test.ts +0 -128
  186. package/plugins/acryl-router/src/core/helper/streaming/text.test.ts +0 -34
  187. package/plugins/acryl-router/src/core/helper/testing/index.test.ts +0 -42
  188. package/plugins/acryl-router/src/core/helper/websocket/index.test.ts +0 -124
  189. package/plugins/acryl-router/src/core/http-exception.test.ts +0 -45
  190. package/plugins/acryl-router/src/core/jsx/base.test.tsx +0 -97
  191. package/plugins/acryl-router/src/core/jsx/children.test.ts +0 -52
  192. package/plugins/acryl-router/src/core/jsx/components.test.tsx +0 -936
  193. package/plugins/acryl-router/src/core/jsx/context-isolation.test.ts +0 -655
  194. package/plugins/acryl-router/src/core/jsx/dom/client.test.tsx +0 -128
  195. package/plugins/acryl-router/src/core/jsx/dom/components.test.tsx +0 -330
  196. package/plugins/acryl-router/src/core/jsx/dom/context.test.tsx +0 -184
  197. package/plugins/acryl-router/src/core/jsx/dom/css.test.tsx +0 -149
  198. package/plugins/acryl-router/src/core/jsx/dom/hooks/index.test.tsx +0 -172
  199. package/plugins/acryl-router/src/core/jsx/dom/index.test.tsx +0 -3681
  200. package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.test.tsx +0 -1344
  201. package/plugins/acryl-router/src/core/jsx/dom/server.test.tsx +0 -199
  202. package/plugins/acryl-router/src/core/jsx/hooks/dom.test.tsx +0 -859
  203. package/plugins/acryl-router/src/core/jsx/hooks/string.test.tsx +0 -40
  204. package/plugins/acryl-router/src/core/jsx/index.test.tsx +0 -1744
  205. package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.test.tsx +0 -666
  206. package/plugins/acryl-router/src/core/jsx/jsx-runtime.test.tsx +0 -85
  207. package/plugins/acryl-router/src/core/jsx/streaming.test.tsx +0 -1281
  208. package/plugins/acryl-router/src/core/jsx/utils.test.ts +0 -366
  209. package/plugins/acryl-router/src/core/middleware/basic-auth/index.test.ts +0 -434
  210. package/plugins/acryl-router/src/core/middleware/bearer-auth/index.test.ts +0 -1018
  211. package/plugins/acryl-router/src/core/middleware/body-limit/index.test.ts +0 -273
  212. package/plugins/acryl-router/src/core/middleware/cache/index.test.ts +0 -1211
  213. package/plugins/acryl-router/src/core/middleware/combine/index.test.ts +0 -355
  214. package/plugins/acryl-router/src/core/middleware/compress/index.test.ts +0 -535
  215. package/plugins/acryl-router/src/core/middleware/context-storage/index.test.ts +0 -43
  216. package/plugins/acryl-router/src/core/middleware/cors/index.test.ts +0 -532
  217. package/plugins/acryl-router/src/core/middleware/csrf/index.test.ts +0 -534
  218. package/plugins/acryl-router/src/core/middleware/etag/digest.test.ts +0 -21
  219. package/plugins/acryl-router/src/core/middleware/etag/index.test.ts +0 -503
  220. package/plugins/acryl-router/src/core/middleware/ip-restriction/index.test.ts +0 -217
  221. package/plugins/acryl-router/src/core/middleware/jwk/index.test.ts +0 -1135
  222. package/plugins/acryl-router/src/core/middleware/jwk/keys.test.json +0 -48
  223. package/plugins/acryl-router/src/core/middleware/jwt/index.test.ts +0 -802
  224. package/plugins/acryl-router/src/core/middleware/language/index.test.ts +0 -552
  225. package/plugins/acryl-router/src/core/middleware/logger/index.test.ts +0 -204
  226. package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.test.ts +0 -292
  227. package/plugins/acryl-router/src/core/middleware/method-override/index.test.ts +0 -221
  228. package/plugins/acryl-router/src/core/middleware/mount/index.test.ts +0 -334
  229. package/plugins/acryl-router/src/core/middleware/powered-by/index.test.ts +0 -37
  230. package/plugins/acryl-router/src/core/middleware/pretty-json/index.test.ts +0 -218
  231. package/plugins/acryl-router/src/core/middleware/request-id/index.test.ts +0 -168
  232. package/plugins/acryl-router/src/core/middleware/secure-headers/index.test.ts +0 -671
  233. package/plugins/acryl-router/src/core/middleware/serve-static/index.test.ts +0 -450
  234. package/plugins/acryl-router/src/core/middleware/serve-static/path.test.ts +0 -50
  235. package/plugins/acryl-router/src/core/middleware/timeout/index.test.ts +0 -70
  236. package/plugins/acryl-router/src/core/middleware/timing/index.test.ts +0 -310
  237. package/plugins/acryl-router/src/core/middleware/trailing-slash/index.test.ts +0 -381
  238. package/plugins/acryl-router/src/core/preset/quick.test.ts +0 -42
  239. package/plugins/acryl-router/src/core/preset/tiny.test.ts +0 -42
  240. package/plugins/acryl-router/src/core/request.test.ts +0 -751
  241. package/plugins/acryl-router/src/core/router/common.case.test.ts +0 -1132
  242. package/plugins/acryl-router/src/core/router/linear-router/router.test.ts +0 -80
  243. package/plugins/acryl-router/src/core/router/pattern-router/router.test.ts +0 -46
  244. package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.test.ts +0 -154
  245. package/plugins/acryl-router/src/core/router/reg-exp-router/router.test.ts +0 -265
  246. package/plugins/acryl-router/src/core/router/smart-router/router.test.ts +0 -13
  247. package/plugins/acryl-router/src/core/router/trie-router/node.test.ts +0 -896
  248. package/plugins/acryl-router/src/core/router/trie-router/router.test.ts +0 -8
  249. package/plugins/acryl-router/src/core/types.test.ts +0 -4134
  250. package/plugins/acryl-router/src/core/utils/accept.test.ts +0 -299
  251. package/plugins/acryl-router/src/core/utils/basic-auth.test.ts +0 -56
  252. package/plugins/acryl-router/src/core/utils/body.test.ts +0 -496
  253. package/plugins/acryl-router/src/core/utils/buffer.test.ts +0 -147
  254. package/plugins/acryl-router/src/core/utils/color.test.ts +0 -23
  255. package/plugins/acryl-router/src/core/utils/concurrent.test.ts +0 -69
  256. package/plugins/acryl-router/src/core/utils/cookie.test.ts +0 -460
  257. package/plugins/acryl-router/src/core/utils/crypto.test.ts +0 -43
  258. package/plugins/acryl-router/src/core/utils/encode.test.ts +0 -61
  259. package/plugins/acryl-router/src/core/utils/filepath.test.ts +0 -78
  260. package/plugins/acryl-router/src/core/utils/html.test.ts +0 -16
  261. package/plugins/acryl-router/src/core/utils/ipaddr.test.ts +0 -149
  262. package/plugins/acryl-router/src/core/utils/jwt/jwa.test.ts +0 -86
  263. package/plugins/acryl-router/src/core/utils/jwt/jwt.test.ts +0 -1788
  264. package/plugins/acryl-router/src/core/utils/mime.test.ts +0 -64
  265. package/plugins/acryl-router/src/core/utils/stream.test.ts +0 -212
  266. package/plugins/acryl-router/src/core/utils/types.test.ts +0 -295
  267. package/plugins/acryl-router/src/core/utils/url.test.ts +0 -384
  268. package/plugins/acryl-router/src/core/validator/utils.test.ts +0 -82
  269. package/plugins/acryl-router/src/core/validator/validator.test.ts +0 -1488
  270. package/plugins/acryl-router/tests/docs-examples.spec.ts +0 -152
  271. package/plugins/acryl-router/tests/jsx.spec.tsx +0 -63
  272. package/plugins/acryl-router/tests/live-install.spec.ts +0 -64
  273. package/plugins/acryl-router/tests/loader.spec.ts +0 -72
  274. package/plugins/acryl-router/tests/loopback-only.spec.ts +0 -80
  275. package/plugins/acryl-router/tests/no-dom/consumer.ts +0 -11
  276. package/plugins/acryl-router/tests/no-dom/tsconfig.json +0 -13
  277. package/plugins/acryl-router/tests/service.spec.ts +0 -426
  278. package/plugins/acryl-router/tests/shadow-state.spec.ts +0 -79
  279. package/plugins/acryl-router-http/tests/adapter.spec.ts +0 -174
  280. package/plugins/acryl-router-http/tests/stream.spec.ts +0 -133
  281. package/plugins/acryl-router-http/tests/surfaces.spec.ts +0 -101
  282. package/plugins/acryl-state/src/react.ts +0 -11
  283. package/plugins/acryl-state/tests/cell.spec.ts +0 -71
  284. package/plugins/acryl-state/tests/react.spec.ts +0 -39
  285. package/plugins/acryl-state/tests/service.spec.ts +0 -132
@@ -1,506 +0,0 @@
1
- /** @jsxImportSource ../../jsx */
2
- import type {
3
- Style as StyleComponent,
4
- css as cssHelper,
5
- keyframes as keyframesHelper,
6
- rawCssString as rawCssStringHelper,
7
- viewTransition as viewTransitionHelper,
8
- } from './index.ts'
9
-
10
- interface Support {
11
- nest: boolean
12
- }
13
- export const renderTest = (
14
- getEnv: () => {
15
- css: typeof cssHelper
16
- keyframes: typeof keyframesHelper
17
- viewTransition: typeof viewTransitionHelper
18
- rawCssString: typeof rawCssStringHelper
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- toString: (template: any) => Promise<string>
21
- Style: typeof StyleComponent
22
- support: Support
23
- }
24
- ) => {
25
- const { support } = getEnv()
26
-
27
- let css: typeof cssHelper
28
- let keyframes: typeof keyframesHelper
29
- let viewTransition: typeof viewTransitionHelper
30
- let rawCssString: typeof rawCssStringHelper
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- let toString: (template: any) => Promise<string>
33
- let Style: typeof StyleComponent
34
- beforeEach(() => {
35
- ;({ css, keyframes, viewTransition, rawCssString, toString, Style } = getEnv())
36
- })
37
-
38
- describe('render css', () => {
39
- it('Should render CSS styles with JSX', async () => {
40
- const headerClass = css`
41
- background-color: blue;
42
- `
43
- const template = (
44
- <>
45
- <Style />
46
- <h1 class={headerClass}>Hello!</h1>
47
- </>
48
- )
49
- expect(await toString(template)).toBe(
50
- '<style id="acryl-css">.css-2458908649{background-color:blue}</style><h1 class="css-2458908649">Hello!</h1>'
51
- )
52
- })
53
-
54
- it('Should render CSS with keyframes', async () => {
55
- const animation = keyframes`
56
- from {
57
- opacity: 0;
58
- }
59
- to {
60
- opacity: 1;
61
- }
62
- `
63
- const headerClass = css`
64
- background-color: blue;
65
- animation: ${animation} 1s ease-in-out;
66
- `
67
- const template = (
68
- <>
69
- <Style />
70
- <h1 class={headerClass}>Hello!</h1>
71
- </>
72
- )
73
- expect(await toString(template)).toBe(
74
- '<style id="acryl-css">.css-1580801783{background-color:blue;animation:css-9294673 1s ease-in-out}@keyframes css-9294673{from{opacity:0}to{opacity:1}}</style><h1 class="css-1580801783">Hello!</h1>'
75
- )
76
- })
77
-
78
- it('Should not output the same class name multiple times.', async () => {
79
- const headerClass = css`
80
- background-color: blue;
81
- `
82
- const headerClass2 = css`
83
- background-color: blue;
84
- `
85
- const template = (
86
- <>
87
- <Style />
88
- <h1 class={headerClass}>Hello!</h1>
89
- <h1 class={headerClass2}>Hello2!</h1>
90
- </>
91
- )
92
- expect(await toString(template)).toBe(
93
- '<style id="acryl-css">.css-2458908649{background-color:blue}</style><h1 class="css-2458908649">Hello!</h1><h1 class="css-2458908649">Hello2!</h1>'
94
- )
95
- })
96
-
97
- it('Should render CSS with variable', async () => {
98
- const headerClass = css`
99
- background-color: blue;
100
- content: '${"I'm a variable!"}';
101
- `
102
- const template = (
103
- <>
104
- <Style />
105
- <h1 class={headerClass}>Hello!</h1>
106
- </>
107
- )
108
- expect(await toString(template)).toBe(
109
- '<style id="acryl-css">.css-4027435072{background-color:blue;content:\'I\\\'m a variable!\'}</style><h1 class="css-4027435072">Hello!</h1>'
110
- )
111
- })
112
-
113
- it('Should escape </style>', async () => {
114
- const headerClass = css`
115
- background-color: blue;
116
- content: '${'</style>'}';
117
- `
118
- const template = (
119
- <>
120
- <Style />
121
- <h1 class={headerClass}>Hello!</h1>
122
- </>
123
- )
124
- expect(await toString(template)).toBe(
125
- '<style id="acryl-css">.css-372954897{background-color:blue;content:\'<\\/style>\'}</style><h1 class="css-372954897">Hello!</h1>'
126
- )
127
- })
128
-
129
- it('Should not escape URL', async () => {
130
- const headerClass = css`
131
- background-color: blue;
132
- background: url('${'http://www.example.com/path/to/file.jpg'}');
133
- `
134
- const template = (
135
- <>
136
- <Style />
137
- <h1 class={headerClass}>Hello!</h1>
138
- </>
139
- )
140
- expect(await toString(template)).toBe(
141
- '<style id="acryl-css">.css-1321888780{background-color:blue;background:url(\'http://www.example.com/path/to/file.jpg\')}</style><h1 class="css-1321888780">Hello!</h1>'
142
- )
143
- })
144
-
145
- it('Should render CSS with escaped variable', async () => {
146
- const headerClass = css`
147
- background-color: blue;
148
- content: '${rawCssString('say "Hello!"')}';
149
- `
150
- const template = (
151
- <>
152
- <Style />
153
- <h1 class={headerClass}>Hello!</h1>
154
- </>
155
- )
156
- expect(await toString(template)).toBe(
157
- '<style id="acryl-css">.css-2238574885{background-color:blue;content:\'say "Hello!"\'}</style><h1 class="css-2238574885">Hello!</h1>'
158
- )
159
- })
160
-
161
- it('Should render CSS with number', async () => {
162
- const headerClass = css`
163
- background-color: blue;
164
- font-size: ${1}rem;
165
- `
166
- const template = (
167
- <>
168
- <Style />
169
- <h1 class={headerClass}>Hello!</h1>
170
- </>
171
- )
172
- expect(await toString(template)).toBe(
173
- '<style id="acryl-css">.css-1847536026{background-color:blue;font-size:1rem}</style><h1 class="css-1847536026">Hello!</h1>'
174
- )
175
- })
176
-
177
- it('Should render CSS with array', async () => {
178
- const animation = keyframes`
179
- from {
180
- opacity: 0;
181
- }
182
- to {
183
- opacity: 1;
184
- }
185
- `
186
- const headerClass = css`
187
- background-color: blue;
188
- animation: ${animation} 1s ease-in-out;
189
- `
190
- const extendedHeaderClass = css`
191
- ${headerClass}
192
- color: red;
193
- `
194
- const template = (
195
- <>
196
- <Style />
197
- <h1 class={extendedHeaderClass}>Hello!</h1>
198
- </>
199
- )
200
- expect(await toString(template)).toBe(
201
- '<style id="acryl-css">.css-2558359670{background-color:blue;animation:css-9294673 1s ease-in-out;color:red}@keyframes css-9294673{from{opacity:0}to{opacity:1}}</style><h1 class="css-2558359670">Hello!</h1>'
202
- )
203
- })
204
-
205
- it.runIf(support.nest)(
206
- 'Should be used as a class name for syntax `${className} {`',
207
- async () => {
208
- const headerClass = css`
209
- font-weight: bold;
210
- `
211
- const containerClass = css`
212
- ${headerClass} {
213
- h1 {
214
- color: red;
215
- }
216
- }
217
- `
218
- const template = (
219
- <>
220
- <Style />
221
- <div class={containerClass}>
222
- <h1 class={headerClass}>Hello!</h1>
223
- </div>
224
- </>
225
- )
226
- expect(await toString(template)).toBe(
227
- '<style id="acryl-css">.css-4220297002{.css-1032195302{h1{color:red}}}.css-1032195302{font-weight:bold}</style><div class="css-4220297002"><h1 class="css-1032195302">Hello!</h1></div>'
228
- )
229
- }
230
- )
231
-
232
- it('Should be inserted to global if style string starts with :-acryl-root', async () => {
233
- const globalClass = css`
234
- :-acryl-global {
235
- html {
236
- color: red;
237
- }
238
- body {
239
- display: flex;
240
- }
241
- }
242
- `
243
- const template = (
244
- <>
245
- <Style />
246
- <div class={globalClass}>
247
- <h1>Hello!</h1>
248
- </div>
249
- </>
250
- )
251
- expect(await toString(template)).toBe(
252
- '<style id="acryl-css">html{color:red}body{display:flex}</style><div class=""><h1>Hello!</h1></div>'
253
- )
254
- })
255
-
256
- it.runIf(support.nest)(
257
- 'Should be inserted to global if style string starts with :-acryl-root and extends class name',
258
- async () => {
259
- const headerClass = css`
260
- display: flex;
261
- `
262
- const specialHeaderClass = css`
263
- :-acryl-global {
264
- ${headerClass} {
265
- h1 {
266
- color: red;
267
- }
268
- }
269
- }
270
- `
271
- const template = (
272
- <>
273
- <Style />
274
- <div class={specialHeaderClass}>
275
- <h1>Hello!</h1>
276
- </div>
277
- </>
278
- )
279
- expect(await toString(template)).toBe(
280
- '<style id="acryl-css">.css-3980466870{h1{color:red}}.css-3980466870{display:flex}</style><div class="css-3980466870"><h1>Hello!</h1></div>'
281
- )
282
- }
283
- )
284
-
285
- it('Should be inserted as global css if passed css`` to Style component', async () => {
286
- const headerClass = css`
287
- font-size: 1rem;
288
- `
289
- const template = (
290
- <>
291
- <Style>{css`
292
- html {
293
- color: red;
294
- }
295
- body {
296
- display: flex;
297
- }
298
- `}</Style>
299
- <div>
300
- <h1 class={headerClass}>Hello!</h1>
301
- </div>
302
- </>
303
- )
304
- expect(await toString(template)).toBe(
305
- '<style id="acryl-css">html{color:red}body{display:flex}.css-1740067317{font-size:1rem}</style><div><h1 class="css-1740067317">Hello!</h1></div>'
306
- )
307
- })
308
-
309
- it('Should be ignored :-acryl-root inside Style component', async () => {
310
- const headerClass = css`
311
- font-size: 1rem;
312
- `
313
- const template = (
314
- <>
315
- <Style>{css`
316
- :-acryl-global {
317
- html {
318
- color: red;
319
- }
320
- body {
321
- display: flex;
322
- }
323
- }
324
- `}</Style>
325
- <div>
326
- <h1 class={headerClass}>Hello!</h1>
327
- </div>
328
- </>
329
- )
330
- expect(await toString(template)).toBe(
331
- '<style id="acryl-css">html{color:red}body{display:flex}.css-1740067317{font-size:1rem}</style><div><h1 class="css-1740067317">Hello!</h1></div>'
332
- )
333
- })
334
-
335
- describe('viewTransition', () => {
336
- it('Should render CSS with unique view-transition-name', async () => {
337
- const transition = viewTransition()
338
- const template = (
339
- <>
340
- <Style />
341
- <h1 class={transition}>Hello!</h1>
342
- </>
343
- )
344
- expect(await toString(template)).toBe(
345
- '<style id="acryl-css">.css-1644952339{view-transition-name:css-1644952339}</style><h1 class="css-1644952339">Hello!</h1>'
346
- )
347
- })
348
-
349
- it('Should render CSS with css and keyframes', async () => {
350
- const kf = keyframes`
351
- from {
352
- opacity: 0;
353
- }
354
- to {
355
- opacity: 1;
356
- }
357
- `
358
- const transition = viewTransition(css`
359
- ::view-transition-old() {
360
- animation-name: ${kf};
361
- }
362
- ::view-transition-new() {
363
- animation-name: ${kf};
364
- }
365
- `)
366
- const headerClass = css`
367
- ${transition}
368
- background-color: blue;
369
- `
370
- const template = (
371
- <>
372
- <Style />
373
- <h1 class={headerClass}>Hello!</h1>
374
- </>
375
- )
376
- expect(await toString(template)).toBe(
377
- '<style id="acryl-css">.css-1245070278{view-transition-name:css-399742870;background-color:blue}@keyframes css-9294673{from{opacity:0}to{opacity:1}}::view-transition-old(css-399742870){animation-name:css-9294673}::view-transition-new(css-399742870){animation-name:css-9294673}</style><h1 class="css-1245070278">Hello!</h1>'
378
- )
379
- })
380
-
381
- it('Should works as a template tag function', async () => {
382
- const kf = keyframes`
383
- from {
384
- opacity: 0;
385
- }
386
- to {
387
- opacity: 1;
388
- }
389
- `
390
- const transition = viewTransition`
391
- ::view-transition-old() {
392
- animation-name: ${kf};
393
- }
394
- ::view-transition-new() {
395
- animation-name: ${kf};
396
- }
397
- `
398
- const headerClass = css`
399
- ${transition}
400
- background-color: blue;
401
- `
402
- const template = (
403
- <>
404
- <Style />
405
- <h1 class={headerClass}>Hello!</h1>
406
- </>
407
- )
408
- expect(await toString(template)).toBe(
409
- '<style id="acryl-css">.css-1245070278{view-transition-name:css-399742870;background-color:blue}@keyframes css-9294673{from{opacity:0}to{opacity:1}}::view-transition-old(css-399742870){animation-name:css-9294673}::view-transition-new(css-399742870){animation-name:css-9294673}</style><h1 class="css-1245070278">Hello!</h1>'
410
- )
411
- })
412
- })
413
-
414
- it.runIf(support.nest)('Should render sub CSS with keyframe', async () => {
415
- const headerClass = css`
416
- background-color: blue;
417
- ${[1, 2].map(
418
- (i) => css`
419
- :nth-child(${i}) {
420
- color: red;
421
- }
422
- `
423
- )}
424
- `
425
- const template = (
426
- <>
427
- <Style />
428
- <h1 class={headerClass}>Hello!</h1>
429
- </>
430
- )
431
- expect(await toString(template)).toBe(
432
- '<style id="acryl-css">.css-1539881271{background-color:blue;:nth-child(1){color:red}:nth-child(2){color:red}}</style><h1 class="css-1539881271">Hello!</h1>'
433
- )
434
- })
435
-
436
- it('Should be generated deferent class name for deferent first line comment even if the content is the same', async () => {
437
- const headerClassA = css`
438
- /* class A */
439
- display: flex;
440
- `
441
- const headerClassB = css`
442
- /* class B */
443
- display: flex;
444
- `
445
- const template = (
446
- <>
447
- <Style />
448
- <h1 class={headerClassA}>Hello!</h1>
449
- <h1 class={headerClassB}>Hello!</h1>
450
- </>
451
- )
452
- expect(await toString(template)).toBe(
453
- '<style id="acryl-css">.css-3170754153{display:flex}.css-896513246{display:flex}</style><h1 class="css-3170754153">Hello!</h1><h1 class="css-896513246">Hello!</h1>'
454
- )
455
- })
456
-
457
- describe('Booleans, Null, and Undefined Are Ignored', () => {
458
- it.each([true, false, undefined, null])('%s', async (value) => {
459
- const headerClass = css`
460
- ${value}
461
- background-color: blue;
462
- `
463
- const template = (
464
- <>
465
- <Style />
466
- <h1 class={headerClass}>Hello!</h1>
467
- </>
468
- )
469
- expect(await toString(template)).toBe(
470
- '<style id="acryl-css">.css-2458908649{background-color:blue}</style><h1 class="css-2458908649">Hello!</h1>'
471
- )
472
- })
473
-
474
- it('falsy value', async () => {
475
- const value = 0
476
- const headerClass = css`
477
- padding: ${value};
478
- `
479
- const template = (
480
- <>
481
- <Style />
482
- <h1 class={headerClass}>Hello!</h1>
483
- </>
484
- )
485
- expect(await toString(template)).toBe(
486
- '<style id="acryl-css">.css-478287868{padding:0}</style><h1 class="css-478287868">Hello!</h1>'
487
- )
488
- })
489
-
490
- it('Should render CSS styles with CSP nonce', async () => {
491
- const headerClass = css`
492
- background-color: blue;
493
- `
494
- const template = (
495
- <>
496
- <Style nonce='1234' />
497
- <h1 class={headerClass}>Hello!</h1>
498
- </>
499
- )
500
- expect(await toString(template)).toBe(
501
- '<style id="acryl-css" nonce="1234">.css-2458908649{background-color:blue}</style><h1 class="css-2458908649">Hello!</h1>'
502
- )
503
- })
504
- })
505
- })
506
- }