foldkit-ssr 0.5.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 CHANGED
@@ -844,3 +844,5 @@ const Message = defineMessageUnion({
844
844
  why, phase by phase.
845
845
  - [What the tests prove](./test/README.md).
846
846
  - [What this package asks of Foldkit](../../docs/upstream-foldkit-ssr.md).
847
+ - [Site, Remote and SSR together](../../docs/site-remote-ssr.md): a routed
848
+ application rendered with its server data, taken over, and built statically.
@@ -3,6 +3,59 @@ import { ActiveSurface, Metadata, SurfaceSource, WritableProjection } from "fold
3
3
  import { Attribute, Html, HtmlBuilder, KeyboardModifiers } from "foldkit/html";
4
4
  import { Runtime } from "foldkit";
5
5
  import { Ports } from "foldkit/port";
6
+ //#region src/listen.d.ts
7
+ /**
8
+ * A binding as the envelope carries it: Foldkit's attribute (`OnSubmit`,
9
+ * `OnBlur`), whose tag says what its handler does beside dispatching; the
10
+ * Message, encoded through the application's Message Schema (for a hole, with
11
+ * the hole filled by a placeholder); the fields the event fills, `depth`
12
+ * placement wrappers down; and the attribute's options. Its ordinal is its
13
+ * index.
14
+ */
15
+ interface EncodedBinding {
16
+ readonly attribute: string;
17
+ readonly message: unknown;
18
+ readonly hole?: ReadonlyArray<string>;
19
+ readonly depth?: number;
20
+ readonly options?: unknown;
21
+ }
22
+ /** A binding decoded from the page: its Message is one of the application's. */
23
+ interface DecodedBinding {
24
+ readonly attribute: string;
25
+ readonly event: string;
26
+ readonly message: unknown;
27
+ readonly hole?: ReadonlyArray<string> | undefined;
28
+ readonly depth?: number | undefined;
29
+ readonly options?: unknown;
30
+ }
31
+ /**
32
+ * What the markers make of one event: the Messages its bindings dispatch, in
33
+ * the order the live page would, and, when the walk met a handler the page
34
+ * could not name, that element. An answer with `unnamed` is incomplete: the
35
+ * live page would do more than its Messages say.
36
+ */
37
+ interface Answer {
38
+ readonly event: Event;
39
+ readonly messages: ReadonlyArray<unknown>;
40
+ readonly unnamed?: Element | undefined;
41
+ }
42
+ interface ListenOptions {
43
+ readonly bindings: ReadonlyArray<DecodedBinding>;
44
+ readonly onAnswer: (answer: Answer) => void;
45
+ /**
46
+ * Every event the page's markers name, as the envelope lists them. Given,
47
+ * `listen` needs no pass over the page to find the events a marker names
48
+ * with `*` alone; without it, it reads every element's attributes, which on
49
+ * a large page is most of its cost.
50
+ */
51
+ readonly events?: Iterable<string> | undefined;
52
+ }
53
+ /**
54
+ * Listens at `root` for every event the bindings name, and answers each from
55
+ * the markers. Returns what removes the listeners.
56
+ */
57
+ declare const listen: (root: Element, options: ListenOptions) => (() => void);
58
+ //#endregion
6
59
  //#region src/resumable.d.ts
7
60
  /** The attribute prefix of an element's binding marker. */
8
61
  declare const BINDING_ATTRIBUTE = "data-foldkit-plus-on-";
@@ -65,6 +118,17 @@ type ResumableBuilder<Message> = Omit<HtmlBuilder<Message>, 'OnInput' | 'OnChang
65
118
  readonly OnKeyDown: KeyHole<Message>;
66
119
  readonly OnKeyUp: KeyHole<Message>;
67
120
  };
121
+ /**
122
+ * The resumable builder for a view's `h`. Use it in place of `h`; it has the
123
+ * same elements and attributes, and the hole forms of the four value events.
124
+ */
125
+ declare const builder: <Builder extends AnyBuilder>(h: Builder) => ResumableBuilder<MessageOf<Builder>>;
126
+ /**
127
+ * A view or renderer written against the resumable builder, as one that takes
128
+ * the builder it is given: `Surface.rootView(Page, params, Resume.view(render))`,
129
+ * `SurfaceView.define`, or an application's own view.
130
+ */
131
+ declare const view: <Model, Builder extends AnyBuilder, Out>(render: (model: Model, rh: ResumableBuilder<MessageOf<Builder>>) => Out) => (model: Model, h: Builder) => Out;
68
132
  //#endregion
69
133
  //#region src/context.d.ts
70
134
  type Region = ReadonlyArray<Html | string>;
@@ -74,54 +138,6 @@ interface UnnamedHandler {
74
138
  readonly event: string;
75
139
  }
76
140
  //#endregion
77
- //#region src/listen.d.ts
78
- /**
79
- * A binding as the envelope carries it: Foldkit's attribute (`OnSubmit`,
80
- * `OnBlur`), whose tag says what its handler does beside dispatching; the
81
- * Message, encoded through the application's Message Schema (for a hole, with
82
- * the hole filled by a placeholder); the fields the event fills, `depth`
83
- * placement wrappers down; and the attribute's options. Its ordinal is its
84
- * index.
85
- */
86
- interface EncodedBinding {
87
- readonly attribute: string;
88
- readonly message: unknown;
89
- readonly hole?: ReadonlyArray<string>;
90
- readonly depth?: number;
91
- readonly options?: unknown;
92
- }
93
- /** A binding decoded from the page: its Message is one of the application's. */
94
- interface DecodedBinding {
95
- readonly attribute: string;
96
- readonly event: string;
97
- readonly message: unknown;
98
- readonly hole?: ReadonlyArray<string> | undefined;
99
- readonly depth?: number | undefined;
100
- readonly options?: unknown;
101
- }
102
- /**
103
- * What the markers make of one event: the Messages its bindings dispatch, in
104
- * the order the live page would, and, when the walk met a handler the page
105
- * could not name, that element. An answer with `unnamed` is incomplete: the
106
- * live page would do more than its Messages say.
107
- */
108
- interface Answer {
109
- readonly event: Event;
110
- readonly messages: ReadonlyArray<unknown>;
111
- readonly unnamed?: Element | undefined;
112
- }
113
- interface ListenOptions {
114
- readonly bindings: ReadonlyArray<DecodedBinding>;
115
- readonly onAnswer: (answer: Answer) => void;
116
- /**
117
- * Every event the page's markers name, as the envelope lists them. Given,
118
- * `listen` needs no pass over the page to find the events a marker names
119
- * with `*` alone; without it, it reads every element's attributes, which on
120
- * a large page is most of its cost.
121
- */
122
- readonly events?: Iterable<string> | undefined;
123
- }
124
- //#endregion
125
141
  //#region src/shared.d.ts
126
142
  /**
127
143
  * The attribute Foldkit's server stamps on an application's root, as
@@ -135,6 +151,12 @@ declare const FOLDKIT_APP_ATTRIBUTE = "data-foldkit-app";
135
151
  * beside the app stamp, and the client reads it before adopting anything.
136
152
  */
137
153
  declare const RESUME_ATTRIBUTE = "data-foldkit-plus-resume";
154
+ /**
155
+ * JSON for a script element: `<` is escaped so `</script>` in the data ends
156
+ * nothing. U+2028 and U+2029 are escaped too: they are fine in JSON and break a
157
+ * reader that treats the text as JavaScript.
158
+ */
159
+ declare const serializeJsonScript: (value: unknown) => string;
138
160
  /**
139
161
  * What a page says of itself beyond Foldkit's `Document` (`title`, `lang`,
140
162
  * `dir`, `canonical`, `ogUrl`): what a search result and a link preview show.
@@ -244,6 +266,36 @@ declare const ResumeRefused_base: Schema.Class<ResumeRefused, Schema.TaggedStruc
244
266
  }>, import("effect/Cause").YieldableError>;
245
267
  /** Why a page's resume envelope was refused. */
246
268
  declare class ResumeRefused extends ResumeRefused_base {}
269
+ /**
270
+ * A resume plan for an application. The baseline defaults to the
271
+ * application's initial Model. It is never written: a writable projection's
272
+ * `set` returns a new Model, so a baseline Foldkit freezes in development is
273
+ * safe to start from.
274
+ *
275
+ * `surfaces` are the Surfaces the browser may activate, and `local` the Model
276
+ * fields allowed to start from the baseline, such as an open menu. Rendering
277
+ * refuses a plan that leaves a Surface's read or activation in neither.
278
+ */
279
+ declare const plan: <Model, Fields extends Schema.Struct.Fields, Commands = unknown>(application: {
280
+ readonly initial: Model;
281
+ readonly owner?: object;
282
+ readonly Message?: Schema.Top | undefined;
283
+ }, config: {
284
+ readonly id: string;
285
+ readonly state: WritableProjection<Model, Fields>;
286
+ readonly baseline?: Model | undefined;
287
+ readonly boot?: ((model: Model) => Commands) | undefined;
288
+ readonly local?: ReadonlyArray<{
289
+ readonly dependency: ReadonlyArray<string>;
290
+ }> | undefined;
291
+ readonly surfaces?: ReadonlyArray<PlanSurface<Model>> | undefined;
292
+ readonly parts?: ReadonlyArray<ResumePart<Model>> | undefined;
293
+ readonly start?: Start | undefined;
294
+ readonly deferrable?: ReadonlyArray<string> | undefined;
295
+ readonly fallback?: 'server' | undefined;
296
+ readonly meta?: ((model: Model) => Meta) | undefined;
297
+ readonly version?: unknown | undefined;
298
+ }) => ResumePlan<Model, Fields, Commands>;
247
299
  /**
248
300
  * How a page's recorded route is compared with the browser's. `full` compares
249
301
  * path and query. `path` compares the path alone, ignoring a trailing slash or
@@ -251,8 +303,36 @@ declare class ResumeRefused extends ResumeRefused_base {}
251
303
  * for every query, and for `/about` and `/about/` alike.
252
304
  */
253
305
  type RouteMatch = 'full' | 'path';
306
+ /**
307
+ * The Model a page resumes from: the baseline with the stamped root's envelope
308
+ * set onto it. Refused, with the reason, when the page holds no stamped root
309
+ * or more than one, when the root carries no envelope or not JSON, when it is
310
+ * not this protocol or this plan, or when the slice does not decode through
311
+ * the plan's Schema. A page is never half-restored.
312
+ */
313
+ declare const resume: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, page: ParentNode, options?: {
314
+ readonly route?: string | undefined;
315
+ }) => Result.Result<Model, ResumeRefused>;
254
316
  /** The attribute on a static region's element, naming the region. */
255
317
  declare const STATIC_ATTRIBUTE = "data-foldkit-plus-static";
318
+ /**
319
+ * A region of the page the server owns for the life of the document. It is
320
+ * rendered on the server with the inert builder, so it can dispatch no
321
+ * Message. The browser adopts the server's markup as trusted `InnerHTML` and
322
+ * never runs `render`, so the region reads nothing from the browser's Model
323
+ * and a plan need not send what it reads.
324
+ *
325
+ * A region changes only with a new document. Content a Message should change
326
+ * belongs in a Surface, not here.
327
+ */
328
+ declare const staticRegion: (id: string, render: (ih: HtmlBuilder<never>) => Region) => Html;
329
+ /**
330
+ * Whether the view call in progress is the server rendering a page, rather than the browser: true
331
+ * through both of `render`'s passes, false while the browser resumes and outside any render. For a
332
+ * view that sends markup it will adopt in the browser rather than draw there, such as
333
+ * `foldkit-richtext-dom`'s editor host, whose placement takes this as `serverRendered`.
334
+ */
335
+ declare const serving: () => boolean;
256
336
  /**
257
337
  * The `makeApplication` options `SSR` hands to Foldkit as they are, typed as
258
338
  * Foldkit types them.
@@ -295,78 +375,77 @@ interface Loadable {
295
375
  readonly load: () => Promise<void>;
296
376
  readonly isLoaded: () => boolean;
297
377
  }
378
+ /**
379
+ * The page's bindings, decoded through the plan's Message Schema, kept to the
380
+ * Messages the Surfaces active for `model` may send, and checked against
381
+ * every marker in `root`. Refused, with the reason, when the page carries
382
+ * none, an entry is not one of the application's Messages or one no active
383
+ * Surface lists, or a marker names a binding the page does not carry: a page
384
+ * is answered whole or not at all.
385
+ */
386
+ declare const bindings: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, page: ParentNode, root: Element, model: Model) => Result.Result<ReadonlyArray<DecodedBinding>, ResumeRefused>;
298
387
  //#endregion
299
388
  //#region src/client.d.ts
389
+ /**
390
+ * Starts the browser from the page's resumed Model, without running `init`.
391
+ *
392
+ * In the order Foldkit checks a page: the build id first, before the payload
393
+ * is read, then the envelope and its route. A page from another build is
394
+ * refused by Foldkit itself. A page that cannot resume is refused and contained
395
+ * by Foldkit's own refusal, and the reason is logged. A server page is never
396
+ * rendered again on the client. A page with no server render at all, no
397
+ * stamped root, is rendered on the client as usual.
398
+ */
399
+ declare const hydrate: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
400
+ readonly buildId: string;
401
+ /**
402
+ * Whether this page is taken over: asked before anything is adopted, so
403
+ * a page showing another reader's data never becomes live facts. Omitted
404
+ * adopts as before. Must not throw: a throwing predicate propagates out
405
+ * of `hydrate` with no runtime booted and nothing contained.
406
+ */
407
+ readonly when?: ((page: Document) => boolean) | undefined;
408
+ /**
409
+ * What a declined or stale page does: `render` runs the application
410
+ * afresh where the rendered page is, replacing its markup in place (the
411
+ * config's container with no served page). Omitted contains the page the
412
+ * way a resume failure does.
413
+ */
414
+ readonly otherwise?: 'render' | undefined;
415
+ /**
416
+ * With `otherwise: 'render'`, when the fresh application is ready to be
417
+ * seen: until a Model it has drawn satisfies this, it draws out of view
418
+ * and the served page stays, so a page is not swapped for its loading
419
+ * state and back. Omitted, the fresh application replaces the page at
420
+ * once. The served page stays no longer than `UNTIL_LIMIT_MS`.
421
+ */
422
+ readonly until?: ((model: Model) => boolean) | undefined;
423
+ /**
424
+ * Whether the plan's data version is still current: asked once, with
425
+ * `plan.version`, before anything is adopted. Omitted never asks. A plan
426
+ * with no version still asks, with `undefined` (a check shaped like
427
+ * `version === expected` then marks every such page stale). Must not
428
+ * throw, as `when`.
429
+ */
430
+ readonly fresh?: ((version: unknown) => boolean) | undefined;
431
+ }) => void;
300
432
  /** The longest a served page stays in view while a fresh application waits for `until`. */
301
433
  declare const UNTIL_LIMIT_MS = 3000;
302
434
  /** The resumable track: bindings the server's markup names, so a page can answer before it boots. */
303
435
  declare const Resume: {
304
- builder: <Builder extends AnyBuilder>(h: Builder) => ResumableBuilder<MessageOf<Builder>>;
305
- view: <Model, Builder extends AnyBuilder, Out>(render: (model: Model, rh: ResumableBuilder<MessageOf<Builder>>) => Out) => (model: Model, h: Builder) => Out;
306
- bindings: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, page: ParentNode, root: Element, model: Model) => Result.Result<ReadonlyArray<DecodedBinding>, ResumeRefused>;
307
- listen: (root: Element, options: ListenOptions) => (() => void);
436
+ builder: typeof builder;
437
+ view: typeof view;
438
+ bindings: typeof bindings;
439
+ listen: typeof listen;
308
440
  };
309
441
  /** The browser's part of `SSR`: the same functions, without the server's. */
310
442
  declare const SSR: {
311
- plan: <Model, Fields extends Schema.Struct.Fields, Commands = unknown>(application: {
312
- readonly initial: Model;
313
- readonly owner?: object;
314
- readonly Message?: Schema.Top | undefined;
315
- }, config: {
316
- readonly id: string;
317
- readonly state: import("foldkit-surface").WritableProjection<Model, Fields>;
318
- readonly baseline?: Model | undefined;
319
- readonly boot?: ((model: Model) => Commands) | undefined;
320
- readonly local?: ReadonlyArray<{
321
- readonly dependency: ReadonlyArray<string>;
322
- }> | undefined;
323
- readonly surfaces?: ReadonlyArray<PlanSurface<Model>> | undefined;
324
- readonly parts?: ReadonlyArray<ResumePart<Model>> | undefined;
325
- readonly start?: Start | undefined;
326
- readonly deferrable?: ReadonlyArray<string> | undefined;
327
- readonly fallback?: "server" | undefined;
328
- readonly meta?: ((model: Model) => Meta) | undefined;
329
- readonly version?: unknown | undefined;
330
- }) => ResumePlan<Model, Fields, Commands>;
331
- resume: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, page: ParentNode, options?: {
332
- readonly route?: string | undefined;
333
- }) => Result.Result<Model, ResumeRefused>;
334
- hydrate: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
335
- readonly buildId: string;
336
- /**
337
- * Whether this page is taken over: asked before anything is adopted, so
338
- * a page showing another reader's data never becomes live facts. Omitted
339
- * adopts as before. Must not throw: a throwing predicate propagates out
340
- * of `hydrate` with no runtime booted and nothing contained.
341
- */
342
- readonly when?: ((page: Document) => boolean) | undefined;
343
- /**
344
- * What a declined or stale page does: `render` runs the application
345
- * afresh where the rendered page is, replacing its markup in place (the
346
- * config's container with no served page). Omitted contains the page the
347
- * way a resume failure does.
348
- */
349
- readonly otherwise?: "render" | undefined;
350
- /**
351
- * With `otherwise: 'render'`, when the fresh application is ready to be
352
- * seen: until a Model it has drawn satisfies this, it draws out of view
353
- * and the served page stays, so a page is not swapped for its loading
354
- * state and back. Omitted, the fresh application replaces the page at
355
- * once. The served page stays no longer than `UNTIL_LIMIT_MS`.
356
- */
357
- readonly until?: ((model: Model) => boolean) | undefined;
358
- /**
359
- * Whether the plan's data version is still current: asked once, with
360
- * `plan.version`, before anything is adopted. Omitted never asks. A plan
361
- * with no version still asks, with `undefined` (a check shaped like
362
- * `version === expected` then marks every such page stale). Must not
363
- * throw, as `when`.
364
- */
365
- readonly fresh?: ((version: unknown) => boolean) | undefined;
366
- }) => void;
367
- static: (id: string, render: (ih: import("foldkit/html").HtmlBuilder<never>) => Region) => import("foldkit/html").Html;
368
- serving: () => boolean;
443
+ plan: typeof plan;
444
+ resume: typeof resume;
445
+ hydrate: typeof hydrate;
446
+ static: typeof staticRegion;
447
+ serving: typeof serving;
369
448
  };
370
449
  //#endregion
371
- export { FALLBACK_FIELD as C, BINDING_ATTRIBUTE as S, SLOT_ATTRIBUTE as T, metaMarkup as _, Loadable as a, Region as b, PlanSurface as c, ResumePart as d, ResumePlan as f, Start as g, STATIC_ATTRIBUTE as h, FOLDKIT_APP_ATTRIBUTE as i, RESUME_ATTRIBUTE as l, RouteMatch as m, SSR as n, META_ATTRIBUTE as o, ResumeRefused as p, UNTIL_LIMIT_MS as r, Meta as s, Resume as t, ResumableConfig as u, DecodedBinding as v, ResumableBuilder as w, UnnamedHandler as x, EncodedBinding as y };
372
- //# sourceMappingURL=client-NuipTFHy.d.mts.map
450
+ export { UnnamedHandler as C, SLOT_ATTRIBUTE as D, ResumableBuilder as E, DecodedBinding as O, staticRegion as S, FALLBACK_FIELD as T, metaMarkup as _, Loadable as a, serializeJsonScript as b, PlanSurface as c, ResumePart as d, ResumePlan as f, Start as g, STATIC_ATTRIBUTE as h, FOLDKIT_APP_ATTRIBUTE as i, EncodedBinding as k, RESUME_ATTRIBUTE as l, RouteMatch as m, SSR as n, META_ATTRIBUTE as o, ResumeRefused as p, UNTIL_LIMIT_MS as r, Meta as s, Resume as t, ResumableConfig as u, plan as v, BINDING_ATTRIBUTE as w, serving as x, resume as y };
451
+ //# sourceMappingURL=client-DkwAniQQ.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-DkwAniQQ.d.mts","names":[],"sources":["../src/listen.ts","../src/resumable.ts","../src/context.ts","../src/shared.ts","../src/client.ts"],"mappings":";;;;;;;;;;;;;;UA0BiB;WACN;WACA;WACA,OAAO;WACP;WACA;;;UA8CM;WACN;WACA;WACA;WACA,OAAO;WACP;WACA;;;;;;;;UAkIM;WACN,OAAO;WACP,UAAU;WACV,UAAU;;UAGJ;WACN,UAAU,cAAc;WACxB,WAAW,QAAQ;;;;;;;WAOnB,SAAS;;;;;;cAOP,SAAM,MAAU,SAAO,SAAW;;;;cCvNlC;;cA4GA;;cAMA;cAEC;;UAGG,QAAQ;YACb,UAAU;;KAGjB,QAAQ,GAAG,IAAI,KAAK,sBAAsB,YAAY;;KAGtD,kBAAkB,OAAO;WAAiB,QAAQ,OAAO,OAAO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mB,OAAO,WAAW,QACxC,KACE,QAAQ,yBAAyB,OAAO,uBAAuB;;;;;;;UAkBlD,gBAAgB,OAAO,uBAAuB,mBAAmB,OAAO;WAC9E,OAAO,OAAO,MAAM;WACpB,UAAU,MAAM;aACd,OAAO;aACP,WAAW;eAAyB;;;WAEtC,SAAS,OAAO,OAAO,SAAS;aAAuB,OAAO;;WAC9D,OAAO,OAAO,OAAO;WACrB,WAAW;WACX;WACA,gBAAgB,SAAS;WACzB,mBAAmB,SAAS;;WAE5B,YAAY,MAAM;;;;;;WAMlB,OAAO,cAAc;;;UAIf;WACN;WACA,YAAY;WACZ;;;;;;;;;;cAiCE,WAAY,OAAO,eAAe,OAAO,OAAO,QAAM,MAC3D,WAAW,OAAO,SAAO,MACzB,YAAU,MACV,SAAO,OACN,UACN,OAAO,OAAO,cAAc,iBAAiB;;;;;;;;;;;;;cC7jB1C,UAAW,OAAO,eAAe,OAAO,OAAO,QAAQ,eAAa,QAChE,gBAAgB,OAAO,UAAQ,MACjC,WAAW,OAAO,SAAO;WAEpB;;;;;;;WAOA,SAAS,MAAM;;;;;;;WAOf;;;;;;;;WAQA,UAAU,OAAO;;;;;;;;WAQjB,UAAU;;;cAgGV;;cA8JA;;;;;;;cAGA"}
package/dist/client.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as FALLBACK_FIELD, S as BINDING_ATTRIBUTE, T as SLOT_ATTRIBUTE, _ as metaMarkup, a as Loadable, c as PlanSurface, d as ResumePart, f as ResumePlan, g as Start, h as STATIC_ATTRIBUTE, i as FOLDKIT_APP_ATTRIBUTE, l as RESUME_ATTRIBUTE, n as SSR, o as META_ATTRIBUTE, p as ResumeRefused, r as UNTIL_LIMIT_MS, s as Meta, t as Resume, u as ResumableConfig, v as DecodedBinding, w as ResumableBuilder, x as UnnamedHandler } from "./client-NuipTFHy.mjs";
1
+ import { C as UnnamedHandler, D as SLOT_ATTRIBUTE, E as ResumableBuilder, O as DecodedBinding, T as FALLBACK_FIELD, _ as metaMarkup, a as Loadable, c as PlanSurface, d as ResumePart, f as ResumePlan, g as Start, h as STATIC_ATTRIBUTE, i as FOLDKIT_APP_ATTRIBUTE, l as RESUME_ATTRIBUTE, n as SSR, o as META_ATTRIBUTE, p as ResumeRefused, r as UNTIL_LIMIT_MS, s as Meta, t as Resume, u as ResumableConfig, w as BINDING_ATTRIBUTE } from "./client-DkwAniQQ.mjs";
2
2
  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, SSR, STATIC_ATTRIBUTE, type Start, UNTIL_LIMIT_MS, type UnnamedHandler, metaMarkup };
package/dist/client.mjs CHANGED
@@ -1,2 +1 @@
1
- import { D as SLOT_ATTRIBUTE, E as FALLBACK_FIELD, a as META_ATTRIBUTE, c as STATIC_ATTRIBUTE, f as metaMarkup, i as FOLDKIT_APP_ATTRIBUTE, n as SSR, o as RESUME_ATTRIBUTE, r as UNTIL_LIMIT_MS, s as ResumeRefused, t as Resume, w as BINDING_ATTRIBUTE } from "./client-DVG9_3rL.mjs";
2
- export { BINDING_ATTRIBUTE, FALLBACK_FIELD, FOLDKIT_APP_ATTRIBUTE, META_ATTRIBUTE, RESUME_ATTRIBUTE, Resume, ResumeRefused, SLOT_ATTRIBUTE, SSR, STATIC_ATTRIBUTE, UNTIL_LIMIT_MS, metaMarkup };
1
+ export { w as BINDING_ATTRIBUTE, E as FALLBACK_FIELD, i as FOLDKIT_APP_ATTRIBUTE, a as META_ATTRIBUTE, o as RESUME_ATTRIBUTE, t as Resume, s as ResumeRefused, D as SLOT_ATTRIBUTE, n as SSR, c as STATIC_ATTRIBUTE, r as UNTIL_LIMIT_MS, f as metaMarkup } from "./client-DVG9_3rL.mjs";
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as FALLBACK_FIELD, S as BINDING_ATTRIBUTE, T as SLOT_ATTRIBUTE, _ as metaMarkup, a as Loadable, b as Region, c as PlanSurface, d as ResumePart, f as ResumePlan, g as Start, h as STATIC_ATTRIBUTE, i as FOLDKIT_APP_ATTRIBUTE, 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 DecodedBinding, w as ResumableBuilder, x as UnnamedHandler, y as EncodedBinding } from "./client-NuipTFHy.mjs";
2
- import { Cause, Effect, Result, Schema } from "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. */
@@ -57,6 +65,12 @@ export interface PlanInspection {
57
65
  readonly parts: ReadonlyArray<string>;
58
66
  readonly surfaces: ReadonlyArray<SurfaceCoverage>;
59
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;
60
74
  declare const ResumeUnsafe_base: Schema.Class<ResumeUnsafe, Schema.TaggedStruct<"ResumeUnsafe", {
61
75
  readonly reason: Schema.Literals<readonly ["UndeclaredStartup", "Uncovered", "ViewDependsOnUnsentState", "DuplicateStaticRegion", "UngeneratablePath", "UnrestorablePart", "UnencodableBinding", "EagerStartRequired", "UndeclaredSurfaces", "BindingInStaticRegion", "VoidRootWithStyles"]>;
62
76
  readonly message: Schema.String;
@@ -81,6 +95,31 @@ export interface RenderedPage {
81
95
  */
82
96
  readonly unnamed: ReadonlyArray<UnnamedHandler>;
83
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>;
84
123
  /**
85
124
  * What a page adds to its head, given what it rendered: such as a stylesheet
86
125
  * of the classes the markup uses (`Style.usedIn` in `foldkit-mixins`). The
@@ -88,6 +127,18 @@ export interface RenderedPage {
88
127
  * for pages whose template the host owns.
89
128
  */
90
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;
91
142
  /** A page generated at build time, and the file a static host serves it from. */
92
143
  export interface GeneratedPage {
93
144
  readonly path: string;
@@ -99,101 +150,128 @@ export interface GeneratedPage {
99
150
  * are written out, so `const [home, about] = pages` needs no check.
100
151
  */
101
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;
102
233
  declare const FallbackRefused_base: Schema.Class<FallbackRefused, Schema.TaggedStruct<"FallbackRefused", {
103
234
  readonly reason: Schema.Literals<readonly ["Missing", "Unreadable", "Invalid", "Unlisted", "NoFallback"]>;
104
235
  readonly message: Schema.String;
105
236
  }>, Cause.YieldableError>;
106
237
  /** Why a posted form was not handled: the request, not the page or the plan, is at fault. */
107
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>;
108
253
  export declare const SSR: {
109
- plan: <Model, Fields extends Schema.Struct.Fields, Commands = unknown>(application: {
110
- readonly initial: Model;
111
- readonly owner?: object;
112
- readonly Message?: Schema.Top | undefined;
113
- }, config: {
114
- readonly id: string;
115
- readonly state: import("foldkit-surface").WritableProjection<Model, Fields>;
116
- readonly baseline?: Model | undefined;
117
- readonly boot?: ((model: Model) => Commands) | undefined;
118
- readonly local?: ReadonlyArray<{
119
- readonly dependency: ReadonlyArray<string>;
120
- }> | undefined;
121
- readonly surfaces?: ReadonlyArray<PlanSurface<Model>> | undefined;
122
- readonly parts?: ReadonlyArray<ResumePart<Model>> | undefined;
123
- readonly start?: Start | undefined;
124
- readonly deferrable?: ReadonlyArray<string> | undefined;
125
- readonly fallback?: "server" | undefined;
126
- readonly meta?: ((model: Model) => Meta) | undefined;
127
- readonly version?: unknown | undefined;
128
- }) => ResumePlan<Model, Fields, Commands>;
129
- envelope: <Model, Fields extends Schema.Struct.Fields>(resume: ResumePlan<Model, Fields>, model: Model, options?: EnvelopeOptions) => string;
130
- resume: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, page: ParentNode, options?: {
131
- readonly route?: string | undefined;
132
- }) => Result.Result<Model, ResumeRefused>;
133
- render: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
134
- readonly buildId: string;
135
- readonly url?: string | undefined;
136
- readonly flags?: unknown;
137
- /**
138
- * Markup for the first paint, given what was rendered, carried as the
139
- * root's last child: keep it to `<style>`, which the browser drops on
140
- * hydration. Anything a head owns (`meta`, links) stays with `SSR.page`
141
- * and `SSR.generate`.
142
- */
143
- readonly styles?: Head | undefined;
144
- }) => Effect.Effect<RenderedPage, RenderError | ResumeUnsafe>;
145
- page: (template: string, result: {
146
- readonly rendered: RenderedApplication;
147
- readonly meta: string;
148
- }, options?: {
149
- readonly head?: Head | undefined;
150
- }) => string;
254
+ plan: typeof plan;
255
+ envelope: typeof envelope;
256
+ resume: typeof resume;
257
+ render: typeof render;
258
+ page: typeof page;
151
259
  hydrate: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
152
260
  readonly buildId: string;
153
261
  readonly when?: ((page: Document) => boolean) | undefined;
154
- readonly otherwise?: "render" | undefined;
262
+ readonly otherwise?: 'render' | undefined;
155
263
  readonly until?: ((model: Model) => boolean) | undefined;
156
264
  readonly fresh?: ((version: unknown) => boolean) | undefined;
157
265
  }) => void;
158
- inspect: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, model: Model) => PlanInspection;
159
- static: (id: string, render: (ih: import("foldkit/html").HtmlBuilder<never>) => Region) => import("foldkit/html").Html;
160
- serving: () => boolean;
161
- generate: <Model, Fields extends Schema.Struct.Fields, const Paths extends ReadonlyArray<string>, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
162
- readonly buildId: string;
163
- readonly template: string;
164
- readonly origin: string;
165
- readonly paths: Paths;
166
- readonly flags?: ((path: string) => unknown) | undefined;
167
- readonly head?: Head | undefined;
168
- }) => Effect.Effect<GeneratedPages<Paths>, RenderError | ResumeUnsafe>;
169
- entry: <Model, Fields extends Schema.Struct.Fields, Message = any>(config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
170
- readonly buildId: string;
171
- readonly flags?: ((request: Request) => unknown | PromiseLike<unknown>) | undefined;
172
- readonly headers?: ((request: Request) => HeadersInit) | undefined;
173
- /**
174
- * Markup for the first paint, carried as the rendered root's last child.
175
- * The host owns the template in dynamic serving, so this is where
176
- * per-page styles go; anything a head owns stays with `SSR.generate`.
177
- */
178
- readonly styles?: Head | undefined;
179
- }) => EntryModule;
180
- handle: <Model, Fields extends Schema.Struct.Fields, Message = any>(request: Request, config: ResumableConfig<Model, Message>, plan: ResumePlan<Model, Fields>, options: {
181
- readonly buildId: string;
182
- readonly flags?: unknown;
183
- readonly styles?: Head | undefined;
184
- }) => Effect.Effect<RenderedPage, RenderError | ResumeUnsafe | FallbackRefused>;
185
- serializeJsonScript: (value: unknown) => string;
186
- sitemap: (pages: ReadonlyArray<{
187
- readonly path: string;
188
- readonly modified?: string | undefined;
189
- }>, options: {
190
- readonly origin: string;
191
- }) => string;
192
- robots: (options: {
193
- readonly origin: string;
194
- readonly sitemap?: string | undefined;
195
- readonly disallow?: ReadonlyArray<string> | undefined;
196
- }) => 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;
197
275
  };
198
276
  //#endregion
199
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 };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;UA4FU;WACC;WACA,QAAQ;WACR,WAAW,cAAc;;WAEzB,SAAS;;;YA6HR;;iBAGK;WACN;;WAEA;;WAEA;;;;;WAKA;aAEM;aACA;eAAwB;eAAuB,OAAO;;;;WAI5D;aAAwB;aAAuB,OAAO;;;WAEtD,OAAO;aAAyB;aAAuB,OA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mKjC,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/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { f as ResumePlan, u as ResumableConfig } from "./client-NuipTFHy.mjs";
1
+ import { f as ResumePlan, u as ResumableConfig } from "./client-DkwAniQQ.mjs";
2
2
  import { Head, ResumeUnsafe } from "./index.mjs";
3
3
  import { Effect, Schema } from "effect";
4
4
  import { RenderError } from "foldkit/experimental/server";
@@ -16,7 +16,7 @@ export type SitePath = string | {
16
16
  * refuses what is not servable (a query, a fragment, an unresolvable
17
17
  * address) before this maps it, so this maps and never validates.
18
18
  */
19
- export declare const fileFor: (path: string, layout: "directory" | "flat") => string;
19
+ export declare const fileFor: (path: string, layout: 'directory' | 'flat') => string;
20
20
  /**
21
21
  * What a static site is: everything `SSR.generate` takes, plus where its
22
22
  * pages land. `config` may read the path (a site whose Model is prepared
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite.ts"],"mappings":";;;;;;;YAwBY;WAA+B;WAAuB;;;;;;;;;qBAarD,UAAW,cAAc;;;;;;;;;;iBAgBrB,WACf,OACA,eAAe,OAAO,OAAO,QAC7B,SAKA,WAAW,gBAAgB,OAAO;WAEzB,QAAQ,aAAa,iBAAiB,WAAW,QAAQ;WACzD,MAAM,WAAW,OAAO;WACxB;WACA;WACA,OACP,cAAc,mBAAmB,cAAc,YAAY,QAAQ,cAAc;WAC1E;WACA,OAAO;WACP,UAAU;WACV;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;;;iBAIM;WACN,OAAO,cAAc;WACrB;WACA;;;;;;;;qBASE,qBAAsB,OAAO,eAAe,OAAO,OAAO,QAAQ,eAC7E,MAAM,WAAW,OAAO,QAAQ,aAC/B,OAAO,OAAO,WAAW,cAAc;;iBAmEzB;WACN,QACL,8BACE,iBAAiB,4BAA4B,QAAQ;WAClD,MAAM;WACN;WACA;WACA,OACP,cAAc,mBAAmB,cAAc,YAAY,QAAQ,cAAc;WAC1E,aAAa;WACb,OAAO;WACP,UAAU;WACV;WACA;WACA;;;;;;;;;qBAaE,aAAc;;WAEhB;aAAiB;aAAyB;;;WAE1C;MACP"}
1
+ {"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite.ts"],"mappings":";;;;;;;YAwBY;WAA+B;WAAuB;;;;;;;;;qBAarD,UAAO,cAAgB;;;;;;;;;;iBAgBnB,WACf,OACA,eAAe,OAAO,OAAO,QAC7B,SAKA,WAAW,gBAAgB,OAAO;WAEzB,QAAQ,aAAa,iBAAiB,WAAW,QAAQ;WACzD,MAAM,WAAW,OAAO;WACxB;WACA;WACA,OACP,cAAc,mBAAmB,cAAc,YAAY,QAAQ,cAAc;WAC1E;WACA,OAAO;WACP,UAAU;WACV;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;;;iBAIM;WACN,OAAO,cAAc;WACrB;WACA;;;;;;;;qBASE,qBAAsB,OAAO,eAAe,OAAO,OAAO,QAAQ,eAAa,MACpF,WAAW,OAAO,QAAQ,aAC/B,OAAO,OAAO,WAAW,cAAc;;iBAmEzB;WACN,QACL,8BACE,iBAAiB,4BAA4B,QAAQ;WAClD,MAAM;WACN;WACA;WACA,OACP,cAAc,mBAAmB,cAAc,YAAY,QAAQ,cAAc;WAC1E,aAAa;WACb,OAAO;WACP,UAAU;WACV;WACA;WACA;;;;;;;;;qBAaE,aAAU;;WAEZ;aAAiB;aAAyB;;;WAE1C;MACP"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-ssr",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Server rendering for Foldkit Plus: render once on the server, hand the Model over, and hydrate without rerunning init.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -19,7 +19,7 @@
19
19
  "url": "git+https://github.com/doeixd/foldkit-plus.git",
20
20
  "directory": "packages/ssr"
21
21
  },
22
- "homepage": "https://github.com/doeixd/foldkit-plus/tree/main/packages/ssr#readme",
22
+ "homepage": "https://foldkit-plus.pages.dev/ssr",
23
23
  "bugs": {
24
24
  "url": "https://github.com/doeixd/foldkit-plus/issues"
25
25
  },
@@ -48,26 +48,26 @@
48
48
  ],
49
49
  "peerDependencies": {
50
50
  "effect": "^4.0.0",
51
- "foldkit": "^0.165.0"
51
+ "foldkit": "^0.168.0"
52
52
  },
53
53
  "dependencies": {
54
- "foldkit-surface": "0.8.0"
54
+ "foldkit-surface": "0.9.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@effect/platform-browser": "4.0.0",
58
- "@types/jsdom": "21.1.7",
59
- "effect": "4.0.0",
57
+ "@effect/platform-browser": "^4.0.4",
58
+ "@types/jsdom": "30.0.0",
59
+ "effect": "^4.0.4",
60
60
  "esbuild": "0.28.2",
61
- "foldkit": "0.165.0",
62
- "jsdom": "26.1.0",
63
- "playwright-core": "1.63.0",
64
- "tsdown": "^0.23.0",
65
- "typescript": "5.9.3",
66
- "vite": "5.4.21",
67
- "foldkit-entity": "0.8.0",
68
- "foldkit-mirror": "0.5.2",
69
- "foldkit-bundle": "0.6.0",
70
- "foldkit-remote": "0.14.0"
61
+ "foldkit": "0.168.0",
62
+ "jsdom": "30.1.2",
63
+ "playwright-core": "1.64.0",
64
+ "tsdown": "^0.23.1",
65
+ "typescript": "7.0.2",
66
+ "vite": "8.3.4",
67
+ "foldkit-entity": "0.9.0",
68
+ "foldkit-bundle": "0.7.0",
69
+ "foldkit-mirror": "0.6.0",
70
+ "foldkit-remote": "0.16.0"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsdown",
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-NuipTFHy.d.mts","names":[],"sources":["../src/resumable.ts","../src/context.ts","../src/listen.ts","../src/shared.ts","../src/client.ts"],"mappings":";;;;;;;cAoBa;;cA4GA;;cAMA;cAEC;;UAGG,QAAQ;YACb,UAAU;;KAGjB,QAAQ,GAAG,IAAI,KAAK,sBAAsB,YAAY;;KAGtD,kBAAkB,OAAO;WAAiB,QAAQ,OAAO,OAAO;;;KAGhE,KAAK,KAAK;WAAqB,YAAY;IAAM;;KAGjD,QAAQ,KAAK,QAAQ,KAAK,KAAK;;KAG/B,KAAK,GAAG,SAAS,KAAK,KAAK,mBAAmB;KAE9C,gBAAgB,GAAG,YAAY,KAAK,aAAa,qBAElD;KAEC,cAAc,GAAG,gBAAgB,KAAK,GAAG,0BAC1C,6EACa,cAAc,KAAK,GAAG,UACjC,yFACA,KAAK,GAAG,aAAa,KAAK,GAAG,wCACZ,KAAK,GAAG,aAAa,KAAK,GAAG,oBAE1C,wDACF;KAEH,a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