foldkit-ssr 0.4.0 → 0.6.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.
- package/README.md +6 -0
- package/dist/{client-ASzkY6Sw.mjs → client-DVG9_3rL.mjs} +21 -4
- package/dist/client-DVG9_3rL.mjs.map +1 -0
- package/dist/{client-BDyZf200.d.mts → client-DkwAniQQ.d.mts} +195 -114
- package/dist/client-DkwAniQQ.d.mts.map +1 -0
- package/dist/client.d.mts +2 -2
- package/dist/client.mjs +1 -2
- package/dist/index.d.mts +176 -85
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +56 -24
- package/dist/index.mjs.map +1 -1
- package/dist/vite.d.mts +2 -2
- package/dist/vite.d.mts.map +1 -1
- package/package.json +17 -17
- package/dist/client-ASzkY6Sw.mjs.map +0 -1
- package/dist/client-BDyZf200.d.mts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ResumableBuilder, S as FALLBACK_FIELD, _ as
|
|
2
|
-
import { Cause, Effect,
|
|
1
|
+
import { C as UnnamedHandler, D as SLOT_ATTRIBUTE, E as ResumableBuilder, O as DecodedBinding, S as staticRegion, T as FALLBACK_FIELD, _ as metaMarkup, a as Loadable, b as serializeJsonScript, c as PlanSurface, d as ResumePart, f as ResumePlan, g as Start, h as STATIC_ATTRIBUTE, i as FOLDKIT_APP_ATTRIBUTE, k as EncodedBinding, l as RESUME_ATTRIBUTE, m as RouteMatch, o as META_ATTRIBUTE, p as ResumeRefused, r as UNTIL_LIMIT_MS, s as Meta, t as Resume, u as ResumableConfig, v as plan, w as BINDING_ATTRIBUTE, x as serving, y as resume } from "./client-DkwAniQQ.mjs";
|
|
2
|
+
import { Cause, Effect, Schema } from "effect";
|
|
3
3
|
import { EntryModule, RenderError, RenderedApplication } from "foldkit/experimental/server";
|
|
4
4
|
import { MetadataSummary } from "foldkit-surface";
|
|
5
5
|
//#region src/index.d.ts
|
|
@@ -10,6 +10,14 @@ interface EnvelopeOptions {
|
|
|
10
10
|
/** Every event the page's markers name, so the browser listens without scanning for them. */
|
|
11
11
|
readonly events?: ReadonlyArray<string> | undefined;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* The envelope for `model`: the plan's slice, each part's capture, and
|
|
15
|
+
* the route it was rendered for, if it was rendered for one. `SSR.render`
|
|
16
|
+
* carries it on the stamped root, beside Foldkit's own stamps, escaped for
|
|
17
|
+
* the attribute; this is the same JSON unescaped, for tests and hosts that
|
|
18
|
+
* place the page themselves.
|
|
19
|
+
*/
|
|
20
|
+
declare const envelope: <Model, Fields extends Schema.Struct.Fields>(resume: ResumePlan<Model, Fields>, model: Model, options?: EnvelopeOptions) => string;
|
|
13
21
|
/** Where the browser gets a Model path's value: the envelope, the baseline, or nowhere it may. */
|
|
14
22
|
export type Cover = 'state' | 'local' | 'missing';
|
|
15
23
|
/** One Surface as a plan covers it, for the server's Model. */
|
|
@@ -17,6 +25,19 @@ export interface SurfaceCoverage {
|
|
|
17
25
|
readonly name: string;
|
|
18
26
|
/** Whether the Surface is active for the server's Model. */
|
|
19
27
|
readonly active: boolean;
|
|
28
|
+
/** The instance key, for one instance of a `Surface.each` family. */
|
|
29
|
+
readonly key?: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The parent a family instance resolves through: the Surface whose Model
|
|
32
|
+
* reveals it, and the place that activates the parent, when readable.
|
|
33
|
+
*/
|
|
34
|
+
readonly via?: {
|
|
35
|
+
readonly surface: string;
|
|
36
|
+
readonly activation?: {
|
|
37
|
+
readonly path: string;
|
|
38
|
+
readonly cover: Cover;
|
|
39
|
+
} | undefined;
|
|
40
|
+
} | undefined;
|
|
20
41
|
/** The place a `Surface.when` activation reads; absent for `Surface.at`. */
|
|
21
42
|
readonly activation?: {
|
|
22
43
|
readonly path: string;
|
|
@@ -44,6 +65,12 @@ export interface PlanInspection {
|
|
|
44
65
|
readonly parts: ReadonlyArray<string>;
|
|
45
66
|
readonly surfaces: ReadonlyArray<SurfaceCoverage>;
|
|
46
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* How a plan covers each of its Surfaces when the server's Model is `model`.
|
|
70
|
+
* A Surface's reads depend on the Model, through its params, so coverage is
|
|
71
|
+
* worked out for a Model, not for the plan alone.
|
|
72
|
+
*/
|
|
73
|
+
declare const inspect: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, model: Model) => PlanInspection;
|
|
47
74
|
declare const ResumeUnsafe_base: Schema.Class<ResumeUnsafe, Schema.TaggedStruct<"ResumeUnsafe", {
|
|
48
75
|
readonly reason: Schema.Literals<readonly ["UndeclaredStartup", "Uncovered", "ViewDependsOnUnsentState", "DuplicateStaticRegion", "UngeneratablePath", "UnrestorablePart", "UnencodableBinding", "EagerStartRequired", "UndeclaredSurfaces", "BindingInStaticRegion", "VoidRootWithStyles"]>;
|
|
49
76
|
readonly message: Schema.String;
|
|
@@ -68,6 +95,31 @@ export interface RenderedPage {
|
|
|
68
95
|
*/
|
|
69
96
|
readonly unnamed: ReadonlyArray<UnnamedHandler>;
|
|
70
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Renders a page on the server against a resume plan.
|
|
100
|
+
*
|
|
101
|
+
* The application's `init` runs once. Its Model's slice is round-tripped
|
|
102
|
+
* through the plan's Schema and set onto the baseline, which is the Model the
|
|
103
|
+
* browser will start from, and the page is rendered from that Model. Every
|
|
104
|
+
* way the browser could start somewhere else is a `ResumeUnsafe`, whose
|
|
105
|
+
* `reason` names it; the README lists them. The one that matters most: the
|
|
106
|
+
* view rendered from the browser's Model differs from the one rendered from
|
|
107
|
+
* the server's, because it reads a field the plan leaves out. In production
|
|
108
|
+
* Foldkit would rebuild that part of the page silently, so this is the one
|
|
109
|
+
* place it shows.
|
|
110
|
+
*/
|
|
111
|
+
declare const render: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
|
|
112
|
+
readonly buildId: string;
|
|
113
|
+
readonly url?: string | undefined;
|
|
114
|
+
readonly flags?: unknown;
|
|
115
|
+
/**
|
|
116
|
+
* Markup for the first paint, given what was rendered, carried as the
|
|
117
|
+
* root's last child: keep it to `<style>`, which the browser drops on
|
|
118
|
+
* hydration. Anything a head owns (`meta`, links) stays with `SSR.page`
|
|
119
|
+
* and `SSR.generate`.
|
|
120
|
+
*/
|
|
121
|
+
readonly styles?: Head | undefined;
|
|
122
|
+
}) => Effect.Effect<RenderedPage, RenderError | ResumeUnsafe>;
|
|
71
123
|
/**
|
|
72
124
|
* What a page adds to its head, given what it rendered: such as a stylesheet
|
|
73
125
|
* of the classes the markup uses (`Style.usedIn` in `foldkit-mixins`). The
|
|
@@ -75,6 +127,18 @@ export interface RenderedPage {
|
|
|
75
127
|
* for pages whose template the host owns.
|
|
76
128
|
*/
|
|
77
129
|
export type Head = (rendered: RenderedApplication) => string;
|
|
130
|
+
/**
|
|
131
|
+
* The page to serve: the rendered application in the template, with the
|
|
132
|
+
* plan's `meta` and `head`'s markup, if any, before `</head>`. The envelope
|
|
133
|
+
* is already in the rendered root, so this is Foldkit's `injectIntoTemplate`
|
|
134
|
+
* with a head, and nothing else.
|
|
135
|
+
*/
|
|
136
|
+
declare const page: (template: string, result: {
|
|
137
|
+
readonly rendered: RenderedApplication;
|
|
138
|
+
readonly meta: string;
|
|
139
|
+
}, options?: {
|
|
140
|
+
readonly head?: Head | undefined;
|
|
141
|
+
}) => string;
|
|
78
142
|
/** A page generated at build time, and the file a static host serves it from. */
|
|
79
143
|
export interface GeneratedPage {
|
|
80
144
|
readonly path: string;
|
|
@@ -86,102 +150,129 @@ export interface GeneratedPage {
|
|
|
86
150
|
* are written out, so `const [home, about] = pages` needs no check.
|
|
87
151
|
*/
|
|
88
152
|
export type GeneratedPages<Paths extends ReadonlyArray<string>> = { readonly [K in keyof Paths]: GeneratedPage; };
|
|
153
|
+
/**
|
|
154
|
+
* A sitemap of the pages a build generated, each at its full address under
|
|
155
|
+
* `origin`, in the order given. `modified`, when a page has it, is any date
|
|
156
|
+
* `Date` reads, written as the UTC day. A path that does not start with `/`,
|
|
157
|
+
* a path given twice, and a date `Date` cannot read are refused: each would
|
|
158
|
+
* make a sitemap a search engine rejects or misreads.
|
|
159
|
+
*/
|
|
160
|
+
declare const sitemap: (pages: ReadonlyArray<{
|
|
161
|
+
readonly path: string;
|
|
162
|
+
readonly modified?: string | undefined;
|
|
163
|
+
}>, options: {
|
|
164
|
+
readonly origin: string;
|
|
165
|
+
}) => string;
|
|
166
|
+
/**
|
|
167
|
+
* A `robots.txt` that lets every crawler in, except under `disallow`, and
|
|
168
|
+
* names the sitemap at `sitemap` (default `/sitemap.xml`) under `origin`.
|
|
169
|
+
*/
|
|
170
|
+
declare const robots: (options: {
|
|
171
|
+
readonly origin: string;
|
|
172
|
+
readonly sitemap?: string | undefined;
|
|
173
|
+
readonly disallow?: ReadonlyArray<string> | undefined;
|
|
174
|
+
}) => string;
|
|
175
|
+
/**
|
|
176
|
+
* Renders pages at build time, one per path, each as `SSR.render` and
|
|
177
|
+
* `SSR.page` would, to be written as files. `origin` makes each path the full
|
|
178
|
+
* URL a routing application parses. `flags`, when the application has them,
|
|
179
|
+
* gives each path its own.
|
|
180
|
+
*
|
|
181
|
+
* A generated page records its path alone: a static host serves the same file
|
|
182
|
+
* whatever the query, so the browser checks the path and ignores the query. A
|
|
183
|
+
* path with a query or fragment, or two paths that would be one file, are
|
|
184
|
+
* refused.
|
|
185
|
+
*/
|
|
186
|
+
declare const generate: <Model, Fields extends Schema.Struct.Fields, const Paths extends ReadonlyArray<string>, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
|
|
187
|
+
readonly buildId: string;
|
|
188
|
+
readonly template: string;
|
|
189
|
+
readonly origin: string;
|
|
190
|
+
readonly paths: Paths;
|
|
191
|
+
readonly flags?: ((path: string) => unknown) | undefined;
|
|
192
|
+
readonly head?: Head | undefined;
|
|
193
|
+
}) => Effect.Effect<GeneratedPages<Paths>, RenderError | ResumeUnsafe>;
|
|
194
|
+
/**
|
|
195
|
+
* The server entry for Foldkit's pipeline: the `renderPage` a dev server,
|
|
196
|
+
* a fetch handler, or `handleRequest` calls, and that the `fetch.js` a Foldkit
|
|
197
|
+
* build emits imports from the server entry module, so a resumed page is
|
|
198
|
+
* served by Node and Workers alike.
|
|
199
|
+
*
|
|
200
|
+
* `GET` and `HEAD` render the page against the plan, with the request's URL
|
|
201
|
+
* and, when the application has Flags, `flags(request)`. `POST` goes to
|
|
202
|
+
* `SSR.handle` when the plan has a server fallback, and is answered `400` when
|
|
203
|
+
* the post is unusable. `OPTIONS` is answered `204`, and any other method
|
|
204
|
+
* `405`, each with the methods the entry answers in `allow` (`handleRequest`
|
|
205
|
+
* passes every method through). A render that fails, or a plan the render
|
|
206
|
+
* refuses, is answered `500` with the reason logged, never with a page the
|
|
207
|
+
* browser cannot resume. `headers(request)` rides on the `Rendered` result, so
|
|
208
|
+
* Foldkit's `toResponse` sets it over its own on the page: a cache policy, or
|
|
209
|
+
* a CORS answer to a preflight.
|
|
210
|
+
*
|
|
211
|
+
* The page is answered as `Rendered`: the rendered application carries the
|
|
212
|
+
* envelope in its root, so the host injects it into its own template with
|
|
213
|
+
* Foldkit's `injectIntoTemplate`, and a build can generate it with Foldkit's
|
|
214
|
+
* `prerender`. The template, and the container it fills, are the host's:
|
|
215
|
+
* `handleRequest` still classifies static misses and answers `HEAD` without
|
|
216
|
+
* a body.
|
|
217
|
+
*
|
|
218
|
+
* What the page says of itself (`meta`) and per-page `head` markup are
|
|
219
|
+
* written into a template's head, which the host owns here: a plan with
|
|
220
|
+
* `meta` is refused when the entry is made, and served with `SSR.generate`.
|
|
221
|
+
*/
|
|
222
|
+
declare const entry: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
|
|
223
|
+
readonly buildId: string;
|
|
224
|
+
readonly flags?: ((request: Request) => unknown | PromiseLike<unknown>) | undefined;
|
|
225
|
+
readonly headers?: ((request: Request) => HeadersInit) | undefined;
|
|
226
|
+
/**
|
|
227
|
+
* Markup for the first paint, carried as the rendered root's last child.
|
|
228
|
+
* The host owns the template in dynamic serving, so this is where
|
|
229
|
+
* per-page styles go; anything a head owns stays with `SSR.generate`.
|
|
230
|
+
*/
|
|
231
|
+
readonly styles?: Head | undefined;
|
|
232
|
+
}) => EntryModule;
|
|
89
233
|
declare const FallbackRefused_base: Schema.Class<FallbackRefused, Schema.TaggedStruct<"FallbackRefused", {
|
|
90
234
|
readonly reason: Schema.Literals<readonly ["Missing", "Unreadable", "Invalid", "Unlisted", "NoFallback"]>;
|
|
91
235
|
readonly message: Schema.String;
|
|
92
236
|
}>, Cause.YieldableError>;
|
|
93
237
|
/** Why a posted form was not handled: the request, not the page or the plan, is at fault. */
|
|
94
238
|
export declare class FallbackRefused extends FallbackRefused_base {}
|
|
239
|
+
/**
|
|
240
|
+
* Answers a form posted by a page rendered with `fallback: 'server'`: the
|
|
241
|
+
* posted Message is decoded through the plan's Message Schema, with posted
|
|
242
|
+
* fields of the same names as its own overriding them, and must be one the
|
|
243
|
+
* Surfaces active for the request's Model may send. The server then rebuilds
|
|
244
|
+
* the Model the browser had, `init` and then the plan's `boot` with every
|
|
245
|
+
* Command it leads to, runs `update` with the Message and every Command that
|
|
246
|
+
* follows, and renders the result as a fresh page.
|
|
247
|
+
*/
|
|
248
|
+
declare const handle: <Model, Fields extends Schema.Struct.Fields, Message = any>(request: Request, config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
|
|
249
|
+
readonly buildId: string;
|
|
250
|
+
readonly flags?: unknown;
|
|
251
|
+
readonly styles?: Head | undefined;
|
|
252
|
+
}) => Effect.Effect<RenderedPage, RenderError | ResumeUnsafe | FallbackRefused>;
|
|
95
253
|
export declare const SSR: {
|
|
96
|
-
plan:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
readonly id: string;
|
|
102
|
-
readonly state: import("foldkit-surface").WritableProjection<Model, Fields>;
|
|
103
|
-
readonly baseline?: Model | undefined;
|
|
104
|
-
readonly boot?: ((model: Model) => Commands) | undefined;
|
|
105
|
-
readonly local?: ReadonlyArray<{
|
|
106
|
-
readonly dependency: ReadonlyArray<string>;
|
|
107
|
-
}> | undefined;
|
|
108
|
-
readonly surfaces?: ReadonlyArray<import("foldkit-surface").ActiveSurface<Model>> | undefined;
|
|
109
|
-
readonly parts?: ReadonlyArray<ResumePart<Model>> | undefined;
|
|
110
|
-
readonly start?: Start | undefined;
|
|
111
|
-
readonly deferrable?: ReadonlyArray<string> | undefined;
|
|
112
|
-
readonly fallback?: "server" | undefined;
|
|
113
|
-
readonly meta?: ((model: Model) => Meta) | undefined;
|
|
114
|
-
readonly version?: unknown | undefined;
|
|
115
|
-
}) => ResumePlan<Model, Fields, Commands>;
|
|
116
|
-
envelope: <Model, Fields extends Schema.Struct.Fields>(resume: ResumePlan<Model, Fields>, model: Model, options?: EnvelopeOptions) => string;
|
|
117
|
-
resume: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, page: ParentNode, options?: {
|
|
118
|
-
readonly route?: string | undefined;
|
|
119
|
-
}) => Result.Result<Model, ResumeRefused>;
|
|
120
|
-
render: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
|
|
121
|
-
readonly buildId: string;
|
|
122
|
-
readonly url?: string | undefined;
|
|
123
|
-
readonly flags?: unknown;
|
|
124
|
-
/**
|
|
125
|
-
* Markup for the first paint, given what was rendered, carried as the
|
|
126
|
-
* root's last child: keep it to `<style>`, which the browser drops on
|
|
127
|
-
* hydration. Anything a head owns (`meta`, links) stays with `SSR.page`
|
|
128
|
-
* and `SSR.generate`.
|
|
129
|
-
*/
|
|
130
|
-
readonly styles?: Head | undefined;
|
|
131
|
-
}) => Effect.Effect<RenderedPage, RenderError | ResumeUnsafe>;
|
|
132
|
-
page: (template: string, result: {
|
|
133
|
-
readonly rendered: RenderedApplication;
|
|
134
|
-
readonly meta: string;
|
|
135
|
-
}, options?: {
|
|
136
|
-
readonly head?: Head | undefined;
|
|
137
|
-
}) => string;
|
|
254
|
+
plan: typeof plan;
|
|
255
|
+
envelope: typeof envelope;
|
|
256
|
+
resume: typeof resume;
|
|
257
|
+
render: typeof render;
|
|
258
|
+
page: typeof page;
|
|
138
259
|
hydrate: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
|
|
139
260
|
readonly buildId: string;
|
|
140
261
|
readonly when?: ((page: Document) => boolean) | undefined;
|
|
141
|
-
readonly otherwise?:
|
|
262
|
+
readonly otherwise?: 'render' | undefined;
|
|
142
263
|
readonly until?: ((model: Model) => boolean) | undefined;
|
|
143
264
|
readonly fresh?: ((version: unknown) => boolean) | undefined;
|
|
144
265
|
}) => void;
|
|
145
|
-
inspect:
|
|
146
|
-
static:
|
|
147
|
-
serving:
|
|
148
|
-
generate:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
readonly head?: Head | undefined;
|
|
155
|
-
}) => Effect.Effect<GeneratedPages<Paths>, RenderError | ResumeUnsafe>;
|
|
156
|
-
entry: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
|
|
157
|
-
readonly buildId: string;
|
|
158
|
-
readonly flags?: ((request: Request) => unknown | PromiseLike<unknown>) | undefined;
|
|
159
|
-
readonly headers?: ((request: Request) => HeadersInit) | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* Markup for the first paint, carried as the rendered root's last child.
|
|
162
|
-
* The host owns the template in dynamic serving, so this is where
|
|
163
|
-
* per-page styles go; anything a head owns stays with `SSR.generate`.
|
|
164
|
-
*/
|
|
165
|
-
readonly styles?: Head | undefined;
|
|
166
|
-
}) => EntryModule;
|
|
167
|
-
handle: <Model, Fields extends Schema.Struct.Fields, Message = any>(request: Request, config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
|
|
168
|
-
readonly buildId: string;
|
|
169
|
-
readonly flags?: unknown;
|
|
170
|
-
readonly styles?: Head | undefined;
|
|
171
|
-
}) => Effect.Effect<RenderedPage, RenderError | ResumeUnsafe | FallbackRefused>;
|
|
172
|
-
serializeJsonScript: (value: unknown) => string;
|
|
173
|
-
sitemap: (pages: ReadonlyArray<{
|
|
174
|
-
readonly path: string;
|
|
175
|
-
readonly modified?: string | undefined;
|
|
176
|
-
}>, options: {
|
|
177
|
-
readonly origin: string;
|
|
178
|
-
}) => string;
|
|
179
|
-
robots: (options: {
|
|
180
|
-
readonly origin: string;
|
|
181
|
-
readonly sitemap?: string | undefined;
|
|
182
|
-
readonly disallow?: ReadonlyArray<string> | undefined;
|
|
183
|
-
}) => string;
|
|
266
|
+
inspect: typeof inspect;
|
|
267
|
+
static: typeof staticRegion;
|
|
268
|
+
serving: typeof serving;
|
|
269
|
+
generate: typeof generate;
|
|
270
|
+
entry: typeof entry;
|
|
271
|
+
handle: typeof handle;
|
|
272
|
+
serializeJsonScript: typeof serializeJsonScript;
|
|
273
|
+
sitemap: typeof sitemap;
|
|
274
|
+
robots: typeof robots;
|
|
184
275
|
};
|
|
185
276
|
//#endregion
|
|
186
|
-
export { BINDING_ATTRIBUTE, type DecodedBinding, FALLBACK_FIELD, FOLDKIT_APP_ATTRIBUTE, type Loadable, META_ATTRIBUTE, type Meta, RESUME_ATTRIBUTE, type ResumableBuilder, type ResumableConfig, Resume, type ResumePart, type ResumePlan, ResumeRefused, SLOT_ATTRIBUTE, STATIC_ATTRIBUTE, type Start, UNTIL_LIMIT_MS, type UnnamedHandler, metaMarkup };
|
|
277
|
+
export { BINDING_ATTRIBUTE, type DecodedBinding, FALLBACK_FIELD, FOLDKIT_APP_ATTRIBUTE, type Loadable, META_ATTRIBUTE, type Meta, type PlanSurface, RESUME_ATTRIBUTE, type ResumableBuilder, type ResumableConfig, Resume, type ResumePart, type ResumePlan, ResumeRefused, SLOT_ATTRIBUTE, STATIC_ATTRIBUTE, type Start, UNTIL_LIMIT_MS, type UnnamedHandler, metaMarkup };
|
|
187
278
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;UA4FU;WACC;WACA,QAAQ;WACR,WAAW,cAAc;;WAEzB,SAAS;;;;;;;;;cAUd,WAAY,OAAO,eAAe,OAAO,OAAO,QAAM,QAClD,WAAW,OAAO,SAAO,OAC1B,OAAK,UACH;;YAgHC;;iBAGK;WACN;;WAEA;;WAEA;;;;;WAKA;aAEM;aACA;eAAwB;eAAuB,OAAO;;;;WAI5D;aAAwB;aAAuB,OAAO;;;WAEtD,OAAO;aAAyB;aAAuB,OAAO;;;;;;WAK9D,WAAW,cAAc;;WAEzB;;;iBAIM;WACN;WACA,OAAO;WACP,OAAO;;WAEP,OAAO;WACP,UAAU,cAAc;;;;;;;cA4C7B,UAAW,OAAO,eAAe,OAAO,OAAO,QAAM,MACnD,WAAW,OAAO,SAAO,OACxB,UACN;;;;;;qBA6JU,qBAAqB;;iBA+HjB;;;;;;WAMN,UAAU;;WAEV;;WAEA;;;;;WAKA,SAAS,cAAc;;;;;;;;;;;;;;;cAgB5B,SAAU,OAAO,eAAe,OAAO,OAAO,QAAQ,eAAa,QAC/D,gBAAgB,OAAO,UAAQ,MACjC,WAAW,OAAO,SAAO;WAEpB;WACA;WACA;;;;;;;WAOA,SAAS;MAEnB,OAAO,OAAO,cAAc,cAAc;;;;;;;YAmKjC,QAAQ,UAAU;;;;;;;cAwDxB,OAAI,kBACQ;WACG,UAAU;WAA8B;GAAc;WACrD,OAAO;;;iBAQZ;WACN;WACA;WACA;;;;;;YAOC,eAAe,cAAc,qCAC7B,WAAW,QAAQ;;;;;;;;cAyBzB,UAAO,OACJ;WAAyB;WAAuB;IAAgC;WACnE;;;;;;cA4BhB,SAAM;WACD;WACA;WACA,WAAW;;;;;;;;;;;;;cA+ChB,WACJ,OACA,eAAe,OAAO,OAAO,cACvB,cAAc,uBACpB,eAAa,QAEL,gBAAgB,OAAO,UAAQ,MACjC,WAAW,OAAO,SAAO;WAEpB;WACA;WACA;WACA,OAAO;WACP,UAAU;WACV,OAAO;MAEjB,OAAO,OAAO,eAAe,QAAQ,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyEhD,QAAS,OAAO,eAAe,OAAO,OAAO,QAAQ,eAAa,QAC9D,gBAAgB,OAAO,UAAQ,MACjC,WAAW,OAAO,SAAO;WAEpB;WACA,UAAU,SAAS,sBAAsB;WACzC,YAAY,SAAS,YAAY;;;;;;WAMjC,SAAS;MAEnB;;;;;;qBAgGU,wBAAwB;;;;;;;;;;cAgH/B,SAAU,OAAO,eAAe,OAAO,OAAO,QAAQ,eAAa,SAC9D,SAAO,QACR,gBAAgB,OAAO,UAAQ,MACjC,WAAW,OAAO,SAAO;WAEpB;WACA;WACA,SAAS;MAEnB,OAAO,OAAO,cAAc,cAAc,eAAe;qBAsE/C"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as tagOf, D as SLOT_ATTRIBUTE, E as FALLBACK_FIELD, O as withContext, S as staticRegion, T as FALLBACK_DEPTH_FIELD, _ as resume, a as META_ATTRIBUTE, b as serving, c as STATIC_ATTRIBUTE, d as codecOf, f as metaMarkup, g as projectionsOf, h as plan, i as FOLDKIT_APP_ATTRIBUTE, l as allowedTags, m as pathKey, n as SSR$1, o as RESUME_ATTRIBUTE, p as modelFrom, r as UNTIL_LIMIT_MS, s as ResumeRefused, t as Resume, u as attributeOf, v as routeOf, w as BINDING_ATTRIBUTE, x as startingFrom, y as serializeJsonScript } from "./client-DVG9_3rL.mjs";
|
|
2
2
|
import { Cause, Effect, Exit, Option, Result, Schema } from "effect";
|
|
3
3
|
import { FOLDKIT_FLAGS_ATTRIBUTE, Rendered, Responded, injectIntoTemplate, renderToString } from "foldkit/experimental/server";
|
|
4
4
|
import { Metadata } from "foldkit-surface";
|
|
@@ -18,8 +18,8 @@ import { Metadata } from "foldkit-surface";
|
|
|
18
18
|
* handover. This module is the server's side and the browser's
|
|
19
19
|
* (`foldkit-ssr/client`) together.
|
|
20
20
|
*/
|
|
21
|
-
/** The projections of the plan's
|
|
22
|
-
const activeProjections = (plan, model) => plan.surfaces.flatMap((
|
|
21
|
+
/** The projections of the plan's entries that are active for `model`. */
|
|
22
|
+
const activeProjections = (plan, model) => plan.surfaces.flatMap((source) => projectionsOf(source, model));
|
|
23
23
|
/**
|
|
24
24
|
* What the envelope carries of `model`: the plan's slice, encoded through its
|
|
25
25
|
* own Schema, and each part's capture.
|
|
@@ -144,31 +144,63 @@ const coverage = (plan, model, browser) => {
|
|
|
144
144
|
state: plan.state.dependencies.map(pathOf),
|
|
145
145
|
local: plan.local.map(pathOf),
|
|
146
146
|
parts: plan.parts.map((part) => part.id),
|
|
147
|
-
surfaces: plan.surfaces.
|
|
148
|
-
const served = Option.getOrUndefined(surface.projectionOf(model));
|
|
149
|
-
return {
|
|
150
|
-
name: surface.name,
|
|
151
|
-
active: served !== void 0,
|
|
152
|
-
...surface.activation === void 0 ? {} : { activation: {
|
|
153
|
-
path: pathOf(surface.activation.path),
|
|
154
|
-
cover: coverOf(surface.activation.path, plan)
|
|
155
|
-
} },
|
|
156
|
-
reads: (served?.dependencies ?? []).map((path) => ({
|
|
157
|
-
path: pathOf(path),
|
|
158
|
-
cover: coverOf(path, plan)
|
|
159
|
-
})),
|
|
160
|
-
unresumed: served === void 0 ? [] : Metadata.summarize(served.metadata).filter((summary) => !covered.has(summary.name)),
|
|
161
|
-
sameInBrowser: readsKey(served) === readsKey(Option.getOrUndefined(surface.projectionOf(browser)))
|
|
162
|
-
};
|
|
163
|
-
})
|
|
147
|
+
surfaces: plan.surfaces.flatMap((source) => coverSource(plan, covered, source, model, browser))
|
|
164
148
|
};
|
|
165
149
|
};
|
|
150
|
+
/** One coverage row: a lone Surface, a family's parent, or one family instance. */
|
|
151
|
+
const coverRow = (plan, covered, entry, served, browserServed) => ({
|
|
152
|
+
name: entry.name,
|
|
153
|
+
active: served !== void 0,
|
|
154
|
+
...entry.key === void 0 ? {} : { key: entry.key },
|
|
155
|
+
...entry.via === void 0 ? {} : { via: entry.via },
|
|
156
|
+
...entry.activation === void 0 ? {} : { activation: {
|
|
157
|
+
path: pathOf(entry.activation.path),
|
|
158
|
+
cover: coverOf(entry.activation.path, plan)
|
|
159
|
+
} },
|
|
160
|
+
reads: (served?.dependencies ?? []).map((path) => ({
|
|
161
|
+
path: pathOf(path),
|
|
162
|
+
cover: coverOf(path, plan)
|
|
163
|
+
})),
|
|
164
|
+
unresumed: served === void 0 ? [] : Metadata.summarize(served.metadata).filter((summary) => !covered.has(summary.name)),
|
|
165
|
+
sameInBrowser: readsKey(served) === readsKey(browserServed)
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* A plan entry's coverage rows: one for a lone Surface, or a family's parent
|
|
169
|
+
* followed by one row per instance. The parent row keeps the parent's reads
|
|
170
|
+
* covered; each instance row says which key it is and which parent reveals
|
|
171
|
+
* it, so a gap names the instance (`Member[u1]`), not just the Surface.
|
|
172
|
+
*/
|
|
173
|
+
const coverSource = (plan, covered, source, model, browser) => {
|
|
174
|
+
const from = source.from;
|
|
175
|
+
if (from === void 0 || typeof source.instancesOf !== "function") {
|
|
176
|
+
const lone = source;
|
|
177
|
+
return [coverRow(plan, covered, lone, Option.getOrUndefined(lone.projectionOf(model)), Option.getOrUndefined(lone.projectionOf(browser)))];
|
|
178
|
+
}
|
|
179
|
+
const family = source;
|
|
180
|
+
const rows = [coverRow(plan, covered, from, Option.getOrUndefined(from.projectionOf(model)), Option.getOrUndefined(from.projectionOf(browser)))];
|
|
181
|
+
if (rows[0]?.active !== true) return rows;
|
|
182
|
+
const browserInstances = family.instancesOf(browser);
|
|
183
|
+
for (const instance of family.instancesOf(model)) rows.push(coverRow(plan, covered, {
|
|
184
|
+
name: family.name,
|
|
185
|
+
key: instance.key,
|
|
186
|
+
via: {
|
|
187
|
+
surface: from.name,
|
|
188
|
+
...from.activation === void 0 ? {} : { activation: {
|
|
189
|
+
path: pathOf(from.activation.path),
|
|
190
|
+
cover: coverOf(from.activation.path, plan)
|
|
191
|
+
} }
|
|
192
|
+
}
|
|
193
|
+
}, instance.projection, browserInstances.find((other) => other.key === instance.key)?.projection));
|
|
194
|
+
return rows;
|
|
195
|
+
};
|
|
196
|
+
/** A coverage row as a shortfall names it: `Member[u1]` for an instance, the name alone otherwise. */
|
|
197
|
+
const displayOf = (surface) => surface.key === void 0 ? surface.name : `${surface.name}[${surface.key}]`;
|
|
166
198
|
/** Each way an inspection shows the plan falls short, one line each. */
|
|
167
199
|
const shortfalls = (inspection) => inspection.surfaces.flatMap((surface) => [
|
|
168
|
-
...surface.activation?.cover === "missing" ? [`Surface "${surface
|
|
169
|
-
...surface.reads.filter((read) => read.cover === "missing").map((read) => `Surface "${surface
|
|
170
|
-
...surface.unresumed.map((summary) => `Surface "${surface
|
|
171
|
-
...surface.sameInBrowser ? [] : [`Surface "${surface
|
|
200
|
+
...surface.activation?.cover === "missing" ? [`Surface "${displayOf(surface)}" is activated by ${surface.activation.path}, which is neither in the plan's state nor local`] : [],
|
|
201
|
+
...surface.reads.filter((read) => read.cover === "missing").map((read) => `Surface "${displayOf(surface)}" reads ${read.path}, which is neither in the plan's state nor local`),
|
|
202
|
+
...surface.unresumed.map((summary) => `Surface "${displayOf(surface)}" reads ${summary.name} data (${summary.entries.join(", ")}), which no part of the plan resumes`),
|
|
203
|
+
...surface.sameInBrowser ? [] : [`Surface "${displayOf(surface)}" is ${surface.active ? "active" : "inactive"} on the server and activates differently from the Model the browser starts from`]
|
|
172
204
|
]);
|
|
173
205
|
/** Why a server refused to render a page against its plan. */
|
|
174
206
|
var ResumeUnsafe = class extends Schema.TaggedError()("ResumeUnsafe", {
|