@alecsibilia/ui-kit 0.0.0-stage → 0.1.0-alpha.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 (283) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +201 -0
  3. package/README.md +233 -2
  4. package/bin/ui-kit.js +12 -0
  5. package/dist/alchemy/app.d.ts +34 -0
  6. package/dist/alchemy/app.js +88 -0
  7. package/dist/alchemy/index.d.ts +11 -0
  8. package/dist/alchemy/index.js +11 -0
  9. package/dist/alchemy/live-rooms.d.ts +21 -0
  10. package/dist/alchemy/live-rooms.js +31 -0
  11. package/dist/alchemy/migrations.d.ts +28 -0
  12. package/dist/alchemy/migrations.js +56 -0
  13. package/dist/alchemy/stage.d.ts +20 -0
  14. package/dist/alchemy/stage.js +20 -0
  15. package/dist/alchemy/wrangler-config.d.ts +76 -0
  16. package/dist/alchemy/wrangler-config.js +82 -0
  17. package/dist/build/app-modules.d.ts +11 -0
  18. package/dist/build/app-modules.js +40 -0
  19. package/dist/build/check.d.ts +4 -0
  20. package/dist/build/check.js +170 -0
  21. package/dist/build/cli.d.ts +1 -0
  22. package/dist/build/cli.js +79 -0
  23. package/dist/build/feature.d.ts +8 -0
  24. package/dist/build/feature.js +24 -0
  25. package/dist/build/index.d.ts +13 -0
  26. package/dist/build/index.js +13 -0
  27. package/dist/build/measure-cpu.d.ts +2 -0
  28. package/dist/build/measure-cpu.js +196 -0
  29. package/dist/build/prerender.d.ts +5 -0
  30. package/dist/build/prerender.js +109 -0
  31. package/dist/build/preview.d.ts +7 -0
  32. package/dist/build/preview.js +41 -0
  33. package/dist/build/seo-files.d.ts +27 -0
  34. package/dist/build/seo-files.js +24 -0
  35. package/dist/client/head-swap.d.ts +45 -0
  36. package/dist/client/head-swap.js +183 -0
  37. package/dist/client/hydration-pass.d.ts +56 -0
  38. package/dist/client/hydration-pass.js +186 -0
  39. package/dist/client/hydration-reset.d.ts +82 -0
  40. package/dist/client/hydration-reset.js +154 -0
  41. package/dist/client/index.d.ts +37 -0
  42. package/dist/client/index.js +65 -0
  43. package/dist/client/nav-client.d.ts +35 -0
  44. package/dist/client/nav-client.js +371 -0
  45. package/dist/live/collab/doc-provider.d.ts +74 -0
  46. package/dist/live/collab/doc-provider.js +412 -0
  47. package/dist/live/collab/index.d.ts +51 -0
  48. package/dist/live/collab/index.jsx +142 -0
  49. package/dist/live/collab-status.d.ts +25 -0
  50. package/dist/live/collab-status.js +17 -0
  51. package/dist/live/cursors/cursor-engine.d.ts +57 -0
  52. package/dist/live/cursors/cursor-engine.js +243 -0
  53. package/dist/live/cursors/index.d.ts +46 -0
  54. package/dist/live/cursors/index.jsx +110 -0
  55. package/dist/live/declaration.d.ts +113 -0
  56. package/dist/live/declaration.js +94 -0
  57. package/dist/live/index.d.ts +8 -0
  58. package/dist/live/index.js +8 -0
  59. package/dist/live/protocol.d.ts +224 -0
  60. package/dist/live/protocol.js +272 -0
  61. package/dist/live/server/doc-store.d.ts +68 -0
  62. package/dist/live/server/doc-store.js +187 -0
  63. package/dist/live/server/index.d.ts +60 -0
  64. package/dist/live/server/index.js +77 -0
  65. package/dist/live/server/room-presence.d.ts +24 -0
  66. package/dist/live/server/room-presence.js +123 -0
  67. package/dist/live/server/room-sockets.d.ts +65 -0
  68. package/dist/live/server/room-sockets.js +97 -0
  69. package/dist/live/server/room.d.ts +20 -0
  70. package/dist/live/server/room.js +348 -0
  71. package/dist/live/server/route.d.ts +56 -0
  72. package/dist/live/server/route.js +159 -0
  73. package/dist/live/server/types.d.ts +163 -0
  74. package/dist/live/server/types.js +2 -0
  75. package/dist/logic/agent-actions.d.ts +133 -0
  76. package/dist/logic/agent-actions.js +150 -0
  77. package/dist/logic/command-types.d.ts +53 -0
  78. package/dist/logic/command-types.js +0 -0
  79. package/dist/logic/dev.d.ts +9 -0
  80. package/dist/logic/dev.js +10 -0
  81. package/dist/logic/draft-rebase.d.ts +59 -0
  82. package/dist/logic/draft-rebase.js +71 -0
  83. package/dist/logic/form-state.d.ts +105 -0
  84. package/dist/logic/form-state.js +93 -0
  85. package/dist/logic/head.d.ts +145 -0
  86. package/dist/logic/head.js +140 -0
  87. package/dist/logic/index.d.ts +27 -0
  88. package/dist/logic/index.js +25 -0
  89. package/dist/logic/island-def.d.ts +89 -0
  90. package/dist/logic/island-def.js +59 -0
  91. package/dist/logic/kit-commands.d.ts +104 -0
  92. package/dist/logic/kit-commands.js +72 -0
  93. package/dist/logic/kit-errors.d.ts +25 -0
  94. package/dist/logic/kit-errors.js +6 -0
  95. package/dist/logic/listen.d.ts +99 -0
  96. package/dist/logic/listen.js +92 -0
  97. package/dist/logic/mutation-def.d.ts +65 -0
  98. package/dist/logic/mutation-def.js +43 -0
  99. package/dist/logic/navigation-data.d.ts +50 -0
  100. package/dist/logic/navigation-data.js +55 -0
  101. package/dist/logic/navigation-policy.d.ts +74 -0
  102. package/dist/logic/navigation-policy.js +127 -0
  103. package/dist/logic/page-model-def.d.ts +108 -0
  104. package/dist/logic/page-model-def.js +31 -0
  105. package/dist/logic/path.d.ts +31 -0
  106. package/dist/logic/path.js +48 -0
  107. package/dist/logic/query-def.d.ts +56 -0
  108. package/dist/logic/query-def.js +37 -0
  109. package/dist/logic/query-key.d.ts +24 -0
  110. package/dist/logic/query-key.js +35 -0
  111. package/dist/logic/query-types.d.ts +28 -0
  112. package/dist/logic/query-types.js +2 -0
  113. package/dist/logic/resources.d.ts +163 -0
  114. package/dist/logic/resources.js +62 -0
  115. package/dist/logic/result.d.ts +30 -0
  116. package/dist/logic/result.js +23 -0
  117. package/dist/logic/route-model.d.ts +139 -0
  118. package/dist/logic/route-model.js +207 -0
  119. package/dist/logic/route-params.d.ts +80 -0
  120. package/dist/logic/route-params.js +114 -0
  121. package/dist/logic/route-table.d.ts +308 -0
  122. package/dist/logic/route-table.js +206 -0
  123. package/dist/logic/seo.d.ts +61 -0
  124. package/dist/logic/seo.js +101 -0
  125. package/dist/logic/site.d.ts +12 -0
  126. package/dist/logic/site.js +0 -0
  127. package/dist/logic/subscriptions.d.ts +177 -0
  128. package/dist/logic/subscriptions.js +152 -0
  129. package/dist/render/index.d.ts +32 -0
  130. package/dist/render/index.js +52 -0
  131. package/dist/runtime/island-wake.d.ts +38 -0
  132. package/dist/runtime/island-wake.js +147 -0
  133. package/dist/runtime/query-scope.d.ts +224 -0
  134. package/dist/runtime/query-scope.js +222 -0
  135. package/dist/runtime/room-hub.d.ts +107 -0
  136. package/dist/runtime/room-hub.js +307 -0
  137. package/dist/runtime/subscription-runner.d.ts +71 -0
  138. package/dist/runtime/subscription-runner.js +240 -0
  139. package/dist/server/bindings.d.ts +41 -0
  140. package/dist/server/bindings.js +74 -0
  141. package/dist/server/browser.d.ts +9 -0
  142. package/dist/server/browser.js +9 -0
  143. package/dist/server/edge-cache.d.ts +28 -0
  144. package/dist/server/edge-cache.js +35 -0
  145. package/dist/server/errors.d.ts +45 -0
  146. package/dist/server/errors.js +36 -0
  147. package/dist/server/form-actions-setup.d.ts +1 -0
  148. package/dist/server/form-actions-setup.js +15 -0
  149. package/dist/server/form-actions.d.ts +121 -0
  150. package/dist/server/form-actions.js +211 -0
  151. package/dist/server/index.d.ts +36 -0
  152. package/dist/server/index.js +35 -0
  153. package/dist/server/inputs.d.ts +45 -0
  154. package/dist/server/inputs.js +77 -0
  155. package/dist/server/rate-limit.d.ts +29 -0
  156. package/dist/server/rate-limit.js +32 -0
  157. package/dist/server/read-cache.d.ts +74 -0
  158. package/dist/server/read-cache.js +58 -0
  159. package/dist/server/request-info.d.ts +17 -0
  160. package/dist/server/request-info.js +11 -0
  161. package/dist/server/request.d.ts +52 -0
  162. package/dist/server/request.js +73 -0
  163. package/dist/server/response-cookies.d.ts +23 -0
  164. package/dist/server/response-cookies.js +24 -0
  165. package/dist/server/run-effect.d.ts +42 -0
  166. package/dist/server/run-effect.js +92 -0
  167. package/dist/server/run.d.ts +63 -0
  168. package/dist/server/run.js +66 -0
  169. package/dist/server/session.d.ts +125 -0
  170. package/dist/server/session.js +247 -0
  171. package/dist/test/fake-bindings.d.ts +32 -0
  172. package/dist/test/fake-bindings.js +108 -0
  173. package/dist/test/fake-room.d.ts +66 -0
  174. package/dist/test/fake-room.js +216 -0
  175. package/dist/test/index.d.ts +19 -0
  176. package/dist/test/index.js +44 -0
  177. package/dist/test/probe.d.ts +11 -0
  178. package/dist/test/probe.js +11 -0
  179. package/dist/test/solid-jsx.d.ts +23 -0
  180. package/dist/test/solid-jsx.js +28 -0
  181. package/dist/test/solid-preload.d.ts +1 -0
  182. package/dist/test/solid-preload.js +29 -0
  183. package/dist/ui/code-editor/index.d.ts +21 -0
  184. package/dist/ui/code-editor/index.jsx +286 -0
  185. package/dist/ui/collab-text/index.d.ts +29 -0
  186. package/dist/ui/collab-text/index.jsx +96 -0
  187. package/dist/ui/components/controls.d.ts +69 -0
  188. package/dist/ui/components/controls.jsx +81 -0
  189. package/dist/ui/components/feedback.d.ts +26 -0
  190. package/dist/ui/components/feedback.jsx +80 -0
  191. package/dist/ui/components/layout.d.ts +74 -0
  192. package/dist/ui/components/layout.jsx +146 -0
  193. package/dist/ui/components/lists.d.ts +69 -0
  194. package/dist/ui/components/lists.jsx +133 -0
  195. package/dist/ui/components/navigation.d.ts +73 -0
  196. package/dist/ui/components/navigation.jsx +112 -0
  197. package/dist/ui/components/text.d.ts +34 -0
  198. package/dist/ui/components/text.jsx +163 -0
  199. package/dist/ui/index.d.ts +7 -0
  200. package/dist/ui/index.js +7 -0
  201. package/dist/ui/jsx-runtime.d.ts +19 -0
  202. package/dist/ui/jsx-runtime.js +0 -0
  203. package/dist/ui/list-keys.d.ts +31 -0
  204. package/dist/ui/list-keys.js +45 -0
  205. package/dist/ui/styles/base.css +38 -0
  206. package/dist/ui/styles/components.css +608 -0
  207. package/dist/ui/styles/tokens.css +27 -0
  208. package/dist/ui/styles/transitions.css +23 -0
  209. package/dist/ui/styles/workbench.css +428 -0
  210. package/dist/ui/styles.css +9 -0
  211. package/dist/view/agent-actions-view.d.ts +30 -0
  212. package/dist/view/agent-actions-view.js +27 -0
  213. package/dist/view/agent-surface.d.ts +42 -0
  214. package/dist/view/agent-surface.js +123 -0
  215. package/dist/view/app-scope.d.ts +51 -0
  216. package/dist/view/app-scope.js +75 -0
  217. package/dist/view/boundary.d.ts +18 -0
  218. package/dist/view/boundary.jsx +26 -0
  219. package/dist/view/command-runner.d.ts +16 -0
  220. package/dist/view/command-runner.js +245 -0
  221. package/dist/view/form.d.ts +82 -0
  222. package/dist/view/form.jsx +109 -0
  223. package/dist/view/head-view.d.ts +31 -0
  224. package/dist/view/head-view.js +46 -0
  225. package/dist/view/index.d.ts +41 -0
  226. package/dist/view/index.js +40 -0
  227. package/dist/view/island-root.d.ts +30 -0
  228. package/dist/view/island-root.js +36 -0
  229. package/dist/view/island.d.ts +102 -0
  230. package/dist/view/island.jsx +154 -0
  231. package/dist/view/match.d.ts +41 -0
  232. package/dist/view/match.js +111 -0
  233. package/dist/view/model.d.ts +92 -0
  234. package/dist/view/model.js +162 -0
  235. package/dist/view/navigation-head.d.ts +29 -0
  236. package/dist/view/navigation-head.jsx +38 -0
  237. package/dist/view/page-model.d.ts +46 -0
  238. package/dist/view/page-model.js +146 -0
  239. package/dist/view/query-effects.d.ts +87 -0
  240. package/dist/view/query-effects.js +147 -0
  241. package/dist/view/query-ok.d.ts +45 -0
  242. package/dist/view/query-ok.js +96 -0
  243. package/dist/view/query.d.ts +115 -0
  244. package/dist/view/query.jsx +179 -0
  245. package/dist/view/result-view.d.ts +14 -0
  246. package/dist/view/result-view.jsx +15 -0
  247. package/dist/view/route-pages.d.ts +43 -0
  248. package/dist/view/route-pages.js +59 -0
  249. package/dist/view/router.d.ts +44 -0
  250. package/dist/view/router.js +123 -0
  251. package/dist/vite/dev-middleware.d.ts +12 -0
  252. package/dist/vite/dev-middleware.js +39 -0
  253. package/dist/vite/dev-objects.d.ts +25 -0
  254. package/dist/vite/dev-objects.js +127 -0
  255. package/dist/vite/dev-platform.d.ts +19 -0
  256. package/dist/vite/dev-platform.js +77 -0
  257. package/dist/vite/dev-seo-files.d.ts +11 -0
  258. package/dist/vite/dev-seo-files.js +40 -0
  259. package/dist/vite/index.d.ts +53 -0
  260. package/dist/vite/index.js +148 -0
  261. package/dist/vite/local-config.d.ts +34 -0
  262. package/dist/vite/local-config.js +72 -0
  263. package/dist/vite/worker-build.d.ts +24 -0
  264. package/dist/vite/worker-build.js +84 -0
  265. package/dist/worker/create-worker.d.ts +52 -0
  266. package/dist/worker/create-worker.js +90 -0
  267. package/dist/worker/index.d.ts +12 -0
  268. package/dist/worker/index.js +12 -0
  269. package/dist/worker/page-routes.d.ts +88 -0
  270. package/dist/worker/page-routes.js +100 -0
  271. package/dist/worker/page-status.d.ts +41 -0
  272. package/dist/worker/page-status.js +23 -0
  273. package/dist/worker/request-prelude.d.ts +69 -0
  274. package/dist/worker/request-prelude.js +107 -0
  275. package/dist/worker/security.d.ts +76 -0
  276. package/dist/worker/security.js +137 -0
  277. package/dist/worker/server-app.d.ts +54 -0
  278. package/dist/worker/server-app.js +76 -0
  279. package/guards/browser-only.js +5 -0
  280. package/guards/node-only.js +6 -0
  281. package/guards/server-only.js +5 -0
  282. package/migrations/0001-sessions.sql +22 -0
  283. package/package.json +233 -5
@@ -0,0 +1,105 @@
1
+ import type { Result as ResultValue, Tagged } from './result.ts';
2
+ /**
3
+ * Pure form state for the kit's `<Form>` (import-free: models use it).
4
+ *
5
+ * A form's model holds one `FormStatus` field; `update` moves it
6
+ * (`formSubmitting` on the submit Message, `formStatusOf(result)` on the
7
+ * mutation's result Message) and decides what success means (navigate,
8
+ * toast). The `<Form>` view reads it for the pending state, the field
9
+ * errors and the form-level notice. Field errors are data from the
10
+ * mutation's typed `ValidationFailed` (`field_errors`), never strings the
11
+ * view parses.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // sign-in.model.ts
16
+ * Submitted: ({ fields }) => [{ ...model, form: formSubmitting }, [{ _tag: "SubmitSignIn", fields }]],
17
+ * Finished: ({ result }) => [
18
+ * { ...model, form: formStatusOf(result) },
19
+ * result._tag === "Ok" ? [navigate(model.next)] : [],
20
+ * ],
21
+ * ```
22
+ */
23
+ /** One field's problem, as `ValidationFailed.field_errors` carries it (`field: ""` = the whole form). */
24
+ export interface FieldError {
25
+ readonly field: string;
26
+ readonly message: string;
27
+ }
28
+ /** A submitted form's values by field name (what `<Form onSubmit>` hands the Message). */
29
+ export type FormFields = Readonly<Record<string, string>>;
30
+ export type FormStatus =
31
+ /** Nothing submitted with JS yet (a no-JS submission's outcome may still show). */
32
+ {
33
+ readonly _tag: 'Idle';
34
+ } | {
35
+ readonly _tag: 'Submitting';
36
+ } | {
37
+ readonly _tag: 'Succeeded';
38
+ }
39
+ /** The input did not decode: per-field errors (`ValidationFailed`). */
40
+ | {
41
+ readonly _tag: 'Rejected';
42
+ readonly message: string;
43
+ readonly field_errors: readonly FieldError[];
44
+ }
45
+ /** Any other failure (a typed error or `Unexpected`): one message. */
46
+ | {
47
+ readonly _tag: 'Failed';
48
+ readonly message: string;
49
+ };
50
+ export declare const formIdle: FormStatus;
51
+ export declare const formSubmitting: FormStatus;
52
+ /** What a failed mutation's error looks like to a form: a tag, a message, maybe field errors. */
53
+ export interface FormFailure extends Tagged {
54
+ readonly message: string;
55
+ readonly field_errors?: readonly FieldError[];
56
+ }
57
+ /**
58
+ * The status after a mutation's result: `Ok` -> `Succeeded`;
59
+ * `ValidationFailed` with field errors -> `Rejected`; anything else ->
60
+ * `Failed` with the error's message.
61
+ */
62
+ export declare function formStatusOf(result: ResultValue<unknown, FormFailure>): FormStatus;
63
+ /** The first error for `field` in a status (`undefined` when none). */
64
+ export declare function fieldErrorOf(status: FormStatus, field: string): string | undefined;
65
+ /**
66
+ * The form-level message: a `Failed` message, or a `Rejected` one whose
67
+ * errors don't belong to a named field (field errors show at the fields).
68
+ */
69
+ export declare function formMessageOf(status: FormStatus): string | undefined;
70
+ /** Whether the form is waiting for its mutation. */
71
+ export declare function isFormPending(status: FormStatus): boolean;
72
+ /** A `FormData` as plain fields (string values only; files are dropped). */
73
+ export declare function formFieldsOf(data: {
74
+ forEach(cb: (value: unknown, key: string) => void): void;
75
+ }): FormFields;
76
+ /**
77
+ * The outcome of a form posted without JS, as the server hands it to the
78
+ * next render on `locals.formFlash` (decoded from Solid's flash cookie by
79
+ * the Worker / dev middleware; `readFormFlash` in `@alecsibilia/ui-kit/server`): which
80
+ * form (`action`), what was typed (`values`) and what came back. Plain data.
81
+ */
82
+ export interface FormFlash {
83
+ readonly action: string;
84
+ readonly values: Readonly<Record<string, string>>;
85
+ readonly outcome: {
86
+ readonly _tag: 'Returned';
87
+ readonly result: unknown;
88
+ } | {
89
+ readonly _tag: 'Thrown';
90
+ } | {
91
+ readonly _tag: 'Truncated';
92
+ };
93
+ }
94
+ /** What a `<Form>` shows from a no-JS submission of its own mutation. */
95
+ export interface FlashView {
96
+ readonly status: FormStatus;
97
+ readonly values: FormFields;
98
+ }
99
+ /** Shown when a no-JS submission threw (the details stay in the server log). */
100
+ export declare const FORM_UNEXPECTED_MESSAGE = "Something went wrong. Try again.";
101
+ /**
102
+ * The flash for the form posting to `formUrl` (its status and typed
103
+ * values), or an idle view when the flash is for another form or absent.
104
+ */
105
+ export declare function flashViewFor(flash: FormFlash | undefined, formUrl: string): FlashView;
@@ -0,0 +1,93 @@
1
+ export const formIdle = { _tag: 'Idle' };
2
+ export const formSubmitting = { _tag: 'Submitting' };
3
+ /**
4
+ * The status after a mutation's result: `Ok` -> `Succeeded`;
5
+ * `ValidationFailed` with field errors -> `Rejected`; anything else ->
6
+ * `Failed` with the error's message.
7
+ */
8
+ export function formStatusOf(result) {
9
+ if (result._tag === 'Ok')
10
+ return { _tag: 'Succeeded' };
11
+ const error = result.error;
12
+ if (error._tag === 'ValidationFailed') {
13
+ return {
14
+ _tag: 'Rejected',
15
+ message: error.message,
16
+ field_errors: error.field_errors ?? [],
17
+ };
18
+ }
19
+ return { _tag: 'Failed', message: error.message };
20
+ }
21
+ /** The first error for `field` in a status (`undefined` when none). */
22
+ export function fieldErrorOf(status, field) {
23
+ if (status._tag !== 'Rejected')
24
+ return undefined;
25
+ return status.field_errors.find((e) => e.field === field)?.message;
26
+ }
27
+ /**
28
+ * The form-level message: a `Failed` message, or a `Rejected` one whose
29
+ * errors don't belong to a named field (field errors show at the fields).
30
+ */
31
+ export function formMessageOf(status) {
32
+ if (status._tag === 'Failed')
33
+ return status.message;
34
+ if (status._tag !== 'Rejected')
35
+ return undefined;
36
+ const loose = status.field_errors.filter((e) => e.field === '');
37
+ if (loose.length > 0)
38
+ return loose.map((e) => e.message).join(' ');
39
+ return status.field_errors.length === 0 ? status.message : undefined;
40
+ }
41
+ /** Whether the form is waiting for its mutation. */
42
+ export function isFormPending(status) {
43
+ return status._tag === 'Submitting';
44
+ }
45
+ /** A `FormData` as plain fields (string values only; files are dropped). */
46
+ export function formFieldsOf(data) {
47
+ const fields = {};
48
+ data.forEach((value, key) => {
49
+ if (typeof value === 'string' && !(key in fields))
50
+ fields[key] = value;
51
+ });
52
+ return fields;
53
+ }
54
+ const NO_FLASH = { status: formIdle, values: {} };
55
+ /** Shown when a no-JS submission threw (the details stay in the server log). */
56
+ export const FORM_UNEXPECTED_MESSAGE = 'Something went wrong. Try again.';
57
+ function pathOf(url) {
58
+ const noOrigin = url.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/?]*/i, '');
59
+ return noOrigin.split('?')[0] ?? noOrigin;
60
+ }
61
+ function isResult(value) {
62
+ if (!value || typeof value !== 'object')
63
+ return false;
64
+ const result = value;
65
+ return (result._tag === 'Ok' ||
66
+ (result._tag === 'Err' && typeof result.error?._tag === 'string'));
67
+ }
68
+ /**
69
+ * The flash for the form posting to `formUrl` (its status and typed
70
+ * values), or an idle view when the flash is for another form or absent.
71
+ */
72
+ export function flashViewFor(flash, formUrl) {
73
+ if (!flash ||
74
+ typeof flash.action !== 'string' ||
75
+ pathOf(flash.action) !== pathOf(formUrl)) {
76
+ return NO_FLASH;
77
+ }
78
+ const outcome = flash.outcome;
79
+ if (outcome._tag === 'Thrown') {
80
+ return {
81
+ status: { _tag: 'Failed', message: FORM_UNEXPECTED_MESSAGE },
82
+ values: flash.values,
83
+ };
84
+ }
85
+ if (outcome._tag === 'Returned' && isResult(outcome.result)) {
86
+ const status = formStatusOf(outcome.result);
87
+ return {
88
+ status,
89
+ values: status._tag === 'Succeeded' ? {} : flash.values,
90
+ };
91
+ }
92
+ return NO_FLASH;
93
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Head and meta as data: what a route (or a page, once its data is in)
3
+ * says about itself to browsers, search engines, link previews and agents.
4
+ * Pure and import-free, so `routes.ts` (read by the Worker, the prerender
5
+ * and sitemap scripts and the router) and tests can use it. The kit's
6
+ * `<RoutePage>` and `<Head>` turn a {@link HeadSpec} into Solid 2's
7
+ * `useHead` tags (`headTagsFor`), which Solid splices into the SSR /
8
+ * prerendered `<head>` and keeps up to date on client navigation.
9
+ *
10
+ * One spec gives: `<title>` (through the site's title template), the meta
11
+ * description, an absolute canonical URL, robots, Open Graph and Twitter
12
+ * card tags, `hreflang` alternates and JSON-LD data blocks.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const site: SiteHead = {
17
+ * name: "Forever Turbo",
18
+ * origin: "https://foreverturbo.com",
19
+ * lang: "en",
20
+ * locale: "en_US",
21
+ * titleTemplate: "%s · Forever Turbo",
22
+ * description: "Gear planning for Forever.",
23
+ * };
24
+ * headTagsFor({ title: "Plans", description: "Every saved plan." }, site, "/plans");
25
+ * // [{ tag: "title", props: { children: "Plans · Forever Turbo" } },
26
+ * // { tag: "meta", props: { name: "description", content: "Every saved plan." } },
27
+ * // { tag: "link", key: "canonical", props: { rel: "canonical", href: "https://foreverturbo.com/plans" } }, ...]
28
+ * ```
29
+ */
30
+ /** A JSON value (JSON-LD documents are plain JSON). */
31
+ export type JsonValue = string | number | boolean | null | readonly JsonValue[] | {
32
+ readonly [key: string]: JsonValue;
33
+ };
34
+ /** One JSON-LD document (`@context` defaults to `https://schema.org`). */
35
+ export type JsonLd = {
36
+ readonly '@type': string | readonly string[];
37
+ } & {
38
+ readonly [key: string]: JsonValue;
39
+ };
40
+ /** `robots` meta values the kit allows (absent: indexable, the default). */
41
+ export type RobotsDirective = 'noindex' | 'noindex, nofollow' | 'nofollow';
42
+ /** One language alternate (`<link rel="alternate" hreflang>`); `x-default` for the fallback. */
43
+ export interface HeadAlternate {
44
+ readonly hreflang: string;
45
+ /** A path on this site (`/fr/plans`) or an absolute URL. */
46
+ readonly href: string;
47
+ }
48
+ /**
49
+ * What one page says about itself. `title` and `description` are required
50
+ * (lint: `ui-kit/route-head-required` for public routes); the rest is optional.
51
+ */
52
+ export interface HeadSpec {
53
+ /** The page's own title; the site's `titleTemplate` wraps it (`%s · Site`). */
54
+ readonly title: string;
55
+ /** One or two sentences, shown under the title in search results and link previews. */
56
+ readonly description: string;
57
+ /**
58
+ * The canonical URL: a path on this site or an absolute URL. Default: the
59
+ * route's path with its params and without search params.
60
+ */
61
+ readonly canonical?: string;
62
+ /** Leave out for indexable pages. */
63
+ readonly robots?: RobotsDirective;
64
+ /** Open Graph `og:type` (default `website`). */
65
+ readonly ogType?: 'website' | 'article' | 'profile';
66
+ /** A share image (path or absolute URL; default: the site's). */
67
+ readonly image?: string;
68
+ readonly imageAlt?: string;
69
+ /** Language alternates (each page lists all of them, itself included). */
70
+ readonly alternates?: readonly HeadAlternate[];
71
+ /** Structured data, emitted as `<script type="application/ld+json">` data blocks. */
72
+ readonly jsonLd?: readonly JsonLd[];
73
+ }
74
+ /** Site-wide head defaults, declared once by the app (`src/site.ts`). */
75
+ export interface SiteHead {
76
+ /** The site's name (`og:site_name`, and the title of a route without its own). */
77
+ readonly name: string;
78
+ /** The production origin, no trailing slash: canonical and Open Graph URLs are absolute. */
79
+ readonly origin: string;
80
+ /** `<html lang>` (`en`). */
81
+ readonly lang: string;
82
+ /** `og:locale` (`en_US`). */
83
+ readonly locale: string;
84
+ /** How a page title is shown: `%s` is the page's title (`"%s · Forever Turbo"`). */
85
+ readonly titleTemplate: string;
86
+ /** The description of a route that declares none (auth-only pages). */
87
+ readonly description: string;
88
+ /** Default share image (path or absolute URL). */
89
+ readonly image?: string;
90
+ /** `twitter:site` (`@handle`). */
91
+ readonly twitterSite?: string;
92
+ }
93
+ /**
94
+ * A route's head: a spec, or a pure function of the route's decoded params
95
+ * and search (`/plans/:planId` → a title naming the plan id). Data that
96
+ * only the page's queries know (a plan's character name) goes through the
97
+ * kit's `<Head>` inside the page instead.
98
+ */
99
+ export type RouteHead = HeadSpec | ((route: {
100
+ readonly params: Readonly<Record<string, string>>;
101
+ readonly search: Readonly<Record<string, string | number>>;
102
+ }) => HeadSpec);
103
+ /**
104
+ * A head tag in Solid 2's `useHead` shape (`@solidjs/web` `HeadTag`),
105
+ * declared here so this module stays import-free.
106
+ */
107
+ export interface HeadTagData {
108
+ readonly tag: 'title' | 'meta' | 'link' | 'script';
109
+ readonly props: Readonly<Record<string, string>>;
110
+ readonly key?: string;
111
+ }
112
+ /** `path` or URL → absolute URL on `origin`. */
113
+ export declare function absoluteUrl(origin: string, pathOrUrl: string): string;
114
+ /** The page title through the site's template (the site's own name is not repeated). */
115
+ export declare function pageTitle(site: SiteHead, title: string): string;
116
+ /** A route's spec: the table's `head` (called with the route), or the site's defaults. */
117
+ export declare function resolveRouteHead(head: RouteHead | undefined, route: Parameters<Extract<RouteHead, (route: never) => HeadSpec>>[0], site: SiteHead): HeadSpec;
118
+ /**
119
+ * The JSON text of a JSON-LD data block. Solid escapes `<` in JSON script
120
+ * bodies (`<`), so a value can't close the `<script>` element.
121
+ */
122
+ export declare function jsonLdText(doc: JsonLd): string;
123
+ /**
124
+ * The `useHead` tags for one page. Keys are stable per kind, so a page's
125
+ * `<Head>` (registered after its route's) replaces the route's values tag
126
+ * by tag, and a client navigation replaces the old page's tags.
127
+ *
128
+ * @param spec - the page's head
129
+ * @param site - the site defaults
130
+ * @param path - the page's own path, for the default canonical and `og:url`;
131
+ * `undefined` (a page's `<Head>`) leaves them to the route's head unless
132
+ * the spec names a `canonical`
133
+ */
134
+ export declare function headTagsFor(spec: HeadSpec, site: SiteHead, path: string | undefined): HeadTagData[];
135
+ /**
136
+ * Fills a route pattern's `:params` (percent-encoded): the page's own path
137
+ * for the default canonical. Search params are left out (a tab is the same
138
+ * page).
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * fillPath("/plans/:planId", { planId: "voltar main" }); // "/plans/voltar%20main"
143
+ * ```
144
+ */
145
+ export declare function fillPath(pattern: string, params: Readonly<Record<string, string>>): string;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Head and meta as data: what a route (or a page, once its data is in)
3
+ * says about itself to browsers, search engines, link previews and agents.
4
+ * Pure and import-free, so `routes.ts` (read by the Worker, the prerender
5
+ * and sitemap scripts and the router) and tests can use it. The kit's
6
+ * `<RoutePage>` and `<Head>` turn a {@link HeadSpec} into Solid 2's
7
+ * `useHead` tags (`headTagsFor`), which Solid splices into the SSR /
8
+ * prerendered `<head>` and keeps up to date on client navigation.
9
+ *
10
+ * One spec gives: `<title>` (through the site's title template), the meta
11
+ * description, an absolute canonical URL, robots, Open Graph and Twitter
12
+ * card tags, `hreflang` alternates and JSON-LD data blocks.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const site: SiteHead = {
17
+ * name: "Forever Turbo",
18
+ * origin: "https://foreverturbo.com",
19
+ * lang: "en",
20
+ * locale: "en_US",
21
+ * titleTemplate: "%s · Forever Turbo",
22
+ * description: "Gear planning for Forever.",
23
+ * };
24
+ * headTagsFor({ title: "Plans", description: "Every saved plan." }, site, "/plans");
25
+ * // [{ tag: "title", props: { children: "Plans · Forever Turbo" } },
26
+ * // { tag: "meta", props: { name: "description", content: "Every saved plan." } },
27
+ * // { tag: "link", key: "canonical", props: { rel: "canonical", href: "https://foreverturbo.com/plans" } }, ...]
28
+ * ```
29
+ */
30
+ /** `path` or URL → absolute URL on `origin`. */
31
+ export function absoluteUrl(origin, pathOrUrl) {
32
+ return new URL(pathOrUrl, `${origin}/`).href;
33
+ }
34
+ /** The page title through the site's template (the site's own name is not repeated). */
35
+ export function pageTitle(site, title) {
36
+ return title === site.name ? title : site.titleTemplate.replace('%s', title);
37
+ }
38
+ /** A route's spec: the table's `head` (called with the route), or the site's defaults. */
39
+ export function resolveRouteHead(head, route, site) {
40
+ if (head === undefined)
41
+ return { title: site.name, description: site.description };
42
+ return typeof head === 'function' ? head(route) : head;
43
+ }
44
+ /**
45
+ * The JSON text of a JSON-LD data block. Solid escapes `<` in JSON script
46
+ * bodies (`<`), so a value can't close the `<script>` element.
47
+ */
48
+ export function jsonLdText(doc) {
49
+ return JSON.stringify('@context' in doc ? doc : { '@context': 'https://schema.org', ...doc });
50
+ }
51
+ /**
52
+ * The `useHead` tags for one page. Keys are stable per kind, so a page's
53
+ * `<Head>` (registered after its route's) replaces the route's values tag
54
+ * by tag, and a client navigation replaces the old page's tags.
55
+ *
56
+ * @param spec - the page's head
57
+ * @param site - the site defaults
58
+ * @param path - the page's own path, for the default canonical and `og:url`;
59
+ * `undefined` (a page's `<Head>`) leaves them to the route's head unless
60
+ * the spec names a `canonical`
61
+ */
62
+ export function headTagsFor(spec, site, path) {
63
+ const title = pageTitle(site, spec.title);
64
+ const canonical = spec.canonical ?? path;
65
+ const url = canonical === undefined
66
+ ? undefined
67
+ : absoluteUrl(site.origin, canonical);
68
+ const image = spec.image ?? site.image;
69
+ const meta = (attr, name, content) => ({
70
+ tag: 'meta',
71
+ props: { [attr]: name, content },
72
+ });
73
+ const tags = [
74
+ { tag: 'title', props: { children: title } },
75
+ meta('name', 'description', spec.description),
76
+ meta('name', 'robots', spec.robots ?? 'index, follow'),
77
+ meta('property', 'og:type', spec.ogType ?? 'website'),
78
+ meta('property', 'og:site_name', site.name),
79
+ meta('property', 'og:locale', site.locale),
80
+ meta('property', 'og:title', title),
81
+ meta('property', 'og:description', spec.description),
82
+ meta('name', 'twitter:card', image === undefined ? 'summary' : 'summary_large_image'),
83
+ meta('name', 'twitter:title', title),
84
+ meta('name', 'twitter:description', spec.description),
85
+ ];
86
+ if (url !== undefined) {
87
+ tags.push({
88
+ tag: 'link',
89
+ key: 'canonical',
90
+ props: { rel: 'canonical', href: url },
91
+ }, meta('property', 'og:url', url));
92
+ }
93
+ if (image !== undefined) {
94
+ const imageUrl = absoluteUrl(site.origin, image);
95
+ tags.push(meta('property', 'og:image', imageUrl), meta('name', 'twitter:image', imageUrl));
96
+ if (spec.imageAlt !== undefined) {
97
+ tags.push(meta('property', 'og:image:alt', spec.imageAlt), meta('name', 'twitter:image:alt', spec.imageAlt));
98
+ }
99
+ }
100
+ if (site.twitterSite !== undefined)
101
+ tags.push(meta('name', 'twitter:site', site.twitterSite));
102
+ for (const alt of spec.alternates ?? []) {
103
+ tags.push({
104
+ tag: 'link',
105
+ key: `alternate:${alt.hreflang}`,
106
+ props: {
107
+ rel: 'alternate',
108
+ hreflang: alt.hreflang,
109
+ href: absoluteUrl(site.origin, alt.href),
110
+ },
111
+ });
112
+ }
113
+ ;
114
+ (spec.jsonLd ?? []).forEach((doc, i) => {
115
+ tags.push({
116
+ tag: 'script',
117
+ key: `jsonld:${i}`,
118
+ props: { type: 'application/ld+json', children: jsonLdText(doc) },
119
+ });
120
+ });
121
+ return tags;
122
+ }
123
+ /**
124
+ * Fills a route pattern's `:params` (percent-encoded): the page's own path
125
+ * for the default canonical. Search params are left out (a tab is the same
126
+ * page).
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * fillPath("/plans/:planId", { planId: "voltar main" }); // "/plans/voltar%20main"
131
+ * ```
132
+ */
133
+ export function fillPath(pattern, params) {
134
+ return pattern
135
+ .split('/')
136
+ .map((segment) => segment.startsWith(':')
137
+ ? encodeURIComponent(params[segment.slice(1)] ?? '')
138
+ : segment)
139
+ .join('/');
140
+ }
@@ -0,0 +1,27 @@
1
+ export { matchTag, ok, err, isOk, isErr, type Tagged, type TagHandlers, type Ok, type Err, type Result as ResultValue, } from './result.ts';
2
+ export { normalizePathname, resolveRoute } from './path.ts';
3
+ export { createQueryRegistry, type AnyQueryFn, type AnyQueryRegistry, type QueryDef, type QueryRegistry, type RegistryIdOf, type RegistryInputOf, } from './query-def.ts';
4
+ export { createMutationRegistry, type MutationDef, type MutationRegistry, type MutationSpec, } from './mutation-def.ts';
5
+ export { refetch, navigate, readStorage, writeStorage, scrollToTop, KIT_COMMAND_TAGS, type KitCommand, type NavigateCommand, type RefetchCommand, type ScrollToTopCommand, type StorageReadCommand, type StorageWriteCommand, } from './kit-commands.ts';
6
+ export { every, channel, presence, roomSaved, type RoomDocSaved, type RoomEvent, type RoomPresence, type RoomSubscription, type ChannelStatus, type ChannelSubscription, type EverySubscription, type Subscription, type SubscriptionKeySource, } from './subscriptions.ts';
7
+ export { inputKeyOf, queryIdOf } from './query-key.ts';
8
+ export { listen, messageForOutcome, type ListenSpec, type Listens, type QueryListener, } from './listen.ts';
9
+ export { UNEXPECTED_QUERY_MESSAGE, type QueryError, type QueryFailure, type UnexpectedQueryError, } from './query-types.ts';
10
+ export { routePathsOf, routeEntryFor, prerenderedPathsOf, matchRoute, hrefFor, lazyPage, effectiveSpeculation, routePresence, sameRoute, decodeSearch, searchParam, DEFAULT_SSR_MODE, type IntParam, type OneOfParam, type PageModule, type ParamNames, type ParamsOf, type PathRouteOf, type PathTagOf, type NavigationMode, type NavigationSpec, type SectionOf, routeSection, type RenderMode, type RouteAuth, type RouteEntry, type Speculation, type RouteMatch, type RouteOf, type RoutePathSpec, type RoutePaths, type RouteTable, type SsrMode, type SearchOf, type SearchParamSpec, type SearchParamValue, type SearchSpec, type TextParam, } from './route-table.ts';
11
+ export { fieldErrorOf, flashViewFor, formFieldsOf, formIdle, FORM_UNEXPECTED_MESSAGE, formMessageOf, formStatusOf, formSubmitting, isFormPending, type FieldError, type FlashView, type FormFailure, type FormFields, type FormFlash, type FormStatus, } from './form-state.ts';
12
+ export type { PageProps } from '../view/route-pages.ts';
13
+ export { afterSignIn, initRouter, routerListens, routerUrlChanged, signInRouteFor, updateRouter, Who, type RouterAuth, type RouterModel, type RouterMsg, } from './route-model.ts';
14
+ export { absoluteUrl, fillPath, headTagsFor, jsonLdText, pageTitle, resolveRouteHead, type HeadAlternate, type HeadSpec, type HeadTagData, type JsonLd, type JsonValue, type RobotsDirective, type RouteHead, type SiteHead, } from './head.ts';
15
+ export { robotsTxt, sitemapPlan, sitemapXml, SITEMAP_MAX_URLS, SITEMAP_PATH, type SitemapPlan, type SitemapProvider, type SitemapProviders, } from './seo.ts';
16
+ export { AGENT_MANIFEST_TYPE, agentActions, agentField, agentToolDescriptors, checkAgentInput, inputJsonSchema, runAgentAction, type AgentActionSpec, type AgentActions, type AgentCallResult, type AgentEffect, type AgentField, type AgentInputCheck, type AgentInputOf, type AgentInputSpec, type AgentInt, type AgentOneOf, type AgentText, type AgentToolDescriptor, type JsonSchema, } from './agent-actions.ts';
17
+ export { defineIslands, type IslandDef, type IslandModule, type IslandSpec, type IslandTable, type Json, type LazyIslandWake, type PageIslandWake, } from './island-def.ts';
18
+ export { definePageModel, type PageModelDef, type PageModelPeers, type PageInfo, type PageModelSpec, } from './page-model-def.ts';
19
+ export { caughtUpWith, rebaseDraft, type Rebased, type SaveConflictError, } from './draft-rebase.ts';
20
+ export type { CollabStatus, CollabStatusChanged, } from '../live/collab-status.ts';
21
+ export { bindingSpecsOf, DEFAULT_SESSIONS_CRON, defineResources, resourceProblems, type BindingSpec, type D1Binding, type D1Decl, type D1Statement, type DurableObjectDecl, type DurableObjectNamespaceBinding, type EnvOf, type R2Binding, type RateLimitBinding, type RateLimitDecl, type ResourcesDecl, } from './resources.ts';
22
+ export type { FieldErrorShape, RateLimitedError, UnauthorizedError, ValidationFailedError, } from './kit-errors.ts';
23
+ export type { CommandContext, CommandHandlers, InitResult, TraceEntry, } from './command-types.ts';
24
+ export type { AgentSurfaceFlag, SiteSettings } from './site.ts';
25
+ export { CLIENT_NAV_ACTIVE_ATTR, clientNavigationFor, inlineJson, speculationRulesFor, type SpeculationRules, } from './navigation-policy.ts';
26
+ export { CLIENT_NAV_DATA_TYPE, navigationDecision, parseClientNavigationData, type ClientNavigationData, type FullLoadReason, } from './navigation-data.ts';
27
+ export { matchPattern } from './route-params.ts';
@@ -0,0 +1,25 @@
1
+ export { matchTag, ok, err, isOk, isErr, } from './result.js';
2
+ export { normalizePathname, resolveRoute } from './path.js';
3
+ export { createQueryRegistry, } from './query-def.js';
4
+ export { createMutationRegistry, } from './mutation-def.js';
5
+ export { refetch, navigate, readStorage, writeStorage, scrollToTop, KIT_COMMAND_TAGS, } from './kit-commands.js';
6
+ export { every, channel, presence, roomSaved, } from './subscriptions.js';
7
+ export { inputKeyOf, queryIdOf } from './query-key.js';
8
+ export { listen, messageForOutcome, } from './listen.js';
9
+ export { UNEXPECTED_QUERY_MESSAGE, } from './query-types.js';
10
+ export { routePathsOf, routeEntryFor, prerenderedPathsOf, matchRoute, hrefFor, lazyPage, effectiveSpeculation, routePresence, sameRoute, decodeSearch, searchParam, DEFAULT_SSR_MODE, routeSection, } from './route-table.js';
11
+ export { fieldErrorOf, flashViewFor, formFieldsOf, formIdle, FORM_UNEXPECTED_MESSAGE, formMessageOf, formStatusOf, formSubmitting, isFormPending, } from './form-state.js';
12
+ export { afterSignIn, initRouter, routerListens, routerUrlChanged, signInRouteFor, updateRouter, Who, } from './route-model.js';
13
+ export { absoluteUrl, fillPath, headTagsFor, jsonLdText, pageTitle, resolveRouteHead, } from './head.js';
14
+ export { robotsTxt, sitemapPlan, sitemapXml, SITEMAP_MAX_URLS, SITEMAP_PATH, } from './seo.js';
15
+ export { AGENT_MANIFEST_TYPE, agentActions, agentField, agentToolDescriptors, checkAgentInput, inputJsonSchema, runAgentAction, } from './agent-actions.js';
16
+ export { defineIslands, } from './island-def.js';
17
+ export { definePageModel, } from './page-model-def.js';
18
+ export { caughtUpWith, rebaseDraft, } from './draft-rebase.js';
19
+ export { bindingSpecsOf, DEFAULT_SESSIONS_CRON, defineResources, resourceProblems, } from './resources.js';
20
+ // Client navigation policy (pure): what the kit's navigation runtime and
21
+ // `<PageNavigation>` decide, public so apps can test their route table's
22
+ // sections and speculation rules.
23
+ export { CLIENT_NAV_ACTIVE_ATTR, clientNavigationFor, inlineJson, speculationRulesFor, } from './navigation-policy.js';
24
+ export { CLIENT_NAV_DATA_TYPE, navigationDecision, parseClientNavigationData, } from './navigation-data.js';
25
+ export { matchPattern } from './route-params.js';
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The island table: every island root a page may render, by name, with how
3
+ * it wakes. Plain data (lazy imports are thunks), so the server and the
4
+ * island client entry both import it without loading any island.
5
+ *
6
+ * - `wake: "load"`: **hydrated** at page load. The server renders the
7
+ * island's real component (inside `<Hydration id>`), and the browser
8
+ * hydrates every such root in one pass, in one task, right after the
9
+ * page loads (solidjs/solid#3845: a root hydrated later silently replaces
10
+ * its server DOM).
11
+ * - `wake: "visible" | "interaction" | "idle"`: **client-only**. The server
12
+ * renders the use site's `fallback` (real, semantic HTML); when the wake
13
+ * trigger fires, the browser renders the island fresh over it. Never a
14
+ * late hydrate. Its module may be client-only code (`*-island.lazy.tsx`,
15
+ * CodeMirror): the server never loads it.
16
+ *
17
+ * The wake is part of the table entry, not the use site, so a hydrated
18
+ * island cannot be woken late and a lazy one cannot be hydrated: the API
19
+ * has no way to ask for a late hydrate.
20
+ */
21
+ /** When a page-level island starts: `load` hydrates at load; the rest are client-only renders. */
22
+ export type PageIslandWake = 'load' | 'visible' | 'interaction' | 'idle';
23
+ /** The lazy wakes (client-only renders over the server fallback). */
24
+ export type LazyIslandWake = Exclude<PageIslandWake, 'load'>;
25
+ /**
26
+ * JSON-only check for island props: every function (at any depth) becomes
27
+ * `never`, so passing a callback is a type error. Plain data (records,
28
+ * arrays, strings, numbers, booleans, null) passes through unchanged.
29
+ */
30
+ export type Json<T> = T extends (...args: never[]) => unknown ? never : T extends object ? {
31
+ readonly [K in keyof T]: Json<T[K]>;
32
+ } : T;
33
+ /** An island module: its default export is the island component. */
34
+ export interface IslandModule<P> {
35
+ readonly default: (props: P) => unknown;
36
+ }
37
+ /** One table entry as written in `defineIslands({...})`. */
38
+ export interface IslandSpec<P = any, W extends PageIslandWake = PageIslandWake> {
39
+ readonly wake: W;
40
+ readonly load: () => Promise<IslandModule<P>>;
41
+ }
42
+ /** A table entry with its name: what `<Island of={...}>` takes. */
43
+ export interface IslandDef<P, W extends PageIslandWake = PageIslandWake> {
44
+ readonly _tag: 'IslandDef';
45
+ readonly name: string;
46
+ readonly wake: W;
47
+ readonly load: () => Promise<IslandModule<P>>;
48
+ }
49
+ type PropsOfSpec<S> = S extends {
50
+ readonly load: () => Promise<{
51
+ readonly default: (props: infer P) => unknown;
52
+ }>;
53
+ } ? P : never;
54
+ type WakeOfSpec<S> = S extends {
55
+ readonly wake: infer W extends PageIslandWake;
56
+ } ? W : never;
57
+ /** The island table `defineIslands` returns. */
58
+ export type IslandTable<T extends Record<string, IslandSpec>> = {
59
+ readonly [K in keyof T]: IslandDef<PropsOfSpec<T[K]>, WakeOfSpec<T[K]>>;
60
+ };
61
+ /**
62
+ * Declares the app's island table (`src/islands.ts`). Read by pages
63
+ * (`<Island of={islands.planner} props={...} />`) and by the island client
64
+ * entry (`startIslands(islands, site)`), which finds each root's module by
65
+ * its name. Like the route table, every lazy import is a thunk: each island
66
+ * is its own client chunk, loaded only on pages that render it.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * export const islands = defineIslands({
71
+ * planner: { wake: "load", load: () => import("./features/planner/planner-island.tsx") },
72
+ * dpsChart: { wake: "interaction", load: () => import("./islands/live-demo-dps-chart-island.lazy.tsx") },
73
+ * });
74
+ * ```
75
+ */
76
+ export declare function defineIslands<const T extends Record<string, IslandSpec>>(specs: T): IslandTable<T>;
77
+ /** Island root element attributes (server markup, read by the client entry). */
78
+ export declare const ISLAND_ATTR: {
79
+ readonly name: 'data-kit-island';
80
+ readonly id: 'data-kit-island-id';
81
+ readonly props: 'data-kit-props';
82
+ readonly wake: 'data-kit-wake';
83
+ readonly state: 'data-island-state';
84
+ /** `<Island persist>`: the key (island name + JSON props) a client navigation keeps it by. */
85
+ readonly persist: 'data-kit-persist';
86
+ };
87
+ /** The class every island root element carries (`display: contents` in `@alecsibilia/ui-kit/ui`). */
88
+ export declare const ISLAND_CLASS = "kit-island";
89
+ export {};