foldkit 0.39.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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -20
  3. package/dist/command/index.d.ts +7 -5
  4. package/dist/command/index.d.ts.map +1 -1
  5. package/dist/command/index.js +2 -2
  6. package/dist/devtools/overlay.d.ts +34 -1
  7. package/dist/devtools/overlay.d.ts.map +1 -1
  8. package/dist/devtools/overlay.js +42 -13
  9. package/dist/devtools/store.d.ts +2 -1
  10. package/dist/devtools/store.d.ts.map +1 -1
  11. package/dist/devtools/store.js +4 -1
  12. package/dist/fieldValidation/index.d.ts +45 -37
  13. package/dist/fieldValidation/index.d.ts.map +1 -1
  14. package/dist/fieldValidation/public.d.ts +1 -1
  15. package/dist/fieldValidation/public.d.ts.map +1 -1
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -0
  19. package/dist/runtime/browserListeners.d.ts +2 -2
  20. package/dist/runtime/browserListeners.js +11 -11
  21. package/dist/runtime/crashUI.d.ts.map +1 -1
  22. package/dist/runtime/crashUI.js +1 -3
  23. package/dist/runtime/public.d.ts +2 -2
  24. package/dist/runtime/public.d.ts.map +1 -1
  25. package/dist/runtime/public.js +1 -1
  26. package/dist/runtime/runtime.d.ts +34 -49
  27. package/dist/runtime/runtime.d.ts.map +1 -1
  28. package/dist/runtime/runtime.js +21 -43
  29. package/dist/test/index.d.ts +40 -0
  30. package/dist/test/index.d.ts.map +1 -0
  31. package/dist/test/index.js +138 -0
  32. package/dist/test/public.d.ts +3 -0
  33. package/dist/test/public.d.ts.map +1 -0
  34. package/dist/test/public.js +1 -0
  35. package/dist/ui/checkbox/index.d.ts +1 -1
  36. package/dist/ui/checkbox/index.d.ts.map +1 -1
  37. package/dist/ui/combobox/multi.d.ts +1 -1
  38. package/dist/ui/combobox/shared.d.ts +34 -1
  39. package/dist/ui/combobox/shared.d.ts.map +1 -1
  40. package/dist/ui/combobox/shared.js +10 -10
  41. package/dist/ui/combobox/single.d.ts +1 -1
  42. package/dist/ui/dialog/index.d.ts +13 -1
  43. package/dist/ui/dialog/index.d.ts.map +1 -1
  44. package/dist/ui/dialog/index.js +4 -4
  45. package/dist/ui/disclosure/index.d.ts +4 -1
  46. package/dist/ui/disclosure/index.d.ts.map +1 -1
  47. package/dist/ui/disclosure/index.js +1 -1
  48. package/dist/ui/listbox/multi.d.ts +1 -1
  49. package/dist/ui/listbox/shared.d.ts +40 -1
  50. package/dist/ui/listbox/shared.d.ts.map +1 -1
  51. package/dist/ui/listbox/shared.js +12 -12
  52. package/dist/ui/listbox/single.d.ts +1 -1
  53. package/dist/ui/menu/index.d.ts +40 -1
  54. package/dist/ui/menu/index.d.ts.map +1 -1
  55. package/dist/ui/menu/index.js +12 -12
  56. package/dist/ui/popover/index.d.ts +30 -1
  57. package/dist/ui/popover/index.d.ts.map +1 -1
  58. package/dist/ui/popover/index.js +9 -9
  59. package/dist/ui/radioGroup/index.d.ts +4 -1
  60. package/dist/ui/radioGroup/index.d.ts.map +1 -1
  61. package/dist/ui/radioGroup/index.js +1 -1
  62. package/dist/ui/switch/index.d.ts +1 -1
  63. package/dist/ui/switch/index.d.ts.map +1 -1
  64. package/dist/ui/tabs/index.d.ts +4 -1
  65. package/dist/ui/tabs/index.d.ts.map +1 -1
  66. package/dist/ui/tabs/index.js +1 -1
  67. package/package.json +15 -11
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Devin Jameson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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://github.com/foldkit/foldkit#examples"><strong>Examples</strong></a> · <a href="https://foldkit.dev/getting-started"><strong>Getting Started</strong></a>
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
  ---
@@ -70,9 +70,11 @@ type Message = typeof Message.Type
70
70
  const update = (
71
71
  model: Model,
72
72
  message: Message,
73
- ): [Model, ReadonlyArray<Command.Command<Message>>] =>
73
+ ): readonly [Model, ReadonlyArray<Command.Command<Message>>] =>
74
74
  M.value(message).pipe(
75
- M.withReturnType<[Model, ReadonlyArray<Command.Command<Message>>]>(),
75
+ M.withReturnType<
76
+ readonly [Model, ReadonlyArray<Command.Command<Message>>]
77
+ >(),
76
78
  M.tagsExhaustive({
77
79
  ClickedDecrement: () => [{ count: model.count - 1 }, []],
78
80
  ClickedIncrement: () => [{ count: model.count + 1 }, []],
@@ -82,7 +84,7 @@ const update = (
82
84
 
83
85
  // INIT
84
86
 
85
- const init: Runtime.ElementInit<Model, Message> = () => [{ count: 0 }, []]
87
+ const init: Runtime.ProgramInit<Model, Message> = () => [{ count: 0 }, []]
86
88
 
87
89
  // VIEW
88
90
 
@@ -117,7 +119,7 @@ const buttonStyle = 'bg-black text-white hover:bg-gray-700 px-4 py-2 transition'
117
119
 
118
120
  // RUN
119
121
 
120
- const element = Runtime.makeElement({
122
+ const program = Runtime.makeProgram({
121
123
  Model,
122
124
  init,
123
125
  update,
@@ -125,7 +127,7 @@ const element = Runtime.makeElement({
125
127
  container: document.getElementById('root')!,
126
128
  })
127
129
 
128
- Runtime.run(element)
130
+ Runtime.run(program)
129
131
  ```
130
132
 
131
133
  Source: [examples/counter/src/main.ts](https://github.com/foldkit/foldkit/blob/main/examples/counter/src/main.ts)
@@ -141,7 +143,8 @@ Foldkit is a complete system, not a collection of libraries you stitch together.
141
143
  - **UI Components** — Dialog, menu, tabs, listbox, disclosure — fully accessible primitives that are easy to style and customize.
142
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.
143
145
  - **Virtual DOM** — Declarative Views powered by [Snabbdom](https://github.com/snabbdom/snabbdom). Fast, keyed diffing. Views are plain functions of your Model.
144
- - **DevTools** — Built-in overlay for inspecting Messages and Model state. Time-travel mode lets you jump to any point in your app's history.
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.
145
148
  - **HMR** — Vite plugin with state-preserving hot module replacement. Change your view, keep your state.
146
149
 
147
150
  ## Correctness You (And Your LLM) Can See
@@ -152,19 +155,20 @@ This is what makes Foldkit unusually AI-friendly. The same property that makes t
152
155
 
153
156
  ## Examples
154
157
 
155
- - **[Counter](https://github.com/foldkit/foldkit/blob/main/examples/counter/src/main.ts)** — Increment/decrement with reset
156
- - **[Todo](https://github.com/foldkit/foldkit/blob/main/examples/todo/src/main.ts)** — CRUD operations with localStorage persistence
157
- - **[Stopwatch](https://github.com/foldkit/foldkit/blob/main/examples/stopwatch/src/main.ts)** — Timer with start/stop/reset
158
- - **[Crash View](https://github.com/foldkit/foldkit/blob/main/examples/crash-view/src/main.ts)** — Custom crash fallback UI with crash reporting
159
- - **[Form](https://github.com/foldkit/foldkit/blob/main/examples/form/src/main.ts)** — Form validation with async email checking
160
- - **[Weather](https://github.com/foldkit/foldkit/blob/main/examples/weather/src/main.ts)** — HTTP requests with async state handling
161
- - **[Routing](https://github.com/foldkit/foldkit/blob/main/examples/routing/src/main.ts)** — URL routing with parser combinators
162
- - **[Query Sync](https://github.com/foldkit/foldkit/blob/main/examples/query-sync/src/main.ts)** — URL query parameter sync with filtering and sorting
163
- - **[Snake](https://github.com/foldkit/foldkit/blob/main/examples/snake/src/main.ts)** — Classic game built with Subscriptions
164
- - **[Auth](https://github.com/foldkit/foldkit/blob/main/examples/auth/src/main.ts)** — Authentication flow with Submodels and OutMessage
165
- - **[Shopping Cart](https://github.com/foldkit/foldkit/blob/main/examples/shopping-cart/src/main.ts)** — Nested models and complex state
166
- - **[WebSocket Chat](https://github.com/foldkit/foldkit/blob/main/examples/websocket-chat/src/main.ts)** — Managed Resources with WebSocket integration
167
- - **[Typing Game](https://github.com/foldkit/foldkit/tree/main/packages/typing-game)** — Multiplayer typing game with Effect RPC backend
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))
168
172
 
169
173
  ## License
170
174
 
@@ -12,16 +12,18 @@ export type Command<T, E = never, R = never> = [T] extends [Schema.Schema.Any] ?
12
12
  effect: Effect.Effect<T, E, R>;
13
13
  }>;
14
14
  /** A Command identity created with `Command.define`. Call with an Effect to create a Command. */
15
- export interface CommandDefinition<out Name extends string> {
15
+ export interface CommandDefinition<Name extends string, ResultMessage = any> {
16
16
  readonly [CommandDefinitionTypeId]: CommandDefinitionTypeId;
17
17
  readonly name: Name;
18
- <A, E, R>(effect: Effect.Effect<A, E, R>): Readonly<{
18
+ <CommandEffect extends Effect.Effect<ResultMessage, any, any>>(effect: CommandEffect): Readonly<{
19
19
  name: Name;
20
- effect: Effect.Effect<A, E, R>;
20
+ effect: CommandEffect;
21
21
  }>;
22
22
  }
23
- /** Defines a named Command identity. */
24
- export declare const define: <const Name extends string>(name: Name) => CommandDefinition<Name>;
23
+ /** Defines a named Command identity with the Messages it returns. */
24
+ export declare const define: {
25
+ <const Name extends string, Results extends ReadonlyArray<Schema.Schema.Any>>(name: Name, ...results: Results): CommandDefinition<Name, Schema.Schema.Type<Results[number]>>;
26
+ };
25
27
  /** Transforms the Effect inside a Command while preserving its name. */
26
28
  export declare const mapEffect: {
27
29
  <A, E, R, B>(f: (effect: Effect.Effect<A, E, R>) => Effect.Effect<B, E, R>): (command: Readonly<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEvC,qDAAqD;AAErD,eAAO,MAAM,uBAAuB,EAAE,OAAO,MAEN,CAAA;AAEvC,qDAAqD;AACrD,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAA;AAEpE,8CAA8C;AAC9C,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAC1E,QAAQ,CAAC;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CACnD,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CAC/B,CAAC,CAAA;AAEN,iGAAiG;AACjG,MAAM,WAAW,iBAAiB,CAAC,GAAG,CAAC,IAAI,SAAS,MAAM;IACxD,QAAQ,CAAC,CAAC,uBAAuB,CAAC,EAAE,uBAAuB,CAAA;IAC3D,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACN,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC7B,QAAQ,CAAC;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CA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AAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GAChE,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;KAAE,CAAC,CAAA;CAQI,CAAA"}
@@ -1,8 +1,8 @@
1
1
  /** Type-level brand for CommandDefinition values. */
2
2
  /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
3
3
  export const CommandDefinitionTypeId = Symbol.for('foldkit/CommandDefinition');
4
- /** Defines a named Command identity. */
5
- export const define = (name) => {
4
+ /** Defines a named Command identity with the Messages it returns. */
5
+ export const define = (name, ..._results) => {
6
6
  const create = (effect) => ({
7
7
  name,
8
8
  effect,
@@ -1,5 +1,38 @@
1
- import { Effect, Option } from 'effect';
1
+ import { Effect, HashSet, Option } from 'effect';
2
+ import * as Command from '../command';
2
3
  import type { DevtoolsMode, DevtoolsPosition } from '../runtime/runtime';
3
4
  import { type DevtoolsStore } from './store';
5
+ export declare const JumpTo: Command.CommandDefinition<"JumpTo", {
6
+ readonly _tag: "CompletedJump";
7
+ }>;
8
+ export declare const InspectState: Command.CommandDefinition<"InspectState", {
9
+ readonly _tag: "ReceivedInspectedState";
10
+ readonly model: unknown;
11
+ readonly changedPaths: HashSet.HashSet<string>;
12
+ readonly affectedPaths: HashSet.HashSet<string>;
13
+ readonly maybeMessage: Option.Option<unknown>;
14
+ }>;
15
+ export declare const InspectLatest: Command.CommandDefinition<"InspectLatest", {
16
+ readonly _tag: "ReceivedInspectedState";
17
+ readonly model: unknown;
18
+ readonly changedPaths: HashSet.HashSet<string>;
19
+ readonly affectedPaths: HashSet.HashSet<string>;
20
+ readonly maybeMessage: Option.Option<unknown>;
21
+ }>;
22
+ export declare const Resume: Command.CommandDefinition<"Resume", {
23
+ readonly _tag: "CompletedResume";
24
+ }>;
25
+ export declare const Clear: Command.CommandDefinition<"Clear", {
26
+ readonly _tag: "CompletedClear";
27
+ }>;
28
+ export declare const LockScroll: Command.CommandDefinition<"LockScroll", {
29
+ readonly _tag: "LockedScroll";
30
+ }>;
31
+ export declare const UnlockScroll: Command.CommandDefinition<"UnlockScroll", {
32
+ readonly _tag: "UnlockedScroll";
33
+ }>;
34
+ export declare const ScrollToTop: Command.CommandDefinition<"ScrollToTop", {
35
+ readonly _tag: "ScrolledToTop";
36
+ }>;
4
37
  export declare const createOverlay: (store: DevtoolsStore, position: DevtoolsPosition, mode: DevtoolsMode, maybeBanner: Option.Option<string>) => Effect.Effect<void, never, never>;
5
38
  //# sourceMappingURL=overlay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/devtools/overlay.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,MAAM,EAIN,MAAM,EAQP,MAAM,QAAQ,CAAA;AAOf,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAMxE,OAAO,EAAE,KAAK,aAAa,EAA+B,MAAM,SAAS,CAAA;AAszCzE,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,UAAU,gBAAgB,EAC1B,MAAM,YAAY,EAClB,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,sCA4ChC,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"}
@@ -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 { makeElement } from '../runtime/runtime';
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,
@@ -174,14 +178,14 @@ const computeDiff = (previous, current) => {
174
178
  };
175
179
  };
176
180
  // UPDATE
177
- const JumpTo = Command.define('JumpTo');
178
- const InspectState = Command.define('InspectState');
179
- const InspectLatest = Command.define('InspectLatest');
180
- const Resume = Command.define('Resume');
181
- const Clear = Command.define('Clear');
182
- const LockScroll = Command.define('LockScroll');
183
- const UnlockScroll = Command.define('UnlockScroll');
184
- const ScrollToTop = Command.define('ScrollToTop');
181
+ export const JumpTo = Command.define('JumpTo', CompletedJump);
182
+ export const InspectState = Command.define('InspectState', ReceivedInspectedState);
183
+ export const InspectLatest = Command.define('InspectLatest', ReceivedInspectedState);
184
+ export const Resume = Command.define('Resume', CompletedResume);
185
+ export const Clear = Command.define('Clear', CompletedClear);
186
+ export const LockScroll = Command.define('LockScroll', LockedScroll);
187
+ export const UnlockScroll = Command.define('UnlockScroll', UnlockedScroll);
188
+ export const ScrollToTop = Command.define('ScrollToTop', ScrolledToTop);
185
189
  const makeUpdate = (store, shadow, mode) => {
186
190
  const jumpTo = (index) => JumpTo(Effect.gen(function* () {
187
191
  yield* store.jumpTo(index);
@@ -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 = ['Model', 'Message'];
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 inspectorTabContent = (model, tab, inspectedModel) => M.value(tab).pipe(M.when('Model', () => modelTabContent(model, inspectedModel)), M.when('Message', () => messageTabContent(model)), M.exhaustive);
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 = makeElement({
766
+ const overlayRuntime = makeProgram({
738
767
  Model,
739
768
  Flags,
740
769
  flags,
@@ -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
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K,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC1D,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3E,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1B,QAAQ,EAAE,eAAe,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;CACtD,CAAC,CAAA"}
@@ -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,46 +1,54 @@
1
1
  import { Predicate, Schema as S } from 'effect';
2
- /** Creates a tagged union of field states (`NotValidated`, `Validating`, `Valid`, `Invalid`) for a given value schema. */
3
- export declare const makeField: <A, I>(value: S.Schema<A, I>) => {
4
- NotValidated: import("../schema").CallableTaggedStruct<"NotValidated", {
5
- value: S.Schema<A, I, never>;
2
+ import { CallableTaggedStruct } from '../schema';
3
+ /** A tagged union of field states for use with form validation. */
4
+ export type Field<A, I> = Readonly<{
5
+ NotValidated: CallableTaggedStruct<'NotValidated', {
6
+ value: S.Schema<A, I>;
6
7
  }>;
7
- Validating: import("../schema").CallableTaggedStruct<"Validating", {
8
- value: S.Schema<A, I, never>;
8
+ Validating: CallableTaggedStruct<'Validating', {
9
+ value: S.Schema<A, I>;
9
10
  }>;
10
- Valid: import("../schema").CallableTaggedStruct<"Valid", {
11
- value: S.Schema<A, I, never>;
11
+ Valid: CallableTaggedStruct<'Valid', {
12
+ value: S.Schema<A, I>;
12
13
  }>;
13
- Invalid: import("../schema").CallableTaggedStruct<"Invalid", {
14
- value: S.Schema<A, I, never>;
14
+ Invalid: CallableTaggedStruct<'Invalid', {
15
+ value: S.Schema<A, I>;
15
16
  errors: S.NonEmptyArray<typeof S.String>;
16
17
  }>;
17
- Union: S.Union<[import("../schema").CallableTaggedStruct<"NotValidated", {
18
- value: S.Schema<A, I, never>;
19
- }>, import("../schema").CallableTaggedStruct<"Validating", {
20
- value: S.Schema<A, I, never>;
21
- }>, import("../schema").CallableTaggedStruct<"Valid", {
22
- value: S.Schema<A, I, never>;
23
- }>, import("../schema").CallableTaggedStruct<"Invalid", {
24
- value: S.Schema<A, I, never>;
25
- errors: S.NonEmptyArray<typeof S.String>;
26
- }>]>;
27
- validate: (fieldValidations: ReadonlyArray<Validation<A>>) => (fieldValue: A) => {
28
- readonly _tag: "Valid";
29
- readonly value: A;
30
- } | {
31
- readonly _tag: "Invalid";
32
- readonly value: A;
33
- readonly errors: readonly [string, ...string[]];
34
- };
35
- validateAll: (fieldValidations: ReadonlyArray<Validation<A>>) => (fieldValue: A) => {
36
- readonly _tag: "Valid";
37
- readonly value: A;
38
- } | {
39
- readonly _tag: "Invalid";
40
- readonly value: A;
41
- readonly errors: readonly [string, ...string[]];
42
- };
43
- };
18
+ Union: S.Union<[
19
+ CallableTaggedStruct<'NotValidated', {
20
+ value: S.Schema<A, I>;
21
+ }>,
22
+ CallableTaggedStruct<'Validating', {
23
+ value: S.Schema<A, I>;
24
+ }>,
25
+ CallableTaggedStruct<'Valid', {
26
+ value: S.Schema<A, I>;
27
+ }>,
28
+ CallableTaggedStruct<'Invalid', {
29
+ value: S.Schema<A, I>;
30
+ errors: S.NonEmptyArray<typeof S.String>;
31
+ }>
32
+ ]>;
33
+ validate: (fieldValidations: ReadonlyArray<Validation<A>>) => (fieldValue: A) => Readonly<{
34
+ _tag: 'Valid';
35
+ value: A;
36
+ }> | Readonly<{
37
+ _tag: 'Invalid';
38
+ value: A;
39
+ errors: readonly [string, ...Array<string>];
40
+ }>;
41
+ validateAll: (fieldValidations: ReadonlyArray<Validation<A>>) => (fieldValue: A) => Readonly<{
42
+ _tag: 'Valid';
43
+ value: A;
44
+ }> | Readonly<{
45
+ _tag: 'Invalid';
46
+ value: A;
47
+ errors: readonly [string, ...Array<string>];
48
+ }>;
49
+ }>;
50
+ /** Creates a tagged union of field states (`NotValidated`, `Validating`, `Valid`, `Invalid`) for a given value schema. */
51
+ export declare const makeField: <A, I>(value: S.Schema<A, I>) => Field<A, I>;
44
52
  /** An error message for a validation rule — either a static string or a function that receives the invalid value. */
45
53
  export type ValidationMessage<T> = string | ((value: T) => string);
46
54
  /** A tuple of a predicate and error message used for field validation. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fieldValidation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT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UAAU,iBAAiB,CAAC,MAAM,CAAC,KAClC,UAAU,CAAC,MAAM,CAMnB,CAAA;AAED,2EAA2E;AAC3E,eAAO,MAAM,QAAQ,GACnB,UAAS,iBAAiB,CAAC,MAAM,CAAsB,KACtD,UAAU,CAAC,MAAM,CAAsC,CAAA;AAE1D,yEAAyE;AACzE,eAAO,MAAM,WAAW,GACtB,UAAS,iBAAiB,CAAC,MAAM,CAA0B,KAC1D,UAAU,CAAC,MAAM,CAA+C,CAAA;AAEnE,kFAAkF;AAClF,eAAO,MAAM,OAAO,GAClB,UAAS,iBAAiB,CAAC,MAAM,CAA4B,KAC5D,UAAU,CAAC,MAAM,CAAgD,CAAA;AAIpE,kGAAkG;AAClG,eAAO,MAAM,KAAK,GAChB,QAAQ,aAAa,CAAC,MAAM,CAAC,EAC7B,UAAU,iBAAiB,CAAC,MAAM,CAAC,KAClC,UAAU,CAAC,MAAM,CAMnB,CAAA"}
@@ -1,3 +1,3 @@
1
1
  export { makeField, required, minLength, maxLength, pattern, email, url, startsWith, endsWith, includes, equals, min, max, between, positive, nonNegative, integer, oneOf, } from './index';
2
- export type { Validation, ValidationMessage } from './index';
2
+ export type { Field, Validation, ValidationMessage } from './index';
3
3
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/fieldValidation/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EACL,GAAG,EACH,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,GAAG,EACH,GAAG,EACH,OAAO,EACP,QAAQ,EACR,WAAW,EACX,OAAO,EACP,KAAK,GACN,MAAM,SAAS,CAAA;AAEhB,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/fieldValidation/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EACL,GAAG,EACH,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,GAAG,EACH,GAAG,EACH,OAAO,EACP,QAAQ,EACR,WAAW,EACX,OAAO,EACP,KAAK,GACN,MAAM,SAAS,CAAA;AAEhB,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA"}
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * as Schema from './schema/public';
10
10
  export * as Struct from './struct/public';
11
11
  export * as Subscription from './subscription/public';
12
12
  export * as Task from './task/public';
13
+ export * as Test from './test/public';
13
14
  export * as Ui from './ui';
14
15
  export * as Url from './url/public';
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,MAAM,CAAA;AAC1B,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,MAAM,CAAA;AAC1B,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -10,5 +10,6 @@ export * as Schema from './schema/public';
10
10
  export * as Struct from './struct/public';
11
11
  export * as Subscription from './subscription/public';
12
12
  export * as Task from './task/public';
13
+ export * as Test from './test/public';
13
14
  export * as Ui from './ui';
14
15
  export * as Url from './url/public';
@@ -1,5 +1,5 @@
1
1
  import { Queue } from 'effect';
2
- import { BrowserConfig } from './runtime';
3
- export declare const addNavigationEventListeners: <Message>(messageQueue: Queue.Queue<Message>, browserConfig: BrowserConfig<Message>) => void;
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, browserConfig) => {
5
- addPopStateListener(messageQueue, browserConfig);
6
- addLinkClickListener(messageQueue, browserConfig);
7
- addProgrammaticNavigationListener(messageQueue, browserConfig);
4
+ export const addNavigationEventListeners = (messageQueue, routingConfig) => {
5
+ addPopStateListener(messageQueue, routingConfig);
6
+ addLinkClickListener(messageQueue, routingConfig);
7
+ addProgrammaticNavigationListener(messageQueue, routingConfig);
8
8
  };
9
- const addPopStateListener = (messageQueue, browserConfig) => {
9
+ const addPopStateListener = (messageQueue, routingConfig) => {
10
10
  const onPopState = () => {
11
- Queue.unsafeOffer(messageQueue, browserConfig.onUrlChange(locationToUrl()));
11
+ Queue.unsafeOffer(messageQueue, routingConfig.onUrlChange(locationToUrl()));
12
12
  };
13
13
  window.addEventListener('popstate', onPopState);
14
14
  };
15
- const addLinkClickListener = (messageQueue, browserConfig) => {
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, browserConfig.onUrlRequest(External({ href })));
34
+ Queue.unsafeOffer(messageQueue, routingConfig.onUrlRequest(External({ href })));
35
35
  return;
36
36
  }
37
- Queue.unsafeOffer(messageQueue, browserConfig.onUrlRequest(Internal({ url: urlToFoldkitUrl(linkUrl) })));
37
+ Queue.unsafeOffer(messageQueue, routingConfig.onUrlRequest(Internal({ url: urlToFoldkitUrl(linkUrl) })));
38
38
  };
39
39
  document.addEventListener('click', onLinkClick);
40
40
  };
41
- const addProgrammaticNavigationListener = (messageQueue, browserConfig) => {
41
+ const addProgrammaticNavigationListener = (messageQueue, routingConfig) => {
42
42
  const onProgrammaticNavigation = () => {
43
- Queue.unsafeOffer(messageQueue, browserConfig.onUrlChange(locationToUrl()));
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,IA4LF,CAAA"}
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"}