@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.20

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 (124) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +5065 -0
  3. package/dist/server.js +1757 -355
  4. package/dist/{server.cjs → server.observe.js} +1951 -558
  5. package/dist/{dev.cjs → web.dev.js} +945 -550
  6. package/dist/web.js +635 -332
  7. package/dist/{dev.js → web.observe.js} +688 -403
  8. package/frames/dist/assets.js +92 -0
  9. package/frames/dist/client.dev.js +1296 -1198
  10. package/frames/dist/client.js +1128 -1191
  11. package/frames/dist/client.observe.js +2041 -0
  12. package/frames/dist/regions.js +171 -0
  13. package/frames/dist/server.dev.js +2549 -0
  14. package/frames/dist/server.js +1688 -3005
  15. package/frames/dist/server.observe.js +2548 -0
  16. package/frames/dist/trace.js +45 -0
  17. package/frames/dist/wire.js +594 -0
  18. package/frames/package.json +2 -25
  19. package/package.json +244 -256
  20. package/performance-tracks/dist/performance-tracks.dev.js +679 -0
  21. package/performance-tracks/dist/performance-tracks.js +6 -0
  22. package/performance-tracks/dist/performance-tracks.observe.js +667 -0
  23. package/performance-tracks/package.json +7 -0
  24. package/performance-tracks/types/index.d.ts +69 -0
  25. package/serialization/decode/package.json +2 -15
  26. package/serialization/dist/decode.js +121 -25
  27. package/serialization/dist/serialization.js +242 -88
  28. package/serialization/package.json +2 -15
  29. package/serialization/types/index.d.ts +85 -158
  30. package/serialization/types/serializer-decode.d.ts +173 -114
  31. package/serialization/types/serializer.d.ts +109 -0
  32. package/server-functions/dist/client.dev.js +1462 -0
  33. package/server-functions/dist/client.js +667 -165
  34. package/server-functions/dist/client.observe.js +1441 -0
  35. package/server-functions/dist/rich-args.js +84 -1
  36. package/server-functions/dist/server.dev.js +2714 -297
  37. package/server-functions/dist/server.js +2595 -271
  38. package/server-functions/dist/server.observe.js +3594 -0
  39. package/server-functions/package.json +2 -35
  40. package/server-functions/rich-args/package.json +2 -15
  41. package/skills/server-components/SKILL.md +117 -0
  42. package/storage/package.json +2 -15
  43. package/types/client.d.ts +342 -288
  44. package/types/constants.d.ts +22 -0
  45. package/types/cookies.d.ts +32 -84
  46. package/types/diagnostics.d.ts +80 -0
  47. package/types/frames/assets-tier.d.ts +78 -0
  48. package/types/frames/client.d.ts +40 -1
  49. package/types/frames/frame-client.d.ts +443 -280
  50. package/types/frames/frame-container-plugin.d.ts +64 -0
  51. package/types/frames/frame-morph.d.ts +29 -0
  52. package/types/frames/frame-sink.d.ts +141 -161
  53. package/types/frames/frame-transport.d.ts +263 -184
  54. package/types/frames/regions-tier.d.ts +60 -0
  55. package/types/frames/serializer-decode.d.ts +241 -0
  56. package/types/frames/serializer.d.ts +85 -158
  57. package/types/frames/server.d.ts +2 -2
  58. package/types/frames/trace-tier.d.ts +2 -0
  59. package/types/frames/tree-rewrite.d.ts +39 -0
  60. package/types/frames/wire-tier.d.ts +169 -0
  61. package/types/head.d.ts +20 -0
  62. package/types/index.d.ts +98 -81
  63. package/types/index.server.d.ts +159 -0
  64. package/types/jsx.d.ts +49 -44
  65. package/types/observe.d.ts +535 -0
  66. package/types/reconcile.d.ts +1 -0
  67. package/types/render.d.ts +11 -0
  68. package/types/request-error-hook.d.ts +5 -0
  69. package/types/response.d.ts +95 -147
  70. package/types/serializer-decode.d.ts +173 -114
  71. package/types/serializer.d.ts +85 -158
  72. package/types/server-functions/argument-codec.d.ts +30 -0
  73. package/types/server-functions/client.d.ts +238 -223
  74. package/types/server-functions/flash.d.ts +28 -30
  75. package/types/server-functions/registry.d.ts +105 -0
  76. package/types/server-functions/rich-args.d.ts +1 -10
  77. package/types/server-functions/server.d.ts +539 -531
  78. package/types/server-functions/shared.d.ts +398 -425
  79. package/types/server-functions/uploads.d.ts +50 -0
  80. package/types/server-mock.d.ts +120 -13
  81. package/types/server-observe.d.ts +86 -0
  82. package/types/server.d.ts +571 -422
  83. package/types/trace.d.ts +127 -0
  84. package/LICENSE +0 -21
  85. package/dist/web.cjs +0 -2033
  86. package/frames/dist/client.cjs +0 -2002
  87. package/frames/dist/client.dev.cjs +0 -2022
  88. package/frames/dist/server.cjs +0 -3877
  89. package/serialization/dist/decode.cjs +0 -139
  90. package/serialization/dist/serialization.cjs +0 -261
  91. package/serialization/types-cjs/index.d.cts +0 -182
  92. package/serialization/types-cjs/package.json +0 -3
  93. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  94. package/server-functions/dist/client.cjs +0 -834
  95. package/server-functions/dist/rich-args.cjs +0 -11
  96. package/server-functions/dist/server.cjs +0 -1242
  97. package/server-functions/dist/server.dev.cjs +0 -1242
  98. package/storage/dist/storage.cjs +0 -12
  99. package/storage/types-cjs/index.d.cts +0 -28
  100. package/storage/types-cjs/package.json +0 -3
  101. package/types/core.d.ts +0 -9
  102. package/types-cjs/client.d.cts +0 -337
  103. package/types-cjs/cookies.d.cts +0 -93
  104. package/types-cjs/core.d.cts +0 -9
  105. package/types-cjs/frames/client.d.cts +0 -36
  106. package/types-cjs/frames/frame-client.d.cts +0 -356
  107. package/types-cjs/frames/frame-sink.d.cts +0 -194
  108. package/types-cjs/frames/frame-transport.d.cts +0 -222
  109. package/types-cjs/frames/serializer.d.cts +0 -182
  110. package/types-cjs/frames/server.d.cts +0 -52
  111. package/types-cjs/index.d.cts +0 -244
  112. package/types-cjs/jsx-properties.d.cts +0 -93
  113. package/types-cjs/jsx.d.cts +0 -4159
  114. package/types-cjs/package.json +0 -3
  115. package/types-cjs/response.d.cts +0 -174
  116. package/types-cjs/serializer-decode.d.cts +0 -182
  117. package/types-cjs/serializer.d.cts +0 -182
  118. package/types-cjs/server-functions/client.d.cts +0 -262
  119. package/types-cjs/server-functions/flash.d.cts +0 -38
  120. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  121. package/types-cjs/server-functions/server.d.cts +0 -681
  122. package/types-cjs/server-functions/shared.d.cts +0 -523
  123. package/types-cjs/server-mock.d.cts +0 -286
  124. package/types-cjs/server.d.cts +0 -544
@@ -1,40 +1,7 @@
1
1
  {
2
- "name": "@solidjs/web/server-functions",
3
- "main": "./dist/server.cjs",
2
+ "main": "./dist/server.js",
4
3
  "module": "./dist/server.js",
5
4
  "types": "../types/server-functions/server.d.ts",
6
5
  "type": "module",
7
- "sideEffects": false,
8
- "exports": {
9
- ".": {
10
- "browser": {
11
- "import": {
12
- "types": "../types/server-functions/client.d.ts",
13
- "default": "./dist/client.js"
14
- },
15
- "require": {
16
- "types": "../types-cjs/server-functions/client.d.cts",
17
- "default": "./dist/client.cjs"
18
- }
19
- },
20
- "development": {
21
- "import": {
22
- "types": "../types/server-functions/server.d.ts",
23
- "default": "./dist/server.dev.js"
24
- },
25
- "require": {
26
- "types": "../types-cjs/server-functions/server.d.cts",
27
- "default": "./dist/server.dev.cjs"
28
- }
29
- },
30
- "import": {
31
- "types": "../types/server-functions/server.d.ts",
32
- "default": "./dist/server.js"
33
- },
34
- "require": {
35
- "types": "../types-cjs/server-functions/server.d.cts",
36
- "default": "./dist/server.cjs"
37
- }
38
- }
39
- }
6
+ "sideEffects": false
40
7
  }
@@ -1,20 +1,7 @@
1
1
  {
2
- "name": "@solidjs/web/server-functions/rich-args",
3
- "main": "../dist/rich-args.cjs",
2
+ "main": "../dist/rich-args.js",
4
3
  "module": "../dist/rich-args.js",
5
4
  "types": "../../types/server-functions/rich-args.d.ts",
6
5
  "type": "module",
7
- "sideEffects": false,
8
- "exports": {
9
- ".": {
10
- "import": {
11
- "types": "../../types/server-functions/rich-args.d.ts",
12
- "default": "../dist/rich-args.js"
13
- },
14
- "require": {
15
- "types": "../../types-cjs/server-functions/rich-args.d.cts",
16
- "default": "../dist/rich-args.cjs"
17
- }
18
- }
19
- }
6
+ "sideEffects": false
20
7
  }
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: server-components
3
+ description: Rules for writing Solid 2.0 server components ("use server" functions that return a template) and their slots with @solidjs/web. Use when writing or reviewing a server component, deciding what lives on the server versus the client, or wiring a slot.
4
+ ---
5
+
6
+ # Writing Solid server components with slots
7
+
8
+ A Solid server component is a `"use server"` function that returns a
9
+ template; the browser receives its markup and never its code. Anything the
10
+ client contributes goes through a **slot** on the component's props: a
11
+ client component the client places at a position in the server's markup.
12
+ This guide is the set of rules an author — a person or an agent — needs to
13
+ write one correctly the first time. The design record is
14
+ `documentation/server-components/server-components-principles.md`; this
15
+ file is the operative subset.
16
+
17
+ ## Where things go
18
+
19
+ > **An element lives where the data that creates it lives.**
20
+
21
+ - Exists because of **server data** (a todo row, a nav link, a search
22
+ form the server renders)? It is **server markup**. A mutation on it is a
23
+ form `action` — it works without JavaScript, and the router marks a
24
+ submission in flight (`aria-busy`) so CSS can show the intent.
25
+ - Needs **client behavior or client state** (a handler, an optimistic add,
26
+ a modal, a drag ghost, an editor open over a field)? It is a **client
27
+ component** placed through a **slot**.
28
+
29
+ When the client confirms an optimistic entity and the server renders it, the
30
+ row _becomes_ server markup; `$key` on the element reconciles the two.
31
+
32
+ ## Slots
33
+
34
+ ```tsx
35
+ import type { Slot } from "@solidjs/web/frames";
36
+
37
+ interface TodosProps {
38
+ pending: Slot; // no props
39
+ editor: Slot<{ id: string; title: string }>; // props from the server
40
+ }
41
+ ```
42
+
43
+ A slot is placed as an element: `<props.pending />`,
44
+ `<props.editor id={t.id} title={t.title} />`. The client owns the nodes
45
+ between the slot's markers; the server's markup around them stays the
46
+ server's.
47
+
48
+ ```tsx
49
+ export async function todoList() {
50
+ "use server";
51
+ const todos = await db.list();
52
+ return (props: TodosProps) => (
53
+ <ul>
54
+ {todos.map(t => (
55
+ <li $key={t.id}>
56
+ {t.title}
57
+ <props.editor $key={t.id} id={t.id} title={t.title} />
58
+ </li>
59
+ ))}
60
+ <props.pending />
61
+ </ul>
62
+ );
63
+ }
64
+ ```
65
+
66
+ The client passes the fill — a component of the slot's props:
67
+
68
+ ```tsx
69
+ <Todos editor={p => <Editor id={p.id} title={p.title} />} pending={() => <For each={adds}>{…}</For>} />
70
+ ```
71
+
72
+ - **The fill runs once per occurrence, as a component body does.** It runs
73
+ untracked, under the occurrence's owner, with live props. State it
74
+ creates (a signal, a memo, an `onCleanup`) lives as long as the
75
+ occurrence. A top-level read is read once, and `STRICT_READ_UNTRACKED`
76
+ names it ("the \`editor\` template-slot fill").
77
+ - **Place slots as JSX, not calls.** The compiler wraps each prop in a
78
+ getter so the read defers to the slot border; a call form
79
+ (`props.status({ … })`) evaluates its args eagerly in the server
80
+ component's body.
81
+ - **`$key` is optional.** Add it when the fill holds its own state (an edit
82
+ draft, a signal created inside) that must follow the entity across
83
+ refetches and reorders.
84
+ - **An async value crosses with `asyncArg`.**
85
+ `<props.status progress={asyncArg(gen.progress)} />` ships the promise or
86
+ async iterable; the fill's read settles (suspends until the first value).
87
+
88
+ ## Behavior on server markup
89
+
90
+ A handler on a server-rendered element cannot come from the server: a
91
+ server function never runs in the browser. Pick one:
92
+
93
+ - **A form.** A mutation is `<form action={…}>`; it works before
94
+ JavaScript and needs no client code.
95
+ - **A client component that owns the element.** Move the control into a
96
+ slot's fill (`<props.toggle id={t.id} done={t.completed} />`, rendering
97
+ the checkbox on the client).
98
+ - **One delegated listener.** For many identical controls inside server
99
+ markup (a copy button on every code block), place one slot occurrence
100
+ whose component registers a single document listener in `onSettled` and
101
+ finds its target from the event (`closest("button.copy-code")`). Inside a
102
+ live hole this is the shape that keeps the hole streaming: a slot placed
103
+ inside a live hole latches it (`SSR_LIVE_HOLE_LATCHED`, `data.cause`
104
+ `"records"`). `examples/chat`'s Copy button is this shape.
105
+
106
+ ## Shared components
107
+
108
+ One component can render on both sides. Put `$key={props.id}` on the
109
+ element it renders (morph identity) — the slot's own `$key` is a different
110
+ key for a different job. Do not read `document`/`window` during render;
111
+ that is the ordinary isomorphic rule.
112
+
113
+ ## Compiling
114
+
115
+ With `@solidjs/vite-plugin`, `solid({ ssr: true, serverFunctions:
116
+ { components: true } })` is the turnkey setup (the examples under
117
+ `examples/todos-server`, `examples/notes`, `examples/chat`).
@@ -1,20 +1,7 @@
1
1
  {
2
- "name": "@solidjs/web/storage",
3
- "main": "./dist/storage.cjs",
2
+ "main": "./dist/storage.js",
4
3
  "module": "./dist/storage.js",
5
4
  "types": "./types/index.d.ts",
6
5
  "type": "module",
7
- "sideEffects": false,
8
- "exports": {
9
- ".": {
10
- "import": {
11
- "types": "./types/index.d.ts",
12
- "default": "./dist/storage.js"
13
- },
14
- "require": {
15
- "types": "./types-cjs/index.d.cts",
16
- "default": "./dist/storage.cjs"
17
- }
18
- }
19
- }
6
+ "sideEffects": false
20
7
  }