@acryldev/create-blends 1.7.0 → 1.7.1

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 (98) hide show
  1. package/{docs/framework/LICENSE → LICENSE} +1 -3
  2. package/package.json +2 -2
  3. package/docs/framework/README.md +0 -70
  4. package/docs/framework/agents/index.md +0 -59
  5. package/docs/framework/api/acryl.md +0 -247
  6. package/docs/framework/api/context.md +0 -478
  7. package/docs/framework/api/exception.md +0 -80
  8. package/docs/framework/api/index.md +0 -12
  9. package/docs/framework/api/presets.md +0 -62
  10. package/docs/framework/api/request.md +0 -396
  11. package/docs/framework/api/routing.md +0 -303
  12. package/docs/framework/api/summary.md +0 -143
  13. package/docs/framework/concepts/benchmarks.md +0 -26
  14. package/docs/framework/concepts/developer-experience.md +0 -5
  15. package/docs/framework/concepts/middleware.md +0 -21
  16. package/docs/framework/concepts/motivation.md +0 -14
  17. package/docs/framework/concepts/routers.md +0 -63
  18. package/docs/framework/concepts/stacks.md +0 -235
  19. package/docs/framework/concepts/web-standard.md +0 -27
  20. package/docs/framework/cordis/acryl-in-a-cordis-app.md +0 -160
  21. package/docs/framework/cordis/concepts.md +0 -105
  22. package/docs/framework/cordis/middleware.md +0 -8
  23. package/docs/framework/cordis/migration-from-0-3.md +0 -111
  24. package/docs/framework/cordis/migration-from-0-4.md +0 -14
  25. package/docs/framework/cordis/migration-from-dsh-webserver.md +0 -109
  26. package/docs/framework/cordis/migration-to-1-0.md +0 -46
  27. package/docs/framework/cordis/mounting.md +0 -85
  28. package/docs/framework/cordis/node-server.md +0 -100
  29. package/docs/framework/cordis/plugin-lifecycle.md +0 -111
  30. package/docs/framework/cordis/surfaces.md +0 -71
  31. package/docs/framework/cordis/transport-and-cancellation.md +0 -57
  32. package/docs/framework/cordis/validation.md +0 -135
  33. package/docs/framework/getting-started/basic.md +0 -201
  34. package/docs/framework/getting-started/bun.md +0 -219
  35. package/docs/framework/getting-started/deploy.md +0 -133
  36. package/docs/framework/getting-started/desktop.md +0 -80
  37. package/docs/framework/getting-started/nodejs.md +0 -365
  38. package/docs/framework/getting-started/other-runtimes.md +0 -30
  39. package/docs/framework/guides/best-practices.md +0 -231
  40. package/docs/framework/guides/bring-your-own-tool.md +0 -218
  41. package/docs/framework/guides/client-modules.md +0 -210
  42. package/docs/framework/guides/create-acrylblends.md +0 -143
  43. package/docs/framework/guides/data.md +0 -314
  44. package/docs/framework/guides/examples.md +0 -3
  45. package/docs/framework/guides/faq.md +0 -19
  46. package/docs/framework/guides/forms-and-sessions.md +0 -235
  47. package/docs/framework/guides/helpers.md +0 -33
  48. package/docs/framework/guides/jsx-dom.md +0 -301
  49. package/docs/framework/guides/jsx.md +0 -487
  50. package/docs/framework/guides/middleware.md +0 -253
  51. package/docs/framework/guides/production.md +0 -80
  52. package/docs/framework/guides/rpc.md +0 -878
  53. package/docs/framework/guides/testing.md +0 -133
  54. package/docs/framework/guides/validation.md +0 -470
  55. package/docs/framework/helpers/accepts.md +0 -60
  56. package/docs/framework/helpers/adapter.md +0 -57
  57. package/docs/framework/helpers/conninfo.md +0 -77
  58. package/docs/framework/helpers/cookie.md +0 -232
  59. package/docs/framework/helpers/css.md +0 -282
  60. package/docs/framework/helpers/dev.md +0 -64
  61. package/docs/framework/helpers/factory.md +0 -180
  62. package/docs/framework/helpers/html.md +0 -123
  63. package/docs/framework/helpers/jwt.md +0 -184
  64. package/docs/framework/helpers/proxy.md +0 -115
  65. package/docs/framework/helpers/route.md +0 -143
  66. package/docs/framework/helpers/ssg.md +0 -390
  67. package/docs/framework/helpers/streaming.md +0 -224
  68. package/docs/framework/helpers/testing.md +0 -118
  69. package/docs/framework/helpers/websocket.md +0 -208
  70. package/docs/framework/middleware/builtin/basic-auth.md +0 -165
  71. package/docs/framework/middleware/builtin/bearer-auth.md +0 -138
  72. package/docs/framework/middleware/builtin/body-limit.md +0 -71
  73. package/docs/framework/middleware/builtin/cache.md +0 -99
  74. package/docs/framework/middleware/builtin/combine.md +0 -94
  75. package/docs/framework/middleware/builtin/compress.md +0 -59
  76. package/docs/framework/middleware/builtin/context-storage.md +0 -74
  77. package/docs/framework/middleware/builtin/cors.md +0 -134
  78. package/docs/framework/middleware/builtin/csrf.md +0 -105
  79. package/docs/framework/middleware/builtin/etag.md +0 -54
  80. package/docs/framework/middleware/builtin/ip-restriction.md +0 -69
  81. package/docs/framework/middleware/builtin/jsx-renderer.md +0 -283
  82. package/docs/framework/middleware/builtin/jwk.md +0 -192
  83. package/docs/framework/middleware/builtin/jwt.md +0 -145
  84. package/docs/framework/middleware/builtin/language.md +0 -232
  85. package/docs/framework/middleware/builtin/logger.md +0 -74
  86. package/docs/framework/middleware/builtin/loopback-only.md +0 -31
  87. package/docs/framework/middleware/builtin/method-not-allowed.md +0 -48
  88. package/docs/framework/middleware/builtin/method-override.md +0 -80
  89. package/docs/framework/middleware/builtin/mount.md +0 -103
  90. package/docs/framework/middleware/builtin/pretty-json.md +0 -53
  91. package/docs/framework/middleware/builtin/request-id.md +0 -87
  92. package/docs/framework/middleware/builtin/secure-headers.md +0 -247
  93. package/docs/framework/middleware/builtin/timeout.md +0 -98
  94. package/docs/framework/middleware/builtin/timing.md +0 -100
  95. package/docs/framework/middleware/builtin/trailing-slash.md +0 -74
  96. package/docs/framework/middleware/third-party.md +0 -4
  97. package/docs/framework/workshop/README.md +0 -294
  98. package/docs/framework/workshop/facilitator.md +0 -101
@@ -1,301 +0,0 @@
1
- # Client Components
2
-
3
- `acrylblends/jsx` supports not only server side but also client side. This means that it is possible to create an interactive UI that runs in the browser. We call it Client Components or `acrylblends/jsx/dom`.
4
-
5
- It is small and imports nothing. Measured with Node's `zlib.brotliCompressSync` at the highest quality: the whole runtime as
6
- [`clientModules`](client-modules.md) serves it (`jsx-dom.js`, not minified) is 11,209 bytes with Brotli compression, and the counter
7
- below, bundled and minified with tsdown so only the parts it uses are kept, is 5,804 bytes.
8
-
9
- This section introduces Client Components-specific features.
10
-
11
- ## Counter example
12
-
13
- Here is an example of a simple counter, the same code works as in React.
14
-
15
- ```tsx
16
- import { useState } from '@acryldev/blends/jsx'
17
- import { render } from '@acryldev/blends/jsx/dom'
18
-
19
- function Counter() {
20
- const [count, setCount] = useState(0)
21
- return (
22
- <div>
23
- <p>Count: {count}</p>
24
- <button onClick={() => setCount(count + 1)}>Increment</button>
25
- </div>
26
- )
27
- }
28
-
29
- function App() {
30
- return (
31
- <html>
32
- <body>
33
- <Counter />
34
- </body>
35
- </html>
36
- )
37
- }
38
-
39
- const root = document.getElementById('root')
40
- render(<App />, root)
41
- ```
42
-
43
- ## `render()`
44
-
45
- You can use `render()` to insert JSX components within a specified HTML element.
46
-
47
- ```tsx
48
- render(<Component />, container)
49
- ```
50
-
51
- You can see full example code here: Counter example.
52
-
53
- ## Hooks compatible with React
54
-
55
- acrylblends/jsx/dom has Hooks that are compatible or partially compatible with React. You can learn about these APIs by looking at [the React documentation](https://react.dev/reference/react/hooks).
56
-
57
- - `useState()`
58
- - `useEffect()`
59
- - `useRef()`
60
- - `useCallback()`
61
- - `use()`
62
- - `startTransition()`
63
- - `useTransition()`
64
- - `useDeferredValue()`
65
- - `useMemo()`
66
- - `useLayoutEffect()`
67
- - `useReducer()`
68
- - `useDebugValue()`
69
- - `createElement()`
70
- - `memo()`
71
- - `isValidElement()`
72
- - `useId()`
73
- - `createRef()`
74
- - `forwardRef()`
75
- - `useImperativeHandle()`
76
- - `useSyncExternalStore()`
77
- - `useInsertionEffect()`
78
- - `useFormStatus()`
79
- - `useActionState()`
80
- - `useOptimistic()`
81
-
82
- ## `startViewTransition()` family
83
-
84
- The `startViewTransition()` family contains original hooks and functions to handle [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) easily. The examples below demonstrate how to use them.
85
-
86
- ### 1. A very simple example
87
-
88
- You can write a transition using the `document.startViewTransition` shortly with the `startViewTransition()`.
89
-
90
- ```tsx
91
- import { useState, startViewTransition } from '@acryldev/blends/jsx'
92
- import { css, Style } from '@acryldev/blends/css'
93
-
94
- export default function App() {
95
- const [showLargeImage, setShowLargeImage] = useState(false)
96
- return (
97
- <>
98
- <Style />
99
- <button
100
- onClick={() =>
101
- startViewTransition(() =>
102
- setShowLargeImage((state) => !state)
103
- )
104
- }
105
- >
106
- Click!
107
- </button>
108
- <div>
109
- {!showLargeImage ? (
110
- <img src="/photo.jpg" alt="" />
111
- ) : (
112
- <div
113
- class={css`
114
- background: url('/photo.jpg');
115
- background-size: contain;
116
- background-repeat: no-repeat;
117
- background-position: center;
118
- width: 600px;
119
- height: 600px;
120
- `}
121
- ></div>
122
- )}
123
- </div>
124
- </>
125
- )
126
- }
127
- ```
128
-
129
- ### 2. Using `viewTransition()` with `keyframes()`
130
-
131
- The `viewTransition()` function allows you to get the unique `view-transition-name`.
132
-
133
- You can use it with the `keyframes()`, The `::view-transition-old()` is converted to `::view-transition-old(${uniqueName))`.
134
-
135
- ```tsx
136
- import { useState, startViewTransition } from '@acryldev/blends/jsx'
137
- import { viewTransition } from '@acryldev/blends/jsx/dom/css'
138
- import { css, keyframes, Style } from '@acryldev/blends/css'
139
-
140
- const rotate = keyframes`
141
- from {
142
- rotate: 0deg;
143
- }
144
- to {
145
- rotate: 360deg;
146
- }
147
- `
148
-
149
- export default function App() {
150
- const [showLargeImage, setShowLargeImage] = useState(false)
151
- const [transitionNameClass] = useState(() =>
152
- viewTransition(css`
153
- ::view-transition-old() {
154
- animation-name: ${rotate};
155
- }
156
- ::view-transition-new() {
157
- animation-name: ${rotate};
158
- }
159
- `)
160
- )
161
- return (
162
- <>
163
- <Style />
164
- <button
165
- onClick={() =>
166
- startViewTransition(() =>
167
- setShowLargeImage((state) => !state)
168
- )
169
- }
170
- >
171
- Click!
172
- </button>
173
- <div>
174
- {!showLargeImage ? (
175
- <img src="/photo.jpg" alt="" />
176
- ) : (
177
- <div
178
- class={css`
179
- ${transitionNameClass}
180
- background: url('/photo.jpg');
181
- background-size: contain;
182
- background-repeat: no-repeat;
183
- background-position: center;
184
- width: 600px;
185
- height: 600px;
186
- `}
187
- ></div>
188
- )}
189
- </div>
190
- </>
191
- )
192
- }
193
- ```
194
-
195
- ### 3. Using `useViewTransition`
196
-
197
- If you want to change the style only during the animation. You can use `useViewTransition()`. This hook returns the `[boolean, (callback: () => void) => void]`, and they are the `isUpdating` flag and the `startViewTransition()` function.
198
-
199
- When this hook is used, the Component is evaluated at the following two times.
200
-
201
- - Inside the callback of a call to `startViewTransition()`.
202
- - When [the `finish` promise becomes fulfilled](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/finished)
203
-
204
- ```tsx
205
- import { useState, useViewTransition } from '@acryldev/blends/jsx'
206
- import { viewTransition } from '@acryldev/blends/jsx/dom/css'
207
- import { css, keyframes, Style } from '@acryldev/blends/css'
208
-
209
- const rotate = keyframes`
210
- from {
211
- rotate: 0deg;
212
- }
213
- to {
214
- rotate: 360deg;
215
- }
216
- `
217
-
218
- export default function App() {
219
- const [isUpdating, startViewTransition] = useViewTransition()
220
- const [showLargeImage, setShowLargeImage] = useState(false)
221
- const [transitionNameClass] = useState(() =>
222
- viewTransition(css`
223
- ::view-transition-old() {
224
- animation-name: ${rotate};
225
- }
226
- ::view-transition-new() {
227
- animation-name: ${rotate};
228
- }
229
- `)
230
- )
231
- return (
232
- <>
233
- <Style />
234
- <button
235
- onClick={() =>
236
- startViewTransition(() =>
237
- setShowLargeImage((state) => !state)
238
- )
239
- }
240
- >
241
- Click!
242
- </button>
243
- <div>
244
- {!showLargeImage ? (
245
- <img src="/photo.jpg" alt="" />
246
- ) : (
247
- <div
248
- class={css`
249
- ${transitionNameClass}
250
- background: url('/photo.jpg');
251
- background-size: contain;
252
- background-repeat: no-repeat;
253
- background-position: center;
254
- width: 600px;
255
- height: 600px;
256
- position: relative;
257
- ${isUpdating &&
258
- css`
259
- &:before {
260
- content: 'Loading...';
261
- position: absolute;
262
- top: 50%;
263
- left: 50%;
264
- }
265
- `}
266
- `}
267
- ></div>
268
- )}
269
- </div>
270
- </>
271
- )
272
- }
273
- ```
274
-
275
- ## The `acrylblends/jsx/dom` runtime
276
-
277
- On Node you can skip the bundler: [Client components without a bundler](client-modules.md) serves `.tsx` client modules to the browser with
278
- this runtime and one script tag, in development and in production.
279
-
280
- There is a small JSX Runtime for Client Components. Using this will result in smaller bundled results than using `acrylblends/jsx`. Specify `acrylblends/jsx/dom` in `tsconfig.json`.
281
-
282
- ```json
283
- {
284
- "compilerOptions": {
285
- "jsx": "react-jsx",
286
- "jsxImportSource": "@acryldev/blends/jsx/dom"
287
- }
288
- }
289
- ```
290
-
291
- Alternatively, you can specify `acrylblends/jsx/dom` in the esbuild transform options in `vite.config.ts`.
292
-
293
- ```ts
294
- import { defineConfig } from 'vite'
295
-
296
- export default defineConfig({
297
- esbuild: {
298
- jsxImportSource: '@acryldev/blends/jsx/dom',
299
- },
300
- })
301
- ```