foldkit 0.40.0 → 0.41.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 +20 -18
- package/dist/devtools/overlay.d.ts.map +1 -1
- package/dist/devtools/overlay.js +34 -5
- package/dist/devtools/store.d.ts +2 -1
- package/dist/devtools/store.d.ts.map +1 -1
- package/dist/devtools/store.js +4 -1
- package/dist/runtime/browserListeners.d.ts +2 -2
- package/dist/runtime/browserListeners.js +11 -11
- package/dist/runtime/crashUI.d.ts.map +1 -1
- package/dist/runtime/crashUI.js +1 -3
- package/dist/runtime/public.d.ts +2 -2
- package/dist/runtime/public.d.ts.map +1 -1
- package/dist/runtime/public.js +1 -1
- package/dist/runtime/runtime.d.ts +31 -46
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +21 -43
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<h3 align="center">The frontend framework for correctness.</h3>
|
|
14
14
|
|
|
15
15
|
<p align="center">
|
|
16
|
-
<a href="https://foldkit.dev"><strong>Documentation</strong></a> · <a href="https://
|
|
16
|
+
<a href="https://foldkit.dev"><strong>Documentation</strong></a> · <a href="https://foldkit.dev/example-apps"><strong>Examples</strong></a> · <a href="https://foldkit.dev/getting-started"><strong>Getting Started</strong></a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
---
|
|
@@ -84,7 +84,7 @@ const update = (
|
|
|
84
84
|
|
|
85
85
|
// INIT
|
|
86
86
|
|
|
87
|
-
const init: Runtime.
|
|
87
|
+
const init: Runtime.ProgramInit<Model, Message> = () => [{ count: 0 }, []]
|
|
88
88
|
|
|
89
89
|
// VIEW
|
|
90
90
|
|
|
@@ -119,7 +119,7 @@ const buttonStyle = 'bg-black text-white hover:bg-gray-700 px-4 py-2 transition'
|
|
|
119
119
|
|
|
120
120
|
// RUN
|
|
121
121
|
|
|
122
|
-
const
|
|
122
|
+
const program = Runtime.makeProgram({
|
|
123
123
|
Model,
|
|
124
124
|
init,
|
|
125
125
|
update,
|
|
@@ -127,7 +127,7 @@ const element = Runtime.makeElement({
|
|
|
127
127
|
container: document.getElementById('root')!,
|
|
128
128
|
})
|
|
129
129
|
|
|
130
|
-
Runtime.run(
|
|
130
|
+
Runtime.run(program)
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
Source: [examples/counter/src/main.ts](https://github.com/foldkit/foldkit/blob/main/examples/counter/src/main.ts)
|
|
@@ -143,7 +143,8 @@ Foldkit is a complete system, not a collection of libraries you stitch together.
|
|
|
143
143
|
- **UI Components** — Dialog, menu, tabs, listbox, disclosure — fully accessible primitives that are easy to style and customize.
|
|
144
144
|
- **Field Validation** — Per-field validation state modeled as a discriminated union. Define rules as data, apply them in update, and the Model tracks the result.
|
|
145
145
|
- **Virtual DOM** — Declarative Views powered by [Snabbdom](https://github.com/snabbdom/snabbdom). Fast, keyed diffing. Views are plain functions of your Model.
|
|
146
|
-
- **DevTools** — Built-in overlay for inspecting Messages
|
|
146
|
+
- **DevTools** — Built-in overlay for inspecting Messages, Model state, and Commands. Time-travel mode lets you jump to any point in your app's history.
|
|
147
|
+
- **Testing** — Simulate the update loop in tests. Send Messages, resolve Commands inline, and assert on the Model. No mocking libraries, no fake timers, no setup or teardown.
|
|
147
148
|
- **HMR** — Vite plugin with state-preserving hot module replacement. Change your view, keep your state.
|
|
148
149
|
|
|
149
150
|
## Correctness You (And Your LLM) Can See
|
|
@@ -154,19 +155,20 @@ This is what makes Foldkit unusually AI-friendly. The same property that makes t
|
|
|
154
155
|
|
|
155
156
|
## Examples
|
|
156
157
|
|
|
157
|
-
- **[Counter](https://
|
|
158
|
-
- **[Todo](https://
|
|
159
|
-
- **[Stopwatch](https://
|
|
160
|
-
- **[Crash View](https://
|
|
161
|
-
- **[Form](https://
|
|
162
|
-
- **[Weather](https://
|
|
163
|
-
- **[Routing](https://
|
|
164
|
-
- **[Query Sync](https://
|
|
165
|
-
- **[Snake](https://
|
|
166
|
-
- **[Auth](https://
|
|
167
|
-
- **[Shopping Cart](https://
|
|
168
|
-
- **[WebSocket Chat](https://
|
|
169
|
-
- **[
|
|
158
|
+
- **[Counter](https://foldkit.dev/example-apps/counter)** — Increment/decrement with reset
|
|
159
|
+
- **[Todo](https://foldkit.dev/example-apps/todo)** — CRUD operations with localStorage persistence
|
|
160
|
+
- **[Stopwatch](https://foldkit.dev/example-apps/stopwatch)** — Timer with start/stop/reset
|
|
161
|
+
- **[Crash View](https://foldkit.dev/example-apps/crash-view)** — Custom crash fallback UI with crash reporting
|
|
162
|
+
- **[Form](https://foldkit.dev/example-apps/form)** — Form validation with async email checking
|
|
163
|
+
- **[Weather](https://foldkit.dev/example-apps/weather)** — HTTP requests with async state handling
|
|
164
|
+
- **[Routing](https://foldkit.dev/example-apps/routing)** — URL routing with parser combinators
|
|
165
|
+
- **[Query Sync](https://foldkit.dev/example-apps/query-sync)** — URL query parameter sync with filtering and sorting
|
|
166
|
+
- **[Snake](https://foldkit.dev/example-apps/snake)** — Classic game built with Subscriptions
|
|
167
|
+
- **[Auth](https://foldkit.dev/example-apps/auth)** — Authentication flow with Submodels and OutMessage
|
|
168
|
+
- **[Shopping Cart](https://foldkit.dev/example-apps/shopping-cart)** — Nested models and complex state
|
|
169
|
+
- **[WebSocket Chat](https://foldkit.dev/example-apps/websocket-chat)** — Managed Resources with WebSocket integration
|
|
170
|
+
- **[UI Showcase](https://foldkit.dev/example-apps/ui-showcase)** — Interactive showcase of every Foldkit UI component
|
|
171
|
+
- **[Typing Game](https://github.com/foldkit/foldkit/tree/main/packages/typing-game)** — Multiplayer typing game with Effect RPC backend ([play it live](https://typingterminal.com))
|
|
170
172
|
|
|
171
173
|
## License
|
|
172
174
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/devtools/overlay.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,MAAM,EACN,OAAO,EAGP,MAAM,EAQP,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AAKrC,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAMxE,OAAO,EAAE,KAAK,aAAa,EAA+B,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/devtools/overlay.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,MAAM,EACN,OAAO,EAGP,MAAM,EAQP,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AAKrC,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAMxE,OAAO,EAAE,KAAK,aAAa,EAA+B,MAAM,SAAS,CAAA;AA4QzE,eAAO,MAAM,MAAM;;EAA0C,CAAA;AAC7D,eAAO,MAAM,YAAY;;;;;;EAGxB,CAAA;AACD,eAAO,MAAM,aAAa;;;;;;EAGzB,CAAA;AACD,eAAO,MAAM,MAAM;;EAA4C,CAAA;AAC/D,eAAO,MAAM,KAAK;;EAA0C,CAAA;AAC5D,eAAO,MAAM,UAAU;;EAA6C,CAAA;AACpE,eAAO,MAAM,YAAY;;EAAiD,CAAA;AAC1E,eAAO,MAAM,WAAW;;EAA+C,CAAA;AAsmCvE,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,UAAU,gBAAgB,EAC1B,MAAM,YAAY,EAClB,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,sCA4ChC,CAAA"}
|
package/dist/devtools/overlay.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as Command from '../command';
|
|
|
4
4
|
import { OptionExt } from '../effectExtensions';
|
|
5
5
|
import { createKeyedLazy, html } from '../html';
|
|
6
6
|
import { m } from '../message';
|
|
7
|
-
import {
|
|
7
|
+
import { makeProgram } from '../runtime/runtime';
|
|
8
8
|
import { makeSubscriptions } from '../runtime/subscription';
|
|
9
9
|
import { evo } from '../struct';
|
|
10
10
|
import { lockScroll, unlockScroll } from '../task/scrollLock';
|
|
@@ -29,6 +29,7 @@ const Model = S.Struct({
|
|
|
29
29
|
isOpen: S.Boolean,
|
|
30
30
|
isMobile: S.Boolean,
|
|
31
31
|
entries: S.Array(DisplayEntry),
|
|
32
|
+
initCommandNames: S.Array(S.String),
|
|
32
33
|
startIndex: S.Number,
|
|
33
34
|
isPaused: S.Boolean,
|
|
34
35
|
pausedAtIndex: S.Number,
|
|
@@ -44,6 +45,7 @@ const Model = S.Struct({
|
|
|
44
45
|
const Flags = S.Struct({
|
|
45
46
|
isMobile: S.Boolean,
|
|
46
47
|
entries: S.Array(DisplayEntry),
|
|
48
|
+
initCommandNames: S.Array(S.String),
|
|
47
49
|
startIndex: S.Number,
|
|
48
50
|
isPaused: S.Boolean,
|
|
49
51
|
pausedAtIndex: S.Number,
|
|
@@ -75,6 +77,7 @@ const GotInspectorTabsMessage = m('GotInspectorTabsMessage', {
|
|
|
75
77
|
});
|
|
76
78
|
const ReceivedStoreUpdate = m('ReceivedStoreUpdate', {
|
|
77
79
|
entries: S.Array(DisplayEntry),
|
|
80
|
+
initCommandNames: S.Array(S.String),
|
|
78
81
|
startIndex: S.Number,
|
|
79
82
|
isPaused: S.Boolean,
|
|
80
83
|
pausedAtIndex: S.Number,
|
|
@@ -96,6 +99,7 @@ const toDisplayEntries = ({ entries }) => Array_.map(entries, ({ tag, commandNam
|
|
|
96
99
|
}));
|
|
97
100
|
const toDisplayState = (state) => ({
|
|
98
101
|
entries: toDisplayEntries(state),
|
|
102
|
+
initCommandNames: state.initCommandNames,
|
|
99
103
|
startIndex: state.startIndex,
|
|
100
104
|
isPaused: state.isPaused,
|
|
101
105
|
pausedAtIndex: state.pausedAtIndex,
|
|
@@ -302,7 +306,7 @@ const makeUpdate = (store, shadow, mode) => {
|
|
|
302
306
|
}),
|
|
303
307
|
[],
|
|
304
308
|
],
|
|
305
|
-
ReceivedStoreUpdate: ({ entries, startIndex, isPaused, pausedAtIndex, }) => {
|
|
309
|
+
ReceivedStoreUpdate: ({ entries, initCommandNames, startIndex, isPaused, pausedAtIndex, }) => {
|
|
306
310
|
const shouldFollowLatest = M.value(mode).pipe(M.when('TimeTravel', () => !isPaused), M.when('Inspect', () => model.isFollowingLatest), M.exhaustive);
|
|
307
311
|
const latestIndex = Array_.match(entries, {
|
|
308
312
|
onEmpty: () => INIT_INDEX,
|
|
@@ -311,6 +315,7 @@ const makeUpdate = (store, shadow, mode) => {
|
|
|
311
315
|
return [
|
|
312
316
|
evo(model, {
|
|
313
317
|
entries: () => entries,
|
|
318
|
+
initCommandNames: () => initCommandNames,
|
|
314
319
|
startIndex: () => startIndex,
|
|
315
320
|
isPaused: () => isPaused,
|
|
316
321
|
pausedAtIndex: () => pausedAtIndex,
|
|
@@ -513,7 +518,11 @@ const makeView = (position, mode, maybeBanner) => {
|
|
|
513
518
|
const emptyInspectorView = div([
|
|
514
519
|
Class('flex-1 flex items-center justify-center text-dt-muted text-2xs font-mono min-w-0'),
|
|
515
520
|
], ['Click a message to inspect']);
|
|
516
|
-
const INSPECTOR_TABS = [
|
|
521
|
+
const INSPECTOR_TABS = [
|
|
522
|
+
'Model',
|
|
523
|
+
'Message',
|
|
524
|
+
'Commands',
|
|
525
|
+
];
|
|
517
526
|
const noMessageView = div([
|
|
518
527
|
Class('flex-1 flex items-center justify-center text-dt-muted text-2xs font-mono min-w-0'),
|
|
519
528
|
], ['init — no Message']);
|
|
@@ -529,7 +538,27 @@ const makeView = (position, mode, maybeBanner) => {
|
|
|
529
538
|
]),
|
|
530
539
|
]),
|
|
531
540
|
});
|
|
532
|
-
const
|
|
541
|
+
const selectedCommandNames = (model) => {
|
|
542
|
+
const selectedIndex = M.value(mode).pipe(M.when('TimeTravel', () => model.isPaused ? model.pausedAtIndex : INIT_INDEX), M.when('Inspect', () => model.selectedIndex), M.exhaustive);
|
|
543
|
+
if (selectedIndex === INIT_INDEX) {
|
|
544
|
+
return model.initCommandNames;
|
|
545
|
+
}
|
|
546
|
+
return pipe(Array_.get(model.entries, selectedIndex - model.startIndex), Option.map(entry => entry.commandNames), Option.getOrElse(() => []));
|
|
547
|
+
};
|
|
548
|
+
const commandsTabContent = (model) => Array_.match(selectedCommandNames(model), {
|
|
549
|
+
onEmpty: () => div([
|
|
550
|
+
Class('flex-1 flex items-center justify-center text-dt-muted text-2xs font-mono min-w-0'),
|
|
551
|
+
], ['No Commands returned']),
|
|
552
|
+
onNonEmpty: names => div([
|
|
553
|
+
Class('flex flex-col flex-1 min-h-0 min-w-0 overflow-auto overscroll-none'),
|
|
554
|
+
], Array_.map(names, (name, index) => div([
|
|
555
|
+
Class('flex items-center px-2 py-1 text-base font-mono text-dt border-b gap-1.5'),
|
|
556
|
+
], [
|
|
557
|
+
span([Class(indexClass)], [String(index + 1)]),
|
|
558
|
+
span([Class('json-tag')], [name]),
|
|
559
|
+
]))),
|
|
560
|
+
});
|
|
561
|
+
const inspectorTabContent = (model, tab, inspectedModel) => M.value(tab).pipe(M.when('Model', () => modelTabContent(model, inspectedModel)), M.when('Message', () => messageTabContent(model)), M.when('Commands', () => commandsTabContent(model)), M.exhaustive);
|
|
533
562
|
const inspectorPaneView = (model) => div([
|
|
534
563
|
Class('flex flex-col border-l min-w-0 min-h-0 flex-1 dt-inspector-pane'),
|
|
535
564
|
], [
|
|
@@ -734,7 +763,7 @@ export const createOverlay = (store, position, mode, maybeBanner) => Effect.gen(
|
|
|
734
763
|
},
|
|
735
764
|
[],
|
|
736
765
|
];
|
|
737
|
-
const overlayRuntime =
|
|
766
|
+
const overlayRuntime = makeProgram({
|
|
738
767
|
Model,
|
|
739
768
|
Flags,
|
|
740
769
|
flags,
|
package/dist/devtools/store.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type StoreState = Readonly<{
|
|
|
11
11
|
entries: ReadonlyArray<HistoryEntry>;
|
|
12
12
|
keyframes: HashMap.HashMap<number, unknown>;
|
|
13
13
|
maybeInitModel: Option.Option<unknown>;
|
|
14
|
+
initCommandNames: ReadonlyArray<string>;
|
|
14
15
|
startIndex: number;
|
|
15
16
|
isPaused: boolean;
|
|
16
17
|
pausedAtIndex: number;
|
|
@@ -22,7 +23,7 @@ export type Bridge = Readonly<{
|
|
|
22
23
|
}>;
|
|
23
24
|
export declare const createDevtoolsStore: (bridge: Bridge, maxEntries?: number) => Effect.Effect<DevtoolsStore>;
|
|
24
25
|
export type DevtoolsStore = Readonly<{
|
|
25
|
-
recordInit: (model: unknown) => Effect.Effect<void>;
|
|
26
|
+
recordInit: (model: unknown, commandNames: ReadonlyArray<string>) => Effect.Effect<void>;
|
|
26
27
|
recordMessage: (message: Readonly<{
|
|
27
28
|
_tag: string;
|
|
28
29
|
}>, modelAfterUpdate: unknown, commandNames: ReadonlyArray<string>, isModelChanged: boolean) => Effect.Effect<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/devtools/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAQ,MAAM,QAAQ,CAAA;AAE9E,eAAO,MAAM,UAAU,KAAK,CAAA;AAI5B,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;CACxB,CAAC,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACpC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3C,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACtC,UA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C1B,QAAQ,EAAE,eAAe,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;CACtD,CAAC,CAAA"}
|
package/dist/devtools/store.js
CHANGED
|
@@ -6,6 +6,7 @@ const emptyState = {
|
|
|
6
6
|
entries: [],
|
|
7
7
|
keyframes: HashMap.empty(),
|
|
8
8
|
maybeInitModel: Option.none(),
|
|
9
|
+
initCommandNames: [],
|
|
9
10
|
startIndex: 0,
|
|
10
11
|
isPaused: false,
|
|
11
12
|
pausedAtIndex: 0,
|
|
@@ -34,9 +35,10 @@ export const createDevtoolsStore = (bridge, maxEntries = DEFAULT_MAX_ENTRIES) =>
|
|
|
34
35
|
isPaused: state.isPaused && isPausedAtRetainedIndex,
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
|
-
const recordInit = (model) => SubscriptionRef.update(stateRef, state => ({
|
|
38
|
+
const recordInit = (model, commandNames) => SubscriptionRef.update(stateRef, state => ({
|
|
38
39
|
...state,
|
|
39
40
|
maybeInitModel: Option.some(model),
|
|
41
|
+
initCommandNames: commandNames,
|
|
40
42
|
keyframes: HashMap.set(state.keyframes, 0, model),
|
|
41
43
|
}));
|
|
42
44
|
const recordMessage = (message, modelAfterUpdate, commandNames, isModelChanged) => SubscriptionRef.update(stateRef, state => {
|
|
@@ -83,6 +85,7 @@ export const createDevtoolsStore = (bridge, maxEntries = DEFAULT_MAX_ENTRIES) =>
|
|
|
83
85
|
const clear = SubscriptionRef.update(stateRef, state => ({
|
|
84
86
|
...emptyState,
|
|
85
87
|
maybeInitModel: state.maybeInitModel,
|
|
88
|
+
initCommandNames: state.initCommandNames,
|
|
86
89
|
keyframes: Option.match(state.maybeInitModel, {
|
|
87
90
|
onNone: () => HashMap.empty(),
|
|
88
91
|
onSome: model => HashMap.set(HashMap.empty(), 0, model),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Queue } from 'effect';
|
|
2
|
-
import {
|
|
3
|
-
export declare const addNavigationEventListeners: <Message>(messageQueue: Queue.Queue<Message>,
|
|
2
|
+
import { RoutingConfig } from './runtime';
|
|
3
|
+
export declare const addNavigationEventListeners: <Message>(messageQueue: Queue.Queue<Message>, routingConfig: RoutingConfig<Message>) => void;
|
|
4
4
|
export declare const addBfcacheRestoreListener: () => void;
|
|
5
5
|
//# sourceMappingURL=browserListeners.d.ts.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Option, Queue, String } from 'effect';
|
|
2
2
|
import { OptionExt, StringExt } from '../effectExtensions';
|
|
3
3
|
import { External, Internal } from './urlRequest';
|
|
4
|
-
export const addNavigationEventListeners = (messageQueue,
|
|
5
|
-
addPopStateListener(messageQueue,
|
|
6
|
-
addLinkClickListener(messageQueue,
|
|
7
|
-
addProgrammaticNavigationListener(messageQueue,
|
|
4
|
+
export const addNavigationEventListeners = (messageQueue, routingConfig) => {
|
|
5
|
+
addPopStateListener(messageQueue, routingConfig);
|
|
6
|
+
addLinkClickListener(messageQueue, routingConfig);
|
|
7
|
+
addProgrammaticNavigationListener(messageQueue, routingConfig);
|
|
8
8
|
};
|
|
9
|
-
const addPopStateListener = (messageQueue,
|
|
9
|
+
const addPopStateListener = (messageQueue, routingConfig) => {
|
|
10
10
|
const onPopState = () => {
|
|
11
|
-
Queue.unsafeOffer(messageQueue,
|
|
11
|
+
Queue.unsafeOffer(messageQueue, routingConfig.onUrlChange(locationToUrl()));
|
|
12
12
|
};
|
|
13
13
|
window.addEventListener('popstate', onPopState);
|
|
14
14
|
};
|
|
15
|
-
const addLinkClickListener = (messageQueue,
|
|
15
|
+
const addLinkClickListener = (messageQueue, routingConfig) => {
|
|
16
16
|
const onLinkClick = (event) => {
|
|
17
17
|
const target = event.target;
|
|
18
18
|
if (!target || !('closest' in target)) {
|
|
@@ -31,16 +31,16 @@ const addLinkClickListener = (messageQueue, browserConfig) => {
|
|
|
31
31
|
const linkUrl = new URL(href);
|
|
32
32
|
const currentUrl = new URL(window.location.href);
|
|
33
33
|
if (linkUrl.origin !== currentUrl.origin) {
|
|
34
|
-
Queue.unsafeOffer(messageQueue,
|
|
34
|
+
Queue.unsafeOffer(messageQueue, routingConfig.onUrlRequest(External({ href })));
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
Queue.unsafeOffer(messageQueue,
|
|
37
|
+
Queue.unsafeOffer(messageQueue, routingConfig.onUrlRequest(Internal({ url: urlToFoldkitUrl(linkUrl) })));
|
|
38
38
|
};
|
|
39
39
|
document.addEventListener('click', onLinkClick);
|
|
40
40
|
};
|
|
41
|
-
const addProgrammaticNavigationListener = (messageQueue,
|
|
41
|
+
const addProgrammaticNavigationListener = (messageQueue, routingConfig) => {
|
|
42
42
|
const onProgrammaticNavigation = () => {
|
|
43
|
-
Queue.unsafeOffer(messageQueue,
|
|
43
|
+
Queue.unsafeOffer(messageQueue, routingConfig.onUrlChange(locationToUrl()));
|
|
44
44
|
};
|
|
45
45
|
window.addEventListener('foldkit:urlchange', onProgrammaticNavigation);
|
|
46
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crashUI.d.ts","sourceRoot":"","sources":["../../src/runtime/crashUI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,IAAI,EAAQ,MAAM,SAAS,CAAA;AAEpC,eAAO,MAAM,YAAY;8BACG,OAAO;6BACR,OAAO;CACjC,CAAA;AAmBD,eAAO,MAAM,gBAAgB,GAC3B,SAAS,QAAQ,CAAC;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,EACnC,YAAY,OAAO,KAClB,
|
|
1
|
+
{"version":3,"file":"crashUI.d.ts","sourceRoot":"","sources":["../../src/runtime/crashUI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,IAAI,EAAQ,MAAM,SAAS,CAAA;AAEpC,eAAO,MAAM,YAAY;8BACG,OAAO;6BACR,OAAO;CACjC,CAAA;AAmBD,eAAO,MAAM,gBAAgB,GAC3B,SAAS,QAAQ,CAAC;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,EACnC,YAAY,OAAO,KAClB,IA0LF,CAAA"}
|
package/dist/runtime/crashUI.js
CHANGED
|
@@ -92,9 +92,7 @@ export const defaultCrashView = (context, viewError) => {
|
|
|
92
92
|
'This is the default crash view. You can customize it by providing a ',
|
|
93
93
|
span([inlineCodeStyle], ['crash.view']),
|
|
94
94
|
' function to ',
|
|
95
|
-
span([inlineCodeStyle], ['
|
|
96
|
-
' or ',
|
|
97
|
-
span([inlineCodeStyle], ['makeApplication']),
|
|
95
|
+
span([inlineCodeStyle], ['makeProgram']),
|
|
98
96
|
'.',
|
|
99
97
|
]),
|
|
100
98
|
];
|
package/dist/runtime/public.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { makeProgram, run } from './runtime';
|
|
2
|
+
export type { RoutingConfig, CrashConfig, CrashContext, RoutingProgramConfigWithFlags, RoutingProgramConfig, ProgramConfigWithFlags, ProgramConfig, ProgramInit, RoutingProgramInit, MakeRuntimeReturn, Visibility, SlowViewContext, SlowViewConfig, DevtoolsConfig, } from './runtime';
|
|
3
3
|
export { UrlRequest } from './urlRequest';
|
|
4
4
|
export type { Internal, External } from './urlRequest';
|
|
5
5
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/runtime/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/runtime/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE5C,YAAY,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,6BAA6B,EAC7B,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,cAAc,EACd,cAAc,GACf,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/runtime/public.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { makeProgram, run } from './runtime';
|
|
2
2
|
export { UrlRequest } from './urlRequest';
|
|
@@ -60,8 +60,8 @@ declare const Dispatch_base: Context.TagClass<Dispatch, "@foldkit/Dispatch", {
|
|
|
60
60
|
export declare class Dispatch extends Dispatch_base {
|
|
61
61
|
}
|
|
62
62
|
export type { Command } from '../command';
|
|
63
|
-
/** Configuration for
|
|
64
|
-
export type
|
|
63
|
+
/** Configuration for URL routing with handlers for URL requests and URL changes. */
|
|
64
|
+
export type RoutingConfig<Message> = Readonly<{
|
|
65
65
|
onUrlRequest: (request: UrlRequest) => Message;
|
|
66
66
|
onUrlChange: (url: Url) => Message;
|
|
67
67
|
}>;
|
|
@@ -76,7 +76,7 @@ export type CrashConfig<Model, Message> = Readonly<{
|
|
|
76
76
|
view?: (context: CrashContext<Model, Message>) => Html;
|
|
77
77
|
report?: (context: CrashContext<Model, Message>) => void;
|
|
78
78
|
}>;
|
|
79
|
-
type
|
|
79
|
+
type BaseProgramConfig<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never> = Readonly<{
|
|
80
80
|
Model: Schema.Schema<Model, any, never>;
|
|
81
81
|
update: (model: Model, message: Message) => readonly [
|
|
82
82
|
Model,
|
|
@@ -91,86 +91,71 @@ type BaseElementConfig<Model, Message, StreamDepsMap extends Schema.Struct<Schem
|
|
|
91
91
|
managedResources?: ManagedResources<Model, Message, ManagedResourceServices>;
|
|
92
92
|
devtools?: DevtoolsConfig;
|
|
93
93
|
}>;
|
|
94
|
-
/** Configuration for `
|
|
95
|
-
export type
|
|
94
|
+
/** Configuration for `makeProgram` with flags and URL routing. */
|
|
95
|
+
export type RoutingProgramConfigWithFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags, Resources = never, ManagedResourceServices = never> = BaseProgramConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices> & Readonly<{
|
|
96
96
|
Flags: Schema.Schema<Flags, any, never>;
|
|
97
97
|
flags: Effect.Effect<Flags>;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
101
|
-
];
|
|
102
|
-
}>;
|
|
103
|
-
/** Configuration for `makeElement` without flags. */
|
|
104
|
-
export type ElementConfigWithoutFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never> = BaseElementConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices> & Readonly<{
|
|
105
|
-
init: () => readonly [
|
|
98
|
+
routing: RoutingConfig<Message>;
|
|
99
|
+
init: (flags: Flags, url: Url) => readonly [
|
|
106
100
|
Model,
|
|
107
101
|
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
108
102
|
];
|
|
109
103
|
}>;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
/** Configuration for `makeProgram` with URL routing but no flags. */
|
|
105
|
+
export type RoutingProgramConfig<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never> = BaseProgramConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices> & Readonly<{
|
|
106
|
+
routing: RoutingConfig<Message>;
|
|
107
|
+
init: (url: Url) => readonly [
|
|
113
108
|
Model,
|
|
114
109
|
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
115
110
|
];
|
|
116
|
-
view: (model: Model) => Html;
|
|
117
|
-
subscriptions?: Subscriptions<Model, Message, StreamDepsMap, Resources | ManagedResourceServices>;
|
|
118
|
-
container: HTMLElement;
|
|
119
|
-
browser: BrowserConfig<Message>;
|
|
120
|
-
crash?: CrashConfig<Model, Message>;
|
|
121
|
-
slowView?: SlowViewConfig<Model, Message>;
|
|
122
|
-
resources?: Layer.Layer<Resources>;
|
|
123
|
-
managedResources?: ManagedResources<Model, Message, ManagedResourceServices>;
|
|
124
|
-
devtools?: DevtoolsConfig;
|
|
125
111
|
}>;
|
|
126
|
-
/** Configuration for `
|
|
127
|
-
export type
|
|
112
|
+
/** Configuration for `makeProgram` with flags but no URL routing. */
|
|
113
|
+
export type ProgramConfigWithFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags, Resources = never, ManagedResourceServices = never> = BaseProgramConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices> & Readonly<{
|
|
128
114
|
Flags: Schema.Schema<Flags, any, never>;
|
|
129
115
|
flags: Effect.Effect<Flags>;
|
|
130
|
-
init: (flags: Flags
|
|
116
|
+
init: (flags: Flags) => readonly [
|
|
131
117
|
Model,
|
|
132
118
|
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
133
119
|
];
|
|
134
120
|
}>;
|
|
135
|
-
/** Configuration for `
|
|
136
|
-
export type
|
|
137
|
-
init: (
|
|
121
|
+
/** Configuration for `makeProgram` without flags or URL routing. */
|
|
122
|
+
export type ProgramConfig<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never> = BaseProgramConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices> & Readonly<{
|
|
123
|
+
init: () => readonly [
|
|
138
124
|
Model,
|
|
139
125
|
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
140
126
|
];
|
|
141
127
|
}>;
|
|
142
|
-
/** The `init` function type for
|
|
143
|
-
export type
|
|
128
|
+
/** The `init` function type for programs without URL routing. */
|
|
129
|
+
export type ProgramInit<Model, Message, Flags = void, Resources = never, ManagedResourceServices = never> = Flags extends void ? () => readonly [
|
|
144
130
|
Model,
|
|
145
131
|
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
146
132
|
] : (flags: Flags) => readonly [
|
|
147
133
|
Model,
|
|
148
134
|
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
149
135
|
];
|
|
150
|
-
/** The `init` function type for
|
|
151
|
-
export type
|
|
136
|
+
/** The `init` function type for programs with URL routing, receives the current URL and optional flags. */
|
|
137
|
+
export type RoutingProgramInit<Model, Message, Flags = void, Resources = never, ManagedResourceServices = never> = Flags extends void ? (url: Url) => readonly [
|
|
152
138
|
Model,
|
|
153
139
|
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
154
140
|
] : (flags: Flags, url: Url) => readonly [
|
|
155
141
|
Model,
|
|
156
142
|
ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
|
|
157
143
|
];
|
|
158
|
-
/** A configured Foldkit runtime returned by `
|
|
144
|
+
/** A configured Foldkit runtime returned by `makeProgram`, passed to `run` to start the application. */
|
|
159
145
|
export type MakeRuntimeReturn = (hmrModel?: unknown) => Effect.Effect<void>;
|
|
160
|
-
/** Creates a Foldkit
|
|
161
|
-
export declare function
|
|
146
|
+
/** Creates a Foldkit program and returns a runtime that can be passed to `run`. Add a `routing` config for URL routing. */
|
|
147
|
+
export declare function makeProgram<Model, Message extends {
|
|
162
148
|
_tag: string;
|
|
163
|
-
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags, Resources = never, ManagedResourceServices = never>(config:
|
|
164
|
-
export declare function
|
|
149
|
+
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags, Resources = never, ManagedResourceServices = never>(config: RoutingProgramConfigWithFlags<Model, Message, StreamDepsMap, Flags, Resources, ManagedResourceServices>): MakeRuntimeReturn;
|
|
150
|
+
export declare function makeProgram<Model, Message extends {
|
|
165
151
|
_tag: string;
|
|
166
|
-
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never>(config:
|
|
167
|
-
|
|
168
|
-
export declare function makeApplication<Model, Message extends {
|
|
152
|
+
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never>(config: RoutingProgramConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices>): MakeRuntimeReturn;
|
|
153
|
+
export declare function makeProgram<Model, Message extends {
|
|
169
154
|
_tag: string;
|
|
170
|
-
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags, Resources = never, ManagedResourceServices = never>(config:
|
|
171
|
-
export declare function
|
|
155
|
+
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags, Resources = never, ManagedResourceServices = never>(config: ProgramConfigWithFlags<Model, Message, StreamDepsMap, Flags, Resources, ManagedResourceServices>): MakeRuntimeReturn;
|
|
156
|
+
export declare function makeProgram<Model, Message extends {
|
|
172
157
|
_tag: string;
|
|
173
|
-
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never>(config:
|
|
158
|
+
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never>(config: ProgramConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices>): MakeRuntimeReturn;
|
|
174
159
|
/** Starts a Foldkit runtime, with HMR support for development. */
|
|
175
160
|
export declare const run: (foldkitRuntime: MakeRuntimeReturn) => void;
|
|
176
161
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,OAAO,EACP,MAAM,EAGN,KAAK,EAEL,MAAM,EAMN,MAAM,EAKP,MAAM,QAAQ,CAAA;AAGf,OAAO,KAAK,EAAE,OA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,iBAAiB,CAAA;AAEpB,wBAAgB,WAAW,CACzB,KAAK,EACL,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChC,aAAa,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EACzD,SAAS,GAAG,KAAK,EACjB,uBAAuB,GAAG,KAAK,EAE/B,MAAM,EAAE,oBAAoB,CAC1B,KAAK,EACL,OAAO,EACP,aAAa,EACb,SAAS,EACT,uBAAuB,CACxB,GACA,iBAAiB,CAAA;AAEpB,wBAAgB,WAAW,CACzB,KAAK,EACL,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChC,aAAa,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EACzD,KAAK,EACL,SAAS,GAAG,KAAK,EACjB,uBAAuB,GAAG,KAAK,EAE/B,MAAM,EAAE,sBAAsB,CAC5B,KAAK,EACL,OAAO,EACP,aAAa,EACb,KAAK,EACL,SAAS,EACT,uBAAuB,CACxB,GACA,iBAAiB,CAAA;AAEpB,wBAAgB,WAAW,CACzB,KAAK,EACL,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChC,aAAa,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EACzD,SAAS,GAAG,KAAK,EACjB,uBAAuB,GAAG,KAAK,EAE/B,MAAM,EAAE,aAAa,CACnB,KAAK,EACL,OAAO,EACP,aAAa,EACb,SAAS,EACT,uBAAuB,CACxB,GACA,iBAAiB,CAAA;AAgLpB,kEAAkE;AAClE,eAAO,MAAM,GAAG,GAAI,gBAAgB,iBAAiB,KAAG,IA+BvD,CAAA"}
|
package/dist/runtime/runtime.js
CHANGED
|
@@ -27,7 +27,7 @@ const defaultSlowViewCallback = (context) => {
|
|
|
27
27
|
/** Effect service tag that provides message dispatching to the view layer. */
|
|
28
28
|
export class Dispatch extends Context.Tag('@foldkit/Dispatch')() {
|
|
29
29
|
}
|
|
30
|
-
const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscriptions, container,
|
|
30
|
+
const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscriptions, container, routing: routingConfig, crash, slowView, resources, managedResources, devtools, }) => {
|
|
31
31
|
const resolvedSlowView = pipe(slowView ?? {}, Option.liftPredicate(config => config !== false), Option.filter(config => Match.value(config.show ?? DEFAULT_SLOW_VIEW_SHOW).pipe(Match.when('Always', () => true), Match.when('Development', () => !!import.meta.hot), Match.exhaustive)), Option.map(config => ({
|
|
32
32
|
thresholdMs: config.thresholdMs ?? DEFAULT_SLOW_VIEW_THRESHOLD_MS,
|
|
33
33
|
onSlowView: config.onSlowView ?? defaultSlowViewCallback,
|
|
@@ -67,7 +67,7 @@ const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscript
|
|
|
67
67
|
const modelEquivalence = Schema.equivalence(Model);
|
|
68
68
|
const messageQueue = yield* Queue.unbounded();
|
|
69
69
|
const enqueueMessage = (message) => Queue.offer(messageQueue, message);
|
|
70
|
-
const currentUrl = Option.fromNullable(
|
|
70
|
+
const currentUrl = Option.fromNullable(routingConfig).pipe(Option.flatMap(() => urlFromString(window.location.href)));
|
|
71
71
|
const [initModel, initCommands] = Predicate.isNotUndefined(hmrModel)
|
|
72
72
|
? pipe(hmrModel, Schema.decodeUnknownEither(Model), Either.match({
|
|
73
73
|
onLeft: () => init(flags, Option.getOrUndefined(currentUrl)),
|
|
@@ -78,8 +78,8 @@ const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscript
|
|
|
78
78
|
yield* Effect.forEach(
|
|
79
79
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
80
80
|
initCommands, command => Effect.forkDaemon(command.effect.pipe(Effect.withSpan(command.name), provideAllResources, Effect.flatMap(enqueueMessage))));
|
|
81
|
-
if (
|
|
82
|
-
addNavigationEventListeners(messageQueue,
|
|
81
|
+
if (routingConfig) {
|
|
82
|
+
addNavigationEventListeners(messageQueue, routingConfig);
|
|
83
83
|
}
|
|
84
84
|
const modelRef = yield* Ref.make(initModel);
|
|
85
85
|
const maybeCurrentVNodeRef = yield* Ref.make(Option.none());
|
|
@@ -189,7 +189,7 @@ const makeRuntime = ({ Model, flags: resolveFlags, init, update, view, subscript
|
|
|
189
189
|
getCurrentModel: Ref.get(modelRef),
|
|
190
190
|
});
|
|
191
191
|
yield* Ref.set(maybeDevtoolsStoreRef, Option.some(devtoolsStore));
|
|
192
|
-
yield* devtoolsStore.recordInit(initModel);
|
|
192
|
+
yield* devtoolsStore.recordInit(initModel, Array.map(initCommands, ({ name }) => name));
|
|
193
193
|
yield* createOverlay(devtoolsStore, position, mode, maybeBanner);
|
|
194
194
|
}
|
|
195
195
|
yield* render(initModel, Option.none());
|
|
@@ -284,13 +284,19 @@ const renderCrashView = (context, crash, container, maybeCurrentVNodeRef) => {
|
|
|
284
284
|
patchVNode(maybeCurrentVNode, vnode, container);
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
|
-
export function
|
|
287
|
+
export function makeProgram(config) {
|
|
288
|
+
const hasRouting = 'routing' in config;
|
|
289
|
+
const hasFlags = 'Flags' in config;
|
|
290
|
+
const currentUrl = hasRouting
|
|
291
|
+
? Option.getOrThrow(urlFromString(window.location.href))
|
|
292
|
+
: undefined;
|
|
288
293
|
const baseConfig = {
|
|
289
294
|
Model: config.Model,
|
|
290
295
|
update: config.update,
|
|
291
296
|
view: config.view,
|
|
292
297
|
...(config.subscriptions && { subscriptions: config.subscriptions }),
|
|
293
298
|
container: config.container,
|
|
299
|
+
...(hasRouting && { routing: config.routing }),
|
|
294
300
|
...(config.crash && { crash: config.crash }),
|
|
295
301
|
...(Predicate.isNotUndefined(config.slowView) && {
|
|
296
302
|
slowView: config.slowView,
|
|
@@ -303,68 +309,40 @@ export function makeElement(config) {
|
|
|
303
309
|
devtools: config.devtools,
|
|
304
310
|
}),
|
|
305
311
|
};
|
|
306
|
-
|
|
307
|
-
|
|
312
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
313
|
+
if (hasFlags && hasRouting) {
|
|
308
314
|
return makeRuntime({
|
|
309
315
|
...baseConfig,
|
|
310
316
|
Flags: config.Flags,
|
|
311
317
|
flags: config.flags,
|
|
312
|
-
init: (flags) =>
|
|
313
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
314
|
-
config.init(flags),
|
|
318
|
+
init: (flags, url) => config.init(flags, url ?? currentUrl),
|
|
315
319
|
});
|
|
316
320
|
}
|
|
317
|
-
else {
|
|
318
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
321
|
+
else if (hasRouting) {
|
|
319
322
|
return makeRuntime({
|
|
320
323
|
...baseConfig,
|
|
321
324
|
Flags: Schema.Void,
|
|
322
325
|
flags: Effect.succeed(undefined),
|
|
323
|
-
init: () => config.init(),
|
|
326
|
+
init: (_flags, url) => config.init(url ?? currentUrl),
|
|
324
327
|
});
|
|
325
328
|
}
|
|
326
|
-
|
|
327
|
-
export function makeApplication(config) {
|
|
328
|
-
const currentUrl = Option.getOrThrow(urlFromString(window.location.href));
|
|
329
|
-
const baseConfig = {
|
|
330
|
-
Model: config.Model,
|
|
331
|
-
update: config.update,
|
|
332
|
-
view: config.view,
|
|
333
|
-
...(config.subscriptions && { subscriptions: config.subscriptions }),
|
|
334
|
-
container: config.container,
|
|
335
|
-
browser: config.browser,
|
|
336
|
-
...(config.crash && { crash: config.crash }),
|
|
337
|
-
...(Predicate.isNotUndefined(config.slowView) && {
|
|
338
|
-
slowView: config.slowView,
|
|
339
|
-
}),
|
|
340
|
-
...(config.resources && { resources: config.resources }),
|
|
341
|
-
...(config.managedResources && {
|
|
342
|
-
managedResources: config.managedResources,
|
|
343
|
-
}),
|
|
344
|
-
...(Predicate.isNotUndefined(config.devtools) && {
|
|
345
|
-
devtools: config.devtools,
|
|
346
|
-
}),
|
|
347
|
-
};
|
|
348
|
-
if ('Flags' in config) {
|
|
349
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
329
|
+
else if (hasFlags) {
|
|
350
330
|
return makeRuntime({
|
|
351
331
|
...baseConfig,
|
|
352
332
|
Flags: config.Flags,
|
|
353
333
|
flags: config.flags,
|
|
354
|
-
init: (flags
|
|
355
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
356
|
-
config.init(flags, url ?? currentUrl),
|
|
334
|
+
init: (flags) => config.init(flags),
|
|
357
335
|
});
|
|
358
336
|
}
|
|
359
337
|
else {
|
|
360
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
361
338
|
return makeRuntime({
|
|
362
339
|
...baseConfig,
|
|
363
340
|
Flags: Schema.Void,
|
|
364
341
|
flags: Effect.succeed(undefined),
|
|
365
|
-
init: (
|
|
342
|
+
init: () => config.init(),
|
|
366
343
|
});
|
|
367
344
|
}
|
|
345
|
+
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
368
346
|
}
|
|
369
347
|
const preserveModel = (model) => {
|
|
370
348
|
if (import.meta.hot) {
|