@opsydyn/astro-foldkit 0.6.0 → 0.8.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/CHANGELOG.md +49 -11
- package/README.md +163 -29
- package/dist/build-id.d.mts +1 -1
- package/dist/build-id.mjs +1 -1
- package/dist/client.d.mts +24 -14
- package/dist/client.mjs +18 -13
- package/dist/define-app.d.mts +2 -2
- package/dist/define-page.d.mts +3 -3
- package/dist/index.mjs +1 -2
- package/dist/server-public.d.mts +2 -2
- package/dist/server-render.d.mts +3 -3
- package/dist/server.d.mts +14 -5
- package/dist/server.mjs +2 -2
- package/dist/types-DDk3MMb7.d.mts +62 -0
- package/package.json +6 -6
- package/dist/types-4PDoP5Mh.d.mts +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,62 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.
|
|
3
|
+
## [0.8.0](https://github.com/opsydyn/fold-kit-experiments/compare/astro-foldkit-v0.7.2...astro-foldkit-v0.8.0) (2026-10-09)
|
|
4
4
|
|
|
5
|
+
Upgrade FoldKit alongside this package: the supported peer range is now
|
|
6
|
+
`>=0.167.0 <0.168.0`, with Effect `4.0.0`. Public app and server APIs are unchanged.
|
|
7
|
+
The integration uses `@foldkit/vite-plugin` 0.27.x for coordinated client/server
|
|
8
|
+
build identity. See the [migration guide](https://github.com/opsydyn/fold-kit-experiments/blob/main/docs/migrations/foldkit-0.167.md)
|
|
9
|
+
and [release notes](https://github.com/opsydyn/fold-kit-experiments/blob/main/docs/releases/foldkit-0.167.md).
|
|
5
10
|
|
|
6
11
|
### Features
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
- support FoldKit 0.167 and keyed chart comparison ([6e3edf7](https://github.com/opsydyn/fold-kit-experiments/commit/6e3edf76d0e04047652c052e2254ccd67a2458d9))
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- **deps:** patch Astro to 7.2.8 ([65ebdb7](https://github.com/opsydyn/fold-kit-experiments/commit/65ebdb74999e7bcafb127f3c87e424dc165a3a7d))
|
|
18
|
+
|
|
19
|
+
## [0.7.2](https://github.com/opsydyn/fold-kit-experiments/compare/astro-foldkit-v0.7.1...astro-foldkit-v0.7.2) (2026-10-05)
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
- support FoldKit 0.166.0 ([248636e](https://github.com/opsydyn/fold-kit-experiments/commit/248636efea03a2048432260da6261bb657a282dc))
|
|
24
|
+
|
|
25
|
+
## [0.7.1](https://github.com/opsydyn/fold-kit-experiments/compare/astro-foldkit-v0.7.0...astro-foldkit-v0.7.1) (2026-10-04)
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
- clear oxlint warnings ([4bd5016](https://github.com/opsydyn/fold-kit-experiments/commit/4bd5016f71dde9621bb5bbd6b587792f9585e6ea))
|
|
30
|
+
|
|
31
|
+
## [0.7.0](https://github.com/opsydyn/fold-kit-experiments/compare/astro-foldkit-v0.6.0...astro-foldkit-v0.7.0) (2026-09-20)
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
- **web:** add stateflow observatory ([b50446e](https://github.com/opsydyn/fold-kit-experiments/commit/b50446e11f2fad81d1b5799974dd1ab10b705f1f))
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
- align Vite plugin with Effect rc.116 ([33682f8](https://github.com/opsydyn/fold-kit-experiments/commit/33682f8fda999ee82d963d5d6687aee56f08c413))
|
|
40
|
+
- satisfy Astro smoke lint contract ([f67f71e](https://github.com/opsydyn/fold-kit-experiments/commit/f67f71e4f7b2ce480ccce841c1dcd4ef3c81cdf7))
|
|
41
|
+
- **web:** complete stateflow SSR and replay interactions ([d71ad2a](https://github.com/opsydyn/fold-kit-experiments/commit/d71ad2aeaf5ad0f1a8ff4e86c77ba99d5da3368f))
|
|
42
|
+
|
|
43
|
+
## [0.6.0](https://github.com/opsydyn/fold-kit-experiments/compare/astro-foldkit-v0.5.0...astro-foldkit-v0.6.0) (2026-08-20)
|
|
44
|
+
|
|
45
|
+
### Features
|
|
14
46
|
|
|
47
|
+
- **astro-foldkit:** add server render handoff ([9773a4d](https://github.com/opsydyn/fold-kit-experiments/commit/9773a4d1883c53fa60957368a0125d3b57b7cd24))
|
|
48
|
+
- **astro-foldkit:** document opt-in server rendering ([53e9d00](https://github.com/opsydyn/fold-kit-experiments/commit/53e9d004c75c10245d0aa88fc4c412b96c7f2f4c))
|
|
49
|
+
- **astro-foldkit:** expose server document resolver ([969dc2f](https://github.com/opsydyn/fold-kit-experiments/commit/969dc2f7e4a679df8b04d60c57783d6b8fb84bd1))
|
|
50
|
+
- **astro-foldkit:** formalize define-page contract ([62863c5](https://github.com/opsydyn/fold-kit-experiments/commit/62863c58fa1462d2ecb04bd52cf3d5e0bb444601))
|
|
51
|
+
- **astro-foldkit:** hydrate page owners on client ([9f8f76b](https://github.com/opsydyn/fold-kit-experiments/commit/9f8f76bef77ea734006c1faa90defdfdd115d09d))
|
|
52
|
+
- support FoldKit 0.136 ([50f4134](https://github.com/opsydyn/fold-kit-experiments/commit/50f4134d7596926fed373408642816736907934f))
|
|
15
53
|
|
|
16
54
|
### Bug Fixes
|
|
17
55
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
56
|
+
- **astro-foldkit:** align server document tests ([f71c2c2](https://github.com/opsydyn/fold-kit-experiments/commit/f71c2c2ccea94f148e81126b00174375566fa5bb))
|
|
57
|
+
- **astro-foldkit:** keep define-page markers inert ([0fb4e54](https://github.com/opsydyn/fold-kit-experiments/commit/0fb4e54dbd3a0b53f21de57f27f3948e13fcf80b))
|
|
58
|
+
- **astro-foldkit:** pass stamped root to page hydration ([b3b3ba6](https://github.com/opsydyn/fold-kit-experiments/commit/b3b3ba65c4bb25bb9c2738f82d1148e5e6407679))
|
|
59
|
+
- **astro-foldkit:** reject empty server build id ([320bc39](https://github.com/opsydyn/fold-kit-experiments/commit/320bc39a9ca8d610fe60480c0c399a71fc029b51))
|
|
22
60
|
|
|
23
61
|
## [0.5.0](https://github.com/opsydyn/fold-kit-experiments/compare/astro-foldkit-v0.4.0...astro-foldkit-v0.5.0) (2026-07-18)
|
|
24
62
|
|
package/README.md
CHANGED
|
@@ -20,11 +20,12 @@ npm install astro foldkit
|
|
|
20
20
|
|
|
21
21
|
## FoldKit compatibility
|
|
22
22
|
|
|
23
|
-
`@opsydyn/astro-foldkit`
|
|
24
|
-
`@foldkit/vite-plugin` `0.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
and lifecycle
|
|
23
|
+
`@opsydyn/astro-foldkit` targets FoldKit `0.167.x`, stable Effect
|
|
24
|
+
`4.0.0`, and the matching `@foldkit/vite-plugin` `0.27.x` line.
|
|
25
|
+
Applications can define interruptible work with
|
|
26
|
+
`Command.define(name, { interrupt: true, ... })` inside their own update loop;
|
|
27
|
+
this integration continues to own Astro rendering, hydration, and lifecycle
|
|
28
|
+
event delivery.
|
|
28
29
|
|
|
29
30
|
## Setup
|
|
30
31
|
|
|
@@ -35,21 +36,25 @@ import { defineConfig } from 'astro/config';
|
|
|
35
36
|
import foldkit from '@opsydyn/astro-foldkit';
|
|
36
37
|
|
|
37
38
|
export default defineConfig({
|
|
38
|
-
integrations: [
|
|
39
|
-
foldkit({
|
|
40
|
-
server: {
|
|
41
|
-
buildId: process.env.FOLDKIT_BUILD_ID ?? 'development',
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
39
|
+
integrations: [foldkit()],
|
|
45
40
|
});
|
|
46
41
|
```
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
FoldKit generates one public build identity for the coordinated client and server
|
|
44
|
+
artifacts. The integration uses that compiled identity by default, including
|
|
45
|
+
Astro's prerender and Cloudflare environments. Astro continues to own the HTML
|
|
46
|
+
document, assets, and deployment adapter; do not enable the standalone FoldKit
|
|
47
|
+
`ssr.build` pipeline inside this integration.
|
|
48
|
+
|
|
49
|
+
For separately built artifacts, supply the same deployment-specific
|
|
50
|
+
`FOLDKIT_BUILD_ID` environment variable to every build, or configure
|
|
51
|
+
`foldkit({ server: { buildId: 'release-unique-deployment-id' } })`. The ID appears
|
|
52
|
+
in public HTML, so it must not contain secrets. Do not reuse it across deployments
|
|
53
|
+
with different rendering inputs. Blank `server.buildId` options are rejected, and FoldKit
|
|
54
|
+
fails closed when neither a compiled identity nor an explicit override is available.
|
|
55
|
+
|
|
56
|
+
See the [0.167 migration guide](../../docs/migrations/foldkit-0.167.md) for the
|
|
57
|
+
subscription API changes and package compatibility checks.
|
|
53
58
|
|
|
54
59
|
## Defining an app
|
|
55
60
|
|
|
@@ -69,9 +74,10 @@ import type { Document, HtmlBuilder } from 'foldkit/html';
|
|
|
69
74
|
type Message = 'Inc' | 'Dec';
|
|
70
75
|
|
|
71
76
|
export const Model = null;
|
|
72
|
-
export const init = () =>
|
|
73
|
-
export const update = (model: number, message: Message) =>
|
|
74
|
-
|
|
77
|
+
export const init = () => ({ model: 0 });
|
|
78
|
+
export const update = (model: number, message: Message) => ({
|
|
79
|
+
model: message === 'Inc' ? model + 1 : model - 1,
|
|
80
|
+
});
|
|
75
81
|
export const view = (model: number, h: HtmlBuilder<Message>): Document => ({
|
|
76
82
|
title: `Counter: ${model}`,
|
|
77
83
|
body: h.button([h.OnClick('Inc')], [String(model)]),
|
|
@@ -95,6 +101,13 @@ serialisation and client directive behavior.
|
|
|
95
101
|
|
|
96
102
|
The demo app's [`/request-diagnostics`](../../apps/web/src/pages/request-diagnostics.astro) page shows the integration boundary with a practical machine-driven chart workflow. The page uses `@opsydyn/astro-foldkit` for hydration, `@opsydyn/foldkit-viz` for chart primitives, and `foldkit/experimental/machine` in the application update layer.
|
|
97
103
|
|
|
104
|
+
The [`/comparison`](../../apps/web/src/pages/comparison.astro) example hosts
|
|
105
|
+
dynamic scatter/histogram panels using the same `lazyApp` island contract.
|
|
106
|
+
Stable panel IDs, `foldChildAt`, linked selection, measurements and focus policy
|
|
107
|
+
belong to the application. Astro provides hydration and lifecycle facts only;
|
|
108
|
+
no additional integration API or server-rendering opt-in is required. The promo
|
|
109
|
+
hosts the maintained workbench with source inspection and standalone exports.
|
|
110
|
+
|
|
98
111
|
## Server-rendered pages (opt-in)
|
|
99
112
|
|
|
100
113
|
Use `definePage` when one FoldKit application owns the document content for an
|
|
@@ -191,6 +204,14 @@ The layout owns the outer `<html>` structure and applies `title`, `lang`,
|
|
|
191
204
|
HTML contains one stamped FoldKit root and the browser hydrates that exact root
|
|
192
205
|
with the serialized Flags payload.
|
|
193
206
|
|
|
207
|
+
### Canonical metadata
|
|
208
|
+
|
|
209
|
+
`definePage` does not infer a canonical URL from `Astro.url`, route parameters,
|
|
210
|
+
or the browser location. The page view must return `Document.canonical` when the
|
|
211
|
+
application has a canonical identity. Query parameters and alternate
|
|
212
|
+
representations remain application-owned. When FoldKit supplies the 0.165
|
|
213
|
+
canonical-to-`ogUrl` fallback, the resolver passes it through unchanged.
|
|
214
|
+
|
|
194
215
|
### SSG
|
|
195
216
|
|
|
196
217
|
The same page owner can be prerendered when its props and Flags are universal:
|
|
@@ -257,9 +278,9 @@ export type Name = typeof Name.Type;
|
|
|
257
278
|
|
|
258
279
|
const Props = Schema.Struct({ name: Name });
|
|
259
280
|
|
|
260
|
-
export const init = (props: unknown): readonly
|
|
281
|
+
export const init = (props: unknown): { readonly model: Model } => {
|
|
261
282
|
const { name } = Schema.decodeUnknownSync(Props)(props);
|
|
262
|
-
return
|
|
283
|
+
return { model: name };
|
|
263
284
|
};
|
|
264
285
|
```
|
|
265
286
|
|
|
@@ -340,12 +361,12 @@ The double-decode is intentional: `Schema.decodeSync` at the Astro boundary ensu
|
|
|
340
361
|
|
|
341
362
|
The module returned by your loader must export:
|
|
342
363
|
|
|
343
|
-
| Export | Type
|
|
344
|
-
| :------- |
|
|
345
|
-
| `Model` | `unknown`
|
|
346
|
-
| `init` | `(props: unknown) =>
|
|
347
|
-
| `update` | `(model, message) =>
|
|
348
|
-
| `view` | `(model, h: HtmlBuilder<Message>) => Document`
|
|
364
|
+
| Export | Type | Description |
|
|
365
|
+
| :------- | :------------------------------------------------------------------------ | :-------------------------------------------- |
|
|
366
|
+
| `Model` | `unknown` | Initial model type marker |
|
|
367
|
+
| `init` | `(props: unknown) => { model: Model; commands?: ReadonlyArray<Command> }` | Initial state from props and startup commands |
|
|
368
|
+
| `update` | `(model, message) => { model: Model; commands?: ReadonlyArray<Command> }` | Pure state transition |
|
|
369
|
+
| `view` | `(model, h: HtmlBuilder<Message>) => Document` | Render with the current render-frame builder |
|
|
349
370
|
|
|
350
371
|
For `definePage`, `init` receives the validated `Flags` value rather than raw
|
|
351
372
|
Astro props, and the module must additionally export the runtime `Flags`
|
|
@@ -476,7 +497,120 @@ element.addEventListener(
|
|
|
476
497
|
| Package | Version |
|
|
477
498
|
| :-------- | :-------------------- |
|
|
478
499
|
| `astro` | `≥ 5.0` |
|
|
479
|
-
| `foldkit` | `≥ 0.
|
|
500
|
+
| `foldkit` | `≥ 0.167.0 < 0.168.0` |
|
|
501
|
+
|
|
502
|
+
## Stateflow Observatory example
|
|
503
|
+
|
|
504
|
+
The demo route `/stateflow` uses `StateflowPage`, an app-owned `definePage` entry,
|
|
505
|
+
to server-render the graph and current state before hydrating with `client:load`
|
|
506
|
+
inside the existing Astro layout. Astro supplies the island and lifecycle facts;
|
|
507
|
+
the app owns the Machine, typed inbound replay Port, outbound transition telemetry Port,
|
|
508
|
+
replay policy, and trace inspector. The graph consumes plain layout records.
|
|
509
|
+
|
|
510
|
+
This slice adds no Astro integration API and moves no async work into the
|
|
511
|
+
integration. Commands and subscriptions remain app-owned, including telemetry
|
|
512
|
+
emission, validation of inbound replay events, and the reduced-motion
|
|
513
|
+
`Dom.streamFromMediaQuery` stream in a `Subscription.persistentEntry`. That subscription is the app's
|
|
514
|
+
example of FoldKit PR [#1424](https://github.com/foldkit/foldkit/pull/1424): it
|
|
515
|
+
records the browser's initial media-query match and subsequent changes, then
|
|
516
|
+
lets the Model decide whether visual motion is allowed.
|
|
517
|
+
|
|
518
|
+
## Remote visual loads
|
|
519
|
+
|
|
520
|
+
For future remote filter, brush, or zoom loads, construct the refresh step with
|
|
521
|
+
an explicit selection snapshot and request ID. `LoadFilteredData` is an
|
|
522
|
+
app-owned interruptible Command whose declared args include `selection` and
|
|
523
|
+
`requestId`; its `execute` uses those args and returns the ID with its result
|
|
524
|
+
Message. Commands do not read the later Model implicitly.
|
|
525
|
+
|
|
526
|
+
In this example, `Model.data` is `AsyncData<Data, string>`. `Selection`, `Data`,
|
|
527
|
+
`Model`, and `Message` are application types. The app also stores the latest
|
|
528
|
+
`selection`, a monotonic `nextRequestId`, `routeActive`, and a discriminated
|
|
529
|
+
`request` union: `Idle | Running { requestId } | Cancelling { requestId }`.
|
|
530
|
+
|
|
531
|
+
```ts
|
|
532
|
+
import { Option } from 'effect';
|
|
533
|
+
import { getData, Idle, revalidateOrLoad, succeed } from 'foldkit/asyncData';
|
|
534
|
+
import { refresh } from 'foldkit/update';
|
|
535
|
+
import type { Return } from 'foldkit/update';
|
|
536
|
+
|
|
537
|
+
import { LoadFilteredData } from './command';
|
|
538
|
+
import type { Message } from './message';
|
|
539
|
+
import type { Data, Model, Selection } from './model';
|
|
540
|
+
|
|
541
|
+
const loadOnFilter = (selection: Selection, requestId: number) =>
|
|
542
|
+
refresh<Model, Message, Data, string>({
|
|
543
|
+
read: (model) => Option.some(model.data),
|
|
544
|
+
revalidate: revalidateOrLoad,
|
|
545
|
+
write: (model, data) => ({ ...model, data }),
|
|
546
|
+
load: LoadFilteredData({ selection, requestId }),
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// Call only when request is Idle and data is not Loading or Refreshing.
|
|
550
|
+
const startLatest = (model: Model): Return<Model, Message> => {
|
|
551
|
+
const requestId = model.nextRequestId;
|
|
552
|
+
const next: Model = {
|
|
553
|
+
...model,
|
|
554
|
+
nextRequestId: requestId + 1,
|
|
555
|
+
request: { _tag: 'Running', requestId },
|
|
556
|
+
};
|
|
557
|
+
return loadOnFilter(next.selection, requestId)(next);
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
// The outcome handler first checks Cancelling and the cancelled request ID.
|
|
561
|
+
const afterInterruption = (model: Model): Return<Model, Message> => {
|
|
562
|
+
const next: Model = {
|
|
563
|
+
...model,
|
|
564
|
+
request: { _tag: 'Idle' },
|
|
565
|
+
data: Option.match(getData(model.data), {
|
|
566
|
+
onNone: () => Idle(),
|
|
567
|
+
onSome: (data) => succeed(data),
|
|
568
|
+
}),
|
|
569
|
+
};
|
|
570
|
+
if (!next.routeActive) return { model: next };
|
|
571
|
+
return startLatest(next);
|
|
572
|
+
};
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
Use this explicit **latest-selection wins** policy in the app's update loop:
|
|
576
|
+
|
|
577
|
+
1. Record every new filter, brush, or zoom selection in `Model.selection`. If
|
|
578
|
+
the route is active and `request` is `Idle`, call `startLatest` with that
|
|
579
|
+
updated Model. While the route is inactive, only store the selection.
|
|
580
|
+
2. If a request is `Running`, change it to `Cancelling` with the same request
|
|
581
|
+
ID and return only its keyed interruption Command. Capture that ID in the
|
|
582
|
+
interruption outcome Message. Do not start a replacement in the same batch.
|
|
583
|
+
3. While `Cancelling`, keep replacing `Model.selection` with the latest input;
|
|
584
|
+
emit no further load or interruption Commands. Ignore normal result Messages
|
|
585
|
+
for this cancelled request, including a result racing with interruption.
|
|
586
|
+
4. For a matching interruption outcome (`Interrupted` or `NotFound`), call
|
|
587
|
+
`afterInterruption` using the current Model. An interrupted Command will not
|
|
588
|
+
send its original result Message. The helper therefore explicitly clears
|
|
589
|
+
pending AsyncData: `Loading` becomes `Idle`, and `Refreshing(data)` becomes
|
|
590
|
+
`Success(data)`. It then starts the latest selection with a fresh ID, moving
|
|
591
|
+
back to `Loading` or `Refreshing`. Calling `refresh` on the old pending state
|
|
592
|
+
would produce no Command because `revalidateOrLoad` returns `None` there.
|
|
593
|
+
5. Accept a normal result only when its ID matches the `Running` request.
|
|
594
|
+
Apply `settle(model.data, result)` from `foldkit/asyncData` and set `request`
|
|
595
|
+
to `Idle` in the same update. Ignore stale IDs and duplicate outcomes. Cached
|
|
596
|
+
data retained during replacement still belongs to the previous selection;
|
|
597
|
+
present it as such until the matching replacement result arrives.
|
|
598
|
+
6. On route exit, mark the route inactive and interrupt any `Running` request,
|
|
599
|
+
or wait for the existing `Cancelling` outcome. The same outcome handler
|
|
600
|
+
clears pending AsyncData but starts no replacement while inactive. Route
|
|
601
|
+
entry can call `startLatest` from `Idle`; if still `Cancelling`, wait for its
|
|
602
|
+
outcome before loading the latest selection.
|
|
603
|
+
|
|
604
|
+
The app owns command keys and correlation, interruption/cancellation policy,
|
|
605
|
+
AsyncData, and the Model. `refresh` supplies the revalidation step, not that
|
|
606
|
+
replacement policy. The app derives the records supplied to `foldkit-viz`,
|
|
607
|
+
whose synchronous functions compute geometry; chart primitives cannot fetch
|
|
608
|
+
data or subscribe to events or Ports.
|
|
609
|
+
|
|
610
|
+
Use typed Ports only for host input/output: map validated inbound values to app
|
|
611
|
+
Messages and emit outbound values through app-owned Commands. Keep internal
|
|
612
|
+
state in the Model and internal event flow in Messages and update. Astro mounts
|
|
613
|
+
the island and supplies lifecycle facts; it does not own remote visual loads.
|
|
480
614
|
|
|
481
615
|
## License
|
|
482
616
|
|
package/dist/build-id.d.mts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
type FoldkitEnv = Readonly<{
|
|
3
3
|
FOLDKIT_BUILD_ID?: string;
|
|
4
4
|
}>;
|
|
5
|
-
declare function readFoldkitBuildId(env?: FoldkitEnv | undefined): string;
|
|
5
|
+
declare function readFoldkitBuildId(env?: FoldkitEnv | undefined): string | undefined;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { readFoldkitBuildId };
|
package/dist/build-id.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/build-id.ts
|
|
2
2
|
function readFoldkitBuildId(env = import.meta.env) {
|
|
3
3
|
const buildId = env?.FOLDKIT_BUILD_ID;
|
|
4
|
-
if (buildId
|
|
4
|
+
if (buildId !== void 0 && buildId.trim() === "") throw new Error("FOLDKIT_BUILD_ID must be non-empty when configured. Omit it to use the generated build identity.");
|
|
5
5
|
return buildId;
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
package/dist/client.d.mts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as NavigationEvent } from "./navigation-Cy2lnE4G.mjs";
|
|
2
|
+
import { a as FoldkitApp, n as AppConfigContract } from "./types-DDk3MMb7.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/client.d.ts
|
|
5
|
+
interface RuntimeConfigInput {}
|
|
6
|
+
interface RuntimeProgram {}
|
|
7
|
+
interface RuntimeHydrationOptions {
|
|
8
|
+
readonly buildId?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ClientSlots {}
|
|
4
11
|
type EventTargetLike = {
|
|
5
12
|
readonly addEventListener: (type: string, listener: EventListener) => void;
|
|
6
13
|
readonly removeEventListener: (type: string, listener: EventListener) => void;
|
|
7
14
|
};
|
|
8
15
|
type NavigationDocument = EventTargetLike & {
|
|
9
16
|
readonly title: string;
|
|
10
|
-
readonly querySelector: (selector: string) =>
|
|
17
|
+
readonly querySelector: (selector: string) => object | null;
|
|
18
|
+
};
|
|
19
|
+
type RuntimePortHandle<Value> = {
|
|
20
|
+
readonly send: (value: Value) => void;
|
|
11
21
|
};
|
|
12
22
|
type EmbedHandle = {
|
|
13
|
-
readonly ports?: Record<string,
|
|
14
|
-
readonly send: (value: unknown) => unknown;
|
|
15
|
-
}>;
|
|
23
|
+
readonly ports?: Readonly<Record<string, RuntimePortHandle<NavigationEvent>>>;
|
|
16
24
|
readonly dispose: () => void;
|
|
17
25
|
};
|
|
18
26
|
type ClientEnvironment = {
|
|
@@ -24,18 +32,20 @@ type ClientEnvironment = {
|
|
|
24
32
|
};
|
|
25
33
|
};
|
|
26
34
|
type ClientRuntime = {
|
|
27
|
-
readonly makeApplication: (config:
|
|
28
|
-
readonly embed: (program:
|
|
29
|
-
readonly hydrate?: (program:
|
|
30
|
-
readonly buildId: string;
|
|
31
|
-
}) => unknown;
|
|
35
|
+
readonly makeApplication: (config: RuntimeConfigInput) => RuntimeProgram;
|
|
36
|
+
readonly embed: (program: RuntimeProgram) => EmbedHandle;
|
|
37
|
+
readonly hydrate?: (program: RuntimeProgram, options: RuntimeHydrationOptions) => void;
|
|
32
38
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
interface ClientPage {
|
|
40
|
+
(props?: never): void;
|
|
41
|
+
readonly __foldkitPage: true;
|
|
42
|
+
readonly load: () => Promise<RuntimeConfigInput>;
|
|
43
|
+
}
|
|
44
|
+
type ClientComponent<Props extends object, Config extends AppConfigContract<Props>> = FoldkitApp<Props, Config> | ClientPage;
|
|
45
|
+
declare function createClientRenderer(runtime?: ClientRuntime, environment?: Partial<ClientEnvironment>): (element: HTMLElement) => <Props extends object, Config extends AppConfigContract<Props>>(component: ClientComponent<Props, Config>, props: Props, _slots: ClientSlots, _meta: {
|
|
36
46
|
client: string;
|
|
37
47
|
}) => Promise<void>;
|
|
38
|
-
declare const _default: (element: HTMLElement) => <Props extends
|
|
48
|
+
declare const _default: (element: HTMLElement) => <Props extends object, Config extends AppConfigContract<Props>>(component: ClientComponent<Props, Config>, props: Props, _slots: ClientSlots, _meta: {
|
|
39
49
|
client: string;
|
|
40
50
|
}) => Promise<void>;
|
|
41
51
|
//#endregion
|
package/dist/client.mjs
CHANGED
|
@@ -8,14 +8,18 @@ const findSingleFoldkitRoot = (container) => {
|
|
|
8
8
|
return roots[0];
|
|
9
9
|
};
|
|
10
10
|
/** Returns true when the `noMeta` prop should suppress document metadata writes. */
|
|
11
|
-
const shouldSkipMetadata = (props) =>
|
|
11
|
+
const shouldSkipMetadata = (props) => {
|
|
12
|
+
if (!("noMeta" in props)) return false;
|
|
13
|
+
const value = props.noMeta;
|
|
14
|
+
return value === true || value === "";
|
|
15
|
+
};
|
|
12
16
|
/**
|
|
13
17
|
* Wraps a foldkit view function so the Document it returns always carries
|
|
14
18
|
* `initialTitle` as its title, preventing the runtime from overwriting
|
|
15
19
|
* `document.title` when the app is embedded as an island on a page that
|
|
16
20
|
* owns its own title.
|
|
17
21
|
*/
|
|
18
|
-
const
|
|
22
|
+
const withNoMetaView = (view, initialTitle) => (model, h) => ({
|
|
19
23
|
...view(model, h),
|
|
20
24
|
title: initialTitle
|
|
21
25
|
});
|
|
@@ -50,12 +54,11 @@ const newDocumentFrom = (event) => {
|
|
|
50
54
|
return beforeSwap.newDocument ?? beforeSwap.detail?.newDocument;
|
|
51
55
|
};
|
|
52
56
|
const destinationHrefFrom = (event, fallback) => {
|
|
53
|
-
|
|
54
|
-
return typeof href === "string" ? href : fallback;
|
|
57
|
+
return event.detail?.to?.href ?? fallback;
|
|
55
58
|
};
|
|
56
59
|
const containsIsland = (document, identity) => {
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
60
|
+
if (document === void 0) return false;
|
|
61
|
+
return document.querySelector(`astro-island[uid="${identity}"]`) !== null;
|
|
59
62
|
};
|
|
60
63
|
const attachNavigationBridge = (element, navigation, send, environment) => {
|
|
61
64
|
let active = true;
|
|
@@ -112,14 +115,13 @@ const defaultRuntime = {
|
|
|
112
115
|
const isPageOwner = (component) => typeof component === "function" && "__foldkitPage" in component && component.__foldkitPage === true;
|
|
113
116
|
function createClientRenderer(runtime = defaultRuntime, environment = {}) {
|
|
114
117
|
return (element) => async (component, props, _slots, _meta) => {
|
|
115
|
-
const config = await component.load();
|
|
116
|
-
const runtimeConfig = config;
|
|
117
118
|
const clientEnvironment = {
|
|
118
119
|
document: environment.document ?? globalThis.document,
|
|
119
120
|
window: environment.window ?? globalThis.window
|
|
120
121
|
};
|
|
121
122
|
element.id ||= element.getAttribute("uid") ?? crypto.randomUUID();
|
|
122
123
|
if (isPageOwner(component)) {
|
|
124
|
+
const config = await component.load();
|
|
123
125
|
const root = findSingleFoldkitRoot(element);
|
|
124
126
|
const application = runtime.makeApplication({
|
|
125
127
|
...config,
|
|
@@ -129,8 +131,10 @@ function createClientRenderer(runtime = defaultRuntime, environment = {}) {
|
|
|
129
131
|
runtime.hydrate(application, { buildId: readFoldkitBuildId() });
|
|
130
132
|
return;
|
|
131
133
|
}
|
|
134
|
+
const config = await component.load();
|
|
135
|
+
const runtimeConfig = config;
|
|
132
136
|
const baseView = runtimeConfig.view;
|
|
133
|
-
const view = shouldSkipMetadata(props) ?
|
|
137
|
+
const view = shouldSkipMetadata(props) ? withNoMetaView(baseView, clientEnvironment.document.title) : baseView;
|
|
134
138
|
const program = runtime.makeApplication({
|
|
135
139
|
...runtimeConfig,
|
|
136
140
|
init: () => config.init(props),
|
|
@@ -147,10 +151,11 @@ function createClientRenderer(runtime = defaultRuntime, environment = {}) {
|
|
|
147
151
|
else console.warn(`FoldKit navigation port "${config.navigation.port}" is not available`);
|
|
148
152
|
}
|
|
149
153
|
element.addEventListener("astro:unmount", () => {
|
|
150
|
-
if (disposed)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
if (!disposed) {
|
|
155
|
+
disposed = true;
|
|
156
|
+
detachNavigation();
|
|
157
|
+
handle.dispose();
|
|
158
|
+
}
|
|
154
159
|
}, { once: true });
|
|
155
160
|
};
|
|
156
161
|
}
|
package/dist/define-app.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as FoldkitApp, i as EmptyProps, n as AppConfigContract, t as AppConfig } from "./types-DDk3MMb7.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/define-app.d.ts
|
|
4
|
-
declare function defineApp<Props extends
|
|
4
|
+
declare function defineApp<Props extends object = EmptyProps, Config extends AppConfigContract<Props> = AppConfigContract<Props>>(load: () => Promise<Config>): FoldkitApp<Props, Config>;
|
|
5
5
|
/** Preferred name for Astro's intentional lazy island entry boundary. */
|
|
6
6
|
declare const lazyApp: typeof defineApp;
|
|
7
7
|
//#endregion
|
package/dist/define-page.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as PageConfigContract, d as PageFlagsSchema, f as PageParams, i as EmptyProps, l as PageContext, o as FoldkitPage, r as DefinePageOptions, s as PageConfig, u as PageFlagsContext } from "./types-DDk3MMb7.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/define-page.d.ts
|
|
4
|
-
declare function definePage<Props extends
|
|
4
|
+
declare function definePage<Props extends object = EmptyProps, Flags extends object = EmptyProps, Config extends PageConfigContract<Flags> = PageConfigContract<Flags>>(load: () => Promise<Config>, options: DefinePageOptions<Props, Flags>): FoldkitPage<Props, Flags, Config>;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { type DefinePageOptions, type FoldkitPage, type PageConfig, type
|
|
6
|
+
export { type DefinePageOptions, type FoldkitPage, type PageConfig, type PageConfigContract, type PageContext, type PageFlagsContext, type PageFlagsSchema, type PageParams, definePage };
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { foldkit as foldkit$1 } from "@foldkit/vite-plugin";
|
|
|
4
4
|
function foldkit(options = {}) {
|
|
5
5
|
const configuredBuildId = options.server?.buildId;
|
|
6
6
|
if (configuredBuildId !== void 0 && configuredBuildId.trim() === "") throw new Error("foldkit({ server: { buildId } }) requires a non-empty server.buildId.");
|
|
7
|
-
const buildId = configuredBuildId ?? "development";
|
|
8
7
|
return {
|
|
9
8
|
name: "astro-foldkit",
|
|
10
9
|
hooks: { "astro:config:setup": ({ addRenderer, updateConfig }) => {
|
|
@@ -13,7 +12,7 @@ function foldkit(options = {}) {
|
|
|
13
12
|
clientEntrypoint: fileURLToPath(new URL("./client.mjs", import.meta.url)),
|
|
14
13
|
serverEntrypoint: fileURLToPath(new URL("./server.mjs", import.meta.url))
|
|
15
14
|
});
|
|
16
|
-
updateConfig({ vite: { plugins: [foldkit$1(
|
|
15
|
+
updateConfig({ vite: { plugins: [foldkit$1(options.server)] } });
|
|
17
16
|
} }
|
|
18
17
|
};
|
|
19
18
|
}
|
package/dist/server-public.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as PageContext, o as FoldkitPage } from "./types-DDk3MMb7.mjs";
|
|
2
2
|
import { RenderedApplication } from "foldkit/experimental/server";
|
|
3
3
|
|
|
4
4
|
//#region src/server-document.d.ts
|
|
@@ -9,6 +9,6 @@ type ResolvedPageDocument = {
|
|
|
9
9
|
readonly canonical?: string;
|
|
10
10
|
readonly ogUrl?: string;
|
|
11
11
|
};
|
|
12
|
-
declare function resolvePageDocument<Props extends
|
|
12
|
+
declare function resolvePageDocument<Props extends object = object, Flags extends object = object>(page: FoldkitPage<Props, Flags>, context: PageContext<Props>): Promise<ResolvedPageDocument>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { type ResolvedPageDocument, resolvePageDocument };
|
package/dist/server-render.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as PageConfigContract } from "./types-DDk3MMb7.mjs";
|
|
2
2
|
import { RenderedApplication } from "foldkit/experimental/server";
|
|
3
3
|
|
|
4
4
|
//#region src/server-render.d.ts
|
|
5
|
-
type ServerConfig<Flags extends
|
|
6
|
-
declare function renderFoldkitServerApplication<Flags extends
|
|
5
|
+
type ServerConfig<Flags extends object> = Pick<PageConfigContract<Flags>, 'Flags' | 'init' | 'view'>;
|
|
6
|
+
declare function renderFoldkitServerApplication<Flags extends object>(config: ServerConfig<Flags>, flags: Flags, buildId?: string): Promise<RenderedApplication>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { renderFoldkitServerApplication };
|
package/dist/server.d.mts
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as PageParams } from "./types-DDk3MMb7.mjs";
|
|
2
2
|
import { NamedSSRLoadedRendererValue } from "astro";
|
|
3
3
|
|
|
4
4
|
//#region src/server.d.ts
|
|
5
|
+
interface AstroComponentInput {}
|
|
6
|
+
interface AstroProps {}
|
|
7
|
+
interface AstroSlots {}
|
|
5
8
|
type AstroRendererResult = Readonly<{
|
|
6
|
-
createAstro: (props:
|
|
9
|
+
createAstro: (props: AstroProps, slots: AstroSlots) => AstroLike<AstroProps>;
|
|
7
10
|
params: PageParams;
|
|
8
11
|
request: Request;
|
|
9
12
|
}>;
|
|
10
13
|
type RendererThis = Readonly<{
|
|
11
14
|
result?: AstroRendererResult;
|
|
12
15
|
}>;
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
type AstroLike<Props extends AstroProps> = Readonly<{
|
|
17
|
+
request?: Request;
|
|
18
|
+
url?: URL;
|
|
19
|
+
params?: PageParams;
|
|
20
|
+
props?: Props;
|
|
21
|
+
}>;
|
|
22
|
+
declare function check<Component>(component: Component): Promise<boolean>;
|
|
23
|
+
declare function renderToStaticMarkup(this: RendererThis | void, component: AstroComponentInput, props: AstroProps, slots: AstroSlots): Promise<{
|
|
15
24
|
html: string;
|
|
16
25
|
}>;
|
|
17
26
|
declare const renderer: NamedSSRLoadedRendererValue;
|
|
18
27
|
//#endregion
|
|
19
|
-
export { check, renderer as default, renderToStaticMarkup };
|
|
28
|
+
export { AstroComponentInput, AstroProps, AstroSlots, check, renderer as default, renderToStaticMarkup };
|
package/dist/server.mjs
CHANGED
|
@@ -30,8 +30,8 @@ const renderPage = async (result, component, props, slots) => {
|
|
|
30
30
|
const flags = component.flags(context);
|
|
31
31
|
return { html: (await renderFoldkitServerApplication(await component.load(), flags, readFoldkitBuildId())).html };
|
|
32
32
|
};
|
|
33
|
-
async function check(
|
|
34
|
-
return isFoldkitApp(
|
|
33
|
+
async function check(component) {
|
|
34
|
+
return isFoldkitApp(component) || isFoldkitPage(component);
|
|
35
35
|
}
|
|
36
36
|
async function renderToStaticMarkup(component, props, slots) {
|
|
37
37
|
if (isFoldkitPage(component)) return renderPage(this?.result, component, props, slots);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { n as NavigationEvent, t as NavigationConfig } from "./navigation-Cy2lnE4G.mjs";
|
|
2
|
+
import { Runtime } from "foldkit";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { Document } from "foldkit/html";
|
|
5
|
+
import { Ports } from "foldkit/port";
|
|
6
|
+
|
|
7
|
+
//#region src/types.d.ts
|
|
8
|
+
type TaggedMessage = {
|
|
9
|
+
readonly _tag: string;
|
|
10
|
+
};
|
|
11
|
+
interface EmptyProps {
|
|
12
|
+
readonly noMeta?: boolean | '';
|
|
13
|
+
}
|
|
14
|
+
type AppReturn<Model = unknown> = Readonly<{
|
|
15
|
+
readonly model: Model;
|
|
16
|
+
readonly commands?: ReadonlyArray<unknown>;
|
|
17
|
+
}>;
|
|
18
|
+
type AppConfigContract<Props extends object = EmptyProps> = {
|
|
19
|
+
readonly Model: unknown;
|
|
20
|
+
readonly init: (props: Props) => AppReturn;
|
|
21
|
+
readonly update: (model: never, message: never) => AppReturn;
|
|
22
|
+
readonly view: (model: never, h: never) => Document;
|
|
23
|
+
readonly navigation?: NavigationConfig<NavigationEvent>;
|
|
24
|
+
readonly ports?: Ports;
|
|
25
|
+
};
|
|
26
|
+
type AppConfig<Props extends object = EmptyProps, Model = unknown, Message extends TaggedMessage = TaggedMessage> = {
|
|
27
|
+
readonly Model: unknown;
|
|
28
|
+
readonly init: (props: Props) => AppReturn<Model>;
|
|
29
|
+
readonly update: Runtime.ApplicationConfig<Model, Message>['update'];
|
|
30
|
+
readonly view: Runtime.ApplicationConfig<Model, Message>['view'];
|
|
31
|
+
};
|
|
32
|
+
type FoldkitApp<Props extends object = EmptyProps, Config extends AppConfigContract<Props> = AppConfigContract<Props>> = {
|
|
33
|
+
(props?: Props): void;
|
|
34
|
+
readonly __foldkit: true;
|
|
35
|
+
readonly load: () => Promise<Config>;
|
|
36
|
+
};
|
|
37
|
+
type PageParams = Readonly<Record<string, string | undefined>>;
|
|
38
|
+
type PageFlagsContext<Props extends object = EmptyProps> = {
|
|
39
|
+
readonly request: Request;
|
|
40
|
+
readonly url: URL;
|
|
41
|
+
readonly params: PageParams;
|
|
42
|
+
readonly props: Props;
|
|
43
|
+
};
|
|
44
|
+
type PageContext<Props extends object = EmptyProps> = PageFlagsContext<Props>;
|
|
45
|
+
type PageFlagsSchema<Flags extends object> = Schema.Codec<Flags, any, never, never>;
|
|
46
|
+
type PageConfig<Flags extends object = EmptyProps, Model = unknown, Message extends TaggedMessage = TaggedMessage> = AppConfig<Flags, Model, Message> & {
|
|
47
|
+
readonly Flags: PageFlagsSchema<Flags>;
|
|
48
|
+
};
|
|
49
|
+
type PageConfigContract<Flags extends object = EmptyProps> = AppConfigContract<Flags> & {
|
|
50
|
+
readonly Flags: PageFlagsSchema<Flags>;
|
|
51
|
+
};
|
|
52
|
+
type DefinePageOptions<Props extends object = EmptyProps, Flags extends object = EmptyProps> = {
|
|
53
|
+
readonly flags: (context: PageFlagsContext<Props>) => Flags;
|
|
54
|
+
};
|
|
55
|
+
type FoldkitPage<Props extends object = EmptyProps, Flags extends object = EmptyProps, Config extends PageConfigContract<Flags> = PageConfigContract<Flags>> = {
|
|
56
|
+
(props?: Props): void;
|
|
57
|
+
readonly __foldkitPage: true;
|
|
58
|
+
readonly load: () => Promise<Config>;
|
|
59
|
+
readonly flags: (context: PageFlagsContext<Props>) => Flags;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { FoldkitApp as a, PageConfigContract as c, PageFlagsSchema as d, PageParams as f, EmptyProps as i, PageContext as l, AppConfigContract as n, FoldkitPage as o, DefinePageOptions as r, PageConfig as s, AppConfig as t, PageFlagsContext as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opsydyn/astro-foldkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Astro integration and renderer for FoldKit.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -72,21 +72,21 @@
|
|
|
72
72
|
"check:fix": "oxfmt . && NODE_OPTIONS=\"--experimental-strip-types\" oxlint --fix ."
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@foldkit/vite-plugin": "^0.
|
|
76
|
-
"effect": "4.0.0
|
|
75
|
+
"@foldkit/vite-plugin": "^0.27.0",
|
|
76
|
+
"effect": "4.0.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@types/node": "^22.0.0",
|
|
80
|
-
"astro": "7.
|
|
80
|
+
"astro": "7.2.8",
|
|
81
81
|
"bun-types": "^1.3.14",
|
|
82
82
|
"fast-check": "^4.8.0",
|
|
83
|
-
"foldkit": "
|
|
83
|
+
"foldkit": "0.167.0",
|
|
84
84
|
"tsdown": "^0.21.8",
|
|
85
85
|
"typescript": "^6.0.3"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"astro": ">=5.0.0",
|
|
89
|
-
"foldkit": ">=0.
|
|
89
|
+
"foldkit": ">=0.167.0 <0.168.0"
|
|
90
90
|
},
|
|
91
91
|
"engines": {
|
|
92
92
|
"node": ">=22.0.0"
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { t as NavigationConfig } from "./navigation-Cy2lnE4G.mjs";
|
|
2
|
-
import { Runtime } from "foldkit";
|
|
3
|
-
import { Schema } from "effect";
|
|
4
|
-
import { Document } from "foldkit/html";
|
|
5
|
-
|
|
6
|
-
//#region src/types.d.ts
|
|
7
|
-
type TaggedMessage = {
|
|
8
|
-
readonly _tag: string;
|
|
9
|
-
};
|
|
10
|
-
type CommandBatch = ReadonlyArray<unknown>;
|
|
11
|
-
type AppConfigShape<Props extends Record<string, unknown>> = {
|
|
12
|
-
readonly Model: unknown;
|
|
13
|
-
readonly init: (props: Props) => readonly [unknown, CommandBatch];
|
|
14
|
-
readonly update: (model: never, message: never) => readonly [unknown, CommandBatch];
|
|
15
|
-
readonly view: (model: never, h: never) => Document;
|
|
16
|
-
readonly navigation?: NavigationConfig<unknown>;
|
|
17
|
-
readonly ports?: Record<string, unknown>;
|
|
18
|
-
};
|
|
19
|
-
type AppConfig<Props extends Record<string, unknown> = Record<string, unknown>, Model = unknown, Message extends TaggedMessage = TaggedMessage> = {
|
|
20
|
-
readonly Model: unknown;
|
|
21
|
-
readonly init: (props: Props) => readonly [Model, CommandBatch];
|
|
22
|
-
readonly update: Runtime.ApplicationConfig<Model, Message>['update'];
|
|
23
|
-
readonly view: Runtime.ApplicationConfig<Model, Message>['view'];
|
|
24
|
-
};
|
|
25
|
-
type FoldkitApp<Props extends Record<string, unknown> = Record<string, unknown>, Config extends AppConfigShape<Props> = AppConfigShape<Props>> = {
|
|
26
|
-
(props?: Props): void;
|
|
27
|
-
readonly __foldkit: true;
|
|
28
|
-
readonly load: () => Promise<Config>;
|
|
29
|
-
};
|
|
30
|
-
type PageParams = Readonly<Record<string, string | undefined>>;
|
|
31
|
-
type PageFlagsContext<Props extends Record<string, unknown> = Record<string, unknown>> = {
|
|
32
|
-
readonly request: Request;
|
|
33
|
-
readonly url: URL;
|
|
34
|
-
readonly params: PageParams;
|
|
35
|
-
readonly props: Props;
|
|
36
|
-
};
|
|
37
|
-
type PageContext<Props extends Record<string, unknown> = Record<string, unknown>> = PageFlagsContext<Props>;
|
|
38
|
-
type PageFlagsSchema<Flags extends Record<string, unknown>> = Schema.Codec<Flags, any, never, never>;
|
|
39
|
-
type PageConfig<Flags extends Record<string, unknown> = Record<string, unknown>, Model = unknown, Message extends TaggedMessage = TaggedMessage> = AppConfig<Flags, Model, Message> & {
|
|
40
|
-
readonly Flags: PageFlagsSchema<Flags>;
|
|
41
|
-
};
|
|
42
|
-
type PageConfigShape<Flags extends Record<string, unknown>> = AppConfigShape<Flags> & {
|
|
43
|
-
readonly Flags: PageFlagsSchema<Flags>;
|
|
44
|
-
};
|
|
45
|
-
type DefinePageOptions<Props extends Record<string, unknown> = Record<string, unknown>, Flags extends Record<string, unknown> = Record<string, unknown>> = {
|
|
46
|
-
readonly flags: (context: PageFlagsContext<Props>) => Flags;
|
|
47
|
-
};
|
|
48
|
-
type FoldkitPage<Props extends Record<string, unknown> = Record<string, unknown>, Flags extends Record<string, unknown> = Record<string, unknown>, Config extends PageConfigShape<Flags> = PageConfigShape<Flags>> = {
|
|
49
|
-
(props?: Props): void;
|
|
50
|
-
readonly __foldkitPage: true;
|
|
51
|
-
readonly load: () => Promise<Config>;
|
|
52
|
-
readonly flags: (context: PageFlagsContext<Props>) => Flags;
|
|
53
|
-
};
|
|
54
|
-
//#endregion
|
|
55
|
-
export { FoldkitPage as a, PageContext as c, PageParams as d, FoldkitApp as i, PageFlagsContext as l, AppConfigShape as n, PageConfig as o, DefinePageOptions as r, PageConfigShape as s, AppConfig as t, PageFlagsSchema as u };
|